feat: add curve executor with router tests
Took 36 minutes Took 2 minutes
This commit is contained in:
committed by
Diana Carvalho
parent
6c679c0434
commit
7cde5130d6
43
foundry/test/CurveRouterGasTest.t.sol
Normal file
43
foundry/test/CurveRouterGasTest.t.sol
Normal file
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
pragma solidity ^0.8.26;
|
||||
|
||||
import {Constants} from "./Constants.sol";
|
||||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import {console} from "forge-std/console.sol";
|
||||
import {ICurveRouter} from "../interfaces/ICurveRouter.sol";
|
||||
|
||||
contract CurveRouterGasTest is Constants {
|
||||
ICurveRouter curveRouter = ICurveRouter(CURVE_ROUTER);
|
||||
|
||||
function setUp() public {
|
||||
uint256 forkBlock = 22031795;
|
||||
vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock);
|
||||
}
|
||||
|
||||
function testCurveRouter() public {
|
||||
address[11] memory route;
|
||||
route[0] = WETH_ADDR;
|
||||
route[1] = TRICRYPTO_USDC_WBTC_WETH;
|
||||
route[2] = USDC_ADDR;
|
||||
|
||||
uint256[5][5] memory swapParams;
|
||||
swapParams[0][0] = 2; // tokenIn Index
|
||||
swapParams[0][1] = 0; // tokenOut Index
|
||||
swapParams[0][2] = 1; // swap type
|
||||
swapParams[0][3] = 3; // pool type
|
||||
swapParams[0][4] = 3; // n_coins
|
||||
|
||||
uint256 amountIn = 1 ether;
|
||||
uint256 minAmountOut = 0;
|
||||
address[5] memory pools;
|
||||
|
||||
deal(WETH_ADDR, ALICE, amountIn);
|
||||
|
||||
vm.startPrank(ALICE);
|
||||
IERC20(WETH_ADDR).approve(address(curveRouter), amountIn);
|
||||
uint256 amountOut = curveRouter.exchange(
|
||||
route, swapParams, amountIn, minAmountOut, pools, address(this)
|
||||
);
|
||||
vm.stopPrank();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user