-
Notifications
You must be signed in to change notification settings - Fork 28
/
UniswapV2SwapAmounts.test.sol
46 lines (37 loc) · 1.45 KB
/
UniswapV2SwapAmounts.test.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import {Test, console2} from "forge-std/Test.sol";
import {IERC20} from "../../src/interfaces/IERC20.sol";
import {IWETH} from "../../src/interfaces/IWETH.sol";
import {IUniswapV2Router02} from
"../../src/interfaces/uniswap-v2/IUniswapV2Router02.sol";
import {DAI, WETH, MKR, UNISWAP_V2_ROUTER_02} from "../../src/Constants.sol";
contract UniswapV2SwapAmountsTest is Test {
IWETH private constant weth = IWETH(WETH);
IERC20 private constant dai = IERC20(DAI);
IERC20 private constant mkr = IERC20(MKR);
IUniswapV2Router02 private constant router =
IUniswapV2Router02(UNISWAP_V2_ROUTER_02);
function test_getAmountsOut() public {
address[] memory path = new address[](3);
path[0] = WETH;
path[1] = DAI;
path[2] = MKR;
uint256 amountIn = 1e18;
uint256[] memory amounts = router.getAmountsOut(amountIn, path);
console2.log("WETH", amounts[0]);
console2.log("DAI", amounts[1]);
console2.log("MKR", amounts[2]);
}
function test_getAmountsIn() public {
address[] memory path = new address[](3);
path[0] = WETH;
path[1] = DAI;
path[2] = MKR;
uint256 amountOut = 1e17;
uint256[] memory amounts = router.getAmountsIn(amountOut, path);
console2.log("WETH", amounts[0]);
console2.log("DAI", amounts[1]);
console2.log("MKR", amounts[2]);
}
}