0

I'm trying to create a bot using JavaScript that interacts with Uniswap's smart contracts. I have been using UniswapV1's factory and exchange contracts, and I was using the getEthToTokenInputPrice method to get the prices for token pairs.

But as I was getting the prices of LINK, KNC, and DAI when exchanging for ETH, I noticed that they are inaccurate when compared to the prices on the Uniswap interface.

For example, the returned price I got from the smart contract for ETH-DAI is 1674, while the Uniswap interface says 1669. For ETH-KNC, it's 591 versus 796. For ETH-LINK, it's 49 versus 58.

Are these differences in price natural or incorrect? Should I switch to V2 instead?

I've been using these contracts below if it helps you understand the problem I'm having.

Uniswap Factory Contract: https://etherscan.io/address/0xc0a47dfe034b400b47bdad5fecda2621de6c4d95#code Uniswap Exchange Template: https://etherscan.io/address/0x09cabec1ead1c0ba254b09efb3ee13841712be14#code

1
  • Maybe it's the difference between MidPrice and ExecutionPrice. The latter is associated with an amount and "direction" (of the swap) so to speak, the former is independent thereof. – pwagner Mar 10 at 13:30

Your Answer

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

Browse other questions tagged or ask your own question.