Mammoth Tangerine Gerbil
Medium
OracleRelay.sol
is is calling latestAnswer
to get the last price. This method will return the last value, but you won't be able to check if the data is fresh.
On the other hand, calling the method latestRoundData
allow you to run some extra validations
No response
No response
No response
No response
Stale price may result in wrong swaps which will cause to loss of funds.
Also the latestAnswer method is depracated by chainlink and may not work in the future.
No response
Consider using latestRoundData() with the following additional checks:
( roundId, rawPrice, , updateTime, answeredInRound ) = aggregator.latestRoundData(); require(rawPrice > 0, "Chainlink price <= 0"); require(updateTime != 0, "Incomplete round"); require(answeredInRound >= roundId, "Stale price");