我试过:
parseInt(reserve0, 16))和parseInt(reserve1, 16))将这些储备从十六进制转换为十进制但我犯了以下错误:
const maxAmount = await uniswapV2Router2.getAmountIn(1, reserve0, reserve1); // amount of MKR for 1 DAI
^
TypeError: uniswapV2Router2.getAmountIn is not a function发布于 2022-06-03 08:17:50
我猜这个错误是由您的路由器abi或路由器地址错误引起的,因为我没有关于前面代码的信息,所以我只能推测它。
但是代码中有几个明显的错误
你应该改变这个
const maxAmount = await uniswapV2Router2.getAmountIn(1, reserve0, reserve1); // amount of MKR for 1 DAI
至
const maxAmount = await uniswapV2Router2.getAmountIn(1, [reserve0, reserve1]); // amount of MKR for 1 DAI。
因为储备0,储备1是一个数组:)
https://ethereum.stackexchange.com/questions/125228
复制相似问题