Merge branch 'main' into router/hr/ENG-4280-gas-test
This commit is contained in:
@@ -3,12 +3,21 @@ const {ethers} = require("hardhat");
|
||||
const hre = require("hardhat");
|
||||
|
||||
// Comment out the executors you don't want to deploy
|
||||
const executors_to_deploy = [
|
||||
{exchange: "UniswapV2Executor", args: []},
|
||||
const executors_to_deploy = {
|
||||
"ethereum":[
|
||||
{exchange: "UniswapV2Executor", args: ["0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f"]},
|
||||
{exchange: "UniswapV3Executor", args: ["0x1F98431c8aD98523631AE4a59f267346ea31F984"]},
|
||||
{exchange: "UniswapV4Executor", args: ["0x000000000004444c5dc75cB358380D2e3dE08A90"]},
|
||||
{exchange: "BalancerV2Executor", args: []},
|
||||
]
|
||||
],
|
||||
"base":[
|
||||
{exchange: "UniswapV2Executor", args: ["0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6"]},
|
||||
{exchange: "UniswapV3Executor", args: ["0x33128a8fC17869897dcE68Ed026d694621f6FDfD"]},
|
||||
{exchange: "UniswapV4Executor", args: ["0x498581ff718922c3f8e6a244956af099b2652b2b"]},
|
||||
{exchange: "BalancerV2Executor", args: []},
|
||||
],
|
||||
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const network = hre.network.name;
|
||||
@@ -18,7 +27,7 @@ async function main() {
|
||||
console.log(`Deploying with account: ${deployer.address}`);
|
||||
console.log(`Account balance: ${ethers.utils.formatEther(await deployer.getBalance())} ETH`);
|
||||
|
||||
for (const executor of executors_to_deploy) {
|
||||
for (const executor of executors_to_deploy[network]) {
|
||||
const {exchange, args} = executor;
|
||||
const Executor = await ethers.getContractFactory(exchange);
|
||||
const deployedExecutor = await Executor.deploy(...args);
|
||||
|
||||
@@ -7,6 +7,7 @@ import "@uniswap-v2/contracts/interfaces/IUniswapV2Pair.sol";
|
||||
|
||||
error UniswapV2Executor__InvalidDataLength();
|
||||
error UniswapV2Executor__InvalidTarget();
|
||||
error UniswapV2Executor__InvalidFactory();
|
||||
|
||||
contract UniswapV2Executor is IExecutor {
|
||||
using SafeERC20 for IERC20;
|
||||
@@ -14,8 +15,16 @@ contract UniswapV2Executor is IExecutor {
|
||||
bytes32 internal constant POOL_INIT_CODE_HASH =
|
||||
0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f;
|
||||
|
||||
address private constant FACTORY =
|
||||
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
|
||||
address public immutable factory;
|
||||
address private immutable self;
|
||||
|
||||
constructor(address _factory) {
|
||||
if (_factory == address(0)) {
|
||||
revert UniswapV2Executor__InvalidFactory();
|
||||
}
|
||||
factory = _factory;
|
||||
self = address(this);
|
||||
}
|
||||
|
||||
// slither-disable-next-line locked-ether
|
||||
function swap(uint256 givenAmount, bytes calldata data)
|
||||
@@ -94,7 +103,7 @@ contract UniswapV2Executor is IExecutor {
|
||||
uint256(
|
||||
keccak256(
|
||||
abi.encodePacked(
|
||||
hex"ff", FACTORY, salt, POOL_INIT_CODE_HASH
|
||||
hex"ff", factory, salt, POOL_INIT_CODE_HASH
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -47,7 +47,8 @@ contract Constants is Test, BaseConstants {
|
||||
address USDC_WBTC_POOL = 0x004375Dff511095CC5A197A54140a24eFEF3A416;
|
||||
|
||||
// Uniswap v3
|
||||
address USV3_FACTORY = 0x1F98431c8aD98523631AE4a59f267346ea31F984;
|
||||
address USV3_FACTORY_ETHEREUM = 0x1F98431c8aD98523631AE4a59f267346ea31F984;
|
||||
address USV2_FACTORY_ETHEREUM = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
|
||||
address DAI_WETH_USV3 = 0xC2e9F25Be6257c210d7Adf0D4Cd6E3E881ba25f8;
|
||||
|
||||
// Uniswap universal router
|
||||
|
||||
@@ -44,7 +44,8 @@ contract TychoRouterTestSetup is Test, Constants {
|
||||
vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock);
|
||||
|
||||
vm.startPrank(ADMIN);
|
||||
address factoryV3 = USV3_FACTORY;
|
||||
address factoryV3 = USV3_FACTORY_ETHEREUM;
|
||||
address factoryV2 = USV2_FACTORY_ETHEREUM;
|
||||
address poolManagerAddress = 0x000000000004444c5dc75cB358380D2e3dE08A90;
|
||||
IPoolManager poolManager = IPoolManager(poolManagerAddress);
|
||||
tychoRouter = new TychoRouterExposed(PERMIT2_ADDRESS, WETH_ADDR);
|
||||
@@ -59,7 +60,7 @@ contract TychoRouterTestSetup is Test, Constants {
|
||||
deployDummyContract();
|
||||
vm.stopPrank();
|
||||
|
||||
usv2Executor = new UniswapV2Executor();
|
||||
usv2Executor = new UniswapV2Executor(factoryV2);
|
||||
usv3Executor = new UniswapV3Executor(factoryV3);
|
||||
usv4Executor = new UniswapV4Executor(poolManager);
|
||||
vm.startPrank(EXECUTOR_SETTER);
|
||||
|
||||
@@ -6,6 +6,8 @@ import {Test} from "../../lib/forge-std/src/Test.sol";
|
||||
import {Constants} from "../Constants.sol";
|
||||
|
||||
contract UniswapV2ExecutorExposed is UniswapV2Executor {
|
||||
constructor(address _factory) UniswapV2Executor(_factory) {}
|
||||
|
||||
function decodeParams(bytes calldata data)
|
||||
external
|
||||
pure
|
||||
@@ -42,7 +44,7 @@ contract FakeUniswapV2Pool {
|
||||
}
|
||||
}
|
||||
|
||||
contract UniswapV2ExecutorTest is UniswapV2ExecutorExposed, Test, Constants {
|
||||
contract UniswapV2ExecutorTest is Test, Constants {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
UniswapV2ExecutorExposed uniswapV2Exposed;
|
||||
@@ -52,7 +54,7 @@ contract UniswapV2ExecutorTest is UniswapV2ExecutorExposed, Test, Constants {
|
||||
function setUp() public {
|
||||
uint256 forkBlock = 17323404;
|
||||
vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock);
|
||||
uniswapV2Exposed = new UniswapV2ExecutorExposed();
|
||||
uniswapV2Exposed = new UniswapV2ExecutorExposed(USV2_FACTORY_ETHEREUM);
|
||||
}
|
||||
|
||||
function testDecodeParams() public view {
|
||||
|
||||
@@ -44,7 +44,7 @@ contract UniswapV3ExecutorTest is Test, Constants {
|
||||
uint256 forkBlock = 17323404;
|
||||
vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock);
|
||||
|
||||
uniswapV3Exposed = new UniswapV3ExecutorExposed(USV3_FACTORY);
|
||||
uniswapV3Exposed = new UniswapV3ExecutorExposed(USV3_FACTORY_ETHEREUM);
|
||||
}
|
||||
|
||||
function testDecodeParams() public view {
|
||||
|
||||
Reference in New Issue
Block a user