# badDebtRatio is calculated after removing the yield token from Alchemist, making worse ratio is used for sent amount

Transmuter computes badDebtRatio after pulling yield tokens, so redemptions use an inflated ratio and users receive less than owed.

- Payout: Contest reward
- Severity: high
- Program: Alchemix
- Credited: farismaulana
- Disclosed: 2025-07-15
- Write-up quality: 7/10
- Original: https://cdn.cantina.xyz/reports/cantina_competition_alchemix_may2025.pdf#3.1.10
- Library page: https://bugbountylibrary.com/r/cantina%3Aalchemix_may2025%3A3.1.10
- Tags: domain:web3 impact:funds-loss kind:contest platform:cantina sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** Transmuter.sol claimRedemption / Alchemist getTotalUnderlyingValue
**Root cause:** claimRedemption transfers the full yield-token amount into Transmuter before computing badDebtRatio from alchemist.getTotalUnderlyingValue(), so the ratio reflects post-transfer (reduced) underlying value.
**Steps:**
1. Deploy Transmuter inheriting forge Test to log badDebtRatio inside claimRedemption.
2. Deposit 200,000 yield tokens as 0xbeef, mint synthetics at minimum collateralization.
3. Transfer 110,000 alTokens to 0xdad; createRedemption(100_000e18) and createRedemption(10_000e18).
4. Roll forward 5,256,001 blocks to mature redemptions.
5. Inflate yield token supply 12% via updateMockTokenSupply to create bad debt.
6. Call claimRedemption(1) and claimRedemption(2); observe ratio used 1.0181e18 vs actual 1.008e18, then 1.0203e18.
**How found:** Code reading of claimRedemption ordering: noticed the yield-token transfer precedes the badDebtRatio computation, hypothesized the post-transfer underlying value skews the ratio, and instrumented the contract with console.log to confirm.
**Exploitation:** When system is in bad debt, each claim transfers full transmuted yield tokens first, lowering getTotalUnderlyingValue and inflating the ratio applied to claimAmount, so users get less than the fair pro-rata amount; leftover tokens sit idle in Transmuter.
**Insight:** In redemption/withdrawal flows, check whether solvency or share-price ratios are computed before or after the asset transfer; moving value into the contract first can silently worsen the ratio applied to the user.
