@@ -139,6 +139,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
139
139
. possible_values ( & pools)
140
140
. help ( "Lending pool to withdraw from. If multiple pools are provided, the pool with the lowest APY is selected" ) ,
141
141
)
142
+ . arg (
143
+ Arg :: with_name ( "skip_withdraw_if_only_one_pool_remains" )
144
+ . long ( "skip-if-only-one-pool-remains" )
145
+ . takes_value ( false )
146
+ . help ( "Do not withdraw if only one lending pool remains" ) ,
147
+ )
142
148
. arg (
143
149
Arg :: with_name ( "signer" )
144
150
. value_name ( "KEYPAIR" )
@@ -303,6 +309,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
303
309
let ( signer, address) = signer_of ( matches, "signer" , & mut wallet_manager) ?;
304
310
let address = address. expect ( "address" ) ;
305
311
let signer = signer. expect ( "signer" ) ;
312
+ let skip_withdraw_if_only_one_pool_remains =
313
+ matches. is_present ( "skip_withdraw_if_only_one_pool_remains" ) ;
306
314
307
315
let token = MaybeToken :: from ( value_t ! ( matches, "token" , Token ) . ok ( ) ) ;
308
316
let pools = values_t_or_exit ! ( matches, "pool" , String ) ;
@@ -360,6 +368,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
360
368
return Err ( "No available pools" . into ( ) ) ;
361
369
}
362
370
371
+ if skip_withdraw_if_only_one_pool_remains && pools. len ( ) == 1 {
372
+ println ! ( "Taking no action due to --skip-if-only-one-pool-remains flag" ) ;
373
+ return Ok ( ( ) ) ;
374
+ }
375
+
363
376
let ordering = if op == Operation :: Deposit {
364
377
std:: cmp:: Ordering :: Less
365
378
} else {
0 commit comments