chore: rename ethAddress to nativeToken, update tests

This commit is contained in:
royvardhan
2025-03-17 18:25:01 +05:30
committed by Diana Carvalho
parent 05ea2c7734
commit 3054ca042b
2 changed files with 19 additions and 29 deletions

View File

@@ -11,14 +11,14 @@ contract CurveExecutor is IExecutor {
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
ICurveRouter public immutable curveRouter; ICurveRouter public immutable curveRouter;
address public immutable ethAddress; address public immutable nativeTokens;
constructor(address _curveRouter, address _ethAddress) { constructor(address _curveRouter, address _nativeTokens) {
if (_curveRouter == address(0) || _ethAddress == address(0)) { if (_curveRouter == address(0) || _nativeTokens == address(0)) {
revert CurveExecutor__InvalidAddresses(); revert CurveExecutor__InvalidAddresses();
} }
curveRouter = ICurveRouter(_curveRouter); curveRouter = ICurveRouter(_curveRouter);
ethAddress = _ethAddress; nativeTokens = _nativeTokens;
} }
// slither-disable-next-line locked-ether // slither-disable-next-line locked-ether
@@ -28,7 +28,7 @@ contract CurveExecutor is IExecutor {
returns (uint256) returns (uint256)
{ {
ICurveRouter.CurveRouterParams memory params = _decodeData(data); ICurveRouter.CurveRouterParams memory params = _decodeData(data);
if (params.route[0] != ethAddress) { if (params.route[0] != nativeTokens) {
// slither-disable-next-line unused-return // slither-disable-next-line unused-return
IERC20(params.route[0]).approve(address(curveRouter), amountIn); IERC20(params.route[0]).approve(address(curveRouter), amountIn);

View File

@@ -13,16 +13,14 @@ interface ICurvePool {
// This is the registry that contains the information about the pool // This is the registry that contains the information about the pool
// The naming convention is different because it is in vyper // The naming convention is different because it is in vyper
interface MetaRegistry { interface MetaRegistry {
// Get the number of coins in the pool
function get_n_coins(address pool) external view returns (uint256); 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) function get_coin_indices(address pool, address from, address to)
external external
view view
returns (int128, int128, bool); returns (int128, int128, bool);
} }
// Aave lending pool
interface IAaveLendingPool { interface IAaveLendingPool {
function deposit( function deposit(
address asset, address asset,
@@ -37,8 +35,8 @@ interface IAaveLendingPool {
} }
contract CurveExecutorExposed is CurveExecutor { contract CurveExecutorExposed is CurveExecutor {
constructor(address _curveRouter, address _ethAddress) constructor(address _curveRouter, address _nativeToken)
CurveExecutor(_curveRouter, _ethAddress) CurveExecutor(_curveRouter, _nativeToken)
{} {}
function decodeParams(bytes calldata data) function decodeParams(bytes calldata data)
@@ -134,8 +132,8 @@ contract CurveExecutorTest is Test, Constants {
uint256 amountOut = curveExecutorExposed.swap(amountIn, data); uint256 amountOut = curveExecutorExposed.swap(amountIn, data);
assertTrue(amountOut >= 1 ether); assertTrue(amountOut == 1 ether - 1); //// Gets 1 wei less than amountOut
assertEq(IERC20(STETH_ADDR).balanceOf(address(this)), amountOut - 1); // Gets 1 wei less than amountOut assertEq(IERC20(STETH_ADDR).balanceOf(address(this)), amountOut - 1);
} }
function testSwapTricrypto2Pool() public { 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 { function testSwapUsdeUsdcPool() public {
// The following pool is from CryptoSwapNG, deployed by factory 0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf
// - It is a plain pool
address[11] memory route = address[11] memory route =
_getRoute(USDC_ADDR, USDE_ADDR, USDE_USDC_POOL); _getRoute(USDC_ADDR, USDE_ADDR, USDE_USDC_POOL);
uint256[5][5] memory swapParams = 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 { function testSwapDolaFraxPyusdPool() public {
// The following pool is from CryptoSwapNG, deployed by factory 0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf
// - It is a meta pool
address[11] memory route = address[11] memory route =
_getRoute(DOLA_ADDR, FRAXPYUSD_POOL, DOLA_FRAXPYUSD_POOL); _getRoute(DOLA_ADDR, FRAXPYUSD_POOL, DOLA_FRAXPYUSD_POOL);
uint256[5][5] memory swapParams = 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 { 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); address[11] memory route = _getRoute(XYO_ADDR, WETH_ADDR, WETH_XYO_POOL);
uint256[5][5] memory swapParams = uint256[5][5] memory swapParams =
_getSwapParams(WETH_XYO_POOL, XYO_ADDR, WETH_ADDR, 1, 2); _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 { function testSwapTricryptoPool() public {
// The following pool is from Tricrypto, deployed by factory 0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963
address[11] memory route = address[11] memory route =
_getRoute(WETH_ADDR, USDC_ADDR, TRICRYPTO_POOL); _getRoute(WETH_ADDR, USDC_ADDR, TRICRYPTO_POOL);
uint256[5][5] memory swapParams = uint256[5][5] memory swapParams =
@@ -341,9 +335,8 @@ contract CurveExecutorTest is Test, Constants {
assertEq(IERC20(USDC_ADDR).balanceOf(address(this)), amountOut); assertEq(IERC20(USDC_ADDR).balanceOf(address(this)), amountOut);
} }
// The following pool is from Twocrypto, deployed by factory 0x98ee851a00abee0d95d08cf4ca2bdce32aeaaf7f
function testSwapUwuWethPool() public { 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); address[11] memory route = _getRoute(UWU_ADDR, WETH_ADDR, UWU_WETH_POOL);
uint256[5][5] memory swapParams = uint256[5][5] memory swapParams =
_getSwapParams(UWU_WETH_POOL, UWU_ADDR, WETH_ADDR, 1, 2); _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 { function testSwapCrvusdUsdtPool() public {
// The following pool is from StableSwap, deployed by factory 0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d
// - It is a plain pool
address[11] memory route = address[11] memory route =
_getRoute(CRVUSD_ADDR, USDT_ADDR, CRVUSD_USDT_POOL); _getRoute(CRVUSD_ADDR, USDT_ADDR, CRVUSD_USDT_POOL);
uint256[5][5] memory swapParams = 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 { function testSwapAavePool() public {
address[11] memory route = _getRoute(ADAI_ADDR, AUSDC_ADDR, AAVE_POOL); address[11] memory route = _getRoute(ADAI_ADDR, AUSDC_ADDR, AAVE_POOL);
uint256[5][5] memory swapParams = uint256[5][5] memory swapParams =