# Unshared losses in DeFi accounting

Losses realized late or recorded wrong, so early exiters escape and remaining holders absorb the shortfall

_Area: DeFi accounting and math bugs. Seen in 38 disclosed reports; latest 2026-03-09. Updated 2026-10-23._

## How it works
A pool promises every holder the same value per share. That holds only if each loss is subtracted from the shared pot before anyone exits. The bug is a loss that is realized late, recorded in the wrong place, or never subtracted, so an early withdrawer is paid at the old healthy rate and the shortfall lands on whoever is left. The broken assumption: "the accounting variable the withdrawal price reads already reflects all losses."

## Where it shows up
- Withdrawal claims recorded in nominal underlying (1 token = 1 collateral) while a yield source can lose value [E3](https://bugbountylibrary.com/r/sherlock%3A2025-04-pareto-contest%3AM-2.md).
- Bad debt socialized by minting shares or dropping totalAssets, with no lock or pro-rata haircut on withdrawals around the event [E6](https://bugbountylibrary.com/r/c4%3A2025-12-panoptic-next-core%3AM-19.md).
- Loss realized only when a depositor withdraws; cumulative counters not adjusted on price recovery [E4](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-11.md).
- Ratio/health formulas whose numerator and denominator move on different paths (repay, burn, liquidate, asset transfer to a sibling contract) [E7](https://bugbountylibrary.com/r/cantina%3Aalchemix_may2025%3A3.1.8.md).
- Liquidation paths passing profit/loss to a pool with mismatched argument semantics, or a callee branch that drops one of profit/loss [E1](https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AH-02.md).
- Pro-rata payout via integer division where a batch can be partially executed [E2](https://bugbountylibrary.com/r/c4%3A2024-08-wildcat%3AH-01.md).
- A `returned < expected` shortfall check where the returned amount is net of fees [E8](https://bugbountylibrary.com/r/cantina%3Aterm_structure_february2025%3A3.2.8.md).

## How to review
The invariant: at any exit, sum of all claims after the exit must not exceed remaining assets, and each exiting holder bears their share of every loss already incurred. Concretely: (1) list every path that changes assets or debt and confirm each updates the same variable the withdrawal price reads (totalAssets, totalSupply, or the epoch claim); (2) check whether withdrawal claims are denominated in shares or nominal value; (3) for ratio formulas, walk each state-mutating path and confirm numerator and denominator move consistently [E7](https://bugbountylibrary.com/r/cantina%3Aalchemix_may2025%3A3.1.8.md); (4) for liquidation profit/loss, confirm caller arguments and callee branch structure agree [E1](https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AH-02.md); (5) for batched pro-rata payouts, test many tiny shares and partial execution [E2](https://bugbountylibrary.com/r/c4%3A2024-08-wildcat%3AH-01.md); (6) check every shortfall branch for fee-vs-loss confusion [E8](https://bugbountylibrary.com/r/cantina%3Aterm_structure_february2025%3A3.2.8.md).

## Variants seen
- Nominal-value redemption claims after bad debt [E3](https://bugbountylibrary.com/r/sherlock%3A2025-04-pareto-contest%3AM-2.md).
- Front-running socialization by withdrawing before dilution [E6](https://bugbountylibrary.com/r/c4%3A2025-12-panoptic-next-core%3AM-19.md).
- Deferred loss realization on withdrawal only [E4](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-11.md).
- Ratio denominator shrunk by asset transfer to sibling contract [E7](https://bugbountylibrary.com/r/cantina%3Aalchemix_may2025%3A3.1.8.md).
- Profit/loss argument errors in liquidation, plus an else-if dropping one when both are nonzero [E1](https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AH-02.md).
- Rounding in partially executed pro-rata batches [E2](https://bugbountylibrary.com/r/c4%3A2024-08-wildcat%3AH-01.md).
- Fee misclassified as bad debt [E8](https://bugbountylibrary.com/r/cantina%3Aterm_structure_february2025%3A3.2.8.md).

## Why fixes fail
E1 is one example: a patch fixed the caller's argument but left the callee's else-if dropping one of profit/loss when both are nonzero. Verify fixes at both call sites and branch structure.

## Impact and severity
Losses shift to late withdrawers, who may be unable to withdraw at all [E2](https://bugbountylibrary.com/r/c4%3A2024-08-wildcat%3AH-01.md)[E4](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-11.md); new depositors absorb prior losses [E3](https://bugbountylibrary.com/r/sherlock%3A2025-04-pareto-contest%3AM-2.md); LPs are diluted [E6](https://bugbountylibrary.com/r/c4%3A2025-12-panoptic-next-core%3AM-19.md); redeemers are underpaid [E7](https://bugbountylibrary.com/r/cantina%3Aalchemix_may2025%3A3.1.8.md)[E8](https://bugbountylibrary.com/r/cantina%3Aterm_structure_february2025%3A3.2.8.md). Severity rises when exits are permissionless and losses are large relative to the pool.

## Evidence
- E1: https://bugbountylibrary.com/r/c4%3A2024-10-loopfi%3AH-02.md
- E2: https://bugbountylibrary.com/r/c4%3A2024-08-wildcat%3AH-01.md
- E3: https://bugbountylibrary.com/r/sherlock%3A2025-04-pareto-contest%3AM-2.md
- E4: https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-11.md
- E5: https://bugbountylibrary.com/r/sherlock%3A2024-06-new-scope%3AH-7.md
- E6: https://bugbountylibrary.com/r/c4%3A2025-12-panoptic-next-core%3AM-19.md
- E7: https://bugbountylibrary.com/r/cantina%3Aalchemix_may2025%3A3.1.8.md
- E8: https://bugbountylibrary.com/r/cantina%3Aterm_structure_february2025%3A3.2.8.md
