Skip to content
Business logic Audit finding Beginner

Incorrect token balance calculation in MorphoYearnOGWETHStrategy.sol::_deallocate() leads to wrong event emitted every time

In the strategy's deallocation function, the WETH balance is read twice after the vault withdrawal instead of once before and once after, so the redeemed amount is always computed as zero. As a result, a loss event is emitted on every deallocation even when no loss occurred, which could mislead off-chain indexers and front-ends.

Vanshika Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

56529 sc low incorrect token balance calculation in morphoyearnogwethstrategy sol deallocate leads to wrong event emitted every time

Submitted on Oct 17th 2025 at 09:44:18 UTC by @Vanshika for Audit Comp | Alchemix V3

Description

Brief/Intro

MorphoYearnOGWETHStrategy.sol::_deallocate() always calculates wethRedeemed as 0. Regardless of the result of the withdrawal, it will always emit the StrategyDeallocationLoss event. This might lead to off-chain errors, although it has no impact on-chain.

Vulnerability Details

MorphoYearnOGWETHStrategy.sol::_deallocate() has the following code:

    function _deallocate(uint256 amount) internal override returns (uint256) {
        vault.withdraw(amount, address(this), address(this));
@>  uint256 wethBalanceBefore = TokenUtils.safeBalanceOf(address(weth), address(this));
        uint256 wethBalanceAfter = TokenUtils.safeBalanceOf(address(weth), address(this));
        uint256 wethRedeemed = wethBalanceAfter - wethBalanceBefore;
        if (wethRedeemed < amount) {
            emit StrategyDeallocationLoss("Strategy deallocation loss.", amount, wethRedeemed);
        }
        require(wethRedeemed + wethBalanceBefore >= amount, "Strategy balance is less than the amount needed");
        require(TokenUtils.safeBalanceOf(address(weth), address(this)) >= amount, "Strategy balance is less than the amount needed");
        TokenUtils.safeApprove(address(weth), msg.sender, amount);
        return amount;
    }

wethBalanceBefore and wethBalanceAfter are both calculated after the withdrawal call to the vault. They will return the same value, and so the wethRedeemed will always be 0. The wethBalanceBefore in this function should be calculated before the external call to the vault. Other strategies do this correctly.

Impact Details

Incorrect event emitted for off-chain indexers or front-ends. No on-chain impact since the function uses the input amount for approval and return value and not the incorrectly calculated wethRedeemed.

Proof of Concept

Proof of Concept

Copy the given test in test/strategies/MorphoYearnOGWETHStrategy.t.sol, and run with any input values using the following command: forge test --mt test_deallocate_POC -vvvv

    function test_deallocate_POC() public {
        // using test inherited from BaseStrategyTest
        test_strategy_deallocate(1e18, 1e17); // any input will produce the same result
    }

In the call trace about halfway through, you will always see the following event even if there is no loss:

emit StrategyDeallocationLoss(message: "Strategy deallocation loss.", amountRequested: 999900000000000000 [9.999e17], actualAmountSent: 0)

The original report as published on Immunefi, by Vanshika. 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

The 'before' balance snapshot is taken after the external vault withdrawal instead of before it, so both readings are identical.

Impact

Only an incorrect event is emitted for off-chain consumers; there is no on-chain impact because approval and return use the requested amount.

What the attacker needed

None

How it was found

  1. Add the provided test to the strategy test file.
  2. Run it with forge test using the given test name.
  3. Observe in the call trace that the loss event is emitted with a redeemed amount of zero.

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.

A smart contract is a program on a blockchain. This one moves funds out of a vault and then checks how much came back by comparing the balance before and after. The mistake is that it reads the balance twice after the withdrawal, so the difference is always zero and it wrongly reports a loss.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Vanshika

View all

3 more disclosed reports, best first.

More from Alchemix V3

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.