Skip to content
Business logic Audit finding Beginner

The amount of weth redeemed is not calculated properly in morphoyearnogweth

The strategy's deallocation function reads the WETH balance after withdrawing, so the before and after balances are identical and the redeemed amount is always zero. This causes a loss event to be emitted on every deallocation even when no loss occurred, misleading off-chain monitoring.

Josh4324 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

58497 sc low the amount of weth redeemed is not calculated properly in morphoyearnogweth

Submitted on Nov 2nd 2025 at 19:25:54 UTC by @Josh4324 for Audit Comp | Alchemix V3

Description

Brief/Intro

The amount of WETH redeemed is not accurately calculated; this will make the WETH redeemed always zero, and the contract will always emit StrategyDeallocationLoss( when it didn't deallocate at a loss.

Vulnerability Details

The root cause of the issue is that the vault.withdraw function is called before the wethBalanceBefore value is queried. This means that wethBalanceBefore and wethBalanceAfter is always equal and uint256 wethRedeemed = wethBalanceAfter - wethBalanceBefore; will always be zero.

SOL
    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;
    }

Since wethRedeemed is always zero, this will always be emitted.

SOL
        if (wethRedeemed < amount) {
            emit StrategyDeallocationLoss("Strategy deallocation loss.", amount, wethRedeemed);
        }

Impact Details

The current impact is that any off-chain system that is listening to this StrategyDeallocationLoss event will always think that the contract is at a loss.

References

https://github.com/alchemix-finance/v3-poc/blob/immunefi\\_audit/src/strategies/mainnet/MorphoYearnOGWETH.sol?utm\\_source=immunefi#L50

Proof of Concept

Proof of Concept

Add to test/strategy/MorphoYearnOGWETHStrategy.t.sol

SOL
interface IERC20Lite {
    function balanceOf(address) external returns (uint);
}
SOL
    // Declare the event so the test can emit an expected log
    event StrategyDeallocationLoss(string message, uint256 amount, uint256 loss);
    function test_redeem_poc(uint256 amountToAllocate) public {
        amountToAllocate = bound(amountToAllocate, 1e18, testConfig.vaultInitialDeposit);
        uint amountToDeallocate = amountToAllocate / 2;
        vm.startPrank(vault);
        deal(WETH, strategy, amountToAllocate);
        bytes memory prevAllocationAmount = abi.encode(0);
        IMYTStrategy(strategy).allocate(prevAllocationAmount, amountToAllocate, "", address(vault));

        // Get Balance of Strategy before deallocation
        uint balanceBefore = IERC20Lite(WETH).balanceOf(address(strategy));

        bytes memory prevAllocationAmount2 = abi.encode(amountToAllocate);

        vm.expectEmit(true, true, true, true);
        emit StrategyDeallocationLoss("Strategy deallocation loss.", amountToDeallocate, 0);

        IMYTStrategy(strategy).deallocate(prevAllocationAmount2, amountToDeallocate, "", address(vault));
        vm.stopPrank();

        // Get Balance of Strategy before deallocation
        uint balanceAfter = IERC20Lite(WETH).balanceOf(address(strategy));

        console2.log("STRATEGY BALANCE Before deallocation: ", balanceBefore);

        console2.log("STRATEGY BALANCE After  deallocation: ", balanceAfter);

        console2.log("Balance Redeemed                    : ", balanceAfter - balanceBefore);
    }

OUTPUT

Bash
   ├─ [534] 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2::balanceOf(MockMorphoYearnOGWETHStrategy: [0x535B3D7A252fa034Ed71F0C53ec0C6F784cB64E1])
    │   └─ ← [Return] 499500000000000002919 [4.995e20]
    ├─ [0] console::log("STRATEGY BALANCE Before deallocation: ", 0) [staticcall]
    │   └─ ← [Stop]
    ├─ [0] console::log("STRATEGY BALANCE After  deallocation: ", 499500000000000002919 [4.995e20]) [staticcall]
    │   └─ ← [Stop]
    ├─ [0] console::log("Balance Redeemed                    : ", 499500000000000002919 [4.995e20]) [staticcall]
    │   └─ ← [Stop]
    └─ ← [Stop]

The original report as published on Immunefi, by Josh4324. 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 balance snapshot is taken after the withdrawal instead of before, so the before and after values are equal.

Impact

Off-chain systems listening for the loss event will always believe the contract is at a loss, although no funds are actually lost.

What the attacker needed

Strategy holds WETH; deallocate is called

How it was found

  1. Allocate WETH to the strategy.
  2. Record the strategy's WETH balance before deallocation.
  3. Call deallocate for half the allocated amount.
  4. Observe that the StrategyDeallocationLoss event is emitted with a loss 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 strategy moves funds in and out of a vault. When it takes funds out, it tries to measure how much it received by comparing the balance before and after. Here it measured both after the withdrawal had already happened, so the difference was always zero and it wrongly reported 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 Josh4324

View all

10 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.