15,000 USDC
View results
Submission Details
Severity: gas

Neglecting view functions

Summary

DSCEngine.sol contract has a range of view function that present information about protocol and users. However, their usage is omitted and direct storage call used

Vulnerability Details

The code will be much cleaner if we use view function instead of storage call.
Particularly:

  • getCollateralTokenPriceFeed(token) instead of s_priceFeeds[token];

  • getCollateralBalanceOfUser(user, token) instead of s_collateralDeposited[user][token];

Impact

View functions name are more self-explanatory and easy to read, thus current implementation may mislead users

Tools Used

Observation

Recommendations

Change:

  • s_priceFeeds[token] to getCollateralTokenPriceFeed(token) in lines 103, 344, 362 of DSCEngine.sol

  • s_collateralDeposited[user][token] to getCollateralBalanceOfUser(user, token) in line 355 of DSCEngine.sol

Support

FAQs

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