# Partial vs full liquidation mismatch

Liquidation paths where a cap, min-size check, or exact-equality test blocks full or partial close, leaving bad debt.

_Area: DeFi oracles, liquidations and flash loans. Seen in 8 disclosed reports; latest 2026-02-05. Updated 2026-10-22._

## How it works
Liquidation code assumes a clean split between "partial" and "full" close, but the two paths disagree on what debt remains. A cap on repay amount, a minimum-borrow check, or an exact-equality test on an accruing value means the residual debt after a partial close still violates a downstream invariant, or the full-close path is unreachable. The position then cannot be liquidated at all, and bad debt accrues.

## Where it shows up
- A repay cap (e.g. maxLiquidatorDeposit) combined with a post-close `debt < minBorrow` require [E2](https://bugbountylibrary.com/r/sherlock%3A2023-03-notional%3AH-10.md).
- Full-repay branch gated on `deltaDebt == calcTotalDebt(...)` where debt accrues per second [E4](https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AH-11.md).
- Liquidation entrypoint that burns the entire debt with no amount parameter [E5](https://bugbountylibrary.com/r/c4%3A2024-04-dyad%3AH-02.md).
- Per-call operation touching one of several coupled debts while the invariant check validates all [E1](https://bugbountylibrary.com/r/sherlock%3A2023-03-notional%3AH-9.md).
- Health/risk assert that rejects zero risk, blocking the terminal full-close state [E7](https://bugbountylibrary.com/r/c4%3A2025-03-starknet-perpetual%3AM-01.md).
- Order treated as fully filled when only partially filled [E6](https://bugbountylibrary.com/r/c4%3A2025-08-gte-perps-and-launchpad%3AM-15.md).
- Wrapper caching original position size, ignoring partial liquidation by the underlying [E8](https://bugbountylibrary.com/r/c4%3A2023-04-rubicon%3AM-19.md).
- Close-factor validated before a min-remaining-debt bump mutates the amount [E3](https://bugbountylibrary.com/r/c4%3A2026-04-k2%3AH-06.md).

## How to review
For every liquidation entrypoint, trace the repay amount from input through any cap, clamp, or bump to the final state change. The invariant: for any position the protocol deems liquidatable, there exists a reachable call that either fully closes it or leaves residual debt satisfying every downstream min-size and health check. Check that full-close is reachable when debt accrues, that partial-close residuals pass min-borrow checks, and that terminal zero-risk states are accepted. Verify order fills are FOK or remaining amount is checked before writing off margin.

## Variants seen
- Min-borrow check blocks deleverage of sub-minimum coupled debts [E1](https://bugbountylibrary.com/r/sherlock%3A2023-03-notional%3AH-9.md).
- Repay cap plus min-borrow require forces full liquidation, unreachable for large debt [E2](https://bugbountylibrary.com/r/sherlock%3A2023-03-notional%3AH-10.md).
- Close factor validated before amount bump to full debt [E3](https://bugbountylibrary.com/r/c4%3A2026-04-k2%3AH-06.md).
- Exact-equality full-repay branch unreachable due to interest accrual [E4](https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AH-11.md).
- No partial-liquidation parameter, capping liquidatable size [E5](https://bugbountylibrary.com/r/c4%3A2024-04-dyad%3AH-02.md).
- Partial fill treated as full close [E6](https://bugbountylibrary.com/r/c4%3A2025-08-gte-perps-and-launchpad%3AM-15.md).
- Zero-risk assert blocks full liquidation [E7](https://bugbountylibrary.com/r/c4%3A2025-03-starknet-perpetual%3AM-01.md).
- Wrapper assumes original size after underlying partial liquidation [E8](https://bugbountylibrary.com/r/c4%3A2023-04-rubicon%3AM-19.md).

## Impact and severity
Unliquidatable or under-liquidated positions accrue bad debt, in some cases protocol-wide loss on large positions [E2](https://bugbountylibrary.com/r/sherlock%3A2023-03-notional%3AH-10.md)[E5](https://bugbountylibrary.com/r/c4%3A2024-04-dyad%3AH-02.md). Severity is high when positions are large relative to available liquidity or when the block is permanent [E1](https://bugbountylibrary.com/r/sherlock%3A2023-03-notional%3AH-9.md)[E2](https://bugbountylibrary.com/r/sherlock%3A2023-03-notional%3AH-10.md).

## Evidence
- E1: https://bugbountylibrary.com/r/sherlock%3A2023-03-notional%3AH-9.md
- E2: https://bugbountylibrary.com/r/sherlock%3A2023-03-notional%3AH-10.md
- E3: https://bugbountylibrary.com/r/c4%3A2026-04-k2%3AH-06.md
- E4: https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AH-11.md
- E5: https://bugbountylibrary.com/r/c4%3A2024-04-dyad%3AH-02.md
- E6: https://bugbountylibrary.com/r/c4%3A2025-08-gte-perps-and-launchpad%3AM-15.md
- E7: https://bugbountylibrary.com/r/c4%3A2025-03-starknet-perpetual%3AM-01.md
- E8: https://bugbountylibrary.com/r/c4%3A2023-04-rubicon%3AM-19.md
