Skip to content

Commit

Permalink
Spearbit 105 (Uniswap#870)
Browse files Browse the repository at this point in the history
  • Loading branch information
hensha256 authored Sep 5, 2024
1 parent ec70076 commit ce82aa5
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
144608
144627
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity CA fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
170897
170916
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
274175
274194
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
135101
135120
Original file line number Diff line number Diff line change
@@ -1 +1 @@
292800
292819
2 changes: 1 addition & 1 deletion .forge-snapshots/poolManager bytecode size.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24006
24044
Original file line number Diff line number Diff line change
@@ -1 +1 @@
98819
98838
2 changes: 1 addition & 1 deletion .forge-snapshots/simple addLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
161364
161383
2 changes: 1 addition & 1 deletion src/libraries/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ library Pool {
// tick spacing will never be 0 since TickMath.MIN_TICK_SPACING is 1
assembly ("memory-safe") {
tickSpacing := signextend(2, tickSpacing)
let minTick := sdiv(MIN_TICK, tickSpacing)
let minTick := sub(sdiv(MIN_TICK, tickSpacing), slt(smod(MIN_TICK, tickSpacing), 0))
let maxTick := sdiv(MAX_TICK, tickSpacing)
let numTicks := add(sub(maxTick, minTick), 1)
result := div(sub(shl(128, 1), 1), numTicks)
Expand Down
10 changes: 5 additions & 5 deletions test/Tick.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,21 @@ contract TickTest is Test, GasSnapshot {
function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForLowFee() public pure {
uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(LOW_TICK_SPACING);

assertEq(maxLiquidityPerTick, 1917569901783203986719870431555990);
assertEq(maxLiquidityPerTick, 1917559095893846719543856547154045);
checkCantOverflow(LOW_TICK_SPACING, maxLiquidityPerTick);
}

function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMediumFee() public pure {
uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(MEDIUM_TICK_SPACING);

assertEq(maxLiquidityPerTick, 11505743598341114571880798222544994);
assertEq(maxLiquidityPerTick, 11505354575363080317263139282924270);
checkCantOverflow(MEDIUM_TICK_SPACING, maxLiquidityPerTick);
}

function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForHighFee() public pure {
uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(HIGH_TICK_SPACING);

assertEq(maxLiquidityPerTick, 38350317471085141830651933667504588);
assertEq(maxLiquidityPerTick, 38345995821606768476828330790147420);
checkCantOverflow(HIGH_TICK_SPACING, maxLiquidityPerTick);
}

Expand All @@ -144,7 +144,7 @@ contract TickTest is Test, GasSnapshot {
function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMaxTickSpacing() public pure {
uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(TickMath.MAX_TICK_SPACING);

assertEq(maxLiquidityPerTick, 6186952125835244790243174680577603844);
assertEq(maxLiquidityPerTick, 6076470837873901133274546561281575204);
checkCantOverflow(TickMath.MAX_TICK_SPACING, maxLiquidityPerTick);
}

Expand All @@ -158,7 +158,7 @@ contract TickTest is Test, GasSnapshot {
function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor2302() public pure {
uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(2302);

assertEq(maxLiquidityPerTick, 441351967472034323558203122479595605);
assertEq(maxLiquidityPerTick, 440780268032303709149448973357212709);
checkCantOverflow(2302, maxLiquidityPerTick);
}

Expand Down
4 changes: 2 additions & 2 deletions test/libraries/Pool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ contract PoolTest is Test, GasSnapshot {
int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing;
int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing;
uint24 numTicks = uint24((maxTick - minTick) / tickSpacing) + 1;
// assert that the result is the same as the v3 math
assertEq(type(uint128).max / numTicks, Pool.tickSpacingToMaxLiquidityPerTick(tickSpacing));
// assert that the result is the same as the v3 math or lower
assertGe(type(uint128).max / numTicks, Pool.tickSpacingToMaxLiquidityPerTick(tickSpacing));
}
}

0 comments on commit ce82aa5

Please sign in to comment.