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

Redundant zero address check in mint method of DecentralizedStableCoin contract

Summary

The mint method in DecentralizedStableCoin checks if the _to address is zero address, and reverts with custom error if this condition is satisfied.

function mint(address _to, uint256 _amount) external onlyOwner returns (bool) {
if (_to == address(0)) {
revert DecentralizedStableCoin__NotZeroAddress();
}
if (_amount <= 0) {
revert DecentralizedStableCoin__MustBeMoreThanZero();
}
_mint(_to, _amount);
return true;
}

This check is already being performed in the _mint method of ERC20 contract. The method can therefore be simplified for gas savings:

function mint(address _to, uint256 _amount) external onlyOwner returns (bool) {
if (_amount <= 0) {
revert DecentralizedStableCoin__MustBeMoreThanZero();
}
_mint(_to, _amount);
return true;
}

The custom error DecentralizedStableCoin__NotZeroAddress can be removed.

Vulnerability Details

n/a

Impact

Unnecessary gas consumption

Tools Used

Manual review

Recommendations

Please consider removing redundant lines of code as suggested in summary.

Support

FAQs

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