From e43f11ed96d2771930a28aea58f9c7027241a2e4 Mon Sep 17 00:00:00 2001 From: Hyunchel Kim Date: Sat, 14 Oct 2023 20:48:30 -0400 Subject: [PATCH 1/6] Set tick spacing range as constants While tick and tick spacing both use int24 as their type, each has a different range. Tick spacing has a range of [1, 32767]. This commit updates Tick test cases to use proper tick spacing range instead that of tick. Resolves issue #371 --- test/foundry-tests/Pool.t.sol | 9 +++++---- test/foundry-tests/Tick.t.sol | 24 +++++++++++------------- test/foundry-tests/utils/Constants.sol | 3 +++ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/test/foundry-tests/Pool.t.sol b/test/foundry-tests/Pool.t.sol index 1e50e4cbe..e7552fc56 100644 --- a/test/foundry-tests/Pool.t.sol +++ b/test/foundry-tests/Pool.t.sol @@ -8,6 +8,7 @@ import {PoolManager} from "../../contracts/PoolManager.sol"; import {Position} from "../../contracts/libraries/Position.sol"; import {TickMath} from "../../contracts/libraries/TickMath.sol"; import {TickBitmap} from "../../contracts/libraries/TickBitmap.sol"; +import {Constants} from "./utils/Constants.sol"; contract PoolTest is Test { using Pool for Pool.State; @@ -40,8 +41,8 @@ contract PoolTest is Test { function testModifyPosition(uint160 sqrtPriceX96, Pool.ModifyPositionParams memory params) public { // Assumptions tested in PoolManager.t.sol - vm.assume(params.tickSpacing > 0); - vm.assume(params.tickSpacing < 32768); + vm.assume(params.tickSpacing >= Constants.MIN_TICK_SPACING); + vm.assume(params.tickSpacing <= Constants.MAX_TICK_SPACING); testPoolInitialize(sqrtPriceX96, 0, 0); @@ -73,8 +74,8 @@ contract PoolTest is Test { function testSwap(uint160 sqrtPriceX96, Pool.SwapParams memory params) public { // Assumptions tested in PoolManager.t.sol - vm.assume(params.tickSpacing > 0); - vm.assume(params.tickSpacing < 32768); + vm.assume(params.tickSpacing >= Constants.MIN_TICK_SPACING); + vm.assume(params.tickSpacing <= Constants.MAX_TICK_SPACING); vm.assume(params.fee < 1000000); testPoolInitialize(sqrtPriceX96, 0, 0); diff --git a/test/foundry-tests/Tick.t.sol b/test/foundry-tests/Tick.t.sol index aea6ea1d1..fe74c9a62 100644 --- a/test/foundry-tests/Tick.t.sol +++ b/test/foundry-tests/Tick.t.sol @@ -105,18 +105,18 @@ contract TickTest is Test, GasSnapshot { checkCantOverflow(HIGH_TICK_SPACING, maxLiquidityPerTick); } - function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor1() public { - uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(1); + function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMinTickSpacing() public { + uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(Constants.MIN_TICK_SPACING); assertEq(maxLiquidityPerTick, 191757530477355301479181766273477); // 126 bits - checkCantOverflow(1, maxLiquidityPerTick); + checkCantOverflow(Constants.MIN_TICK_SPACING, maxLiquidityPerTick); } - function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForEntireRange() public { - uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(887272); + function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMaxTickSpacing() public { + uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(Constants.MAX_TICK_SPACING); - assertEq(maxLiquidityPerTick, Constants.MAX_UINT128 / 3); // 126 bits - checkCantOverflow(887272, maxLiquidityPerTick); + assertEq(maxLiquidityPerTick, 6169404334338910476561253576012511949); + checkCantOverflow(Constants.MAX_TICK_SPACING, maxLiquidityPerTick); } function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor2302() public { @@ -128,7 +128,7 @@ contract TickTest is Test, GasSnapshot { function testTick_tickSpacingToMaxLiquidityPerTick_gasCostMinTickSpacing() public { snapStart("tickSpacingToMaxLiquidityPerTick_gasCostMinTickSpacing"); - tickSpacingToMaxLiquidityPerTick(1); + tickSpacingToMaxLiquidityPerTick(Constants.MIN_TICK_SPACING); snapEnd(); } @@ -139,10 +139,8 @@ contract TickTest is Test, GasSnapshot { } function testTick_tickSpacingToMaxLiquidityPerTick_gasCostMaxTickSpacing() public { - int24 MAX_TICK_SPACING = 32767; - snapStart("tickSpacingToMaxLiquidityPerTick_gasCostMaxTickSpacing"); - tickSpacingToMaxLiquidityPerTick(MAX_TICK_SPACING); + tickSpacingToMaxLiquidityPerTick(Constants.MAX_TICK_SPACING); snapEnd(); } @@ -455,8 +453,8 @@ contract TickTest is Test, GasSnapshot { } function testTick_tickSpacingToParametersInvariants_fuzz(int24 tickSpacing) public { - vm.assume(tickSpacing <= TickMath.MAX_TICK); - vm.assume(tickSpacing > 0); + vm.assume(tickSpacing <= Constants.MAX_TICK_SPACING); + vm.assume(tickSpacing >= Constants.MIN_TICK_SPACING); int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing; int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing; diff --git a/test/foundry-tests/utils/Constants.sol b/test/foundry-tests/utils/Constants.sol index cc34d170f..0951828b5 100644 --- a/test/foundry-tests/utils/Constants.sol +++ b/test/foundry-tests/utils/Constants.sol @@ -15,4 +15,7 @@ library Constants { int24 constant MIN_TICK = -887272; int24 constant MAX_TICK = 887272; + + int24 constant MIN_TICK_SPACING = 1; + int24 constant MAX_TICK_SPACING = type(int16).max; } From 4009909b3b27fb58fa80e3e294cad4e43ae651bf Mon Sep 17 00:00:00 2001 From: Hyunchel Kim Date: Wed, 1 Nov 2023 20:34:47 -0400 Subject: [PATCH 2/6] Restore a unit test on tick spacing liquidity This commit adds back the unit test that checks for tick spacing liquidity given the entire tick range as the input argument. This is an alternative change mentioned on the issue referred below. resolves #369 --- test/foundry-tests/Tick.t.sol | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/foundry-tests/Tick.t.sol b/test/foundry-tests/Tick.t.sol index fe74c9a62..2bdc12f80 100644 --- a/test/foundry-tests/Tick.t.sol +++ b/test/foundry-tests/Tick.t.sol @@ -119,6 +119,13 @@ contract TickTest is Test, GasSnapshot { checkCantOverflow(Constants.MAX_TICK_SPACING, maxLiquidityPerTick); } + function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForEntireRange() public { + uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(Constants.MAX_TICK); + + assertEq(maxLiquidityPerTick, type(uint128).max / 3); + checkCantOverflow(Constants.MAX_TICK, maxLiquidityPerTick); + } + function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor2302() public { uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(2302); From 0fd8f86b49e56222e790c31bf573e4d209bf0796 Mon Sep 17 00:00:00 2001 From: Hyunchel Kim Date: Fri, 3 Nov 2023 21:41:11 -0400 Subject: [PATCH 3/6] Remove duplicate constants from test suite This commit moves MIN_TICK, MAX_TICK, MIN_TICK_SPACING, and MAX_TICK_SPACING constants from test suite constants file to TickMath library. Previous to this commit, TickMath library declared MIN_TICK and MAX_TICK constants with the same value from the test suite constants file. Removing duplicate constants from the test file and referencing them from the production file prevents future dicrepancies between production and test environments. --- contracts/PoolManager.sol | 5 +++-- contracts/libraries/TickMath.sol | 5 +++++ test/foundry-tests/Pool.t.sol | 8 ++++---- test/foundry-tests/Tick.t.sol | 24 ++++++++++++------------ test/foundry-tests/utils/Constants.sol | 6 ------ 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/contracts/PoolManager.sol b/contracts/PoolManager.sol index 6e6ab8db2..fd930c374 100644 --- a/contracts/PoolManager.sol +++ b/contracts/PoolManager.sol @@ -9,6 +9,7 @@ import {FeeLibrary} from "./libraries/FeeLibrary.sol"; import {Currency, CurrencyLibrary} from "./types/Currency.sol"; import {PoolKey} from "./types/PoolKey.sol"; import {LockDataLibrary} from "./libraries/LockDataLibrary.sol"; +import {TickMath} from "./libraries/TickMath.sol"; import {NoDelegateCall} from "./NoDelegateCall.sol"; import {Owned} from "./Owned.sol"; import {IHooks} from "./interfaces/IHooks.sol"; @@ -34,10 +35,10 @@ contract PoolManager is IPoolManager, Fees, NoDelegateCall, ERC1155, IERC1155Rec using FeeLibrary for uint24; /// @inheritdoc IPoolManager - int24 public constant override MAX_TICK_SPACING = type(int16).max; + int24 public constant override MAX_TICK_SPACING = TickMath.MAX_TICK_SPACING; /// @inheritdoc IPoolManager - int24 public constant override MIN_TICK_SPACING = 1; + int24 public constant override MIN_TICK_SPACING = TickMath.MIN_TICK_SPACING; /// @inheritdoc IPoolManager IPoolManager.LockData public override lockData; diff --git a/contracts/libraries/TickMath.sol b/contracts/libraries/TickMath.sol index e716524ff..cd8e5cf01 100644 --- a/contracts/libraries/TickMath.sol +++ b/contracts/libraries/TickMath.sol @@ -15,6 +15,11 @@ library TickMath { /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; + /// @dev The minimum tick spacing value drawn from the range of type int16 that is greater than 0, i.e. min from the range [1, 32767] + int24 internal constant MIN_TICK_SPACING = 1; + /// @dev The maximum tick spacing value drawn from the range of type int16, i.e. max from the range [1, 32767] + int24 internal constant MAX_TICK_SPACING = type(int16).max; + /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) diff --git a/test/foundry-tests/Pool.t.sol b/test/foundry-tests/Pool.t.sol index 7f26a7cb9..8c5ee8630 100644 --- a/test/foundry-tests/Pool.t.sol +++ b/test/foundry-tests/Pool.t.sol @@ -43,8 +43,8 @@ contract PoolTest is Test { function testModifyPosition(uint160 sqrtPriceX96, Pool.ModifyPositionParams memory params) public { // Assumptions tested in PoolManager.t.sol - vm.assume(params.tickSpacing >= Constants.MIN_TICK_SPACING); - vm.assume(params.tickSpacing <= Constants.MAX_TICK_SPACING); + vm.assume(params.tickSpacing >= TickMath.MIN_TICK_SPACING); + vm.assume(params.tickSpacing <= TickMath.MAX_TICK_SPACING); testPoolInitialize(sqrtPriceX96, 0, 0, 0); @@ -76,8 +76,8 @@ contract PoolTest is Test { function testSwap(uint160 sqrtPriceX96, uint24 swapFee, Pool.SwapParams memory params) public { // Assumptions tested in PoolManager.t.sol - vm.assume(params.tickSpacing >= Constants.MIN_TICK_SPACING); - vm.assume(params.tickSpacing <= Constants.MAX_TICK_SPACING); + vm.assume(params.tickSpacing >= TickMath.MIN_TICK_SPACING); + vm.assume(params.tickSpacing <= TickMath.MAX_TICK_SPACING); vm.assume(swapFee < 1000000); testPoolInitialize(sqrtPriceX96, 0, 0, 0); diff --git a/test/foundry-tests/Tick.t.sol b/test/foundry-tests/Tick.t.sol index 2bdc12f80..57e1340a1 100644 --- a/test/foundry-tests/Tick.t.sol +++ b/test/foundry-tests/Tick.t.sol @@ -67,11 +67,11 @@ contract TickTest is Test, GasSnapshot { } function getMinTick(int24 tickSpacing) internal pure returns (int256) { - return (Constants.MIN_TICK / tickSpacing) * tickSpacing; + return (TickMath.MIN_TICK / tickSpacing) * tickSpacing; } function getMaxTick(int24 tickSpacing) internal pure returns (int256) { - return (Constants.MAX_TICK / tickSpacing) * tickSpacing; + return (TickMath.MAX_TICK / tickSpacing) * tickSpacing; } function checkCantOverflow(int24 tickSpacing, uint128 maxLiquidityPerTick) internal { @@ -106,24 +106,24 @@ contract TickTest is Test, GasSnapshot { } function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMinTickSpacing() public { - uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(Constants.MIN_TICK_SPACING); + uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(TickMath.MIN_TICK_SPACING); assertEq(maxLiquidityPerTick, 191757530477355301479181766273477); // 126 bits - checkCantOverflow(Constants.MIN_TICK_SPACING, maxLiquidityPerTick); + checkCantOverflow(TickMath.MIN_TICK_SPACING, maxLiquidityPerTick); } function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMaxTickSpacing() public { - uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(Constants.MAX_TICK_SPACING); + uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(TickMath.MAX_TICK_SPACING); assertEq(maxLiquidityPerTick, 6169404334338910476561253576012511949); - checkCantOverflow(Constants.MAX_TICK_SPACING, maxLiquidityPerTick); + checkCantOverflow(TickMath.MAX_TICK_SPACING, maxLiquidityPerTick); } function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForEntireRange() public { - uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(Constants.MAX_TICK); + uint128 maxLiquidityPerTick = tickSpacingToMaxLiquidityPerTick(TickMath.MAX_TICK); assertEq(maxLiquidityPerTick, type(uint128).max / 3); - checkCantOverflow(Constants.MAX_TICK, maxLiquidityPerTick); + checkCantOverflow(TickMath.MAX_TICK, maxLiquidityPerTick); } function testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor2302() public { @@ -135,7 +135,7 @@ contract TickTest is Test, GasSnapshot { function testTick_tickSpacingToMaxLiquidityPerTick_gasCostMinTickSpacing() public { snapStart("tickSpacingToMaxLiquidityPerTick_gasCostMinTickSpacing"); - tickSpacingToMaxLiquidityPerTick(Constants.MIN_TICK_SPACING); + tickSpacingToMaxLiquidityPerTick(TickMath.MIN_TICK_SPACING); snapEnd(); } @@ -147,7 +147,7 @@ contract TickTest is Test, GasSnapshot { function testTick_tickSpacingToMaxLiquidityPerTick_gasCostMaxTickSpacing() public { snapStart("tickSpacingToMaxLiquidityPerTick_gasCostMaxTickSpacing"); - tickSpacingToMaxLiquidityPerTick(Constants.MAX_TICK_SPACING); + tickSpacingToMaxLiquidityPerTick(TickMath.MAX_TICK_SPACING); snapEnd(); } @@ -460,8 +460,8 @@ contract TickTest is Test, GasSnapshot { } function testTick_tickSpacingToParametersInvariants_fuzz(int24 tickSpacing) public { - vm.assume(tickSpacing <= Constants.MAX_TICK_SPACING); - vm.assume(tickSpacing >= Constants.MIN_TICK_SPACING); + vm.assume(tickSpacing <= TickMath.MAX_TICK_SPACING); + vm.assume(tickSpacing >= TickMath.MIN_TICK_SPACING); int24 minTick = (TickMath.MIN_TICK / tickSpacing) * tickSpacing; int24 maxTick = (TickMath.MAX_TICK / tickSpacing) * tickSpacing; diff --git a/test/foundry-tests/utils/Constants.sol b/test/foundry-tests/utils/Constants.sol index 0951828b5..9a7a7a390 100644 --- a/test/foundry-tests/utils/Constants.sol +++ b/test/foundry-tests/utils/Constants.sol @@ -12,10 +12,4 @@ library Constants { uint256 constant MAX_UINT256 = type(uint256).max; uint128 constant MAX_UINT128 = type(uint128).max; uint160 constant MAX_UINT160 = type(uint160).max; - - int24 constant MIN_TICK = -887272; - int24 constant MAX_TICK = 887272; - - int24 constant MIN_TICK_SPACING = 1; - int24 constant MAX_TICK_SPACING = type(int16).max; } From cdd56e60296f073ae40b23257e621b486cfb5892 Mon Sep 17 00:00:00 2001 From: Hyunchel Kim Date: Fri, 3 Nov 2023 22:09:20 -0400 Subject: [PATCH 4/6] Remove unused import --- test/foundry-tests/Pool.t.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/test/foundry-tests/Pool.t.sol b/test/foundry-tests/Pool.t.sol index 8c5ee8630..c794707d2 100644 --- a/test/foundry-tests/Pool.t.sol +++ b/test/foundry-tests/Pool.t.sol @@ -8,7 +8,6 @@ import {PoolManager} from "../../contracts/PoolManager.sol"; import {Position} from "../../contracts/libraries/Position.sol"; import {TickMath} from "../../contracts/libraries/TickMath.sol"; import {TickBitmap} from "../../contracts/libraries/TickBitmap.sol"; -import {Constants} from "./utils/Constants.sol"; contract PoolTest is Test { using Pool for Pool.State; From 3f523f38865a4ea6425ad3ac7fd1f1c5f5b56f1f Mon Sep 17 00:00:00 2001 From: Hyunchel Kim Date: Tue, 14 Nov 2023 18:50:44 -0500 Subject: [PATCH 5/6] Remove unnecessary override keywords --- contracts/PoolManager.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/PoolManager.sol b/contracts/PoolManager.sol index fd930c374..782c370c7 100644 --- a/contracts/PoolManager.sol +++ b/contracts/PoolManager.sol @@ -35,10 +35,10 @@ contract PoolManager is IPoolManager, Fees, NoDelegateCall, ERC1155, IERC1155Rec using FeeLibrary for uint24; /// @inheritdoc IPoolManager - int24 public constant override MAX_TICK_SPACING = TickMath.MAX_TICK_SPACING; + int24 public constant MAX_TICK_SPACING = TickMath.MAX_TICK_SPACING; /// @inheritdoc IPoolManager - int24 public constant override MIN_TICK_SPACING = TickMath.MIN_TICK_SPACING; + int24 public constant MIN_TICK_SPACING = TickMath.MIN_TICK_SPACING; /// @inheritdoc IPoolManager IPoolManager.LockData public override lockData; From bf62527503aa1857301b41e0ee8c612cafcc10c5 Mon Sep 17 00:00:00 2001 From: Hyunchel Kim Date: Wed, 15 Nov 2023 15:24:35 -0500 Subject: [PATCH 6/6] Update forge snapshots --- .gas-snapshot | 107 +++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index f069fad0d..b2dafc174 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -6,15 +6,15 @@ ClaimsTest:testCatchesUnderflowOnBurn(uint256) (runs: 100, μ: 39932, ~: 40927) ClaimsTest:testCatchesUnderflowOnTransfer(uint256) (runs: 100, μ: 40057, ~: 41052) ClaimsTest:testTransferToClaimsContractFails() (gas: 36413) FeesTest:testCollectFees() (gas: 622560) -FeesTest:testHookWithdrawFeeProtocolWithdrawFee(uint16,uint16) (runs: 100, μ: 491589, ~: 495940) -FeesTest:testInitializeAllFees(uint16,uint16,uint16,uint16) (runs: 100, μ: 164500, ~: 161247) -FeesTest:testInitializeBothHookFee(uint16,uint16) (runs: 100, μ: 86164, ~: 93440) +FeesTest:testHookWithdrawFeeProtocolWithdrawFee(uint16,uint16) (runs: 100, μ: 489854, ~: 495940) +FeesTest:testInitializeAllFees(uint16,uint16,uint16,uint16) (runs: 100, μ: 164080, ~: 161213) +FeesTest:testInitializeBothHookFee(uint16,uint16) (runs: 100, μ: 85965, ~: 93440) FeesTest:testInitializeFailsNoHook() (gas: 20233) -FeesTest:testInitializeHookProtocolSwapFee(uint16,uint16) (runs: 100, μ: 127817, ~: 133651) +FeesTest:testInitializeHookProtocolSwapFee(uint16,uint16) (runs: 100, μ: 126882, ~: 133651) FeesTest:testInitializeHookSwapFee(uint16) (runs: 100, μ: 68614, ~: 70884) -FeesTest:testInitializeHookWithdrawFee(uint16) (runs: 100, μ: 68427, ~: 70924) +FeesTest:testInitializeHookWithdrawFee(uint16) (runs: 100, μ: 68200, ~: 70924) FeesTest:testInitializeWithSwapProtocolFeeAndHookFeeDifferentDirections() (gas: 584240) -FeesTest:testNoHookProtocolFee(uint16,uint16) (runs: 100, μ: 759115, ~: 765926) +FeesTest:testNoHookProtocolFee(uint16,uint16) (runs: 100, μ: 758142, ~: 765926) FeesTest:testProtocolFeeOnWithdrawalRemainsZeroIfNoHookWithdrawalFeeSet(uint16,uint16) (runs: 100, μ: 470360, ~: 472269) FeesTest:testProtocolSwapFeeAndHookSwapFeeSameDirection() (gas: 604631) FeesTest:testSwapWithProtocolFeeAllAndHookFeeAllButOnlySwapFlag() (gas: 643655) @@ -69,16 +69,16 @@ HooksTest:testValidateHookAddressBeforeInitialize(uint152) (runs: 100, μ: 1837, HooksTest:testValidateHookAddressBeforeInitializeAfterModify(uint152) (runs: 100, μ: 1784, ~: 1784) HooksTest:testValidateHookAddressBeforeModify(uint152) (runs: 100, μ: 1863, ~: 1863) HooksTest:testValidateHookAddressBeforeSwap(uint152) (runs: 100, μ: 1856, ~: 1856) -HooksTest:testValidateHookAddressFailsAllHooks(uint152,uint8) (runs: 100, μ: 4783, ~: 4729) -HooksTest:testValidateHookAddressFailsNoHooks(uint152,uint8) (runs: 100, μ: 4808, ~: 4776) +HooksTest:testValidateHookAddressFailsAllHooks(uint152,uint8) (runs: 100, μ: 4787, ~: 4729) +HooksTest:testValidateHookAddressFailsNoHooks(uint152,uint8) (runs: 100, μ: 4805, ~: 4729) HooksTest:testValidateHookAddressNoHooks(uint152) (runs: 100, μ: 1845, ~: 1845) LockersLibrary:testLockerLengthAndNonzeroDeltaCount() (gas: 52392) LockersLibrary:test_clear(address[]) (runs: 100, μ: 114024, ~: 111101) LockersLibrary:test_decrementNonzeroDeltaCount() (gas: 1157) -LockersLibrary:test_decrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 121857, ~: 45987) +LockersLibrary:test_decrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 121371, ~: 45330) LockersLibrary:test_getCurrentLocker_multipleAddressesFuzz(address[]) (runs: 100, μ: 273024, ~: 265967) LockersLibrary:test_incrementNonzeroDeltaCount() (gas: 807) -LockersLibrary:test_incrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 72656, ~: 27388) +LockersLibrary:test_incrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 72366, ~: 26996) LockersLibrary:test_pop() (gas: 1770) LockersLibrary:test_pop_multipleAddressesFuzz(address[]) (runs: 100, μ: 240601, ~: 234397) LockersLibrary:test_push() (gas: 1421) @@ -97,38 +97,38 @@ PoolManagerTest:test_collectProtocolFees_initializesWithProtocolFeeIfCalled() (g PoolManagerTest:test_collectProtocolFees_nativeToken_allowsOwnerToAccumulateFees_gas() (gas: 575330) PoolManagerTest:test_collectProtocolFees_nativeToken_returnsAllFeesIf0IsProvidedAsParameter() (gas: 542397) PoolManagerTest:test_donate_OneToken_gas() (gas: 452140) -PoolManagerTest:test_donate_failsIfNoLiquidity(uint160) (runs: 100, μ: 64520, ~: 64652) +PoolManagerTest:test_donate_failsIfNoLiquidity(uint160) (runs: 100, μ: 64518, ~: 64651) PoolManagerTest:test_donate_failsIfNotInitialized() (gas: 28042) PoolManagerTest:test_donate_failsWithIncorrectSelectors() (gas: 1420105) PoolManagerTest:test_donate_succeedsForNativeTokensWhenPoolHasLiquidity() (gas: 440700) PoolManagerTest:test_donate_succeedsWhenPoolHasLiquidity() (gas: 493156) PoolManagerTest:test_donate_succeedsWithCorrectSelectors() (gas: 1393184) PoolManagerTest:test_feeControllerSet() (gas: 39595) -PoolManagerTest:test_fetchFeeWhenController(uint160) (runs: 100, μ: 112676, ~: 112808) +PoolManagerTest:test_fetchFeeWhenController(uint160) (runs: 100, μ: 112707, ~: 112809) PoolManagerTest:test_getPosition() (gas: 366837) -PoolManagerTest:test_initialize((address,address,uint24,int24,address),uint160) (runs: 100, μ: 18620, ~: 13942) +PoolManagerTest:test_initialize((address,address,uint24,int24,address),uint160) (runs: 100, μ: 18626, ~: 13942) PoolManagerTest:test_initialize_failsIfTickSpaceNeg(uint160) (runs: 100, μ: 15866, ~: 15866) PoolManagerTest:test_initialize_failsIfTickSpaceTooLarge(uint160) (runs: 100, μ: 16790, ~: 16790) PoolManagerTest:test_initialize_failsIfTickSpaceZero(uint160) (runs: 100, μ: 15888, ~: 15888) PoolManagerTest:test_initialize_failsWithIncorrectSelectors() (gas: 984435) -PoolManagerTest:test_initialize_forNativeTokens(uint160) (runs: 100, μ: 59161, ~: 59445) +PoolManagerTest:test_initialize_forNativeTokens(uint160) (runs: 100, μ: 59139, ~: 59421) PoolManagerTest:test_initialize_gas() (gas: 73772) -PoolManagerTest:test_initialize_revertsWhenPoolAlreadyInitialized(uint160) (runs: 100, μ: 50375, ~: 50478) +PoolManagerTest:test_initialize_revertsWhenPoolAlreadyInitialized(uint160) (runs: 100, μ: 50365, ~: 50478) PoolManagerTest:test_initialize_revertsWithIdenticalTokens(uint160) (runs: 100, μ: 13399, ~: 13399) -PoolManagerTest:test_initialize_revertsWithSameTokenCombo(uint160) (runs: 100, μ: 49238, ~: 49341) +PoolManagerTest:test_initialize_revertsWithSameTokenCombo(uint160) (runs: 100, μ: 49228, ~: 49341) PoolManagerTest:test_initialize_succeedsWithCorrectSelectors() (gas: 980799) -PoolManagerTest:test_initialize_succeedsWithEmptyHooks(uint160) (runs: 100, μ: 946584, ~: 946697) -PoolManagerTest:test_initialize_succeedsWithHooks(uint160) (runs: 100, μ: 8937393460516837947, ~: 8937393460516838057) -PoolManagerTest:test_initialize_succeedsWithMaxTickSpacing(uint160) (runs: 100, μ: 50738, ~: 50841) +PoolManagerTest:test_initialize_succeedsWithEmptyHooks(uint160) (runs: 100, μ: 946581, ~: 946697) +PoolManagerTest:test_initialize_succeedsWithHooks(uint160) (runs: 100, μ: 8937393460516837929, ~: 8937393460516838058) +PoolManagerTest:test_initialize_succeedsWithMaxTickSpacing(uint160) (runs: 100, μ: 50708, ~: 50840) PoolManagerTest:test_lock_EmitsCorrectId() (gas: 18848) PoolManagerTest:test_lock_NoOpIsOk() (gas: 50372) PoolManagerTest:test_mint_failsIfNotInitialized() (gas: 29346) PoolManagerTest:test_mint_failsWithIncorrectSelectors() (gas: 1176562) PoolManagerTest:test_mint_gas() (gas: 304522) -PoolManagerTest:test_mint_succeedsForNativeTokensIfInitialized(uint160) (runs: 100, μ: 250174, ~: 267847) -PoolManagerTest:test_mint_succeedsIfInitialized(uint160) (runs: 100, μ: 254591, ~: 256272) +PoolManagerTest:test_mint_succeedsForNativeTokensIfInitialized(uint160) (runs: 100, μ: 250535, ~: 267847) +PoolManagerTest:test_mint_succeedsIfInitialized(uint160) (runs: 100, μ: 254269, ~: 251775) PoolManagerTest:test_mint_succeedsWithCorrectSelectors() (gas: 1211340) -PoolManagerTest:test_mint_succeedsWithHooksIfInitialized(uint160) (runs: 100, μ: 8937393460517082568, ~: 8937393460517084221) +PoolManagerTest:test_mint_succeedsWithHooksIfInitialized(uint160) (runs: 100, μ: 8937393460517082508, ~: 8937393460517084221) PoolManagerTest:test_mint_withHooks_gas() (gas: 1209319) PoolManagerTest:test_mint_withNative_gas() (gas: 285824) PoolManagerTest:test_setProtocolFee_updatesProtocolFeeForInitializedPool() (gas: 118065) @@ -149,9 +149,9 @@ PoolManagerTest:test_take_failsWithInvalidTokensThatDoNotReturnTrueOnTransfer() PoolManagerTest:test_take_failsWithNoLiquidity() (gas: 53518) PoolManagerTest:test_take_succeedsWithPoolWithLiquidity() (gas: 469168) PoolManagerTest:test_take_succeedsWithPoolWithLiquidityWithNativeToken() (gas: 438960) -PoolTest:testModifyPosition(uint160,(address,int24,int24,int128,int24)) (runs: 100, μ: 19911, ~: 7536) -PoolTest:testPoolInitialize(uint160,uint16,uint16,uint24) (runs: 100, μ: 15442, ~: 6475) -PoolTest:testSwap(uint160,uint24,(int24,bool,int256,uint160)) (runs: 100, μ: 212145, ~: 7846) +PoolTest:testModifyPosition(uint160,(address,int24,int24,int128,int24)) (runs: 100, μ: 19917, ~: 7542) +PoolTest:testPoolInitialize(uint160,uint16,uint16,uint24) (runs: 100, μ: 16461, ~: 6475) +PoolTest:testSwap(uint160,uint24,(int24,bool,int256,uint160)) (runs: 100, μ: 212151, ~: 7852) SafeCastTest:testToInt128(int256) (runs: 100, μ: 1533, ~: 511) SafeCastTest:testToInt128(uint256) (runs: 100, μ: 1167, ~: 390) SafeCastTest:testToInt256(uint256) (runs: 100, μ: 784, ~: 450) @@ -198,7 +198,7 @@ SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_zeroForOneEqualsFalseGas() SqrtPriceMathTestTest:test_getNextSqrtPriceFromOutput_zeroForOneEqualsTrueGas() (gas: 78570) SqrtPriceMathTestTest:test_swapComputation_sqrtPTimessqrtQOverflows() (gas: 2375) SwapMathTest:test_amountOut_isCappedAtTheDesiredAmountOut() (gas: 3414) -SwapMathTest:test_computeSwapStep_Invariants(uint160,uint160,uint128,int256,uint24) (runs: 100, μ: 7950, ~: 7733) +SwapMathTest:test_computeSwapStep_Invariants(uint160,uint160,uint128,int256,uint24) (runs: 100, μ: 7968, ~: 7751) SwapMathTest:test_entireInputAmountTakenAsFee() (gas: 3490) SwapMathTest:test_exactAmountIn_oneForZero_thatGetsCappedAtPriceTargetIn() (gas: 3451) SwapMathTest:test_exactAmountIn_oneForZero_thatIsFullySpentIn() (gas: 4384) @@ -301,46 +301,47 @@ TickMathTestTest:test_getSqrtRatioAtTick_isValidMaxTick() (gas: 9795) TickMathTestTest:test_getSqrtRatioAtTick_isValidMaxTickSubOne() (gas: 6967) TickMathTestTest:test_getSqrtRatioAtTick_isValidMinTick() (gas: 9494) TickMathTestTest:test_getSqrtRatioAtTick_isValidMinTickAddOne() (gas: 6819) -TickMathTestTest:test_getSqrtRatioAtTick_matchesJavaScriptImplByOneHundrethOfABip() (gas: 864508) +TickMathTestTest:test_getSqrtRatioAtTick_matchesJavaScriptImplByOneHundrethOfABip() (gas: 865500) TickMathTestTest:test_getSqrtRatioAtTick_throwsForTooHigh() (gas: 8800) TickMathTestTest:test_getSqrtRatioAtTick_throwsForTooLow() (gas: 8736) TickMathTestTest:test_getTickAtSqrtRatio_isValidMaxSqrtRatioMinusOne() (gas: 8287) TickMathTestTest:test_getTickAtSqrtRatio_isValidMinSqrtRatio() (gas: 8008) TickMathTestTest:test_getTickAtSqrtRatio_isValidMinSqrtRatioPlusOne() (gas: 8173) TickMathTestTest:test_getTickAtSqrtRatio_isValidRatioClosestToMaxTick() (gas: 8462) -TickMathTestTest:test_getTickAtSqrtRatio_matchesJavascriptImplWithin1() (gas: 374880) +TickMathTestTest:test_getTickAtSqrtRatio_matchesJavascriptImplWithin1() (gas: 376378) TickMathTestTest:test_getTickAtSqrtRatio_throwsForTooHigh() (gas: 8681) TickMathTestTest:test_getTickAtSqrtRatio_throwsForTooLow() (gas: 8692) TickTest:testTick_clear_deletesAllTheDataInTheTick() (gas: 8080) TickTest:testTick_cross_flipsTheGrowthVariables() (gas: 68414) -TickTest:testTick_cross_twoFlipsAreNoOp() (gas: 69074) -TickTest:testTick_getFeeGrowthInside_returns0ForTwoUninitializedTicksIfTickIsAbove() (gas: 75714) -TickTest:testTick_getFeeGrowthInside_returns0ForTwoUninitializedTicksIfTickIsBelow() (gas: 75677) -TickTest:testTick_getFeeGrowthInside_returnsAllForTwoUninitializedTicksIfTickIsInside() (gas: 56050) -TickTest:testTick_getFeeGrowthInside_subtractsLowerTickIfAbove() (gas: 98630) -TickTest:testTick_getFeeGrowthInside_subtractsUpperAndLowerTickIfInside() (gas: 141314) +TickTest:testTick_cross_twoFlipsAreNoOp() (gas: 69119) +TickTest:testTick_getFeeGrowthInside_returns0ForTwoUninitializedTicksIfTickIsAbove() (gas: 75692) +TickTest:testTick_getFeeGrowthInside_returns0ForTwoUninitializedTicksIfTickIsBelow() (gas: 75655) +TickTest:testTick_getFeeGrowthInside_returnsAllForTwoUninitializedTicksIfTickIsInside() (gas: 56028) +TickTest:testTick_getFeeGrowthInside_subtractsLowerTickIfAbove() (gas: 98673) +TickTest:testTick_getFeeGrowthInside_subtractsUpperAndLowerTickIfInside() (gas: 141292) TickTest:testTick_getFeeGrowthInside_subtractsUpperTickIfBelow() (gas: 98732) -TickTest:testTick_getFeeGrowthInside_worksCorrectlyWithOverflowOnInsideTick() (gas: 141531) +TickTest:testTick_getFeeGrowthInside_worksCorrectlyWithOverflowOnInsideTick() (gas: 141509) TickTest:testTick_tickSpacingToMaxLiquidityPerTick_gasCost60TickSpacing() (gas: 78180) -TickTest:testTick_tickSpacingToMaxLiquidityPerTick_gasCostMaxTickSpacing() (gas: 78238) -TickTest:testTick_tickSpacingToMaxLiquidityPerTick_gasCostMinTickSpacing() (gas: 78224) -TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor1() (gas: 1634) -TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor2302() (gas: 1657) -TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForEntireRange() (gas: 1750) -TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForHighFee() (gas: 1635) -TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForLowFee() (gas: 1614) -TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMediumFee() (gas: 1612) -TickTest:testTick_tickSpacingToParametersInvariants_fuzz(int24) (runs: 100, μ: 5435, ~: 5435) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_gasCostMaxTickSpacing() (gas: 78203) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_gasCostMinTickSpacing() (gas: 78202) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueFor2302() (gas: 1724) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForEntireRange() (gas: 2049) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForHighFee() (gas: 1702) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForLowFee() (gas: 1745) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMaxTickSpacing() (gas: 1746) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMediumFee() (gas: 1746) +TickTest:testTick_tickSpacingToMaxLiquidityPerTick_returnsTheCorrectValueForMinTickSpacing() (gas: 1745) +TickTest:testTick_tickSpacingToParametersInvariants_fuzz(int24) (runs: 100, μ: 5304, ~: 5304) TickTest:testTick_update_assumesAllGrowthHappensBelowTicksLteCurrentTick() (gas: 134932) -TickTest:testTick_update_doesNotFlipFromNonzeroToGreaterNonzero() (gas: 36014) -TickTest:testTick_update_doesNotFlipFromNonzeroToLesserZero() (gas: 36068) +TickTest:testTick_update_doesNotFlipFromNonzeroToGreaterNonzero() (gas: 35992) +TickTest:testTick_update_doesNotFlipFromNonzeroToLesserZero() (gas: 36113) TickTest:testTick_update_doesNotSetAnyGrowthFieldsForTicksGtCurrentTick() (gas: 94471) -TickTest:testTick_update_doesNotSetAnyGrowthFieldsIfTickIsAlreadyInitialized() (gas: 136290) -TickTest:testTick_update_flipsFromNonzeroToZero() (gas: 24676) +TickTest:testTick_update_doesNotSetAnyGrowthFieldsIfTickIsAlreadyInitialized() (gas: 136268) +TickTest:testTick_update_flipsFromNonzeroToZero() (gas: 24659) TickTest:testTick_update_flipsFromZeroToNonzero() (gas: 34678) -TickTest:testTick_update_liquidityParsing_parsesMaxInt128StoredLiquidityGrossAfterUpdate() (gas: 95683) -TickTest:testTick_update_liquidityParsing_parsesMaxInt128StoredLiquidityGrossBeforeUpdate() (gas: 95639) -TickTest:testTick_update_liquidityParsing_parsesMaxUint128StoredLiquidityGrossAfterUpdate() (gas: 95679) -TickTest:testTick_update_liquidityParsing_parsesMaxUint128StoredLiquidityGrossBeforeUpdate() (gas: 95383) -TickTest:testTick_update_netsTheLiquidityBasedOnUpperFlag() (gas: 39534) +TickTest:testTick_update_liquidityParsing_parsesMaxInt128StoredLiquidityGrossAfterUpdate() (gas: 95728) +TickTest:testTick_update_liquidityParsing_parsesMaxInt128StoredLiquidityGrossBeforeUpdate() (gas: 95617) +TickTest:testTick_update_liquidityParsing_parsesMaxUint128StoredLiquidityGrossAfterUpdate() (gas: 95657) +TickTest:testTick_update_liquidityParsing_parsesMaxUint128StoredLiquidityGrossBeforeUpdate() (gas: 95361) +TickTest:testTick_update_netsTheLiquidityBasedOnUpperFlag() (gas: 39512) TickTest:testTick_update_revertsOnOverflowLiquidityGross() (gas: 38987) \ No newline at end of file