feat: Fix rollFork usage for Ekubo test

- Created methods to deploy the router and the executors. Whenever we use rollFork we need to redeploy everything! Notice that the addresses will be different then!
- Created a test_executor_addresses.json to be used in the encoding tests, this way the calldata for the integration tests is already correct and we don't need to do any manual replacing (this was annoying). The addresses in this file match with the addresses used in the solidity tests

--- don't change below this line ---
ENG-4411 Took 1 hour 9 minutes

Took 28 minutes


Took 4 minutes

Took 45 minutes
This commit is contained in:
Diana Carvalho
2025-04-01 13:14:58 +01:00
parent 69f4e748b5
commit 6cdca8381e
4 changed files with 91 additions and 87 deletions

View File

@@ -1,6 +1,8 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;
import "../src/executors/BalancerV2Executor.sol";
import "../src/executors/EkuboExecutor.sol";
import "../src/executors/UniswapV2Executor.sol";
import "../src/executors/UniswapV3Executor.sol";
import "../src/executors/UniswapV4Executor.sol";
@@ -8,9 +10,8 @@ import "./Constants.sol";
import "./mock/MockERC20.sol";
import "@src/TychoRouter.sol";
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {WETH} from "../lib/permit2/lib/solmate/src/tokens/WETH.sol";
import {PoolManager} from "@uniswap/v4-core/src/PoolManager.sol";
import "../src/executors/EkuboExecutor.sol";
import {WETH} from "../lib/permit2/lib/solmate/src/tokens/WETH.sol";
contract TychoRouterExposed is TychoRouter {
constructor(address _permit2, address weth) TychoRouter(_permit2, weth) {}
@@ -39,6 +40,7 @@ contract TychoRouterTestSetup is Test, Constants {
UniswapV3Executor public usv3Executor;
UniswapV3Executor public pancakev3Executor;
UniswapV4Executor public usv4Executor;
BalancerV2Executor public balancerv2Executor;
EkuboExecutor public ekuboExecutor;
MockERC20[] tokens;
@@ -47,6 +49,36 @@ contract TychoRouterTestSetup is Test, Constants {
vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock);
vm.startPrank(ADMIN);
tychoRouter = deployRouter();
deployDummyContract();
vm.stopPrank();
address[] memory executors = deployExecutors();
vm.startPrank(EXECUTOR_SETTER);
tychoRouter.setExecutors(executors);
vm.stopPrank();
vm.startPrank(BOB);
tokens.push(new MockERC20("Token A", "A"));
tokens.push(new MockERC20("Token B", "B"));
tokens.push(new MockERC20("Token C", "C"));
vm.stopPrank();
}
function deployRouter() public returns (TychoRouterExposed) {
tychoRouter = new TychoRouterExposed(PERMIT2_ADDRESS, WETH_ADDR);
tychoRouterAddr = address(tychoRouter);
tychoRouter.grantRole(keccak256("FUND_RESCUER_ROLE"), FUND_RESCUER);
tychoRouter.grantRole(keccak256("FEE_SETTER_ROLE"), FEE_SETTER);
tychoRouter.grantRole(keccak256("PAUSER_ROLE"), PAUSER);
tychoRouter.grantRole(keccak256("UNPAUSER_ROLE"), UNPAUSER);
tychoRouter.grantRole(
keccak256("EXECUTOR_SETTER_ROLE"), EXECUTOR_SETTER
);
return tychoRouter;
}
function deployExecutors() public returns (address[] memory) {
address factoryV2 = USV2_FACTORY_ETHEREUM;
address factoryV3 = USV3_FACTORY_ETHEREUM;
address factoryPancakeV3 = PANCAKESWAPV3_DEPLOYER_ETHEREUM;
@@ -57,40 +89,22 @@ contract TychoRouterTestSetup is Test, Constants {
address ekuboCore = 0xe0e0e08A6A4b9Dc7bD67BCB7aadE5cF48157d444;
IPoolManager poolManager = IPoolManager(poolManagerAddress);
tychoRouter = new TychoRouterExposed(PERMIT2_ADDRESS, WETH_ADDR);
tychoRouterAddr = address(tychoRouter);
tychoRouter.grantRole(keccak256("FUND_RESCUER_ROLE"), FUND_RESCUER);
tychoRouter.grantRole(keccak256("FEE_SETTER_ROLE"), FEE_SETTER);
tychoRouter.grantRole(keccak256("PAUSER_ROLE"), PAUSER);
tychoRouter.grantRole(keccak256("UNPAUSER_ROLE"), UNPAUSER);
tychoRouter.grantRole(
keccak256("EXECUTOR_SETTER_ROLE"), EXECUTOR_SETTER
);
deployDummyContract();
vm.stopPrank();
usv2Executor = new UniswapV2Executor(factoryV2, initCodeV2);
usv3Executor = new UniswapV3Executor(factoryV3, initCodeV3);
usv4Executor = new UniswapV4Executor(poolManager);
pancakev3Executor =
new UniswapV3Executor(factoryPancakeV3, initCodePancakeV3);
balancerv2Executor = new BalancerV2Executor();
ekuboExecutor = new EkuboExecutor(ekuboCore);
vm.startPrank(EXECUTOR_SETTER);
address[] memory executors = new address[](5);
address[] memory executors = new address[](6);
executors[0] = address(usv2Executor);
executors[1] = address(usv3Executor);
executors[2] = address(pancakev3Executor);
executors[3] = address(usv4Executor);
executors[4] = address(ekuboExecutor);
tychoRouter.setExecutors(executors);
vm.stopPrank();
vm.startPrank(BOB);
tokens.push(new MockERC20("Token A", "A"));
tokens.push(new MockERC20("Token B", "B"));
tokens.push(new MockERC20("Token C", "C"));
vm.stopPrank();
executors[4] = address(balancerv2Executor);
executors[5] = address(ekuboExecutor);
return executors;
}
/**