57926 sc low the conditional strategydeallocationloss event in morphoyearnogwethstrategy deallocate gets logged all the time due a misplacement in variable declaration

Submitted on Oct 29th 2025 at 13:39:53 UTC by @TyroneX for Audit Comp | Alchemix V3arrow-up-right

  • Report ID: #57926

  • 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

A misplacement in syntax makes a conditional event trigger all the time, which could lead to issues in on-chain/off-chain mechanisms listening to it

Vulnerability Details

In the MorphoYearnOGWETHStrategy contract, StrategyDeallocationLoss event is logged all the time due to wethBalanceBefore and wethBalanceAfter being the same value. This happened cause wethBalanceBefore is declared after the withdrawal is triggered rather than before. This means wethBalanceBefore and wethBalanceAfter are the same value hence, wethRedeemed, a variable which depends on the difference of both always returns 0. This in turn makes StrategyDeallocationLoss, which depends on wethRedeemed, always return true. Hence the event always triggers leaving any onchain/offchain variables listening to it susceptible to error.

Impact Details

The function executes properly regardless, and no immediate funds are at risk; however, other mechanisms that listen to the StrategyDeallocationLoss may be at risk as the third parameter, wethRedeemed would always return 0.

References

Proof of Concept

Proof of Concept

Place the following into MorphoYearnOGWETHStrategyTest.t.sol

Place this in MorphoYearnOGWETHStrategyTest contract

This will result in an error due to Foundry's vm.expectEmit, which struggles to compare dynamic types like strings and bytes (when comparing the actual emitted string and the expected emitted string). But from the stack trace, we can see that an event was truly logged at that point. This occurs for every possible value of amount

Was this helpful?