Skip to content

Commit

Permalink
Merge pull request invariant-labs#21 from invariant-labs/checked_cros…
Browse files Browse the repository at this point in the history
…s_tick

Use checked_cross_tick version
  • Loading branch information
wojciech-cichocki authored Apr 3, 2024
2 parents e0e0d11 + af2ba35 commit 8e3f3c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,11 @@ impl JupiterInvariant {

// crossing tick
if !x_to_y || is_enough_amount_to_cross {
cross_tick(&mut tick, pool)
.map_err(|_| "Internal Invariant Error: Cross tick".to_string())?;
let cross_tick_result = cross_tick(&mut tick, pool);
if cross_tick_result.is_err() {
global_insufficient_liquidity = true;
break;
}
crossed_ticks.push(tick.index);
} else if !remaining_amount.is_zero() {
total_amount_in += remaining_amount;
Expand Down

0 comments on commit 8e3f3c4

Please sign in to comment.