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

Redundant checks.

Summary

There are redundant checks in the burn and mint functions.

Vulnerability Details

In the burn function, it checks _amount <= 0 and balance < _amount, and in the mint function, it checks _to == address(0) and _amount <= 0. These checks are unnecessary because similar checks are already performed in _burn and _mint functions, making them redundant. Below is the code from OpenZeppelin:
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/19293f3ecdb20a7f44d54279b5c1ddbb84de4a2e/contracts/token/ERC20/ERC20.sol#L297-L302
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/19293f3ecdb20a7f44d54279b5c1ddbb84de4a2e/contracts/token/ERC20/ERC20.sol#L282-L287
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/19293f3ecdb20a7f44d54279b5c1ddbb84de4a2e/contracts/token/ERC20/ERC20.sol#L244-L272

Impact

Redundant checks result in unnecessary computations and gas consumption

Tools Used

Manual review

Recommendations

It is advisable to remove these redundant checks.

Support

FAQs

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