Skip to content
Business logic Audit finding Intermediate

# AlchemistV::liquidate is not updating the _mytSharesDeposited which makes it inflated and can cause deposits DoS and liquidations malfunction that may cause protocol insolvency.

The liquidate function transfers collateral out of the contract but never reduces the global _mytSharesDeposited counter, so the counter grows more inflated with every liquidation. This inflated value can push deposits past the deposit cap (denying new deposits) and makes the protocol's collateralisation appear healthier than it is, which could hide undercollateralisation and lead to insolvency.

Luc1jan Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

57725 sc high alchemistv liquidate is not updating the mytsharesdeposited which makes it inflated and can cause deposits dos and liquidations malfunction that may cause protocol insolvency

Submitted on Oct 28th 2025 at 13:43:58 UTC by @luc1jan for Audit Comp | Alchemix V3

Description

Brief/Intro

Liquidations freeze and transfer user's collateral from contract, but lack _mytSharesDeposited update which makes the state variable inflated and will cause deposit DoS along with potential malfunctions in liquidations that can lead to insolvency.

Vulnerability Details

Liquidations reduce liquidated collateral (yield tokens) and transfer it from the contract to Transmuter and fees recipients. However, the state variable _mytSharesDeposited which represents global deposited amount of yield tokens is not updated. With every liquidation, it becomes more and more inflated. This will effectively cause deposit DoS because inflated _mytSharesDeposited will reach depositCap and line 369 will revert. Additionally the protocol underlying value will be inflated because it uses _mytSharesDeposited as a source of truth. This will cause protocol to appear healthy even if it's globally undercollateralized, leading to eventual insolvency.

Impact Details

During the lifecycle of the protocol, it is almost certain we will reach depositCap because of inflated _mytSharesDeposited. The check on line 369 will revert causing deposit DoS:

JavaScript
    _checkState(_mytSharesDeposited + amount <= depositCap);

Additionally, the _getTotalUnderlyingValue will return inflated amount because it's using _mytSharesDeposited. This will make alchemistCurrentCollateralization argument inside calculateLiquidation inflated as well, causing this check to always return false even in cases when protocol is unhealthy:

JavaScript
if (alchemistCurrentCollateralization < alchemistMinimumCollateralization) {
    outsourcedFee = (debt * feeBps) / BPS;
    // fully liquidate debt in high ltv global environment
    return (debt, debt, 0, outsourcedFee);
}

Global undercollateralization will go unnoticed leading to even deeper undercollateralization and eventually to insolvency.

References

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

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

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

Proof of Concept

Proof of Concept

JavaScript
    function test_mytSharesInflationPOC() external {
        // 1. create a position and then adjust the price so it becomes liquidatable
        address user = address(0xbeef);
        uint256 _depositAmount = 100_000e18;
        
        // Setup whale with yield tokens
        vm.startPrank(someWhale);
        IMockYieldToken(mockStrategyYieldToken).mint(whaleSupply, someWhale);
        vm.stopPrank();
        
        // Create a position that's at the edge of liquidation
        vm.startPrank(user);
        SafeERC20.safeApprove(address(vault), address(alchemist), _depositAmount + 100e18);
        alchemist.deposit(_depositAmount, user, 0);
        uint256 tokenId = AlchemistNFTHelper.getFirstTokenId(user, address(alchemistNFT));
        // Mint at exactly the minimum collateralization ratio
        alchemist.mint(tokenId, alchemist.totalValue(tokenId) * FIXED_POINT_SCALAR / minimumCollateralization, user);
        vm.stopPrank();
        
        // Make position liquidatable by decreasing yield token price (increasing supply)
        uint256 initialVaultSupply = IERC20(address(mockStrategyYieldToken)).totalSupply();
        IMockYieldToken(mockStrategyYieldToken).updateMockTokenSupply(initialVaultSupply);
        // Increase yield token supply by 6% to make position undercollateralized
        uint256 modifiedVaultSupply = (initialVaultSupply * 600 / 10_000) + initialVaultSupply;
        IMockYieldToken(mockStrategyYieldToken).updateMockTokenSupply(modifiedVaultSupply);
        
        // 2. log current mytSharesDeposited and myt contract balance
        uint256 mytContractBalanceBefore = alchemist.getTotalDeposited();
        uint256 mytAccountingValueBefore = alchemist.getTotalUnderlyingValue();
        uint256 mytAccountingValueBeforeInYield = alchemist.convertUnderlyingTokensToYield(mytAccountingValueBefore);

        emit log_string("Before Liquidation:");
        emit log_named_uint("MYT contract balance", mytContractBalanceBefore / 1e16);
        emit log_named_uint("_mytSharesDeposited", mytAccountingValueBeforeInYield / 1e16);

        // 3. liquidate the position
        vm.startPrank(externalUser);
        (uint256 liquidationAmount, uint256 feeInYield, uint256 feeInUnderlying) = alchemist.liquidate(tokenId);
        vm.stopPrank();

        // 4. log balances
        uint256 mytContractBalanceAfter = alchemist.getTotalDeposited();
        uint256 mytAccountingValueAfter = alchemist.getTotalUnderlyingValue();
        uint256 mytAccountingValueAfterInYield = alchemist.convertUnderlyingTokensToYield(mytAccountingValueAfter);

        emit log_string("After Liquidation:");
        emit log_named_uint("MYT contract balance", mytContractBalanceAfter / 1e16);
        emit log_named_uint("_mytSharesDeposited", mytAccountingValueAfterInYield / 1e16);
    }
Logs:
  Before Liquidation:
  MYT contract balance: 10000000
  _mytSharesDeposited: 9999999
  After Liquidation:
  MYT contract balance: 459999
  _mytSharesDeposited: 9999999

The PoC demonstrated that _mytSharesDeposited is not reduced in liquidations which means inflation will accrue indefinitely with each liquidation.

The original report as published on Immunefi, by luc1jan. 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

Likely the liquidate function reduces and transfers collateral out of the contract without decrementing the _mytSharesDeposited accounting variable.

Impact

The inflated counter will eventually reach the deposit cap and block all new deposits, and it inflates the protocol's perceived collateral value so global undercollateralisation may go unnoticed, potentially leading to insolvency.

What the attacker needed

A liquidatable position; a liquidation is performed

How it was found

  1. Create a position and adjust the yield token price so the position becomes liquidatable.
  2. Record the contract's collateral balance and the _mytSharesDeposited value.
  3. Call liquidate on the position from another account.
  4. Record the balances again and observe that the contract balance dropped while _mytSharesDeposited stayed the same.

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.

The contract keeps a running total of how much collateral users have deposited. When a position is liquidated, collateral leaves the contract, but that running total is never reduced, so it keeps counting collateral that is no longer there. Because deposits are capped against this total, the cap is eventually hit and no one can deposit, and the contract also thinks it holds more than it does.

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 Luc1jan

View all

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