From 3054ca042b2f37a709d1b9060e45d93b4b7bd212 Mon Sep 17 00:00:00 2001 From: royvardhan Date: Mon, 17 Mar 2025 18:25:01 +0530 Subject: [PATCH] chore: rename ethAddress to nativeToken, update tests --- foundry/src/executors/CurveExecutor.sol | 10 +++--- foundry/test/executors/CurveExecutor.t.sol | 38 ++++++++-------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/foundry/src/executors/CurveExecutor.sol b/foundry/src/executors/CurveExecutor.sol index 0010b9a..c46a138 100644 --- a/foundry/src/executors/CurveExecutor.sol +++ b/foundry/src/executors/CurveExecutor.sol @@ -11,14 +11,14 @@ contract CurveExecutor is IExecutor { using SafeERC20 for IERC20; ICurveRouter public immutable curveRouter; - address public immutable ethAddress; + address public immutable nativeTokens; - constructor(address _curveRouter, address _ethAddress) { - if (_curveRouter == address(0) || _ethAddress == address(0)) { + constructor(address _curveRouter, address _nativeTokens) { + if (_curveRouter == address(0) || _nativeTokens == address(0)) { revert CurveExecutor__InvalidAddresses(); } curveRouter = ICurveRouter(_curveRouter); - ethAddress = _ethAddress; + nativeTokens = _nativeTokens; } // slither-disable-next-line locked-ether @@ -28,7 +28,7 @@ contract CurveExecutor is IExecutor { returns (uint256) { ICurveRouter.CurveRouterParams memory params = _decodeData(data); - if (params.route[0] != ethAddress) { + if (params.route[0] != nativeTokens) { // slither-disable-next-line unused-return IERC20(params.route[0]).approve(address(curveRouter), amountIn); diff --git a/foundry/test/executors/CurveExecutor.t.sol b/foundry/test/executors/CurveExecutor.t.sol index 9771845..0dd0e30 100644 --- a/foundry/test/executors/CurveExecutor.t.sol +++ b/foundry/test/executors/CurveExecutor.t.sol @@ -13,16 +13,14 @@ interface ICurvePool { // This is the registry that contains the information about the pool // The naming convention is different because it is in vyper interface MetaRegistry { - // Get the number of coins in the pool function get_n_coins(address pool) external view returns (uint256); - // Get the indices of the coins in the pool + function get_coin_indices(address pool, address from, address to) external view returns (int128, int128, bool); } -// Aave lending pool interface IAaveLendingPool { function deposit( address asset, @@ -37,8 +35,8 @@ interface IAaveLendingPool { } contract CurveExecutorExposed is CurveExecutor { - constructor(address _curveRouter, address _ethAddress) - CurveExecutor(_curveRouter, _ethAddress) + constructor(address _curveRouter, address _nativeToken) + CurveExecutor(_curveRouter, _nativeToken) {} function decodeParams(bytes calldata data) @@ -134,8 +132,8 @@ contract CurveExecutorTest is Test, Constants { uint256 amountOut = curveExecutorExposed.swap(amountIn, data); - assertTrue(amountOut >= 1 ether); - assertEq(IERC20(STETH_ADDR).balanceOf(address(this)), amountOut - 1); // Gets 1 wei less than amountOut + assertTrue(amountOut == 1 ether - 1); //// Gets 1 wei less than amountOut + assertEq(IERC20(STETH_ADDR).balanceOf(address(this)), amountOut - 1); } function testSwapTricrypto2Pool() public { @@ -224,10 +222,9 @@ contract CurveExecutorTest is Test, Constants { ); } - // The following pool is from CryptoSwapNG, deployed by factory 0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf - // - It is a plain pool - function testSwapUsdeUsdcPool() public { + // The following pool is from CryptoSwapNG, deployed by factory 0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf + // - It is a plain pool address[11] memory route = _getRoute(USDC_ADDR, USDE_ADDR, USDE_USDC_POOL); uint256[5][5] memory swapParams = @@ -256,10 +253,9 @@ contract CurveExecutorTest is Test, Constants { ); } - // The following pool is from CryptoSwapNG, deployed by factory 0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf - // - It is a meta pool - function testSwapDolaFraxPyusdPool() public { + // The following pool is from CryptoSwapNG, deployed by factory 0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf + // - It is a meta pool address[11] memory route = _getRoute(DOLA_ADDR, FRAXPYUSD_POOL, DOLA_FRAXPYUSD_POOL); uint256[5][5] memory swapParams = @@ -288,9 +284,8 @@ contract CurveExecutorTest is Test, Constants { ); } - // The following pool is from CryptoPool, deployed by factory 0xF18056Bbd320E96A48e3Fbf8bC061322531aac99 - function testSwapWethXyoPool() public { + // The following pool is from CryptoPool, deployed by factory 0xF18056Bbd320E96A48e3Fbf8bC061322531aac99 address[11] memory route = _getRoute(XYO_ADDR, WETH_ADDR, WETH_XYO_POOL); uint256[5][5] memory swapParams = _getSwapParams(WETH_XYO_POOL, XYO_ADDR, WETH_ADDR, 1, 2); @@ -318,9 +313,8 @@ contract CurveExecutorTest is Test, Constants { ); } - // The following pool is from Tricrypto, deployed by factory 0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963 - function testSwapTricryptoPool() public { + // The following pool is from Tricrypto, deployed by factory 0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963 address[11] memory route = _getRoute(WETH_ADDR, USDC_ADDR, TRICRYPTO_POOL); uint256[5][5] memory swapParams = @@ -341,9 +335,8 @@ contract CurveExecutorTest is Test, Constants { assertEq(IERC20(USDC_ADDR).balanceOf(address(this)), amountOut); } - // The following pool is from Twocrypto, deployed by factory 0x98ee851a00abee0d95d08cf4ca2bdce32aeaaf7f - function testSwapUwuWethPool() public { + // The following pool is from Twocrypto, deployed by factory 0x98ee851a00abee0d95d08cf4ca2bdce32aeaaf7f address[11] memory route = _getRoute(UWU_ADDR, WETH_ADDR, UWU_WETH_POOL); uint256[5][5] memory swapParams = _getSwapParams(UWU_WETH_POOL, UWU_ADDR, WETH_ADDR, 1, 2); @@ -371,10 +364,9 @@ contract CurveExecutorTest is Test, Constants { ); } - // The following pool is from StableSwap, deployed by factory 0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d - // - It is a plain pool - function testSwapCrvusdUsdtPool() public { + // The following pool is from StableSwap, deployed by factory 0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d + // - It is a plain pool address[11] memory route = _getRoute(CRVUSD_ADDR, USDT_ADDR, CRVUSD_USDT_POOL); uint256[5][5] memory swapParams = @@ -403,8 +395,6 @@ contract CurveExecutorTest is Test, Constants { ); } - // The following pools were taken from the old curve executor tests - function testSwapAavePool() public { address[11] memory route = _getRoute(ADAI_ADDR, AUSDC_ADDR, AAVE_POOL); uint256[5][5] memory swapParams =