4

I want to use Chainlink to get the price of an asset at a given point in time in the past (which I will refer to as "expiry") in order to settle options.

To get a historical price, Chainlink requires to pass in a roundId as argument into the getRoundData function. In order to verify that the round implied by the given roundId includes the expiry time, my initial thought was checking inside the smart contract whether startedAt <= expiry && timestamp >= expiry for the received roundData.

In order to assess whether this is a feasible approach, I would like to better understand the concept of rounds in Chainlink:

  1. Can I assume that rounds always span adjacent time intervals, i.e. if say a round starts at unixTime t1 and ends at t2, can I assume that the next round will start at t2?
  2. getRoundData(roundId) returns startedAt and timestamp. Does the timeStamp represent the end of the given roundId?
  3. What exactly is the answeredInRound that I receive as output from getRoundData?

Any help is highly appreciated.

1 Answers1

0
  1. There are currently 2 "trigger" parameters that kick off Chainlink nodes to update. If the real-world price of an asset deviates past some interval, it will trigger all the nodes to do an update. Right now, most Ethereum data feeds have a 0.5% deviation threshold. If the price stays within the deviation parameters, it will only trigger an update every X minutes/hours. You can see these parameters on data.chain.link.

  2. timeStamp (updatedAt) - Timestamp of when the round was updated. More details here

  3. answeredInRound is a legacy variable from when the Chainlink price feeds were 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.

More info is available at Data Feeds API Reference.

Additionally, since you want to use Chainlink to get the price of an asset at a given point in time in the past, there is an open-source community project that solves the same issue

Andrej
  • 534
  • 2
  • 7
  • "The round ID of the round in which the answer was computed." The answer wasn't computed in this round? Or is it referring to the next answer ie the next round? – Jonah Jan 30 '22 at 17:09
  • @Jonah `answeredInRound` is a legacy variable from when the Chainlink price feeds were 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. Updating the answer now. – Andrej Aug 22 '22 at 19:11