58502 sc high deposit cap denial of service due to stale mytsharesdeposited during liquidation
Submitted on Nov 2nd 2025 at 20:41:45 UTC by @zcai for Audit Comp | Alchemix V3
Report ID: #58502
Report Type: Smart Contract
Report severity: High
Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/AlchemistV3.sol
Impacts:
Smart contract unable to operate due to lack of token funds
Description
Brief/Intro
The contract enforces a global deposit cap using the internal counter _mytSharesDeposited, which tracks yield tokens deposited into user positions. However, during liquidations and forced repayments, MYT tokens are transferred out of the contract without decrementing this counter, causing it to become stale and overreported. This results in a denial of service for deposits, as the cap enforcement prevents new deposits even when the contract's actual token balance has decreased below the cap.
Vulnerability Details
The AlchemistV3 contract uses _mytSharesDeposited to track the total amount of yield tokens (MYT) deposited by users and enforce the global depositCap. This counter is properly incremented during deposits and decremented during withdrawals, redemptions, and fee transfers. However, critical outflow paths in the liquidation system fail to update this accounting variable.
During liquidations, the _doLiquidation() function transfers MYT tokens to the transmuter and liquidator without decrementing _mytSharesDeposited. Similarly, the _forceRepay() function, which handles earmarked debt repayment during liquidations, transfers tokens to the transmuter and protocol fee receiver without updating the counter.
The vulnerability manifests when undercollateralized positions undergo liquidation. These operations transfer substantial amounts of MYT out of the contract, reducing the actual token balance while leaving _mytSharesDeposited unchanged. Since deposit() enforces the cap by checking _mytSharesDeposited + amount <= depositCap, freed capacity created by these outflows is never recognized.
Once the system approaches its deposit cap—a common scenario in production—any liquidation activity permanently blocks further deposits for all users. The contract appears to be at capacity based on the stale counter, even though significant token amounts have left the contract and actual capacity exists.
Impact Details
This vulnerability causes a systemic denial of service for the core deposit functionality. When liquidations transfer MYT tokens out without updating _mytSharesDeposited, the accounting variable becomes permanently inflated relative to the actual token balance. This prevents the deposit cap from reflecting freed capacity, blocking legitimate user deposits even when the contract has available room. The issue persists until administrative intervention raises the cap, effectively requiring manual workarounds for normal protocol operations. Additionally, the _getTotalUnderlyingValue() function relies on _mytSharesDeposited for TVL calculations, resulting in overstated metrics that may impact liquidation logic and protocol risk assessments.
References
https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/AlchemistV3.sol#L365-L372
https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/AlchemistV3.sol#L771-L780
https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/AlchemistV3.sol#L875-L889
Link to Proof of Concept
https://gist.github.com/i-am-zcai/0630d2becc015e8debf8cde4f7b6e657
Proof of Concept
Proof of Concept
src/test/poc/DepositCapDoS.t.sol
Was this helpful?