Open vm06007 opened 1 year ago
All these functions are used only _recalibratePreview
which is only used in _recalibrate -> recalibrate
which means it is expected to be called only once by the team when setting the oracle feed initially. If it costs a little bit more thats okay it is not meant to be called more than once per life-cycle most likely anyway unless something changes. This function would be called relatively rarely if at all. Calling _getRoundTimestamp
to only get one value in the loop is still needed to be separate. No change intended based on the suggestion. Not worth the rewrite. Still nice to have separate functions that would return separate values.
OHR-02C: Inefficient Invocation of Chainlink Related Functions
Description:
The highlighted argument to the
OracleHelper::_getLatestAggregatorRoundId
,OracleHelper::_getPhaseId
, andOracleHelper::_getRoundTimestamp
functions is inefficient as it will always be "converted" to its Chainlink oracle via thepriceFeed[_tokenAddress]
lookup from storage.Example:
Recommendation:
We advise the oracle to be queried once in the
OracleHelper::_recalibratePreview
function and to be passed in as an oracle to the highlighted functions, optimizing the gas cost of the function significantly.