newly released token in sol, the code I used is as follows
function getTokenPrice(address pairAddress, uint amount) public view returns(uint)
{
IUniswapV2Pair pair = IUniswapV2Pair(pairAddress);
IERC20 token1 = IERC20(pair.token1());
(uint Res0, uint Res1,) = pair.getReserves();
// decimals
uint res0 = Res0*(10**token1.decimals());
return (amount * res0) / Res1;
// return((amount*res0)/Res1); // return amount of token0 needed to buy token1
}
But it gives an error, is there a way to do it?
this error: call to Getprice.getTokenPrice errored: execution reverted
How do I find the pair address in the test network?
Anybody know this?
Обсуждают сегодня