Skip to content

Commit e530b52

Browse files
crispheaneyharsh4786
authored andcommitted
program: add invariant for max in amount for if swap (drift-labs#1825)
1 parent 25b818a commit e530b52

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

programs/drift/src/controller/insurance.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,14 @@ pub fn handle_if_end_swap(
10981098
if_rebalance_config.epoch_max_in_amount
10991099
)?;
11001100

1101+
validate!(
1102+
if_rebalance_config.current_in_amount <= if_rebalance_config.total_in_amount,
1103+
ErrorCode::InvalidIfRebalanceSwap,
1104+
"current_in_amount={} > total_in_amount={}",
1105+
if_rebalance_config.current_in_amount,
1106+
if_rebalance_config.total_in_amount
1107+
)?;
1108+
11011109
let oracle_twap = out_spot_market
11021110
.historical_oracle_data
11031111
.last_oracle_price_twap;

0 commit comments

Comments
 (0)