15,000 USDC
View results
Submission Details
Severity: gas

unnecessary calls to chainlink oracle

Summary

There is a call to the chainlink oracle, even if the amount is 0 and the price is not needed.

Vulnerability Details

In the getAccountCollateralValue function there is a loop thru all the available collateral tokens and a call to getUsdValue with the amount the account holds and the token address. Neither here, nor in getUsdValue there is a check for the amount to be 0. This results in the chainlink oracle to be called for every Token, even if the user is not hold any amount and the returned value would be 0, no matter the price.

Impact

Unneccessary calls to chainlink oracle cost more gas.

Tools Used

Manual Review

Recommendations

Check for amount to be 0 in getUsdValue function and return 0 without calling the oracle.

Support

FAQs

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