15,000 USDC
View results
Submission Details
Severity: gas
Valid

burn -> replace <= with <

Summary

function burn(uint256 _amount) in DecentralizedStableCoin.sol has a check:

if (_amount <= 0) {
revert DecentralizedStableCoin__MustBeMoreThanZero();
}

<= is more gas inefficient than just a < as it has to use 2 opcodes instead of 1.

Vulnerability Details

Impact

Less gas consumption

Tools Used

Recommendations

I propose the following change to make it more efficient:
if (_amount < 1) {
revert DecentralizedStableCoin__MustBeMoreThanZero();
}

I also recommend moving the balance fetch on L:47 after the above check. That removes a storage read and reduces the gas costs a lot in the case of someone calling this function with _amount < 1.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.