diff --git a/src/pool-cl/CLMigrator.sol b/src/pool-cl/CLMigrator.sol index b0d5692..e66c3c9 100644 --- a/src/pool-cl/CLMigrator.sol +++ b/src/pool-cl/CLMigrator.sol @@ -17,7 +17,7 @@ contract CLMigrator is ICLMigrator, BaseMigrator { function migrateFromV2( V2PoolParams calldata v2PoolParams, - V4CLPoolParams calldata v4MintParams, + V4CLPoolParams calldata v4PoolParams, uint256 extraAmount0, uint256 extraAmount1 ) external payable override { @@ -25,39 +25,39 @@ contract CLMigrator is ICLMigrator, BaseMigrator { /// @notice if user mannually specify the price range, they might need to send extra token batchAndNormalizeTokens( - v4MintParams.poolKey.currency0, v4MintParams.poolKey.currency1, extraAmount0, extraAmount1 + v4PoolParams.poolKey.currency0, v4PoolParams.poolKey.currency1, extraAmount0, extraAmount1 ); uint256 amount0In = amount0Received + extraAmount0; uint256 amount1In = amount1Received + extraAmount1; INonfungiblePositionManager.MintParams memory mintParams = INonfungiblePositionManager.MintParams({ - poolKey: v4MintParams.poolKey, - tickLower: v4MintParams.tickLower, - tickUpper: v4MintParams.tickUpper, - salt: v4MintParams.salt, + poolKey: v4PoolParams.poolKey, + tickLower: v4PoolParams.tickLower, + tickUpper: v4PoolParams.tickUpper, + salt: v4PoolParams.salt, amount0Desired: amount0In, amount1Desired: amount1In, - amount0Min: v4MintParams.amount0Min, - amount1Min: v4MintParams.amount1Min, - recipient: v4MintParams.recipient, - deadline: v4MintParams.deadline + amount0Min: v4PoolParams.amount0Min, + amount1Min: v4PoolParams.amount1Min, + recipient: v4PoolParams.recipient, + deadline: v4PoolParams.deadline }); (,, uint256 amount0Consumed, uint256 amount1Consumed) = _addLiquidityToTargetPool(mintParams); // refund if necessary, ETH is supported by CurrencyLib unchecked { if (amount0In > amount0Consumed) { - v4MintParams.poolKey.currency0.transfer(v4MintParams.recipient, amount0In - amount0Consumed); + v4PoolParams.poolKey.currency0.transfer(v4PoolParams.recipient, amount0In - amount0Consumed); } if (amount1In > amount1Consumed) { - v4MintParams.poolKey.currency1.transfer(v4MintParams.recipient, amount1In - amount1Consumed); + v4PoolParams.poolKey.currency1.transfer(v4PoolParams.recipient, amount1In - amount1Consumed); } } } function migrateFromV3( V3PoolParams calldata v3PoolParams, - V4CLPoolParams calldata v4MintParams, + V4CLPoolParams calldata v4PoolParams, uint256 extraAmount0, uint256 extraAmount1 ) external payable override { @@ -65,32 +65,32 @@ contract CLMigrator is ICLMigrator, BaseMigrator { /// @notice if user mannually specify the price range, they need to send extra token batchAndNormalizeTokens( - v4MintParams.poolKey.currency0, v4MintParams.poolKey.currency1, extraAmount0, extraAmount1 + v4PoolParams.poolKey.currency0, v4PoolParams.poolKey.currency1, extraAmount0, extraAmount1 ); uint256 amount0In = amount0Received + extraAmount0; uint256 amount1In = amount1Received + extraAmount1; INonfungiblePositionManager.MintParams memory mintParams = INonfungiblePositionManager.MintParams({ - poolKey: v4MintParams.poolKey, - tickLower: v4MintParams.tickLower, - tickUpper: v4MintParams.tickUpper, - salt: v4MintParams.salt, + poolKey: v4PoolParams.poolKey, + tickLower: v4PoolParams.tickLower, + tickUpper: v4PoolParams.tickUpper, + salt: v4PoolParams.salt, amount0Desired: amount0In, amount1Desired: amount1In, - amount0Min: v4MintParams.amount0Min, - amount1Min: v4MintParams.amount1Min, - recipient: v4MintParams.recipient, - deadline: v4MintParams.deadline + amount0Min: v4PoolParams.amount0Min, + amount1Min: v4PoolParams.amount1Min, + recipient: v4PoolParams.recipient, + deadline: v4PoolParams.deadline }); (,, uint256 amount0Consumed, uint256 amount1Consumed) = _addLiquidityToTargetPool(mintParams); // refund if necessary, ETH is supported by CurrencyLib unchecked { if (amount0In > amount0Consumed) { - v4MintParams.poolKey.currency0.transfer(v4MintParams.recipient, amount0In - amount0Consumed); + v4PoolParams.poolKey.currency0.transfer(v4PoolParams.recipient, amount0In - amount0Consumed); } if (amount1In > amount1Consumed) { - v4MintParams.poolKey.currency1.transfer(v4MintParams.recipient, amount1In - amount1Consumed); + v4PoolParams.poolKey.currency1.transfer(v4PoolParams.recipient, amount1In - amount1Consumed); } } } diff --git a/src/pool-cl/interfaces/ICLMigrator.sol b/src/pool-cl/interfaces/ICLMigrator.sol index 878e599..733c350 100644 --- a/src/pool-cl/interfaces/ICLMigrator.sol +++ b/src/pool-cl/interfaces/ICLMigrator.sol @@ -23,7 +23,7 @@ interface ICLMigrator is IBaseMigrator { function migrateFromV2( V2PoolParams calldata v2PoolParams, - V4CLPoolParams calldata v4MintParams, + V4CLPoolParams calldata v4PoolParams, // extra funds to be added uint256 extraAmount0, uint256 extraAmount1 @@ -31,7 +31,7 @@ interface ICLMigrator is IBaseMigrator { function migrateFromV3( V3PoolParams calldata v3PoolParams, - V4CLPoolParams calldata v4MintParams, + V4CLPoolParams calldata v4PoolParams, // extra funds to be added uint256 extraAmount0, uint256 extraAmount1 diff --git a/test/pool-cl/migrator/CLMigratorFromV3.sol b/test/pool-cl/migrator/CLMigratorFromV3.sol index c087744..5fa6900 100644 --- a/test/pool-cl/migrator/CLMigratorFromV3.sol +++ b/test/pool-cl/migrator/CLMigratorFromV3.sol @@ -448,7 +448,6 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, GasSnapshot { } function testMigrateFromV3AddExtraAmountThroughWETH() public { - // 1. mint some liquidity to the v2 pair // 1. mint some liquidity to the v3 pool _mintV3Liquidity(address(weth), address(token0)); assertEq(v3Nfpm.ownerOf(1), address(this)); @@ -487,7 +486,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, GasSnapshot { weth.approve(address(migrator), 20 ether); IERC20(address(token0)).approve(address(migrator), 20 ether); - // 4. migrate from v2 to v4, not sending ETH denotes pay by WETH + // 4. migrate from v3 to v4, not sending ETH denotes pay by WETH migrator.migrateFromV3(v3PoolParams, v4MintParams, 20 ether, 20 ether); // necessary checks @@ -664,7 +663,7 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, GasSnapshot { uint256 balance0Before = token0.balanceOf(address(this)); uint256 balance1Before = token1.balanceOf(address(this)); - // 4. migrate from v2 to v4 + // 4. migrate from v3 to v4 migrator.migrateFromV3(v3PoolParams, v4MintParams, 0, 0); // necessary checks @@ -675,7 +674,6 @@ abstract contract CLMigratorFromV3 is OldVersionHelper, GasSnapshot { // WETH balance unchanged assertEq(weth.balanceOf(address(this)), 100 ether); - // v2 pair should be burned already // v3 liqudity should be 0 (,,,,,,, uint128 liquidityFromV3After,,,,) = v3Nfpm.positions(1); assertEq(liquidityFromV3After, 0);