# Liquidating maturies with unassigned earnings will not take into account floating assets increase leading to loss of funds

Liquidation preview in Auditor.checkLiquidation ignores floating-asset accrual from unassigned earnings, so liquidators seize too little collateral, leaving funds stuck or bad debt unclearable.

- Payout: Audit contest
- Severity: medium
- Program: Exactly Stacking Contracts
- Found by: 0x73696d616f
- Disclosed: 2024-07-17
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-07-exactly-stacking-contracts-judging/issues/64
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-07-exactly-stacking-contracts%3AM-8
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:liquidation

**Target:** Market/Auditor liquidation accounting (Solidity)
**Root cause:** Auditor.checkLiquidation computes collateral from shares only, not accounting for floating assets increase from unassigned earnings applied in Market.noTransferRepayAtMaturity; checkLiquidation runs before that increase.
**Steps:**
1. Deposit liquidity; BOB deposits 100 ether and borrowsAtMaturity 60e18 for 4 weeks.
2. Skip 10 weeks so unassigned earnings accrue.
3. accountSnapshot(BOB) shows coll=100e18, debt=111.24e18.
4. ALICE calls `market.liquidate(BOB, 100_000 ether, market)`.
5. Post-liquidation snapshot shows coll=4.55e15 and debt=20.33e18 remaining, though debt>collateral should have seized all collateral.
**How found:** Code reading of Auditor.checkLiquidation collateral computation versus Market.noTransferRepayAtMaturity floating-asset increase, noting checkLiquidation is invoked before the increase in liquidate().
**Exploitation:** Liquidator calls liquidate; checkLiquidation underestimates collateral value because floating-asset accrual from unassigned earnings is not previewed, so less collateral is seized than entitled, leaving residual collateral or unclearable bad debt.
**Insight:** When a liquidation preview reads share balances but the repay path mutates pool-level accounting (floating assets/earnings accumulator) afterward, the preview under-values collateral; check ordering of state mutations relative to solvency checks.

## Proof of concept (copied exactly from the original report)

**Foundry test proving incomplete liquidation from floating assets**

```
function test_POC_FloatingAssetsIncrease() external {
  uint256 maxVal = type(uint256).max;

  market.deposit(10000 ether, address(this));

  vm.startPrank(BOB);
  market.deposit(100 ether, BOB);
  market.borrowAtMaturity(4 weeks, 60e18, maxVal, BOB, BOB);
  vm.stopPrank();

  skip(10 weeks);

  (uint256 coll, uint256 debt) = market.accountSnapshot(BOB);
  assertEq(coll, 100e18);
  assertEq(debt, 111.246904109483404820e18);

  vm.startPrank(ALICE);
  market.liquidate(BOB, 100_000 ether, market);
  vm.stopPrank();

  (coll, debt) = market.accountSnapshot(BOB);
  assertEq(coll, 4.557168045571680e15);
  assertEq(debt, 20.337813200392495730e18);
}
```

