# Lending pool state transition will be broken when pool is expired in late state

Carapace's pool status check returns Expired before Late, so a late-then-expired pool never unlocks locked capital or triggers default compensation.

- Payout: Contest reward
- Severity: high
- Program: Carapace
- Credited: rvierdiiev
- Disclosed: 2023-02-01
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2023-02-carapace-judging/issues/230
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-02-carapace%3AH-4
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** DefaultStateManager / ReferenceLendingPools lending pool status logic
**Root cause:** _getLendingPoolStatus checks isLendingPoolExpired first, so a pool that is both late and expired (or repaid) resolves to Expired; DefaultStateManager has no Late->Expired transition, so capital stays locked and default detection is skipped.
**Steps:**
1. Read `_getLendingPoolStatus` in ReferenceLendingPools.sol: expired is evaluated before LateWithinGracePeriod and Late.
2. Note GoldfinchAdapter.isLendingPoolExpired returns true when `block.timestamp >= termEndTime` or balance==0.
3. Scenario A: pool in Late (capital locked), then term ends or loan repaid -> status becomes Expired; DefaultStateManager._assessState has no Late->Expired transition, capital never unlocked.
4. Scenario B: pool Active, final payment missed and term ends before assessment -> status Expired directly, capital never locked and default not detected.
5. Observe no compensation path executes in either case.
**How found:** Code reading of the status-ordering in _getLendingPoolStatus against the transition table in DefaultStateManager._assessState, spotting that Expired short-circuits Late and that no Late->Expired edge exists.
**Insight:** When a state machine derives status from ordered boolean checks, enumerate every (prior state, new status) pair against the transition table; a higher-priority terminal check can silently swallow transitions that carry side effects like lock/unlock.
