DeFiHardhat
21,000 USDC
View results
Submission Details
Severity: low
Invalid

Custom Errors 01

Summary

The provided audit concerns optimizing gas usage by replacing a require() statement with Custom Errors.

Vulnerability Detail

The require() statement in the UnripeFacet::switchUnderlyingToken function is currently used to check if the balance of the unripeToken is zero. This check could potentially be optimized to use a Custom Error instead.

Impact

Gas optimization is the primary impact of this change. By using Custom Errors, gas costs could potentially be reduced.

Code Snippet

function switchUnderlyingToken(
address unripeToken,
address newUnderlyingToken
) external payable {
LibDiamond.enforceIsContractOwner();
require(s.u[unripeToken].balanceOfUnderlying == 0, "Unripe: Underlying balance > 0");
LibUnripe.switchUnderlyingToken(unripeToken, newUnderlyingToken);
}

Tool used

Manual Review

Recommendation

The function should use Custom Errors as shown below:

function switchUnderlyingToken(
address unripeToken,
address newUnderlyingToken
) external payable {
LibDiamond.enforceIsContractOwner();
// Optimized gas usage by using Custom Error instead of require()
if (s.u[unripeToken].balanceOfUnderlying != 0) {
revert("Unripe: Underlying balance > 0");
}
LibUnripe.switchUnderlyingToken(unripeToken, newUnderlyingToken);
}
Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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