15,000 USDC
View results
Submission Details
Severity: gas

[G-01] No need return all values staleCheckLatestRoundData function

Summary

In our libary OracleLib.sol, staleCheckLatestRoundData function returns 5 values, of which only 1 is used.

Vulnerability Details

The function returns roundId, answer, startedAt, updatedAt, answeredInRound but only answer is used in

Impact

Gas optimization

Tools Used

Manual code review

Recommendations

Change that the staleCheckLatestRoundData function only returns the answer(price) and make the necessary changes in the affected functions such as:
DSCEnginel.sol/getTokenAmountFromUsd

- (, int256 price,,,) = priceFeed.staleCheckLatestRoundData();
+ int256 price = priceFeed.staleCheckLatestRoundData()

DSCEnginel.sol/getUsdValue

- (, int256 price,,,) = priceFeed.staleCheckLatestRoundData();
+ int256 price = priceFeed.staleCheckLatestRoundData()

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.