0

When I exchange in TOKEN for WETH or WHET for a TOKEN, the result obtained with trade.outputAmount always gives me the same result as in the uniswap UI.

But when I go to obtain the output price in a TOKEN TRADE for another TOKEN erc-20 I get a different result. Always lower than the one offered by the uniswap UI at the same time.

My code

const TOKENP = new Token(ChainId.MAINNET, tokenw.hash, tokenw.decimals);
const TOKEN_M = new Token(ChainId.MAINNET, tokenm.hash, tokenm.decimals); //
const pair3 = await Fetcher.fetchPairData(TOKEN_M ,TOKEN_P);
const route3 = new Route([pair3], TOKEN_P);
let qtyToken = Math.pow(10, 18)*1;
const tradeM = new Trade(route3, new TokenAmount( TOKEN_P, qtyToken ), TradeType.EXACT_INPUT)
return tradeM.outputAmount.toSignificant(6); 

Shouldn't this code give me the exact data from the uniswap UI just like it happens to me when I trade with ETH? This difference increases when the amount of the input token increases. In this case this 1 unit.

enter image description here enter image description here

0

Not familiar with Uniswap SDK so the best I can offer is my logic, isnt your code fetching info from uniswap v3? i see you're using v2 on the UI

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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