Cyfrin / 2023-07-foundry-defi-stablecoin

37 stars 32 forks source link

Constants should be defined rather than using magic numbers #1136

Open codehawks-bot opened 1 year ago

codehawks-bot commented 1 year ago

Constants should be defined rather than using magic numbers

Severity

Gas Optimization / Informational

Relevant GitHub Links

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

Summary

Constants should be defined rather than using magic numbers

Vulnerability Details

Even assembly can benefit from using readable constants instead of hex/numeric literals

Instances (1):

File: src/DSCEngine.sol

333:         return (collateralAdjustedForThreshold * 1e18) / totalDscMinted;

Link to code - https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/tree/main/src/DSCEngine.sol

Tools Used

Code Review using VSCode

Recommendations

Define constants instead of magic numbers