Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions script/DeployUniversalRouter.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 1 addition & 4 deletions script/deployParameters/mainnet/DeployArbitrum.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions script/deployParameters/mainnet/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions script/deployParameters/mainnet/DeployBsc.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions script/deployParameters/mainnet/DeployEth.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions script/deployParameters/mainnet/DeployLinea.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions script/deployParameters/mainnet/DeployOpBnb.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions script/deployParameters/mainnet/DeployzkEvm.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions script/deployParameters/testnet/DeployBscTestnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions script/deployParameters/testnet/DeployEthSepolia.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions snapshots/BinNativePancakeSwapInfinityTest.json
Original file line number Diff line number Diff line change
@@ -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"
}
14 changes: 7 additions & 7 deletions snapshots/BinPancakeSwapInfinityTest.json
Original file line number Diff line number Diff line change
@@ -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"
}
6 changes: 3 additions & 3 deletions snapshots/CLNativePancakeSwapInfinityTest.json
Original file line number Diff line number Diff line change
@@ -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"
}
14 changes: 7 additions & 7 deletions snapshots/CLPancakeSwapInfinityTest.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion snapshots/UniversalRouterTest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"UniversalRouterBytecodeSize": "24350",
"UniversalRouterBytecodeSize": "22521",
"test_sweep_token": "55429"
}
10 changes: 5 additions & 5 deletions snapshots/V3BnbCake.json
Original file line number Diff line number Diff line change
@@ -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"
}
63 changes: 19 additions & 44 deletions src/base/Dispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down
19 changes: 0 additions & 19 deletions src/base/RouterImmutables.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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);
}
}
7 changes: 2 additions & 5 deletions src/libraries/Commands.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
Loading