The deposit will be reverted because _mytSharesDeposited references an outdated value
The contract's internal counter of deposited collateral is not reduced when a position is liquidated, so it overstates the actual amount. This can cause new deposits to be rejected once the counter reaches the deposit cap, even though real collateral is lower.
Originally disclosed on Immunefi
- Disclosed after under an hour
56845 sc high the deposit will be reverted because mytsharesdeposited references an outdated value
Submitted on Oct 21st 2025 at 07:19:02 UTC by @pashap9990 for Audit Comp | Alchemix V3
- Report ID: #56845
- 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
Finding Description and Impact
_mytSharesDeposited shows how much collateral has been put into AlchemistV3. In addition, its value will go down once CDP holders take back their collateral. Nevertheless, it would not update after a CDP that will be liquidated, leading to denial of service.
Furthermore, users are prohibited from depositing into AlchemistV3 beyond the established capacity set by the owner. This implies that if _mytSharesDeposited exceeds the actual amount, the user cannot deposit, as _mytSharesDeposited + amount would surpass depositCap.
Textual PoC
Presume depositCap is 200,000
- User A deposits 200,000 alUSD into AlchemistV3.(_mytSharesDeposited = 200,000)
- User A will be susceptible to liquidation, resulting in the transfer of their collateral to
Transmitur, while_mytSharesDepositedremains at 200,000. - Other users are unable to deposit, as AlchemistV3's capacity is at its limit.
Code Snippet
Proof of Concept
Proof of Concept
Please incorporate the following PoC in AlchemistV3.t.sol.
function testMytSharesDepositedPointsToStaleValueWhichCausesProtocolInsolvency() public {
vm.startPrank(someWhale);
IMockYieldToken(mockStrategyYieldToken).mint(whaleSupply, someWhale);
vm.stopPrank();
vm.prank(alOwner);
alchemist.setDepositCap(depositAmount);
vm.startPrank(address(0xbeef));
SafeERC20.safeApprove(address(vault), address(alchemist), depositAmount + 100e18);
alchemist.deposit(depositAmount, address(0xbeef), 0);
// a single position nft would have been minted to 0xbeef
uint256 tokenIdFor0xBeef = AlchemistNFTHelper.getFirstTokenId(address(0xbeef), address(alchemistNFT));
alchemist.mint(tokenIdFor0xBeef, alchemist.totalValue(tokenIdFor0xBeef) * FIXED_POINT_SCALAR / minimumCollateralization, address(0xbeef));
vm.stopPrank();
uint256 transmuterPreviousBalance = IERC20(address(vault)).balanceOf(address(transmuterLogic));
// // modify yield token price via modifying underlying token supply
uint256 initialVaultSupply = IERC20(address(mockStrategyYieldToken)).totalSupply();
IMockYieldToken(mockStrategyYieldToken).updateMockTokenSupply(initialVaultSupply);
// increasing yeild token suppy by 59 bps or 5.9% while keeping the unederlying supply unchanged
uint256 modifiedVaultSupply = (initialVaultSupply * 590 / 10_000) + initialVaultSupply;
IMockYieldToken(mockStrategyYieldToken).updateMockTokenSupply(modifiedVaultSupply);
(uint256 assets, uint256 feeInYield, uint256 feeInUnderlying) = alchemist.liquidate(tokenIdFor0xBeef);
vm.startPrank(yetAnotherExternalUser);
SafeERC20.safeApprove(address(vault), address(alchemist), depositAmount / 2);
vm.expectRevert();
alchemist.deposit(depositAmount / 2, yetAnotherExternalUser, 0);
vm.stopPrank();
}
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 deposit counter is not decremented during liquidation, leaving it stale.
Impact
Users may be unable to deposit because the contract incorrectly believes it has reached its deposit cap, causing a denial of service for new deposits.
What the attacker needed
Deposit cap is set; a position reaches the cap; the position becomes liquidatable and is liquidated
How it was found
- Set the deposit cap to a value.
- A user deposits an amount equal to the cap.
- The user's position becomes liquidatable and is liquidated, moving collateral out.
- Another user tries to deposit but the transaction reverts because the stale counter plus the new amount exceeds the cap.
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.
A smart contract keeps a running total of how much collateral users have deposited. When a user's position is liquidated, their collateral is taken away, but the running total is not reduced. Later, the contract thinks it is full and refuses new deposits, even though there is actually room.
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.