# Incorrect liquidation mechanics either causes revert on liquidation due to insufficient seizeTokens or causes transition into bad debt

Numa's liquidation logic lets partial liquidations shrink collateral so full liquidation reverts with LIQUIDATE_SEIZE_TOO_MUCH or pushes position into bad debt.

- Payout: Audit contest
- Severity: medium
- Program: Numa Audit
- Found by: t0x1c
- Disclosed: 2024-12-04
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-12-numa-audit-judging/issues/101
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-12-numa-audit%3AM-6
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:liquidation

**Target:** Compound-fork lending market (NumaComptroller / CToken / NumaVault liquidation)
**Root cause:** Liquidation incentive is applied on each partial liquidation, worsening collateral-to-debt ratio; once borrowBalance falls below minBorrowAmountAllowPartialLiquidation only full liquidation is allowed, but seizeTokens then exceeds borrower collateral, reverting or leaving bad debt.
**Steps:**
1. Set collateral factor 85%, liquidation incentive 12%, close factor 90% (path 1); path 2 uses close factor 85%.
2. Borrow 80% LTV against NUMA collateral; drop price via sell fee so shortfall>0, badDebt=0 (path 1 sell fee 0.90, path 2 sell fee 0.87).
3. Liquidator repays 55% of debt via `vault.liquidateLstBorrower(userA, repayAmount, false, false)`; succeeds.
4. Remaining borrow now below `minBorrowAmountAllowPartialLiquidation`, so only full liquidation allowed.
5. Attempt full liquidation of remaining debt: reverts `LIQUIDATE_SEIZE_TOO_MUCH` because seizeTokens > collateral balance.
6. Path 2: repay 85% instead (close factor 85%); remaining position now shows badDebt>0, unprofitable for liquidators.
**How found:** Reasoned about interaction between closeFactorMantissa, liquidationIncentive, and minBorrowAmountAllowPartialLiquidation: each partial liquidation raises LTV, so eventually full liquidation is forced but seizeTokens exceeds collateral. Verified with two Foundry tests.
**Exploitation:** A liquidator (or malicious actor) deliberately performs a partial liquidation sized to leave remaining debt just below minBorrowAmountAllowPartialLiquidation while collateral is insufficient to cover full liquidation plus incentive, permanently stranding the position or converting it to bad debt.
**Insight:** In Compound-style forks, check the boundary where partial liquidation is disabled (minBorrowAmountAllowPartialLiquidation) against the seizeTokens math including incentive: a position can become liquidatable-but-unliquidatable. Test partial-then-full liquidation sequences, not just single liquidations.

