I am trying to get the price impact of a trade in uniswap sdk and I noticed that the result from the sdk isn't accurate as what was shown on the uniswap webapp. There is 0.3 difference regardless of which token and input value. Where does the 0.3 come from?

Here is my snippet:

const amountIn = '2';
const TOKEN_ADDRESS = '0x30f271C9E86D2B7d00a6376Cd96A1cFBD5F0b9b3';

// swapTokensForExactToken
let pair = await UNISWAP.Fetcher.fetchPairData(UNISWAP.WETH[TOKEN.chainId], TOKEN)
let route = new UNISWAP.Route([pair], UNISWAP.WETH[TOKEN.chainId])
const inputToken = web3.utils.toWei((parseFloat(amountIn) * parseFloat(route.midPrice.raw.toSignificant(6))).toString(), 'ether');
let trade = new UNISWAP.Trade(route, new UNISWAP.TokenAmount(TOKEN, inputToken), UNISWAP.TradeType.EXACT_OUTPUT)

console.log('impact: ', trade.priceImpact.toFixed()) // 1.10
// Uniswap app value 0.80

1 Answer 1


It is likely that one takes into account the 0.3% liquidity provider fee and the other does not.

  • Agreed, price impact shows where the price will be afterwards, whereas the webapp shows you what tokens you have afterwards, which will take into account fees as well as slippage.
    – Meriadoc
    Mar 9, 2022 at 21:28

Your Answer

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

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