Submitted by nonseodion
WiseLending calibrates Oracles to get a heartbeat which it uses for checking the staleness of prices returned from the Oracle.
To calibrate, it fetches between 3-50 inclusive historical prices and picks the second largest update time among those prices. It calls _getIterationCount() to know the number of historical prices itll use. If the current _latestAggregatorRoundId is less than 50 (MAX_ROUND_COUNT) it uses _latestAggregatorRoundId else it uses 50.
OracleHelper.sol#L665-L667
The issue with the snippet above is that _latestAggregatorRoundId will always be greater than 50 so the number of historical prices it uses will always be 50.
Its always greater than 50 because it is fetched from the aggregators proxy contract. The roundIds returned from the proxy are a combination of the current aggregators roundId and phaseId. Check Chainlink docs for more info. getLatestRoundId() returns the roundId.
OracleHelper.sol#L708-L715
The roundId returned is used in the _recalibratePreview() function below to get previous roundIds. The iterationCount as we already mentioned will always be 50.
OracleHelper.sol#L620C1-L630C15
The problem with the above call is that the argument, latestRoundId-1 above may not have valid data for some rounds. So calls to the Chainlink Oracle for those rounds will revert.
This may occur because of the way proxy roundIds work.
Example:
Check Chainlink docs for more info.
Thus, if the aggregator roundId derived from the proxy roundId is less than 50, _recalibratePreview() will revert. The caller will have to wait until it is greater than 50.
In both cases above the max amount of time user can wait for is 50x the official Chainlink heartbeat for the price feed, i.e. price feed heartbeat * 50.
For the BTC/ETH price feed this would be 50 days (24 hours * 50).
Consider deriving the aggregator roundId from the proxy roundId and using that instead of the proxy roundId.
OracleHelper.sol#L665-L667
vonMangoldt (Wise Lending) commented:
Trust (judge) commented:
0xStalin (warden) commented:
Trust (judge) commented:
0xStalin (warden) commented:
Wise Lending commented:
