diff --git a/.forge-snapshots/BinHookTest#testBurnSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testBurnSucceedsWithHook.snap index b2f6f3f..8ae96e8 100644 --- a/.forge-snapshots/BinHookTest#testBurnSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testBurnSucceedsWithHook.snap @@ -1 +1 @@ -178321 \ No newline at end of file +178189 \ No newline at end of file diff --git a/.forge-snapshots/BinHookTest#testDonateSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testDonateSucceedsWithHook.snap index 01d3222..9a6770a 100644 --- a/.forge-snapshots/BinHookTest#testDonateSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testDonateSucceedsWithHook.snap @@ -1 +1 @@ -188513 \ No newline at end of file +188425 \ No newline at end of file diff --git a/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap index f1652a5..835e268 100644 --- a/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap @@ -1 +1 @@ -249529 \ No newline at end of file +184774 \ No newline at end of file diff --git a/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap index 70b3d99..8972ae6 100644 --- a/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap @@ -1 +1 @@ -311511 \ No newline at end of file +311515 \ No newline at end of file diff --git a/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap index 9996cb1..e6e7790 100644 --- a/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap @@ -1 +1 @@ -189812 \ No newline at end of file +189692 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerBytecodeSize.snap b/.forge-snapshots/BinPoolManagerBytecodeSize.snap index 1eda836..70341d9 100644 --- a/.forge-snapshots/BinPoolManagerBytecodeSize.snap +++ b/.forge-snapshots/BinPoolManagerBytecodeSize.snap @@ -1 +1 @@ -24232 \ No newline at end of file +24173 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap b/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap index 501c53a..3dc4c18 100644 --- a/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap +++ b/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap @@ -1 +1 @@ -133846 \ No newline at end of file +133833 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testExtLoadPoolActiveId.snap b/.forge-snapshots/BinPoolManagerTest#testExtLoadPoolActiveId.snap index b12aaf6..0bc965d 100644 --- a/.forge-snapshots/BinPoolManagerTest#testExtLoadPoolActiveId.snap +++ b/.forge-snapshots/BinPoolManagerTest#testExtLoadPoolActiveId.snap @@ -1 +1 @@ -1870 \ No newline at end of file +1877 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testFuzzUpdateDynamicLPFee.snap b/.forge-snapshots/BinPoolManagerTest#testFuzzUpdateDynamicLPFee.snap index 25b75a7..b3d3bba 100644 --- a/.forge-snapshots/BinPoolManagerTest#testFuzzUpdateDynamicLPFee.snap +++ b/.forge-snapshots/BinPoolManagerTest#testFuzzUpdateDynamicLPFee.snap @@ -1 +1 @@ -32540 \ No newline at end of file +32518 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testFuzz_SetMaxBinStep.snap b/.forge-snapshots/BinPoolManagerTest#testFuzz_SetMaxBinStep.snap index 86a9e30..fa634ff 100644 --- a/.forge-snapshots/BinPoolManagerTest#testFuzz_SetMaxBinStep.snap +++ b/.forge-snapshots/BinPoolManagerTest#testFuzz_SetMaxBinStep.snap @@ -1 +1 @@ -34988 \ No newline at end of file +34966 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap index ebe0530..1e8e434 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap @@ -1 +1 @@ -142646 \ No newline at end of file +142629 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap b/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap index 0fb650f..4cfa439 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap @@ -1 +1 @@ -289677 \ No newline at end of file +289662 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap index 886838c..840fba6 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap @@ -1 +1 @@ -127019 \ No newline at end of file +127005 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap b/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap index ba75e2e..83155a7 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap @@ -1 +1 @@ -118785 \ No newline at end of file +118763 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasGetBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasGetBin.snap index 29d7f6f..cf516ad 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasGetBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasGetBin.snap @@ -1 +1 @@ -4105 \ No newline at end of file +4083 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap index a86f2d3..c3af14f 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap @@ -1 +1 @@ -970507 \ No newline at end of file +970510 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap index dfa4cc8..26feb40 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap @@ -1 +1 @@ -329818 \ No newline at end of file +329822 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap index 81d7c1a..c2421d1 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap @@ -1 +1 @@ -337827 \ No newline at end of file +337829 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap index 8dc4e1b..563ff6c 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap @@ -1 +1 @@ -140377 \ No newline at end of file +140380 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap index aefc0d9..d729758 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap @@ -1 +1 @@ -173336 \ No newline at end of file +173317 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap index 4cb4deb..eb2276a 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap @@ -1 +1 @@ -179365 \ No newline at end of file +179345 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap index 8ba2bbc..01ba963 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap @@ -1 +1 @@ -133367 \ No newline at end of file +133348 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testInitialize_gasCheck_withoutHooks.snap b/.forge-snapshots/BinPoolManagerTest#testInitialize_gasCheck_withoutHooks.snap index fa8f898..4e350ed 100644 --- a/.forge-snapshots/BinPoolManagerTest#testInitialize_gasCheck_withoutHooks.snap +++ b/.forge-snapshots/BinPoolManagerTest#testInitialize_gasCheck_withoutHooks.snap @@ -1 +1 @@ -163762 \ No newline at end of file +163446 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap b/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap index 686b16e..a7e7092 100644 --- a/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap +++ b/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap @@ -1 +1 @@ -304784 \ No newline at end of file +304787 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testSetProtocolFee.snap b/.forge-snapshots/BinPoolManagerTest#testSetProtocolFee.snap index 8a5cc60..3b72cfd 100644 --- a/.forge-snapshots/BinPoolManagerTest#testSetProtocolFee.snap +++ b/.forge-snapshots/BinPoolManagerTest#testSetProtocolFee.snap @@ -1 +1 @@ -34507 \ No newline at end of file +34485 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerBytecodeSize.snap b/.forge-snapshots/CLPoolManagerBytecodeSize.snap index c3463c2..a5d452b 100644 --- a/.forge-snapshots/CLPoolManagerBytecodeSize.snap +++ b/.forge-snapshots/CLPoolManagerBytecodeSize.snap @@ -1 +1 @@ -21220 \ No newline at end of file +21216 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap b/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap index b1a6f81..f0e0e21 100644 --- a/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap +++ b/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap @@ -1 +1 @@ -347599 \ No newline at end of file +347609 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap b/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap index f551f14..9689766 100644 --- a/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap +++ b/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap @@ -1 +1 @@ -238356 \ No newline at end of file +238365 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap b/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap index 432944a..0dc04c2 100644 --- a/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap +++ b/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap @@ -1 +1 @@ -150645 \ No newline at end of file +150173 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap b/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap index cd254b6..4f72d56 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap @@ -1 +1 @@ -131089 \ No newline at end of file +131090 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap b/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap index 29f6232..12dd6e9 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap @@ -1 +1 @@ -143342 \ No newline at end of file +143343 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap b/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap index 2bb200d..f20f62e 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap @@ -1 +1 @@ -87973 \ No newline at end of file +87879 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#testFuzzUpdateDynamicLPFee.snap b/.forge-snapshots/CLPoolManagerTest#testFuzzUpdateDynamicLPFee.snap index ef17d0b..c2550d4 100644 --- a/.forge-snapshots/CLPoolManagerTest#testFuzzUpdateDynamicLPFee.snap +++ b/.forge-snapshots/CLPoolManagerTest#testFuzzUpdateDynamicLPFee.snap @@ -1 +1 @@ -31961 \ No newline at end of file +31971 \ No newline at end of file diff --git a/src/pool-bin/BinPoolManager.sol b/src/pool-bin/BinPoolManager.sol index f532622..3431ce3 100644 --- a/src/pool-bin/BinPoolManager.sol +++ b/src/pool-bin/BinPoolManager.sol @@ -96,7 +96,7 @@ contract BinPoolManager is IBinPoolManager, ProtocolFees, Extsload { } /// @inheritdoc IBinPoolManager - function initialize(PoolKey memory key, uint24 activeId, bytes calldata hookData) + function initialize(PoolKey memory key, uint24 activeId) external override poolManagerMatch(address(key.poolManager)) @@ -121,7 +121,7 @@ contract BinPoolManager is IBinPoolManager, ProtocolFees, Extsload { uint24 lpFee = key.fee.getInitialLPFee(); lpFee.validate(LPFeeLibrary.TEN_PERCENT_FEE); - BinHooks.beforeInitialize(key, activeId, hookData); + BinHooks.beforeInitialize(key, activeId); PoolId id = key.toId(); @@ -133,7 +133,7 @@ contract BinPoolManager is IBinPoolManager, ProtocolFees, Extsload { /// @notice Make sure the first event is noted, so that later events from afterHook won't get mixed up with this one emit Initialize(id, key.currency0, key.currency1, key.hooks, key.fee, key.parameters, activeId); - BinHooks.afterInitialize(key, activeId, hookData); + BinHooks.afterInitialize(key, activeId); } /// @inheritdoc IBinPoolManager diff --git a/src/pool-bin/interfaces/IBinHooks.sol b/src/pool-bin/interfaces/IBinHooks.sol index febedb4..8cde1a4 100644 --- a/src/pool-bin/interfaces/IBinHooks.sol +++ b/src/pool-bin/interfaces/IBinHooks.sol @@ -31,21 +31,15 @@ interface IBinHooks is IHooks { /// @param sender The initial msg.sender for the initialize call /// @param key The key for the pool being initialized /// @param activeId The binId of the pool, when the value is 2 ** 23, token price is 1:1 - /// @param hookData Arbitrary data handed into the PoolManager by the initializer to be be passed on to the hook /// @return bytes4 The function selector for the hook - function beforeInitialize(address sender, PoolKey calldata key, uint24 activeId, bytes calldata hookData) - external - returns (bytes4); + function beforeInitialize(address sender, PoolKey calldata key, uint24 activeId) external returns (bytes4); /// @notice The hook called after the state of a pool is initialized /// @param sender The initial msg.sender for the initialize call /// @param key The key for the pool being initialized /// @param activeId The binId of the pool, when the value is 2 ** 23, token price is 1:1 - /// @param hookData Arbitrary data handed into the PoolManager by the initializer to be be passed on to the hook /// @return bytes4 The function selector for the hook - function afterInitialize(address sender, PoolKey calldata key, uint24 activeId, bytes calldata hookData) - external - returns (bytes4); + function afterInitialize(address sender, PoolKey calldata key, uint24 activeId) external returns (bytes4); /// @notice The hook called before adding liquidity /// @param sender The initial msg.sender for the modify position call diff --git a/src/pool-bin/interfaces/IBinPoolManager.sol b/src/pool-bin/interfaces/IBinPoolManager.sol index 519d35e..d70340e 100644 --- a/src/pool-bin/interfaces/IBinPoolManager.sol +++ b/src/pool-bin/interfaces/IBinPoolManager.sol @@ -167,7 +167,7 @@ interface IBinPoolManager is IProtocolFees, IPoolManager, IExtsload { function getNextNonEmptyBin(PoolId id, bool swapForY, uint24 binId) external view returns (uint24 nextId); /// @notice Initialize a new pool - function initialize(PoolKey memory key, uint24 activeId, bytes calldata hookData) external; + function initialize(PoolKey memory key, uint24 activeId) external; /// @notice Add liquidity to a pool /// @return delta BalanceDelta, will be negative indicating how much total amt0 and amt1 liquidity added diff --git a/src/pool-bin/libraries/BinHooks.sol b/src/pool-bin/libraries/BinHooks.sol index 77b178c..db6524f 100644 --- a/src/pool-bin/libraries/BinHooks.sol +++ b/src/pool-bin/libraries/BinHooks.sol @@ -51,19 +51,19 @@ library BinHooks { } } - function beforeInitialize(PoolKey memory key, uint24 activeId, bytes calldata hookData) internal { + function beforeInitialize(PoolKey memory key, uint24 activeId) internal { IBinHooks hooks = IBinHooks(address(key.hooks)); if (key.parameters.shouldCall(HOOKS_BEFORE_INITIALIZE_OFFSET, hooks)) { - Hooks.callHook(hooks, abi.encodeCall(IBinHooks.beforeInitialize, (msg.sender, key, activeId, hookData))); + Hooks.callHook(hooks, abi.encodeCall(IBinHooks.beforeInitialize, (msg.sender, key, activeId))); } } - function afterInitialize(PoolKey memory key, uint24 activeId, bytes calldata hookData) internal { + function afterInitialize(PoolKey memory key, uint24 activeId) internal { IBinHooks hooks = IBinHooks(address(key.hooks)); if (key.parameters.shouldCall(HOOKS_AFTER_INITIALIZE_OFFSET, hooks)) { - Hooks.callHook(hooks, abi.encodeCall(IBinHooks.afterInitialize, (msg.sender, key, activeId, hookData))); + Hooks.callHook(hooks, abi.encodeCall(IBinHooks.afterInitialize, (msg.sender, key, activeId))); } } diff --git a/src/pool-cl/CLPoolManager.sol b/src/pool-cl/CLPoolManager.sol index a1982c2..40be9aa 100644 --- a/src/pool-cl/CLPoolManager.sol +++ b/src/pool-cl/CLPoolManager.sol @@ -83,7 +83,7 @@ contract CLPoolManager is ICLPoolManager, ProtocolFees, Extsload { } /// @inheritdoc ICLPoolManager - function initialize(PoolKey memory key, uint160 sqrtPriceX96, bytes calldata hookData) + function initialize(PoolKey memory key, uint160 sqrtPriceX96) external override poolManagerMatch(address(key.poolManager)) @@ -106,7 +106,7 @@ contract CLPoolManager is ICLPoolManager, ProtocolFees, Extsload { uint24 lpFee = key.fee.getInitialLPFee(); lpFee.validate(LPFeeLibrary.ONE_HUNDRED_PERCENT_FEE); - CLHooks.beforeInitialize(key, sqrtPriceX96, hookData); + CLHooks.beforeInitialize(key, sqrtPriceX96); PoolId id = key.toId(); uint24 protocolFee = _fetchProtocolFee(key); @@ -117,7 +117,7 @@ contract CLPoolManager is ICLPoolManager, ProtocolFees, Extsload { /// @notice Make sure the first event is noted, so that later events from afterHook won't get mixed up with this one emit Initialize(id, key.currency0, key.currency1, key.hooks, key.fee, key.parameters, sqrtPriceX96, tick); - CLHooks.afterInitialize(key, sqrtPriceX96, tick, hookData); + CLHooks.afterInitialize(key, sqrtPriceX96, tick); } /// @inheritdoc ICLPoolManager diff --git a/src/pool-cl/interfaces/ICLHooks.sol b/src/pool-cl/interfaces/ICLHooks.sol index 0d813fd..0376ae3 100644 --- a/src/pool-cl/interfaces/ICLHooks.sol +++ b/src/pool-cl/interfaces/ICLHooks.sol @@ -32,27 +32,18 @@ interface ICLHooks is IHooks { /// @param sender The initial msg.sender for the initialize call /// @param key The key for the pool being initialized /// @param sqrtPriceX96 The sqrt(price) of the pool as a Q64.96 - /// @param hookData Arbitrary data handed into the PoolManager by the initializer to be be passed on to the hook /// @return bytes4 The function selector for the hook - - function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, bytes calldata hookData) - external - returns (bytes4); + function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96) external returns (bytes4); /// @notice The hook called after the state of a pool is initialized /// @param sender The initial msg.sender for the initialize call /// @param key The key for the pool being initialized /// @param sqrtPriceX96 The sqrt(price) of the pool as a Q64.96 /// @param tick The current tick after the state of a pool is initialized - /// @param hookData Arbitrary data handed into the PoolManager by the initializer to be be passed on to the hook /// @return bytes4 The function selector for the hook - function afterInitialize( - address sender, - PoolKey calldata key, - uint160 sqrtPriceX96, - int24 tick, - bytes calldata hookData - ) external returns (bytes4); + function afterInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, int24 tick) + external + returns (bytes4); /// @notice The hook called before liquidity is added /// @param sender The initial msg.sender for the add liquidity call diff --git a/src/pool-cl/interfaces/ICLPoolManager.sol b/src/pool-cl/interfaces/ICLPoolManager.sol index c1ac37b..055d6be 100644 --- a/src/pool-cl/interfaces/ICLPoolManager.sol +++ b/src/pool-cl/interfaces/ICLPoolManager.sol @@ -120,9 +120,7 @@ interface ICLPoolManager is IProtocolFees, IPoolManager, IExtsload { returns (CLPosition.Info memory position); /// @notice Initialize the state for a given pool ID - function initialize(PoolKey memory key, uint160 sqrtPriceX96, bytes calldata hookData) - external - returns (int24 tick); + function initialize(PoolKey memory key, uint160 sqrtPriceX96) external returns (int24 tick); struct ModifyLiquidityParams { // the lower and upper tick of the position diff --git a/src/pool-cl/libraries/CLHooks.sol b/src/pool-cl/libraries/CLHooks.sol index 640c3dd..f5db439 100644 --- a/src/pool-cl/libraries/CLHooks.sol +++ b/src/pool-cl/libraries/CLHooks.sol @@ -50,21 +50,19 @@ library CLHooks { } } - function beforeInitialize(PoolKey memory key, uint160 sqrtPriceX96, bytes calldata hookData) internal { + function beforeInitialize(PoolKey memory key, uint160 sqrtPriceX96) internal { ICLHooks hooks = ICLHooks(address(key.hooks)); if (key.parameters.shouldCall(HOOKS_BEFORE_INITIALIZE_OFFSET, hooks)) { - Hooks.callHook(hooks, abi.encodeCall(ICLHooks.beforeInitialize, (msg.sender, key, sqrtPriceX96, hookData))); + Hooks.callHook(hooks, abi.encodeCall(ICLHooks.beforeInitialize, (msg.sender, key, sqrtPriceX96))); } } - function afterInitialize(PoolKey memory key, uint160 sqrtPriceX96, int24 tick, bytes calldata hookData) internal { + function afterInitialize(PoolKey memory key, uint160 sqrtPriceX96, int24 tick) internal { ICLHooks hooks = ICLHooks(address(key.hooks)); if (key.parameters.shouldCall(HOOKS_AFTER_INITIALIZE_OFFSET, hooks)) { - Hooks.callHook( - hooks, abi.encodeCall(ICLHooks.afterInitialize, (msg.sender, key, sqrtPriceX96, tick, hookData)) - ); + Hooks.callHook(hooks, abi.encodeCall(ICLHooks.afterInitialize, (msg.sender, key, sqrtPriceX96, tick))); } } diff --git a/src/test/MockFeePoolManager.sol b/src/test/MockFeePoolManager.sol index 23ddd16..8a4ef82 100644 --- a/src/test/MockFeePoolManager.sol +++ b/src/test/MockFeePoolManager.sol @@ -25,7 +25,7 @@ contract MockFeePoolManager is ProtocolFees { constructor(IVault vault, uint256 controllerGasLimit) ProtocolFees(vault) {} - function initialize(PoolKey memory key, bytes calldata) external { + function initialize(PoolKey memory key) external { PoolId id = key.toId(); uint24 protocolFee = _fetchProtocolFee(key); diff --git a/src/test/fee/MockFeeManagerHook.sol b/src/test/fee/MockFeeManagerHook.sol index fb257b6..fb8dd70 100644 --- a/src/test/fee/MockFeeManagerHook.sol +++ b/src/test/fee/MockFeeManagerHook.sol @@ -29,7 +29,7 @@ contract MockFeeManagerHook is IHooks { } // swap fee for dynamic fee pool is 0 by default, so we need to update it after pool initialization - function afterInitialize(address, PoolKey calldata key, uint24, bytes calldata) external returns (bytes4) { + function afterInitialize(address, PoolKey calldata key, uint24) external returns (bytes4) { IBinPoolManager(msg.sender).updateDynamicLPFee(key, swapfee); return MockFeeManagerHook.afterInitialize.selector; } diff --git a/src/test/pool-bin/MockBinHooks.sol b/src/test/pool-bin/MockBinHooks.sol index ff8d0ed..edf5697 100644 --- a/src/test/pool-bin/MockBinHooks.sol +++ b/src/test/pool-bin/MockBinHooks.sol @@ -12,8 +12,6 @@ import {PoolId} from "../../types/PoolId.sol"; contract MockBinHooks is IBinHooks { using Hooks for IBinHooks; - bytes public beforeInitializeData; - bytes public afterInitializeData; bytes public beforeMintData; bytes public afterMintData; bytes public beforeSwapData; @@ -35,18 +33,12 @@ contract MockBinHooks is IBinHooks { return bitmap; } - function beforeInitialize(address, PoolKey calldata, uint24, bytes calldata hookData) external returns (bytes4) { - beforeInitializeData = hookData; + function beforeInitialize(address, PoolKey calldata, uint24) external returns (bytes4) { bytes4 selector = MockBinHooks.beforeInitialize.selector; return returnValues[selector] == bytes4(0) ? selector : returnValues[selector]; } - function afterInitialize(address, PoolKey calldata, uint24, bytes calldata hookData) - external - override - returns (bytes4) - { - afterInitializeData = hookData; + function afterInitialize(address, PoolKey calldata, uint24) external override returns (bytes4) { bytes4 selector = MockBinHooks.afterInitialize.selector; return returnValues[selector] == bytes4(0) ? selector : returnValues[selector]; } diff --git a/test/ProtocolFees.t.sol b/test/ProtocolFees.t.sol index e2afc60..d871f2a 100644 --- a/test/ProtocolFees.t.sol +++ b/test/ProtocolFees.t.sol @@ -68,7 +68,7 @@ contract ProtocolFeesTest is Test { } function testSwap_NoProtocolFee() public { - poolManager.initialize(key, new bytes(0)); + poolManager.initialize(key); (uint256 protocolFee0, uint256 protocolFee1) = poolManager.swap(key, 1e18, 1e18); assertEq(protocolFee0, 0); @@ -89,12 +89,12 @@ contract ProtocolFeesTest is Test { poolManagerWithLowControllerGasLimit.setProtocolFeeController(feeController); vm.expectRevert(IProtocolFees.ProtocolFeeCannotBeFetched.selector); - poolManagerWithLowControllerGasLimit.initialize{gas: 2000_000}(_key, new bytes(0)); + poolManagerWithLowControllerGasLimit.initialize{gas: 2000_000}(_key); } function testInit_WhenFeeControllerRevert() public { poolManager.setProtocolFeeController(revertingFeeController); - poolManager.initialize(key, new bytes(0)); + poolManager.initialize(key); assertEq(poolManager.getProtocolFee(key), 0); } @@ -102,7 +102,7 @@ contract ProtocolFeesTest is Test { function testInit_WhenFeeControllerOutOfBound() public { poolManager.setProtocolFeeController(outOfBoundsFeeController); assertEq(address(poolManager.protocolFeeController()), address(outOfBoundsFeeController)); - poolManager.initialize(key, new bytes(0)); + poolManager.initialize(key); assertEq(poolManager.getProtocolFee(key), 0); } @@ -110,7 +110,7 @@ contract ProtocolFeesTest is Test { function testInit_WhenFeeControllerOverflow() public { poolManager.setProtocolFeeController(overflowFeeController); assertEq(address(poolManager.protocolFeeController()), address(overflowFeeController)); - poolManager.initialize(key, new bytes(0)); + poolManager.initialize(key); assertEq(poolManager.getProtocolFee(key), 0); } @@ -118,7 +118,7 @@ contract ProtocolFeesTest is Test { function testInit_WhenFeeControllerInvalidReturnSize() public { poolManager.setProtocolFeeController(invalidReturnSizeFeeController); assertEq(address(poolManager.protocolFeeController()), address(invalidReturnSizeFeeController)); - poolManager.initialize(key, new bytes(0)); + poolManager.initialize(key); assertEq(poolManager.getProtocolFee(key), 0); } @@ -130,7 +130,7 @@ contract ProtocolFeesTest is Test { address(feeController), abi.encodeCall(IProtocolFeeController.protocolFeeForPool, key), abi.encode(fee) ); - poolManager.initialize(key, new bytes(0)); + poolManager.initialize(key); if (fee != 0) { uint24 fee0 = fee % 4096; @@ -146,7 +146,7 @@ contract ProtocolFeesTest is Test { } function testSetProtocolFee() public { - poolManager.initialize(key, new bytes(0)); + poolManager.initialize(key); poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); assertEq(poolManager.getProtocolFee(key), 0); @@ -178,7 +178,7 @@ contract ProtocolFeesTest is Test { feeController.setProtocolFeeForPool(key, protocolFee); poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); - poolManager.initialize(key, new bytes(0)); + poolManager.initialize(key); (uint256 protocolFee0, uint256 protocolFee1) = poolManager.swap(key, 1e18, 1e18); assertEq(protocolFee0, 1e15); assertEq(protocolFee1, 1e15); @@ -202,7 +202,7 @@ contract ProtocolFeesTest is Test { uint24 protocolFee = _buildProtocolFee(ProtocolFeeLibrary.MAX_PROTOCOL_FEE, ProtocolFeeLibrary.MAX_PROTOCOL_FEE); feeController.setProtocolFeeForPool(key, protocolFee); poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); - poolManager.initialize(key, new bytes(0)); + poolManager.initialize(key); (uint256 protocolFee0, uint256 protocolFee1) = poolManager.swap(key, 1e18, 1e18); assertEq(protocolFee0, 1e15); assertEq(protocolFee1, 1e15); diff --git a/test/pool-bin/BinHook.t.sol b/test/pool-bin/BinHook.t.sol index 811a4da..38490ee 100644 --- a/test/pool-bin/BinHook.t.sol +++ b/test/pool-bin/BinHook.t.sol @@ -45,7 +45,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { mockHooks.setReturnValue(mockHooks.beforeInitialize.selector, bytes4(0xdeadbeef)); vm.expectRevert(Hooks.InvalidHookResponse.selector); - poolManager.initialize(key, binId, ZERO_BYTES); + poolManager.initialize(key, binId); } function testAfterInitializeInvalidReturn() public { @@ -55,7 +55,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { mockHooks.setReturnValue(mockHooks.afterInitialize.selector, bytes4(0xdeadbeef)); vm.expectRevert(Hooks.InvalidHookResponse.selector); - poolManager.initialize(key, binId, ZERO_BYTES); + poolManager.initialize(key, binId); } function testInitializeSucceedsWithHook() public { @@ -64,10 +64,8 @@ contract BinHookTest is BinTestHelper, GasSnapshot { _createPoolWithBitMap(bitMap); snapStart("BinHookTest#testInitializeSucceedsWithHook"); - poolManager.initialize(key, binId, new bytes(123)); + poolManager.initialize(key, binId); snapEnd(); - assertEq(mockHooks.beforeInitializeData(), new bytes(123)); - assertEq(mockHooks.afterInitializeData(), new bytes(123)); } function testMintInvalidReturn() public { @@ -78,7 +76,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { mockHooks.setReturnValue(mockHooks.beforeMint.selector, bytes4(0xdeadbeef)); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); vm.expectRevert(Hooks.InvalidHookResponse.selector); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, ""); } @@ -91,7 +89,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { mockHooks.setReturnValue(mockHooks.afterMint.selector, bytes4(0xdeadbeef)); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); vm.expectRevert(Hooks.InvalidHookResponse.selector); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, ""); } @@ -102,7 +100,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { _createPoolWithBitMap(bitMap); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); snapStart("BinHookTest#testMintSucceedsWithHook"); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, new bytes(123)); @@ -118,7 +116,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { _createPoolWithBitMap(bitMap); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, new bytes(123)); uint256 bobBal = poolManager.getPosition(key.toId(), bob, binId, 0).share; @@ -139,7 +137,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { mockHooks.setReturnValue(mockHooks.beforeBurn.selector, bytes4(0xdeadbeef)); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, ""); uint256 bobBal = poolManager.getPosition(key.toId(), bob, binId, 0).share; @@ -155,7 +153,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { mockHooks.setReturnValue(mockHooks.afterBurn.selector, bytes4(0xdeadbeef)); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, ""); uint256 bobBal = poolManager.getPosition(key.toId(), bob, binId, 0).share; @@ -169,7 +167,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { _createPoolWithBitMap(bitMap); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, new bytes(123)); snapStart("BinHookTest#testSwapSucceedsWithHook"); @@ -188,7 +186,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { mockHooks.setReturnValue(mockHooks.beforeSwap.selector, bytes4(0xdeadbeef)); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, new bytes(123)); vm.expectRevert(Hooks.InvalidHookResponse.selector); @@ -203,7 +201,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { mockHooks.setReturnValue(mockHooks.afterSwap.selector, bytes4(0xdeadbeef)); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, new bytes(123)); vm.expectRevert(Hooks.InvalidHookResponse.selector); @@ -216,7 +214,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { _createPoolWithBitMap(bitMap); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, new bytes(123)); snapStart("BinHookTest#testDonateSucceedsWithHook"); @@ -235,7 +233,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { mockHooks.setReturnValue(mockHooks.beforeDonate.selector, bytes4(0xdeadbeef)); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, new bytes(123)); vm.expectRevert(Hooks.InvalidHookResponse.selector); @@ -250,7 +248,7 @@ contract BinHookTest is BinTestHelper, GasSnapshot { mockHooks.setReturnValue(mockHooks.afterDonate.selector, bytes4(0xdeadbeef)); // initialize and add 1e18 token0, 1e18 token1 into a single binId - poolManager.initialize(key, binId, ""); + poolManager.initialize(key, binId); addLiquidityToBin(key, poolManager, bob, binId, 1e18, 1e18, 1e18, 1e18, new bytes(123)); vm.expectRevert(Hooks.InvalidHookResponse.selector); diff --git a/test/pool-bin/BinHookReturnsDelta.t.sol b/test/pool-bin/BinHookReturnsDelta.t.sol index 4288e61..930a5e6 100644 --- a/test/pool-bin/BinHookReturnsDelta.t.sol +++ b/test/pool-bin/BinHookReturnsDelta.t.sol @@ -92,7 +92,7 @@ contract BinHookReturnsDelta is Test, GasSnapshot, BinTestHelper { parameters: bytes32(uint256(binReturnsDeltaHook.getHooksRegistrationBitmap())).setBinStep(10) }); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); } function testMint_MintMore() external { diff --git a/test/pool-bin/BinHookReturnsFee.t.sol b/test/pool-bin/BinHookReturnsFee.t.sol index 906ae57..c2eb727 100644 --- a/test/pool-bin/BinHookReturnsFee.t.sol +++ b/test/pool-bin/BinHookReturnsFee.t.sol @@ -91,7 +91,7 @@ contract BinHookReturnsFeeTest is Test, BinTestHelper { parameters: bytes32(uint256(dynamicReturnsFeesHook.getHooksRegistrationBitmap())).setBinStep(10) }); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); IBinPoolManager.MintParams memory mintParams = _getSingleBinMintParams(activeId, 1 ether, 1 ether); binLiquidityHelper.mint(key, mintParams, abi.encode(0)); @@ -128,7 +128,7 @@ contract BinHookReturnsFeeTest is Test, BinTestHelper { function test_dynamicReturnSwapFee_initializeZeroSwapFee() public { key.parameters = BinPoolParametersHelper.setBinStep(bytes32(uint256(dynamicReturnsFeesHook.getHooksRegistrationBitmap())), 1); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); assertEq(_fetchPoolSwapFee(key), 0); } @@ -136,7 +136,7 @@ contract BinHookReturnsFeeTest is Test, BinTestHelper { key.fee = 3000; // static fee dynamicReturnsFeesHook.setFee(1000); // 0.10% fee is NOT used because the pool has a static fee - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); IBinPoolManager.MintParams memory mintParams = _getSingleBinMintParams(activeId, 1 ether, 1 ether); binLiquidityHelper.mint(key, mintParams, abi.encode(0)); assertEq(_fetchPoolSwapFee(key), 3000); @@ -160,7 +160,7 @@ contract BinHookReturnsFeeTest is Test, BinTestHelper { // create a new pool with an initial fee of 123 key.parameters = BinPoolParametersHelper.setBinStep(bytes32(uint256(dynamicReturnsFeesHook.getHooksRegistrationBitmap())), 1); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); IBinPoolManager.MintParams memory mintParams = _getSingleBinMintParams(activeId, 1 ether, 1 ether); binLiquidityHelper.mint(key, mintParams, abi.encode(0)); diff --git a/test/pool-bin/BinHookRevertWithReason.t.sol b/test/pool-bin/BinHookRevertWithReason.t.sol index 9bbb46d..c33c1f7 100644 --- a/test/pool-bin/BinHookRevertWithReason.t.sol +++ b/test/pool-bin/BinHookRevertWithReason.t.sol @@ -53,10 +53,11 @@ contract BinHookRevertWithReasonTest is Test { function testRevertWithNoReason() public { vm.expectRevert(abi.encodeWithSelector(Hooks.Wrap__FailedHookCall.selector, hook, new bytes(0))); - poolManager.initialize(key, activeId, abi.encode(false)); + poolManager.initialize(key, activeId); } function testRevertWithHookNotImplemented() public { + hook.setRevertWithHookNotImplemented(true); vm.expectRevert( abi.encodeWithSelector( Hooks.Wrap__FailedHookCall.selector, @@ -64,6 +65,6 @@ contract BinHookRevertWithReasonTest is Test { abi.encodeWithSelector(BaseBinTestHook.HookNotImplemented.selector) ) ); - poolManager.initialize(key, activeId, abi.encode(true)); + poolManager.initialize(key, activeId); } } diff --git a/test/pool-bin/BinHookSkipCallback.t.sol b/test/pool-bin/BinHookSkipCallback.t.sol index 79aade7..218f116 100644 --- a/test/pool-bin/BinHookSkipCallback.t.sol +++ b/test/pool-bin/BinHookSkipCallback.t.sol @@ -94,17 +94,17 @@ contract BinHookSkipCallbackTest is Test, GasSnapshot, BinTestHelper { } function testInitialize_FromHook() external { - binSkipCallbackHook.initialize(key, activeId, new bytes(0)); + binSkipCallbackHook.initialize(key, activeId); assertEq(binSkipCallbackHook.hookCounterCallbackCount(), 0); } function testInitialize_NotfromHook() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); assertEq(binSkipCallbackHook.hookCounterCallbackCount(), 2); } function testMint_FromHook() external { - binSkipCallbackHook.initialize(key, activeId, new bytes(0)); + binSkipCallbackHook.initialize(key, activeId); IBinPoolManager.MintParams memory mintParams = _getSingleBinMintParams(activeId, 1 ether, 1 ether); binLiquidityHelper.mint(key, mintParams, ""); @@ -113,7 +113,7 @@ contract BinHookSkipCallbackTest is Test, GasSnapshot, BinTestHelper { } function testMint_NotFromHook() external { - binSkipCallbackHook.initialize(key, activeId, new bytes(0)); + binSkipCallbackHook.initialize(key, activeId); IBinPoolManager.MintParams memory mintParams = _getSingleBinMintParams(activeId, 1 ether, 1 ether); binSkipCallbackHook.mint(key, mintParams, ""); @@ -122,7 +122,7 @@ contract BinHookSkipCallbackTest is Test, GasSnapshot, BinTestHelper { } function testBurn_FromHook() external { - binSkipCallbackHook.initialize(key, activeId, new bytes(0)); + binSkipCallbackHook.initialize(key, activeId); IBinPoolManager.MintParams memory mintParams = _getSingleBinMintParams(activeId, 1 ether, 1 ether); binSkipCallbackHook.mint(key, mintParams, ""); @@ -136,7 +136,7 @@ contract BinHookSkipCallbackTest is Test, GasSnapshot, BinTestHelper { } function testBurn_NotFromHook() external { - binSkipCallbackHook.initialize(key, activeId, new bytes(0)); + binSkipCallbackHook.initialize(key, activeId); IBinPoolManager.MintParams memory mintParams = _getSingleBinMintParams(activeId, 1 ether, 1 ether); binLiquidityHelper.mint(key, mintParams, ""); @@ -150,7 +150,7 @@ contract BinHookSkipCallbackTest is Test, GasSnapshot, BinTestHelper { } function testDonate_FromHook() external { - binSkipCallbackHook.initialize(key, activeId, new bytes(0)); + binSkipCallbackHook.initialize(key, activeId); IBinPoolManager.MintParams memory mintParams = _getSingleBinMintParams(activeId, 1 ether, 1 ether); binSkipCallbackHook.mint(key, mintParams, ""); @@ -160,7 +160,7 @@ contract BinHookSkipCallbackTest is Test, GasSnapshot, BinTestHelper { } function testDonate_NotFromHook() external { - binSkipCallbackHook.initialize(key, activeId, new bytes(0)); + binSkipCallbackHook.initialize(key, activeId); IBinPoolManager.MintParams memory mintParams = _getSingleBinMintParams(activeId, 1 ether, 1 ether); binSkipCallbackHook.mint(key, mintParams, ""); diff --git a/test/pool-bin/BinPoolManager.t.sol b/test/pool-bin/BinPoolManager.t.sol index a817c3e..b2aee60 100644 --- a/test/pool-bin/BinPoolManager.t.sol +++ b/test/pool-bin/BinPoolManager.t.sol @@ -122,7 +122,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { function testInitialize_gasCheck_withoutHooks() public { snapStart("BinPoolManagerTest#testInitialize_gasCheck_withoutHooks"); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); snapEnd(); } @@ -148,7 +148,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { key.toId(), key.currency0, key.currency1, IHooks(address(mockHooks)), key.fee, key.parameters, activeId ); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); (Currency curr0, Currency curr1, IHooks hooks, IPoolManager pm, uint24 fee, bytes32 parameters) = poolManager.poolIdToPoolKey(key.toId()); @@ -178,7 +178,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { }); vm.expectRevert(abi.encodeWithSelector(ParametersHelper.UnusedBitsNonZero.selector)); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); } function testInitializeHookValidation() public { @@ -198,7 +198,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { parameters: bytes32(uint256(bitMap - 1)).setBinStep(10) }); vm.expectRevert(abi.encodeWithSelector(Hooks.HookConfigValidationError.selector)); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); } // hook permission @@ -215,15 +215,15 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { parameters: bytes32(uint256(bitMap)).setBinStep(10) }); vm.expectRevert(abi.encodeWithSelector(Hooks.HookPermissionsValidationError.selector)); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); } } function testInitializeSamePool() public { - poolManager.initialize(key, 2 ** 23, new bytes(0)); + poolManager.initialize(key, 2 ** 23); vm.expectRevert(PoolAlreadyInitialized.selector); - poolManager.initialize(key, 2 ** 23 + 1, new bytes(0)); // different activeId but same pool + poolManager.initialize(key, 2 ** 23 + 1); // different activeId but same pool } function test_fuzz_InvalidPrice(uint24 activeId, bool isLeft) public { @@ -237,7 +237,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { } vm.expectRevert(); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); } function test_fuzz_ValidPrice(uint24 activeId, bool isLeft) public { @@ -251,7 +251,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { } // no revert expected - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); } function testInitializeDynamicFeeTooLarge(uint24 dynamicSwapFee) public { @@ -292,12 +292,12 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { }); vm.expectRevert(abi.encodeWithSelector(LPFeeLibrary.LPFeeTooLarge.selector, key.fee)); - poolManager.initialize(key, 2 ** 23, new bytes(0)); + poolManager.initialize(key, 2 ** 23); } function testInitializeInvalidId() public { vm.expectRevert(); - poolManager.initialize(key, 0, new bytes(0)); + poolManager.initialize(key, 0); } function testInitializeSwapFeeTooLarge() public { @@ -313,7 +313,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { }); vm.expectRevert(abi.encodeWithSelector(LPFeeLibrary.LPFeeTooLarge.selector, swapFee)); - poolManager.initialize(key, activeId, ""); + poolManager.initialize(key, activeId); } function testInitializeInvalidBinStep() public { @@ -329,7 +329,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { vm.expectRevert( abi.encodeWithSelector(IBinPoolManager.BinStepTooSmall.selector, poolManager.MIN_BIN_STEP() - 1) ); - poolManager.initialize(key, activeId, ""); + poolManager.initialize(key, activeId); key = PoolKey({ currency0: currency0, @@ -343,11 +343,11 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { vm.expectRevert( abi.encodeWithSelector(IBinPoolManager.BinStepTooLarge.selector, poolManager.MAX_BIN_STEP() + 1) ); - poolManager.initialize(key, activeId, ""); + poolManager.initialize(key, activeId); } function testGasMintOneBin() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); token0.mint(address(this), 2 ether); token1.mint(address(this), 2 ether); @@ -373,7 +373,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { } function testGasMintNneBins() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); token0.mint(address(this), 10 ether); token1.mint(address(this), 10 ether); @@ -397,7 +397,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { fee: uint24(3000), // 3000 = 0.3% parameters: poolParam.setBinStep(10) // binStep }); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); token1.mint(address(this), 1 ether); IBinPoolManager.MintParams memory mintParams = _getSingleBinMintParams(activeId, 1 ether, 1 ether); @@ -419,7 +419,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { function testMintAndBurnWithSalt() public { bytes32 salt = bytes32(uint256(0x1234)); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); token0.mint(address(this), 10 ether); token1.mint(address(this), 10 ether); @@ -477,7 +477,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { bytes32 salt0 = bytes32(0); bytes32 salt1 = bytes32(uint256(0x1234)); bytes32 salt2 = bytes32(uint256(0x5678)); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); token0.mint(address(this), 30 ether); token1.mint(address(this), 30 ether); @@ -615,7 +615,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { function testGasBurnOneBin() public { // initialize - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // mint token0.mint(address(this), 2 ether); @@ -641,7 +641,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { function testGasBurnHalfBin() public { // initialize - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // mint token0.mint(address(this), 2 ether); @@ -659,7 +659,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { } function testGasBurnNineBins() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // mint on 9 bins token0.mint(address(this), 10 ether); @@ -685,7 +685,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { fee: uint24(3000), // 3000 = 0.3% parameters: poolParam.setBinStep(10) // binStep }); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // mint token1.mint(address(this), 1 ether); @@ -710,7 +710,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { function testGasSwapSingleBin() public { // initialize - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // mint token0.mint(address(this), 10 ether); @@ -733,7 +733,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { } function testGasSwapMultipleBins() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // mint on 9 bins, around 2 eth worth on each bin. eg. 4 binY || activeBin || 4 binX token0.mint(address(this), 10 ether); @@ -751,7 +751,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { } function testGasSwapOverBigBinIdGate() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // mint on 9 bins, around 2 eth worth on each bin. eg. 4 binY || activeBin || 4 binX token0.mint(address(this), 1 ether); @@ -779,7 +779,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { } function testGasDonate() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); token0.mint(address(this), 11 ether); token1.mint(address(this), 11 ether); @@ -800,7 +800,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { BinSwapHelper.TestSettings memory testSettings; // initialize the pool - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // mint token0.mint(address(this), 10 ether); @@ -869,7 +869,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { assertEq(abi.encode(owner), abi.encode(address(this))); // initialize - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // verify poolId. uint256 POOL_SLOT = 5; @@ -911,7 +911,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { function testSetProtocolFee() public { // initialize the pool and asset protocolFee is 0 - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); (, uint24 protocolFee,) = poolManager.getSlot0(key.toId()); assertEq(protocolFee, 0); @@ -1030,7 +1030,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { fee: LPFeeLibrary.DYNAMIC_FEE_FLAG, parameters: bytes32(uint256(bitMap)).setBinStep(10) }); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); binFeeManagerHook.setFee(_lpFee); @@ -1059,7 +1059,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { fee: LPFeeLibrary.DYNAMIC_FEE_FLAG, parameters: bytes32(uint256(bitMap)).setBinStep(10) }); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); binFeeManagerHook.setFee(_lpFee); @@ -1079,7 +1079,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { BinSwapHelper.TestSettings memory testSettings; // initialize the pool - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // mint token0.mint(address(this), 10 ether); @@ -1101,7 +1101,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { token0.mint(address(this), 1 ether); token1.mint(address(this), 1 ether); - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); IBinPoolManager.MintParams memory mintParams; // add 1 eth of tokenX and 1 eth of tokenY liquidity at activeId @@ -1117,7 +1117,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { // verify remove liquidity is fine when paused function testBurn_WhenPaused() public { // initialize - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // mint token0.mint(address(this), 2 ether); @@ -1142,7 +1142,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { } function testDonate_WhenPaused() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); token0.mint(address(this), 11 ether); token1.mint(address(this), 11 ether); @@ -1160,7 +1160,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { function testGasGetBin() public { // Initialize and add 1e18 token0, token1 to the active bin. price of bin: 2**128, 3.4e38 - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // add 1 eth of tokenX and 1 eth of tokenY liquidity at activeId token0.mint(address(this), 1 ether); diff --git a/test/pool-bin/BinPoolManagerBehaviorComparison.t.sol b/test/pool-bin/BinPoolManagerBehaviorComparison.t.sol index 18b2507..c97f9b3 100644 --- a/test/pool-bin/BinPoolManagerBehaviorComparison.t.sol +++ b/test/pool-bin/BinPoolManagerBehaviorComparison.t.sol @@ -91,7 +91,7 @@ abstract contract LBFuzzer is LBHelper, BinTestHelper { fee: 0, parameters: bytes32(0).setBinStep(boundBinStep) }); - manager.initialize(key_, boundActiveId, ""); + manager.initialize(key_, boundActiveId); } function mint(ILBPair lbPair, PoolKey memory key, uint24 boundId, uint256 amountX, uint256 amountY, uint8 binNum) diff --git a/test/pool-bin/helpers/BaseBinTestHook.sol b/test/pool-bin/helpers/BaseBinTestHook.sol index 8efb48e..8e230a0 100644 --- a/test/pool-bin/helpers/BaseBinTestHook.sol +++ b/test/pool-bin/helpers/BaseBinTestHook.sol @@ -32,11 +32,11 @@ contract BaseBinTestHook is IBinHooks { revert HookNotImplemented(); } - function beforeInitialize(address, PoolKey calldata, uint24, bytes calldata) external virtual returns (bytes4) { + function beforeInitialize(address, PoolKey calldata, uint24) external virtual returns (bytes4) { revert HookNotImplemented(); } - function afterInitialize(address, PoolKey calldata, uint24, bytes calldata) external virtual returns (bytes4) { + function afterInitialize(address, PoolKey calldata, uint24) external virtual returns (bytes4) { revert HookNotImplemented(); } diff --git a/test/pool-bin/helpers/BinRevertHook.sol b/test/pool-bin/helpers/BinRevertHook.sol index b4b2e0b..9042529 100644 --- a/test/pool-bin/helpers/BinRevertHook.sol +++ b/test/pool-bin/helpers/BinRevertHook.sol @@ -5,6 +5,8 @@ import {PoolKey} from "../../../src/types/PoolKey.sol"; import {BaseBinTestHook} from "./BaseBinTestHook.sol"; contract BinRevertHook is BaseBinTestHook { + bool public revertWithHookNotImplemented = false; + function getHooksRegistrationBitmap() external pure override returns (uint16) { return _hooksRegistrationBitmapFrom( Permissions({ @@ -26,13 +28,11 @@ contract BinRevertHook is BaseBinTestHook { ); } - function afterInitialize(address, PoolKey calldata, uint24, bytes calldata data) - external - pure - override - returns (bytes4) - { - (bool revertWithHookNotImplemented) = abi.decode(data, (bool)); + function setRevertWithHookNotImplemented(bool value) external { + revertWithHookNotImplemented = value; + } + + function afterInitialize(address, PoolKey calldata, uint24) external view override returns (bytes4) { if (revertWithHookNotImplemented) { revert HookNotImplemented(); } else { diff --git a/test/pool-bin/helpers/BinSkipCallbackHook.sol b/test/pool-bin/helpers/BinSkipCallbackHook.sol index 1ea23b4..d61e355 100644 --- a/test/pool-bin/helpers/BinSkipCallbackHook.sol +++ b/test/pool-bin/helpers/BinSkipCallbackHook.sol @@ -198,16 +198,16 @@ contract BinSkipCallbackHook is BaseBinTestHook { return abi.encode(delta); } - function initialize(PoolKey memory key, uint24 activeId, bytes memory hookData) external { - poolManager.initialize(key, activeId, hookData); + function initialize(PoolKey memory key, uint24 activeId) external { + poolManager.initialize(key, activeId); } - function beforeInitialize(address, PoolKey calldata, uint24, bytes calldata) external override returns (bytes4) { + function beforeInitialize(address, PoolKey calldata, uint24) external override returns (bytes4) { hookCounterCallbackCount++; return BinSkipCallbackHook.beforeInitialize.selector; } - function afterInitialize(address, PoolKey calldata, uint24, bytes calldata) external override returns (bytes4) { + function afterInitialize(address, PoolKey calldata, uint24) external override returns (bytes4) { hookCounterCallbackCount++; return BinSkipCallbackHook.afterInitialize.selector; } diff --git a/test/pool-bin/libraries/BinPoolDonate.t.sol b/test/pool-bin/libraries/BinPoolDonate.t.sol index c57dfc5..99e1a20 100644 --- a/test/pool-bin/libraries/BinPoolDonate.t.sol +++ b/test/pool-bin/libraries/BinPoolDonate.t.sol @@ -58,7 +58,7 @@ contract BinPoolDonateTest is BinTestHelper { function testDonate_InsufficientBinShareForDonate(uint256 remainingShare) public { // Initialize pool and add liqudiity - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, alice, activeId, 1e18, 1e18, 1e18, 1e18, ""); // Remove all share leaving less than MIN_LIQUIDITY_BEFORE_DONATE shares @@ -72,7 +72,7 @@ contract BinPoolDonateTest is BinTestHelper { function testDonate() public { // Initialize. Alice/Bob both add 1e18 token0, token1 to the active bin - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, alice, activeId, 1e18, 1e18, 1e18, 1e18, ""); uint256 aliceShare = poolManager.getPosition(poolId, alice, activeId, 0).share; addLiquidityToBin(key, poolManager, bob, activeId, 1e18, 1e18, 1e18, 1e18, ""); @@ -115,7 +115,7 @@ contract BinPoolDonateTest is BinTestHelper { vm.assume(amt0 < uint128(type(int128).max) && amt1 < uint128(type(int128).max)); // Initialize and add 1e18 token0, token1 to the active bin. price of bin: 2**128, 3.4e38 - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 1e18, 1e18, 1e18, 1e18, ""); poolManager.getPosition(poolId, bob, activeId, 0).share; @@ -129,7 +129,7 @@ contract BinPoolDonateTest is BinTestHelper { function testDonateOverflow_BinReserve() public { // Initialize and add 1e18 token0, token1 to the active bin - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 1e18, 1e18, 1e18, 1e18, ""); vm.expectRevert(PackedUint128Math.PackedUint128Math__AddOverflow.selector); @@ -145,7 +145,7 @@ contract BinPoolDonateTest is BinTestHelper { uint24 binId = activeId + 60_000; // price: 3.7e64 // Initialize and add 1e18 token0, token1 to the active bin. - poolManager.initialize(key, binId, new bytes(0)); + poolManager.initialize(key, binId); addLiquidityToBin(key, poolManager, bob, binId, 1, 1, 1e18, 1e18, ""); // scenario 1: L = 3.7e64 * 3.4e38 will be greater than 2**256 diff --git a/test/pool-bin/libraries/BinPoolFee.t.sol b/test/pool-bin/libraries/BinPoolFee.t.sol index 6af06e4..186c120 100644 --- a/test/pool-bin/libraries/BinPoolFee.t.sol +++ b/test/pool-bin/libraries/BinPoolFee.t.sol @@ -98,7 +98,7 @@ contract BinPoolFeeTest is BinTestHelper { uint24 binId = ID_ONE; // where token price are the same uint256 amountX = 1_000 * 1e18; uint256 amountY = 1_000 * 1e18; - poolManager.initialize(key, binId, new bytes(0)); + poolManager.initialize(key, binId); // first mint: 5:5 ratio, will never incur composition fee for first mint addLiquidityToBin(key, poolManager, bob, binId, amountX, amountY, 1e18, 1e18, ""); @@ -128,8 +128,8 @@ contract BinPoolFeeTest is BinTestHelper { // initialize both pool uint24 binId = ID_ONE; // where token price are the same - poolManager.initialize(key, binId, new bytes(0)); - poolManager.initialize(key2, binId, new bytes(0)); + poolManager.initialize(key, binId); + poolManager.initialize(key2, binId); // add same liquidity (100 to 100_000 ether) to both pool initialAmt = uint256(bound(initialAmt, 100 ether, 100_000 ether)); @@ -167,7 +167,7 @@ contract BinPoolFeeTest is BinTestHelper { }); uint24 activeId = ID_ONE; // where token price are the same - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); bytes memory data = abi.encode(true, uint24(swapFee)); vm.expectRevert( @@ -195,7 +195,7 @@ contract BinPoolFeeTest is BinTestHelper { }); uint24 binId = ID_ONE; // where token price are the same - poolManager.initialize(key, binId, new bytes(0)); + poolManager.initialize(key, binId); vm.expectRevert(abi.encodeWithSelector(LPFeeLibrary.LPFeeTooLarge.selector, 110_000)); addLiquidityToBin(key, poolManager, bob, binId, 1000e18, 1000e18, 1e18, 1e18, ""); @@ -221,7 +221,7 @@ contract BinPoolFeeTest is BinTestHelper { uint24 binId = ID_ONE; // where token price are the same uint256 amountX = 1_000 * 1e18; uint256 amountY = 1_000 * 1e18; - poolManager.initialize(key, binId, new bytes(0)); + poolManager.initialize(key, binId); // first mint: 5:5 ratio, will never incur composition fee for first mint addLiquidityToBin(key, poolManager, bob, binId, amountX, amountY, 1e18, 1e18, ""); @@ -252,7 +252,7 @@ contract BinPoolFeeTest is BinTestHelper { uint24 binId = ID_ONE; // where token price are the same uint256 amountX = 1_000 * 1e18; uint256 amountY = 1_000 * 1e18; - poolManager.initialize(key, binId, new bytes(0)); + poolManager.initialize(key, binId); // first mint: 5:5 ratio, will never incur composition fee for first mint addLiquidityToBin(key, poolManager, bob, binId, amountX, amountY, 1e18, 1e18, ""); @@ -292,7 +292,7 @@ contract BinPoolFeeTest is BinTestHelper { uint24 binId = ID_ONE; // where token price are the same uint256 amountX = 1_000 * 1e18; uint256 amountY = 1_000 * 1e18; - poolManager.initialize(key, binId, new bytes(0)); + poolManager.initialize(key, binId); // first mint: 1000e18 tokenX and 1000e18 tokenY with 5:5 ratio addLiquidityToBin(key, poolManager, bob, binId, amountX, amountY, 1e18, 1e18, ""); @@ -315,7 +315,7 @@ contract BinPoolFeeTest is BinTestHelper { function _addLiquidityForBurnTest(uint24 activeId, PoolKey memory _key) internal { uint256 amountX = 1000 ether; uint256 amountY = 1000 ether; - poolManager.initialize(_key, activeId, new bytes(0)); + poolManager.initialize(_key, activeId); // mint 5:5 ratio addLiquidityToBin(_key, poolManager, bob, activeId, amountX, amountY, 1e18, 1e18, ""); @@ -340,7 +340,7 @@ contract BinPoolFeeTest is BinTestHelper { function test_Swap_NoFee() external { uint24 activeId = ID_ONE; // where token price are the same - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); // addLiquidity: 10_000 token0 and token1 on active bin addLiquidityToBin(key, poolManager, bob, activeId, 10_000e18, 10_000e18, 1e18, 1e18, ""); @@ -378,7 +378,7 @@ contract BinPoolFeeTest is BinTestHelper { // addLiquidity: 10_000 token0 and token1 on active bin uint24 activeId = ID_ONE; // where token price are the same - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 10_000 ether, 10_000 ether, 1e18, 1e18, ""); // overwrite fee to 2% @@ -410,7 +410,7 @@ contract BinPoolFeeTest is BinTestHelper { // addLiquidity: 10_000 token0 and token1 on active bin uint24 activeId = ID_ONE; // where token price are the same - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 10_000e18, 10_000e18, 1e18, 1e18, ""); bytes memory data = abi.encode(true, uint24(swapFee)); diff --git a/test/pool-bin/libraries/BinPoolLiquidity.t.sol b/test/pool-bin/libraries/BinPoolLiquidity.t.sol index fb45ae7..b71537f 100644 --- a/test/pool-bin/libraries/BinPoolLiquidity.t.sol +++ b/test/pool-bin/libraries/BinPoolLiquidity.t.sol @@ -54,7 +54,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_SimpleMintX() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); uint256 amountX = 120 * 10 ** 18; uint256 amountY = 2_400 * 10 ** 6; @@ -129,7 +129,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_MintTwice() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); uint256 amountX = 100 * 10 ** 18; uint256 amountY = 2_000 * 10 ** 6; @@ -176,7 +176,7 @@ contract BinPoolLiquidityTest is BinTestHelper { /// @dev Ensure composition fee all goes to LP function test_Mint_CompositionFeeGoesToLp() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); uint256 amountX = 100 ether; uint256 amountY = 1 ether; @@ -195,7 +195,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_MintWithDifferentBins() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); uint256 amountX = 100 * 10 ** 18; uint256 amountY = 2_000 * 10 ** 6; @@ -234,7 +234,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_revert_MintEmptyConfig() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); IBinPoolManager.MintParams memory params = IBinPoolManager.MintParams({ liquidityConfigs: new bytes32[](0), @@ -247,7 +247,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_revert_MintZeroShares() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); bytes32[] memory data = new bytes32[](1); data[0] = LiquidityConfigurations.encodeParams(1e18, 1e18, activeId); @@ -260,7 +260,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_revert_MintMoreThanAmountSent() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); bytes32[] memory data = new bytes32[](2); data[0] = LiquidityConfigurations.encodeParams(0, 0.5e18, activeId - 1); @@ -286,7 +286,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_SimpleBurn() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); uint256 amountX = 100 * 10 ** 18; uint256 amountY = 100 * 10 ** 18; @@ -326,7 +326,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_BurnHalfTwice() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); uint256 amountX = 100 * 10 ** 18; uint256 amountY = 100 * 10 ** 18; @@ -375,7 +375,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_revert_BurnEmptyArraysOrDifferent() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); uint256[] memory ids = new uint256[](0); uint256[] memory balances = new uint256[](1); @@ -403,7 +403,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_revert_BurnMoreThanBalance() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidity(key, poolManager, alice, activeId, 1e18, 1e18, 1, 0); addLiquidity(key, poolManager, bob, activeId, 1e18, 1e18, 1, 0); @@ -419,7 +419,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_revert_BurnZeroShares() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); uint256[] memory ids = new uint256[](1); uint256[] memory balances = new uint256[](1); @@ -432,7 +432,7 @@ contract BinPoolLiquidityTest is BinTestHelper { } function test_revert_BurnForZeroAmounts() external { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); uint256[] memory ids = new uint256[](1); uint256[] memory balances = new uint256[](1); diff --git a/test/pool-bin/libraries/BinPoolSwap.t.sol b/test/pool-bin/libraries/BinPoolSwap.t.sol index 12c8626..68f3127 100644 --- a/test/pool-bin/libraries/BinPoolSwap.t.sol +++ b/test/pool-bin/libraries/BinPoolSwap.t.sol @@ -53,7 +53,7 @@ contract BinPoolSwapTest is BinTestHelper { } function test_exactInputSingleBin_SwapForY() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 1e18, 1e18, 1e18, 1e18, ""); BalanceDelta delta = poolManager.swap(key, true, -int128(1e18), ""); @@ -62,7 +62,7 @@ contract BinPoolSwapTest is BinTestHelper { } function test_exactInputSingleBin_SwapForX() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 1e18, 1e18, 1e18, 1e18, ""); BalanceDelta delta = poolManager.swap(key, false, -int128(1e18), ""); @@ -71,7 +71,7 @@ contract BinPoolSwapTest is BinTestHelper { } function test_exactOutputSingleBin_SwapForY() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 1e18, 1e18, 1e18, 1e18, ""); BalanceDelta delta = poolManager.swap(key, true, 1e18, ""); @@ -80,7 +80,7 @@ contract BinPoolSwapTest is BinTestHelper { } function test_exactOutputSingleBin_SwapForX() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 1e18, 1e18, 1e18, 1e18, ""); BalanceDelta delta = poolManager.swap(key, false, 1e18, ""); @@ -89,7 +89,7 @@ contract BinPoolSwapTest is BinTestHelper { } function test_exactInputMultipleBin() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidity(key, poolManager, bob, activeId, 1e18, 1e18, 10, 10); BalanceDelta delta = poolManager.swap(key, true, -1e18, ""); @@ -98,7 +98,7 @@ contract BinPoolSwapTest is BinTestHelper { } function test_exactOutputMultipleBin() public { - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidity(key, poolManager, bob, activeId, 1e18, 1e18, 10, 10); BalanceDelta delta = poolManager.swap(key, true, 1e18, ""); @@ -114,7 +114,7 @@ contract BinPoolSwapTest is BinTestHelper { poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); // add 1 ether on each side to active bin - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 1e18, 1e18, 1e18, 1e18, ""); // before swap @@ -139,7 +139,7 @@ contract BinPoolSwapTest is BinTestHelper { poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); // add 1 ether on each side to active bin - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 1e18, 1e18, 1e18, 1e18, ""); // before swap @@ -164,7 +164,7 @@ contract BinPoolSwapTest is BinTestHelper { poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); // add 1 ether on each side to active bin - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidityToBin(key, poolManager, bob, activeId, 1e18, 1e18, 1e18, 1e18, ""); // before swap @@ -189,7 +189,7 @@ contract BinPoolSwapTest is BinTestHelper { poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); // add liquidity to multiple bin - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidity(key, poolManager, bob, activeId, 1e18, 1e18, 10, 10); // before swap @@ -208,7 +208,7 @@ contract BinPoolSwapTest is BinTestHelper { function test_revert_SwapAmountSpecifiedIsZero() external { // Add liquidity of 1e18 on each side - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidity(key, poolManager, bob, activeId, 1e18, 1e18, 50, 50); uint128 amountIn = 0; @@ -222,7 +222,7 @@ contract BinPoolSwapTest is BinTestHelper { function test_revert_SwapInsufficientAmountOut() external { // Add liquidity of 1e18 on each side - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidity(key, poolManager, bob, activeId, 1e18, 1e18, 50, 50); uint128 amountIn = 1; @@ -236,7 +236,7 @@ contract BinPoolSwapTest is BinTestHelper { function test_revert_SwapOutOfLiquidity() external { // Add liquidity of 1e18 on each side - poolManager.initialize(key, activeId, new bytes(0)); + poolManager.initialize(key, activeId); addLiquidity(key, poolManager, bob, activeId, 1e18, 1e18, 50, 50); // pool only have 1e18 token0, 1e18 token1 diff --git a/test/pool-cl/CLHookReturnsDelta.t.sol b/test/pool-cl/CLHookReturnsDelta.t.sol index be0e757..254e688 100644 --- a/test/pool-cl/CLHookReturnsDelta.t.sol +++ b/test/pool-cl/CLHookReturnsDelta.t.sol @@ -54,7 +54,7 @@ contract CLHookReturnsDeltaTest is Test, Deployers, TokenFixture, GasSnapshot { parameters: bytes32(uint256(clReturnsDeltaHook.getHooksRegistrationBitmap())).setTickSpacing(10) }); - poolManager.initialize(key, SQRT_RATIO_1_1, new bytes(0)); + poolManager.initialize(key, SQRT_RATIO_1_1); } function testModifyPosition_AddMore() external { diff --git a/test/pool-cl/CLHookReturnsFee.t.sol b/test/pool-cl/CLHookReturnsFee.t.sol index 05dab2b..1508576 100644 --- a/test/pool-cl/CLHookReturnsFee.t.sol +++ b/test/pool-cl/CLHookReturnsFee.t.sol @@ -63,7 +63,7 @@ contract CLHookReturnsFeeTest is Test, Deployers, TokenFixture, GasSnapshot { ) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); IERC20(Currency.unwrap(currency0)).approve(address(router), type(uint256).max); IERC20(Currency.unwrap(currency1)).approve(address(router), type(uint256).max); @@ -118,7 +118,7 @@ contract CLHookReturnsFeeTest is Test, Deployers, TokenFixture, GasSnapshot { key.parameters = CLPoolParametersHelper.setTickSpacing( bytes32(uint256(dynamicReturnsFeesHook.getHooksRegistrationBitmap())), 10 ); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); assertEq(_fetchPoolSwapFee(key), 0); } @@ -126,7 +126,7 @@ contract CLHookReturnsFeeTest is Test, Deployers, TokenFixture, GasSnapshot { key.fee = 3000; // static fee dynamicReturnsFeesHook.setFee(1000); // 0.10% fee is NOT used because the pool has a static fee - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); IERC20(Currency.unwrap(currency0)).approve(address(router), type(uint256).max); IERC20(Currency.unwrap(currency1)).approve(address(router), type(uint256).max); @@ -165,7 +165,7 @@ contract CLHookReturnsFeeTest is Test, Deployers, TokenFixture, GasSnapshot { key.parameters = CLPoolParametersHelper.setTickSpacing( bytes32(uint256(dynamicReturnsFeesHook.getHooksRegistrationBitmap())), 10 ); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); IERC20(Currency.unwrap(currency0)).approve(address(router), type(uint256).max); IERC20(Currency.unwrap(currency1)).approve(address(router), type(uint256).max); diff --git a/test/pool-cl/CLHookRevertWithReason.t.sol b/test/pool-cl/CLHookRevertWithReason.t.sol index e42ea25..001c5c0 100644 --- a/test/pool-cl/CLHookRevertWithReason.t.sol +++ b/test/pool-cl/CLHookRevertWithReason.t.sol @@ -46,10 +46,11 @@ contract CLHookRevertWithReasonTest is Test, Deployers, TokenFixture { function testRevertWithNoReason() public { vm.expectRevert(abi.encodeWithSelector(Hooks.Wrap__FailedHookCall.selector, hook, new bytes(0))); - poolManager.initialize(key, SQRT_RATIO_1_1, abi.encode(false)); + poolManager.initialize(key, SQRT_RATIO_1_1); } function testRevertWithHookNotImplemented() public { + hook.setRevertWithHookNotImplemented(true); vm.expectRevert( abi.encodeWithSelector( Hooks.Wrap__FailedHookCall.selector, @@ -57,6 +58,6 @@ contract CLHookRevertWithReasonTest is Test, Deployers, TokenFixture { abi.encodeWithSelector(BaseCLTestHook.HookNotImplemented.selector) ) ); - poolManager.initialize(key, SQRT_RATIO_1_1, abi.encode(true)); + poolManager.initialize(key, SQRT_RATIO_1_1); } } diff --git a/test/pool-cl/CLHookSkipCallback.t.sol b/test/pool-cl/CLHookSkipCallback.t.sol index f5e043d..d30b9a1 100644 --- a/test/pool-cl/CLHookSkipCallback.t.sol +++ b/test/pool-cl/CLHookSkipCallback.t.sol @@ -57,17 +57,17 @@ contract CLHookSkipCallbackTest is Test, Deployers, TokenFixture, GasSnapshot { } function testInitialize_FromHook() external { - clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1, new bytes(0)); + clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1); assertEq(clSkipCallbackHook.hookCounterCallbackCount(), 0); } function testInitialize_NotFromHook() external { - poolManager.initialize(key, SQRT_RATIO_1_1, new bytes(0)); + poolManager.initialize(key, SQRT_RATIO_1_1); assertEq(clSkipCallbackHook.hookCounterCallbackCount(), 2); } function testModifyPosition_FromHook() external { - clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1, new bytes(0)); + clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1); // Add and remove liquidity clSkipCallbackHook.modifyPosition( @@ -84,7 +84,7 @@ contract CLHookSkipCallbackTest is Test, Deployers, TokenFixture, GasSnapshot { } function testModifyPosition_NotFromHook() external { - clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1, new bytes(0)); + clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1); // Add and remove liquidity router.modifyPosition( @@ -101,7 +101,7 @@ contract CLHookSkipCallbackTest is Test, Deployers, TokenFixture, GasSnapshot { } function testSwap_FromHook() external { - clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1, new bytes(0)); + clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1); // Pre-req add some liqudiity clSkipCallbackHook.modifyPosition( @@ -121,7 +121,7 @@ contract CLHookSkipCallbackTest is Test, Deployers, TokenFixture, GasSnapshot { } function testSwap_NotFromHook() external { - clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1, new bytes(0)); + clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1); // Pre-req add some liqudiity clSkipCallbackHook.modifyPosition( @@ -141,7 +141,7 @@ contract CLHookSkipCallbackTest is Test, Deployers, TokenFixture, GasSnapshot { } function testDonate_FromHook() external { - clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1, new bytes(0)); + clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1); // Pre-req add some liqudiity clSkipCallbackHook.modifyPosition( @@ -156,7 +156,7 @@ contract CLHookSkipCallbackTest is Test, Deployers, TokenFixture, GasSnapshot { } function testDonate_NotFromHook() external { - clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1, new bytes(0)); + clSkipCallbackHook.initialize(key, SQRT_RATIO_1_1); // Pre-req add some liqudiity clSkipCallbackHook.modifyPosition( diff --git a/test/pool-cl/CLPoolManager.t.sol b/test/pool-cl/CLPoolManager.t.sol index 4c24498..3b3e308 100644 --- a/test/pool-cl/CLPoolManager.t.sol +++ b/test/pool-cl/CLPoolManager.t.sol @@ -94,7 +94,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0xa0000)) }); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // 0 @@ -108,7 +108,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0xa0000)) }); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // 300000 i.e. 30% @@ -122,7 +122,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0xa0000)) }); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // 1000000 i.e. 100% @@ -136,7 +136,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0xa0000)) }); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // 1000001 i.e. > 100% @@ -151,7 +151,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(LPFeeLibrary.LPFeeTooLarge.selector, uint24(1000001))); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } } @@ -168,7 +168,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(ICLPoolManager.TickSpacingTooSmall.selector, int24(0))); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // tickSpacing 1 @@ -182,7 +182,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0x10000)) }); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // tickSpacing 10 @@ -196,7 +196,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0xa0000)) }); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // tickSpacing max @@ -210,7 +210,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0x7fff0000)) }); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // tickSpacing overflow @@ -225,7 +225,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(ICLPoolManager.TickSpacingTooLarge.selector, int24(0x8000))); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } } @@ -243,7 +243,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps // 0x800001 = -8388607 vm.expectRevert(abi.encodeWithSelector(ICLPoolManager.TickSpacingTooSmall.selector, -8388607)); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // 1 at 40 bit @@ -258,7 +258,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(ParametersHelper.UnusedBitsNonZero.selector)); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // 1 at 41 bit @@ -273,7 +273,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(ParametersHelper.UnusedBitsNonZero.selector)); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // 1 at 42 bit @@ -288,7 +288,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(ParametersHelper.UnusedBitsNonZero.selector)); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } } @@ -309,7 +309,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(Hooks.HookConfigValidationError.selector)); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } // hook permission @@ -328,7 +328,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(Hooks.HookPermissionsValidationError.selector)); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); } } @@ -344,7 +344,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0xa0000)) }); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); (CLPool.Slot0 memory slot0, uint256 feeGrowthGlobal0X128, uint256 feeGrowthGlobal1X128, uint128 liquidity) = poolManager.pools(key.toId()); @@ -370,7 +370,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); snapStart("CLPoolManagerTest#initializeWithoutHooks"); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); snapEnd(); } @@ -386,38 +386,38 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps vm.expectRevert( abi.encodeWithSelector(ICLPoolManager.TickSpacingTooLarge.selector, key.parameters.getTickSpacing()) ); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } else if (key.parameters.getTickSpacing() < TickMath.MIN_TICK_SPACING) { vm.expectRevert( abi.encodeWithSelector(ICLPoolManager.TickSpacingTooSmall.selector, key.parameters.getTickSpacing()) ); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } else if (key.currency0 > key.currency1 || key.currency0 == key.currency1) { vm.expectRevert( abi.encodeWithSelector( IPoolManager.CurrenciesInitializedOutOfOrder.selector, key.currency0, key.currency1 ) ); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } else if (!checkUnusedBitsAllZero(key.parameters)) { vm.expectRevert(abi.encodeWithSelector(ParametersHelper.UnusedBitsNonZero.selector)); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } else if (!_validateHookConfig(key)) { vm.expectRevert(abi.encodeWithSelector(Hooks.HookConfigValidationError.selector)); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } else if (!_validateHookPermissionsConflict(key)) { vm.expectRevert(abi.encodeWithSelector(Hooks.HookPermissionsValidationError.selector)); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } else if (key.fee > LPFeeLibrary.ONE_HUNDRED_PERCENT_FEE) { vm.expectRevert(abi.encodeWithSelector(LPFeeLibrary.LPFeeTooLarge.selector, key.fee)); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } else { int24 tick = TickMath.getTickAtSqrtRatio(sqrtPriceX96); vm.expectEmit(true, true, true, true); emit ICLPoolManager.Initialize( key.toId(), key.currency0, key.currency1, key.hooks, key.fee, key.parameters, sqrtPriceX96, tick ); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); (CLPool.Slot0 memory slot0,,,) = poolManager.pools(key.toId()); assertEq(slot0.sqrtPriceX96, sqrtPriceX96); @@ -449,7 +449,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps sqrtPriceX96, TickMath.getTickAtSqrtRatio(sqrtPriceX96) ); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); (CLPool.Slot0 memory slot0,,,) = poolManager.pools(key.toId()); assertEq(slot0.sqrtPriceX96, sqrtPriceX96); @@ -474,16 +474,15 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps int24 tick = TickMath.getTickAtSqrtRatio(sqrtPriceX96); bytes memory beforePayload = - abi.encodeWithSelector(MockHooks.beforeInitialize.selector, address(this), key, sqrtPriceX96, ZERO_BYTES); + abi.encodeWithSelector(MockHooks.beforeInitialize.selector, address(this), key, sqrtPriceX96); - bytes memory afterPayload = abi.encodeWithSelector( - MockHooks.afterInitialize.selector, address(this), key, sqrtPriceX96, tick, ZERO_BYTES - ); + bytes memory afterPayload = + abi.encodeWithSelector(MockHooks.afterInitialize.selector, address(this), key, sqrtPriceX96, tick); vm.expectCall(address(hookAddr), 0, beforePayload, 1); vm.expectCall(address(hookAddr), 0, afterPayload, 1); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); (CLPool.Slot0 memory slot0,,,) = poolManager.pools(key.toId()); assertEq(slot0.sqrtPriceX96, sqrtPriceX96); @@ -522,7 +521,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps TickMath.getTickAtSqrtRatio(sqrtPriceX96) ); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } function test_initialize_succeedsWithEmptyHooks(uint160 sqrtPriceX96) public { @@ -540,7 +539,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256((60 << 16) | hookEmptyAddr.getHooksRegistrationBitmap())) }); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); (CLPool.Slot0 memory slot0,,,) = poolManager.pools(key.toId()); assertEq(slot0.sqrtPriceX96, sqrtPriceX96); } @@ -562,7 +561,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps vm.expectRevert( abi.encodeWithSelector(IPoolManager.CurrenciesInitializedOutOfOrder.selector, key.currency0, key.currency1) ); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } function test_initialize_revertsWithSameTokenCombo(uint160 sqrtPriceX96) public { @@ -587,7 +586,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(60 << 16)) }); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); vm.expectRevert( abi.encodeWithSelector( IPoolManager.CurrenciesInitializedOutOfOrder.selector, @@ -595,7 +594,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps keyInvertedCurrency.currency1 ) ); - poolManager.initialize(keyInvertedCurrency, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(keyInvertedCurrency, sqrtPriceX96); } function test_initialize_revertsWhenPoolAlreadyInitialized(uint160 sqrtPriceX96) public { @@ -611,9 +610,9 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(60 << 16)) }); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); vm.expectRevert(CLPool.PoolAlreadyInitialized.selector); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } function test_initialize_failsWithIncorrectSelectors() public { @@ -633,12 +632,12 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps // Fails at beforeInitialize hook. vm.expectRevert(Hooks.InvalidHookResponse.selector); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); // Fail at afterInitialize hook. mockHooks.setReturnValue(mockHooks.beforeInitialize.selector, mockHooks.beforeInitialize.selector); vm.expectRevert(Hooks.InvalidHookResponse.selector); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); } function test_initialize_succeedsWithCorrectSelectors() public { @@ -656,7 +655,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps mockHooks.setReturnValue(mockHooks.beforeInitialize.selector, mockHooks.beforeInitialize.selector); mockHooks.setReturnValue(mockHooks.afterInitialize.selector, mockHooks.afterInitialize.selector); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); } function test_initialize_failsIfTickSpaceTooLarge(uint160 sqrtPriceX96) public { @@ -675,7 +674,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps vm.expectRevert( abi.encodeWithSelector(ICLPoolManager.TickSpacingTooLarge.selector, TickMath.MAX_TICK_SPACING + 1) ); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } function test_initialize_failsIfTickSpaceZero(uint160 sqrtPriceX96) public { @@ -692,7 +691,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(ICLPoolManager.TickSpacingTooSmall.selector, 0)); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } function test_initialize_failsIfTickSpaceNeg(uint160 sqrtPriceX96) public { @@ -710,7 +709,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(ICLPoolManager.TickSpacingTooSmall.selector, -1)); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); } function test_initialize_failsIDynamicFeeTooLarge(uint24 dynamicSwapFee) public { @@ -736,7 +735,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps abi.encodeWithSelector(LPFeeLibrary.LPFeeTooLarge.selector, dynamicSwapFee) ) ); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); } function test_initialize_failsDynamicFeeInvalid() public { @@ -753,7 +752,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); vm.expectRevert(abi.encodeWithSelector(LPFeeLibrary.LPFeeTooLarge.selector, LPFeeLibrary.DYNAMIC_FEE_FLAG + 1)); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); } // ************** *************** // @@ -780,7 +779,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); // price = 100 tick roughly 46054 - poolManager.initialize(key, uint160(10 * FixedPoint96.Q96), ZERO_BYTES); + poolManager.initialize(key, uint160(10 * FixedPoint96.Q96)); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e10 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e10 ether); @@ -879,7 +878,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0x10000)) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e30 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e30 ether); @@ -1007,7 +1006,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); // price = 100 tick roughly 46054 - poolManager.initialize(key, uint160(10 * FixedPoint96.Q96), ZERO_BYTES); + poolManager.initialize(key, uint160(10 * FixedPoint96.Q96)); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e30 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e30 ether); @@ -1053,7 +1052,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); // price = 100 tick roughly 46054 - poolManager.initialize(key, uint160(10 * FixedPoint96.Q96), ZERO_BYTES); + poolManager.initialize(key, uint160(10 * FixedPoint96.Q96)); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e30 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e30 ether); @@ -1094,7 +1093,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); // price = 100 tick roughly 46054 - poolManager.initialize(key, uint160(10 * FixedPoint96.Q96), ZERO_BYTES); + poolManager.initialize(key, uint160(10 * FixedPoint96.Q96)); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e30 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e30 ether); @@ -1120,7 +1119,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); // price = 100 tick roughly 46054 - poolManager.initialize(key, uint160(10 * FixedPoint96.Q96), ZERO_BYTES); + poolManager.initialize(key, uint160(10 * FixedPoint96.Q96)); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e30 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e30 ether); @@ -1146,7 +1145,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); // price = 1 i.e. tick 0 - poolManager.initialize(key, uint160(1 * FixedPoint96.Q96), ZERO_BYTES); + poolManager.initialize(key, uint160(1 * FixedPoint96.Q96)); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e30 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e30 ether); @@ -1205,7 +1204,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); // price = 100 tick roughly 46054 - poolManager.initialize(key, uint160(10 * FixedPoint96.Q96), ZERO_BYTES); + poolManager.initialize(key, uint160(10 * FixedPoint96.Q96)); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e30 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e30 ether); @@ -1313,7 +1312,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(60) << 16) }); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); vm.expectEmit(true, true, true, true); emit ICLPoolManager.ModifyLiquidity(key.toId(), address(router), 0, 60, 100, 0); @@ -1337,7 +1336,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(60) << 16) }); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); vm.expectEmit(true, true, true, true); emit ICLPoolManager.ModifyLiquidity(key.toId(), address(router), 0, 60, 100, 0); @@ -1365,7 +1364,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams({tickLower: -60, tickUpper: 60, liquidityDelta: 100, salt: 0}); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); router.modifyPosition(key, params, ZERO_BYTES); @@ -1413,7 +1412,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams({tickLower: 0, tickUpper: 60, liquidityDelta: 100, salt: 0}); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); BalanceDelta balanceDelta; // create a new context to swallow up the revert @@ -1461,7 +1460,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams({tickLower: 0, tickUpper: 60, liquidityDelta: 100, salt: 0}); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); // make sure there is some liquidity router.modifyPosition(key, params, ZERO_BYTES); @@ -1501,7 +1500,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams({tickLower: 0, tickUpper: 60, liquidityDelta: 100, salt: 0}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); mockHooks.setReturnValue(mockHooks.beforeAddLiquidity.selector, bytes4(0xdeadbeef)); mockHooks.setReturnValue(mockHooks.afterAddLiquidity.selector, bytes4(0xdeadbeef)); @@ -1531,7 +1530,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams({tickLower: 0, tickUpper: 60, liquidityDelta: 100, salt: 0}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); mockHooks.setReturnValue(mockHooks.beforeAddLiquidity.selector, mockHooks.beforeAddLiquidity.selector); mockHooks.setReturnValue(mockHooks.afterAddLiquidity.selector, mockHooks.afterAddLiquidity.selector); @@ -1552,7 +1551,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(60) << 16) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); snapStart("CLPoolManagerTest#addLiquidity_nativeToken"); router.modifyPosition{value: 100}( @@ -1580,7 +1579,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); // price = 100 tick roughly 46054 - poolManager.initialize(key, uint160(10 * FixedPoint96.Q96), ZERO_BYTES); + poolManager.initialize(key, uint160(10 * FixedPoint96.Q96)); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e10 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e10 ether); @@ -1669,7 +1668,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); // price = 100 tick roughly 46054 - poolManager.initialize(key, uint160(10 * FixedPoint96.Q96), ZERO_BYTES); + poolManager.initialize(key, uint160(10 * FixedPoint96.Q96)); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e10 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e10 ether); @@ -1773,7 +1772,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps }); // price = 100 tick roughly 46054 - poolManager.initialize(key, uint160(10 * FixedPoint96.Q96), ZERO_BYTES); + poolManager.initialize(key, uint160(10 * FixedPoint96.Q96)); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e30 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e30 ether); @@ -1844,7 +1843,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(60) << 16) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory modifyPositionParams = ICLPoolManager.ModifyLiquidityParams({tickLower: -60, tickUpper: 60, liquidityDelta: 1 ether, salt: 0}); @@ -1879,7 +1878,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256((60 << 16) | clFeeManagerHook.getHooksRegistrationBitmap())) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory modifyPositionParams = ICLPoolManager.ModifyLiquidityParams({tickLower: -60, tickUpper: 60, liquidityDelta: 1 ether, salt: 0}); @@ -1913,7 +1912,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(60) << 16) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); poolManager.setProtocolFeeController(feeController); // 0.1% @@ -1971,7 +1970,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: false, settleUsingTransfer: false}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); vm.expectEmit(true, true, true, true); emit ICLPoolManager.Swap(key.toId(), address(router), 0, 0, SQRT_RATIO_1_2, 0, -6932, 3000, 0); @@ -1997,7 +1996,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: false, settleUsingTransfer: false}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); BalanceDelta balanceDelta; // create a new context to swallow up the revert @@ -2042,7 +2041,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: false, settleUsingTransfer: false}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.modifyPosition(key, params, ZERO_BYTES); mockHooks.setReturnValue(mockHooks.beforeSwap.selector, bytes4(0xdeadbeef)); @@ -2079,7 +2078,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: false, settleUsingTransfer: false}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.modifyPosition(key, params, ZERO_BYTES); mockHooks.setReturnValue(mockHooks.beforeSwap.selector, mockHooks.beforeSwap.selector); @@ -2107,7 +2106,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: false, settleUsingTransfer: true}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.modifyPosition( key, ICLPoolManager.ModifyLiquidityParams({ @@ -2143,7 +2142,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: false, settleUsingTransfer: true}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.modifyPosition( key, ICLPoolManager.ModifyLiquidityParams({ @@ -2194,7 +2193,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: true, settleUsingTransfer: true}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.swap(key, params, testSettings, ZERO_BYTES); params = ICLPoolManager.SwapParams({zeroForOne: true, amountSpecified: 100, sqrtPriceLimitX96: SQRT_RATIO_1_4}); @@ -2221,7 +2220,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: true, settleUsingTransfer: true}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.swap(key, params, testSettings, ZERO_BYTES); params = ICLPoolManager.SwapParams({zeroForOne: true, amountSpecified: 100, sqrtPriceLimitX96: SQRT_RATIO_1_4}); @@ -2250,7 +2249,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: true, settleUsingTransfer: true}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.swap(key, params, testSettings, ZERO_BYTES); params = ICLPoolManager.SwapParams({zeroForOne: true, amountSpecified: 100, sqrtPriceLimitX96: SQRT_RATIO_1_4}); @@ -2277,7 +2276,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: false, settleUsingTransfer: true}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.modifyPosition( key, ICLPoolManager.ModifyLiquidityParams({ @@ -2310,7 +2309,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: false, settleUsingTransfer: true}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.modifyPosition( key, ICLPoolManager.ModifyLiquidityParams({ @@ -2356,7 +2355,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: true, settleUsingTransfer: true}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.modifyPosition( key, ICLPoolManager.ModifyLiquidityParams({ @@ -2393,7 +2392,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps CLPoolManagerRouter.SwapTestSettings memory testSettings = CLPoolManagerRouter.SwapTestSettings({withdrawTokens: true, settleUsingTransfer: true}); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); router.modifyPosition{value: 1 ether}( key, ICLPoolManager.ModifyLiquidityParams({tickLower: -120, tickUpper: 120, liquidityDelta: 1 ether, salt: 0}), @@ -2437,7 +2436,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager: poolManager, parameters: bytes32(uint256(10 << 16)) }); - poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); + poolManager.initialize(key, sqrtPriceX96); vm.expectRevert(abi.encodeWithSelector(CLPool.NoLiquidityToReceiveFees.selector)); router.donate(key, 100, 100, ZERO_BYTES); } @@ -2452,7 +2451,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager: poolManager, parameters: bytes32(uint256(10 << 16)) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams(-60, 60, 100, 0); router.modifyPosition(key, params, ZERO_BYTES); @@ -2476,7 +2475,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps hooks: IHooks(address(0)), parameters: bytes32(uint256(10 << 16)) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams(-60, 60, 100, 0); router.modifyPosition{value: 1}(key, params, ZERO_BYTES); @@ -2502,7 +2501,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager: poolManager, parameters: bytes32(uint256(10 << 16) | impl.getHooksRegistrationBitmap()) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams(-60, 60, 100, 0); router.modifyPosition(key, params, ZERO_BYTES); @@ -2534,7 +2533,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager: poolManager, parameters: bytes32(uint256(10 << 16) | impl.getHooksRegistrationBitmap()) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams(-60, 60, 100, 0); router.modifyPosition(key, params, ZERO_BYTES); @@ -2554,7 +2553,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager: poolManager, parameters: bytes32(uint256(10 << 16)) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams(-60, 60, 100, 0); router.modifyPosition(key, params, ZERO_BYTES); @@ -2576,7 +2575,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager: poolManager, parameters: bytes32(uint256(10 << 16)) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams(-60, 60, 100, 0); router.modifyPosition(key, params, ZERO_BYTES); @@ -2603,7 +2602,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps invalidToken.approve(address(router), type(uint256).max); MockERC20(Currency.unwrap(currency0)).approve(address(router), type(uint256).max); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams(-60, 60, 1000, 0); router.modifyPosition(key, params, ZERO_BYTES); @@ -2626,7 +2625,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager: poolManager, parameters: bytes32(uint256(10) << 16) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams(-60, 60, 100, 0); router.modifyPosition(key, params, ZERO_BYTES); @@ -2642,7 +2641,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager: poolManager, parameters: bytes32(uint256(10) << 16) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory params = ICLPoolManager.ModifyLiquidityParams(-60, 60, 100, 0); router.modifyPosition{value: 100}(key, params, ZERO_BYTES); @@ -2660,7 +2659,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager: poolManager, parameters: bytes32(uint256(10) << 16) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); (CLPool.Slot0 memory slot0,,,) = poolManager.pools(key.toId()); assertEq(slot0.protocolFee, 0); @@ -2686,7 +2685,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); feeController.setProtocolFeeForPool(key.toId(), protocolFee); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); (CLPool.Slot0 memory slot0,,,) = poolManager.pools(key.toId()); assertEq(slot0.protocolFee, protocolFee); } @@ -2708,7 +2707,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); feeController.setProtocolFeeForPool(key.toId(), protocolFee); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); (CLPool.Slot0 memory slot0,,,) = poolManager.pools(key.toId()); assertEq(slot0.protocolFee, protocolFee); @@ -2749,7 +2748,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); feeController.setProtocolFeeForPool(key.toId(), protocolFee); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); (CLPool.Slot0 memory slot0,,,) = poolManager.pools(key.toId()); assertEq(slot0.protocolFee, protocolFee); @@ -2790,7 +2789,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager.setProtocolFeeController(IProtocolFeeController(address(feeController))); feeController.setProtocolFeeForPool(key.toId(), protocolFee); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); (CLPool.Slot0 memory slot0,,,) = poolManager.pools(key.toId()); assertEq(slot0.protocolFee, protocolFee); @@ -2861,7 +2860,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256((10 << 16) | clFeeManagerHook.getHooksRegistrationBitmap())) }); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); clFeeManagerHook.setFee(_swapFee); @@ -2890,7 +2889,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256((10 << 16) | clFeeManagerHook.getHooksRegistrationBitmap())) }); - poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, ZERO_BYTES); + poolManager.initialize(key, TickMath.MIN_SQRT_RATIO); clFeeManagerHook.setFee(_swapFee); @@ -2916,7 +2915,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0x10000)) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e10 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e10 ether); @@ -2949,7 +2948,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0x10000)) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e10 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e10 ether); @@ -2981,7 +2980,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps parameters: bytes32(uint256(0x10000)) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); IERC20(Currency.unwrap(currency0)).approve(address(router), 1e10 ether); IERC20(Currency.unwrap(currency1)).approve(address(router), 1e10 ether); @@ -3010,7 +3009,7 @@ contract CLPoolManagerTest is Test, NoIsolate, Deployers, TokenFixture, GasSnaps poolManager: poolManager, parameters: bytes32(uint256(10 << 16)) }); - poolManager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(key, SQRT_RATIO_1_1); // pause poolManager.pause(); diff --git a/test/pool-cl/CLPoolManagerBehaviorComparison.t.sol b/test/pool-cl/CLPoolManagerBehaviorComparison.t.sol index e51d28a..1d85b56 100644 --- a/test/pool-cl/CLPoolManagerBehaviorComparison.t.sol +++ b/test/pool-cl/CLPoolManagerBehaviorComparison.t.sol @@ -66,7 +66,7 @@ abstract contract V3Fuzzer is V3Helper, Deployers, Fuzzers, IUniswapV3MintCallba fee: fee, parameters: bytes32(0).setTickSpacing(tickSpacing) }); - manager.initialize(key_, sqrtPriceX96, ""); + manager.initialize(key_, sqrtPriceX96); } function addLiquidity( diff --git a/test/pool-cl/CLProtocolFees.t.sol b/test/pool-cl/CLProtocolFees.t.sol index 728b815..f9320f0 100644 --- a/test/pool-cl/CLProtocolFees.t.sol +++ b/test/pool-cl/CLProtocolFees.t.sol @@ -69,7 +69,7 @@ contract CLProtocolFeesTest is Test, Deployers, TokenFixture, GasSnapshot { parameters: bytes32(uint256((60 << 16) | hook.getHooksRegistrationBitmap())) }); - manager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + manager.initialize(key, SQRT_RATIO_1_1); } function testSetProtocolFeeControllerFuzz(uint24 protocolFee) public { @@ -171,7 +171,7 @@ contract CLProtocolFeesTest is Test, Deployers, TokenFixture, GasSnapshot { key.fee = 6000; uint256 gasBefore = gasleft(); - manager.initialize(key, SQRT_RATIO_1_1, ZERO_BYTES); + manager.initialize(key, SQRT_RATIO_1_1); uint256 gasConsumed = gasBefore - gasleft(); /// @dev Return data size 230k would consume almost all the gas speicified in the controllerGasLimit i.e. 500k /// And the gas consumed by the tx would be more than 800K if the payload is copied to the caller context. diff --git a/test/pool-cl/helpers/BaseCLTestHook.sol b/test/pool-cl/helpers/BaseCLTestHook.sol index e90225c..321bed9 100644 --- a/test/pool-cl/helpers/BaseCLTestHook.sol +++ b/test/pool-cl/helpers/BaseCLTestHook.sol @@ -32,15 +32,11 @@ contract BaseCLTestHook is ICLHooks { revert HookNotImplemented(); } - function beforeInitialize(address, PoolKey calldata, uint160, bytes calldata) external virtual returns (bytes4) { + function beforeInitialize(address, PoolKey calldata, uint160) external virtual returns (bytes4) { revert HookNotImplemented(); } - function afterInitialize(address, PoolKey calldata, uint160, int24, bytes calldata) - external - virtual - returns (bytes4) - { + function afterInitialize(address, PoolKey calldata, uint160, int24) external virtual returns (bytes4) { revert HookNotImplemented(); } diff --git a/test/pool-cl/helpers/CLFeeManagerHook.sol b/test/pool-cl/helpers/CLFeeManagerHook.sol index bf89640..750b564 100644 --- a/test/pool-cl/helpers/CLFeeManagerHook.sol +++ b/test/pool-cl/helpers/CLFeeManagerHook.sol @@ -35,11 +35,7 @@ contract CLFeeManagerHook is BaseCLTestHook { } /// @dev update swap fee once pool is initialized - function afterInitialize(address, PoolKey calldata key, uint160, int24, bytes calldata) - external - override - returns (bytes4) - { + function afterInitialize(address, PoolKey calldata key, uint160, int24) external override returns (bytes4) { clManager.updateDynamicLPFee(key, fee); return ICLHooks.afterInitialize.selector; } diff --git a/test/pool-cl/helpers/CLRevertHook.sol b/test/pool-cl/helpers/CLRevertHook.sol index c4fd866..2e6c347 100644 --- a/test/pool-cl/helpers/CLRevertHook.sol +++ b/test/pool-cl/helpers/CLRevertHook.sol @@ -5,6 +5,8 @@ import {PoolKey} from "../../../src/types/PoolKey.sol"; import {BaseCLTestHook} from "./BaseCLTestHook.sol"; contract CLRevertHook is BaseCLTestHook { + bool public revertWithHookNotImplemented; + function getHooksRegistrationBitmap() external pure override returns (uint16) { return _hooksRegistrationBitmapFrom( Permissions({ @@ -26,13 +28,11 @@ contract CLRevertHook is BaseCLTestHook { ); } - function afterInitialize(address, PoolKey calldata, uint160, int24, bytes calldata data) - external - pure - override - returns (bytes4) - { - (bool revertWithHookNotImplemented) = abi.decode(data, (bool)); + function setRevertWithHookNotImplemented(bool value) public { + revertWithHookNotImplemented = value; + } + + function afterInitialize(address, PoolKey calldata, uint160, int24) external view override returns (bytes4) { if (revertWithHookNotImplemented) { revert HookNotImplemented(); } else { diff --git a/test/pool-cl/helpers/CLSkipCallbackHook.sol b/test/pool-cl/helpers/CLSkipCallbackHook.sol index 2e2b767..92edbf7 100644 --- a/test/pool-cl/helpers/CLSkipCallbackHook.sol +++ b/test/pool-cl/helpers/CLSkipCallbackHook.sol @@ -56,8 +56,8 @@ contract CLSkipCallbackHook is BaseCLTestHook { bytes rawCallbackData; } - function initialize(PoolKey memory key, uint160 sqrtPriceX96, bytes memory hookData) external { - poolManager.initialize(key, sqrtPriceX96, hookData); + function initialize(PoolKey memory key, uint160 sqrtPriceX96) external { + poolManager.initialize(key, sqrtPriceX96); } struct ModifyPositionCallbackData { @@ -215,16 +215,12 @@ contract CLSkipCallbackHook is BaseCLTestHook { } } - function beforeInitialize(address, PoolKey calldata, uint160, bytes calldata) external override returns (bytes4) { + function beforeInitialize(address, PoolKey calldata, uint160) external override returns (bytes4) { hookCounterCallbackCount++; return CLSkipCallbackHook.beforeInitialize.selector; } - function afterInitialize(address, PoolKey calldata, uint160, int24, bytes calldata) - external - override - returns (bytes4) - { + function afterInitialize(address, PoolKey calldata, uint160, int24) external override returns (bytes4) { hookCounterCallbackCount++; return CLSkipCallbackHook.afterInitialize.selector; } diff --git a/test/pool-cl/helpers/Deployers.sol b/test/pool-cl/helpers/Deployers.sol index a2dacc9..0c6eba5 100644 --- a/test/pool-cl/helpers/Deployers.sol +++ b/test/pool-cl/helpers/Deployers.sol @@ -45,13 +45,6 @@ contract Deployers { function createPool(ICLPoolManager manager, IHooks hooks, uint24 fee, uint160 sqrtPriceX96) private returns (PoolKey memory key, PoolId id) - { - (key, id) = createPool(manager, hooks, fee, sqrtPriceX96, ZERO_BYTES); - } - - function createPool(ICLPoolManager manager, IHooks hooks, uint24 fee, uint160 sqrtPriceX96, bytes memory initData) - private - returns (PoolKey memory key, PoolId id) { MockERC20[] memory tokens = deployTokens(2, 2 ** 255); (Currency currency0, Currency currency1) = SortTokens.sort(tokens[0], tokens[1]); @@ -66,22 +59,15 @@ contract Deployers { : bytes32(uint256(((fee / 100 * 2) << 16) | 0x00ff)) ); id = key.toId(); - manager.initialize(key, sqrtPriceX96, initData); + manager.initialize(key, sqrtPriceX96); } function createFreshPool(IHooks hooks, uint24 fee, uint160 sqrtPriceX96) internal returns (IVault vault, ICLPoolManager manager, PoolKey memory key, PoolId id) - { - (vault, manager, key, id) = createFreshPool(hooks, fee, sqrtPriceX96, ZERO_BYTES); - } - - function createFreshPool(IHooks hooks, uint24 fee, uint160 sqrtPriceX96, bytes memory initData) - internal - returns (IVault vault, ICLPoolManager manager, PoolKey memory key, PoolId id) { (vault, manager) = createFreshManager(); - (key, id) = createPool(manager, hooks, fee, sqrtPriceX96, initData); + (key, id) = createPool(manager, hooks, fee, sqrtPriceX96); return (vault, manager, key, id); } diff --git a/test/pool-cl/helpers/MockHooks.sol b/test/pool-cl/helpers/MockHooks.sol index 0f8659c..9b7dbaf 100644 --- a/test/pool-cl/helpers/MockHooks.sol +++ b/test/pool-cl/helpers/MockHooks.sol @@ -12,8 +12,6 @@ import {PoolId} from "../../../src/types/PoolId.sol"; contract MockHooks is ICLHooks { using Hooks for ICLHooks; - bytes public beforeInitializeData; - bytes public afterInitializeData; bytes public beforeAddLiquidityData; bytes public afterAddLiquidityData; bytes public beforeRemoveLiquidityData; @@ -37,22 +35,12 @@ contract MockHooks is ICLHooks { bitmap = newBitmapValue; } - function beforeInitialize(address, PoolKey calldata, uint160, bytes calldata hookData) - external - override - returns (bytes4) - { - beforeInitializeData = hookData; + function beforeInitialize(address, PoolKey calldata, uint160) external override returns (bytes4) { bytes4 selector = MockHooks.beforeInitialize.selector; return returnValues[selector] == bytes4(0) ? selector : returnValues[selector]; } - function afterInitialize(address, PoolKey calldata, uint160, int24, bytes calldata hookData) - external - override - returns (bytes4) - { - afterInitializeData = hookData; + function afterInitialize(address, PoolKey calldata, uint160, int24) external override returns (bytes4) { bytes4 selector = MockHooks.afterInitialize.selector; return returnValues[selector] == bytes4(0) ? selector : returnValues[selector]; } diff --git a/test/pool-cl/libraries/CLPoolSwapFee.t.sol b/test/pool-cl/libraries/CLPoolSwapFee.t.sol index 082e2d0..7b15a67 100644 --- a/test/pool-cl/libraries/CLPoolSwapFee.t.sol +++ b/test/pool-cl/libraries/CLPoolSwapFee.t.sol @@ -66,13 +66,13 @@ contract CLPoolSwapFeeTest is Deployers, TokenFixture, Test { function testPoolInitializeFailsWithTooLargeFee() public { staticFeeKey.fee = LPFeeLibrary.ONE_HUNDRED_PERCENT_FEE + 1; vm.expectRevert(abi.encodeWithSelector(LPFeeLibrary.LPFeeTooLarge.selector, staticFeeKey.fee)); - poolManager.initialize(staticFeeKey, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(staticFeeKey, SQRT_RATIO_1_1); } function testUpdateFailsWithTooLargeFee() public { hook.setFee(LPFeeLibrary.ONE_HUNDRED_PERCENT_FEE / 2); hook.setHooksRegistrationBitmap(uint16((1 << HOOKS_BEFORE_SWAP_OFFSET) | (1 << HOOKS_AFTER_INITIALIZE_OFFSET))); - poolManager.initialize(dynamicFeeKey, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(dynamicFeeKey, SQRT_RATIO_1_1); hook.setFee(LPFeeLibrary.ONE_HUNDRED_PERCENT_FEE + 1); vm.expectRevert( @@ -87,7 +87,7 @@ contract CLPoolSwapFeeTest is Deployers, TokenFixture, Test { // starts from price = 1 hook.setHooksRegistrationBitmap(uint16((1 << HOOKS_BEFORE_SWAP_OFFSET) | (1 << HOOKS_AFTER_INITIALIZE_OFFSET))); - poolManager.initialize(dynamicFeeKey, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(dynamicFeeKey, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory modifyPositionParams = ICLPoolManager.ModifyLiquidityParams({tickLower: -60, tickUpper: 60, liquidityDelta: 1 ether, salt: 0}); @@ -117,7 +117,7 @@ contract CLPoolSwapFeeTest is Deployers, TokenFixture, Test { function testSwapWorksWithStaticFee() public { // starts from price = 1 - poolManager.initialize(staticFeeKey, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(staticFeeKey, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory modifyPositionParams = ICLPoolManager.ModifyLiquidityParams({tickLower: -60, tickUpper: 60, liquidityDelta: 1 ether, salt: 0}); @@ -150,7 +150,7 @@ contract CLPoolSwapFeeTest is Deployers, TokenFixture, Test { hook.setHooksRegistrationBitmap(uint16((1 << HOOKS_BEFORE_SWAP_OFFSET) | (1 << HOOKS_AFTER_INITIALIZE_OFFSET))); // starts from price = 1 - poolManager.initialize(dynamicFeeKey, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(dynamicFeeKey, SQRT_RATIO_1_1); ICLPoolManager.ModifyLiquidityParams memory modifyPositionParams = ICLPoolManager.ModifyLiquidityParams({tickLower: -60, tickUpper: 60, liquidityDelta: 1 ether, salt: 0}); @@ -183,6 +183,6 @@ contract CLPoolSwapFeeTest is Deployers, TokenFixture, Test { }); vm.expectRevert(Hooks.HookConfigValidationError.selector); - poolManager.initialize(_key, SQRT_RATIO_1_1, ZERO_BYTES); + poolManager.initialize(_key, SQRT_RATIO_1_1); } }