gas

Non Critical Issues:Discrepancy between code and comments

Reward

Total

24.49 USDC

Selected
24.49 USDC
Selected Submission

Non Critical Issues:Discrepancy between code and comments

Severity

Gas Optimization / Informational

Relevant GitHub Links

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L346

Summary

  • The code implementation does not match the description provided in the corresponding comments.

Vulnerability Details

  • During the auditing process, I noticed this comment: // ($10e18 * 1e18) / ($2000e8 * 1e10). Then, I substituted it into the calculation formula (usdAmountInWei * PRECISION) / (uint256(price) * ADDITIONAL_FEED_PRECISION) for computation.
  • In the end, I found that the content of this comment is incorrect. It should be $10e8 instead of $10e18. Considering $2000e8, it can be inferred that it should be $10e8.

Tools Used

  • Manual Review

Recommendations

  • Update the comments to keep them consistent.
File src/DSCEngine.sol

- 346        // ($10e18 * 1e18) / ($2000e8 * 1e10)
+ 346        // ($10e8 * 1e18) / ($2000e8 * 1e10)