The _addDebt function in AlchemistV3.sol incorrectly calculates required locked collateral using convertDebtTokensToYield, a function that converts debt tokens to yield tokens while comparing it directly against collateralBalance (which is in yield token shares). This unit mismatch breaks the collateralization invariant and causes the collateralization ratio to be incorrectly evaluated, allowing users to mint debt far exceeding the actual value of their collateral. In production, this leads to unbacked synthetic issuance, protocol insolvency, and total loss of depositor funds.
Vulnerability Details
The core logic of _addDebt() performs a collateralization check before allowing additional debt to be added to a user’s account. However, the implementation mistakenly uses convertDebtTokensToYield() to convert debt values into yield tokens, creating a unit mismatch between collateral and debt.
The core issue lies in _addDebt(), called during mint():
account.collateralBalance is denominated in yield tokens (shares).
convertDebtTokensToYield() converts debt tokens into yield tokens, based on the current exchange rate.
convertDebtTokensToYield() assumes parity between yield token shares and underlying debt value, which only holds when the exchange rate = 1.0.
This introduces a unit mismatch when the exchange rate between yield tokens and underlying assets changes (e.g., due to yield accumulation). As a result: The protocol may think an account is over-collateralized when it’s actually under-collateralized.
Or revert valid mints when the account is safely collateralized.
Scenario
ALICE collateralBalance = 100 shares (100 yieldtokenMYT)
ALICE debt = 50 debt token alice minted 50 debt tokens
Because the check is done in mixed units, _addDebt() either falsely reverts or fails to detect insolvency.
Uses shares, not value
When rate > 1.0, toLock shrinks undercollateralized mint
When rate < 1.0, toLock inflates false revert
Even with correct rate, the logic is fundamentally flawed, it measures shares, not economic value.
Impact Details
Severity: Critical
This bug directly affects the core accounting of collateralization:
Attackers can over-mint debt beyond their collateral value when the conversion rate skews, draining protocol liquidity.
Conversely, users may experience false reverts, preventing valid mints and disrupting user experience.
If exploited over time, this can lead to system-wide insolvency, where total outstanding debt exceeds total collateral.
Potential impact:
Complete loss of funds backing the synthetic/debt tokens.
Broken mint/burn balance and liquidation logic.
Systemic collapse of protocol solvency guarantees.
Recommended Mitigation
Use consistent units across the collateralization check always compare values in the same domain (debt units). A correct implementation would look like this
This ensures collateral and debt are compared in the same unit system (debt value), eliminating the mismatch and preventing insolvency risks.