Chainlink Price Feeds – Difference Between `answeredInRound` and `roundId` in Chainlink Price Feed

chainlink

In a chainlink price feed, we can get data by calling:

function latestRoundData() external view
    returns (
        uint80 roundId,
        int256 answer,
        uint256 startedAt,
        uint256 updatedAt,
        uint80 answeredInRound
    )

With the following return values:

  • roundId: The round ID
  • answer: The answer for this round
  • startedAt: Timestamp of when the round started
  • updatedAt: Timestamp of when the round was updated
  • answeredInRound: The round ID in which the answer was computed

Would roundId ever be different from answeredInRound? What is the difference between the two?

Best Answer

roundId is the "round" the answer was created in. Every time a Chainlink network updates a price feed, they add 1 to the round.

answeredInRound is a legacy variable from when the Chainlink price feeds was on the Flux Aggregator model instead of OCR (Off-Chain Reporting) and it was possible for a price to be updated slowly and leek into the next "round". This is now no longer the case.

Related Topic