gas

Boolean equality

Reward

Total

24.49 USDC

Selected
24.49 USDC
Selected Submission

Boolean equality

Severity

Gas Optimization / Informational

Relevant GitHub Links

https://github.com/Cyfrin/foundry-defi-stablecoin-f23/blob/main/src/DSCEngine.sol#L238-L240

Summary

Boolean constants can be used directly and do not need to be compared to true or false.

Vulnerability Details

!minted is more concise and readable than minted != true. The !minted expression directly conveys the meaning "if not minted" or "if minted is false," which is much clearer than explicitly comparing minted to true. The latter form, minted != true, adds unnecessary complexity and verbosity to the code.

Impact

Code Readability

Tools Used

Manual code inspection

Recommendations

Change this:

if (minted != true) {
    revert DSCEngine__MintFailed();
}

to:

if (!minted) {
    revert DSCEngine__MintFailed();
}