diff --git a/src/bin/sys-lend.rs b/src/bin/sys-lend.rs index 263c59b..44dbec4 100644 --- a/src/bin/sys-lend.rs +++ b/src/bin/sys-lend.rs @@ -139,6 +139,12 @@ async fn main() -> Result<(), Box> { .possible_values(&pools) .help("Lending pool to withdraw from. If multiple pools are provided, the pool with the lowest APY is selected"), ) + .arg( + Arg::with_name("skip_withdraw_if_only_one_pool_remains") + .long("skip-if-only-one-pool-remains") + .takes_value(false) + .help("Do not withdraw if only one lending pool remains"), + ) .arg( Arg::with_name("signer") .value_name("KEYPAIR") @@ -303,6 +309,7 @@ async fn main() -> Result<(), Box> { let (signer, address) = signer_of(matches, "signer", &mut wallet_manager)?; let address = address.expect("address"); let signer = signer.expect("signer"); + let skip_withdraw_if_only_one_pool_remains = matches.is_present("skip_withdraw_if_only_one_pool_remains"); let token = MaybeToken::from(value_t!(matches, "token", Token).ok()); let pools = values_t_or_exit!(matches, "pool", String); @@ -360,6 +367,11 @@ async fn main() -> Result<(), Box> { return Err("No available pools".into()); } + if skip_withdraw_if_only_one_pool_remains && pools.len() == 1 { + println!("Taking no action due to --skip-if-only-one-pool-remains flag"); + return Ok(()); + } + let ordering = if op == Operation::Deposit { std::cmp::Ordering::Less } else {