diff --git a/foundry/scripts/deploy-executors.js b/foundry/scripts/deploy-executors.js index 9192e1c..f6a6364 100644 --- a/foundry/scripts/deploy-executors.js +++ b/foundry/scripts/deploy-executors.js @@ -5,27 +5,30 @@ const hre = require("hardhat"); // Comment out the executors you don't want to deploy const executors_to_deploy = { "ethereum": [ - // USV2 - Args: Factory, Pool Init Code Hash, Fee BPS + // USV2 - Args: Factory, Pool Init Code Hash, Permit2, Fee BPS { exchange: "UniswapV2Executor", args: [ "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f", + "0x000000000022D473030F116dDEE9F6B43aC78BA3", 30 ] }, - // SUSHISWAP - Args: Factory, Pool Init Code Hash, Fee BPS, Fee BPS + // SUSHISWAP - Args: Factory, Pool Init Code Hash, Fee BPS, Permit2, Fee BPS { exchange: "UniswapV2Executor", args: [ "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac", "0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303", + "0x000000000022D473030F116dDEE9F6B43aC78BA3", 30 ] }, - // PANCAKESWAP V2 - Args: Factory, Pool Init Code Hash, Fee BPS + // PANCAKESWAP V2 - Args: Factory, Pool Init Code Hash, Permit2, Fee BPS { exchange: "UniswapV2Executor", args: [ "0x1097053Fd2ea711dad45caCcc45EfF7548fCB362", "0x57224589c67f3f30a6b0d7a1b54cf3153ab84563bc609ef41dfb34f8b2974d2d", + "0x000000000022D473030F116dDEE9F6B43aC78BA3", 25 ] }, @@ -50,8 +53,8 @@ const executors_to_deploy = { "0x000000000004444c5dc75cB358380D2e3dE08A90", "0x000000000022D473030F116dDEE9F6B43aC78BA3" ]}, - // Args: None - {exchange: "BalancerV2Executor", args: []}, + // Args: Permit2 + {exchange: "BalancerV2Executor", args: ["0x000000000022D473030F116dDEE9F6B43aC78BA3"]}, // Args: Ekubo core contract, Permit2 { exchange: "EkuboExecutor", args: [ @@ -59,64 +62,69 @@ const executors_to_deploy = { "0x000000000022D473030F116dDEE9F6B43aC78BA3" ] }, - // Args: ETH address in curve pools + // Args: ETH address in curve pools, Permit2 { exchange: "CurveExecutor", args: [ - "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" + "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + "0x000000000022D473030F116dDEE9F6B43aC78BA3" ] } ], "base": [ - // Args: Factory, Pool Init Code Hash, Fee BPS - { - exchange: "UniswapV2Executor", args: [ - "0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6", - "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f", - 30 - ] - }, - // SUSHISWAP V2 - Args: Factory, Pool Init Code Hash, Fee BPS - { - exchange: "UniswapV2Executor", args: [ - "0x71524B4f93c58fcbF659783284E38825f0622859", - "0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303", - 30 - ] - }, - // PANCAKESWAP V2 - Args: Factory, Pool Init Code Hash, Fee BPS + // // Args: Factory, Pool Init Code Hash, Permit2, Fee BPS + // { + // exchange: "UniswapV2Executor", args: [ + // "0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6", + // "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f", + // "0x000000000022D473030F116dDEE9F6B43aC78BA3", + // 30 + // ] + // }, + // // SUSHISWAP V2 - Args: Factory, Pool Init Code Hash, Permit2, Fee BPS + // { + // exchange: "UniswapV2Executor", args: [ + // "0x71524B4f93c58fcbF659783284E38825f0622859", + // "0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303", + // "0x000000000022D473030F116dDEE9F6B43aC78BA3", + // 30 + // ] + // }, + // PANCAKESWAP V2 - Args: Factory, Pool Init Code Hash, Permit2, Fee BPS { exchange: "UniswapV2Executor", args: [ "0x1097053Fd2ea711dad45caCcc45EfF7548fCB362", "0x57224589c67f3f30a6b0d7a1b54cf3153ab84563bc609ef41dfb34f8b2974d2d", + "0x000000000022D473030F116dDEE9F6B43aC78BA3", 25 ] }, - // USV3 - Args: Factory, Pool Init Code Hash, Permit2 - { - exchange: "UniswapV3Executor", args: [ - "0x33128a8fC17869897dcE68Ed026d694621f6FDfD", - "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54", - "0x000000000022D473030F116dDEE9F6B43aC78BA3" - ] - }, - // PANCAKESWAP V3 - Args: Deployer, Pool Init Code Hash, Permit2 - { - exchange: "UniswapV3Executor", args: [ - "0x41ff9AA7e16B8B1a8a8dc4f0eFacd93D02d071c9", - "0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2", - "0x000000000022D473030F116dDEE9F6B43aC78BA3" - ] - }, - // Args: Pool manager - {exchange: "UniswapV4Executor", args: ["0x498581ff718922c3f8e6a244956af099b2652b2b"]}, - {exchange: "BalancerV2Executor", args: []}, + // // USV3 - Args: Factory, Pool Init Code Hash, Permit2 + // { + // exchange: "UniswapV3Executor", args: [ + // "0x33128a8fC17869897dcE68Ed026d694621f6FDfD", + // "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54", + // "0x000000000022D473030F116dDEE9F6B43aC78BA3" + // ] + // }, + // // PANCAKESWAP V3 - Args: Deployer, Pool Init Code Hash, Permit2 + // { + // exchange: "UniswapV3Executor", args: [ + // "0x41ff9AA7e16B8B1a8a8dc4f0eFacd93D02d071c9", + // "0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2", + // "0x000000000022D473030F116dDEE9F6B43aC78BA3" + // ] + // }, + // // Args: Pool manager + // {exchange: "UniswapV4Executor", args: ["0x498581ff718922c3f8e6a244956af099b2652b2b"]}, + // {exchange: "BalancerV2Executor", args: []}, ], "unichain": [ - // Args: Factory, Pool Init Code Hash, Fee BPS + // Args: Factory, Pool Init Code Hash, Permit2, Fee BPS { exchange: "UniswapV2Executor", args: [ "0x1f98400000000000000000000000000000000002", "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f", + "0x000000000022D473030F116dDEE9F6B43aC78BA3", 30 ] }, diff --git a/foundry/src/executors/BalancerV2Executor.sol b/foundry/src/executors/BalancerV2Executor.sol index 54958e1..02b272b 100644 --- a/foundry/src/executors/BalancerV2Executor.sol +++ b/foundry/src/executors/BalancerV2Executor.sol @@ -18,6 +18,8 @@ contract BalancerV2Executor is IExecutor { address private constant VAULT = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; + constructor(address _permit2) {} + // slither-disable-next-line locked-ether function swap(uint256 givenAmount, bytes calldata data) external diff --git a/foundry/src/executors/CurveExecutor.sol b/foundry/src/executors/CurveExecutor.sol index 2304f69..a3f2030 100644 --- a/foundry/src/executors/CurveExecutor.sol +++ b/foundry/src/executors/CurveExecutor.sol @@ -39,7 +39,7 @@ contract CurveExecutor is IExecutor { address public immutable nativeToken; - constructor(address _nativeToken) { + constructor(address _nativeToken, address _permit2) { if (_nativeToken == address(0)) { revert CurveExecutor__AddressZero(); } diff --git a/foundry/src/executors/MaverickV2Executor.sol b/foundry/src/executors/MaverickV2Executor.sol index fab7dc8..a7c9cee 100644 --- a/foundry/src/executors/MaverickV2Executor.sol +++ b/foundry/src/executors/MaverickV2Executor.sol @@ -14,7 +14,7 @@ contract MaverickV2Executor is IExecutor { address public immutable factory; - constructor(address _factory) { + constructor(address _factory, address _permit2) { if (_factory == address(0)) { revert MaverickV2Executor__InvalidFactory(); } diff --git a/foundry/src/executors/UniswapV2Executor.sol b/foundry/src/executors/UniswapV2Executor.sol index 753ecef..d5b1831 100644 --- a/foundry/src/executors/UniswapV2Executor.sol +++ b/foundry/src/executors/UniswapV2Executor.sol @@ -19,7 +19,12 @@ contract UniswapV2Executor is IExecutor { address private immutable self; uint256 public immutable feeBps; - constructor(address _factory, bytes32 _initCode, uint256 _feeBps) { + constructor( + address _factory, + bytes32 _initCode, + address _permit2, + uint256 _feeBps + ) { if (_factory == address(0)) { revert UniswapV2Executor__InvalidFactory(); } diff --git a/foundry/test/TychoRouterTestSetup.sol b/foundry/test/TychoRouterTestSetup.sol index 8c40ef3..31dd507 100644 --- a/foundry/test/TychoRouterTestSetup.sol +++ b/foundry/test/TychoRouterTestSetup.sol @@ -101,17 +101,19 @@ contract TychoRouterTestSetup is Constants, Permit2TestHelper, TestUtils { address ekuboCore = 0xe0e0e08A6A4b9Dc7bD67BCB7aadE5cF48157d444; IPoolManager poolManager = IPoolManager(poolManagerAddress); - usv2Executor = new UniswapV2Executor(factoryV2, initCodeV2, 30); + usv2Executor = + new UniswapV2Executor(factoryV2, initCodeV2, PERMIT2_ADDRESS, 30); usv3Executor = new UniswapV3Executor(factoryV3, initCodeV3, PERMIT2_ADDRESS); usv4Executor = new UniswapV4Executor(poolManager, PERMIT2_ADDRESS); pancakev3Executor = new UniswapV3Executor( factoryPancakeV3, initCodePancakeV3, PERMIT2_ADDRESS ); - balancerv2Executor = new BalancerV2Executor(); + balancerv2Executor = new BalancerV2Executor(PERMIT2_ADDRESS); ekuboExecutor = new EkuboExecutor(ekuboCore, PERMIT2_ADDRESS); - curveExecutor = new CurveExecutor(ETH_ADDR_FOR_CURVE); - maverickv2Executor = new MaverickV2Executor(MAVERICK_V2_FACTORY); + curveExecutor = new CurveExecutor(ETH_ADDR_FOR_CURVE, PERMIT2_ADDRESS); + maverickv2Executor = + new MaverickV2Executor(MAVERICK_V2_FACTORY, PERMIT2_ADDRESS); address[] memory executors = new address[](8); executors[0] = address(usv2Executor); diff --git a/foundry/test/executors/BalancerV2Executor.t.sol b/foundry/test/executors/BalancerV2Executor.t.sol index 3e86df6..46b2ffd 100644 --- a/foundry/test/executors/BalancerV2Executor.t.sol +++ b/foundry/test/executors/BalancerV2Executor.t.sol @@ -6,6 +6,8 @@ import "@src/executors/BalancerV2Executor.sol"; import {Constants} from "../Constants.sol"; contract BalancerV2ExecutorExposed is BalancerV2Executor { + constructor(address _permit2) BalancerV2Executor(_permit2) {} + function decodeParams(bytes calldata data) external pure @@ -33,7 +35,7 @@ contract BalancerV2ExecutorTest is Constants, TestUtils { function setUp() public { uint256 forkBlock = 17323404; vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock); - balancerV2Exposed = new BalancerV2ExecutorExposed(); + balancerV2Exposed = new BalancerV2ExecutorExposed(PERMIT2_ADDRESS); } function testDecodeParams() public view { diff --git a/foundry/test/executors/CurveExecutor.t.sol b/foundry/test/executors/CurveExecutor.t.sol index b270958..3d5621e 100644 --- a/foundry/test/executors/CurveExecutor.t.sol +++ b/foundry/test/executors/CurveExecutor.t.sol @@ -22,7 +22,9 @@ interface MetaRegistry { } contract CurveExecutorExposed is CurveExecutor { - constructor(address _nativeToken) CurveExecutor(_nativeToken) {} + constructor(address _nativeToken, address _permit2) + CurveExecutor(_nativeToken, _permit2) + {} function decodeData(bytes calldata data) external @@ -51,7 +53,8 @@ contract CurveExecutorTest is Test, Constants { function setUp() public { uint256 forkBlock = 22031795; vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock); - curveExecutorExposed = new CurveExecutorExposed(ETH_ADDR_FOR_CURVE); + curveExecutorExposed = + new CurveExecutorExposed(ETH_ADDR_FOR_CURVE, PERMIT2_ADDRESS); metaRegistry = MetaRegistry(CURVE_META_REGISTRY); } diff --git a/foundry/test/executors/MaverickV2Executor.t.sol b/foundry/test/executors/MaverickV2Executor.t.sol index be7d99e..241d265 100644 --- a/foundry/test/executors/MaverickV2Executor.t.sol +++ b/foundry/test/executors/MaverickV2Executor.t.sol @@ -6,7 +6,9 @@ import {Constants} from "../Constants.sol"; import "../TestUtils.sol"; contract MaverickV2ExecutorExposed is MaverickV2Executor { - constructor(address _factory) MaverickV2Executor(_factory) {} + constructor(address _factory, address _permit2) + MaverickV2Executor(_factory, _permit2) + {} function decodeParams(bytes calldata data) external @@ -32,7 +34,8 @@ contract MaverickV2ExecutorTest is TestUtils, Constants { function setUp() public { uint256 forkBlock = 22096000; vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock); - maverickV2Exposed = new MaverickV2ExecutorExposed(MAVERICK_V2_FACTORY); + maverickV2Exposed = + new MaverickV2ExecutorExposed(MAVERICK_V2_FACTORY, PERMIT2_ADDRESS); } function testDecodeParams() public view { diff --git a/foundry/test/executors/UniswapV2Executor.t.sol b/foundry/test/executors/UniswapV2Executor.t.sol index ef29637..a6a34bd 100644 --- a/foundry/test/executors/UniswapV2Executor.t.sol +++ b/foundry/test/executors/UniswapV2Executor.t.sol @@ -8,9 +8,12 @@ import {Permit2TestHelper} from "../Permit2TestHelper.sol"; import {Test} from "../../lib/forge-std/src/Test.sol"; contract UniswapV2ExecutorExposed is UniswapV2Executor { - constructor(address _factory, bytes32 _initCode, uint256 _feeBps) - UniswapV2Executor(_factory, _initCode, _feeBps) - {} + constructor( + address _factory, + bytes32 _initCode, + address _permit2, + uint256 _feeBps + ) UniswapV2Executor(_factory, _initCode, _permit2, _feeBps) {} function decodeParams(bytes calldata data) external @@ -62,13 +65,19 @@ contract UniswapV2ExecutorTest is Constants, Permit2TestHelper, TestUtils { uint256 forkBlock = 17323404; vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock); uniswapV2Exposed = new UniswapV2ExecutorExposed( - USV2_FACTORY_ETHEREUM, USV2_POOL_CODE_INIT_HASH, 30 + USV2_FACTORY_ETHEREUM, USV2_POOL_CODE_INIT_HASH, PERMIT2_ADDRESS, 30 ); sushiswapV2Exposed = new UniswapV2ExecutorExposed( - SUSHISWAPV2_FACTORY_ETHEREUM, SUSHIV2_POOL_CODE_INIT_HASH, 30 + SUSHISWAPV2_FACTORY_ETHEREUM, + SUSHIV2_POOL_CODE_INIT_HASH, + PERMIT2_ADDRESS, + 30 ); pancakeswapV2Exposed = new UniswapV2ExecutorExposed( - PANCAKESWAPV2_FACTORY_ETHEREUM, PANCAKEV2_POOL_CODE_INIT_HASH, 25 + PANCAKESWAPV2_FACTORY_ETHEREUM, + PANCAKEV2_POOL_CODE_INIT_HASH, + PERMIT2_ADDRESS, + 25 ); }