diff --git a/script/DeployUniversalRouter.s.sol b/script/DeployUniversalRouter.s.sol index a571afe..c4081ff 100644 --- a/script/DeployUniversalRouter.s.sol +++ b/script/DeployUniversalRouter.s.sol @@ -54,10 +54,7 @@ abstract contract DeployUniversalRouter is Script { stableInfo: mapUnsupported(params.stableInfo), infiVault: mapUnsupported(params.infiVault), infiClPoolManager: mapUnsupported(params.infiClPoolManager), - infiBinPoolManager: mapUnsupported(params.infiBinPoolManager), - v3NFTPositionManager: mapUnsupported(params.v3NFTPositionManager), - infiClPositionManager: mapUnsupported(params.infiClPositionManager), - infiBinPositionManager: mapUnsupported(params.infiBinPositionManager) + infiBinPoolManager: mapUnsupported(params.infiBinPoolManager) }); logParams(); @@ -95,9 +92,6 @@ abstract contract DeployUniversalRouter is Script { console2.log("infiVault:", params.infiVault); console2.log("infiClPoolManager:", params.infiClPoolManager); console2.log("infiBinPoolManager:", params.infiBinPoolManager); - console2.log("v3NFTPositionManager:", params.v3NFTPositionManager); - console2.log("infiClPositionManager:", params.infiClPositionManager); - console2.log("infiBinPositionManager:", params.infiBinPositionManager); } function mapUnsupported(address protocol) internal view returns (address) { diff --git a/script/deployParameters/mainnet/DeployArbitrum.s.sol b/script/deployParameters/mainnet/DeployArbitrum.s.sol index 700056d..542e169 100644 --- a/script/deployParameters/mainnet/DeployArbitrum.s.sol +++ b/script/deployParameters/mainnet/DeployArbitrum.s.sol @@ -31,10 +31,7 @@ contract DeployArbitrum is DeployUniversalRouter { stableInfo: UNSUPPORTED_PROTOCOL, infiVault: UNSUPPORTED_PROTOCOL, infiClPoolManager: UNSUPPORTED_PROTOCOL, - infiBinPoolManager: UNSUPPORTED_PROTOCOL, - v3NFTPositionManager: UNSUPPORTED_PROTOCOL, - infiClPositionManager: UNSUPPORTED_PROTOCOL, - infiBinPositionManager: UNSUPPORTED_PROTOCOL + infiBinPoolManager: UNSUPPORTED_PROTOCOL }); unsupported = 0x64D74e1EAAe3176744b5767b93B7Bee39Cf7898F; diff --git a/script/deployParameters/mainnet/DeployBase.s.sol b/script/deployParameters/mainnet/DeployBase.s.sol index 71aeaff..cfca3cd 100644 --- a/script/deployParameters/mainnet/DeployBase.s.sol +++ b/script/deployParameters/mainnet/DeployBase.s.sol @@ -31,10 +31,7 @@ contract DeployBase is DeployUniversalRouter { stableInfo: UNSUPPORTED_PROTOCOL, infiVault: 0x238a358808379702088667322f80aC48bAd5e6c4, infiClPoolManager: 0xa0FfB9c1CE1Fe56963B0321B32E7A0302114058b, - infiBinPoolManager: 0xC697d2898e0D09264376196696c51D7aBbbAA4a9, - v3NFTPositionManager: 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364, - infiClPositionManager: 0x55f4c8abA71A1e923edC303eb4fEfF14608cC226, - infiBinPositionManager: 0x3D311D6283Dd8aB90bb0031835C8e606349e2850 + infiBinPoolManager: 0xC697d2898e0D09264376196696c51D7aBbbAA4a9 }); unsupported = 0x64D74e1EAAe3176744b5767b93B7Bee39Cf7898F; diff --git a/script/deployParameters/mainnet/DeployBsc.s.sol b/script/deployParameters/mainnet/DeployBsc.s.sol index 71fe052..0a95885 100644 --- a/script/deployParameters/mainnet/DeployBsc.s.sol +++ b/script/deployParameters/mainnet/DeployBsc.s.sol @@ -31,10 +31,7 @@ contract DeployBsc is DeployUniversalRouter { stableInfo: 0xf3A6938945E68193271Cad8d6f79B1f878b16Eb1, infiVault: 0x238a358808379702088667322f80aC48bAd5e6c4, infiClPoolManager: 0xa0FfB9c1CE1Fe56963B0321B32E7A0302114058b, - infiBinPoolManager: 0xC697d2898e0D09264376196696c51D7aBbbAA4a9, - v3NFTPositionManager: 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364, - infiClPositionManager: 0x55f4c8abA71A1e923edC303eb4fEfF14608cC226, - infiBinPositionManager: 0x3D311D6283Dd8aB90bb0031835C8e606349e2850 + infiBinPoolManager: 0xC697d2898e0D09264376196696c51D7aBbbAA4a9 }); unsupported = 0x2979d1ea8f04C60423eb7735Cc3ed1BF74b565b8; diff --git a/script/deployParameters/mainnet/DeployEth.s.sol b/script/deployParameters/mainnet/DeployEth.s.sol index 7c4395b..4774fd2 100644 --- a/script/deployParameters/mainnet/DeployEth.s.sol +++ b/script/deployParameters/mainnet/DeployEth.s.sol @@ -31,10 +31,7 @@ contract DeployEth is DeployUniversalRouter { stableInfo: UNSUPPORTED_PROTOCOL, infiVault: UNSUPPORTED_PROTOCOL, infiClPoolManager: UNSUPPORTED_PROTOCOL, - infiBinPoolManager: UNSUPPORTED_PROTOCOL, - v3NFTPositionManager: UNSUPPORTED_PROTOCOL, - infiClPositionManager: UNSUPPORTED_PROTOCOL, - infiBinPositionManager: UNSUPPORTED_PROTOCOL + infiBinPoolManager: UNSUPPORTED_PROTOCOL }); unsupported = 0x5C19Add791a23C55be09fAB1db73bFd5fa80C2b0; diff --git a/script/deployParameters/mainnet/DeployLinea.s.sol b/script/deployParameters/mainnet/DeployLinea.s.sol index 53c22ff..9780510 100644 --- a/script/deployParameters/mainnet/DeployLinea.s.sol +++ b/script/deployParameters/mainnet/DeployLinea.s.sol @@ -31,10 +31,7 @@ contract DeployLinea is DeployUniversalRouter { stableInfo: UNSUPPORTED_PROTOCOL, infiVault: UNSUPPORTED_PROTOCOL, infiClPoolManager: UNSUPPORTED_PROTOCOL, - infiBinPoolManager: UNSUPPORTED_PROTOCOL, - v3NFTPositionManager: UNSUPPORTED_PROTOCOL, - infiClPositionManager: UNSUPPORTED_PROTOCOL, - infiBinPositionManager: UNSUPPORTED_PROTOCOL + infiBinPoolManager: UNSUPPORTED_PROTOCOL }); unsupported = 0x64D74e1EAAe3176744b5767b93B7Bee39Cf7898F; diff --git a/script/deployParameters/mainnet/DeployOpBnb.s.sol b/script/deployParameters/mainnet/DeployOpBnb.s.sol index f9dd0a9..71e8f89 100644 --- a/script/deployParameters/mainnet/DeployOpBnb.s.sol +++ b/script/deployParameters/mainnet/DeployOpBnb.s.sol @@ -32,10 +32,7 @@ contract DeployOpbnb is DeployUniversalRouter { stableInfo: UNSUPPORTED_PROTOCOL, infiVault: UNSUPPORTED_PROTOCOL, infiClPoolManager: UNSUPPORTED_PROTOCOL, - infiBinPoolManager: UNSUPPORTED_PROTOCOL, - v3NFTPositionManager: UNSUPPORTED_PROTOCOL, - infiClPositionManager: UNSUPPORTED_PROTOCOL, - infiBinPositionManager: UNSUPPORTED_PROTOCOL + infiBinPoolManager: UNSUPPORTED_PROTOCOL }); unsupported = 0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912; diff --git a/script/deployParameters/mainnet/DeployzkEvm.s.sol b/script/deployParameters/mainnet/DeployzkEvm.s.sol index 715f422..d6eeeb6 100644 --- a/script/deployParameters/mainnet/DeployzkEvm.s.sol +++ b/script/deployParameters/mainnet/DeployzkEvm.s.sol @@ -31,10 +31,7 @@ contract DeployZkEvm is DeployUniversalRouter { stableInfo: UNSUPPORTED_PROTOCOL, infiVault: UNSUPPORTED_PROTOCOL, infiClPoolManager: UNSUPPORTED_PROTOCOL, - infiBinPoolManager: UNSUPPORTED_PROTOCOL, - v3NFTPositionManager: UNSUPPORTED_PROTOCOL, - infiClPositionManager: UNSUPPORTED_PROTOCOL, - infiBinPositionManager: UNSUPPORTED_PROTOCOL + infiBinPoolManager: UNSUPPORTED_PROTOCOL }); unsupported = 0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912; diff --git a/script/deployParameters/testnet/DeployBscTestnet.s.sol b/script/deployParameters/testnet/DeployBscTestnet.s.sol index 11a373a..6af8610 100644 --- a/script/deployParameters/testnet/DeployBscTestnet.s.sol +++ b/script/deployParameters/testnet/DeployBscTestnet.s.sol @@ -32,10 +32,7 @@ contract DeployBscTestnet is DeployUniversalRouter { stableInfo: 0x0A548d59D04096Bc01206D58C3D63c478e1e06dB, infiVault: 0x2CdB3EC82EE13d341Dc6E73637BE0Eab79cb79dD, infiClPoolManager: 0x36A12c70c9Cf64f24E89ee132BF93Df2DCD199d4, - infiBinPoolManager: 0xe71d2e0230cE0765be53A8A1ee05bdACF30F296B, - v3NFTPositionManager: 0x427bF5b37357632377eCbEC9de3626C71A5396c1, - infiClPositionManager: 0x77DedB52EC6260daC4011313DBEE09616d30d122, - infiBinPositionManager: 0x68B834232da911c787bcF782CED84ec5d36909a7 + infiBinPoolManager: 0xe71d2e0230cE0765be53A8A1ee05bdACF30F296B }); unsupported = 0xe4da88F38C11C1450c720b8aDeDd94956610a4e5; diff --git a/script/deployParameters/testnet/DeployEthSepolia.s.sol b/script/deployParameters/testnet/DeployEthSepolia.s.sol index 45ad21d..91425c2 100644 --- a/script/deployParameters/testnet/DeployEthSepolia.s.sol +++ b/script/deployParameters/testnet/DeployEthSepolia.s.sol @@ -34,10 +34,7 @@ contract DeployEthSepolia is DeployUniversalRouter { stableInfo: UNSUPPORTED_PROTOCOL, infiVault: 0x4670F769Daa625FF5F89719AE5295E9824f5805f, infiClPoolManager: 0xD4EAc75ee0E76EAD6AC6995DF30CA14b38549682, - infiBinPoolManager: 0x0Ca8430E263A098B998E47e0544C2C82B30CbDB1, - v3NFTPositionManager: 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364, - infiClPositionManager: 0x53C9802F47295979c0E154779eD10fa6af27D7cA, - infiBinPositionManager: 0x21015eF9927e06b7Fc19D986A214e449Aa22FF7d + infiBinPoolManager: 0x0Ca8430E263A098B998E47e0544C2C82B30CbDB1 }); unsupported = 0x6879F5C1AdaDDF29892bf650F9C48350C12795D9; diff --git a/snapshots/BinNativePancakeSwapInfinityTest.json b/snapshots/BinNativePancakeSwapInfinityTest.json index d4f9548..a3c5045 100644 --- a/snapshots/BinNativePancakeSwapInfinityTest.json +++ b/snapshots/BinNativePancakeSwapInfinityTest.json @@ -1,6 +1,6 @@ { - "test_infiBinSwap_ExactInSingle_NativeIn": "128929", - "test_infiBinSwap_ExactInSingle_NativeOut": "117627", - "test_infiBinSwap_ExactInSingle_NativeOut_RouterRecipient": "117916", - "test_infiBinSwap_infiInitializeBinPool": "132846" + "test_infiBinSwap_ExactInSingle_NativeIn": "128863", + "test_infiBinSwap_ExactInSingle_NativeOut": "117561", + "test_infiBinSwap_ExactInSingle_NativeOut_RouterRecipient": "117850", + "test_infiBinSwap_infiInitializeBinPool": "132794" } \ No newline at end of file diff --git a/snapshots/BinPancakeSwapInfinityTest.json b/snapshots/BinPancakeSwapInfinityTest.json index 198c77c..ae78331 100644 --- a/snapshots/BinPancakeSwapInfinityTest.json +++ b/snapshots/BinPancakeSwapInfinityTest.json @@ -1,9 +1,9 @@ { - "test_infiBinSwap_ExactInSingle": "143529", - "test_infiBinSwap_ExactIn_MultiHop": "174923", - "test_infiBinSwap_ExactIn_SingleHop": "145327", - "test_infiBinSwap_ExactOutSingle": "147891", - "test_infiBinSwap_ExactOut_MultiHop": "178771", - "test_infiBinSwap_ExactOut_SingleHop": "149699", - "test_infiBinSwap_InitializeBinPool": "152986" + "test_infiBinSwap_ExactInSingle": "143463", + "test_infiBinSwap_ExactIn_MultiHop": "174857", + "test_infiBinSwap_ExactIn_SingleHop": "145261", + "test_infiBinSwap_ExactOutSingle": "147825", + "test_infiBinSwap_ExactOut_MultiHop": "178705", + "test_infiBinSwap_ExactOut_SingleHop": "149633", + "test_infiBinSwap_InitializeBinPool": "152934" } \ No newline at end of file diff --git a/snapshots/CLNativePancakeSwapInfinityTest.json b/snapshots/CLNativePancakeSwapInfinityTest.json index a30e2e8..c3d2b0b 100644 --- a/snapshots/CLNativePancakeSwapInfinityTest.json +++ b/snapshots/CLNativePancakeSwapInfinityTest.json @@ -1,5 +1,5 @@ { - "test_infiClSwap_ExactInSingle_NativeIn": "161970", - "test_infiClSwap_ExactInSingle_NativeOut": "144706", - "test_infiClSwap_infiInitializeClPool": "133628" + "test_infiClSwap_ExactInSingle_NativeIn": "161904", + "test_infiClSwap_ExactInSingle_NativeOut": "144640", + "test_infiClSwap_infiInitializeClPool": "133576" } \ No newline at end of file diff --git a/snapshots/CLPancakeSwapInfinityTest.json b/snapshots/CLPancakeSwapInfinityTest.json index 71b9b15..50ce37b 100644 --- a/snapshots/CLPancakeSwapInfinityTest.json +++ b/snapshots/CLPancakeSwapInfinityTest.json @@ -1,9 +1,9 @@ { - "test_infiClSwap_ExactInSingle": "176570", - "test_infiClSwap_ExactIn_MultiHop": "241016", - "test_infiClSwap_ExactIn_SingleHop": "178361", - "test_infiClSwap_ExactOutSingle": "180894", - "test_infiClSwap_ExactOut_MultiHop": "244792", - "test_infiClSwap_ExactOut_SingleHop": "182697", - "test_infiClSwap_infiInitializeClPool": "153756" + "test_infiClSwap_ExactInSingle": "176504", + "test_infiClSwap_ExactIn_MultiHop": "240950", + "test_infiClSwap_ExactIn_SingleHop": "178295", + "test_infiClSwap_ExactOutSingle": "180828", + "test_infiClSwap_ExactOut_MultiHop": "244726", + "test_infiClSwap_ExactOut_SingleHop": "182631", + "test_infiClSwap_infiInitializeClPool": "153704" } \ No newline at end of file diff --git a/snapshots/UniversalRouterTest.json b/snapshots/UniversalRouterTest.json index a1a4348..854268a 100644 --- a/snapshots/UniversalRouterTest.json +++ b/snapshots/UniversalRouterTest.json @@ -1,4 +1,4 @@ { - "UniversalRouterBytecodeSize": "24350", + "UniversalRouterBytecodeSize": "22521", "test_sweep_token": "55429" } \ No newline at end of file diff --git a/snapshots/V3BnbCake.json b/snapshots/V3BnbCake.json index f764c4d..74c33a8 100644 --- a/snapshots/V3BnbCake.json +++ b/snapshots/V3BnbCake.json @@ -1,7 +1,7 @@ { - "test_v3Swap_ExactInput0For1": "151904", - "test_v3Swap_ExactInput0For1_ContractBalance": "154811", - "test_v3Swap_exactInput_MultiHop": "243354", - "test_v3Swap_exactOutput0For1": "150606", - "test_v3Swap_exactOutput_MultiHop": "254284" + "test_v3Swap_ExactInput0For1": "151871", + "test_v3Swap_ExactInput0For1_ContractBalance": "154778", + "test_v3Swap_exactInput_MultiHop": "243288", + "test_v3Swap_exactOutput0For1": "150573", + "test_v3Swap_exactOutput_MultiHop": "254218" } \ No newline at end of file diff --git a/src/base/Dispatcher.sol b/src/base/Dispatcher.sol index 92e5f12..2cb1dac 100755 --- a/src/base/Dispatcher.sol +++ b/src/base/Dispatcher.sol @@ -7,7 +7,6 @@ import {InfinitySwapRouter} from "../modules/pancakeswap/infinity/InfinitySwapRo import {StableSwapRouter} from "../modules/pancakeswap/StableSwapRouter.sol"; import {Payments} from "../modules/Payments.sol"; import {RouterImmutables} from "../base/RouterImmutables.sol"; -import {V3ToInfinityMigrator} from "../modules/V3ToInfinityMigrator.sol"; import {BytesLib} from "../libraries/BytesLib.sol"; import {Commands} from "../libraries/Commands.sol"; import {Lock} from "./Lock.sol"; @@ -22,15 +21,7 @@ import {IBinPoolManager} from "infinity-core/src/pool-bin/interfaces/IBinPoolMan /// @title Decodes and Executes Commands /// @notice Called by the UniversalRouter contract to efficiently decode and execute a singular command -abstract contract Dispatcher is - Payments, - V2SwapRouter, - V3SwapRouter, - StableSwapRouter, - InfinitySwapRouter, - V3ToInfinityMigrator, - Lock -{ +abstract contract Dispatcher is Payments, V2SwapRouter, V3SwapRouter, StableSwapRouter, InfinitySwapRouter, Lock { using BytesLib for bytes; using CalldataDecoder for bytes; @@ -121,14 +112,15 @@ abstract contract Dispatcher is permitBatch := add(inputs.offset, calldataload(inputs.offset)) } bytes calldata data = inputs.toBytes(1); - (success, output) = address(PERMIT2).call( - abi.encodeWithSignature( - "permit(address,((address,uint160,uint48,uint48)[],address,uint256),bytes)", - msgSender(), - permitBatch, - data - ) - ); + (success, output) = address(PERMIT2) + .call( + abi.encodeWithSignature( + "permit(address,((address,uint160,uint48,uint48)[],address,uint256),bytes)", + msgSender(), + permitBatch, + data + ) + ); return (success, output); } else if (command == Commands.SWEEP) { // equivalent: abi.decode(inputs, (address, address, uint256)) @@ -213,14 +205,15 @@ abstract contract Dispatcher is permitSingle := inputs.offset } bytes calldata data = inputs.toBytes(6); // PermitSingle takes first 6 slots (0..5) - (success, output) = address(PERMIT2).call( - abi.encodeWithSignature( - "permit(address,((address,uint160,uint48,uint48),address,uint256),bytes)", - msgSender(), - permitSingle, - data - ) - ); + (success, output) = address(PERMIT2) + .call( + abi.encodeWithSignature( + "permit(address,((address,uint160,uint48,uint48),address,uint256),bytes)", + msgSender(), + permitSingle, + data + ) + ); return (success, output); } else if (command == Commands.WRAP_ETH) { // equivalent: abi.decode(inputs, (address, uint256)) @@ -275,16 +268,6 @@ abstract contract Dispatcher is // pass the calldata provided to InfinitySwapRouter._executeActions (defined in BaseActionsRouter) _executeActions(inputs); return (success, output); - // This contract MUST be approved to spend the token since its going to be doing the call on the position manager - } else if (command == Commands.V3_POSITION_MANAGER_PERMIT) { - _checkV3PermitCall(inputs); - (success, output) = address(V3_POSITION_MANAGER).call(inputs); - return (success, output); - } else if (command == Commands.V3_POSITION_MANAGER_CALL) { - _checkV3PositionManagerCall(inputs, msgSender()); - /// @dev ensure there's follow-up action if v3 position's removed token are sent to router contract - (success, output) = address(V3_POSITION_MANAGER).call(inputs); - return (success, output); } else if (command == Commands.INFI_CL_INITIALIZE_POOL) { // equivalent: abi.decode(inputs, (PoolKey, uint160)) where PoolKey is // (Currency currency0, Currency currency1, IHooks hooks, IPoolManager poolManager, uint24 fee, bytes32 parameters) @@ -307,14 +290,6 @@ abstract contract Dispatcher is } (success, output) = address(binPoolManager).call(abi.encodeCall(IBinPoolManager.initialize, (poolKey, activeId))); - } else if (command == Commands.INFI_CL_POSITION_CALL) { - _checkInfiClPositionManagerCall(inputs); - (success, output) = address(INFI_CL_POSITION_MANAGER).call{value: address(this).balance}(inputs); - return (success, output); - } else if (command == Commands.INFI_BIN_POSITION_CALL) { - _checkInfiBinPositionManagerCall(inputs); - (success, output) = address(INFI_BIN_POSITION_MANAGER).call{value: address(this).balance}(inputs); - return (success, output); } else { // placeholder area for commands 0x15-0x20 revert InvalidCommandType(command); diff --git a/src/base/RouterImmutables.sol b/src/base/RouterImmutables.sol index d0c4f0b..2b4cd19 100755 --- a/src/base/RouterImmutables.sol +++ b/src/base/RouterImmutables.sol @@ -2,9 +2,6 @@ pragma solidity ^0.8.0; import {IPermit2} from "permit2/src/interfaces/IPermit2.sol"; -import {IV3NonfungiblePositionManager} from - "infinity-periphery/src/interfaces/external/IV3NonfungiblePositionManager.sol"; -import {IPositionManager} from "infinity-periphery/src/interfaces/IPositionManager.sol"; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {IWETH9} from "infinity-periphery/src/interfaces/external/IWETH9.sol"; @@ -24,10 +21,6 @@ struct RouterParameters { address infiVault; address infiClPoolManager; address infiBinPoolManager; - // PCS v3->infinity migration parameters - address v3NFTPositionManager; - address infiClPositionManager; - address infiBinPositionManager; } /// @title Router Immutable Storage contract @@ -54,15 +47,6 @@ contract RouterImmutables { /// @dev The address of PancakeSwap V3 Deployer address internal immutable PANCAKESWAP_V3_DEPLOYER; - /// @dev v3PositionManager address - IV3NonfungiblePositionManager public immutable V3_POSITION_MANAGER; - - /// @dev infinity CLPositionManager address - IPositionManager public immutable INFI_CL_POSITION_MANAGER; - - /// @dev infinity BinPositionManager address - IPositionManager public immutable INFI_BIN_POSITION_MANAGER; - constructor(RouterParameters memory params) { PERMIT2 = IPermit2(params.permit2); WETH9 = IWETH9(params.weth9); @@ -71,8 +55,5 @@ contract RouterImmutables { PANCAKESWAP_V3_FACTORY = params.v3Factory; PANCAKESWAP_V3_POOL_INIT_CODE_HASH = params.v3InitCodeHash; PANCAKESWAP_V3_DEPLOYER = params.v3Deployer; - V3_POSITION_MANAGER = IV3NonfungiblePositionManager(params.v3NFTPositionManager); - INFI_CL_POSITION_MANAGER = IPositionManager(params.infiClPositionManager); - INFI_BIN_POSITION_MANAGER = IPositionManager(params.infiBinPositionManager); } } diff --git a/src/libraries/Commands.sol b/src/libraries/Commands.sol index aab2bd5..d0a4ec8 100755 --- a/src/libraries/Commands.sol +++ b/src/libraries/Commands.sol @@ -33,13 +33,10 @@ library Commands { // Command Types where 0x10<=value<=0x20, executed in the third nested-if block uint256 constant INFI_SWAP = 0x10; - uint256 constant V3_POSITION_MANAGER_PERMIT = 0x11; - uint256 constant V3_POSITION_MANAGER_CALL = 0x12; + // COMMAND_PLACEHOLDER = 0x11, 0x12 uint256 constant INFI_CL_INITIALIZE_POOL = 0x13; uint256 constant INFI_BIN_INITIALIZE_POOL = 0x14; - uint256 constant INFI_CL_POSITION_CALL = 0x15; - uint256 constant INFI_BIN_POSITION_CALL = 0x16; - // COMMAND_PLACEHOLDER = 0x17 -> 0x20 + // COMMAND_PLACEHOLDER = 0x15 -> 0x20 // Command Types where 0x21<=value<=0x3f uint256 constant EXECUTE_SUB_PLAN = 0x21; diff --git a/src/modules/V3ToInfinityMigrator.sol b/src/modules/V3ToInfinityMigrator.sol deleted file mode 100644 index 577f606..0000000 --- a/src/modules/V3ToInfinityMigrator.sol +++ /dev/null @@ -1,137 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -// Copyright (C) 2024 PancakeSwap -pragma solidity ^0.8.0; - -import {RouterImmutables} from "../base/RouterImmutables.sol"; -import {IV3NonfungiblePositionManager} from - "infinity-periphery/src/interfaces/external/IV3NonfungiblePositionManager.sol"; -import {Actions} from "infinity-periphery/src/libraries/Actions.sol"; -import {CalldataDecoder} from "infinity-periphery/src/libraries/CalldataDecoder.sol"; -import {IPositionManager} from "infinity-periphery/src/interfaces/IPositionManager.sol"; -import {IERC721Permit} from "infinity-periphery/src/interfaces/IERC721Permit.sol"; - -/// @title V3 to Infinity Migrator -/// @notice A contract that migrates liquidity from PancakeSwap V3 to Infinity -abstract contract V3ToInfinityMigrator is RouterImmutables { - using CalldataDecoder for bytes; - - error NotAuthorizedForToken(uint256 tokenId); - error InvalidAction(bytes4 action); - error OnlyMintAllowed(); - error OnlyAddLiqudityAllowed(); - - /// @dev validate if an action is decreaseLiquidity, collect, or burn - function _isValidAction(bytes4 selector) private pure returns (bool) { - return selector == IV3NonfungiblePositionManager.decreaseLiquidity.selector - || selector == IV3NonfungiblePositionManager.collect.selector - || selector == IV3NonfungiblePositionManager.burn.selector; - } - - /// @dev the caller is authorized for the token if its the owner, spender, or operator - function _isAuthorizedForToken(address caller, uint256 tokenId) private view returns (bool) { - address owner = V3_POSITION_MANAGER.ownerOf(tokenId); - return caller == owner || V3_POSITION_MANAGER.getApproved(tokenId) == caller - || V3_POSITION_MANAGER.isApprovedForAll(owner, caller); - } - - /// @dev check that a call is to the ERC721 permit function - function _checkV3PermitCall(bytes calldata inputs) internal pure { - bytes4 selector; - assembly { - selector := calldataload(inputs.offset) - } - - if (selector != IERC721Permit.permit.selector) { - revert InvalidAction(selector); - } - } - - /// @dev check that the v3 position manager call is a safe call - function _checkV3PositionManagerCall(bytes calldata inputs, address caller) internal view { - bytes4 selector; - assembly { - selector := calldataload(inputs.offset) - } - - if (!_isValidAction(selector)) { - revert InvalidAction(selector); - } - - uint256 tokenId; - assembly { - // tokenId is always the first parameter in the valid actions - tokenId := calldataload(add(inputs.offset, 0x04)) - } - // If any other address that is not the owner wants to call this function, it also needs to be approved (in addition to this contract) - // This can be done in 2 ways: - // 1. This contract is permitted for the specific token and the caller is approved for ALL of the owner's tokens - // 2. This contract is permitted for ALL of the owner's tokens and the caller is permitted for the specific token - if (!_isAuthorizedForToken(caller, tokenId)) { - revert NotAuthorizedForToken(tokenId); - } - } - - /// @dev check that the infinity cl position manager call is a safe call - /// of the position-altering Actions, we only allow Actions.MINT - /// this is because, if a user could be tricked into approving the UniversalRouter for - /// their position, an attacker could take their fees, or drain their entire position - function _checkInfiClPositionManagerCall(bytes calldata inputs) internal view { - bytes4 selector; - assembly { - selector := calldataload(inputs.offset) - } - if (selector != INFI_CL_POSITION_MANAGER.modifyLiquidities.selector) { - revert InvalidAction(selector); - } - - // slice is `abi.encode(bytes unlockData, uint256 deadline)` - bytes calldata slice = inputs[4:]; - // the first bytes(0) extracts the unlockData parameter from modifyLiquidities - // unlockData = `abi.encode(bytes actions, bytes[] params)` - // the second bytes(0) extracts the actions parameter from unlockData - bytes calldata actions = slice.toBytes(0).toBytes(0); - - uint256 numActions = actions.length; - - for (uint256 actionIndex = 0; actionIndex < numActions; actionIndex++) { - uint256 action = uint8(actions[actionIndex]); - - if ( - action == Actions.CL_INCREASE_LIQUIDITY || action == Actions.CL_DECREASE_LIQUIDITY - || action == Actions.CL_BURN_POSITION - ) { - revert OnlyMintAllowed(); - } - } - } - - /// @dev check that the infinity bin position manager call is a safe call - /// of the position-altering Actions, we only allow Actions.BIN_ADD_LIQUIDITY - /// this is because, if a user could be tricked into approving the UniversalRouter for - /// their position, an attacker could drain their entire position - function _checkInfiBinPositionManagerCall(bytes calldata inputs) internal view { - bytes4 selector; - assembly { - selector := calldataload(inputs.offset) - } - if (selector != INFI_BIN_POSITION_MANAGER.modifyLiquidities.selector) { - revert InvalidAction(selector); - } - - // slice is `abi.encode(bytes unlockData, uint256 deadline)` - bytes calldata slice = inputs[4:]; - // the first bytes(0) extracts the unlockData parameter from modifyLiquidities - // unlockData = `abi.encode(bytes actions, bytes[] params)` - // the second bytes(0) extracts the actions parameter from unlockData - bytes calldata actions = slice.toBytes(0).toBytes(0); - - uint256 numActions = actions.length; - - for (uint256 actionIndex = 0; actionIndex < numActions; actionIndex++) { - uint256 action = uint8(actions[actionIndex]); - if (action == Actions.BIN_REMOVE_LIQUIDITY) { - revert OnlyAddLiqudityAllowed(); - } - } - } -} diff --git a/src/modules/pancakeswap/v2/V2SwapRouter.sol b/src/modules/pancakeswap/v2/V2SwapRouter.sol index f3d67f9..0f3b994 100755 --- a/src/modules/pancakeswap/v2/V2SwapRouter.sol +++ b/src/modules/pancakeswap/v2/V2SwapRouter.sol @@ -57,8 +57,9 @@ abstract contract V2SwapRouter is RouterImmutables, Permit2Payments { address[] calldata path, address payer ) internal { - address firstPair = - UniversalRouterHelper.pairFor(PANCAKESWAP_V2_FACTORY, PANCAKESWAP_V2_PAIR_INIT_CODE_HASH, path[0], path[1]); + address firstPair = UniversalRouterHelper.pairFor( + PANCAKESWAP_V2_FACTORY, PANCAKESWAP_V2_PAIR_INIT_CODE_HASH, path[0], path[1] + ); if ( amountIn != Constants.ALREADY_PAID // amountIn of 0 to signal that the pair already has the tokens ) { diff --git a/src/modules/pancakeswap/v3/V3SwapRouter.sol b/src/modules/pancakeswap/v3/V3SwapRouter.sol index afb445d..3d6765f 100755 --- a/src/modules/pancakeswap/v3/V3SwapRouter.sol +++ b/src/modules/pancakeswap/v3/V3SwapRouter.sol @@ -44,8 +44,8 @@ abstract contract V3SwapRouter is RouterImmutables, Permit2Payments, IPancakeV3S if ( UniversalRouterHelper.computePoolAddress( - PANCAKESWAP_V3_DEPLOYER, PANCAKESWAP_V3_POOL_INIT_CODE_HASH, tokenIn, tokenOut, fee - ) != msg.sender + PANCAKESWAP_V3_DEPLOYER, PANCAKESWAP_V3_POOL_INIT_CODE_HASH, tokenIn, tokenOut, fee + ) != msg.sender ) revert V3InvalidCaller(); (bool isExactInput, uint256 amountToPay) = @@ -150,15 +150,16 @@ abstract contract V3SwapRouter is RouterImmutables, Permit2Payments, IPancakeV3S zeroForOne = isExactIn ? tokenIn < tokenOut : tokenOut < tokenIn; (amount0Delta, amount1Delta) = IPancakeV3Pool( - UniversalRouterHelper.computePoolAddress( - PANCAKESWAP_V3_DEPLOYER, PANCAKESWAP_V3_POOL_INIT_CODE_HASH, tokenIn, tokenOut, fee + UniversalRouterHelper.computePoolAddress( + PANCAKESWAP_V3_DEPLOYER, PANCAKESWAP_V3_POOL_INIT_CODE_HASH, tokenIn, tokenOut, fee + ) ) - ).swap( - recipient, - zeroForOne, - amount, - (zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1), - abi.encode(path, payer) - ); + .swap( + recipient, + zeroForOne, + amount, + (zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1), + abi.encode(path, payer) + ); } } diff --git a/src/modules/pancakeswap/v3/interfaces/pool/IPancakeV3PoolActions.sol b/src/modules/pancakeswap/v3/interfaces/pool/IPancakeV3PoolActions.sol index 809a137..c52fa74 100644 --- a/src/modules/pancakeswap/v3/interfaces/pool/IPancakeV3PoolActions.sol +++ b/src/modules/pancakeswap/v3/interfaces/pool/IPancakeV3PoolActions.sol @@ -52,9 +52,7 @@ interface IPancakeV3PoolActions { /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient - function burn(int24 tickLower, int24 tickUpper, uint128 amount) - external - returns (uint256 amount0, uint256 amount1); + function burn(int24 tickLower, int24 tickUpper, uint128 amount) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IPancakeV3SwapCallback#pancakeV3SwapCallback diff --git a/test/UniversalRouter.crossVersion.t.sol b/test/UniversalRouter.crossVersion.t.sol index a714dd1..0d70a89 100644 --- a/test/UniversalRouter.crossVersion.t.sol +++ b/test/UniversalRouter.crossVersion.t.sol @@ -25,8 +25,9 @@ import {CLPositionDescriptorOffChain} from "infinity-periphery/src/pool-cl/CLPos import {CLPositionManager} from "infinity-periphery/src/pool-cl/CLPositionManager.sol"; import {BinPositionManager} from "infinity-periphery/src/pool-bin/BinPositionManager.sol"; import {Actions} from "infinity-periphery/src/libraries/Actions.sol"; -import {IV3NonfungiblePositionManager} from - "infinity-periphery/src/interfaces/external/IV3NonfungiblePositionManager.sol"; +import { + IV3NonfungiblePositionManager +} from "infinity-periphery/src/interfaces/external/IV3NonfungiblePositionManager.sol"; import {IERC721Permit} from "infinity-periphery/src/interfaces/IERC721Permit.sol"; import {IPositionManager} from "infinity-periphery/src/interfaces/IPositionManager.sol"; import {IBinPositionManager} from "infinity-periphery/src/pool-bin/interfaces/IBinPositionManager.sol"; @@ -133,10 +134,7 @@ contract UniversalRouterCrossVersionTest is BasePancakeSwapInfinity, OldVersionH stableInfo: address(0), infiVault: address(vault), infiClPoolManager: address(clPoolManager), - infiBinPoolManager: address(binPoolManager), - v3NFTPositionManager: address(v3Nfpm), - infiClPositionManager: address(clPositionManager), - infiBinPositionManager: address(binPositionManager) + infiBinPoolManager: address(binPoolManager) }); router = new UniversalRouter(params); _approvePermit2ForCurrency(address(this), currency0, address(router), permit2); @@ -516,18 +514,12 @@ contract UniversalRouterCrossVersionTest is BasePancakeSwapInfinity, OldVersionH // prep position manager action to mint liquidity Plan memory planner = Planner.init(); planner.add(Actions.CL_MINT_POSITION, abi.encode(key, -120, 120, 1000 ether, 10 ether, 10 ether, recipient, "")); - planner.add(Actions.SETTLE, abi.encode(key.currency0, ActionConstants.OPEN_DELTA, false)); // deduct from universal router - planner.add(Actions.SETTLE, abi.encode(key.currency1, ActionConstants.OPEN_DELTA, false)); // deduct from universal router + planner.add(Actions.SETTLE, abi.encode(key.currency0, ActionConstants.OPEN_DELTA, false)); // pay from position manager balance + planner.add(Actions.SETTLE, abi.encode(key.currency1, ActionConstants.OPEN_DELTA, false)); // pay from position manager balance planner.add(Actions.SWEEP, abi.encode(key.currency0, recipient)); planner.add(Actions.SWEEP, abi.encode(key.currency1, recipient)); - // prep universal router actions - bytes memory commands = abi.encodePacked(bytes1(uint8(Commands.INFI_CL_POSITION_CALL))); - bytes[] memory inputs = new bytes[](1); - inputs[0] = - abi.encodePacked(IPositionManager.modifyLiquidities.selector, abi.encode(planner.encode(), block.timestamp)); - - router.execute(commands, inputs); + clPositionManager.modifyLiquidities(planner.encode(), block.timestamp); } function _deal(address token, address to, uint256 amount) internal { diff --git a/test/UniversalRouter.t.sol b/test/UniversalRouter.t.sol index e5db4fd..67eeb29 100644 --- a/test/UniversalRouter.t.sol +++ b/test/UniversalRouter.t.sol @@ -58,10 +58,7 @@ contract UniversalRouterTest is Test, Permit2SignatureHelpers, DeployPermit2 { stableInfo: address(0), infiVault: address(0), infiClPoolManager: address(0), - infiBinPoolManager: address(0), - v3NFTPositionManager: address(0), - infiClPositionManager: address(0), - infiBinPositionManager: address(0) + infiBinPoolManager: address(0) }); router = new UniversalRouter(params); assertEq(router.owner(), address(this)); diff --git a/test/V3ToInfinityMigration.t.sol b/test/V3ToInfinityMigration.t.sol deleted file mode 100644 index d4810f1..0000000 --- a/test/V3ToInfinityMigration.t.sol +++ /dev/null @@ -1,481 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.15; - -import {Test, console} from "forge-std/Test.sol"; -import {IAllowanceTransfer} from "permit2/src/interfaces/IAllowanceTransfer.sol"; -import {IWETH9} from "infinity-periphery/src/interfaces/external/IWETH9.sol"; -import {WETH} from "solmate/src/tokens/WETH.sol"; -import {MockERC20} from "solmate/src/test/utils/mocks/MockERC20.sol"; - -import {PoolKey} from "infinity-core/src/types/PoolKey.sol"; -import {Currency} from "infinity-core/src/types/Currency.sol"; -import {IVault} from "infinity-core/src/interfaces/IVault.sol"; -import {Vault} from "infinity-core/src/Vault.sol"; -import {CLPoolManager} from "infinity-core/src/pool-cl/CLPoolManager.sol"; -import {ICLPoolManager} from "infinity-core/src/pool-cl/interfaces/ICLPoolManager.sol"; -import {BinPoolManager} from "infinity-core/src/pool-bin/BinPoolManager.sol"; -import {IBinPoolManager} from "infinity-core/src/pool-bin/interfaces/IBinPoolManager.sol"; -import {FixedPoint96} from "infinity-core/src/pool-cl/libraries/FixedPoint96.sol"; -import {IHooks} from "infinity-core/src/interfaces/IHooks.sol"; -import {CLPoolParametersHelper} from "infinity-core/src/pool-cl/libraries/CLPoolParametersHelper.sol"; -import {BinPoolParametersHelper} from "infinity-core/src/pool-bin/libraries/BinPoolParametersHelper.sol"; -import {ActionConstants} from "infinity-periphery/src/libraries/ActionConstants.sol"; -import {Plan, Planner} from "infinity-periphery/src/libraries/Planner.sol"; -import {CLPositionManager} from "infinity-periphery/src/pool-cl/CLPositionManager.sol"; -import {CLPositionDescriptorOffChain} from "infinity-periphery/src/pool-cl/CLPositionDescriptorOffChain.sol"; -import {BinPositionManager} from "infinity-periphery/src/pool-bin/BinPositionManager.sol"; -import {Actions} from "infinity-periphery/src/libraries/Actions.sol"; -import {IV3NonfungiblePositionManager} from - "infinity-periphery/src/interfaces/external/IV3NonfungiblePositionManager.sol"; -import {IERC721Permit} from "infinity-periphery/src/interfaces/IERC721Permit.sol"; -import {IPositionManager} from "infinity-periphery/src/interfaces/IPositionManager.sol"; -import {IBinPositionManager} from "infinity-periphery/src/pool-bin/interfaces/IBinPositionManager.sol"; -import {OldVersionHelper} from "infinity-periphery/test/helpers/OldVersionHelper.sol"; -import {BinLiquidityHelper} from "infinity-periphery/test/pool-bin/helper/BinLiquidityHelper.sol"; - -import {IPancakeV3PoolDeployer} from "../src/modules/pancakeswap/v3/interfaces/IPancakeV3PoolDeployer.sol"; -import {IPancakeV3Factory} from "../src/modules/pancakeswap/v3/interfaces/IPancakeV3Factory.sol"; -import {V3ToInfinityMigrator} from "../src/modules/V3ToInfinityMigrator.sol"; -import {IUniversalRouter} from "../src/interfaces/IUniversalRouter.sol"; -import {Commands} from "../src/libraries/Commands.sol"; -import {RouterParameters} from "../src/base/RouterImmutables.sol"; -import {Dispatcher} from "../src/base/Dispatcher.sol"; -import {UniversalRouter} from "../src/UniversalRouter.sol"; -import {BasePancakeSwapInfinity} from "./infinity/BasePancakeSwapInfinity.sol"; - -interface IPancakeV3LikePairFactory { - function createPool(address tokenA, address tokenB, uint24 fee) external returns (address pool); -} - -contract V3ToInfinityMigrationTest is BasePancakeSwapInfinity, OldVersionHelper, BinLiquidityHelper { - using BinPoolParametersHelper for bytes32; - using CLPoolParametersHelper for bytes32; - using Planner for Plan; - - MockERC20 token0; - MockERC20 token1; - WETH weth = new WETH(); - - // v3 related - IV3NonfungiblePositionManager v3Nfpm; - address alice; - uint256 alicePK; - uint256 v3TokenId; - - // infinity related - IVault vault; - IBinPoolManager binPoolManager; - BinPositionManager binPositionManager; - ICLPoolManager clPoolManager; - CLPositionManager clPositionManager; - IAllowanceTransfer permit2; - UniversalRouter router; - PoolKey clPoolKey; - PoolKey binPoolKey; - - uint24 constant ACTIVE_ID_1_1 = 2 ** 23; // where token0 and token1 price is the same - uint160 constant SQRT_PRICE_1_1 = uint160(1 * FixedPoint96.Q96); // price 1 - - function setUp() public { - (alice, alicePK) = makeAddrAndKey("ALICE"); - - initializeTokens(); - vm.label(Currency.unwrap(currency0), "token0"); - vm.label(Currency.unwrap(currency1), "token1"); - token0 = MockERC20(Currency.unwrap(currency0)); - token1 = MockERC20(Currency.unwrap(currency1)); - - permit2 = IAllowanceTransfer(deployPermit2()); - - /////////////////////////////////// - //////////// v3 setup ///////////// - /////////////////////////////////// - address deployer = createContractThroughBytecode(_getDeployerBytecodePath()); - IPancakeV3LikePairFactory v3Factory = IPancakeV3LikePairFactory( - createContractThroughBytecode(_getFactoryBytecodePath(), toBytes32(address(deployer))) - ); - (bool success,) = deployer.call(abi.encodeWithSignature("setFactoryAddress(address)", address(v3Factory))); - require(success, "setFactoryAddress failed"); - v3Nfpm = IV3NonfungiblePositionManager( - createContractThroughBytecode( - _getNfpmBytecodePath(), toBytes32(deployer), toBytes32(address(v3Factory)), toBytes32(address(weth)), 0 - ) - ); - - // Get alice to mint some v3 liqudiity to migrate later - token0.mint(alice, 10 ether); - token1.mint(alice, 10 ether); - vm.startPrank(alice); - token0.approve(address(v3Nfpm), type(uint256).max); - token1.approve(address(v3Nfpm), type(uint256).max); - v3TokenId = _mintV3Liquidity(address(token0), address(token1), alice); - vm.stopPrank(); - - /////////////////////////////////// - ////////// infinity setup ///////// - /////////////////////////////////// - vault = IVault(new Vault()); - binPoolManager = new BinPoolManager(vault); - clPoolManager = new CLPoolManager(vault); - vault.registerApp(address(binPoolManager)); - vault.registerApp(address(clPoolManager)); - - binPositionManager = new BinPositionManager(vault, binPoolManager, permit2, IWETH9(address(weth))); - _approvePermit2ForCurrency(address(this), currency0, address(binPositionManager), permit2); - _approvePermit2ForCurrency(address(this), currency1, address(binPositionManager), permit2); - - CLPositionDescriptorOffChain pd = - new CLPositionDescriptorOffChain("https://pancakeswap.finance/infinity/pool-cl/positions/"); - clPositionManager = new CLPositionManager(vault, clPoolManager, permit2, 100_000, pd, IWETH9(address(weth))); - _approvePermit2ForCurrency(address(this), currency0, address(clPositionManager), permit2); - _approvePermit2ForCurrency(address(this), currency1, address(clPositionManager), permit2); - - clPoolKey = PoolKey({ - currency0: currency0, - currency1: currency1, - hooks: IHooks(address(0)), - poolManager: clPoolManager, - fee: uint24(3000), - parameters: bytes32(0).setTickSpacing(10) - }); - clPoolManager.initialize(clPoolKey, SQRT_PRICE_1_1); - - binPoolKey = PoolKey({ - currency0: currency0, - currency1: currency1, - hooks: IHooks(address(0)), - poolManager: binPoolManager, - fee: uint24(3000), - parameters: bytes32(0).setBinStep(10) - }); - binPoolManager.initialize(binPoolKey, ACTIVE_ID_1_1); - - /////////////////////////////////// - //////////// Router setup ///////////// - /////////////////////////////////// - RouterParameters memory params = RouterParameters({ - permit2: address(permit2), - weth9: address(weth), - v2Factory: address(0), - v3Factory: address(0), - v3Deployer: address(0), - v2InitCodeHash: bytes32(0), - v3InitCodeHash: bytes32(0), - stableFactory: address(0), - stableInfo: address(0), - infiVault: address(vault), - infiClPoolManager: address(clPoolManager), - infiBinPoolManager: address(binPoolManager), - v3NFTPositionManager: address(v3Nfpm), - infiClPositionManager: address(clPositionManager), - infiBinPositionManager: address(binPositionManager) - }); - router = new UniversalRouter(params); - _approvePermit2ForCurrency(alice, currency0, address(router), permit2); - _approvePermit2ForCurrency(alice, currency1, address(router), permit2); - } - - function test_v3PositionManager_onlyAuthorizedForToken() public { - //valid action: decreaseLiquidity, collect, burn - IV3NonfungiblePositionManager.CollectParams memory params = IV3NonfungiblePositionManager.CollectParams({ - tokenId: v3TokenId, - recipient: address(this), - amount0Max: type(uint128).max, - amount1Max: type(uint128).max - }); - - bytes memory commands = abi.encodePacked(bytes1(uint8(Commands.V3_POSITION_MANAGER_CALL))); - bytes[] memory inputs = new bytes[](1); - inputs[0] = abi.encodePacked(IV3NonfungiblePositionManager.collect.selector, abi.encode(params)); - - vm.expectRevert(abi.encodeWithSelector(V3ToInfinityMigrator.NotAuthorizedForToken.selector, params.tokenId)); - router.execute(commands, inputs); - } - - function test_v3PositionManager_invalidAction() public { - IV3NonfungiblePositionManager.MintParams memory params = IV3NonfungiblePositionManager.MintParams({ - token0: address(token0), - token1: address(token1), - fee: 500, - tickLower: -100, - tickUpper: 100, - amount0Desired: 1 ether, - amount1Desired: 1 ether, - amount0Min: 0, - amount1Min: 0, - recipient: address(this), - deadline: block.timestamp - }); - - bytes memory commands = abi.encodePacked(bytes1(uint8(Commands.V3_POSITION_MANAGER_CALL))); - bytes[] memory inputs = new bytes[](1); - inputs[0] = abi.encodePacked(IV3NonfungiblePositionManager.mint.selector, abi.encode(params)); - - vm.expectRevert( - abi.encodeWithSelector( - V3ToInfinityMigrator.InvalidAction.selector, IV3NonfungiblePositionManager.mint.selector - ) - ); - router.execute(commands, inputs); - } - - function test_v3PositionManager_erc721Permit() public { - vm.startPrank(alice); - - (uint8 v, bytes32 r, bytes32 s) = _getErc721PermitSignature(address(router), v3TokenId, block.timestamp); - bytes memory commands = abi.encodePacked(bytes1(uint8(Commands.V3_POSITION_MANAGER_PERMIT))); - bytes[] memory inputs = new bytes[](1); - inputs[0] = abi.encodePacked( - IERC721Permit.permit.selector, abi.encode(address(router), v3TokenId, block.timestamp, v, r, s) - ); - - router.execute(commands, inputs); - - assertEq(v3Nfpm.getApproved(v3TokenId), address(router)); - } - - /// @dev simulate permit -> decrease -> collect (token0/token1 to universal router) -> burn - function test_v3PositionManager_burn() public { - vm.startPrank(alice); - - // before: verify token0/token1 balance in router - assertEq(token0.balanceOf(address(router)), 0); - assertEq(token1.balanceOf(address(router)), 0); - - // build up the params for (permit -> decrease -> collect) - (,,,,,,, uint128 liqudiity,,,,) = v3Nfpm.positions(v3TokenId); - (uint8 v, bytes32 r, bytes32 s) = _getErc721PermitSignature(address(router), v3TokenId, block.timestamp); - IV3NonfungiblePositionManager.DecreaseLiquidityParams memory decreaseParams = IV3NonfungiblePositionManager - .DecreaseLiquidityParams({ - tokenId: v3TokenId, - liquidity: liqudiity, - amount0Min: 0, - amount1Min: 0, - deadline: block.timestamp - }); - IV3NonfungiblePositionManager.CollectParams memory collectParam = IV3NonfungiblePositionManager.CollectParams({ - tokenId: v3TokenId, - recipient: address(router), - amount0Max: type(uint128).max, - amount1Max: type(uint128).max - }); - - // build up univeral router commands - bytes memory commands = abi.encodePacked( - bytes1(uint8(Commands.V3_POSITION_MANAGER_PERMIT)), - bytes1(uint8(Commands.V3_POSITION_MANAGER_CALL)), // decrease - bytes1(uint8(Commands.V3_POSITION_MANAGER_CALL)), // collect - bytes1(uint8(Commands.V3_POSITION_MANAGER_CALL)) // burn - ); - - bytes[] memory inputs = new bytes[](4); - inputs[0] = abi.encodePacked( - IERC721Permit.permit.selector, abi.encode(address(router), v3TokenId, block.timestamp, v, r, s) - ); - inputs[1] = - abi.encodePacked(IV3NonfungiblePositionManager.decreaseLiquidity.selector, abi.encode(decreaseParams)); - inputs[2] = abi.encodePacked(IV3NonfungiblePositionManager.collect.selector, abi.encode(collectParam)); - inputs[3] = abi.encodePacked(IV3NonfungiblePositionManager.burn.selector, abi.encode(v3TokenId)); - - router.execute(commands, inputs); - vm.snapshotGasLastCall("test_v3PositionManager_burn"); - - // after: verify token0/token1 balance in router - assertEq(token0.balanceOf(address(router)), 9999999999999999999); - assertEq(token1.balanceOf(address(router)), 9999999999999999999); - } - - function test_infiCLPositionmanger_InvalidAction() public { - Plan memory planner = Planner.init(); - - // prep universal router actions - bytes memory commands = abi.encodePacked(bytes1(uint8(Commands.INFI_CL_POSITION_CALL))); - bytes[] memory inputs = new bytes[](1); - - bytes4 invalidSelector = IPositionManager.modifyLiquiditiesWithoutLock.selector; - inputs[0] = abi.encodePacked(invalidSelector, abi.encode(planner.encode(), block.timestamp)); - vm.expectRevert(abi.encodeWithSelector(V3ToInfinityMigrator.InvalidAction.selector, invalidSelector)); - router.execute(commands, inputs); - } - - function test_infiCLPositionmanger_BlacklistedAction() public { - Plan memory planner = Planner.init(); - bytes memory commands = abi.encodePacked(bytes1(uint8(Commands.INFI_CL_POSITION_CALL))); - bytes[] memory inputs = new bytes[](1); - - uint256[] memory invalidActions = new uint256[](3); - invalidActions[0] = Actions.CL_INCREASE_LIQUIDITY; - invalidActions[1] = Actions.CL_DECREASE_LIQUIDITY; - invalidActions[2] = Actions.CL_BURN_POSITION; - - for (uint256 i; i < invalidActions.length; i++) { - planner.add(invalidActions[i], ""); - inputs[0] = abi.encodePacked( - IPositionManager.modifyLiquidities.selector, abi.encode(planner.encode(), block.timestamp) - ); - - // verify revert for invalid actions - vm.expectRevert(V3ToInfinityMigrator.OnlyMintAllowed.selector); - router.execute(commands, inputs); - } - } - - function test_infiBinPositionmanger_InvalidAction() public { - Plan memory planner = Planner.init(); - - // prep universal router actions - bytes memory commands = abi.encodePacked(bytes1(uint8(Commands.INFI_BIN_POSITION_CALL))); - bytes[] memory inputs = new bytes[](1); - - bytes4 invalidSelector = IPositionManager.modifyLiquiditiesWithoutLock.selector; - inputs[0] = abi.encodePacked(invalidSelector, abi.encode(planner.encode(), block.timestamp)); - vm.expectRevert(abi.encodeWithSelector(V3ToInfinityMigrator.InvalidAction.selector, invalidSelector)); - router.execute(commands, inputs); - } - - function test_infiBinPositionmanger_BlacklistedAction() public { - Plan memory planner = Planner.init(); - bytes memory commands = abi.encodePacked(bytes1(uint8(Commands.INFI_BIN_POSITION_CALL))); - bytes[] memory inputs = new bytes[](1); - - uint256[] memory invalidActions = new uint256[](1); - invalidActions[0] = Actions.BIN_REMOVE_LIQUIDITY; - - for (uint256 i; i < invalidActions.length; i++) { - planner.add(invalidActions[i], ""); - inputs[0] = abi.encodePacked( - IPositionManager.modifyLiquidities.selector, abi.encode(planner.encode(), block.timestamp) - ); - - // verify revert for invalid actions - vm.expectRevert(V3ToInfinityMigrator.OnlyAddLiqudityAllowed.selector); - router.execute(commands, inputs); - } - } - - /// @dev Assume token0/token1 is aready in universal router from earlier steps on v3 - /// then add liquidity to infinity cl and sweep remaining token - function test_infiCLPositionmanager_Mint() public { - // assume token0/token1 is in universal router - token0.mint(address(router), 10 ether); - token1.mint(address(router), 10 ether); - - // prep position manager action: mint/ settle/ settle - Plan memory planner = Planner.init(); - planner.add(Actions.CL_MINT_POSITION, abi.encode(clPoolKey, -120, 120, 1 ether, 10 ether, 10 ether, alice, "")); - planner.add(Actions.SETTLE, abi.encode(clPoolKey.currency0, ActionConstants.OPEN_DELTA, false)); // deduct from universal router - planner.add(Actions.SETTLE, abi.encode(clPoolKey.currency1, ActionConstants.OPEN_DELTA, false)); // deduct from universal router - planner.add(Actions.SWEEP, abi.encode(clPoolKey.currency0, alice)); - planner.add(Actions.SWEEP, abi.encode(clPoolKey.currency1, alice)); - - // prep universal router actions - bytes memory commands = abi.encodePacked( - bytes1(uint8(Commands.SWEEP)), bytes1(uint8(Commands.SWEEP)), bytes1(uint8(Commands.INFI_CL_POSITION_CALL)) - ); - bytes[] memory inputs = new bytes[](3); - inputs[0] = abi.encode(token0, address(clPositionManager), 0); // send token to clPositionmanager - inputs[1] = abi.encode(token1, address(clPositionManager), 0); // send token to clPositionmanager - inputs[2] = - abi.encodePacked(IPositionManager.modifyLiquidities.selector, abi.encode(planner.encode(), block.timestamp)); - - vm.prank(alice); - router.execute(commands, inputs); - vm.snapshotGasLastCall("test_infiCLPositionmanager_Mint"); - - // verify balance sent back to alice - assertEq(token0.balanceOf(address(alice)), 9994018262239490337); - assertEq(token1.balanceOf(address(alice)), 9994018262239490337); - assertEq(clPositionManager.ownerOf(1), alice); - } - - /// @dev Assume token0/token1 is aready in universal router from earlier steps on v3 - /// then add liquidity to infinity cl and sweep remaining token - function test_infiBinPositionmanager_BinAddLiquidity() public { - // assume token0/token1 is in universal router - token0.mint(address(router), 10 ether); - token1.mint(address(router), 10 ether); - - // prep position manager action: mint/ settle/ settle - uint24[] memory binIds = getBinIds(ACTIVE_ID_1_1, 1); - IBinPositionManager.BinAddLiquidityParams memory addParams = - _getAddParams(binPoolKey, binIds, 5 ether, 5 ether, ACTIVE_ID_1_1, address(this)); - - Plan memory planner = Planner.init(); - planner.add(Actions.BIN_ADD_LIQUIDITY, abi.encode(addParams)); - planner.add(Actions.SETTLE, abi.encode(binPoolKey.currency0, ActionConstants.OPEN_DELTA, false)); // deduct from universal router - planner.add(Actions.SETTLE, abi.encode(binPoolKey.currency1, ActionConstants.OPEN_DELTA, false)); // deduct from universal router - planner.add(Actions.SWEEP, abi.encode(binPoolKey.currency0, alice)); - planner.add(Actions.SWEEP, abi.encode(binPoolKey.currency1, alice)); - - // prep universal router actions - bytes memory commands = abi.encodePacked( - bytes1(uint8(Commands.SWEEP)), bytes1(uint8(Commands.SWEEP)), bytes1(uint8(Commands.INFI_BIN_POSITION_CALL)) - ); - bytes[] memory inputs = new bytes[](3); - inputs[0] = abi.encode(token0, address(binPositionManager), 0); // send token to binPositionManager - inputs[1] = abi.encode(token1, address(binPositionManager), 0); // send token to binPositionManager - inputs[2] = - abi.encodePacked(IPositionManager.modifyLiquidities.selector, abi.encode(planner.encode(), block.timestamp)); - - vm.prank(alice); - router.execute(commands, inputs); - vm.snapshotGasLastCall("test_infiBinPositionmanager_BinAddLiquidity"); - - // verify balance sent back to alice - assertEq(token0.balanceOf(address(alice)), 5 ether); - assertEq(token1.balanceOf(address(alice)), 5 ether); - } - - /// @dev add 10 eth liquidity to v3 pool with 1:1 price at -100, to 100 tick range - function _mintV3Liquidity(address _token0, address _token1, address recipient) internal returns (uint256 tokenId) { - v3Nfpm.createAndInitializePoolIfNecessary(_token0, _token1, 500, SQRT_PRICE_1_1); - IV3NonfungiblePositionManager.MintParams memory mintParams = IV3NonfungiblePositionManager.MintParams({ - token0: _token0, - token1: _token1, - fee: 500, - tickLower: -100, - tickUpper: 100, - amount0Desired: 10 ether, - amount1Desired: 10 ether, - amount0Min: 0, - amount1Min: 0, - recipient: recipient, - deadline: block.timestamp + 100 - }); - - (tokenId,,,) = v3Nfpm.mint(mintParams); - } - - /// @dev generate erc721 signature, signing from alice - function _getErc721PermitSignature(address spender, uint256 tokenId, uint256 deadline) - internal - view - returns (uint8 v, bytes32 r, bytes32 s) - { - (uint256 nonce,,,,,,,,,,,) = v3Nfpm.positions(tokenId); - bytes32 digest = keccak256( - abi.encodePacked( - "\x19\x01", - v3Nfpm.DOMAIN_SEPARATOR(), - keccak256(abi.encode(v3Nfpm.PERMIT_TYPEHASH(), spender, tokenId, nonce, deadline)) - ) - ); - - (v, r, s) = vm.sign(alicePK, digest); - } - - function _getDeployerBytecodePath() internal pure returns (string memory) { - // https://etherscan.io/address/0x41ff9AA7e16B8B1a8a8dc4f0eFacd93D02d071c9#code - return "./test/bin/pcsV3Deployer.bytecode"; - } - - function _getFactoryBytecodePath() internal pure returns (string memory) { - // https://etherscan.io/address/0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865#code - return "./test/bin/pcsV3Factory.bytecode"; - } - - function _getNfpmBytecodePath() internal pure returns (string memory) { - // https://etherscan.io/address/0x46A15B0b27311cedF172AB29E4f4766fbE7F4364#code - return "./test/bin/pcsV3Nfpm.bytecode"; - } -} diff --git a/test/V3ToInfinityMigrationNative.t.sol b/test/V3ToInfinityMigrationNative.t.sol deleted file mode 100644 index 81f8292..0000000 --- a/test/V3ToInfinityMigrationNative.t.sol +++ /dev/null @@ -1,224 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.15; - -import {Test, console} from "forge-std/Test.sol"; -import {IAllowanceTransfer} from "permit2/src/interfaces/IAllowanceTransfer.sol"; -import {IWETH9} from "infinity-periphery/src/interfaces/external/IWETH9.sol"; -import {WETH} from "solmate/src/tokens/WETH.sol"; -import {MockERC20} from "solmate/src/test/utils/mocks/MockERC20.sol"; - -import {PoolKey} from "infinity-core/src/types/PoolKey.sol"; -import {Currency, CurrencyLibrary} from "infinity-core/src/types/Currency.sol"; -import {IVault} from "infinity-core/src/interfaces/IVault.sol"; -import {Vault} from "infinity-core/src/Vault.sol"; -import {CLPoolManager} from "infinity-core/src/pool-cl/CLPoolManager.sol"; -import {ICLPoolManager} from "infinity-core/src/pool-cl/interfaces/ICLPoolManager.sol"; -import {BinPoolManager} from "infinity-core/src/pool-bin/BinPoolManager.sol"; -import {IBinPoolManager} from "infinity-core/src/pool-bin/interfaces/IBinPoolManager.sol"; -import {FixedPoint96} from "infinity-core/src/pool-cl/libraries/FixedPoint96.sol"; -import {IHooks} from "infinity-core/src/interfaces/IHooks.sol"; -import {CLPoolParametersHelper} from "infinity-core/src/pool-cl/libraries/CLPoolParametersHelper.sol"; -import {BinPoolParametersHelper} from "infinity-core/src/pool-bin/libraries/BinPoolParametersHelper.sol"; -import {ActionConstants} from "infinity-periphery/src/libraries/ActionConstants.sol"; -import {Plan, Planner} from "infinity-periphery/src/libraries/Planner.sol"; -import {CLPositionManager} from "infinity-periphery/src/pool-cl/CLPositionManager.sol"; -import {CLPositionDescriptorOffChain} from "infinity-periphery/src/pool-cl/CLPositionDescriptorOffChain.sol"; -import {BinPositionManager} from "infinity-periphery/src/pool-bin/BinPositionManager.sol"; -import {Actions} from "infinity-periphery/src/libraries/Actions.sol"; -import {IV3NonfungiblePositionManager} from - "infinity-periphery/src/interfaces/external/IV3NonfungiblePositionManager.sol"; -import {IERC721Permit} from "infinity-periphery/src/interfaces/IERC721Permit.sol"; -import {IPositionManager} from "infinity-periphery/src/interfaces/IPositionManager.sol"; -import {IBinPositionManager} from "infinity-periphery/src/pool-bin/interfaces/IBinPositionManager.sol"; -import {OldVersionHelper} from "infinity-periphery/test/helpers/OldVersionHelper.sol"; -import {BinLiquidityHelper} from "infinity-periphery/test/pool-bin/helper/BinLiquidityHelper.sol"; -import {Constants} from "../src/libraries/Constants.sol"; - -import {IUniversalRouter} from "../src/interfaces/IUniversalRouter.sol"; -import {Commands} from "../src/libraries/Commands.sol"; -import {RouterParameters} from "../src/base/RouterImmutables.sol"; -import {Dispatcher} from "../src/base/Dispatcher.sol"; -import {UniversalRouter} from "../src/UniversalRouter.sol"; -import {BasePancakeSwapInfinity} from "./infinity/BasePancakeSwapInfinity.sol"; - -interface IPancakeV3LikePairFactory { - function createPool(address tokenA, address tokenB, uint24 fee) external returns (address pool); -} - -/// @dev Test simplified, assume weth-token pair is already broken and token reside in universal router -contract V3ToInfinityMigrationNativeTest is BasePancakeSwapInfinity, OldVersionHelper, BinLiquidityHelper { - using BinPoolParametersHelper for bytes32; - using CLPoolParametersHelper for bytes32; - using Planner for Plan; - - MockERC20 token0; - MockERC20 token1; - WETH weth = new WETH(); - address alice; - uint256 alicePK; - - // infinity related - IVault vault; - IBinPoolManager binPoolManager; - BinPositionManager binPositionManager; - ICLPoolManager clPoolManager; - CLPositionManager clPositionManager; - IAllowanceTransfer permit2; - UniversalRouter router; - PoolKey clPoolKey; - PoolKey binPoolKey; - - uint24 constant ACTIVE_ID_1_1 = 2 ** 23; // where token0 and token1 price is the same - uint160 constant SQRT_PRICE_1_1 = uint160(1 * FixedPoint96.Q96); // price 1 - - function setUp() public { - (alice, alicePK) = makeAddrAndKey("ALICE"); - - initializeTokens(); - vm.label(Currency.unwrap(currency1), "token1"); - token1 = MockERC20(Currency.unwrap(currency1)); - - permit2 = IAllowanceTransfer(deployPermit2()); - - /////////////////////////////////// - ///////// infinity setup ////////// - /////////////////////////////////// - vault = IVault(new Vault()); - binPoolManager = new BinPoolManager(vault); - clPoolManager = new CLPoolManager(vault); - vault.registerApp(address(binPoolManager)); - vault.registerApp(address(clPoolManager)); - - binPositionManager = new BinPositionManager(vault, binPoolManager, permit2, IWETH9(address(weth))); - _approvePermit2ForCurrency(address(this), currency1, address(binPositionManager), permit2); - - CLPositionDescriptorOffChain pd = - new CLPositionDescriptorOffChain("https://pancakeswap.finance/infinity/pool-cl/positions/"); - clPositionManager = new CLPositionManager(vault, clPoolManager, permit2, 100_000, pd, IWETH9(address(weth))); - _approvePermit2ForCurrency(address(this), currency1, address(clPositionManager), permit2); - - clPoolKey = PoolKey({ - currency0: CurrencyLibrary.NATIVE, - currency1: currency1, - hooks: IHooks(address(0)), - poolManager: clPoolManager, - fee: uint24(3000), - parameters: bytes32(0).setTickSpacing(10) - }); - clPoolManager.initialize(clPoolKey, SQRT_PRICE_1_1); - - binPoolKey = PoolKey({ - currency0: CurrencyLibrary.NATIVE, - currency1: currency1, - hooks: IHooks(address(0)), - poolManager: binPoolManager, - fee: uint24(3000), - parameters: bytes32(0).setBinStep(10) - }); - binPoolManager.initialize(binPoolKey, ACTIVE_ID_1_1); - - /////////////////////////////////// - //////////// Router setup ///////////// - /////////////////////////////////// - RouterParameters memory params = RouterParameters({ - permit2: address(permit2), - weth9: address(weth), - v2Factory: address(0), - v3Factory: address(0), - v3Deployer: address(0), - v2InitCodeHash: bytes32(0), - v3InitCodeHash: bytes32(0), - stableFactory: address(0), - stableInfo: address(0), - infiVault: address(vault), - infiClPoolManager: address(clPoolManager), - infiBinPoolManager: address(binPoolManager), - v3NFTPositionManager: address(0), - infiClPositionManager: address(clPositionManager), - infiBinPositionManager: address(binPositionManager) - }); - router = new UniversalRouter(params); - _approvePermit2ForCurrency(alice, currency1, address(router), permit2); - } - - /// @dev Assume weth/token1 is aready in universal router from v3 removal liquidity - /// then add liquidity to infinity cl and sweep remaining token - function test_infiCLPositionmanager_Mint_Native() public { - // assume weth/token1 is in universal router - vm.deal(address(this), 10 ether); - weth.deposit{value: 10 ether}(); - weth.transfer(address(router), 10 ether); - token1.mint(address(router), 10 ether); - - // prep position manager action: mint/ settle/ settle - Plan memory planner = Planner.init(); - planner.add(Actions.CL_MINT_POSITION, abi.encode(clPoolKey, -120, 120, 1 ether, 10 ether, 10 ether, alice, "")); - planner.add(Actions.SETTLE, abi.encode(clPoolKey.currency0, ActionConstants.OPEN_DELTA, false)); // deduct from universal router - planner.add(Actions.SETTLE, abi.encode(clPoolKey.currency1, ActionConstants.OPEN_DELTA, false)); // deduct from universal router - planner.add(Actions.SWEEP, abi.encode(clPoolKey.currency0, alice)); - planner.add(Actions.SWEEP, abi.encode(clPoolKey.currency1, alice)); - - // prep universal router actions - bytes memory commands = abi.encodePacked( - bytes1(uint8(Commands.UNWRAP_WETH)), - bytes1(uint8(Commands.SWEEP)), - bytes1(uint8(Commands.INFI_CL_POSITION_CALL)) - ); - bytes[] memory inputs = new bytes[](3); - inputs[0] = abi.encode(address(router), 10 ether); // get native eth to router - inputs[1] = abi.encode(token1, address(clPositionManager), 0); // send token1 to clPositionmanager - inputs[2] = - abi.encodePacked(IPositionManager.modifyLiquidities.selector, abi.encode(planner.encode(), block.timestamp)); - - vm.prank(alice); - router.execute(commands, inputs); - vm.snapshotGasLastCall("test_infiCLPositionmanager_Mint_Native"); - - // verify remaining balance sent back to alice - assertEq(alice.balance, 9994018262239490337); - assertEq(token1.balanceOf(address(alice)), 9994018262239490337); - assertEq(clPositionManager.ownerOf(1), alice); - } - - /// @dev Assume weth/token1 is aready in universal router from v3 removal liquidity - /// then add liquidity to infinity cl and sweep remaining token - function test_infiBinPositionmanager_BinAddLiquidity_Native() public { - // assume weth/token1 is in universal router - vm.deal(address(this), 10 ether); - weth.deposit{value: 10 ether}(); - weth.transfer(address(router), 10 ether); - token1.mint(address(router), 10 ether); - - // prep position manager action: mint/ settle/ settle - uint24[] memory binIds = getBinIds(ACTIVE_ID_1_1, 1); - IBinPositionManager.BinAddLiquidityParams memory addParams = - _getAddParams(binPoolKey, binIds, 5 ether, 5 ether, ACTIVE_ID_1_1, address(this)); - - Plan memory planner = Planner.init(); - planner.add(Actions.BIN_ADD_LIQUIDITY, abi.encode(addParams)); - planner.add(Actions.SETTLE, abi.encode(binPoolKey.currency0, ActionConstants.OPEN_DELTA, false)); // deduct from universal router - planner.add(Actions.SETTLE, abi.encode(binPoolKey.currency1, ActionConstants.OPEN_DELTA, false)); // deduct from universal router - planner.add(Actions.SWEEP, abi.encode(binPoolKey.currency0, alice)); - planner.add(Actions.SWEEP, abi.encode(binPoolKey.currency1, alice)); - - // prep universal router actions - bytes memory commands = abi.encodePacked( - bytes1(uint8(Commands.UNWRAP_WETH)), - bytes1(uint8(Commands.SWEEP)), - bytes1(uint8(Commands.INFI_BIN_POSITION_CALL)) - ); - bytes[] memory inputs = new bytes[](3); - inputs[0] = abi.encode(address(router), 10 ether); // get native eth to universal router - inputs[1] = abi.encode(token1, address(binPositionManager), 0); // send token1 to binPositionManager - inputs[2] = - abi.encodePacked(IPositionManager.modifyLiquidities.selector, abi.encode(planner.encode(), block.timestamp)); - - vm.prank(alice); - router.execute(commands, inputs); - vm.snapshotGasLastCall("test_infiBinPositionmanager_BinAddLiquidity_Native"); - - // verify remaining balance sent back to alice - assertEq(alice.balance, 5 ether); - assertEq(token1.balanceOf(address(alice)), 5 ether); - } -} diff --git a/test/infinity/BinNativePancakeSwapInfinity.t.sol b/test/infinity/BinNativePancakeSwapInfinity.t.sol index 21dc897..2fffbdb 100644 --- a/test/infinity/BinNativePancakeSwapInfinity.t.sol +++ b/test/infinity/BinNativePancakeSwapInfinity.t.sol @@ -78,10 +78,7 @@ contract BinNativePancakeSwapInfinityTest is BasePancakeSwapInfinity, BinLiquidi stableInfo: address(0), infiVault: address(vault), infiClPoolManager: address(0), - infiBinPoolManager: address(poolManager), - v3NFTPositionManager: address(0), - infiClPositionManager: address(0), - infiBinPositionManager: address(positionManager) + infiBinPoolManager: address(poolManager) }); router = new UniversalRouter(params); _approvePermit2ForCurrency(alice, currency1, address(router), permit2); diff --git a/test/infinity/BinPancakeSwapInfinity.t.sol b/test/infinity/BinPancakeSwapInfinity.t.sol index 4babec7..4e9f462 100644 --- a/test/infinity/BinPancakeSwapInfinity.t.sol +++ b/test/infinity/BinPancakeSwapInfinity.t.sol @@ -86,10 +86,7 @@ contract BinPancakeSwapInfinityTest is BasePancakeSwapInfinity, BinLiquidityHelp stableInfo: address(0), infiVault: address(vault), infiClPoolManager: address(0), - infiBinPoolManager: address(poolManager), - v3NFTPositionManager: address(0), - infiClPositionManager: address(0), - infiBinPositionManager: address(positionManager) + infiBinPoolManager: address(poolManager) }); router = new UniversalRouter(params); _approvePermit2ForCurrency(alice, currency0, address(router), permit2); diff --git a/test/infinity/CLNativePancakeSwapInfinity.t.sol b/test/infinity/CLNativePancakeSwapInfinity.t.sol index 9947922..590eceb 100644 --- a/test/infinity/CLNativePancakeSwapInfinity.t.sol +++ b/test/infinity/CLNativePancakeSwapInfinity.t.sol @@ -83,10 +83,7 @@ contract CLNativePancakeSwapInfinityTest is BasePancakeSwapInfinity { stableInfo: address(0), infiVault: address(vault), infiClPoolManager: address(poolManager), - infiBinPoolManager: address(0), - v3NFTPositionManager: address(0), - infiClPositionManager: address(positionManager), - infiBinPositionManager: address(0) + infiBinPoolManager: address(0) }); router = new UniversalRouter(params); _approvePermit2ForCurrency(alice, currency1, address(router), permit2); diff --git a/test/infinity/CLPancakeSwapInfinity.t.sol b/test/infinity/CLPancakeSwapInfinity.t.sol index 3be17d7..c65a699 100644 --- a/test/infinity/CLPancakeSwapInfinity.t.sol +++ b/test/infinity/CLPancakeSwapInfinity.t.sol @@ -91,10 +91,7 @@ contract CLPancakeSwapInfinityTest is BasePancakeSwapInfinity { stableInfo: address(0), infiVault: address(vault), infiClPoolManager: address(poolManager), - infiBinPoolManager: address(0), - v3NFTPositionManager: address(0), - infiClPositionManager: address(positionManager), - infiBinPositionManager: address(0) + infiBinPoolManager: address(0) }); router = new UniversalRouter(params); _approvePermit2ForCurrency(alice, currency0, address(router), permit2); diff --git a/test/stableSwap/StableSwap.t.sol b/test/stableSwap/StableSwap.t.sol index 5db1f35..c12713f 100644 --- a/test/stableSwap/StableSwap.t.sol +++ b/test/stableSwap/StableSwap.t.sol @@ -46,10 +46,7 @@ abstract contract StableSwapTest is Test { stableInfo: address(STABLE_INFO), infiVault: address(0), infiClPoolManager: address(0), - infiBinPoolManager: address(0), - v3NFTPositionManager: address(0), - infiClPositionManager: address(0), - infiBinPositionManager: address(0) + infiBinPoolManager: address(0) }); router = new UniversalRouter(params); diff --git a/test/v2/PancakeSwapV2.t.sol b/test/v2/PancakeSwapV2.t.sol index 395d95f..34badc8 100644 --- a/test/v2/PancakeSwapV2.t.sol +++ b/test/v2/PancakeSwapV2.t.sol @@ -41,10 +41,7 @@ abstract contract PancakeSwapV2Test is Test { stableInfo: address(0), infiVault: address(0), infiClPoolManager: address(0), - infiBinPoolManager: address(0), - v3NFTPositionManager: address(0), - infiClPositionManager: address(0), - infiBinPositionManager: address(0) + infiBinPoolManager: address(0) }); router = new UniversalRouter(params); diff --git a/test/v3/PancakeSwapV3.t.sol b/test/v3/PancakeSwapV3.t.sol index acdbcd1..b45360d 100644 --- a/test/v3/PancakeSwapV3.t.sol +++ b/test/v3/PancakeSwapV3.t.sol @@ -44,10 +44,7 @@ abstract contract PancakeSwapV3Test is Test { stableInfo: address(0), infiVault: address(0), infiClPoolManager: address(0), - infiBinPoolManager: address(0), - v3NFTPositionManager: address(0), - infiClPositionManager: address(0), - infiBinPositionManager: address(0) + infiBinPoolManager: address(0) }); router = new UniversalRouter(params);