feat: Support sushiswap v2 and pancakeswap v2 on ethereum

- Needed to take pool code init hash as input param for executors
- Added tests for ethereum. Will test base on-chain.
This commit is contained in:
TAMARA LIPOWSKI
2025-03-19 14:27:34 -04:00
parent 5a6433caf1
commit 0a8a34be03
5 changed files with 86 additions and 13 deletions

View File

@@ -6,7 +6,9 @@ import {Test} from "../../lib/forge-std/src/Test.sol";
import {Constants} from "../Constants.sol";
contract UniswapV2ExecutorExposed is UniswapV2Executor {
constructor(address _factory) UniswapV2Executor(_factory) {}
constructor(address _factory, bytes32 _init_code)
UniswapV2Executor(_factory, _init_code)
{}
function decodeParams(bytes calldata data)
external
@@ -48,13 +50,23 @@ contract UniswapV2ExecutorTest is Test, Constants {
using SafeERC20 for IERC20;
UniswapV2ExecutorExposed uniswapV2Exposed;
UniswapV2ExecutorExposed sushiswapV2Exposed;
UniswapV2ExecutorExposed pancakeswapV2Exposed;
IERC20 WETH = IERC20(WETH_ADDR);
IERC20 DAI = IERC20(DAI_ADDR);
function setUp() public {
uint256 forkBlock = 17323404;
vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock);
uniswapV2Exposed = new UniswapV2ExecutorExposed(USV2_FACTORY_ETHEREUM);
uniswapV2Exposed = new UniswapV2ExecutorExposed(
USV2_FACTORY_ETHEREUM, USV2_POOL_CODE_INIT_HASH
);
sushiswapV2Exposed = new UniswapV2ExecutorExposed(
SUSHISWAPV2_FACTORY_ETHEREUM, SUSHIV2_POOL_CODE_INIT_HASH
);
pancakeswapV2Exposed = new UniswapV2ExecutorExposed(
PANCAKESWAPV2_FACTORY_ETHEREUM, PANCAKEV2_POOL_CODE_INIT_HASH
);
}
function testDecodeParams() public view {
@@ -82,6 +94,14 @@ contract UniswapV2ExecutorTest is Test, Constants {
uniswapV2Exposed.verifyPairAddress(WETH_DAI_POOL);
}
function testVerifyPairAddressSushi() public view {
sushiswapV2Exposed.verifyPairAddress(SUSHISWAP_WBTC_WETH_POOL);
}
function testVerifyPairAddressPancake() public view {
pancakeswapV2Exposed.verifyPairAddress(PANCAKESWAP_WBTC_WETH_POOL);
}
function testInvalidTarget() public {
address fakePool = address(new FakeUniswapV2Pool(WETH_ADDR, DAI_ADDR));
vm.expectRevert(UniswapV2Executor__InvalidTarget.selector);