Skip to content

Commit

Permalink
feat: [internal-r7] fix priceLimit check
Browse files Browse the repository at this point in the history
  • Loading branch information
chefburger committed Sep 3, 2024
1 parent df0b7a4 commit ece44ef
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerBytecodeSize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21241
21242
Original file line number Diff line number Diff line change
@@ -1 +1 @@
131781
131784
Original file line number Diff line number Diff line change
@@ -1 +1 @@
164345
164348
Original file line number Diff line number Diff line change
@@ -1 +1 @@
149798
149801
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#swap_simple.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
72390
72393
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#swap_withHooks.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
88676
88679
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#swap_withNative.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
72393
72396
4 changes: 3 additions & 1 deletion src/pool-cl/libraries/CLPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,11 @@ library CLPool {
uint160 sqrtPriceLimitX96 = params.sqrtPriceLimitX96;

// check price limit
// Swaps can never occur at MIN_TICK, only at MIN_TICK + 1, except at initialization of a pool
// Under certain circumstances outlined below, the tick will preemptively reach MIN_TICK without swapping there
if (
zeroForOne
? (sqrtPriceLimitX96 >= slot0Start.sqrtPriceX96 || sqrtPriceLimitX96 < TickMath.MIN_SQRT_RATIO)
? (sqrtPriceLimitX96 >= slot0Start.sqrtPriceX96 || sqrtPriceLimitX96 <= TickMath.MIN_SQRT_RATIO)
: (sqrtPriceLimitX96 <= slot0Start.sqrtPriceX96 || sqrtPriceLimitX96 >= TickMath.MAX_SQRT_RATIO)
) {
revert InvalidSqrtPriceLimit(slot0Start.sqrtPriceX96, sqrtPriceLimitX96);
Expand Down

0 comments on commit ece44ef

Please sign in to comment.