我试图用UniswapRouterV2和ethers.js将ETH替换成它在WETH中的等价物,但是我不知道在路径数组中作为ETH的地址是什么,因为它没有一个,所以请告诉我我做错了什么。
await this.uniswapRouter.swapETHForExactTokens(
ethers.provider.getBalance(attacker.addres), // amountOut
[0, this.weth.address], // path: what should it be instead of 0?
attacker.address, // to
(await ethers.provider.getBlock('latest').timestamp) * 2, // deadline
{value: ethers.provider.getBalance(attacker.addres)} // msg.value
)发布于 2022-07-01 06:47:53
刚拿到。这太简单了,根本不需要UniswapRouterV2合同。必须履行WETH合同的押金功能,并将合同退还给ETH。就像这样:
await this.weth.connect(attacker).deposit({value: ethToWETHAmount})https://stackoverflow.com/questions/72824154
复制相似问题