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

Use custom errors instead of `require()`/`revert()` strings

Summary

Custom errors are not implemented everywhere

Vulnerability Details

Custom errors save around 50 gas each time they're hit by avoiding having to allocate and store the revert string, and not defining the strings also save deployment gas. This feature is available in solidity version 0.8.4 and greater

27 require(_profits != WETH, "not allowed");

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Fees.sol#L27

11 require(msg.sender == owner, "UNAUTHORIZED");

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/utils/Ownable.sol#L11

Impact

Gas savings

Tools Used

Manual review

Recommendations

Use custom errors in all require statements

Support

FAQs

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