Interesting Cedar Hare
Medium
we are calling latestAnswer()
to get the last oracle price. This method will return the last value, but you will not be able to check if the data is fresh. On the other hand, calling the method latestRoundData()
allows you to run some extra validations.
function currentValue() external view override returns (uint256) { int256 latest = aggregator.latestAnswer(); require(latest > 0, "chainlink: px < 0"); return uint256(latest); }
No response
No response
No response
stale price may happen in currentValue.
No response
( roundId, rawPrice, , updateTime, answeredInRound ) = IChainlinkAdapter(_oracle).latestRoundData(); require(rawPrice > 0, "Chainlink price <= 0"); require(updateTime != 0, "Incomplete round"); require(answeredInRound >= roundId, "Stale price");