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

Better Consistently Named Custom Errors

Summary

Custom errors need to be descriptive and follow consistent format in code. This is not the case with the errors in all contracts in scope

Vulnerability Details

As dicussed in other finding on Custom Error ambiguity. It is necessary for Custom Errors to be clear about what they specify, mean, are enforcing, checking, requiring or preventing etc. Naming can be more aligned across the Custom Errors used in the contracts. The naming is not consistent and can be improved for clarity

Impact

Informational: This can lead to confusion for debugging, offchain monitoring, tooling,error analysis and maintainability of code. If Custom Error is not clear it may be misinterpreted incorrectly and may even lead to more errors in code as developers make wrong assumptions about the errors intentions.

Tools Used

Manual Analysis

Recommendations

Following on from above, Custom errors can be named more aligned, shorter and more descriptive and consistent e.g language of ‘Not’ or of ‘Must’ to emphasize what went wrong e.g ‘Must’ , ‘Is’, ‘Not’, ‘Only’ ‘IsOk’ or end with ‘Failed’ etc
DecentralizedStableCoin.sol
DecentralizedStableCoin__MustBeMoreThanZero()
DecentralizedStableCoin__MustNotExceedBalance()
DecentralizedStableCoin__MustNotBeZeroAddress();
Or ‘Not’ a requirement format
DecentralizedStableCoin__NotMoreThanZero()
DecentralizedStableCoin__NotLessThanBalance()
DecentralizedStableCoin__NotDifferentToZeroAddress();
DSCEngine.sol consistent use of 'Must' language as in below
DSCEngine__NeedsMoreThanZero() -> DSCEngine__MustBeMoreThanZero()
DSCEngine__TokenAddressesAndPriceFeedAddressesMustBeSameLength()-> DSCEngine_MustBeSameLengthTokenAndPriceFeedAddresses()
DSCEngine__NotAllowedToken() -> DSCEngine__MustBeAllowedToken()
DSCEngine__BreaksHealthFactor(uint256 healthFactor) -> DSCEngine__MustNotBreakHealthFactor(uint256 healthFactor);
DSCEngine__HealthFactorOk() -> DSCEngine__HealthIsFactorOk()
DSCEngine__HealthFactorNotImproved() -> DSCEngine__MustImproveHealthFactor()
Above a just illustrative examples of how to ensure alignment of naming

Support

FAQs

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