Skip to content

Commit 5dfba00

Browse files
committed
Exit early if there are no tokens to deposit
1 parent ce3b589 commit 5dfba00

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/bin/sys-lend.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
352352
amount => token.amount(amount.parse::<f64>().unwrap()),
353353
};
354354

355-
if op == Operation::Deposit && amount > token_balance {
356-
return Err(format!(
357-
"Deposit amount of {} is greater than current balance of {}",
358-
token.format_amount(amount),
359-
token.format_amount(token_balance),
360-
)
361-
.into());
355+
if op == Operation::Deposit {
356+
if amount > token_balance {
357+
return Err(format!(
358+
"Deposit amount of {} is greater than current balance of {}",
359+
token.format_amount(amount),
360+
token.format_amount(token_balance),
361+
)
362+
.into());
363+
}
364+
if amount == 0 {
365+
println!("Nothing to deposit");
366+
return Ok(());
367+
}
362368
}
363369

364370
for pool in &pools {

0 commit comments

Comments
 (0)