# Deposits are eliminated before currently unclaimed reserves when there is no reserve auction

Ajna's settle() counts expired reserve-auction unclaimed funds as liabilities, so bad debt is written off against depositors while free reserves sit unused.

- Payout: Contest reward
- Severity: medium
- Program: Ajna
- Credited: hyh
- Disclosed: 2022-12-21
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-01-ajna-judging/issues/102
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-12
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** ERC20Pool/ERC721Pool settle() and Auctions.settlePoolDebt
**Root cause:** settle() computes liabilities including reserveAuction.unclaimed unconditionally, even after the 72h reserve auction window has ended, so unclaimed reserves are treated as owed rather than free pool funds available to cover bad debt.
**Steps:**
1. Observe reserve auction ends by timer (kicked + 72h) with unclaimed > 0 if not fully taken.
2. Call settle() on a borrower with t0Debt != 0 and collateral == 0.
3. Note liabilities = Deposits.treeSum + totalBondEscrowed + reserveAuction.unclaimed, so reserves = assets - liabilities excludes the unclaimed amount.
4. settlePoolDebt() then covers debt only from remaining reserves, then writes off HPB deposits, emitting BucketBankruptcy.
5. Fix: only include unclaimed in liabilities when kicked != 0 && block.timestamp - kicked <= 72 hours.
**How found:** Code reading of settle() liability accounting versus the whitepaper's stated order of bad-debt coverage (reserves before deposits); noticed unclaimed is never adjusted when the auction expires unsold.
**Insight:** When auditing accounting invariants, check whether state that is only valid during a time window (auction unclaimed) is still counted as a liability after the window closes; expired auction remainders become free funds.
