Skip to content

Commit 879416a

Browse files
committed
sys-lend: add --skip-if-only-one-pool-remains flag to withdraw
1 parent f3eb7e4 commit 879416a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/bin/sys-lend.rs

+13
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
139139
.possible_values(&pools)
140140
.help("Lending pool to withdraw from. If multiple pools are provided, the pool with the lowest APY is selected"),
141141
)
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+
)
142148
.arg(
143149
Arg::with_name("signer")
144150
.value_name("KEYPAIR")
@@ -303,6 +309,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
303309
let (signer, address) = signer_of(matches, "signer", &mut wallet_manager)?;
304310
let address = address.expect("address");
305311
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");
306314

307315
let token = MaybeToken::from(value_t!(matches, "token", Token).ok());
308316
let pools = values_t_or_exit!(matches, "pool", String);
@@ -360,6 +368,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
360368
return Err("No available pools".into());
361369
}
362370

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+
363376
let ordering = if op == Operation::Deposit {
364377
std::cmp::Ordering::Less
365378
} else {

0 commit comments

Comments
 (0)