I want to get the latest and most accurate price data from Uniswap and found out that I can either call the getAmountsOut() function which gives me the amount of tokens I will get in return of a given input amount of tokens. Also it's possible to get the wanted price data via an on-chain price oracle which I could implement by myself thanks to the Uniswap smart contract that stores cumulative price data.

So what's the difference, are their drawbacks with using one method vs the other?

  • This is going to be opinion based here. My two cents is that calling just uniswap will get you the price of an asset just from uniswap. You're now depending on uniswap never having liquidity problems for your smart contract, and you have uniswap as your single point of failure. Versus using Chainlink which won't have that issue as the data is coming from a decentralized network. However, if you only plan on interacting with uniswap, it might make sense just to grab from uniswap. But if you want the most accurate price overall, then it will make sense to pull from Chainlink. Mar 29, 2021 at 0:53
  • It is not opinion based. There are clear positives and drawbacks for each. Ultimately, it depends of the use case. See my answer.
    – Undead8
    Mar 29, 2021 at 1:34

1 Answer 1


Uniswap V2 oracle

This will give you the average price of all the swaps that were made for an interval of blocks that you specify (the last 50 blocks, for instance).


  • Manipulation resistant. The manipulator would have to make bad and expensive swaps for most blocks of the chosen interval. If you choose a long interval, that would be very expensive to do.
  • Can show the price over different time-period depending on the block interval that you choose.
  • The price that you get does not depend on the size of a swap in particular.


  • The price that you get is not representative of the swap that you will make. It is not useful in a swaping context.
  • The price could be stalled and out-dated since it is an average of past transactions.
  • The price that you get is specific to a single pair. You do not get the price of swaping across multiple pairs.
  • You need to call a node that keeps the state of old blocks, such as an archive node. Overall, it is a bit more difficult to implement than just calling getAmountsOut()

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.