Some input checks are not necessary or they can be improved.
Some input checks are not necessary or they can be improved. More details are provided in the "Recommendations" section.
Gas can be saved and code can be more clear by improving this. vice versa.
constructor() ERC20("DecentralizedStableCoin", "DSC") {}
function burn(uint256 _amount) public override onlyOwner {
- uint256 balance = balanceOf(msg.sender); // @audit because ERC20Burnable will check this, so this is not necessary. @audit gas - put his after the `if` check to save gas.
- if (_amount <= 0) { // @audit this is not necessary, because uint is above zero by default. change this to `== 0`.
+ if (_amount == 0) {
revert DecentralizedStableCoin__MustBeMoreThanZero();
}
- if (balance < _amount) { // @audit this is not necessary, because ERC20Burnable will check this.
- revert DecentralizedStableCoin__BurnAmountExceedsBalance();
- }
super.burn(_amount);
}
function mint(address _to, uint256 _amount) external onlyOwner returns (bool) {
- if (_to == address(0)) { // @audit this is not necessary, because ERC20 will check this.
- revert DecentralizedStableCoin__NotZeroAddress();
- }
- if (_amount <= 0) {
+ if (_amount == 0) {
revert DecentralizedStableCoin__MustBeMoreThanZero();
}
_mint(_to, _amount);
return true;
}
}