Liquidation

Anyone can call liquidate(id) on a loan at or above the 70 % threshold, or on a matured unpaid loan. A loan under the threshold before maturity cannot be liquidated: the call reverts (a stateful invariant of the tests).

What the contract does

  1. Reads the guarded price (it must be usable: fresh and within the pool bound).
  2. Sells HYPE for USDC through the Elysium Uniswap v4 HYPE/USDC pool (native HYPE / USDC, 0.30 %, no hook, pool id 0xb3032695…e265cc) directly on the PoolManager, exact input, with a price limit 3 % under the guarded price. It sells what repays the debt (plus 0.1 % for rounding) and at most collateral ÷ (1 + bonus).
  3. Repays the debt into the cohort's cash. The caller receives 5 % of the HYPE sold, in WHYPE. Surplus USDC and the remaining HYPE go to the borrower.

In slices

When the pool reaches the price limit before the debt is repaid, the call repays what it sold and the rest of the loan waits for the next call; arbitrage between Elysium and HyperCore brings the pool back between calls. A loan that returns under the threshold after a partial liquidation stops being liquidatable. The fork test of the suite runs this on the real pool: a 37 % fall, a first call that sold down to the limit, and the remaining debt closed at maturity in six calls.

Bad debt

If every unit of sellable collateral is sold and debt remains, the loan closes: the remaining debt is recorded as the cohort's bad debt and the last wei of HYPE go to the caller. The cohort's notes then redeem pro rata to its cash once all its loans are closed, which shares the loss across that cohort's lenders and no one else.

The keeper runs a liquidation pass every five minutes and after each maturity.

Loans and healthPrice feed and guardians