Skip to content
Audit finding Beginner

Redundant code in dexaggregatorwrapperwithpredicateproxy impairs readability and potentially increases gas costs

The report identifies redundant code in the depositOneInch function of DexAggregatorWrapperWithPredicateProxy, where the vault address is validated three times and shares are recalculated unnecessarily. This redundancy increases gas costs and reduces readability, potentially introducing errors.

KKam86 Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

50677 sc insight redundant code in dexaggregatorwrapperwithpredicateproxy impairs readability and potentially increases gas costs

Submitted on Jul 27th 2025 at 12:14:16 UTC by @KKam86 for Attackathon | Plume Network

Description

Brief/Intro

One of the functions in DexAggregatorWrapperWithPredicateProxy - depositOneInch has redundant code which unnecessarily complicates function logic. Redundant code impairs readability, produces additional gas costs or even can introduce new errors in contract logic.

Vulnerability Details

{% stepper %} {% step %}

Redundant vault address validation (multiple checks)

Function depositOneInch validates vaultAddress three separate times:

  1. First time inside call to _oneInchHelper:
Solidity
uint256 supportedAssetAmount = _oneInchHelper(
    supportedAsset,
    address(teller),
    executor,
    desc,
    data,
    nativeValueToWrap
);

Inside _oneInchHelper before approving assets to vaultAddress:

Solidity
address vaultAddress = address(
    TellerWithMultiAssetSupport(payable(teller)).vault()
);
if (vaultAddress == address(0)) {
    revert("DexAggregatorWrapper: Invalid vault address for approval");
}

supportedAsset.safeApprove(vaultAddress, supportedAssetAmount);
  1. Second check immediately in depositOneInch after calling _oneInchHelper and before deposit:
Solidity
address vaultAddress = address(teller.vault());
if (vaultAddress == address(0)) {
    // Handle error: Vault address cannot be zero if we need to transfer shares
    revert("DexAggregatorWrapper: Invalid vault address");
}
  1. Third check at the end of depositOneInch inside _calcSharesAndEmitEvent call path:
Solidity
_calcSharesAndEmitEvent(
    supportedAsset,
    CrossChainTellerBase(address(teller)),
    address(desc.srcToken),
    desc.amount,
    supportedAssetAmount
);

And inside _calcSharesAndEmitEvent it again obtains and checks the vault address:

Solidity
// Get vault address
address vaultAddress = address(teller.vault());
if (vaultAddress == address(0)) {
    revert("DexAggregatorWrapper: Invalid vault address");
}

These repeated checks for the same invariant are redundant and increase code complexity and gas usage. {% endstep %}

{% step %}

Unnecessary shares recalculation in _calcSharesAndEmitEvent

The call to _calcSharesAndEmitEvent in depositOneInch recomputes shares solely to emit a Deposit event, but teller.deposit already returns the shares calculated using the same logic.

Example in depositOneInch:

Solidity
shares = teller.deposit(
    supportedAsset,
    supportedAssetAmount,
    minimumMint
);

In TellerWithMultiAssetSupport.sol the deposit function returns shares via internal _erc20Deposit:

Solidity
function deposit(
    ERC20 depositAsset,
    uint256 depositAmount,
    uint256 minimumMint
) external requiresAuth nonReentrant returns (uint256 shares)

And _erc20Deposit calculates shares as:

Solidity
shares = depositAmount.mulDivDown(
    ONE_SHARE,
    accountant.getRateInQuoteSafe(depositAsset)
);

Where ONE_SHARE and accountant are initialized in TellerWithMultiAssetSupport constructor.

Meanwhile, shares calculation inside _calcSharesAndEmitEvent duplicates the same computation:

Solidity
uint256 shares = supportedAssetAmount.mulDivDown(
    10 ** teller.vault().decimals(),
    AccountantWithRateProviders(teller.accountant()).getRateInQuoteSafe(
        supportedAsset
    )
);

This redundant recalculation is unnecessary since the shares were already computed and returned by teller.deposit. {% endstep %} {% endstepper %}

Impact Details

  1. Increased gas costs — redundant operations consume additional gas which the user must pay for.
  2. Reduced readability — redundant and repeated checks make the code harder to reason about, maintain, and audit, increasing risk of errors.

References

Proof of Concept

(Empty)

Proof of Concept

(Empty)

The original report as published on Immunefi, by KKam86. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the code performs redundant validation and recalculation instead of reusing results from earlier calls.

Impact

The redundant operations could increase gas costs for users and reduce code readability, potentially leading to errors.

What the attacker needed

None

The fix

The code should be refactored to remove redundant checks and reuse the shares returned by teller.deposit.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This report points out that a smart contract function repeats the same checks and calculations multiple times. While not a security vulnerability, this wastes gas (transaction fees) and makes the code harder to understand and maintain.

More by KKam86

View all

2 more disclosed reports, best first.

More from Plume Network

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.