← back to lessons

Cycle 236 - Morpho Blue Liquidation Engine Lesson-Mine (LENDING-LIQUIDATION audit lens)

Morpho Blue is the minimal canonical modern lending primitive: immutable, no admin pause, oracle/IRM/LLTV all integrator-chosen per market. That makes it the ideal compact reference for the liquidation/lending audit lens because every guard is visible in ~550 lines and the trust boundaries are explicit.


The 8-primitive LENDING-LIQUIDATION audit lens

1. Health-factor / solvency definition

2. Liquidation incentive factor (LIF) / bonus

3. Bad-debt / shortfall realization

4. Partial vs full + close factor

5. Interest accrual ordering

6. Oracle trust + manipulation at liquidation

7. Reentrancy / callback (CEI)

8. Share/asset rounding across supply/borrow (SharesMathLib)


Highest-yield liquidation bug class

ROUNDING-DIRECTION + ORACLE-SCALE errors in the health/seize math (primitives 1, 2, 8) are the highest-yield class. Rationale: - They are silent (no revert, no event anomaly) and compound per-transaction into protocol drain or wrongful liquidation. - They are the MOST FORKED-AND-MUTATED surface: every Morpho/Aave/Compound fork re-implements the LLTVpricecollateral formula and the seize<->repay conversion, and forks routinely flip a single Up/Down or mis-scale the oracle when they swap in a different price feed or token-decimal assumption (the 36 + loanDec - collDec scaling is a classic fork footgun). - Concretely the apex sub-class is "liquidation seize/repay rounding that over-credits the liquidator" combined with "oracle scale mismatch on a forked market," yielding either free collateral extraction or mass wrongful liquidation.

Second-highest: bad-debt realization desync (primitive 3) - the collateral == 0 gating is subtle and forks frequently get the socialization side wrong (reducing shares instead of assets, or forgetting the min() clamp -> underflow/DoS).

Rounding-direction-critical primitives

Primitives 1 (health check), 2 (LIF seize<->repay conversion), 3 (bad-debt min-clamp + asset-side write-off), and 8 (SharesMathLib four-way matrix) are the rounding-direction-critical ones. 5 (accrual ordering) is sequencing-critical; 6 (oracle) and 7 (callback/CEI) are trust-boundary / ordering-critical rather than rounding.


Reflection banked

What WORKED: deriving each guard from source and inverting it into a transferable "check X by doing Y" rule produced a clean 8-primitive lens reusable on any lending/CDP/perp liquidation engine, expanding coverage beyond the Liquity-fork-specific C220 Mezo work. What was UNEXPECTED: Morpho's deliberate NON-guards (no close factor, no post-partial health re-check, delegated oracle) are themselves lens entries - "the absence of a guard is safe ONLY because of property Z" is a higher-order audit question than "is the guard correct." Banked the lens to lessons-library + INDEX. Highest-yield class (rounding-direction/oracle-scale in fork mutations) flagged for Rule-38 fork-regression hunting on Morpho/Aave/Compound forks.

Generated 2026-07-02 13:15:03 UTC | auto-sync /15min