From d3bb7d6d4e0353c895af15a83af002a50e68f3b2 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sun, 19 May 2024 18:42:00 -0700 Subject: [PATCH] sys-lend: skip rebalance if source and destination pools are the same --- src/bin/sys-lend.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bin/sys-lend.rs b/src/bin/sys-lend.rs index b5534d3..aca47c2 100644 --- a/src/bin/sys-lend.rs +++ b/src/bin/sys-lend.rs @@ -555,10 +555,16 @@ async fn main() -> Result<(), Box> { let ops = match cmd { Command::Deposit => vec![(Operation::Deposit, deposit_pool)], Command::Withdraw => vec![(Operation::Withdraw, withdraw_pool)], - Command::Rebalance => vec![ - (Operation::Withdraw, withdraw_pool), - (Operation::Deposit, deposit_pool), - ], + Command::Rebalance => { + if withdraw_pool == deposit_pool { + println!("Nothing to rebalance"); + return Ok(()); + } + vec![ + (Operation::Withdraw, withdraw_pool), + (Operation::Deposit, deposit_pool), + ] + } }; let mut instructions = vec![];