From edcf1fb9472baf256397fd0dc39ff2fad881e08b Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Tue, 28 Jan 2025 16:33:00 +0800 Subject: [PATCH] refactor v4 -> infi from migrator --- src/MixedQuoter.sol | 32 ++++----- src/base/BaseMigrator.sol | 18 ++--- src/interfaces/IMixedQuoter.sol | 10 +-- src/libraries/MixedQuoterRecorder.sol | 8 +-- src/pool-bin/BinMigrator.sol | 64 ++++++++--------- src/pool-bin/interfaces/IBinMigrator.sol | 10 +-- src/pool-cl/CLMigrator.sol | 48 ++++++------- src/pool-cl/interfaces/ICLMigrator.sol | 10 +-- test/MixedQuoter.t.sol | 36 +++++----- test/mocks/MockReentrantPositionManager.sol | 20 +++--- test/pool-bin/migrator/BinMigratorFromV2.sol | 52 +++++++------- test/pool-bin/migrator/BinMigratorFromV3.sol | 66 ++++++++--------- test/pool-cl/migrator/CLMigratorFromV2.sol | 60 ++++++++-------- test/pool-cl/migrator/CLMigratorFromV3.sol | 74 ++++++++++---------- 14 files changed, 254 insertions(+), 254 deletions(-) diff --git a/src/MixedQuoter.sol b/src/MixedQuoter.sol index 3694112..e30a517 100644 --- a/src/MixedQuoter.sol +++ b/src/MixedQuoter.sol @@ -303,11 +303,11 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { amountIn = swapAmountOut - accAmountOut; } } else if (action == MixedQuoterActions.INFI_CL_EXACT_INPUT_SINGLE) { - QuoteMixedV4ExactInputSingleParams memory clParams = - abi.decode(params[actionIndex], (QuoteMixedV4ExactInputSingleParams)); - (tokenIn, tokenOut) = convertWETHToV4NativeCurency(clParams.poolKey, tokenIn, tokenOut); + QuoteMixedInfiExactInputSingleParams memory clParams = + abi.decode(params[actionIndex], (QuoteMixedInfiExactInputSingleParams)); + (tokenIn, tokenOut) = convertWETHToInfiNativeCurency(clParams.poolKey, tokenIn, tokenOut); bool zeroForOne = tokenIn < tokenOut; - checkV4PoolKeyCurrency(clParams.poolKey, zeroForOne, tokenIn, tokenOut); + checkInfiPoolKeyCurrency(clParams.poolKey, zeroForOne, tokenIn, tokenOut); IQuoter.QuoteExactSingleParams memory swapParams = IQuoter.QuoteExactSingleParams({ poolKey: clParams.poolKey, @@ -317,8 +317,8 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { }); // will execute all swap history of same infinity pool in one transaction if withContext is true if (withContext) { - bytes32 poolHash = MixedQuoterRecorder.getV4CLPoolHash(clParams.poolKey); - bytes memory swapListBytes = MixedQuoterRecorder.getV4PoolSwapList(poolHash); + bytes32 poolHash = MixedQuoterRecorder.getInfiCLPoolHash(clParams.poolKey); + bytes memory swapListBytes = MixedQuoterRecorder.getInfiPoolSwapList(poolHash); IQuoter.QuoteExactSingleParams[] memory swapHistoryList; uint256 swapHistoryListLength; if (swapListBytes.length > 0) { @@ -335,16 +335,16 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { (amountIn, gasEstimateForCurAction) = clQuoter.quoteExactInputSingleList(swapList); swapListBytes = abi.encode(swapList); - MixedQuoterRecorder.setV4PoolSwapList(poolHash, swapListBytes); + MixedQuoterRecorder.setInfiPoolSwapList(poolHash, swapListBytes); } else { (amountIn, gasEstimateForCurAction) = clQuoter.quoteExactInputSingle(swapParams); } } else if (action == MixedQuoterActions.INFI_BIN_EXACT_INPUT_SINGLE) { - QuoteMixedV4ExactInputSingleParams memory binParams = - abi.decode(params[actionIndex], (QuoteMixedV4ExactInputSingleParams)); - (tokenIn, tokenOut) = convertWETHToV4NativeCurency(binParams.poolKey, tokenIn, tokenOut); + QuoteMixedInfiExactInputSingleParams memory binParams = + abi.decode(params[actionIndex], (QuoteMixedInfiExactInputSingleParams)); + (tokenIn, tokenOut) = convertWETHToInfiNativeCurency(binParams.poolKey, tokenIn, tokenOut); bool zeroForOne = tokenIn < tokenOut; - checkV4PoolKeyCurrency(binParams.poolKey, zeroForOne, tokenIn, tokenOut); + checkInfiPoolKeyCurrency(binParams.poolKey, zeroForOne, tokenIn, tokenOut); IQuoter.QuoteExactSingleParams memory swapParams = IQuoter.QuoteExactSingleParams({ poolKey: binParams.poolKey, @@ -354,8 +354,8 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { }); // will execute all swap history of same infinity pool in one transaction if withContext is true if (withContext) { - bytes32 poolHash = MixedQuoterRecorder.getV4BinPoolHash(binParams.poolKey); - bytes memory swapListBytes = MixedQuoterRecorder.getV4PoolSwapList(poolHash); + bytes32 poolHash = MixedQuoterRecorder.getInfiBinPoolHash(binParams.poolKey); + bytes memory swapListBytes = MixedQuoterRecorder.getInfiPoolSwapList(poolHash); IQuoter.QuoteExactSingleParams[] memory swapHistoryList; uint256 swapHistoryListLength; if (swapListBytes.length > 0) { @@ -372,7 +372,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { (amountIn, gasEstimateForCurAction) = binQuoter.quoteExactInputSingleList(swapList); swapListBytes = abi.encode(swapList); - MixedQuoterRecorder.setV4PoolSwapList(poolHash, swapListBytes); + MixedQuoterRecorder.setInfiPoolSwapList(poolHash, swapListBytes); } else { (amountIn, gasEstimateForCurAction) = binQuoter.quoteExactInputSingle(swapParams); } @@ -431,7 +431,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { } /// @dev Check if the poolKey currency matches the tokenIn and tokenOut - function checkV4PoolKeyCurrency(PoolKey memory poolKey, bool isZeroForOne, address tokenIn, address tokenOut) + function checkInfiPoolKeyCurrency(PoolKey memory poolKey, bool isZeroForOne, address tokenIn, address tokenOut) private pure { @@ -452,7 +452,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall { /// @notice Convert WETH to native currency for infinity pools /// @dev for example, quote route are v3 WETH pool[token0, WETH] and infinity native pool[NATIVE,token1] /// paths is [token0, WETH, token1], we need to convert WETH to NATIVE when quote infinity pool - function convertWETHToV4NativeCurency(PoolKey memory poolKey, address tokenIn, address tokenOut) + function convertWETHToInfiNativeCurency(PoolKey memory poolKey, address tokenIn, address tokenOut) private view returns (address, address) diff --git a/src/base/BaseMigrator.sol b/src/base/BaseMigrator.sol index 9fe81cc..de4373f 100644 --- a/src/base/BaseMigrator.sol +++ b/src/base/BaseMigrator.sol @@ -186,21 +186,21 @@ contract BaseMigrator is IBaseMigrator, Permit2Forwarder, Multicall, SelfPermitE /// Return true if match but v2v3Token1 is WETH which should be ETH in infinity pair /// @param v2v3Token0 token0 from v2/v3 pair /// @param v2v3Token1 token1 from v2/v3 pair - /// @param v4Token0 token0 from infinity pair - /// @param v4Token1 token1 from infinity pair + /// @param infiToken0 token0 from infinity pair + /// @param infiToken1 token1 from infinity pair /// @return shouldReversePair if the order of tokens from v2/v3 pair is different from infinity pair (only when WETH is involved) function _checkIfTokenPairMatchAndOrder( address v2v3Token0, address v2v3Token1, - Currency v4Token0, - Currency v4Token1 + Currency infiToken0, + Currency infiToken1 ) private view returns (bool shouldReversePair) { - if (v4Token0.isNative() && v2v3Token0 == WETH9) { - if (Currency.unwrap(v4Token1) != v2v3Token1) { + if (infiToken0.isNative() && v2v3Token0 == WETH9) { + if (Currency.unwrap(infiToken1) != v2v3Token1) { revert TOKEN_NOT_MATCH(); } - } else if (v4Token0.isNative() && v2v3Token1 == WETH9) { - if (Currency.unwrap(v4Token1) != v2v3Token0) { + } else if (infiToken0.isNative() && v2v3Token1 == WETH9) { + if (Currency.unwrap(infiToken1) != v2v3Token0) { revert TOKEN_NOT_MATCH(); } shouldReversePair = true; @@ -208,7 +208,7 @@ contract BaseMigrator is IBaseMigrator, Permit2Forwarder, Multicall, SelfPermitE /// @dev the order of token0 and token1 is always sorted /// v2: https://github.com/pancakeswap/pancake-swap-core-v2/blob/38aad83854a46a82ea0e31988ff3cddb2bffb71a/contracts/PancakeFactory.sol#L27 /// v3: https://github.com/pancakeswap/pancake-v3-contracts/blob/5cc479f0c5a98966c74d94700057b8c3ca629afd/projects/v3-core/contracts/PancakeV3Factory.sol#L66 - if (Currency.unwrap(v4Token0) != v2v3Token0 || Currency.unwrap(v4Token1) != v2v3Token1) { + if (Currency.unwrap(infiToken0) != v2v3Token0 || Currency.unwrap(infiToken1) != v2v3Token1) { revert TOKEN_NOT_MATCH(); } } diff --git a/src/interfaces/IMixedQuoter.sol b/src/interfaces/IMixedQuoter.sol index 056da02..ede13b8 100644 --- a/src/interfaces/IMixedQuoter.sol +++ b/src/interfaces/IMixedQuoter.sol @@ -16,7 +16,7 @@ interface IMixedQuoter { error NoActions(); error UnsupportedAction(uint256 action); - struct QuoteMixedV4ExactInputSingleParams { + struct QuoteMixedInfiExactInputSingleParams { PoolKey poolKey; bytes hookData; } @@ -50,8 +50,8 @@ interface IMixedQuoter { /// SS_3_EXACT_INPUT_SINGLE params are zero bytes /// V2_EXACT_INPUT_SINGLE params are zero bytes /// V3_EXACT_INPUT_SINGLE params are encoded as `uint24 fee` - /// INFI_CL_EXACT_INPUT_SINGLE params are encoded as `QuoteMixedV4ExactInputSingleParams` - /// V4_EXACT_INPUT_SINGLE params are encoded as `QuoteMixedV4ExactInputSingleParams` + /// INFI_CL_EXACT_INPUT_SINGLE params are encoded as `QuoteMixedInfiExactInputSingleParams` + /// INFI_EXACT_INPUT_SINGLE params are encoded as `QuoteMixedInfiExactInputSingleParams` /// @param amountIn The amount of the first token to swap /// @return amountOut The amount of the last token that would be received /// @return gasEstimate The estimate of the gas that the swap consumes @@ -71,8 +71,8 @@ interface IMixedQuoter { /// SS_3_EXACT_INPUT_SINGLE params are zero bytes /// V2_EXACT_INPUT_SINGLE params are zero bytes /// V3_EXACT_INPUT_SINGLE params are encoded as `uint24 fee` - /// INFI_CL_EXACT_INPUT_SINGLE params are encoded as `QuoteMixedV4ExactInputSingleParams` - /// V4_EXACT_INPUT_SINGLE params are encoded as `QuoteMixedV4ExactInputSingleParams` + /// INFI_CL_EXACT_INPUT_SINGLE params are encoded as `QuoteMixedInfiExactInputSingleParams` + /// INFI_EXACT_INPUT_SINGLE params are encoded as `QuoteMixedInfiExactInputSingleParams` /// @param amountIn The amount of the first token to swap /// @return amountOut The amount of the last token that would be received /// @return gasEstimate The estimate of the gas that the swap consumes diff --git a/src/libraries/MixedQuoterRecorder.sol b/src/libraries/MixedQuoterRecorder.sol index a6d456f..ce26d39 100644 --- a/src/libraries/MixedQuoterRecorder.sol +++ b/src/libraries/MixedQuoterRecorder.sol @@ -125,7 +125,7 @@ library MixedQuoterRecorder { /// @dev Record the swap history list of infinity pool. /// @param poolHash The hash of the pool. /// @param swapListBytes The swap history list bytes. - function setV4PoolSwapList(bytes32 poolHash, bytes memory swapListBytes) internal { + function setInfiPoolSwapList(bytes32 poolHash, bytes memory swapListBytes) internal { uint256 swapListSlot = uint256(keccak256(abi.encode(poolHash, SWAP_V4_LIST))); assembly ("memory-safe") { // save the length of the bytes @@ -142,7 +142,7 @@ library MixedQuoterRecorder { /// @dev Get the swap history list of infinity pool. /// @param poolHash The hash of the pool. /// @return swapListBytes The swap history list bytes. - function getV4PoolSwapList(bytes32 poolHash) internal view returns (bytes memory swapListBytes) { + function getInfiPoolSwapList(bytes32 poolHash) internal view returns (bytes memory swapListBytes) { uint256 swapListSlot = uint256(keccak256(abi.encode(poolHash, SWAP_V4_LIST))); assembly ("memory-safe") { // get the length of the bytes @@ -190,14 +190,14 @@ library MixedQuoterRecorder { /// @dev Get the infinity cl pool hash. /// @param key The pool key. /// @return poolHash The hash of the pool. - function getV4CLPoolHash(PoolKey memory key) internal pure returns (bytes32) { + function getInfiCLPoolHash(PoolKey memory key) internal pure returns (bytes32) { return keccak256(abi.encode(key, SWAP_V4_CL)); } /// @dev Get the infinity bin pool hash. /// @param key The pool key. /// @return poolHash The hash of the pool. - function getV4BinPoolHash(PoolKey memory key) internal pure returns (bytes32) { + function getInfiBinPoolHash(PoolKey memory key) internal pure returns (bytes32) { return keccak256(abi.encode(key, SWAP_V4_BIN)); } } diff --git a/src/pool-bin/BinMigrator.sol b/src/pool-bin/BinMigrator.sol index e82ffde..63046a3 100644 --- a/src/pool-bin/BinMigrator.sol +++ b/src/pool-bin/BinMigrator.sol @@ -27,47 +27,47 @@ contract BinMigrator is IBinMigrator, BaseMigrator, ReentrancyLock { /// @inheritdoc IBinMigrator function migrateFromV2( V2PoolParams calldata v2PoolParams, - V4BinPoolParams calldata v4PoolParams, + InfiBinPoolParams calldata infiPoolParams, uint256 extraAmount0, uint256 extraAmount1 ) external payable override isNotLocked whenNotPaused { bool shouldReversePair = checkTokensOrderAndMatchFromV2( - v2PoolParams.pair, v4PoolParams.poolKey.currency0, v4PoolParams.poolKey.currency1 + v2PoolParams.pair, infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1 ); (uint256 amount0Received, uint256 amount1Received) = withdrawLiquidityFromV2(v2PoolParams, shouldReversePair); /// @notice if user mannually specify the price range, they might need to send extra token batchAndNormalizeTokens( - v4PoolParams.poolKey.currency0, v4PoolParams.poolKey.currency1, extraAmount0, extraAmount1 + infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1, extraAmount0, extraAmount1 ); uint256 amount0Input = amount0Received + extraAmount0; uint256 amount1Input = amount1Received + extraAmount1; IBinPositionManager.BinAddLiquidityParams memory addLiquidityParams = IBinPositionManager.BinAddLiquidityParams({ - poolKey: v4PoolParams.poolKey, + poolKey: infiPoolParams.poolKey, amount0: amount0Input.toUint128(), amount1: amount1Input.toUint128(), - amount0Max: v4PoolParams.amount0Max, - amount1Max: v4PoolParams.amount1Max, - activeIdDesired: v4PoolParams.activeIdDesired, - idSlippage: v4PoolParams.idSlippage, - deltaIds: v4PoolParams.deltaIds, - distributionX: v4PoolParams.distributionX, - distributionY: v4PoolParams.distributionY, - to: v4PoolParams.to, - hookData: v4PoolParams.hookData + amount0Max: infiPoolParams.amount0Max, + amount1Max: infiPoolParams.amount1Max, + activeIdDesired: infiPoolParams.activeIdDesired, + idSlippage: infiPoolParams.idSlippage, + deltaIds: infiPoolParams.deltaIds, + distributionX: infiPoolParams.distributionX, + distributionY: infiPoolParams.distributionY, + to: infiPoolParams.to, + hookData: infiPoolParams.hookData }); (uint256 amount0Consumed, uint256 amount1Consumed) = - _addLiquidityToTargetPool(addLiquidityParams, v4PoolParams.deadline); + _addLiquidityToTargetPool(addLiquidityParams, infiPoolParams.deadline); // refund if necessary, ETH is supported by CurrencyLib unchecked { if (amount0Input > amount0Consumed) { - v4PoolParams.poolKey.currency0.transfer(v4PoolParams.to, amount0Input - amount0Consumed); + infiPoolParams.poolKey.currency0.transfer(infiPoolParams.to, amount0Input - amount0Consumed); } if (amount1Input > amount1Consumed) { - v4PoolParams.poolKey.currency1.transfer(v4PoolParams.to, amount1Input - amount1Consumed); + infiPoolParams.poolKey.currency1.transfer(infiPoolParams.to, amount1Input - amount1Consumed); } } } @@ -75,46 +75,46 @@ contract BinMigrator is IBinMigrator, BaseMigrator, ReentrancyLock { /// @inheritdoc IBinMigrator function migrateFromV3( V3PoolParams calldata v3PoolParams, - V4BinPoolParams calldata v4PoolParams, + InfiBinPoolParams calldata infiPoolParams, uint256 extraAmount0, uint256 extraAmount1 ) external payable override isNotLocked whenNotPaused { bool shouldReversePair = checkTokensOrderAndMatchFromV3( - v3PoolParams.nfp, v3PoolParams.tokenId, v4PoolParams.poolKey.currency0, v4PoolParams.poolKey.currency1 + v3PoolParams.nfp, v3PoolParams.tokenId, infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1 ); (uint256 amount0Received, uint256 amount1Received) = withdrawLiquidityFromV3(v3PoolParams, shouldReversePair); /// @notice if user mannually specify the price range, they need to send extra token batchAndNormalizeTokens( - v4PoolParams.poolKey.currency0, v4PoolParams.poolKey.currency1, extraAmount0, extraAmount1 + infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1, extraAmount0, extraAmount1 ); uint256 amount0Input = amount0Received + extraAmount0; uint256 amount1Input = amount1Received + extraAmount1; IBinPositionManager.BinAddLiquidityParams memory addLiquidityParams = IBinPositionManager.BinAddLiquidityParams({ - poolKey: v4PoolParams.poolKey, + poolKey: infiPoolParams.poolKey, amount0: amount0Input.toUint128(), amount1: amount1Input.toUint128(), - amount0Max: v4PoolParams.amount0Max, - amount1Max: v4PoolParams.amount1Max, - activeIdDesired: v4PoolParams.activeIdDesired, - idSlippage: v4PoolParams.idSlippage, - deltaIds: v4PoolParams.deltaIds, - distributionX: v4PoolParams.distributionX, - distributionY: v4PoolParams.distributionY, - to: v4PoolParams.to, - hookData: v4PoolParams.hookData + amount0Max: infiPoolParams.amount0Max, + amount1Max: infiPoolParams.amount1Max, + activeIdDesired: infiPoolParams.activeIdDesired, + idSlippage: infiPoolParams.idSlippage, + deltaIds: infiPoolParams.deltaIds, + distributionX: infiPoolParams.distributionX, + distributionY: infiPoolParams.distributionY, + to: infiPoolParams.to, + hookData: infiPoolParams.hookData }); (uint256 amount0Consumed, uint256 amount1Consumed) = - _addLiquidityToTargetPool(addLiquidityParams, v4PoolParams.deadline); + _addLiquidityToTargetPool(addLiquidityParams, infiPoolParams.deadline); // refund if necessary, ETH is supported by CurrencyLib unchecked { if (amount0Input > amount0Consumed) { - v4PoolParams.poolKey.currency0.transfer(v4PoolParams.to, amount0Input - amount0Consumed); + infiPoolParams.poolKey.currency0.transfer(infiPoolParams.to, amount0Input - amount0Consumed); } if (amount1Input > amount1Consumed) { - v4PoolParams.poolKey.currency1.transfer(v4PoolParams.to, amount1Input - amount1Consumed); + infiPoolParams.poolKey.currency1.transfer(infiPoolParams.to, amount1Input - amount1Consumed); } } } diff --git a/src/pool-bin/interfaces/IBinMigrator.sol b/src/pool-bin/interfaces/IBinMigrator.sol index c244361..ac141ac 100644 --- a/src/pool-bin/interfaces/IBinMigrator.sol +++ b/src/pool-bin/interfaces/IBinMigrator.sol @@ -8,7 +8,7 @@ import {IV3NonfungiblePositionManager} from "../../interfaces/external/IV3Nonfun interface IBinMigrator is IBaseMigrator { /// @notice same fields as IBinRouterBase.BinAddLiquidityParams /// except amount0/amount1 which will be calculated by migrator - struct V4BinPoolParams { + struct InfiBinPoolParams { PoolKey poolKey; uint128 amount0Max; uint128 amount1Max; @@ -25,14 +25,14 @@ interface IBinMigrator is IBaseMigrator { /// @notice Migrate liquidity from v2 to infinity /// @param v2PoolParams ncessary info for removing liqudity the source v2 pool - /// @param v4PoolParams necessary info for adding liquidity the target infinity bin-pool + /// @param infiPoolParams necessary info for adding liquidity the target infinity bin-pool /// @param extraAmount0 the extra amount of token0 that user wants to add (optional, usually 0) /// if pool token0 is ETH and msg.value == 0, WETH will be taken from sender. /// Otherwise if pool token0 is ETH and msg.value !=0, method will assume user have sent extraAmount0 in msg.value /// @param extraAmount1 the extra amount of token1 that user wants to add (optional, usually 0) function migrateFromV2( V2PoolParams calldata v2PoolParams, - V4BinPoolParams calldata v4PoolParams, + InfiBinPoolParams calldata infiPoolParams, // extra funds to be added uint256 extraAmount0, uint256 extraAmount1 @@ -40,14 +40,14 @@ interface IBinMigrator is IBaseMigrator { /// @notice Migrate liquidity from v3 to infinity /// @param v3PoolParams ncessary info for removing liqudity the source v3 pool - /// @param v4PoolParams necessary info for adding liquidity the target infinity bin-pool + /// @param infiPoolParams necessary info for adding liquidity the target infinity bin-pool /// @param extraAmount0 the extra amount of token0 that user wants to add (optional, usually 0) /// if pool token0 is ETH and msg.value == 0, WETH will be taken from sender. /// Otherwise if pool token0 is ETH and msg.value !=0, method will assume user have sent extraAmount0 in msg.value /// @param extraAmount1 the extra amount of token1 that user wants to add (optional, usually 0) function migrateFromV3( V3PoolParams calldata v3PoolParams, - V4BinPoolParams calldata v4PoolParams, + InfiBinPoolParams calldata infiPoolParams, // extra funds to be added uint256 extraAmount0, uint256 extraAmount1 diff --git a/src/pool-cl/CLMigrator.sol b/src/pool-cl/CLMigrator.sol index fb137d8..3e84937 100644 --- a/src/pool-cl/CLMigrator.sol +++ b/src/pool-cl/CLMigrator.sol @@ -29,43 +29,43 @@ contract CLMigrator is ICLMigrator, BaseMigrator, ReentrancyLock { /// @inheritdoc ICLMigrator function migrateFromV2( V2PoolParams calldata v2PoolParams, - V4CLPoolParams calldata v4PoolParams, + InfiCLPoolParams calldata infiPoolParams, uint256 extraAmount0, uint256 extraAmount1 ) external payable override isNotLocked whenNotPaused { bool shouldReversePair = checkTokensOrderAndMatchFromV2( - v2PoolParams.pair, v4PoolParams.poolKey.currency0, v4PoolParams.poolKey.currency1 + v2PoolParams.pair, infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1 ); (uint256 amount0Received, uint256 amount1Received) = withdrawLiquidityFromV2(v2PoolParams, shouldReversePair); /// @notice if user mannually specify the price range, they might need to send extra token batchAndNormalizeTokens( - v4PoolParams.poolKey.currency0, v4PoolParams.poolKey.currency1, extraAmount0, extraAmount1 + infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1, extraAmount0, extraAmount1 ); uint256 amount0In = amount0Received + extraAmount0; uint256 amount1In = amount1Received + extraAmount1; MintParams memory mintParams = MintParams({ - poolKey: v4PoolParams.poolKey, - tickLower: v4PoolParams.tickLower, - tickUpper: v4PoolParams.tickUpper, + poolKey: infiPoolParams.poolKey, + tickLower: infiPoolParams.tickLower, + tickUpper: infiPoolParams.tickUpper, amount0In: uint128(amount0In), amount1In: uint128(amount1In), - liquidityMin: v4PoolParams.liquidityMin, - recipient: v4PoolParams.recipient, - hookData: v4PoolParams.hookData + liquidityMin: infiPoolParams.liquidityMin, + recipient: infiPoolParams.recipient, + hookData: infiPoolParams.hookData }); (uint256 amount0Consumed, uint256 amount1Consumed) = - _addLiquidityToTargetPool(mintParams, v4PoolParams.deadline); + _addLiquidityToTargetPool(mintParams, infiPoolParams.deadline); // refund if necessary, ETH is supported by CurrencyLib unchecked { if (amount0In > amount0Consumed) { - v4PoolParams.poolKey.currency0.transfer(v4PoolParams.recipient, amount0In - amount0Consumed); + infiPoolParams.poolKey.currency0.transfer(infiPoolParams.recipient, amount0In - amount0Consumed); } if (amount1In > amount1Consumed) { - v4PoolParams.poolKey.currency1.transfer(v4PoolParams.recipient, amount1In - amount1Consumed); + infiPoolParams.poolKey.currency1.transfer(infiPoolParams.recipient, amount1In - amount1Consumed); } } } @@ -73,42 +73,42 @@ contract CLMigrator is ICLMigrator, BaseMigrator, ReentrancyLock { /// @inheritdoc ICLMigrator function migrateFromV3( V3PoolParams calldata v3PoolParams, - V4CLPoolParams calldata v4PoolParams, + InfiCLPoolParams calldata infiPoolParams, uint256 extraAmount0, uint256 extraAmount1 ) external payable override isNotLocked whenNotPaused { bool shouldReversePair = checkTokensOrderAndMatchFromV3( - v3PoolParams.nfp, v3PoolParams.tokenId, v4PoolParams.poolKey.currency0, v4PoolParams.poolKey.currency1 + v3PoolParams.nfp, v3PoolParams.tokenId, infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1 ); (uint256 amount0Received, uint256 amount1Received) = withdrawLiquidityFromV3(v3PoolParams, shouldReversePair); /// @notice if user mannually specify the price range, they need to send extra token batchAndNormalizeTokens( - v4PoolParams.poolKey.currency0, v4PoolParams.poolKey.currency1, extraAmount0, extraAmount1 + infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1, extraAmount0, extraAmount1 ); uint256 amount0In = amount0Received + extraAmount0; uint256 amount1In = amount1Received + extraAmount1; MintParams memory mintParams = MintParams({ - poolKey: v4PoolParams.poolKey, - tickLower: v4PoolParams.tickLower, - tickUpper: v4PoolParams.tickUpper, + poolKey: infiPoolParams.poolKey, + tickLower: infiPoolParams.tickLower, + tickUpper: infiPoolParams.tickUpper, amount0In: uint128(amount0In), amount1In: uint128(amount1In), - liquidityMin: v4PoolParams.liquidityMin, - recipient: v4PoolParams.recipient, - hookData: v4PoolParams.hookData + liquidityMin: infiPoolParams.liquidityMin, + recipient: infiPoolParams.recipient, + hookData: infiPoolParams.hookData }); (uint256 amount0Consumed, uint256 amount1Consumed) = - _addLiquidityToTargetPool(mintParams, v4PoolParams.deadline); + _addLiquidityToTargetPool(mintParams, infiPoolParams.deadline); // refund if necessary, ETH is supported by CurrencyLib unchecked { if (amount0In > amount0Consumed) { - v4PoolParams.poolKey.currency0.transfer(v4PoolParams.recipient, amount0In - amount0Consumed); + infiPoolParams.poolKey.currency0.transfer(infiPoolParams.recipient, amount0In - amount0Consumed); } if (amount1In > amount1Consumed) { - v4PoolParams.poolKey.currency1.transfer(v4PoolParams.recipient, amount1In - amount1Consumed); + infiPoolParams.poolKey.currency1.transfer(infiPoolParams.recipient, amount1In - amount1Consumed); } } } diff --git a/src/pool-cl/interfaces/ICLMigrator.sol b/src/pool-cl/interfaces/ICLMigrator.sol index 1d59e07..08e7e63 100644 --- a/src/pool-cl/interfaces/ICLMigrator.sol +++ b/src/pool-cl/interfaces/ICLMigrator.sol @@ -10,7 +10,7 @@ interface ICLMigrator is IBaseMigrator { /// @notice same fields as INonfungiblePositionManager.MintParams /// except amount0Desired/amount1Desired which will be calculated by migrator - struct V4CLPoolParams { + struct InfiCLPoolParams { PoolKey poolKey; int24 tickLower; int24 tickUpper; @@ -34,14 +34,14 @@ interface ICLMigrator is IBaseMigrator { /// @notice Migrate liquidity from v2 to infinity /// @param v2PoolParams ncessary info for removing liqudity the source v2 pool - /// @param v4PoolParams necessary info for adding liquidity the target infinity cl-pool + /// @param infiPoolParams necessary info for adding liquidity the target infinity cl-pool /// @param extraAmount0 the extra amount of token0 that user wants to add (optional, usually 0) /// if pool token0 is ETH and msg.value == 0, WETH will be taken from sender. /// Otherwise if pool token0 is ETH and msg.value !=0, method will assume user have sent extraAmount0 in msg.value /// @param extraAmount1 the extra amount of token1 that user wants to add (optional, usually 0) function migrateFromV2( V2PoolParams calldata v2PoolParams, - V4CLPoolParams calldata v4PoolParams, + InfiCLPoolParams calldata infiPoolParams, // extra funds to be added uint256 extraAmount0, uint256 extraAmount1 @@ -49,14 +49,14 @@ interface ICLMigrator is IBaseMigrator { /// @notice Migrate liquidity from v3 to infinity /// @param v3PoolParams ncessary info for removing liqudity the source v3 pool - /// @param v4PoolParams necessary info for adding liquidity the target infinity cl-pool + /// @param infiPoolParams necessary info for adding liquidity the target infinity cl-pool /// @param extraAmount0 the extra amount of token0 that user wants to add (optional, usually 0) /// if pool token0 is ETH and msg.value == 0, WETH will be taken from sender. /// Otherwise if pool token0 is ETH and msg.value !=0, method will assume user have sent extraAmount0 in msg.value /// @param extraAmount1 the extra amount of token1 that user wants to add (optional, usually 0) function migrateFromV3( V3PoolParams calldata v3PoolParams, - V4CLPoolParams calldata v4PoolParams, + InfiCLPoolParams calldata infiPoolParams, // extra funds to be added uint256 extraAmount0, uint256 extraAmount1 diff --git a/test/MixedQuoter.t.sol b/test/MixedQuoter.t.sol index 88d6c17..4cb28d7 100644 --- a/test/MixedQuoter.t.sol +++ b/test/MixedQuoter.t.sol @@ -828,7 +828,7 @@ contract MixedQuoterTest is assertLe(diff, 2); } - function testV4CLquoteExactInputSingle_ZeroForOne() public { + function testInfiCLquoteExactInputSingle_ZeroForOne() public { address[] memory paths = new address[](2); paths[0] = address(Currency.unwrap(poolKey.currency0)); paths[1] = address(Currency.unwrap(poolKey.currency1)); @@ -838,7 +838,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](1); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); (uint256 amountOut, uint256 gasEstimate) = mixedQuoter.quoteMixedExactInput(paths, actions, params, 1 ether); @@ -868,7 +868,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](1); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); // swap 0.5 ether (uint256 amountOut, uint256 gasEstimate) = mixedQuoter.quoteMixedExactInput(paths, actions, params, 0.5 ether); assertEq(amountOut, 498417179678643398); @@ -947,7 +947,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](1); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); bytes[] memory multicallBytes = new bytes[](2); multicallBytes[0] = abi.encodeWithSelector( @@ -1028,7 +1028,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](1); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); (uint256 amountOut, uint256 gasEstimate) = mixedQuoter.quoteMixedExactInput(paths, actions, params, 1 ether); @@ -1063,7 +1063,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](1); params[0] = abi.encode( - IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKeyWithWETH, hookData: ZERO_BYTES}) + IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKeyWithWETH, hookData: ZERO_BYTES}) ); (uint256 amountOut, uint256 gasEstimate) = mixedQuoter.quoteMixedExactInput(paths, actions, params, 1 ether); @@ -1094,7 +1094,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](1); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: binPoolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: binPoolKey, hookData: ZERO_BYTES})); (uint256 amountOut, uint256 gasEstimate) = mixedQuoter.quoteMixedExactInput(paths, actions, params, 1 ether); @@ -1124,7 +1124,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](1); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: binPoolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: binPoolKey, hookData: ZERO_BYTES})); // swap 0.5 ether (uint256 amountOut, uint256 gasEstimate) = mixedQuoter.quoteMixedExactInput(paths, actions, params, 0.5 ether); uint256 swapPath1Output = amountOut; @@ -1196,7 +1196,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](1); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: binPoolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: binPoolKey, hookData: ZERO_BYTES})); bytes[] memory multicallBytes = new bytes[](2); multicallBytes[0] = abi.encodeWithSelector( @@ -1277,7 +1277,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](1); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: binPoolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: binPoolKey, hookData: ZERO_BYTES})); (uint256 amountOut, uint256 gasEstimate) = mixedQuoter.quoteMixedExactInput(paths, actions, params, 1 ether); @@ -1314,7 +1314,7 @@ contract MixedQuoterTest is actions1[2] = bytes1(uint8(MixedQuoterActions.V3_EXACT_INPUT_SINGLE)); bytes[] memory params1 = new bytes[](3); params1[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); params1[1] = new bytes(0); uint24 fee = 500; params1[2] = abi.encode(fee); @@ -1333,7 +1333,7 @@ contract MixedQuoterTest is bytes[] memory params2 = new bytes[](3); params2[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); params2[1] = new bytes(0); params2[2] = new bytes(0); @@ -1448,7 +1448,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](2); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); params[1] = new bytes(0); (uint256 amountOut, uint256 gasEstimate) = mixedQuoter.quoteMixedExactInput(paths, actions, params, 1 ether); @@ -1474,7 +1474,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](3); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); params[1] = new bytes(0); uint24 fee = 500; params[2] = abi.encode(fee); @@ -1504,11 +1504,11 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](4); params[0] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKey, hookData: ZERO_BYTES})); params[1] = new bytes(0); params[2] = new bytes(0); params[3] = - abi.encode(IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: binPoolKey, hookData: ZERO_BYTES})); + abi.encode(IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: binPoolKey, hookData: ZERO_BYTES})); (uint256 amountOut, uint256 gasEstimate) = mixedQuoter.quoteMixedExactInput(paths, actions, params, 1 ether); @@ -1533,7 +1533,7 @@ contract MixedQuoterTest is uint24 fee = 500; params[0] = abi.encode(fee); params[1] = abi.encode( - IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKeyWithNativeToken, hookData: ZERO_BYTES}) + IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKeyWithNativeToken, hookData: ZERO_BYTES}) ); (uint256 amountOut, uint256 gasEstimate) = mixedQuoter.quoteMixedExactInput(paths, actions, params, 1 ether); @@ -1557,7 +1557,7 @@ contract MixedQuoterTest is bytes[] memory params = new bytes[](2); params[0] = abi.encode( - IMixedQuoter.QuoteMixedV4ExactInputSingleParams({poolKey: poolKeyWithNativeToken, hookData: ZERO_BYTES}) + IMixedQuoter.QuoteMixedInfiExactInputSingleParams({poolKey: poolKeyWithNativeToken, hookData: ZERO_BYTES}) ); uint24 fee = 500; params[1] = abi.encode(fee); diff --git a/test/mocks/MockReentrantPositionManager.sol b/test/mocks/MockReentrantPositionManager.sol index ed9880b..72a5b6e 100644 --- a/test/mocks/MockReentrantPositionManager.sol +++ b/test/mocks/MockReentrantPositionManager.sol @@ -55,22 +55,22 @@ contract MockReentrantPositionManager is Test { } function modifyLiquidities(bytes calldata, uint256) external payable { - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = _generateMockV4BinPoolParams(); + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = _generateMockInfiBinPoolParams(); - ICLMigrator.V4CLPoolParams memory v4CLPoolParams = _generateMockV4CLPoolParams(); + ICLMigrator.InfiCLPoolParams memory infiCLPoolParams = _generateMockInfiCLPoolParams(); IBaseMigrator.V3PoolParams memory v3PoolParams = _generateMockV3PoolParams(); IBaseMigrator.V2PoolParams memory v2PoolParams = _generateMockV2PoolParams(); // Mock data can fulfill the requirement because it will trigger ContractLocked revert before any operations are executed if (reentrantType == ReentrantType.BinMigrateFromV2) { - binMigrator.migrateFromV2(v2PoolParams, v4BinPoolParams, 0, 0); + binMigrator.migrateFromV2(v2PoolParams, infiBinPoolParams, 0, 0); } else if (reentrantType == ReentrantType.BinMigrateFromV3) { - binMigrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 0, 0); + binMigrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 0, 0); } else if (reentrantType == ReentrantType.CLMigrateFromV2) { - clMigrator.migrateFromV2(v2PoolParams, v4CLPoolParams, 0, 0); + clMigrator.migrateFromV2(v2PoolParams, infiCLPoolParams, 0, 0); } else if (reentrantType == ReentrantType.CLMigrateFromV3) { - clMigrator.migrateFromV3(v3PoolParams, v4CLPoolParams, 0, 0); + clMigrator.migrateFromV3(v3PoolParams, infiCLPoolParams, 0, 0); } } @@ -85,8 +85,8 @@ contract MockReentrantPositionManager is Test { }); } - function _generateMockV4BinPoolParams() internal returns (IBinMigrator.V4BinPoolParams memory) { - return IBinMigrator.V4BinPoolParams({ + function _generateMockInfiBinPoolParams() internal returns (IBinMigrator.InfiBinPoolParams memory) { + return IBinMigrator.InfiBinPoolParams({ poolKey: _generateMockPoolKey(), amount0Max: type(uint128).max, amount1Max: type(uint128).max, @@ -101,8 +101,8 @@ contract MockReentrantPositionManager is Test { }); } - function _generateMockV4CLPoolParams() internal returns (ICLMigrator.V4CLPoolParams memory) { - return ICLMigrator.V4CLPoolParams({ + function _generateMockInfiCLPoolParams() internal returns (ICLMigrator.InfiCLPoolParams memory) { + return ICLMigrator.InfiCLPoolParams({ poolKey: _generateMockPoolKey(), tickLower: 0, tickUpper: 0, diff --git a/test/pool-bin/migrator/BinMigratorFromV2.sol b/test/pool-bin/migrator/BinMigratorFromV2.sol index 5b37e0f..3e20ea2 100644 --- a/test/pool-bin/migrator/BinMigratorFromV2.sol +++ b/test/pool-bin/migrator/BinMigratorFromV2.sol @@ -164,7 +164,7 @@ abstract contract BinMigratorFromV2 is IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -184,7 +184,7 @@ abstract contract BinMigratorFromV2 is // 4. migrateFromV2 vm.expectRevert(Pausable.EnforcedPause.selector); - migrator.migrateFromV2(v2PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiBinPoolParams, 0, 0); } function testMigrateFromV2_HookData() public { @@ -212,7 +212,7 @@ abstract contract BinMigratorFromV2 is _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); bytes memory hookData = abi.encode(32); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -227,7 +227,7 @@ abstract contract BinMigratorFromV2 is }); // 4. migrateFromV2 - migrator.migrateFromV2(v2PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiBinPoolParams, 0, 0); // assert hookData flown to hook assertEq(binMigratorHook.hookData(), hookData); @@ -262,7 +262,7 @@ abstract contract BinMigratorFromV2 is IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -277,7 +277,7 @@ abstract contract BinMigratorFromV2 is }); vm.expectRevert(ReentrancyLock.ContractLocked.selector); - migrator.migrateFromV2(v2PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiBinPoolParams, 0, 0); } function testMigrateFromV2IncludingInit() public { @@ -302,7 +302,7 @@ abstract contract BinMigratorFromV2 is IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -319,7 +319,7 @@ abstract contract BinMigratorFromV2 is // 3. multicall, combine initialize and migrateFromV2 bytes[] memory data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, ACTIVE_BIN_ID, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, v4BinPoolParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, infiBinPoolParams, 0, 0); migrator.multicall(data); vm.snapshotGasLastCall("testMigrateFromV2IncludingInit"); @@ -392,7 +392,7 @@ abstract contract BinMigratorFromV2 is // infinity ETH, token1 PoolKey memory poolKeyMismatch = poolKey; poolKeyMismatch.currency1 = Currency.wrap(address(token1)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: poolKeyMismatch, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -409,7 +409,7 @@ abstract contract BinMigratorFromV2 is // 3. multicall, combine initialize and migrateFromV2 bytes[] memory data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKeyMismatch, ACTIVE_BIN_ID, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, v4BinPoolParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, infiBinPoolParams, 0, 0); vm.expectRevert(); migrator.multicall(data); @@ -418,11 +418,11 @@ abstract contract BinMigratorFromV2 is // infinity token0, token1 poolKeyMismatch.currency0 = Currency.wrap(address(token0)); poolKeyMismatch.currency1 = Currency.wrap(address(token1)); - v4BinPoolParams.poolKey = poolKeyMismatch; + infiBinPoolParams.poolKey = poolKeyMismatch; data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKeyMismatch, ACTIVE_BIN_ID, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, v4BinPoolParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, infiBinPoolParams, 0, 0); vm.expectRevert(); migrator.multicall(data); } @@ -453,7 +453,7 @@ abstract contract BinMigratorFromV2 is IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -468,7 +468,7 @@ abstract contract BinMigratorFromV2 is }); // 4. migrateFromV2 - migrator.migrateFromV2(v2PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiBinPoolParams, 0, 0); vm.snapshotGasLastCall("testMigrateFromV2WithoutInit"); // necessary checks @@ -544,7 +544,7 @@ abstract contract BinMigratorFromV2 is poolKeyWithoutNativeToken, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this) ); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory InfiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -559,7 +559,7 @@ abstract contract BinMigratorFromV2 is }); // 4. migrate from v2 to infinity - migrator.migrateFromV2(v2PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, InfiBinPoolParams, 0, 0); vm.snapshotGasLastCall("testMigrateFromV2WithoutNativeToken"); // necessary checks @@ -629,7 +629,7 @@ abstract contract BinMigratorFromV2 is IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -650,7 +650,7 @@ abstract contract BinMigratorFromV2 is address(this), permit2, address(token0), address(migrator), 20 ether, 20 ether ); // 4. migrate from v2 to infinity - migrator.migrateFromV2{value: 20 ether}(v2PoolParams, v4BinPoolParams, 20 ether, 20 ether); + migrator.migrateFromV2{value: 20 ether}(v2PoolParams, infiBinPoolParams, 20 ether, 20 ether); // necessary checks // consumed extra 20 ether from user @@ -726,7 +726,7 @@ abstract contract BinMigratorFromV2 is IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -750,7 +750,7 @@ abstract contract BinMigratorFromV2 is address(this), permit2, address(token0), address(migrator), 20 ether, 20 ether ); // 4. migrate from v2 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV2(v2PoolParams, v4BinPoolParams, 20 ether, 20 ether); + migrator.migrateFromV2(v2PoolParams, infiBinPoolParams, 20 ether, 20 ether); // necessary checks // consumed extra 20 ether from user @@ -842,7 +842,7 @@ abstract contract BinMigratorFromV2 is // delete the last distribution point so that the refund is triggered // we expect to get 50% of tokenX back // (0, 50%) (50%, 50%) (50%, 0) => (0, 50%) (50%, 50%) - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -860,7 +860,7 @@ abstract contract BinMigratorFromV2 is uint256 balance1Before = token0.balanceOf(address(this)); // 4. migrate from v2 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV2(v2PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiBinPoolParams, 0, 0); // necessary checks // refund 5 ether in the form of native token @@ -953,7 +953,7 @@ abstract contract BinMigratorFromV2 is // delete the last distribution point so that the refund is triggered // we expect to get 50% of tokenX back // (0, 50%) (50%, 50%) (50%, 0) => (0, 50%) (50%, 50%) - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -971,7 +971,7 @@ abstract contract BinMigratorFromV2 is uint256 balance1Before = token1.balanceOf(address(this)); // 4. migrate from v2 to infinity - migrator.migrateFromV2(v2PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiBinPoolParams, 0, 0); // necessary checks @@ -1064,7 +1064,7 @@ abstract contract BinMigratorFromV2 is IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -1082,7 +1082,7 @@ abstract contract BinMigratorFromV2 is bytes[] memory data = new bytes[](3); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, ACTIVE_BIN_ID, bytes("")); data[1] = abi.encodeWithSelector(Permit2Forwarder.permit.selector, userAddr, permit, sig); - data[2] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, v4BinPoolParams, 0, 0); + data[2] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, infiBinPoolParams, 0, 0); vm.startPrank(userAddr); v2Pair.permit(userAddr, address(permit2), lpTokenBefore, ddl, v, r, s); migrator.multicall(data); diff --git a/test/pool-bin/migrator/BinMigratorFromV3.sol b/test/pool-bin/migrator/BinMigratorFromV3.sol index 1c0c86a..3725169 100644 --- a/test/pool-bin/migrator/BinMigratorFromV3.sol +++ b/test/pool-bin/migrator/BinMigratorFromV3.sol @@ -186,7 +186,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -206,7 +206,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep // 4. migrateFromV3 directly given pool has been initialized vm.expectRevert(Pausable.EnforcedPause.selector); - migrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 0, 0); } function testMigrateFromV3_HookData() public { @@ -234,7 +234,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); bytes memory hookData = abi.encode(32); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -249,7 +249,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep }); // 4. migrateFromV3 directly given pool has been initialized - migrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 0, 0); // assert hookData flown to hook assertEq(binMigratorHook.hookData(), hookData); @@ -285,7 +285,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -300,7 +300,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep }); vm.expectRevert(ReentrancyLock.ContractLocked.selector); - migrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 0, 0); } function testMigrateFromV3IncludingInit() public { @@ -326,7 +326,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -343,7 +343,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep // 3. multicall, combine initialize and migrateFromV3 bytes[] memory data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, ACTIVE_BIN_ID, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, v4BinPoolParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, infiBinPoolParams, 0, 0); migrator.multicall(data); vm.snapshotGasLastCall("testMigrateFromV3IncludingInit"); @@ -417,7 +417,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep // infinity ETH, token1 PoolKey memory poolKeyMismatch = poolKey; poolKeyMismatch.currency1 = Currency.wrap(address(token1)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: poolKeyMismatch, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -434,7 +434,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep // 3. multicall, combine initialize and migrateFromV3 bytes[] memory data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKeyMismatch, ACTIVE_BIN_ID, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, v4BinPoolParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, infiBinPoolParams, 0, 0); vm.expectRevert(); migrator.multicall(data); @@ -443,11 +443,11 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep // infinity token0, token1 poolKeyMismatch.currency0 = Currency.wrap(address(token0)); poolKeyMismatch.currency1 = Currency.wrap(address(token1)); - v4BinPoolParams.poolKey = poolKeyMismatch; + infiBinPoolParams.poolKey = poolKeyMismatch; data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKeyMismatch, ACTIVE_BIN_ID, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, v4BinPoolParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, infiBinPoolParams, 0, 0); vm.expectRevert(); migrator.multicall(data); } @@ -479,7 +479,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -494,7 +494,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep }); // 4. migrateFromV3 directly given pool has been initialized - migrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 0, 0); vm.snapshotGasLastCall("testMigrateFromV3WithoutInit"); // necessary checks @@ -568,7 +568,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep poolKeyWithoutNativeToken, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this) ); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -583,7 +583,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep }); // 4. migrate from v3 to infinity - migrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 0, 0); vm.snapshotGasLastCall("testMigrateFromV3WithoutNativeToken"); // necessary checks @@ -655,7 +655,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -676,7 +676,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep address(this), permit2, address(token0), address(migrator), 20 ether, 20 ether ); // 4. migrate from v3 to infinity - migrator.migrateFromV3{value: 20 ether}(v3PoolParams, v4BinPoolParams, 20 ether, 20 ether); + migrator.migrateFromV3{value: 20 ether}(v3PoolParams, infiBinPoolParams, 20 ether, 20 ether); // necessary checks // consumed extra 20 ether from user @@ -753,7 +753,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -801,7 +801,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep 0x0000000000000000000000000000000000000000000000000000000000000000 ); // 4. migrate from v3 to infinity - migrator.migrateFromV3{value: 20 ether}(v3PoolParams, v4BinPoolParams, 20 ether, 20 ether); + migrator.migrateFromV3{value: 20 ether}(v3PoolParams, infiBinPoolParams, 20 ether, 20 ether); uint256 nativeBlanceAfter = address(this).balance; // user did not consume any native token, and also get the v3 liquidity native token as refund @@ -845,7 +845,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -869,7 +869,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep address(this), permit2, address(token0), address(migrator), 20 ether, 20 ether ); // 4. migrate from v3 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 20 ether, 20 ether); + migrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 20 ether, 20 ether); // necessary checks // consumed extra 20 ether from user @@ -963,7 +963,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep // delete the last distribution point so that the refund is triggered // we expect to get 50% of tokenX back // (0, 50%) (50%, 50%) (50%, 0) => (0, 50%) (50%, 50%) - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -981,7 +981,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep uint256 balance1Before = token0.balanceOf(address(this)); // 4. migrate from v3 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 0, 0); // necessary checks // refund 5 ether in the form of native token @@ -1072,7 +1072,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep // delete the last distribution point so that the refund is triggered // we expect to get 50% of tokenX back // (0, 50%) (50%, 50%) (50%, 0) => (0, 50%) (50%, 50%) - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -1090,7 +1090,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep uint256 balance1Before = token1.balanceOf(address(this)); // 4. migrate from v3 to infinity - migrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 0, 0); // necessary checks @@ -1180,7 +1180,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep // delete the last distribution point so that the refund is triggered // we expect to get 50% of tokenX back // (0, 50%) (50%, 50%) (50%, 0) => (0, 50%) (50%, 50%) - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -1195,7 +1195,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep }); // 4. migrate half - migrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 0, 0); // make sure there are still liquidity left in v3 position token (,,,,,,, uint128 liquidityFromV3After,,,,) = v3Nfpm.positions(1); @@ -1204,7 +1204,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep // 5. make sure non-owner can't migrate the rest vm.expectRevert(IBaseMigrator.NOT_TOKEN_OWNER.selector); vm.prank(makeAddr("someone")); - migrator.migrateFromV3(v3PoolParams, v4BinPoolParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiBinPoolParams, 0, 0); } function testMigrateFromV3ThroughOffchainSign() public { @@ -1242,7 +1242,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -1260,7 +1260,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep bytes[] memory data = new bytes[](3); data[0] = abi.encodeWithSelector(migrator.selfPermitERC721.selector, v3Nfpm, 1, ddl, v, r, s); data[1] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, ACTIVE_BIN_ID, bytes("")); - data[2] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, v4BinPoolParams, 0, 0); + data[2] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, infiBinPoolParams, 0, 0); vm.prank(userAddr); migrator.multicall(data); @@ -1342,7 +1342,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep IBinPositionManager.BinAddLiquidityParams memory params = _getAddParams(poolKey, getBinIds(ACTIVE_BIN_ID, 3), 10 ether, 10 ether, ACTIVE_BIN_ID, address(this)); - IBinMigrator.V4BinPoolParams memory v4BinPoolParams = IBinMigrator.V4BinPoolParams({ + IBinMigrator.InfiBinPoolParams memory infiBinPoolParams = IBinMigrator.InfiBinPoolParams({ poolKey: params.poolKey, amount0Max: params.amount0Max, amount1Max: params.amount1Max, @@ -1369,7 +1369,7 @@ abstract contract BinMigratorFromV3 is OldVersionHelper, BinLiquidityHelper, Dep data[0] = abi.encodeWithSelector(migrator.selfPermitERC721.selector, v3Nfpm, 1, ddl, v, r, s); data[1] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, ACTIVE_BIN_ID, bytes("")); data[2] = - abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, v4BinPoolParams, 10 ether, 10 ether); + abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, infiBinPoolParams, 10 ether, 10 ether); vm.prank(userAddr); migrator.multicall{value: 10 ether}(data); diff --git a/test/pool-cl/migrator/CLMigratorFromV2.sol b/test/pool-cl/migrator/CLMigratorFromV2.sol index 90d4f81..288a167 100644 --- a/test/pool-cl/migrator/CLMigratorFromV2.sol +++ b/test/pool-cl/migrator/CLMigratorFromV2.sol @@ -136,7 +136,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -152,7 +152,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap // 4. migrate from v2 to infinity vm.expectRevert(Pausable.EnforcedPause.selector); - migrator.migrateFromV2(v2PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiMintParams, 0, 0); } function testCLMigrateFromV2_HookData() public { @@ -178,7 +178,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap }); bytes memory hookData = abi.encode(32); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -188,7 +188,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap hookData: hookData }); - migrator.migrateFromV2(v2PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiMintParams, 0, 0); // assert hookData flown to hook assertEq(clMigratorHook.hookData(), hookData); @@ -224,7 +224,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -235,7 +235,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap }); vm.expectRevert(ReentrancyLock.ContractLocked.selector); - migrator.migrateFromV2(v2PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiMintParams, 0, 0); } function testCLMigrateFromV2IncludingInit() public { @@ -258,7 +258,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -272,7 +272,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap uint160 initSqrtPrice = 79228162514264337593543950336; bytes[] memory data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, initSqrtPrice, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, v4MintParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, infiMintParams, 0, 0); migrator.multicall(data); vm.snapshotGasLastCall("testCLMigrateFromV2IncludingInit"); @@ -311,7 +311,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap // infinity ETH, token1 PoolKey memory poolKeyMismatch = poolKey; poolKeyMismatch.currency1 = Currency.wrap(address(token1)); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKeyMismatch, tickLower: -100, tickUpper: 100, @@ -325,7 +325,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap uint160 initSqrtPrice = 79228162514264337593543950336; bytes[] memory data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKeyMismatch, initSqrtPrice, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, v4MintParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, infiMintParams, 0, 0); vm.expectRevert(); migrator.multicall(data); @@ -334,11 +334,11 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap // infinity token0, token1 poolKeyMismatch.currency0 = Currency.wrap(address(token0)); poolKeyMismatch.currency1 = Currency.wrap(address(token1)); - v4MintParams.poolKey = poolKeyMismatch; + infiMintParams.poolKey = poolKeyMismatch; data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKeyMismatch, initSqrtPrice, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, v4MintParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, infiMintParams, 0, 0); vm.expectRevert(); migrator.multicall(data); } @@ -368,7 +368,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -379,7 +379,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap }); vm.expectRevert(ICLMigrator.INSUFFICIENT_LIQUIDITY.selector); - migrator.migrateFromV2(v2PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiMintParams, 0, 0); } function testCLMigrateFromV2WithoutInit() public { @@ -406,7 +406,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -417,7 +417,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap }); // 4. migrate from v2 to infinity - migrator.migrateFromV2(v2PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiMintParams, 0, 0); vm.snapshotGasLastCall("testCLMigrateFromV2WithoutInit"); // necessary checks @@ -462,7 +462,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKeyWithoutNativeToken, tickLower: -100, tickUpper: 100, @@ -473,7 +473,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap }); // 4. migrate from v2 to infinity - migrator.migrateFromV2(v2PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiMintParams, 0, 0); vm.snapshotGasLastCall("testCLMigrateFromV2WithoutNativeToken"); // necessary checks @@ -514,7 +514,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -531,7 +531,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap address(this), permit2, address(token0), address(migrator), 20 ether, 20 ether ); // 4. migrate from v2 to infinity - migrator.migrateFromV2{value: 20 ether}(v2PoolParams, v4MintParams, 20 ether, uint160(20 ether)); + migrator.migrateFromV2{value: 20 ether}(v2PoolParams, infiMintParams, 20 ether, uint160(20 ether)); // necessary checks // consumed extra 20 ether from user @@ -578,7 +578,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -598,7 +598,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap address(this), permit2, address(token0), address(migrator), 20 ether, 20 ether ); // 4. migrate from v2 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV2(v2PoolParams, v4MintParams, 20 ether, 20 ether); + migrator.migrateFromV2(v2PoolParams, infiMintParams, 20 ether, 20 ether); // necessary checks // consumed extra 20 ether from user @@ -648,7 +648,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -668,7 +668,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap address(this), permit2, address(token0), address(migrator), extraAmount, uint160(extraAmount) ); // 4. migrate from v2 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV2(v2PoolParams, v4MintParams, extraAmount, extraAmount); + migrator.migrateFromV2(v2PoolParams, infiMintParams, extraAmount, extraAmount); // clPositionManager native balance should be 0 uint256 lPositionManagerNativeBalance = address(lpm).balance; @@ -728,7 +728,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: isWETHFirst ? 4.999 ether : 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -742,7 +742,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap uint256 balance1Before = token0.balanceOf(address(this)); // 4. migrate from v2 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV2(v2PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiMintParams, 0, 0); // necessary checks // refund 5 ether in the form of native token @@ -795,7 +795,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 4.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKeyWithoutNativeToken, tickLower: -100, tickUpper: 100, @@ -809,7 +809,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap uint256 balance1Before = token1.balanceOf(address(this)); // 4. migrate from v2 to infinity - migrator.migrateFromV2(v2PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV2(v2PoolParams, infiMintParams, 0, 0); // necessary checks @@ -877,7 +877,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap amount1Min: 9.999 ether }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -892,7 +892,7 @@ abstract contract CLMigratorFromV2 is OldVersionHelper, PosmTestSetup, Permit2Ap bytes[] memory data = new bytes[](3); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, initSqrtPrice, bytes("")); data[1] = abi.encodeWithSelector(Permit2Forwarder.permit.selector, userAddr, permit, sig); - data[2] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, v4MintParams, 0, 0); + data[2] = abi.encodeWithSelector(migrator.migrateFromV2.selector, v2PoolParams, infiMintParams, 0, 0); vm.startPrank(userAddr); v2Pair.permit(userAddr, address(permit2), lpTokenBefore, ddl, v, r, s); migrator.multicall(data); diff --git a/test/pool-cl/migrator/CLMigratorFromV3.sol b/test/pool-cl/migrator/CLMigratorFromV3.sol index 54bce60..1aa108a 100644 --- a/test/pool-cl/migrator/CLMigratorFromV3.sol +++ b/test/pool-cl/migrator/CLMigratorFromV3.sol @@ -169,7 +169,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -185,7 +185,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap // 4. migrateFromV3 directly given pool has been initialized vm.expectRevert(Pausable.EnforcedPause.selector); - migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 0, 0); } function testCLMigrateFromV3_HookData() public { @@ -210,7 +210,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap }); bytes memory hookData = abi.encode(32); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -221,7 +221,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap }); // 4. migrateFromV3 directly given pool has been initialized - migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 0, 0); // assert hookData flown to hook assertEq(clMigratorHook.hookData(), hookData); @@ -256,7 +256,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -267,7 +267,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap }); vm.expectRevert(ReentrancyLock.ContractLocked.selector); - migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 0, 0); } function testCLMigrateFromV3IncludingInit() public { @@ -290,7 +290,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -303,7 +303,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap // 3. multicall, combine initialize and migrateFromV3 bytes[] memory data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, INIT_SQRT_PRICE, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, v4MintParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, infiMintParams, 0, 0); migrator.multicall(data); vm.snapshotGasLastCall("testCLMigrateFromV3IncludingInit"); @@ -346,7 +346,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap // infinity ETH, token1 PoolKey memory poolKeyMismatch = poolKey; poolKeyMismatch.currency1 = Currency.wrap(address(token1)); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKeyMismatch, tickLower: -100, tickUpper: 100, @@ -359,7 +359,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap // 3. multicall, combine initialize and migrateFromV3 bytes[] memory data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, INIT_SQRT_PRICE, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, v4MintParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, infiMintParams, 0, 0); vm.expectRevert(); migrator.multicall(data); @@ -368,10 +368,10 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap // infinity token0, token1 poolKeyMismatch.currency0 = Currency.wrap(address(token0)); poolKeyMismatch.currency1 = Currency.wrap(address(token1)); - v4MintParams.poolKey = poolKeyMismatch; + infiMintParams.poolKey = poolKeyMismatch; data = new bytes[](2); data[0] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, INIT_SQRT_PRICE, bytes("")); - data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, v4MintParams, 0, 0); + data[1] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, infiMintParams, 0, 0); vm.expectRevert(); migrator.multicall(data); } @@ -400,7 +400,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -411,7 +411,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap }); vm.expectRevert(ICLMigrator.INSUFFICIENT_LIQUIDITY.selector); - migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 0, 0); } function testCLMigrateFromV3WithoutInit() public { @@ -437,7 +437,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -448,7 +448,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap }); // 4. migrateFromV3 directly given pool has been initialized - migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 0, 0); vm.snapshotGasLastCall("testCLMigrateFromV3WithoutInit"); // necessary checks @@ -490,7 +490,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKeyWithoutNativeToken, tickLower: -100, tickUpper: 100, @@ -501,7 +501,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap }); // 4. migrate from v3 to infinity - migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 0, 0); vm.snapshotGasLastCall("testCLMigrateFromV3WithoutNativeToken"); // necessary checks @@ -542,7 +542,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -559,7 +559,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap address(this), permit2, address(token0), address(migrator), 20 ether, 20 ether ); // 4. migrate from v3 to infinity - migrator.migrateFromV3{value: 20 ether}(v3PoolParams, v4MintParams, 20 ether, 20 ether); + migrator.migrateFromV3{value: 20 ether}(v3PoolParams, infiMintParams, 20 ether, 20 ether); // necessary checks // consumed extra 20 ether from user @@ -606,7 +606,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -626,7 +626,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap address(this), permit2, address(token0), address(migrator), 20 ether, 20 ether ); // 4. migrate from v3 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV3(v3PoolParams, v4MintParams, 20 ether, 20 ether); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 20 ether, 20 ether); // necessary checks // consumed extra 20 ether from user @@ -675,7 +675,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -695,7 +695,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap address(this), permit2, address(token0), address(migrator), extraAmount, uint160(extraAmount) ); // 4. migrate from v3 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV3(v3PoolParams, v4MintParams, extraAmount, extraAmount); + migrator.migrateFromV3(v3PoolParams, infiMintParams, extraAmount, extraAmount); // clPositionManager native balance should be 0 uint256 lPositionManagerNativeBalance = address(lpm).balance; @@ -754,7 +754,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: tickLower, tickUpper: tickUpper, @@ -776,7 +776,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap uint256 vaultCurrency1BalanceBefore = poolKey.currency1.balanceOf(address(vault)); vm.recordLogs(); // 4. migrate from v3 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV3(v3PoolParams, v4MintParams, extraAmount0, extraAmount1); + migrator.migrateFromV3(v3PoolParams, infiMintParams, extraAmount0, extraAmount1); uint256 vaultCurrency0BalanceAfter = poolKey.currency0.balanceOf(address(vault)); uint256 vaultCurrency1BalanceAfter = poolKey.currency1.balanceOf(address(vault)); @@ -862,7 +862,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -876,7 +876,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap uint256 balance1Before = token0.balanceOf(address(this)); // 4. migrate from v3 to infinity, not sending ETH denotes pay by WETH - migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 0, 0); // necessary checks // refund 5 ether in the form of native token @@ -924,7 +924,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKeyWithoutNativeToken, tickLower: -100, tickUpper: 100, @@ -938,7 +938,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap uint256 balance1Before = token1.balanceOf(address(this)); // 4. migrate from v3 to infinity - migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 0, 0); // necessary checks @@ -987,7 +987,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -998,7 +998,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap }); // 4. migrate half - migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 0, 0); // make sure there are still liquidity left in v3 position token (,,,,,,, uint128 liquidityFromV3After,,,,) = v3Nfpm.positions(1); @@ -1007,7 +1007,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap // 5. make sure non-owner can't migrate the rest vm.expectRevert(IBaseMigrator.NOT_TOKEN_OWNER.selector); vm.prank(makeAddr("someone")); - migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); + migrator.migrateFromV3(v3PoolParams, infiMintParams, 0, 0); } function testCLMigrateFromV3ThroughOffchainSign() public { @@ -1042,7 +1042,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -1056,7 +1056,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap bytes[] memory data = new bytes[](3); data[0] = abi.encodeWithSelector(migrator.selfPermitERC721.selector, v3Nfpm, 1, ddl, v, r, s); data[1] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, INIT_SQRT_PRICE, bytes("")); - data[2] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, v4MintParams, 0, 0); + data[2] = abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, infiMintParams, 0, 0); vm.prank(userAddr); migrator.multicall(data); @@ -1107,7 +1107,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap deadline: block.timestamp + 100 }); - ICLMigrator.V4CLPoolParams memory v4MintParams = ICLMigrator.V4CLPoolParams({ + ICLMigrator.InfiCLPoolParams memory infiMintParams = ICLMigrator.InfiCLPoolParams({ poolKey: poolKey, tickLower: -100, tickUpper: 100, @@ -1128,7 +1128,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, PosmTestSetup, Permit2Ap data[0] = abi.encodeWithSelector(migrator.selfPermitERC721.selector, v3Nfpm, 1, ddl, v, r, s); data[1] = abi.encodeWithSelector(migrator.initializePool.selector, poolKey, INIT_SQRT_PRICE, bytes("")); data[2] = - abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, v4MintParams, 10 ether, 10 ether); + abi.encodeWithSelector(migrator.migrateFromV3.selector, v3PoolParams, infiMintParams, 10 ether, 10 ether); vm.prank(userAddr); migrator.multicall{value: 10 ether}(data);