Skip to content

Commit 32a9ff3

Browse files
committed
sys-lend: add --retain option to withdraw
1 parent f4e9d3b commit 32a9ff3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/bin/sys-lend.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
741741
.value_name("AMOUNT")
742742
.takes_value(true)
743743
.validator(is_amount)
744-
.help("Amount of tokens to always leave in Wallet regardless of requested deposit AMOUNT \
744+
.help("Amount of tokens to always leave in the wallet regardless of requested deposit AMOUNT \
745745
[default: 0.01 for SOL, 0.0 for all other tokens]"),
746746
)
747747
.arg(
@@ -789,6 +789,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
789789
.default_value("0.0")
790790
.help("Do not withdraw if AMOUNT is less than this value")
791791
)
792+
.arg(
793+
Arg::with_name("retain_ui_amount")
794+
.long("retain")
795+
.value_name("AMOUNT")
796+
.takes_value(true)
797+
.validator(is_amount)
798+
.default_value("0.0")
799+
.help("Amount of tokens to always leave in the pool regardless of requested withdrawal AMOUNT"),
800+
)
792801
.arg(
793802
Arg::with_name("token")
794803
.value_name("TOKEN")
@@ -1286,7 +1295,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
12861295
assert_eq!(maximum_amount, None); // --maximum_amount is only supported by Rebalance
12871296

12881297
for pool in &pools {
1289-
let withdraw_pool_available_balance = supply_balance.get(pool).unwrap().2;
1298+
let withdraw_pool_available_balance = supply_balance
1299+
.get(pool)
1300+
.unwrap()
1301+
.2
1302+
.saturating_sub(retain_amount);
12901303

12911304
let requested_amount = match requested_amount {
12921305
u64::MAX => {

0 commit comments

Comments
 (0)