57730 sc high liquidation does not decrease mytsharesdeposited

Submitted on Oct 28th 2025 at 14:13:56 UTC by @MentemDeus28 for Audit Comp | Alchemix V3arrow-up-right

  • Report ID: #57730

  • Report Type: Smart Contract

  • Report severity: High

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

  • Impacts:

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

Description

Brief/Intro

During liquidation flows forceRepay, liquidate, and _doLiquidation, the protocol properly transfers the corresponding MYT tokens from the user’s position and adjusts their collateral and debt balances.

However, the accounting variable mytSharesDeposited which tracks the total amount of MYT shares a user has deposited into the system is not updated or reduced when a liquidation occurs.

This causes a state inconsistency between actual MYT balances and recorded accounting values. Even though the user’s MYT tokens are transferred out of their position to the transmuter, liquidator, mytSharesDeposited remains unchanged.

Vulnerability Details

/// @dev Total yield tokens deposited
    /// This is used to differentiate between tokens deposited into a CDP and balance of the contract
    uint256 private _mytSharesDeposited; //private

The forceRepay, liquidate, and _doLiquidation functions modify collateral and debt state but never decrement the corresponding user’s mytSharesDeposited or any equivalent share tracking variable after liquidating MYT tokens. This omission allows mytSharesDeposited to remain inflated despite the actual shares being removed from the system.

Impact Details

this can lead to several potential issues:

Accounting drift: system assumes more collateralized MYT shares than actually exist.

Potential mis-calculations.

Misleading TVL.

update mytSharesDeposited aftera successful liquidation or forcerepay.

References

https://github.com/alchemix-finance/v3-poc/blob/a192ab313c81ba3ab621d9ca1ee000110fbdd1e9/src/AlchemistV3.sol#L852

Proof of Concept

Proof of Concept

Consider changing the _mytSharesDeposited variable to public for testing

Expected Output Ran 1 test for src/test/MyPoc.t.sol:AlchemistV3POCGROUND [PASS] test_liquidation_does_not_deduct_mytSharesDeposited() (gas: 554686)

Logs: Before Liquidation:

MYT Balance (shares) before: 1000000000000000000

_mytSharesDeposited before: 1000000000000000000

After Liquidation:

MYT Balance (shares) after: 0

_mytSharesDeposited after: 1000000000000000000

Was this helpful?