1

What's the purpose of secondsAgo, in regards to price accuracy, when using it on observe() to get the tickCumulatives, which you can later use in OracleLibrary.getQuoteAtTick() to get the price of a pool?

Is it as the more far you go in time, the more accurate the price will be?

function observe(uint32[] calldata secondsAgos)
    external
    view
    returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);

1 Answer 1

3

The secondsAgo parameter in the observe() function allows for retrieving historical data on cumulative ticks and liquidity over specified time intervals.

Refer: https://github.com/Uniswap/v3-core/blob/main/contracts/libraries/Oracle.sol and https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool

However, its use does not inherently result in more accurate prices as you go further back in time. Accuracy is contingent upon factors such as past liquidity levels and the oracle implementation. Therefore, the assumption that greater time intervals inherently lead to more accurate prices is not accurate.

2
  • So there's no difference in accuracy if you use 10 or 10000 for secondsAgo and the difference is just the farther you go back in time the more historical the price reading will be?
    – dNyrM
    Commented Mar 4 at 16:05
  • Yes, the secondsAgo parameter in observe() doesn't inherently affect price accuracy; while it determines historical data retrieval, it doesn't ensure more accurate prices for older readings.
    – DevCrypto
    Commented Mar 5 at 12:37

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.