Cyfrin / 2023-07-foundry-defi-stablecoin

37 stars 32 forks source link

The `nonReentrant` `modifier` should occur before all other modifiers #1134

Open codehawks-bot opened 1 year ago

codehawks-bot commented 1 year ago

The nonReentrant modifier should occur before all other modifiers

Severity

Gas Optimization / Informational

Relevant GitHub Links

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

Summary

The nonReentrant modifier should occur before all other modifiers

Vulnerability Details

This is a best-practice to protect against reentrancy in other modifiers

Instances (4):

File: src/DSCEngine.sol

154:         nonReentrant

187:         nonReentrant

198:     function mintDsc(uint256 amountDscToMint) public moreThanZero(amountDscToMint) nonReentrant {

233:         nonReentrant

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

Tools Used

Code Review using VSCode

Recommendations

Put the nonReentrant modifier as the first modifier