0

I tried:

  • getting pair of DAI-MKR pair from factory contract (using address, ABI, Infura RPC provider)

  • Used this pair contract to get reserves. converted these reserves from hex to decimal using parseInt(reserve0, 16)) and parseInt(reserve1, 16))

  • used these in the router contract:

    const uniswapV2Router2 = (uniswapV2Router2_add, uniswapV2Router2_ABI, provider) const maxAmount = await uniswapV2Router2.getAmountIn(1, reserve0, reserve1)

But I got following error:

const maxAmount = await uniswapV2Router2.getAmountIn(1, reserve0, reserve1); // amount of MKR for 1 DAI
                                             ^

TypeError: uniswapV2Router2.getAmountIn is not a function

1 Answer 1

0

This error I guess is caused by your router abi or router address error because I do not have information on the previous code so I can only speculate it

But there are several obvious errors in your code

You should chang this

const maxAmount = await uniswapV2Router2.getAmountIn(1, reserve0, reserve1); // amount of MKR for 1 DAI

to

const maxAmount = await uniswapV2Router2.getAmountIn(1, [reserve0, reserve1]); // amount of MKR for 1 DAI.

Because [reserve0, reserve1] is an array :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.