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))
andparseInt(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