From 3a08c0d71dabe5406de6816a83341fa462bac11b Mon Sep 17 00:00:00 2001 From: royvardhan Date: Wed, 19 Mar 2025 22:55:56 +0530 Subject: [PATCH] test: test two more pool types --- foundry/test/Constants.sol | 6 ++- foundry/test/executors/CurveExecutor.t.sol | 51 +++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/foundry/test/Constants.sol b/foundry/test/Constants.sol index a6905d6..c1d0217 100644 --- a/foundry/test/Constants.sol +++ b/foundry/test/Constants.sol @@ -52,7 +52,9 @@ contract Constants is Test, BaseConstants { address XYO_ADDR = address(0x55296f69f40Ea6d20E478533C15A6B08B654E758); address UWU_ADDR = address(0x55C08ca52497e2f1534B59E2917BF524D4765257); address CRVUSD_ADDR = address(0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E); - + address WSTTAO_ADDR = address(0xe9633C52f4c8B7BDeb08c4A7fE8a5c1B84AFCf67); + address WTAO_ADDR = address(0x77E06c9eCCf2E797fd462A92B6D7642EF85b0A44); + address BSGG_ADDR = address(0xdA16Cf041E2780618c49Dbae5d734B89a6Bac9b3); // Uniswap v2 address WETH_DAI_POOL = 0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11; address DAI_USDC_POOL = 0xAE461cA67B15dc8dc81CE7615e0320dA1A9aB8D5; @@ -107,6 +109,8 @@ contract Constants is Test, BaseConstants { address WETH_XYO_POOL = 0x99e09ee2d6Bb16c0F5ADDfEA649dbB2C1d524624; address UWU_WETH_POOL = 0x77146B0a1d08B6844376dF6d9da99bA7F1b19e71; address CRVUSD_USDT_POOL = 0x390f3595bCa2Df7d23783dFd126427CCeb997BF4; + address WSTTAO_WTAO_POOL = 0xf2DCf6336D8250754B4527f57b275b19c8D5CF88; + address BSGG_USDT_POOL = 0x5500307Bcf134E5851FB4D7D8D1Dc556dCdB84B4; // Uniswap universal router address UNIVERSAL_ROUTER = 0x66a9893cC07D91D95644AEDD05D03f95e1dBA8Af; diff --git a/foundry/test/executors/CurveExecutor.t.sol b/foundry/test/executors/CurveExecutor.t.sol index 430e720..e4327d3 100644 --- a/foundry/test/executors/CurveExecutor.t.sol +++ b/foundry/test/executors/CurveExecutor.t.sol @@ -252,7 +252,7 @@ contract CurveExecutorTest is Test, Constants { } function testSwapWethXyoPool() public { - // The following pool is from CryptoPool, deployed by factory 0xF18056Bbd320E96A48e3Fbf8bC061322531aac99 + // The following pool is from CryptoPool, deployed by factory 0xF18056Bbd320E96A48e3Fbf8bC061322531aac99 - with ETH 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); @@ -342,6 +342,55 @@ contract CurveExecutorTest is Test, Constants { ); } + function testSwapWsttaoWtaoPool() public { + // The following pool is deployed by factory 0xB9fC157394Af804a3578134A6585C0dc9cc990d4 + // - It is a plain pool + address[11] memory route = + _getRoute(WTAO_ADDR, WSTTAO_ADDR, WSTTAO_WTAO_POOL); + uint256[5][5] memory swapParams = + _getSwapParams(WSTTAO_WTAO_POOL, WTAO_ADDR, WSTTAO_ADDR, 1, 1); + + uint256 amountIn = 100 * 10 ** 9; // 9 decimals + uint256 minAmountOut = 0; + + deal(WTAO_ADDR, address(curveExecutorExposed), amountIn); + bytes memory data = abi.encode( + route, swapParams, minAmountOut, address(curveExecutorExposed), true + ); + + uint256 amountOut = curveExecutorExposed.swap(amountIn, data); + + assertEq(amountOut, 32797923609); + assertEq( + IERC20(WSTTAO_ADDR).balanceOf(address(curveExecutorExposed)), + amountOut + ); + } + + function testSwapBsggUsdtPool() public { + // The following pool is from CryptoPool, deployed by factory 0xF18056Bbd320E96A48e3Fbf8bC061322531aac99 + address[11] memory route = + _getRoute(BSGG_ADDR, USDT_ADDR, BSGG_USDT_POOL); + uint256[5][5] memory swapParams = + _getSwapParams(BSGG_USDT_POOL, BSGG_ADDR, USDT_ADDR, 1, 2); + + uint256 amountIn = 1000 ether; + uint256 minAmountOut = 0; + + deal(BSGG_ADDR, address(curveExecutorExposed), amountIn); + bytes memory data = abi.encode( + route, swapParams, minAmountOut, address(curveExecutorExposed), true + ); + + uint256 amountOut = curveExecutorExposed.swap(amountIn, data); + + assertEq(amountOut, 23429); + assertEq( + IERC20(USDT_ADDR).balanceOf(address(curveExecutorExposed)), + amountOut + ); + } + function _getRoute(address tokenIn, address tokenOut, address pool) internal pure