# Zero divisor in accounting math

Divisors from rates, supply, or config that can reach zero and revert settlement

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

## How it works
Accounting math divides by a value the code assumes is positive: a rate, a derived supply, a distance, or a config-derived collateral value. When that value legitimately reaches zero, the division reverts. The broken assumption is that the divisor is always nonzero; nothing enforces it. Because the revert sits inside settlement, health-check, or fee paths, the failure is not a bad number but a blocked operation.

## Where it shows up
- A config field used both as a parameter and as an enable/disable flag, whose derived value (collateralValue) feeds a divisor [E1](https://bugbountylibrary.com/r/c4%3A2024-03-revert-lend%3AM-20.md).
- Supply metrics computed as `total - contractHeldBalance`, where the balance can equal the total [E2](https://bugbountylibrary.com/r/c4%3A2024-01-curves%3AM-07.md).
- `max(width/2, distance)` floors that collapse to zero at a boundary (width==1, at strike) [E3](https://bugbountylibrary.com/r/c4%3A2025-12-panoptic-next-core%3AM-05.md).

## How to review
For every divisor, trace its full range including the disabled/empty/boundary state. The invariant: any value used as a divisor must be provably `>0` at the point of division, or the branch must be skipped. Check that "disable" config states don't zero a value still used downstream [E1](https://bugbountylibrary.com/r/c4%3A2024-03-revert-lend%3AM-20.md). Check boundary arithmetic (balance==total, width==1 at strike) explicitly [E2](https://bugbountylibrary.com/r/c4%3A2024-01-curves%3AM-07.md)[E3](https://bugbountylibrary.com/r/c4%3A2025-12-panoptic-next-core%3AM-05.md). Prioritize E1 and E3: these are the clearest accounting-math cases where a divisor silently reaches zero.

## Variants seen
- Delisting flag zeroes collateralValue used as divisor in liquidation and health checks [E1](https://bugbountylibrary.com/r/c4%3A2024-03-revert-lend%3AM-20.md).
- Derived supply hits zero after full ERC20 withdrawal, reverting addFees [E2](https://bugbountylibrary.com/r/c4%3A2024-01-curves%3AM-07.md).
- Margin floor term zero at width==1, at strike, blocking solvency checks [E3](https://bugbountylibrary.com/r/c4%3A2025-12-panoptic-next-core%3AM-05.md).

## Impact and severity
Led to broken liquidations and health checks [E1](https://bugbountylibrary.com/r/c4%3A2024-03-revert-lend%3AM-20.md), bricked sells [E2](https://bugbountylibrary.com/r/c4%3A2024-01-curves%3AM-07.md), and blocked liquidation/force-exercise [E3](https://bugbountylibrary.com/r/c4%3A2025-12-panoptic-next-core%3AM-05.md). Severity rises when the revert sits in a settlement or liquidation path, freezing funds, and when the zero divisor also lets value be mispriced rather than merely reverting.

## Evidence
- E1: https://bugbountylibrary.com/r/c4%3A2024-03-revert-lend%3AM-20.md
- E2: https://bugbountylibrary.com/r/c4%3A2024-01-curves%3AM-07.md
- E3: https://bugbountylibrary.com/r/c4%3A2025-12-panoptic-next-core%3AM-05.md
