58120 sc low incorrect balance measurement in morphoyearnogweth strategy leads to incorrect deallocation loss registering

Submitted on Oct 30th 2025 at 19:18:19 UTC by @ByteKnight for Audit Comp | Alchemix V3arrow-up-right

  • Report ID: #58120

  • Report Type: Smart Contract

  • Report severity: Low

  • Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/strategies/mainnet/MorphoYearnOGWETH.sol

  • Impacts:

    • Contract fails to deliver promised returns, but doesn't lose value

Description

Brief/Intro

The _deallocate() function in the MorphoYearnOGWETHStrategy contract has a logic flaw where both wethBalanceBefore and wethBalanceAfter variables are measured after the withdrawal operation, causing wethRedeemed variable to always be calculated as 0. While this doesn't result in loss of funds, it causes all deallocations to emit incorrect StrategyDeallocationLoss events with actualAmountSent: 0 which breaks the intended validation logic and forces off-chain infrastructure to incorrectly log all successful deallocations as failures and present misleading loss information in monitoring dashboards and user interfaces.

Vulnerability Details

The balance measurements are both taken after the withdrawal, causing the delta calculation to always be zero:

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

As you can see, function first withdraws the allocated WETH tokens from the vault and then measures WETH balance of the calling contract. And right after that it calculates the wethRedeemed by subtracting the WETH before withdraw from after, which in these case are equal and then emits the StrategyDeallocationLoss event, even thou the withdraw might be successful and without any loss or even with bigger amount.

Impact Details

This logic flaw leads to a situation where the StrategyDeallocationLoss event will be emitted for each deallocation operation with false information that strategy loss is 100% which isn't true and :

  • Any off-chain monitoring systems will incorrectly think all deallocations are failing

  • Off-chain loss tracking and accounting will be completely wrong

  • Users and administrators cannot trust the event data for monitoring strategy performance

  • Every successful deallocation generates a false alert

  • Any real loss in strategy won't be correctly logged and addressed by entitled party

References

Proof of Concept

Proof of Concept

To verify this flaw actually exists, do the following steps:

  1. Add the test below to the existing test suite in MorphoYearnOGWETHStrategy.t.sol (located at src/test/strategies/MorphoYearnOGWETHStrategy.t.sol):

  1. Run the test by executing the following script in terminal and pasting your fork url:

Was this helpful?