It seems that like big part of the test file (free-rider.challenge.js
) in free rider exercise is not used.
This code can be removed:
// Deploy WETH
weth = await (await ethers.getContractFactory('WETH', deployer)).deploy();
// Deploy token to be traded against WETH in Uniswap v2
token = await (await ethers.getContractFactory('DamnValuableToken', deployer)).deploy();
// Deploy Uniswap Factory and Router
uniswapFactory = await (new ethers.ContractFactory(factoryJson.abi, factoryJson.bytecode, deployer)).deploy(
ethers.constants.AddressZero // _feeToSetter
);
uniswapRouter = await (new ethers.ContractFactory(routerJson.abi, routerJson.bytecode, deployer)).deploy(
uniswapFactory.address,
weth.address
);
// Approve tokens, and then create Uniswap v2 pair against WETH and add liquidity
// The function takes care of deploying the pair automatically
await token.approve(
uniswapRouter.address,
UNISWAP_INITIAL_TOKEN_RESERVE
);
await uniswapRouter.addLiquidityETH(
token.address, // token to be traded against WETH
UNISWAP_INITIAL_TOKEN_RESERVE, // amountTokenDesired
0, // amountTokenMin
0, // amountETHMin
deployer.address, // to
(await ethers.provider.getBlock('latest')).timestamp * 2, // deadline
{ value: UNISWAP_INITIAL_WETH_RESERVE }
);
// Get a reference to the created Uniswap pair
uniswapPair = await (new ethers.ContractFactory(pairJson.abi, pairJson.bytecode, deployer)).attach(
await uniswapFactory.getPair(token.address, weth.address)
);
expect(await uniswapPair.token0()).to.eq(weth.address);
expect(await uniswapPair.token1()).to.eq(token.address);
expect(await uniswapPair.balanceOf(deployer.address)).to.be.gt(0);
WETH and DVT are being deployed, then a Uniswap Factory and router and then we're adding liquidity to uniswap, even though the exercise has nothing to do with WETH, DVT, and Uniswap.
The exercise is about an NFT marketplace and the payments are in native ETH.