57172 sc high missing mytsharesdeposited decrements in liquidation flows causes accounting divergence

Submitted on Oct 24th 2025 at 03:59:42 UTC by @Smartkelvin for Audit Comp | Alchemix V3arrow-up-right

  • Report ID: #57172

  • Report Type: Smart Contract

  • Report severity: High

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

  • Impacts:

    • Permanent freezing of funds

Description

Brief/Intro

The AlchemistV3 contract fails to decrement the internal _mytSharesDeposited variable when yield tokens are transferred out during liquidation operations (_doLiquidation and _forceRepay). This accounting error causes _mytSharesDeposited to become inflated relative to the actual MYT token balance held by the contract. As a consequence, the deposit cap check becomes overly restrictive (preventing legitimate deposits even when capacity exists), the Total Value Locked (TVL) calculation via _getTotalUnderlyingValue() becomes overstated, and the bad debt ratio used by the Transmuter for redemption payouts is understated, potentially allowing users to extract more value than entitled during system insolvency

Vulnerability Details

The _mytSharesDeposited variable is designed to track the total yield tokens deposited into CDPs, as indicated by its comment

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

Throughout the codebase, _mytSharesDeposited is correctly updated in most token transfer operations:

Correct implementations:

deposit(): Increments _mytSharesDeposited when tokens enter

withdraw(): Decrements _mytSharesDeposited when tokens leave

burn(): Decrements _mytSharesDeposited for protocol fee deduction

repay(): Decrements _mytSharesDeposited for protocol fee deduction

redeem(): Decrements _mytSharesDeposited for all outbound transfers

However, liquidation flows are missing these decrements:

The inflated _mytSharesDeposited impacts three critical area

Deposit Cap Check (AlchemistV3.sol)

TVL Calculation (AlchemistV3.sol)

Bad Debt Ratio in Transmuter (Transmuter.sol)

Impact Details

Deposit Cap Bypass Prevention (DoS)

After liquidations occur, _mytSharesDeposited remains inflated while the actual MYT balance decreases. This may causes the deposit cap check to incorrectly reject valid deposits

Overstated TVL Calculations

The _getTotalUnderlyingValue() function directly uses the inflated _mytSharesDeposited

Understated Bad Debt Ratio in Transmuter The Transmuter uses getTotalUnderlyingValue() (which relies on _mytSharesDeposited) to calculate the bad debt ratio for scaling redemption payouts:

Proof of Concept

Proof of Concept

Was this helpful?