From b0b98c5e5de7d248f2f98734a8fca3897946861d Mon Sep 17 00:00:00 2001 From: TAMARA LIPOWSKI Date: Thu, 15 May 2025 08:23:55 -0400 Subject: [PATCH] chore: Remove permit2 from executor constructor... whenever not needed. --- foundry/scripts/deploy-executors.js | 96 +++++++++---------- foundry/src/executors/BalancerV2Executor.sol | 2 - foundry/src/executors/CurveExecutor.sol | 2 +- foundry/src/executors/MaverickV2Executor.sol | 2 +- foundry/src/executors/UniswapV2Executor.sol | 7 +- foundry/test/TychoRouterTestSetup.sol | 10 +- .../test/executors/BalancerV2Executor.t.sol | 4 +- foundry/test/executors/CurveExecutor.t.sol | 7 +- .../test/executors/MaverickV2Executor.t.sol | 7 +- .../test/executors/UniswapV2Executor.t.sol | 21 ++-- 10 files changed, 62 insertions(+), 96 deletions(-) diff --git a/foundry/scripts/deploy-executors.js b/foundry/scripts/deploy-executors.js index f6a6364..9192e1c 100644 --- a/foundry/scripts/deploy-executors.js +++ b/foundry/scripts/deploy-executors.js @@ -5,30 +5,27 @@ 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, Permit2, Fee BPS + // USV2 - Args: Factory, Pool Init Code Hash, Fee BPS { exchange: "UniswapV2Executor", args: [ "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f", - "0x000000000022D473030F116dDEE9F6B43aC78BA3", 30 ] }, - // SUSHISWAP - Args: Factory, Pool Init Code Hash, Fee BPS, Permit2, Fee BPS + // SUSHISWAP - Args: Factory, Pool Init Code Hash, Fee BPS, Fee BPS { exchange: "UniswapV2Executor", args: [ "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac", "0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303", - "0x000000000022D473030F116dDEE9F6B43aC78BA3", 30 ] }, - // PANCAKESWAP V2 - Args: Factory, Pool Init Code Hash, Permit2, Fee BPS + // PANCAKESWAP V2 - Args: Factory, Pool Init Code Hash, Fee BPS { exchange: "UniswapV2Executor", args: [ "0x1097053Fd2ea711dad45caCcc45EfF7548fCB362", "0x57224589c67f3f30a6b0d7a1b54cf3153ab84563bc609ef41dfb34f8b2974d2d", - "0x000000000022D473030F116dDEE9F6B43aC78BA3", 25 ] }, @@ -53,8 +50,8 @@ const executors_to_deploy = { "0x000000000004444c5dc75cB358380D2e3dE08A90", "0x000000000022D473030F116dDEE9F6B43aC78BA3" ]}, - // Args: Permit2 - {exchange: "BalancerV2Executor", args: ["0x000000000022D473030F116dDEE9F6B43aC78BA3"]}, + // Args: None + {exchange: "BalancerV2Executor", args: []}, // Args: Ekubo core contract, Permit2 { exchange: "EkuboExecutor", args: [ @@ -62,69 +59,64 @@ const executors_to_deploy = { "0x000000000022D473030F116dDEE9F6B43aC78BA3" ] }, - // Args: ETH address in curve pools, Permit2 + // Args: ETH address in curve pools { exchange: "CurveExecutor", args: [ - "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - "0x000000000022D473030F116dDEE9F6B43aC78BA3" + "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" ] } ], "base": [ - // // 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 + // 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 { 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, Permit2, Fee BPS + // Args: Factory, Pool Init Code Hash, Fee BPS { exchange: "UniswapV2Executor", args: [ "0x1f98400000000000000000000000000000000002", "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f", - "0x000000000022D473030F116dDEE9F6B43aC78BA3", 30 ] }, diff --git a/foundry/src/executors/BalancerV2Executor.sol b/foundry/src/executors/BalancerV2Executor.sol index 016163b..0968cb3 100644 --- a/foundry/src/executors/BalancerV2Executor.sol +++ b/foundry/src/executors/BalancerV2Executor.sol @@ -18,8 +18,6 @@ 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 f953a63..8bef070 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, address _permit2) { + constructor(address _nativeToken) { if (_nativeToken == address(0)) { revert CurveExecutor__AddressZero(); } diff --git a/foundry/src/executors/MaverickV2Executor.sol b/foundry/src/executors/MaverickV2Executor.sol index 24dcd00..f8acbb1 100644 --- a/foundry/src/executors/MaverickV2Executor.sol +++ b/foundry/src/executors/MaverickV2Executor.sol @@ -13,7 +13,7 @@ contract MaverickV2Executor is IExecutor { address public immutable factory; - constructor(address _factory, address _permit2) { + constructor(address _factory) { if (_factory == address(0)) { revert MaverickV2Executor__InvalidFactory(); } diff --git a/foundry/src/executors/UniswapV2Executor.sol b/foundry/src/executors/UniswapV2Executor.sol index d5b1831..753ecef 100644 --- a/foundry/src/executors/UniswapV2Executor.sol +++ b/foundry/src/executors/UniswapV2Executor.sol @@ -19,12 +19,7 @@ contract UniswapV2Executor is IExecutor { address private immutable self; uint256 public immutable feeBps; - constructor( - address _factory, - bytes32 _initCode, - address _permit2, - uint256 _feeBps - ) { + constructor(address _factory, bytes32 _initCode, uint256 _feeBps) { if (_factory == address(0)) { revert UniswapV2Executor__InvalidFactory(); } diff --git a/foundry/test/TychoRouterTestSetup.sol b/foundry/test/TychoRouterTestSetup.sol index 31dd507..8c40ef3 100644 --- a/foundry/test/TychoRouterTestSetup.sol +++ b/foundry/test/TychoRouterTestSetup.sol @@ -101,19 +101,17 @@ contract TychoRouterTestSetup is Constants, Permit2TestHelper, TestUtils { address ekuboCore = 0xe0e0e08A6A4b9Dc7bD67BCB7aadE5cF48157d444; IPoolManager poolManager = IPoolManager(poolManagerAddress); - usv2Executor = - new UniswapV2Executor(factoryV2, initCodeV2, PERMIT2_ADDRESS, 30); + usv2Executor = new UniswapV2Executor(factoryV2, initCodeV2, 30); usv3Executor = new UniswapV3Executor(factoryV3, initCodeV3, PERMIT2_ADDRESS); usv4Executor = new UniswapV4Executor(poolManager, PERMIT2_ADDRESS); pancakev3Executor = new UniswapV3Executor( factoryPancakeV3, initCodePancakeV3, PERMIT2_ADDRESS ); - balancerv2Executor = new BalancerV2Executor(PERMIT2_ADDRESS); + balancerv2Executor = new BalancerV2Executor(); ekuboExecutor = new EkuboExecutor(ekuboCore, PERMIT2_ADDRESS); - curveExecutor = new CurveExecutor(ETH_ADDR_FOR_CURVE, PERMIT2_ADDRESS); - maverickv2Executor = - new MaverickV2Executor(MAVERICK_V2_FACTORY, PERMIT2_ADDRESS); + curveExecutor = new CurveExecutor(ETH_ADDR_FOR_CURVE); + maverickv2Executor = new MaverickV2Executor(MAVERICK_V2_FACTORY); 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 10cf988..6b33327 100644 --- a/foundry/test/executors/BalancerV2Executor.t.sol +++ b/foundry/test/executors/BalancerV2Executor.t.sol @@ -6,8 +6,6 @@ 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 @@ -36,7 +34,7 @@ contract BalancerV2ExecutorTest is Constants, TestUtils { function setUp() public { uint256 forkBlock = 17323404; vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock); - balancerV2Exposed = new BalancerV2ExecutorExposed(PERMIT2_ADDRESS); + balancerV2Exposed = new BalancerV2ExecutorExposed(); } function testDecodeParams() public view { diff --git a/foundry/test/executors/CurveExecutor.t.sol b/foundry/test/executors/CurveExecutor.t.sol index 3d61d60..0b7e1b7 100644 --- a/foundry/test/executors/CurveExecutor.t.sol +++ b/foundry/test/executors/CurveExecutor.t.sol @@ -22,9 +22,7 @@ interface MetaRegistry { } contract CurveExecutorExposed is CurveExecutor { - constructor(address _nativeToken, address _permit2) - CurveExecutor(_nativeToken, _permit2) - {} + constructor(address _nativeToken) CurveExecutor(_nativeToken) {} function decodeData(bytes calldata data) external @@ -54,8 +52,7 @@ contract CurveExecutorTest is Test, Constants { function setUp() public { uint256 forkBlock = 22031795; vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock); - curveExecutorExposed = - new CurveExecutorExposed(ETH_ADDR_FOR_CURVE, PERMIT2_ADDRESS); + curveExecutorExposed = new CurveExecutorExposed(ETH_ADDR_FOR_CURVE); metaRegistry = MetaRegistry(CURVE_META_REGISTRY); } diff --git a/foundry/test/executors/MaverickV2Executor.t.sol b/foundry/test/executors/MaverickV2Executor.t.sol index 241d265..be7d99e 100644 --- a/foundry/test/executors/MaverickV2Executor.t.sol +++ b/foundry/test/executors/MaverickV2Executor.t.sol @@ -6,9 +6,7 @@ import {Constants} from "../Constants.sol"; import "../TestUtils.sol"; contract MaverickV2ExecutorExposed is MaverickV2Executor { - constructor(address _factory, address _permit2) - MaverickV2Executor(_factory, _permit2) - {} + constructor(address _factory) MaverickV2Executor(_factory) {} function decodeParams(bytes calldata data) external @@ -34,8 +32,7 @@ contract MaverickV2ExecutorTest is TestUtils, Constants { function setUp() public { uint256 forkBlock = 22096000; vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock); - maverickV2Exposed = - new MaverickV2ExecutorExposed(MAVERICK_V2_FACTORY, PERMIT2_ADDRESS); + maverickV2Exposed = new MaverickV2ExecutorExposed(MAVERICK_V2_FACTORY); } function testDecodeParams() public view { diff --git a/foundry/test/executors/UniswapV2Executor.t.sol b/foundry/test/executors/UniswapV2Executor.t.sol index a6a34bd..ef29637 100644 --- a/foundry/test/executors/UniswapV2Executor.t.sol +++ b/foundry/test/executors/UniswapV2Executor.t.sol @@ -8,12 +8,9 @@ import {Permit2TestHelper} from "../Permit2TestHelper.sol"; import {Test} from "../../lib/forge-std/src/Test.sol"; contract UniswapV2ExecutorExposed is UniswapV2Executor { - constructor( - address _factory, - bytes32 _initCode, - address _permit2, - uint256 _feeBps - ) UniswapV2Executor(_factory, _initCode, _permit2, _feeBps) {} + constructor(address _factory, bytes32 _initCode, uint256 _feeBps) + UniswapV2Executor(_factory, _initCode, _feeBps) + {} function decodeParams(bytes calldata data) external @@ -65,19 +62,13 @@ 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, PERMIT2_ADDRESS, 30 + USV2_FACTORY_ETHEREUM, USV2_POOL_CODE_INIT_HASH, 30 ); sushiswapV2Exposed = new UniswapV2ExecutorExposed( - SUSHISWAPV2_FACTORY_ETHEREUM, - SUSHIV2_POOL_CODE_INIT_HASH, - PERMIT2_ADDRESS, - 30 + SUSHISWAPV2_FACTORY_ETHEREUM, SUSHIV2_POOL_CODE_INIT_HASH, 30 ); pancakeswapV2Exposed = new UniswapV2ExecutorExposed( - PANCAKESWAPV2_FACTORY_ETHEREUM, - PANCAKEV2_POOL_CODE_INIT_HASH, - PERMIT2_ADDRESS, - 25 + PANCAKESWAPV2_FACTORY_ETHEREUM, PANCAKEV2_POOL_CODE_INIT_HASH, 25 ); }