Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constants in comparisons should appear on the left side #1127

Open
codehawks-bot opened this issue Aug 5, 2023 · 0 comments
Open

Constants in comparisons should appear on the left side #1127

codehawks-bot opened this issue Aug 5, 2023 · 0 comments

Comments

@codehawks-bot
Copy link

Constants in comparisons should appear on the left side

Severity

Gas Optimization / Informational

Relevant GitHub Links

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

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

Summary

Constants in comparisons should appear on the left side

Vulnerability Details

Doing so will prevent typo bugs

Instances (5):

File: src/DSCEngine.sol

96:         if (amount == 0) {

331:         if (totalDscMinted == 0) return type(uint256).max;

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

File: src/DecentralizedStableCoin.sol

49:         if (_amount <= 0) {

59:         if (_to == address(0)) {

63:         if (_amount <= 0) {

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

Tools Used

Code Review using VSCode

Recommendations

Put constants on the left side in comparisons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants