From 22c8d6f34955edd752076c6865cd67c606c47db7 Mon Sep 17 00:00:00 2001 From: chefburger Date: Fri, 7 Jun 2024 15:36:35 +0800 Subject: [PATCH] feat: support salt for cl-pool nfpManager --- ...ddLiquidityOutsideActiveId_ExistingId.snap | 2 +- ...testAddLiquidityOutsideActiveId_NewId.snap | 2 +- ...dityTest#testAddLiquidityWithActiveId.snap | 2 +- ...testAddLiquidityWithActiveId_WithHook.snap | 2 +- ...oveLiquidityOutsideActiveId_ThreeBins.snap | 2 +- ...RemoveLiquidityWithActiveId_ThreeBins.snap | 2 +- ...iquidityTest#testRemoveLiquidity_Half.snap | 2 +- ...kenTest#testBatchTransferFrom_FromBob.snap | 2 +- ...nTest#testBatchTransferFrom_FromOwner.snap | 2 +- .../BinFungibleTokenTest#testBurn.snap | 2 +- .../BinFungibleTokenTest#testMint.snap | 2 +- ...stExactInputSingle_DifferentRecipient.snap | 2 +- ...ctInputSingle_EthPool_SwapEthForToken.snap | 2 +- ...ctInputSingle_EthPool_SwapTokenForEth.snap | 2 +- ...rTest#testExactInputSingle_SwapForY_1.snap | 2 +- ...rTest#testExactInputSingle_SwapForY_2.snap | 2 +- ...ExactInput_MultiHopDifferentRecipient.snap | 2 +- ...tExactOutputSingle_DifferentRecipient.snap | 2 +- ...Test#testExactOutputSingle_SwapForY_1.snap | 2 +- ...Test#testExactOutputSingle_SwapForY_2.snap | 2 +- ...xactOutput_MultiHopDifferentRecipient.snap | 2 +- ...pRouterTest#testExactOutput_SingleHop.snap | 2 +- .../CLSwapRouterTest#ExactInput.snap | 2 +- .../CLSwapRouterTest#ExactInputSingle.snap | 2 +- .../CLSwapRouterTest#ExactOutput.snap | 2 +- .../CLSwapRouterTest#ExactOutputSingle.snap | 2 +- .../NonfungiblePositionManager#burn.snap | 2 +- .../NonfungiblePositionManager#collect.snap | 2 +- ...iblePositionManager#decreaseLiquidity.snap | 2 +- ...iblePositionManager#increaseLiquidity.snap | 2 +- .../NonfungiblePositionManager#mint.snap | 2 +- src/pool-cl/NonfungiblePositionManager.sol | 35 ++-- src/pool-cl/base/LiquidityManagement.sol | 19 +- .../INonfungiblePositionManager.sol | 5 +- test/pool-cl/CLSwapRouterInvariant.t.sol | 1 + test/pool-cl/NonFungiblePositionManager.t.sol | 191 ++++++++++++++---- 36 files changed, 216 insertions(+), 97 deletions(-) diff --git a/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityOutsideActiveId_ExistingId.snap b/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityOutsideActiveId_ExistingId.snap index c63c524..6ea326b 100644 --- a/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityOutsideActiveId_ExistingId.snap +++ b/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityOutsideActiveId_ExistingId.snap @@ -1 +1 @@ -185311 \ No newline at end of file +182676 \ No newline at end of file diff --git a/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityOutsideActiveId_NewId.snap b/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityOutsideActiveId_NewId.snap index 1227dbb..73b72bd 100644 --- a/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityOutsideActiveId_NewId.snap +++ b/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityOutsideActiveId_NewId.snap @@ -1 +1 @@ -638186 \ No newline at end of file +636695 \ No newline at end of file diff --git a/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityWithActiveId.snap b/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityWithActiveId.snap index dd3a178..886d232 100644 --- a/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityWithActiveId.snap +++ b/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityWithActiveId.snap @@ -1 +1 @@ -906704 \ No newline at end of file +904184 \ No newline at end of file diff --git a/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityWithActiveId_WithHook.snap b/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityWithActiveId_WithHook.snap index c36ffe2..f4e7b64 100644 --- a/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityWithActiveId_WithHook.snap +++ b/.forge-snapshots/BinFungiblePositionManager_AddLiquidityTest#testAddLiquidityWithActiveId_WithHook.snap @@ -1 +1 @@ -1274539 \ No newline at end of file +1270878 \ No newline at end of file diff --git a/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidityOutsideActiveId_ThreeBins.snap b/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidityOutsideActiveId_ThreeBins.snap index 608ae11..13f4b1c 100644 --- a/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidityOutsideActiveId_ThreeBins.snap +++ b/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidityOutsideActiveId_ThreeBins.snap @@ -1 +1 @@ -148991 \ No newline at end of file +147212 \ No newline at end of file diff --git a/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidityWithActiveId_ThreeBins.snap b/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidityWithActiveId_ThreeBins.snap index 9006ca0..a6de89c 100644 --- a/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidityWithActiveId_ThreeBins.snap +++ b/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidityWithActiveId_ThreeBins.snap @@ -1 +1 @@ -216053 \ No newline at end of file +213764 \ No newline at end of file diff --git a/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidity_Half.snap b/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidity_Half.snap index 4d09eda..1f80391 100644 --- a/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidity_Half.snap +++ b/.forge-snapshots/BinFungiblePositionManager_RemoveLiquidityTest#testRemoveLiquidity_Half.snap @@ -1 +1 @@ -241767 \ No newline at end of file +239002 \ No newline at end of file diff --git a/.forge-snapshots/BinFungibleTokenTest#testBatchTransferFrom_FromBob.snap b/.forge-snapshots/BinFungibleTokenTest#testBatchTransferFrom_FromBob.snap index 0ef3935..109f32f 100644 --- a/.forge-snapshots/BinFungibleTokenTest#testBatchTransferFrom_FromBob.snap +++ b/.forge-snapshots/BinFungibleTokenTest#testBatchTransferFrom_FromBob.snap @@ -1 +1 @@ -54723 \ No newline at end of file +53954 \ No newline at end of file diff --git a/.forge-snapshots/BinFungibleTokenTest#testBatchTransferFrom_FromOwner.snap b/.forge-snapshots/BinFungibleTokenTest#testBatchTransferFrom_FromOwner.snap index 506e4cc..5ba9e3e 100644 --- a/.forge-snapshots/BinFungibleTokenTest#testBatchTransferFrom_FromOwner.snap +++ b/.forge-snapshots/BinFungibleTokenTest#testBatchTransferFrom_FromOwner.snap @@ -1 +1 @@ -52095 \ No newline at end of file +51680 \ No newline at end of file diff --git a/.forge-snapshots/BinFungibleTokenTest#testBurn.snap b/.forge-snapshots/BinFungibleTokenTest#testBurn.snap index d7585d6..4da38a3 100644 --- a/.forge-snapshots/BinFungibleTokenTest#testBurn.snap +++ b/.forge-snapshots/BinFungibleTokenTest#testBurn.snap @@ -1 +1 @@ -26896 \ No newline at end of file +27059 \ No newline at end of file diff --git a/.forge-snapshots/BinFungibleTokenTest#testMint.snap b/.forge-snapshots/BinFungibleTokenTest#testMint.snap index 4b59870..aa5791d 100644 --- a/.forge-snapshots/BinFungibleTokenTest#testMint.snap +++ b/.forge-snapshots/BinFungibleTokenTest#testMint.snap @@ -1 +1 @@ -67373 \ No newline at end of file +67621 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_DifferentRecipient.snap b/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_DifferentRecipient.snap index 30d5ec8..c63f2d2 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_DifferentRecipient.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_DifferentRecipient.snap @@ -1 +1 @@ -154616 \ No newline at end of file +152292 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_EthPool_SwapEthForToken.snap b/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_EthPool_SwapEthForToken.snap index c2ddc61..e93e55a 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_EthPool_SwapEthForToken.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_EthPool_SwapEthForToken.snap @@ -1 +1 @@ -145793 \ No newline at end of file +143954 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_EthPool_SwapTokenForEth.snap b/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_EthPool_SwapTokenForEth.snap index 4374681..7ae5c03 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_EthPool_SwapTokenForEth.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_EthPool_SwapTokenForEth.snap @@ -1 +1 @@ -151891 \ No newline at end of file +149662 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_SwapForY_1.snap b/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_SwapForY_1.snap index fe72d2e..c69b29a 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_SwapForY_1.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_SwapForY_1.snap @@ -1 +1 @@ -152610 \ No newline at end of file +150280 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_SwapForY_2.snap b/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_SwapForY_2.snap index 9d11b91..47fcd7c 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_SwapForY_2.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactInputSingle_SwapForY_2.snap @@ -1 +1 @@ -152651 \ No newline at end of file +150337 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactInput_MultiHopDifferentRecipient.snap b/.forge-snapshots/BinSwapRouterTest#testExactInput_MultiHopDifferentRecipient.snap index 17618a0..3c434ff 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactInput_MultiHopDifferentRecipient.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactInput_MultiHopDifferentRecipient.snap @@ -1 +1 @@ -179342 \ No newline at end of file +176041 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_DifferentRecipient.snap b/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_DifferentRecipient.snap index 74d15c8..1766b13 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_DifferentRecipient.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_DifferentRecipient.snap @@ -1 +1 @@ -164893 \ No newline at end of file +161837 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_SwapForY_1.snap b/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_SwapForY_1.snap index f61cf35..25ca7e9 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_SwapForY_1.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_SwapForY_1.snap @@ -1 +1 @@ -162899 \ No newline at end of file +159837 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_SwapForY_2.snap b/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_SwapForY_2.snap index 1ed48c6..da0a53f 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_SwapForY_2.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactOutputSingle_SwapForY_2.snap @@ -1 +1 @@ -162936 \ No newline at end of file +159885 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactOutput_MultiHopDifferentRecipient.snap b/.forge-snapshots/BinSwapRouterTest#testExactOutput_MultiHopDifferentRecipient.snap index 510b4ae..28df8f1 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactOutput_MultiHopDifferentRecipient.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactOutput_MultiHopDifferentRecipient.snap @@ -1 +1 @@ -193297 \ No newline at end of file +188524 \ No newline at end of file diff --git a/.forge-snapshots/BinSwapRouterTest#testExactOutput_SingleHop.snap b/.forge-snapshots/BinSwapRouterTest#testExactOutput_SingleHop.snap index d45294d..fb43c66 100644 --- a/.forge-snapshots/BinSwapRouterTest#testExactOutput_SingleHop.snap +++ b/.forge-snapshots/BinSwapRouterTest#testExactOutput_SingleHop.snap @@ -1 +1 @@ -155207 \ No newline at end of file +152243 \ No newline at end of file diff --git a/.forge-snapshots/CLSwapRouterTest#ExactInput.snap b/.forge-snapshots/CLSwapRouterTest#ExactInput.snap index bf91f5f..3c3057d 100644 --- a/.forge-snapshots/CLSwapRouterTest#ExactInput.snap +++ b/.forge-snapshots/CLSwapRouterTest#ExactInput.snap @@ -1 +1 @@ -255442 \ No newline at end of file +251030 \ No newline at end of file diff --git a/.forge-snapshots/CLSwapRouterTest#ExactInputSingle.snap b/.forge-snapshots/CLSwapRouterTest#ExactInputSingle.snap index 1a36d18..1b85096 100644 --- a/.forge-snapshots/CLSwapRouterTest#ExactInputSingle.snap +++ b/.forge-snapshots/CLSwapRouterTest#ExactInputSingle.snap @@ -1 +1 @@ -192524 \ No newline at end of file +189735 \ No newline at end of file diff --git a/.forge-snapshots/CLSwapRouterTest#ExactOutput.snap b/.forge-snapshots/CLSwapRouterTest#ExactOutput.snap index ea40a60..e39b3fc 100644 --- a/.forge-snapshots/CLSwapRouterTest#ExactOutput.snap +++ b/.forge-snapshots/CLSwapRouterTest#ExactOutput.snap @@ -1 +1 @@ -260676 \ No newline at end of file +257088 \ No newline at end of file diff --git a/.forge-snapshots/CLSwapRouterTest#ExactOutputSingle.snap b/.forge-snapshots/CLSwapRouterTest#ExactOutputSingle.snap index 8626acc..dfb4790 100644 --- a/.forge-snapshots/CLSwapRouterTest#ExactOutputSingle.snap +++ b/.forge-snapshots/CLSwapRouterTest#ExactOutputSingle.snap @@ -1 +1 @@ -191719 \ No newline at end of file +189249 \ No newline at end of file diff --git a/.forge-snapshots/NonfungiblePositionManager#burn.snap b/.forge-snapshots/NonfungiblePositionManager#burn.snap index 0d4e47b..3eb1ec5 100644 --- a/.forge-snapshots/NonfungiblePositionManager#burn.snap +++ b/.forge-snapshots/NonfungiblePositionManager#burn.snap @@ -1 +1 @@ -62578 \ No newline at end of file +64452 \ No newline at end of file diff --git a/.forge-snapshots/NonfungiblePositionManager#collect.snap b/.forge-snapshots/NonfungiblePositionManager#collect.snap index e2d4db9..db2d80f 100644 --- a/.forge-snapshots/NonfungiblePositionManager#collect.snap +++ b/.forge-snapshots/NonfungiblePositionManager#collect.snap @@ -1 +1 @@ -265663 \ No newline at end of file +266684 \ No newline at end of file diff --git a/.forge-snapshots/NonfungiblePositionManager#decreaseLiquidity.snap b/.forge-snapshots/NonfungiblePositionManager#decreaseLiquidity.snap index 5e420ab..008e294 100644 --- a/.forge-snapshots/NonfungiblePositionManager#decreaseLiquidity.snap +++ b/.forge-snapshots/NonfungiblePositionManager#decreaseLiquidity.snap @@ -1 +1 @@ -161440 \ No newline at end of file +160846 \ No newline at end of file diff --git a/.forge-snapshots/NonfungiblePositionManager#increaseLiquidity.snap b/.forge-snapshots/NonfungiblePositionManager#increaseLiquidity.snap index 11769d0..0e701a5 100644 --- a/.forge-snapshots/NonfungiblePositionManager#increaseLiquidity.snap +++ b/.forge-snapshots/NonfungiblePositionManager#increaseLiquidity.snap @@ -1 +1 @@ -195159 \ No newline at end of file +194416 \ No newline at end of file diff --git a/.forge-snapshots/NonfungiblePositionManager#mint.snap b/.forge-snapshots/NonfungiblePositionManager#mint.snap index c427d27..22cd5f9 100644 --- a/.forge-snapshots/NonfungiblePositionManager#mint.snap +++ b/.forge-snapshots/NonfungiblePositionManager#mint.snap @@ -1 +1 @@ -607379 \ No newline at end of file +607284 \ No newline at end of file diff --git a/src/pool-cl/NonfungiblePositionManager.sol b/src/pool-cl/NonfungiblePositionManager.sol index ba3406f..2ebd460 100644 --- a/src/pool-cl/NonfungiblePositionManager.sol +++ b/src/pool-cl/NonfungiblePositionManager.sol @@ -79,7 +79,8 @@ contract NonfungiblePositionManager is uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, + bytes32 salt ) { Position memory position = _positions[tokenId]; @@ -97,7 +98,8 @@ contract NonfungiblePositionManager is position.feeGrowthInside0LastX128, position.feeGrowthInside1LastX128, position.tokensOwed0, - position.tokensOwed1 + position.tokensOwed1, + position.salt ); } @@ -224,6 +226,7 @@ contract NonfungiblePositionManager is poolKey: params.poolKey, tickLower: params.tickLower, tickUpper: params.tickUpper, + salt: params.salt, amount0Desired: params.amount0Desired, amount1Desired: params.amount1Desired, amount0Min: params.amount0Min, @@ -234,9 +237,8 @@ contract NonfungiblePositionManager is uint256 tokenId = _nextId++; _mint(params.recipient, tokenId); - // todo: about the salt CLPosition.Info memory positionInfo = poolManager.getPosition( - params.poolKey.toId(), address(this), params.tickLower, params.tickUpper, bytes32(0) + params.poolKey.toId(), address(this), params.tickLower, params.tickUpper, params.salt ); _positions[tokenId] = Position({ nonce: 0, @@ -248,7 +250,8 @@ contract NonfungiblePositionManager is feeGrowthInside0LastX128: positionInfo.feeGrowthInside0LastX128, feeGrowthInside1LastX128: positionInfo.feeGrowthInside1LastX128, tokensOwed0: 0, - tokensOwed1: 0 + tokensOwed1: 0, + salt: params.salt }); if (address(_poolIdToPoolKey[params.poolKey.toId()].poolManager) == address(0)) { _poolIdToPoolKey[params.poolKey.toId()] = params.poolKey; @@ -263,16 +266,18 @@ contract NonfungiblePositionManager is IncreaseLiquidityParams memory params = abi.decode(data.params, (IncreaseLiquidityParams)); Position storage nftPosition = _positions[params.tokenId]; PoolId poolId = nftPosition.poolId; - PoolKey memory poolKey = _poolIdToPoolKey[poolId]; uint128 existingLiquility = nftPosition.liquidity; int24 tickLower = nftPosition.tickLower; int24 tickUpper = nftPosition.tickUpper; + bytes32 salt = nftPosition.salt; + PoolKey memory poolKey = _poolIdToPoolKey[poolId]; (uint128 liquidity, BalanceDelta delta) = addLiquidity( AddLiquidityParams({ poolKey: poolKey, tickLower: tickLower, tickUpper: tickUpper, + salt: salt, amount0Desired: params.amount0Desired, amount1Desired: params.amount1Desired, amount0Min: params.amount0Min, @@ -280,9 +285,8 @@ contract NonfungiblePositionManager is }) ); - // todo: about the salt CLPosition.Info memory poolManagerPositionInfo = - poolManager.getPosition(poolId, address(this), tickLower, tickUpper, bytes32(0)); + poolManager.getPosition(poolId, address(this), tickLower, tickUpper, salt); /// @dev This can be overflow in following cases: /// 1. feeGrowthInside0LastX128 is overflow @@ -323,10 +327,11 @@ contract NonfungiblePositionManager is DecreaseLiquidityParams memory params = abi.decode(data.params, (DecreaseLiquidityParams)); Position storage nftPosition = _positions[params.tokenId]; PoolId poolId = nftPosition.poolId; - PoolKey memory poolKey = _poolIdToPoolKey[poolId]; uint128 liquidity = nftPosition.liquidity; int24 tickLower = nftPosition.tickLower; int24 tickUpper = nftPosition.tickUpper; + bytes32 salt = nftPosition.salt; + PoolKey memory poolKey = _poolIdToPoolKey[poolId]; if (liquidity < params.liquidity) { revert InvalidLiquidityDecreaseAmount(); @@ -339,13 +344,13 @@ contract NonfungiblePositionManager is tickUpper: tickUpper, liquidity: params.liquidity, amount0Min: params.amount0Min, - amount1Min: params.amount1Min + amount1Min: params.amount1Min, + salt: salt }) ); - // todo: about the salt CLPosition.Info memory poolManagerPositionInfo = - poolManager.getPosition(poolId, address(this), tickLower, tickUpper, bytes32(0)); + poolManager.getPosition(poolId, address(this), tickLower, tickUpper, salt); /// @dev This can be overflow in following cases: /// 1. feeGrowthInside0LastX128 is overflow @@ -390,17 +395,17 @@ contract NonfungiblePositionManager is Position storage nftPosition = _positions[params.tokenId]; Position memory nftPositionCache = _positions[params.tokenId]; PoolId poolId = nftPositionCache.poolId; + bytes32 salt = nftPositionCache.salt; PoolKey memory poolKey = _poolIdToPoolKey[poolId]; uint128 tokensOwed0 = nftPositionCache.tokensOwed0; uint128 tokensOwed1 = nftPositionCache.tokensOwed1; if (nftPositionCache.liquidity > 0) { - mintAccumulatedPositionFee(poolKey, nftPositionCache.tickLower, nftPositionCache.tickUpper); + mintAccumulatedPositionFee(poolKey, nftPositionCache.tickLower, nftPositionCache.tickUpper, salt); - // todo: about the salt CLPosition.Info memory poolManagerPositionInfo = poolManager.getPosition( - poolId, address(this), nftPositionCache.tickLower, nftPositionCache.tickUpper, bytes32(0) + poolId, address(this), nftPositionCache.tickLower, nftPositionCache.tickUpper, salt ); /// @dev This can be overflow in following cases: diff --git a/src/pool-cl/base/LiquidityManagement.sol b/src/pool-cl/base/LiquidityManagement.sol index a1c8223..e48e699 100644 --- a/src/pool-cl/base/LiquidityManagement.sol +++ b/src/pool-cl/base/LiquidityManagement.sol @@ -20,15 +20,13 @@ import {LiquidityAmounts} from "../libraries/LiquidityAmounts.sol"; abstract contract LiquidityManagement is CLPeripheryImmutableState, PeripheryPayments { using PoolIdLibrary for PoolKey; - // todo: think if salt require non zero byte - bytes32 constant SALT_0 = bytes32(0); - error PriceSlippageCheckFailed(); struct AddLiquidityParams { PoolKey poolKey; int24 tickLower; int24 tickUpper; + bytes32 salt; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; @@ -42,16 +40,19 @@ abstract contract LiquidityManagement is CLPeripheryImmutableState, PeripheryPay uint128 liquidity; uint256 amount0Min; uint256 amount1Min; + bytes32 salt; } /// @notice Claim accumulated fees from the position and mint them to the NFP contract - function mintAccumulatedPositionFee(PoolKey memory poolKey, int24 tickLower, int24 tickUpper) internal { + function mintAccumulatedPositionFee(PoolKey memory poolKey, int24 tickLower, int24 tickUpper, bytes32 salt) + internal + { CLPosition.Info memory poolManagerPositionInfo = - poolManager.getPosition(poolKey.toId(), address(this), tickLower, tickUpper, SALT_0); + poolManager.getPosition(poolKey.toId(), address(this), tickLower, tickUpper, salt); if (poolManagerPositionInfo.liquidity > 0) { (, BalanceDelta feeDelta) = poolManager.modifyLiquidity( - poolKey, ICLPoolManager.ModifyLiquidityParams(tickLower, tickUpper, 0, SALT_0), "" + poolKey, ICLPoolManager.ModifyLiquidityParams(tickLower, tickUpper, 0, salt), "" ); mintFeeDelta(poolKey, feeDelta); @@ -82,7 +83,9 @@ abstract contract LiquidityManagement is CLPeripheryImmutableState, PeripheryPay BalanceDelta feeDelta; (delta, feeDelta) = poolManager.modifyLiquidity( params.poolKey, - ICLPoolManager.ModifyLiquidityParams(params.tickLower, params.tickUpper, int256(uint256(liquidity)), SALT_0), + ICLPoolManager.ModifyLiquidityParams( + params.tickLower, params.tickUpper, int256(uint256(liquidity)), params.salt + ), "" ); @@ -105,7 +108,7 @@ abstract contract LiquidityManagement is CLPeripheryImmutableState, PeripheryPay (delta, feeDelta) = poolManager.modifyLiquidity( params.poolKey, ICLPoolManager.ModifyLiquidityParams( - params.tickLower, params.tickUpper, -int256(uint256(params.liquidity)), SALT_0 + params.tickLower, params.tickUpper, -int256(uint256(params.liquidity)), params.salt ), "" ); diff --git a/src/pool-cl/interfaces/INonfungiblePositionManager.sol b/src/pool-cl/interfaces/INonfungiblePositionManager.sol index 978f7d2..1d457b1 100644 --- a/src/pool-cl/interfaces/INonfungiblePositionManager.sol +++ b/src/pool-cl/interfaces/INonfungiblePositionManager.sol @@ -87,6 +87,7 @@ interface INonfungiblePositionManager is // how many uncollected tokens are owed to the position, as of the last computation uint128 tokensOwed0; uint128 tokensOwed1; + bytes32 salt; } /// @notice Returns the position information associated with a given token ID. @@ -105,7 +106,8 @@ interface INonfungiblePositionManager is uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, + bytes32 salt ); /// @notice Initialize the pool state for a given pool ID. @@ -123,6 +125,7 @@ interface INonfungiblePositionManager is PoolKey poolKey; int24 tickLower; int24 tickUpper; + bytes32 salt; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; diff --git a/test/pool-cl/CLSwapRouterInvariant.t.sol b/test/pool-cl/CLSwapRouterInvariant.t.sol index c5beb8b..f97314c 100644 --- a/test/pool-cl/CLSwapRouterInvariant.t.sol +++ b/test/pool-cl/CLSwapRouterInvariant.t.sol @@ -264,6 +264,7 @@ contract CLSwapRouterHandler is Test { poolKey: pk, tickLower: -10, tickUpper: 10, + salt: bytes32(0), amount0Desired: amt, amount1Desired: amt, amount0Min: 0, diff --git a/test/pool-cl/NonFungiblePositionManager.t.sol b/test/pool-cl/NonFungiblePositionManager.t.sol index b673341..e4f5965 100644 --- a/test/pool-cl/NonFungiblePositionManager.t.sol +++ b/test/pool-cl/NonFungiblePositionManager.t.sol @@ -92,6 +92,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -111,10 +112,15 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { // make the LPing balance of the position non-zero router.donate(key, 1 ether, 1 ether, ""); - // mint another position in the same price range + // mint another position in the same price range but different recipient INonfungiblePositionManager.MintParams memory mintParams2 = mintParams; mintParams2.recipient = address(this); nonfungiblePoolManager.mint(mintParams2); + + // mint another position in the same price range but different salt + INonfungiblePositionManager.MintParams memory mintParams3 = mintParams; + mintParams3.salt = bytes32(uint256(0xABCD)); + nonfungiblePoolManager.mint(mintParams3); } { @@ -130,7 +136,8 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, + bytes32 salt ) = nonfungiblePoolManager.positions(1); assertEq(nonce, 0, "Unexpected nonce"); assertEq(operator, address(0), "Unexpected operator"); @@ -144,6 +151,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { assertEq(feeGrowthInside1LastX128, 0, "Unexpected feeGrowthInside1LastX128"); assertEq(tokensOwed0, 0, "Unexpected tokensOwed0"); assertEq(tokensOwed1, 0, "Unexpected tokensOwed1"); + assertEq(salt, bytes32(0), "Unexpected salt"); string memory expectTokenURI = string.concat("https://nft.pancakeswap.com/v4/", block.chainid.toString(), "/1"); string memory realTokenURI = nonfungiblePoolManager.tokenURI(1); @@ -162,7 +170,8 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, + bytes32 salt ) = nonfungiblePoolManager.positions(2); assertEq(nonce, 0, "Unexpected nonce"); assertEq(operator, address(0), "Unexpected operator"); @@ -181,6 +190,46 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { ); assertEq(tokensOwed0, 0, "Unexpected tokensOwed0"); assertEq(tokensOwed1, 0, "Unexpected tokensOwed1"); + assertEq(salt, bytes32(0), "Unexpected salt"); + } + + { + ( + uint96 nonce, + address operator, + Currency _currency0, + Currency _currency1, + uint24 fee, + int24 tickLower, + int24 tickUpper, + uint128 liquidity, + uint256 feeGrowthInside0LastX128, + uint256 feeGrowthInside1LastX128, + uint128 tokensOwed0, + uint128 tokensOwed1, + bytes32 salt + ) = nonfungiblePoolManager.positions(3); + assertEq(nonce, 0, "Unexpected nonce"); + assertEq(operator, address(0), "Unexpected operator"); + assertEq(Currency.unwrap(_currency0), Currency.unwrap(currency0), "Unexpected currency0"); + assertEq(Currency.unwrap(_currency1), Currency.unwrap(currency1), "Unexpected currency1"); + assertEq(fee, 3000, "Unexpected fee"); + assertEq(tickLower, 46053, "Unexpected tickLower"); + assertEq(tickUpper, 46055, "Unexpected tickUpper"); + assertEq(liquidity, 1991375027067913587988, "Unexpected liquidity"); + assertEq( + feeGrowthInside0LastX128, 170878092923545294145335173946080448, "Unexpected feeGrowthInside0LastX128" + ); + assertEq( + feeGrowthInside1LastX128, 170878092923545294145335173946080448, "Unexpected feeGrowthInside1LastX128" + ); + assertEq(tokensOwed0, 0, "Unexpected tokensOwed0"); + assertEq(tokensOwed1, 0, "Unexpected tokensOwed1"); + assertEq(salt, bytes32(uint256(0xABCD)), "Unexpected salt"); + string memory expectTokenURI = + string.concat("https://nft.pancakeswap.com/v4/", block.chainid.toString(), "/3"); + string memory realTokenURI = nonfungiblePoolManager.tokenURI(3); + assertEq(expectTokenURI, realTokenURI, "Unexpected tokenURI"); } // modifyPosition 0 to refresh position(1)'s LPing @@ -209,7 +258,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(nonce, 0, "Unexpected nonce"); assertEq(operator, address(0), "Unexpected operator"); @@ -247,7 +296,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { assertEq(vault.balanceOf(address(nonfungiblePoolManager), currency1), 999999999999999999); } - function testMint() external { + function testMint(bytes32 salt) external { PoolKey memory key = PoolKey({ currency0: currency0, currency1: currency1, @@ -285,6 +334,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: tickLower, tickUpper: tickUpper, + salt: salt, amount0Desired: amount0Desired, amount1Desired: amount1Desired, amount0Min: 0, @@ -307,11 +357,12 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { assertEq(amount1, 2000000000000000000, "Actual consumed currency1 mismatch"); } - // tick lower and tick upper + // tick lower and tick upper and salt { - (,,,,, int24 _tickLower, int24 _tickUpper,,,,,) = nonfungiblePoolManager.positions(1); + (,,,,, int24 _tickLower, int24 _tickUpper,,,,,, bytes32 _salt) = nonfungiblePoolManager.positions(1); assertEq(_tickLower, tickLower, "Unexpected tickLower"); assertEq(_tickUpper, tickUpper, "Unexpected tickUpper"); + assertEq(_salt, salt, "Unexpected salt"); } // token id starts from 1 @@ -320,7 +371,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { assertEq(liquidity, 3982750054135827175977, "Liquidity from mint and liquidity from raw calculation mismatch"); assertEq(poolManager.getLiquidity(key.toId()), 3982750054135827175977, "Unexpected liquidity for the pool"); assertEq( - poolManager.getLiquidity(key.toId(), address(nonfungiblePoolManager), 46053, 46055, bytes32(0)), + poolManager.getLiquidity(key.toId(), address(nonfungiblePoolManager), 46053, 46055, salt), 3982750054135827175977, "Unexpected liquidity for current position" ); @@ -358,6 +409,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: tickLower, tickUpper: tickUpper, + salt: bytes32(0), amount0Desired: amount0Desired, amount1Desired: amount1Desired, amount0Min: 0, @@ -385,6 +437,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -437,6 +490,29 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { ); assertEq(nonfungiblePoolManager.ownerOf(tokenId), address(this), "Unexpected owner of the position"); + + // mint another position in the same price range but different salt + INonfungiblePositionManager.MintParams memory mintParams3 = mintParams; + mintParams3.salt = bytes32(uint256(0xABCD)); + nonfungiblePoolManager.mint(mintParams3); + + assertEq( + nonfungiblePoolManager.balanceOf(address(this)), + 2, + "Unexpected balance of the position owner after mint again" + ); + + // make sure total liquidity is correct + assertEq(poolManager.getLiquidity(key.toId()), 3 * 1991375027067913587988, "Unexpected liquidity for the pool"); + + // make sure liquidity for each position is correct + assertEq( + poolManager.getLiquidity( + key.toId(), address(nonfungiblePoolManager), 46053, 46055, bytes32(uint256(0xABCD)) + ), + 1991375027067913587988, + "Unexpected liquidity for current position" + ); } function testMint_slippage() external { @@ -455,6 +531,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, // price 100, the rough ratio is 1:100 @@ -488,6 +565,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -550,7 +628,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -558,7 +636,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { assertEq(tokensOwed0, 0, "Unexpected tokensOwed0"); assertEq(tokensOwed1, 0, "Unexpected tokensOwed1"); - (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = + (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1,) = nonfungiblePoolManager.positions(2); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); // after donation, the feeGrowthInside0LastX128 and feeGrowthInside1LastX128 should be synced @@ -568,7 +646,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { assertEq(tokensOwed1, 0, "Unexpected tokensOwed1"); } - function testIncreaseLiquidity() external { + function testIncreaseLiquidity(bytes32 salt) external { PoolKey memory key = PoolKey({ currency0: currency0, currency1: currency1, @@ -584,6 +662,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: salt, amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -609,7 +688,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -658,7 +737,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { assertEq(poolManager.getLiquidity(key.toId()), 2 * 1991375027067913587988, "Unexpected liquidity for the pool"); assertEq( - poolManager.getLiquidity(key.toId(), address(nonfungiblePoolManager), 46053, 46055, bytes32(0)), + poolManager.getLiquidity(key.toId(), address(nonfungiblePoolManager), 46053, 46055, salt), 1991375027067913587988 * 2, "Unexpected liquidity for current position" ); @@ -682,7 +761,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988 * 2, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -708,6 +787,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -750,6 +830,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -775,7 +856,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -849,7 +930,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988 * 2, "Unexpected liquidity"); assertEq( @@ -879,6 +960,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -923,6 +1005,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -951,7 +1034,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { ); } - function testDecreaseLiquidity() external { + function testDecreaseLiquidity(bytes32 salt) external { PoolKey memory key = PoolKey({ currency0: currency0, currency1: currency1, @@ -967,6 +1050,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: salt, amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -991,7 +1075,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -1027,7 +1111,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { assertEq(poolManager.getLiquidity(key.toId()), 0, "Unexpected liquidity for the pool"); assertEq( - poolManager.getLiquidity(key.toId(), address(nonfungiblePoolManager), 46053, 46055, bytes32(0)), + poolManager.getLiquidity(key.toId(), address(nonfungiblePoolManager), 46053, 46055, salt), 0, "Unexpected liquidity for current position" ); @@ -1037,7 +1121,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { ); assertEq(nonfungiblePoolManager.ownerOf(1), address(this), "Unexpected owner of the position"); - (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = + (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1,) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 0, "Unexpected liquidity"); // after donation, the feeGrowthInside0LastX128 and feeGrowthInside1LastX128 should be synced @@ -1061,6 +1145,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1102,6 +1187,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1143,6 +1229,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1185,6 +1272,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0 ether, @@ -1227,6 +1315,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1250,7 +1339,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -1299,7 +1388,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { ); assertEq(nonfungiblePoolManager.ownerOf(1), address(this), "Unexpected owner of the position"); - (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = + (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1,) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 0, "Unexpected liquidity"); // after donation, the feeGrowthInside0LastX128 and feeGrowthInside1LastX128 should be synced @@ -1325,6 +1414,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1351,7 +1441,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { vm.expectEmit(); emit Transfer(address(this), address(0), 1); - (,,,,,,, uint128 liquidity,,,,) = nonfungiblePoolManager.positions(1); + (,,,,,,, uint128 liquidity,,,,,) = nonfungiblePoolManager.positions(1); assertEq(liquidity, 0, "Unexpected liquidity"); nonfungiblePoolManager.burn(1); @@ -1379,6 +1469,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1423,6 +1514,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1448,7 +1540,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { }) ); - (,,,,,,, uint128 liquidity,,,,) = nonfungiblePoolManager.positions(1); + (,,,,,,, uint128 liquidity,,,,,) = nonfungiblePoolManager.positions(1); assertEq(liquidity, 0, "Unexpected liquidity"); nonfungiblePoolManager.burn(1); @@ -1475,6 +1567,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1523,6 +1616,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1546,7 +1640,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { }) ); - (,,,,,,, uint128 liquidity,,,,) = nonfungiblePoolManager.positions(1); + (,,,,,,, uint128 liquidity,,,,,) = nonfungiblePoolManager.positions(1); assertEq(liquidity, 1, "Unexpected liquidity"); vm.expectRevert(INonfungiblePositionManager.NonEmptyPosition.selector); @@ -1569,6 +1663,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1595,7 +1690,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { }) ); - (,,,,,,, uint128 liquidity,,,,) = nonfungiblePoolManager.positions(1); + (,,,,,,, uint128 liquidity,,,,,) = nonfungiblePoolManager.positions(1); assertEq(liquidity, 0, "Unexpected liquidity"); vm.expectRevert(INonfungiblePositionManager.NonEmptyPosition.selector); @@ -1624,6 +1719,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1652,7 +1748,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -1697,7 +1793,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { ); assertEq(nonfungiblePoolManager.ownerOf(1), address(this), "Unexpected owner of the position"); - (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = + (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1,) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); // after donation, the feeGrowthInside0LastX128 and feeGrowthInside1LastX128 should be synced @@ -1724,6 +1820,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1751,7 +1848,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -1770,7 +1867,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { }) ); - (,,,,,,, _liquidity,,,,) = nonfungiblePoolManager.positions(1); + (,,,,,,, _liquidity,,,,,) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 0, "Unexpected liquidity"); { @@ -1804,7 +1901,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { ); assertEq(nonfungiblePoolManager.ownerOf(1), address(this), "Unexpected owner of the position"); - (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = + (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1,) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 0, "Unexpected liquidity"); // after donation, the feeGrowthInside0LastX128 and feeGrowthInside1LastX128 should be synced @@ -1831,6 +1928,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1874,6 +1972,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1901,7 +2000,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -1936,6 +2035,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -1963,7 +2063,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -2007,7 +2107,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { ); assertEq(nonfungiblePoolManager.ownerOf(1), address(this), "Unexpected owner of the position"); - (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = + (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1,) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); // after donation, the feeGrowthInside0LastX128 and feeGrowthInside1LastX128 should be synced @@ -2034,6 +2134,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -2061,7 +2162,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -2102,7 +2203,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { ); assertEq(nonfungiblePoolManager.ownerOf(1), address(this), "Unexpected owner of the position"); - (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = + (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1,) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); // after donation, the feeGrowthInside0LastX128 and feeGrowthInside1LastX128 should be synced @@ -2126,6 +2227,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -2153,7 +2255,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, - uint128 tokensOwed1 + uint128 tokensOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); assertEq(feeGrowthInside0LastX128, 0, "Unexpected feeGrowthInside0LastX128"); @@ -2204,7 +2306,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { "Unexpected liquidity for current position" ); - (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = + (,,,,,,, _liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1,) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 1991375027067913587988, "Unexpected liquidity"); // after donation, the feeGrowthInside0LastX128 and feeGrowthInside1LastX128 should be synced @@ -2228,6 +2330,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -2268,6 +2371,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: key, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -2299,7 +2403,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { }) ); - (,,,,,,, uint128 _liquidity,,,,) = nonfungiblePoolManager.positions(1); + (,,,,,,, uint128 _liquidity,,,,,) = nonfungiblePoolManager.positions(1); assertEq(_liquidity, 0, "Unexpected liquidity"); } @@ -2324,6 +2428,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: poolKey, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -2390,7 +2495,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokenOwed0, - uint128 tokenOwed1 + uint128 tokenOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(info.feeGrowthInside0LastX128, feeGrowthInside0LastX128, "Unexpected feeGrowthInside0LastX128"); assertEq(info.feeGrowthInside1LastX128, feeGrowthInside1LastX128, "Unexpected feeGrowthInside1LastX128"); @@ -2431,7 +2536,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokenOwed0, - uint128 tokenOwed1 + uint128 tokenOwed1, ) = nonfungiblePoolManager.positions(1); assertEq(info.feeGrowthInside0LastX128, feeGrowthInside0LastX128, "Unexpected feeGrowthInside0LastX128"); assertEq(info.feeGrowthInside1LastX128, feeGrowthInside1LastX128, "Unexpected feeGrowthInside1LastX128"); @@ -2461,6 +2566,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: poolKey, tickLower: 46053, tickUpper: 46055, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -2512,6 +2618,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { poolKey: poolKey, tickLower: 46055, tickUpper: 46058, + salt: bytes32(0), amount0Desired: 1 ether, amount1Desired: 1 ether, amount0Min: 0, @@ -2618,7 +2725,7 @@ contract NonFungiblePositionManagerTest is TokenFixture, Test, GasSnapshot { uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokenOwed0, - uint128 tokenOwed1 + uint128 tokenOwed1, ) = nonfungiblePoolManager.positions(2); assertEq(info.feeGrowthInside0LastX128, feeGrowthInside0LastX128, "Unexpected feeGrowthInside0LastX128"); assertEq(info.feeGrowthInside1LastX128, feeGrowthInside1LastX128, "Unexpected feeGrowthInside1LastX128");