15,000 USDC
View results
Submission Details
Severity: gas

Use modifier for function checks code

Summary

Code repeated to check conditions to require certain things can be put in modifier

Vulnerability Details

Code in DecentralizedStableCoin.sol lines 48-50 is repeated in lines 61-63 to check amount is not less than or equal to zero. This can be put into a modifer instead

Impact

Informational: Avoid code duplication. Improve code quality. Improve code readability. Reduce chances of error that duplicated code in one place is repeated but with error in another. Improve code maintainability, auditability

Tools Used

Manual Analysis

Recommendations

It is recommended to add these checks into a modifier that can be reused on relevant functions
modifier onlyAmountsAboveZero() {
if (_amount <= 0) { // remember earlier finding to change this to (_amount == 0) as _amount cant be negative
revert DecentralizedStableCoin__MustBeMoreThanZero();
}
-;
}
function mint(address _to, uint256 _amount) external onlyOwner onlyAmountsAboveZero returns (bool) {....
function burn(uint256 _amount) public override onlyOwner onlyAmountsAboveZero {....

Support

FAQs

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