-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRouter.test.js
More file actions
23 lines (19 loc) · 995 Bytes
/
Copy pathRouter.test.js
File metadata and controls
23 lines (19 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
it("multi-hop swap A -> B -> C", async function () {
const { owner, tokenA, tokenB, router, factory } = await deployAll();
// Dodajemy trzeci token
const ERC20Mock = await ethers.getContractFactory("ERC20Mock");
const tokenC = await ERC20Mock.deploy("TokenC", "TKC");
await tokenC.mint(owner.address, ethers.parseEther("100000"));
await tokenC.approve(router.address, ethers.MaxUint256);
// Tworzymy pary
await router.addLiquidity(tokenA.target, tokenB.target, ethers.parseEther("1000"), ethers.parseEther("1000"), owner.address);
await router.addLiquidity(tokenB.target, tokenC.target, ethers.parseEther("1000"), ethers.parseEther("1000"), owner.address);
// Multi-hop A -> B -> C
await router.swapExactTokensForTokensMulti(
ethers.parseEther("100"),
0,
[tokenA.target, tokenB.target, tokenC.target],
owner.address
);
expect(await tokenC.balanceOf(owner.address)).to.be.gt(ethers.parseEther("99000"));
});