F-2024-0005·gas-optimization

Use custom errors instead of require statements for gas optimization and clarity

Acknowledgedvaultyieldbtc
TL;DR

The constructor and deposit function use require strings for validation. Replacing with custom errors saves gas on revert and produces more informative error messages.

Severity
INFO
Impact
LOW
Likelihood
LOW
Method
MManual review
CAT.
Complexity
LOW
Exploitability
LOW
02Section · Description

Description

In multiple places in the contract, require statements are used for validation. Consider replacing these with custom errors for gas optimization and improved clarity in error messages.

Affected locations:

  • Constructor:

    solidity
    require(_feeRecipient != address(0))
  • Deposit function:

    solidity
    require((_shares = super.previewDeposit(assetsNoFee)) != 0, "ZERO_SHARES")
03Section · Recommendation

Recommendation

Replace require statements with custom errors. For example:

solidity
error ZeroAddress();
error ZeroShares();
// In constructor
if (_feeRecipient == address(0)) revert ZeroAddress();
// In deposit function
if ((_shares = super.previewDeposit(assetsNoFee)) == 0) revert ZeroShares();

This change will save gas and provide more informative error messages.

F-2024-0005

oog
zealynx

Smart Contract Security Digest

Monthly exploit breakdowns, audit checklists, and DeFi security research — straight to your inbox

© 2026 Zealynx