forked from Cyfrin/advanced-defi-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUniswapV2Factory.test.sol
43 lines (37 loc) · 1.37 KB
/
UniswapV2Factory.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
// 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 {IUniswapV2Factory} from
"../../../src/interfaces/uniswap-v2/IUniswapV2Factory.sol";
import {IUniswapV2Pair} from
"../../../src/interfaces/uniswap-v2/IUniswapV2Pair.sol";
import {
DAI,
WETH,
UNISWAP_V2_PAIR_DAI_WETH,
UNISWAP_V2_FACTORY
} from "../../../src/Constants.sol";
import {ERC20} from "../../../src/ERC20.sol";
contract UniswapV2FactoryTest is Test {
IWETH private constant weth = IWETH(WETH);
IUniswapV2Factory private constant factory =
IUniswapV2Factory(UNISWAP_V2_FACTORY);
function test_createPair() public {
ERC20 token = new ERC20("test", "TEST", 18);
// Exercise - deploy token + WETH pair contract
// Write your code here
// Don’t change any other code
address pair;
address token0 = IUniswapV2Pair(pair).token0();
address token1 = IUniswapV2Pair(pair).token1();
if (address(token) < WETH) {
assertEq(token0, address(token), "token 0");
assertEq(token1, WETH, "token 1");
} else {
assertEq(token0, WETH, "token 0");
assertEq(token1, address(token), "token 1");
}
}
}