I use fetchPairData method from uniswap-v2 SDK to quote two tokens conversion rates:

const uniswapPair: Pair = await Fetcher.fetchPairData(
    new Token(ChainId.MAINNET, baseToken.address, 18),
    new Token(ChainId.MAINNET, quoteToken.address, 18),
console.log(  Number(uniswapPair.token0Price.toFixed(pair.baseToken.decimals)) );

The return value for the token price is slightly different from the quoted value on uniswap website (This is the case for any tested pairs such as AAVE/DAI or LINK/DAI). What is going on wrong with this method of price inquiry?



Your Answer

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

Browse other questions tagged or ask your own question.