Merge branch 'refs/heads/main' into feature/gas-optimization
# Conflicts: # foundry/test/TychoRouter.t.sol # src/encoding/evm/strategy_encoder/strategy_encoders.rs # src/encoding/evm/utils.rs Took 3 minutes Took 35 seconds
This commit is contained in:
@@ -30,7 +30,8 @@ contract Constants is Test, BaseConstants {
|
||||
address UNPAUSER = makeAddr("unpauser");
|
||||
|
||||
// Assets
|
||||
address ETH_ADDR = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
|
||||
address ETH_ADDR_FOR_CURVE =
|
||||
address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
|
||||
address WETH_ADDR = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
|
||||
address DAI_ADDR = address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
|
||||
address BAL_ADDR = address(0xba100000625a3754423978a60c9317c58a424e3D);
|
||||
|
||||
@@ -212,4 +212,33 @@ contract TychoRouterTest is TychoRouterTestSetup {
|
||||
vm.expectRevert(TychoRouter__EmptySwaps.selector);
|
||||
tychoRouter.exposedSplitSwap(amountIn, 2, swaps);
|
||||
}
|
||||
|
||||
function testCurveIntegration() public {
|
||||
deal(UWU_ADDR, ALICE, 1 ether);
|
||||
|
||||
vm.startPrank(ALICE);
|
||||
IERC20(UWU_ADDR).approve(tychoRouterAddr, type(uint256).max);
|
||||
// Encoded solution generated using `test_split_encoding_strategy_curve`
|
||||
(bool success,) = tychoRouterAddr.call(
|
||||
hex"0a83cb080000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000055c08ca52497e2f1534b59e2917bf524d4765257000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc20000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000005b005900010000001d1499e622d69689cdf9004d05ec547d650ff21155c08ca52497e2f1534b59e2917bf524d4765257c02aaa39b223fe8d0a0e5c4f27ead9083c756cc277146b0a1d08b6844376df6d9da99ba7f1b19e71020100010000000000"
|
||||
);
|
||||
|
||||
assertEq(IERC20(WETH_ADDR).balanceOf(ALICE), 4691958787921);
|
||||
|
||||
vm.stopPrank();
|
||||
}
|
||||
|
||||
function testCurveIntegrationStETH() public {
|
||||
deal(ALICE, 1 ether);
|
||||
|
||||
vm.startPrank(ALICE);
|
||||
// Encoded solution generated using `test_split_encoding_strategy_curve_st_eth`
|
||||
(bool success,) = tychoRouterAddr.call{value: 1 ether}(
|
||||
hex"0a83cb080000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe840000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc20000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000005b005900010000001d1499e622d69689cdf9004d05ec547d650ff211eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeae7ab96520de3a18e5e111b5eaab095312d7fe84dc24316b9ae028f1497c275eb9192a3ea0f67022010001000000000000"
|
||||
);
|
||||
|
||||
assertEq(IERC20(STETH_ADDR).balanceOf(ALICE), 1000754689941529590);
|
||||
|
||||
vm.stopPrank();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
pragma solidity ^0.8.26;
|
||||
|
||||
import "../src/executors/BalancerV2Executor.sol";
|
||||
import "../src/executors/CurveExecutor.sol";
|
||||
import "../src/executors/EkuboExecutor.sol";
|
||||
import "../src/executors/UniswapV2Executor.sol";
|
||||
import "../src/executors/UniswapV3Executor.sol";
|
||||
@@ -49,6 +50,7 @@ contract TychoRouterTestSetup is Constants {
|
||||
UniswapV4Executor public usv4Executor;
|
||||
BalancerV2Executor public balancerv2Executor;
|
||||
EkuboExecutor public ekuboExecutor;
|
||||
CurveExecutor public curveExecutor;
|
||||
MockERC20[] tokens;
|
||||
|
||||
function setUp() public {
|
||||
@@ -103,14 +105,16 @@ contract TychoRouterTestSetup is Constants {
|
||||
new UniswapV3Executor(factoryPancakeV3, initCodePancakeV3);
|
||||
balancerv2Executor = new BalancerV2Executor();
|
||||
ekuboExecutor = new EkuboExecutor(ekuboCore);
|
||||
curveExecutor = new CurveExecutor(ETH_ADDR_FOR_CURVE);
|
||||
|
||||
address[] memory executors = new address[](6);
|
||||
address[] memory executors = new address[](7);
|
||||
executors[0] = address(usv2Executor);
|
||||
executors[1] = address(usv3Executor);
|
||||
executors[2] = address(pancakev3Executor);
|
||||
executors[3] = address(usv4Executor);
|
||||
executors[4] = address(balancerv2Executor);
|
||||
executors[5] = address(ekuboExecutor);
|
||||
executors[6] = address(curveExecutor);
|
||||
return executors;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,19 +21,6 @@ interface MetaRegistry {
|
||||
returns (int128, int128, bool);
|
||||
}
|
||||
|
||||
interface IAaveLendingPool {
|
||||
function deposit(
|
||||
address asset,
|
||||
uint256 amount,
|
||||
address onBehalfOf,
|
||||
uint16 referralCode
|
||||
) external;
|
||||
|
||||
function withdraw(address asset, uint256 amount, address to)
|
||||
external
|
||||
returns (uint256);
|
||||
}
|
||||
|
||||
contract CurveExecutorExposed is CurveExecutor {
|
||||
constructor(address _nativeToken) CurveExecutor(_nativeToken) {}
|
||||
|
||||
@@ -63,7 +50,7 @@ contract CurveExecutorTest is Test, Constants {
|
||||
function setUp() public {
|
||||
uint256 forkBlock = 22031795;
|
||||
vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock);
|
||||
curveExecutorExposed = new CurveExecutorExposed(ETH_ADDR);
|
||||
curveExecutorExposed = new CurveExecutorExposed(ETH_ADDR_FOR_CURVE);
|
||||
metaRegistry = MetaRegistry(CURVE_META_REGISTRY);
|
||||
}
|
||||
|
||||
@@ -118,7 +105,8 @@ contract CurveExecutorTest is Test, Constants {
|
||||
uint256 amountIn = 1 ether;
|
||||
deal(address(curveExecutorExposed), amountIn);
|
||||
|
||||
bytes memory data = _getData(ETH_ADDR, STETH_ADDR, STETH_POOL, 1);
|
||||
bytes memory data =
|
||||
_getData(ETH_ADDR_FOR_CURVE, STETH_ADDR, STETH_POOL, 1);
|
||||
|
||||
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
|
||||
|
||||
@@ -216,7 +204,8 @@ contract CurveExecutorTest is Test, Constants {
|
||||
uint256 initialBalance = address(curveExecutorExposed).balance; // this address already has some ETH assigned to it
|
||||
deal(XYO_ADDR, address(curveExecutorExposed), amountIn);
|
||||
|
||||
bytes memory data = _getData(XYO_ADDR, ETH_ADDR, ETH_XYO_POOL, 2);
|
||||
bytes memory data =
|
||||
_getData(XYO_ADDR, ETH_ADDR_FOR_CURVE, ETH_XYO_POOL, 2);
|
||||
|
||||
uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user