The missing fee calculation when debt exceeds collateral in AlchemistV3.sol::calculateLiquidation() will cause a complete loss of liquidation fee revenue for the protocol as liquidators will receive 100% of collateral without paying the expected 5% liquidation fee when positions reach critical undercollateralization.
Vulnerability Details
Root Cause
In AlchemistV3.sol:1252-1255, the calculateLiquidation() function returns a fee of 0 when debt >= collateral, allowing liquidators to claim the entire collateral amount without paying any liquidation fees:
functioncalculateLiquidation(uint256collateral,uint256debt,uint256targetCollateralization,uint256alchemistCurrentCollateralization,uint256alchemistMinimumCollateralization,uint256feeBps)publicpurereturns(uint256grossCollateralToSeize,uint256debtToBurn,uint256fee,uint256outsourcedFee){if(debt >= collateral){ outsourcedFee =(debt * feeBps)/ BPS;// fully liquidate debt if debt is greater than collateralreturn(collateral, debt,0, outsourcedFee);// ❌ fee = 0}// ... rest of function}
The vulnerability exists because when a position becomes severely undercollateralized (debt ≥ collateral), the function immediately returns with fee = 0, bypassing the normal fee calculation logic that would charge the liquidator a percentage of the seized collateral.
Internal Pre-conditions
A user position needs to exist with deposited collateral and minted debt
The position's collateralization ratio needs to drop below the liquidation threshold (collateralizationLowerBound = 150%)
Market conditions or yield token price depreciation needs to cause the position's collateral value to fall to or below the debt value (debt ≥ collateral)
External Pre-conditions
Yield token (MYT) price needs to decrease significantly relative to the underlying token, causing collateral value to drop
Market volatility needs to create conditions where positions can reach critical undercollateralization (debt ≥ collateral value)
Attack Path
Position Creation: A user deposits 1000 yield tokens as collateral and mints 500 debt tokens (50% LTV, within the 200% minimum collateralization requirement)
Market Deterioration: The yield token's conversion rate drops from 100% to 49% due to market conditions, oracle price changes, or yield token depegging
Critical Undercollateralization: The position's collateral value drops to ~490 debt tokens worth, making debt (500) >= collateral (490)
Fee Bypass Exploitation: A liquidator calls liquidate() on the position:
calculateLiquidation() detects debt >= collateral
Returns fee = 0 instead of calculating the proper liquidation fee
Liquidator receives 100% of the remaining collateral (490 tokens worth)
Protocol receives 0 liquidation fee revenue
Revenue Loss: The protocol loses the expected 5% liquidation fee (~24.5 tokens worth) that should have been charged on the seized collateral
Impact Details
The protocol suffers a complete loss of liquidation fee revenue in critical undercollateralization scenarios. Given that:
Liquidation fees are set at 5% (liquidatorFee = 500 bps)
These scenarios are most likely during market stress when liquidations are frequent
The protocol relies on liquidation fees as a revenue stream
Quantified Impact:
For every 1000 tokens of collateral liquidated in debt ≥ collateral scenarios, the protocol loses 50 tokens in expected fees
During market crashes when this condition is most common, the revenue loss compounds across multiple liquidations
This directly reduces protocol sustainability and fee distribution to stakeholders
References
Add any relevant links to documentation or code
Proof of Concept
Proof of Concept
The following test demonstrates the complete fee bypass when debt exceeds collateral.