Diffusal

Liquidation

Proactive liquidation mechanics to ensure protocol solvency

Liquidation ensures protocol solvency by allowing third-party keepers (or anyone) to intervene when a user's equity falls below the maintenance margin. This prevents bad debt from cascading during market volatility.


Liquidation Trigger

A user becomes liquidatable when:

Portfolio Equity<Maintenance Margin\text{Portfolio Equity} < \text{Maintenance Margin}

Important: Both longs AND shorts can be liquidated if their equity falls below maintenance margin. The key difference is in their risk profiles:

Position TypeMax Settlement LossMargin BasisCan Be Liquidated?
Option Long + Premium PayerPremium Payer obligation (bounded, deterministic)Option stress loss + Notional BufferYes
Option Short + Premium ReceiverStressed intrinsic - Premium receivableStressed option loss + Notional BufferYes
Mixed portfoliosCombined exposurePortfolio stress loss + Notional BufferYes

Note: In the Four-Instrument Model, option positions and premium positions are separate instruments. A typical buyer holds both an Option Long AND a Premium Payer position. The premium obligation comes from the Premium Payer instrument, not from the Option Long.

See Margin System: Long Only for detailed margin calculations.


The Liquidation Process

  1. Trigger: Keeper detects Equity < MM
  2. Calculate: Determine debt and positions to close
  3. Transfer Positions at penalized mark price:
    • Long positions: Liquidator pays user at mark × (1 - penalty%) and receives the optionBalance
    • Short positions: User pays liquidator at mark × (1 + penalty%) for taking the obligation
  4. Pay Bounty: Liquidator receives 5% of debt (from user's collateral first, insurance covers any shortfall)
  5. Cover Remaining Debt: If user still has negative equity after transfers, insurance fund covers

Important: Only the optionBalance transfers to the liquidator. The user's premiumBalance (premium obligations) remains with the user and settles at expiry. Liquidators must have deposited collateral (USDC) to pay for acquiring long positions.


Position Transfer Cash Flows

Liquidation uses a position transfer model — the liquidator acquires positions rather than closing them on the market. This creates bidirectional USDC flows through the vault:

┌─────────────────────────────────────────────────────────────────────┐
│           LONG POSITIONS: Liquidator buys at discount               │
├─────────────────────────────────────────────────────────────────────┤
│                                                                     │
│  Liquidator ────USDC (mark × (1 - penalty%))────► User (liquidated) │
│       │                                                │            │
│       │  Receives position                             │            │
│       │  (at discount)                     Receives cash            │
│       ▼                                    (loses position)         │
│                                                                     │
└─────────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────────┐
│       SHORT POSITIONS: Liquidator takes obligation for payment      │
├─────────────────────────────────────────────────────────────────────┤
│                                                                     │
│  User (liquidated) ────USDC (mark × (1 + penalty%))────► Liquidator │
│       │                                                     │       │
│       │  Pays to transfer                       Receives cash       │
│       │  short obligation                       + takes obligation  │
│       ▼                                                             │
│                                                                     │
└─────────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────────┐
│                    BOUNTY + SHORTFALL COVERAGE                      │
├─────────────────────────────────────────────────────────────────────┤
│                                                                     │
│  1. Bounty (5% of debt): User ────────────────► Liquidator          │
│     If user cannot cover: Insurance Fund ─────► Liquidator          │
│                                                                     │
│  2. Bad Debt: If user equity still negative after transfers         │
│     Insurance Fund covers remaining shortfall                       │
│                                                                     │
└─────────────────────────────────────────────────────────────────────┘

Cash Flow Summary

StepDirectionAmountPurpose
1. LongsLiquidator → UserlongsCostPay for long positions (optionBalance)
2. ShortsUser → LiquidatorshortsCostTransfer short obligations (optionBalance)
3. BountyUser → Liquidator5% × debtIncentive payment
4. Bounty shortfallInsurance → LiquidatorremainderGuarantee bounty
5. Bad debtInsurance → Protocolas neededCover negative equity

See DiffusalLiquidationEngine for implementation details.


Debt Calculation

Debt=Initial MarginPortfolio Equity\text{Debt} = \text{Initial Margin} - \text{Portfolio Equity}

If Debt > 0 and Equity < MM, the user is underwater and liquidation is triggered.


Mark Price Liquidation

Liquidations use the mark price (Black-Scholes theoretical) directly. They do not go through the orderbook or RFQ system.

The liquidator buys positions directly from the liquidated user at a penalized mark price:

Position TypeLiquidation PriceEffect
Long (size > 0)mark × (1 - penalty%)Liquidator buys at discount
Short (size < 0)mark × (1 + penalty%)Liquidator buys back at premium

The liquidator immediately earns the penalty as profit. They can then sell the acquired positions via orderbook or RFQ.


Volatility-Adjusted Penalty

The liquidation penalty scales with implied volatility to properly incentivize liquidators during market stress:

Penalty Rate=Base (1%)+Current IV50%100\text{Penalty Rate} = \text{Base (1\%)} + \frac{\text{Current IV} - 50\%}{100}

Examples

IVPenalty CalculationRate
50%1% + (50-50)/1001.0%
75%1% + (75-50)/1001.25%
100%1% + (100-50)/1001.5%
150%1% + (150-50)/1002.0%

Penalty Rate Bounds

ParameterValueDescription
Minimum1.0%Base rate (when IV ≤ 50%)
At baseline1.0%When IV = 50%
Maximum100%Capped to ensure liquidators don't pay more than position value

Note: The penalty rate is capped at 100% to ensure liquidations remain viable even in extreme IV conditions. In extreme IV environments, liquidators need large discounts to take on risk, but above 100% would mean paying more than the position's value, which would never be profitable.

Why Volatility Adjustment Matters

In high volatility environments:

  • Positions move faster - A barely underwater position can become deeply underwater within blocks
  • Liquidators take more risk - Prices may move against them before they can hedge
  • Higher penalties compensate - Ensures liquidators remain incentivized during stress

Without vol-adjustment, liquidators might delay during market stress (when liquidations are most critical), leading to bad debt accumulation.


Partial vs Full Liquidation

The protocol supports partial liquidation to give users a chance to recover.

Key Insight

Margin requirements use stressed scenarios (±30% spot, +50% IV), but liquidation executes at current mark prices. This means:

  • Selling positions at current mark barely reduces equity (just the penalty)
  • But it dramatically reduces the margin requirement (which was stress-based)
  • So partial liquidation often restores health without destroying the user

The Asymmetry That Enables Partial Liquidation

The margin system uses stressed prices for requirements, but liquidation uses current prices:

OptionCurrent MarkStressed (Scenario 1)Difference
ETH Call ($3,200 strike)$116.25$4.73-$111.52
ETH Put ($2,800 strike)$92.00$709.69+$617.69

Why this matters:

  • Margin requirement uses $710 put value → requires ~$7,100 collateral per 10 short puts
  • Liquidation uses $92 put value → transfer costs only ~$920 per 10 short puts
  • This $618 spread per contract is why closing 50% of positions often restores health

The stress scenarios assume extreme market moves that may never happen. When liquidation executes at current prices, the actual cost is much lower than what the margin system reserved for.

Position Selection: Longest-Dated First

The protocol liquidates positions starting with the longest-dated positions first. This ordering:

  • Prioritizes positions furthest from expiry (most liquid, easiest for liquidators to hedge)
  • Preserves near-expiry positions that may settle soon
  • Ensures predictable liquidation behavior

Notional-Based Partial Liquidation

Partial liquidation calculates how much notional value to liquidate based on the debt-to-margin ratio:

Total Notional=imarki×optionBalancei\text{Total Notional} = \sum_i \text{mark}_i \times |\text{optionBalance}_i| Target Notional=Total Notional×DebtInitial Margin\text{Target Notional} = \text{Total Notional} \times \frac{\text{Debt}}{\text{Initial Margin}}

The protocol supports partial position liquidation — a single position can be partially liquidated to hit the exact target notional. This is more capital-efficient than rounding up to whole positions.

Liquidation Process

  1. Trigger: Equity < MM
  2. Sort: Order all positions by expiry descending (longest-dated first)
  3. First Attempt: Liquidate positions until target notional is reached, starting from longest-dated. Supports partial liquidation within a single position.
  4. Re-check: Is user now healthy? (Equity ≥ MM)?
    • If yes, stop and user retains remaining positions
    • If no, automatically escalate to full liquidation (close remaining positions)

Why Longest-Dated First?

  • Liquidity: Longer-dated options typically have better liquidity for liquidators to exit
  • Preservation: Near-expiry positions may settle naturally, avoiding forced liquidation costs
  • Predictability: Clear ordering removes ambiguity about which positions get closed

After liquidation, the user retains any remaining equity and positions (if partial was sufficient).


Liquidator Incentives

Liquidators are compensated through two mechanisms:

1. Penalty Profit (1-2%+)

Liquidators acquire positions at a discount/premium from mark price:

Long positions: Liquidator pays at mark × (1 - penalty%), immediately gaining the penalty as profit. For example, with mark price $100 and penalty 1.5%, the liquidator pays $98.50 for a position worth $100.

Short positions: User pays liquidator at mark × (1 + penalty%) to take the obligation. The liquidator is compensated for assuming the risk.

2. Bounty (5% of debt)

Bounty=Debt×5%\text{Bounty} = \text{Debt} \times 5\%

The bounty is always paid to incentivize liquidators:

  • First drawn from user's collateral (after position transfers)
  • Any shortfall is covered by the insurance fund

This ensures liquidators are compensated even when liquidating deeply underwater users.

Bounty Scenarios

ScenarioDebtBounty (5%)User RemainingInsurance PaysLiquidator Gets
Healthy surplus$5,000$250$3,000$0$250
Tight margin$5,000$250$200$50$250
Deep underwater$10,000$500$0$500$500
Extreme deficit$20,000$1,000-$5,000$1,000 + bad debt$1,000

Key: Liquidators always receive the full bounty. The insurance fund guarantees this regardless of how underwater the user is.

Total Liquidator Profit

Total Profit=Penalty Profit+Bounty\text{Total Profit} = \text{Penalty Profit} + \text{Bounty}

This incentivizes keepers to monitor positions and liquidate promptly, especially during high volatility when the penalty (and thus profit) is higher.

Liquidator Requirements

Liquidators must have deposited collateral to participate:

  • For long positions: Liquidator needs USDC to pay for the positions
  • For short positions: No upfront payment needed (user pays liquidator)
  • Liquidator must remain healthy (equity ≥ MM) after acquiring positions

If the liquidator would become unhealthy after acquiring positions, the transaction reverts with LiquidatorUnhealthy().

Liquidator Health Check Example

Scenario: A liquidator with insufficient collateral attempts to acquire positions.

Liquidated user's positions:

  • Long 10 ETH Call ($3,200 strike, 90d) — mark $296.23
  • Short 5 ETH Put ($2,800 strike, 60d) — mark $165.58

Liquidator state:

ItemBeforeAfter Acquisition
Deposit$10,000$10,000 - $2,932.68 (paid for longs) + $836.18 (received for shorts) = $7,903.50
PositionsNone+10 long calls, -5 short puts
Option Value$0($296.23 × 10) + ($165.58 × -5) = $2,134.40
Premium Balance$0$0 (liquidator doesn't inherit user's premium)
Equity$10,000$7,903.50 + $2,134.40 + $0 = $10,037.90
New IM$0$9,418.41
New MM$0$7,534.73

Health check: $10,037.90 > $7,534.73 → HEALTHY

When liquidation fails: If the liquidator had less initial deposit (e.g., $5,000), they might still become unhealthy after paying for longs and taking on the margin requirements for the short positions.

Solutions for an undercollateralized liquidator:

  1. Deposit more collateral before attempting liquidation
  2. Target smaller positions that won't exceed their margin capacity
  3. Have existing offsetting positions that reduce the combined IM

Post-Liquidation

After acquiring positions, the liquidator can:

ActionDescription
Sell via limit ordersPlace orders on the orderbook
Sell via RFQRequest quote from Main Market Maker
Hold positionsKeep exposure if desired
Hedge externallyOffset risk on other venues

Insurance Fund

The insurance fund provides two types of coverage:

1. Bounty Guarantee

The 5% bounty is always paid to liquidators to ensure incentives remain strong:

  • First drawn from user's collateral (after position transfers)
  • Insurance fund covers any bounty shortfall

2. Bad Debt Coverage

When the user still has negative equity after all transfers:

Shortfall=User Equity (after transfers)\text{Shortfall} = -\text{User Equity (after transfers)}

The Insurance Fund covers any remaining bad debt.

DiffusalInsuranceFund Contract

The insurance fund is a separate contract (DiffusalInsuranceFund) that:

  • Receives all protocol trading fees (set as feeRecipient on OrderBook and RFQ)
  • Holds funds in a deposit on the CollateralVault
  • Provides cover() function callable by LiquidationEngine or SettlementEngine

Insurance Fund Sources

SourceDescription
Protocol feesAll trading fees routed via feeRecipient
Initial seed capitalBootstrap funding via deposits

Flow Diagram

At settlement, funds flow from short holders (obligations) to the settlement pool, then to long holders (payouts). If there's a shortfall, the insurance fund provides coverage.

Settlement Waterfall (Order of Operations)

When liquidation completes, cash flows settle in this exact order:

StepActionFromToCondition
1Long position paymentLiquidatorUserAlways (for each long)
2Short obligation transferUserLiquidatorAlways (for each short)
3Net position settlementAggregate steps 1-2
4Bounty paymentUser depositLiquidatorUp to available balance
5Bounty shortfallInsurance FundLiquidatorIf step 4 insufficient
6Bad debt coverageInsurance FundProtocolIf user equity negative

Example (deeply underwater user):

Initial state:
- Debt: $20,000
- Bounty owed: $1,000 (5% of debt)
- User deposit remaining after transfers: $500

Settlement order:
1. Steps 1-3: Position transfers complete (net: user has $500 remaining)
2. Step 4: User pays $500 bounty (all available)
3. Step 5: Insurance covers $500 bounty shortfall
4. Step 6: Insurance covers any remaining bad debt

Result: Liquidator receives full $1,000 bounty (guaranteed)

Settlement Readiness Liquidation

There's a subtle risk in options trading: a user can have high portfolio equity from profitable long positions but minimal actual cash (USDC deposits). When their positions expire, they need actual cash to pay settlement obligations, but their "paper profits" from longs aren't liquid.

The Problem (Deferred Settlement Model)

With the fungible options model and deferred settlement, positions can have settlement obligations:

Net Settlement Formula:

netSettlement=(intrinsic×optionBalance)+premiumBalance\text{netSettlement} = (\text{intrinsic} \times \text{optionBalance}) + \text{premiumBalance}

Where:

  • optionBalance: Signed position size (+ = long, - = short)
  • premiumBalance: Signed premium position (+ = receivable, - = payable)

Settlement obligations arise when netSettlement is negative:

  • Option Shorts: Pay intrinsic obligation (offset by any Premium Receiver balance they hold)
  • Premium Payers: Pay their fixed premium obligation (separate from option position)

Consider this scenario:

ItemValue
Deposited collateral$2,000
Long-dated calls value+$50,000 (paper)
Short puts expiring tomorrow (Option Short)-$8,000 (worst-case intrinsic obligation)
Premium Payer balance for expiring calls-$2,000 (fixed premium obligation)
Portfolio Equity$40,000

The user looks healthy (equity >> MM), so they can't be liquidated. But at settlement tomorrow:

  • Cash needed: $10,000 (short intrinsic + premium payer obligation)
  • Cash available: $2,000
  • Result: Settlement failure

Solution: Pre-Settlement Liquidation

Settlement Readiness Liquidation is handled by a separate contract (DiffusalSettlementReadinessLiquidator) that liquidates non-expiring LONG option positions to raise cash when positions are approaching settlement and the user lacks sufficient cash. This is a separate liquidation type from margin-based liquidation.

Key difference from regular liquidation:

  • Regular liquidation: Restores margin health by transferring both longs AND shorts
  • Settlement readiness: Raises cash by selling longs and premium receivables (shorts are obligations, not extractable value)

What can be liquidated:

  • Non-expiring LONG option positions (optionBalance > 0) — positive mark value that can be sold for cash
  • Premium receivables (positive premiumBalance) — deterministic value, liquidated at a discount

What CANNOT be liquidated:

  • Option shorts — they represent obligations, not extractable value
  • Premium payables — they are obligations that settle at expiry

Trigger conditions (all must be true):

  1. User has positions expiring within 1 day with net obligations
  2. User's deposited collateral (cash) is insufficient to cover worst-case obligations
  3. User has valuable non-expiring LONG option positions that can be liquidated
  4. User is not an MMM (Main Market Maker)

How It Works

  1. Calculate Cash Shortfall

    • Identify expiring positions within SETTLEMENT_READINESS_WINDOW (1 day)
    • Calculate worst-case obligations:
      • Option shorts: stressed intrinsic × |optionBalance| (if ITM under stress)
      • Premium payers: |premiumBalance| (fixed, deterministic)
    • Net shortfall = total obligations - deposited cash
  2. Liquidation Waterfall (in order)

    Step 1: Non-Expiring Long Option Positions

    • Long option positions (optionBalance > 0) sorted by expiry (longest-dated first)
    • Liquidator pays penalized mark price, receives the option position
    • Stop when shortfall is covered (or all liquidatable assets exhausted)

    Step 2: Premium Receivables (at discount)

    • If shortfall remains and user has premium receivables (positive premiumBalance)
    • Liquidated at a discount rate (default 5%, max 20%)
    • Value realized = premiumReceivable × (1 - discountRate)
    • Premium position transfers to liquidator
  3. Position Transfer

    • User receives cash from liquidator (penalized mark price for options, discounted value for premiums)
    • Liquidator acquires the long option position and/or premium receivable
    • Premium payables are NOT transferred — they remain with original holder

Worst-Case Obligation Calculation (Net Settlement Model)

The protocol calculates obligations using SPAN stress scenarios with the netSettlement formula:

netSettlement=(intrinsicstressed×optionBalance)+premiumBalance\text{netSettlement} = (\text{intrinsic}_{\text{stressed}} \times \text{optionBalance}) + \text{premiumBalance} Obligation=max(0,netSettlement)\text{Obligation} = \max(0, -\text{netSettlement})

For Expiring SHORT Positions

Shorts have obligations when stressed intrinsic payout exceeds their premium receivable.

Option TypeWorst-Case ScenarioStressed SpotWhy
Short CallSpot rises +30%spot × 1.3Maximizes intrinsic
Short PutSpot drops -30%spot × 0.7Maximizes intrinsic

Example (Short 5 puts, premiumBalance = +$600):

Intrinsicstressed=max(0,StrikeSpot×0.7)=$700\text{Intrinsic}_{\text{stressed}} = \max(0, \text{Strike} - \text{Spot} \times 0.7) = \$700 netSettlement=($700×5)+$600=$3,500+$600=$2,900\text{netSettlement} = (\$700 \times -5) + \$600 = -\$3{,}500 + \$600 = -\$2{,}900 Obligation=max(0,$2,900)=$2,900\text{Obligation} = \max(0, \$2{,}900) = \$2{,}900

Key insight: The premium already received ($600) reduces the obligation from $3,500 to $2,900.

For Positions with Premium Payer Balances

Users with Premium Payer positions (premiumBalance < 0) have obligations equal to the premium they owe. For users who also hold expiring Option Long positions, the intrinsic payout from the long offsets the premium obligation.

Note the opposite stress direction for calculating worst-case - we minimize intrinsic to find the maximum net obligation:

Option TypeWorst-Case ScenarioStressed SpotWhy
Long CallSpot drops -30%spot × 0.7Minimizes intrinsic payout
Long PutSpot rises +30%spot × 1.3Minimizes intrinsic payout

Example (Long 10 calls + Premium Payer -$1,500):

Intrinsicstressed=max(0,Spot×0.7Strike)=$0 (OTM)\text{Intrinsic}_{\text{stressed}} = \max(0, \text{Spot} \times 0.7 - \text{Strike}) = \$0 \text{ (OTM)} netSettlement=($0×10)+($1,500)=$1,500\text{netSettlement} = (\$0 \times 10) + (-\$1{,}500) = -\$1{,}500 Obligation=max(0,$1,500)=$1,500\text{Obligation} = \max(0, \$1{,}500) = \$1{,}500

Key insight: The Premium Payer obligation is bounded and deterministic (fixed at trade time). The Option Long position has no obligation—it only receives intrinsic (or nothing if OTM). The net settlement combines both instruments.

Liquidation Waterfall Diagram

SETTLEMENT READINESS LIQUIDATION WATERFALL
══════════════════════════════════════════

┌─────────────────────────────────────────────────────────┐
│          TRIGGER: Settlement Readiness Check            │
├─────────────────────────────────────────────────────────┤
│  1. Positions expiring within 1 day?                    │
│       │                                                 │
│       ▼                                                 │
│  2. User has net settlement obligations?                │
│       │                                                 │
│       ▼                                                 │
│  3. Deposited cash < worst-case obligations?            │
│       │                                                 │
│       ▼                                                 │
│  4. User is NOT an MMM?                                 │
└──────────────────────────┬──────────────────────────────┘
                           │ All conditions met

┌─────────────────────────────────────────────────────────┐
│     STEP 1: Liquidate Non-Expiring LONG Positions       │
├─────────────────────────────────────────────────────────┤
│  • Sort longs by expiry (longest-dated first)           │
│  • Liquidator pays: mark × (1 - penalty%)               │
│  • User receives cash, loses position                   │
│       │                                                 │
│       ▼                                                 │
│  Shortfall covered? ───► YES ──────────────────────┐    │
│       │                                            │    │
│       NO                                           │    │
└───────┴────────────────────────────────────────────┴────┘
        │                                            │
        ▼                                            │
┌────────────────────────────────────────────────────┼────┐
│       STEP 2: Liquidate Premium Receivables        │    │
├────────────────────────────────────────────────────┼────┤
│  • Find positions with premiumBalance > 0          │    │
│  • Liquidator pays: premium × (1 - discount%)      │    │
│  • User receives discounted cash                   │    │
│       │                                            │    │
│       ▼                                            │    │
│  Shortfall covered? ───► YES ──────────────────────┘    │
│       │                                                 │
│       ▼ (or exhausted)                                  │
└───────┴─────────────────────────────────────────────────┘
        │                   │
        └───────────────────┴────────► YES (done)


┌─────────────────────────────────────────────────────────┐
│                  STEP 3: Pay Bounty                     │
│     Keeper receives 5% of shortfall (capped)            │
└──────────────────────────┬──────────────────────────────┘

┌─────────────────────────────────────────────────────────┐
│                        RESULT                           │
├─────────────────────────────────────────────────────────┤
│  • User now has sufficient cash for settlement          │
│  • Expiring positions remain for normal settlement      │
└─────────────────────────────────────────────────────────┘

Key Constants

ConstantValueDescription
SETTLEMENT_READINESS_WINDOW1 dayWindow before expiry to trigger
SETTLEMENT_READINESS_BUFFER5%Buffer for settlement readiness calculations
PREMIUM_RECEIVABLE_DISCOUNT_RATE5%Default discount on premium receivables
MAX_PREMIUM_RECEIVABLE_DISCOUNT_RATE20%Maximum configurable discount rate
STRESS_SPOT_UP1.3 (130%)Spot up scenario
STRESS_SPOT_DOWN0.7 (70%)Spot down scenario

See DiffusalSettlementReadinessLiquidator for the contract API.

Mechanics

StepFlow
1. Identify long positionsSort non-expiring LONG positions by expiry (longest-dated first)
2. Liquidate longs firstSale price = mark × (1 - penalty%), long option moves to liquidator
3. Check shortfallIf shortfall remains and user has premium receivables, continue
4. Identify premium receivablesFind positions with positive premiumBalance
5. Liquidate premiumsValue = premiumReceivable × (1 - discountRate), premium transfers to liquidator
6. Pay bountyUser → Liquidator (5% of shortfall, capped at proceeds)
7. Stop earlyOnce shortfall is covered (or all liquidatable assets exhausted)

Liquidator Incentives

Same as regular liquidation:

1. Penalty Profit

  • Liquidator buys at mark × (1 - penalty%)
  • Penalty rate uses same volatility adjustment formula

2. Bounty (5% of shortfall)

Bounty=min(Cash Shortfall×5%,Cash Raised)\text{Bounty} = \min(\text{Cash Shortfall} \times 5\%, \text{Cash Raised})

Worked Example: Sufficient Cash for Settlement

Setup: A user has short positions expiring within 1 day.

Option Position:

SeriesOption BalanceDescription
ETH Put $2,800-5Short 5 puts (expires tomorrow)

Premium Position:

SeriesPremium BalanceDescription
ETH Put $2,800+$600Received $120 each for 5 puts

Deposited collateral: $4,000 USDC

Calculate Worst-Case Net Settlement:

Under worst-case (spot drops 30%):

Worst-case spot=$3,000×0.70=$2,100\text{Worst-case spot} = \$3{,}000 \times 0.70 = \$2{,}100

Intrinsic value of put at settlement:

Intrinsic=max(0,StrikeSpot)=max(0,$2,800$2,100)=$700\text{Intrinsic} = \max(0, \text{Strike} - \text{Spot}) = \max(0, \$2{,}800 - \$2{,}100) = \$700

Net settlement:

netSettlement=(intrinsic×optionBalance)+premiumBalance\text{netSettlement} = (\text{intrinsic} \times \text{optionBalance}) + \text{premiumBalance} =($700×5)+$600=$3,500+$600=$2,900= (\$700 \times -5) + \$600 = -\$3{,}500 + \$600 = -\$2{,}900

Worst-case obligation:

Obligation=max(0,netSettlement)=max(0,$2,900)=$2,900\text{Obligation} = \max(0, -\text{netSettlement}) = \max(0, \$2{,}900) = \$2{,}900

Key insight: The premium already received ($600) reduces the worst-case obligation from $3,500 to $2,900.

Settlement Readiness Check:

$4,000>$2,900\$4{,}000 > \$2{,}900 \quad \checkmark

Result: User has sufficient cash for settlement. No liquidation needed.

Worked Example: Settlement Readiness Liquidation

Setup: Same short position as above, but with insufficient cash and an additional long position.

Option Positions:

SeriesOption BalanceDescription
ETH Put $2,800-5Short 5 puts (expires tomorrow)
ETH Call $3,200+10Long 10 calls (expires in 60 days)

Premium Positions:

SeriesPremium BalanceDescription
ETH Put $2,800+$600Received $120 each for 5 puts
ETH Call $3,200-$1,500Paid $150 each for 10 calls
Total-$900Net premium payer

Deposited collateral: $2,000 USDC

Calculate Cash Shortfall:

Worst-case obligation for expiring puts:

netSettlementput=($700×5)+$600=$2,900\text{netSettlement}_{\text{put}} = (\$700 \times -5) + \$600 = -\$2{,}900 Obligation=max(0,$2,900)=$2,900\text{Obligation} = \max(0, \$2{,}900) = \$2{,}900

Cash shortfall:

Cash Shortfall=$2,900$2,000=$900\text{Cash Shortfall} = \$2{,}900 - \$2{,}000 = \$900

Settlement Readiness Liquidation:

The user's portfolio equity is healthy (they have long calls with Option Value of $1,162.50), but deposited cash is insufficient to cover expiring position obligations.

The system liquidates non-expiring LONG positions to raise cash. Only longs can be liquidated because they have positive Option Value:

Contracts to sell$900$116.25×(11%)7.8 calls\text{Contracts to sell} \approx \frac{\$900}{\$116.25 \times (1 - 1\%)} \approx 7.8 \text{ calls}

After liquidation:

  • User's long calls: ~2.2 contracts remaining
  • User's cash: ~$2,900 (sufficient for settlement)
  • Short puts: unchanged (will settle normally with netSettlement formula)

Key insight: Only LONG positions can be liquidated for settlement readiness. Shorts are obligations that cannot be "sold" to raise cash.

Example: Complex Settlement Readiness

Initial State (using netSettlement formula):

Expiring Positions (12 hours to expiry):

  • Short 10 puts (Option Short + Premium Receiver): optionBalance=-10, premiumBalance=+$1,000
    • Stressed intrinsic: $700, netSettlement = ($700 × -10) + $1,000 = -$6,000
    • Net Obligation: $6,000 (intrinsic obligation partially offset by premium receivable)
  • Long 15 calls (Option Long + Premium Payer): optionBalance=+15, premiumBalance=-$4,500
    • Stressed intrinsic: $100, netSettlement = ($100 × 15) + (-$4,500) = -$3,000
    • Net Obligation: $3,000 (premium payer obligation exceeds intrinsic payout)
  • Total worst-case obligation: $9,000
  • Deposited collateral: $1,000
  • Cash shortfall: $9,000 - $1,000 = $8,000

Non-Expiring LONG Position (60 days to expiry):

  • Long 200 calls: optionBalance=+200, Option Value = $20,000 (mark × 200)
┌─────────────────────────────────────────────────────────────────────────┐
│                    SETTLEMENT READINESS LIQUIDATION                     │
│                       (Non-Expiring Long Example)                       │
└─────────────────────────────────────────────────────────────────────────┘

Initial State:
  User: Cash $1,000 | Obligations $9,000 | Shortfall $8,000
  Position: Long 200 calls (60 days to expiry), value $20,000

Step 1: Check Conditions
  ├─ Expiring positions within 1 day? Yes (12 hours)
  └─ Cash < Obligations? $1,000 < $9,000 ✓

Step 2: Liquidate Non-Expiring Longs
  Liquidator → Protocol: "Liquidate 200 calls"
  Liquidator → Vault: Pay $19,800 (mark × 0.99)
  Vault → User: Credit $19,800

  User: Cash $20,800 | Shortfall COVERED

Step 3: Pay Bounty
  User → Liquidator: $400 (5% of $8,000 shortfall)

Final State:
  User: Cash $20,400 | Obligations $9,000 | Ready for settlement

Liquidation (1% penalty) — Only the non-expiring LONG is liquidated:

  • Liquidator pays: $20,000 × 0.99 = $19,800
  • User receives: $19,800 (new cash balance = $20,800)
  • Bounty: min($8,000 × 5%, $19,800) = $400
  • User's final cash: $20,800 - $400 = $20,400

The user now has $20,400 to cover the $9,000 total obligation at settlement. The expiring positions (both the short puts and long calls) remain with the user for settlement.

Key Differences from Regular Liquidation

AspectRegular LiquidationSettlement Readiness
TriggerEquity < MMCash shortfall for expiring obligations
What's liquidatedAll positions (longs AND shorts)Non-expiring LONG positions (first) + premium receivables
Position handlingTransfer to liquidatorWaterfall: longs at penalty, then premiums at discount
GoalRestore margin healthRaise cash for settlement obligations
Expiring positions affectedYes (transferred)No (remain for settlement)
Can shorts be liquidated?YesNo (shorts are obligations, not value)
Premium receivablesTransferred with optionLiquidated second at discount rate (5-20%) if shortfall remains
Premium payablesTransferred with optionNOT transferred (settle separately)

Worked Examples

For detailed worked examples of partial and full liquidation with step-by-step calculations, see:

The settlement readiness liquidation examples are unique to this page and shown in the Settlement Readiness Liquidation section above.

Key takeaways from the margin system examples:

  • Notional-based partial liquidation closes only the target notional needed
  • Partial position liquidation is supported — fractional contracts can be liquidated
  • Longest-dated first ordering is deterministic and predictable
  • If partial fails, the system escalates to full liquidation automatically
  • Users retain remaining collateral after positions are transferred

Risk Parameters

ParameterDefaultDescription
LIQUIDATION_PENALTY_BASE1%Base price penalty
LIQUIDATION_PENALTY_IV_BASELINE50%IV threshold for penalty scaling
LIQUIDATOR_BOUNTY_RATE5%% of debt paid to liquidator

Note: Partial liquidation uses proportional position closure (debt/IM fraction) rather than a fixed percentage.


Main Market Maker Exception

The Main Market Maker (MMM) is a privileged, non-liquidatable entity. The liquidation function rejects any attempt to liquidate the MMM address by first checking if the user is an MMM (returning false if so) before checking equity vs maintenance margin.

Why MMM Is Exempt

The MMM's solvency is managed operationally, not by protocol rules:

ConcernMitigation
MMM goes underwaterMMM operator monitors and rebalances externally
MMM accumulates too much riskMMM offloads shorts via limit orders or OTC
MMM runs out of capitalMMM operator injects capital before insolvency
MMM becomes maliciousGovernance can replace MMM address

This is a deliberate trust tradeoff: by trusting one well-managed entity, the protocol guarantees that RFQ always functions—so liquidators can always offload acquired positions to the MMM after executing liquidations.


Smart Contract API

The DiffusalLiquidationEngine contract implements the liquidation mechanics. Liquidation is permissioned — only approved liquidators can execute liquidation functions. This ensures trusted entities (e.g., keeper bots, protocol operators) manage liquidations while maintaining protocol solvency.

Liquidation Functions (DiffusalLiquidationEngine)

  • liquidatePortfolio(user, portfolioId, liquidatorPortfolioId) — Liquidates an undercollateralized user's portfolio. Requires caller to be an approved liquidator. The liquidatorPortfolioId specifies which portfolio receives the acquired positions. Tries partial liquidation first (proportional fraction based on debt/IM), then escalates to full liquidation if partial doesn't restore health. Returns a LiquidationResult containing: user, liquidator, portfolioId, debt, longsCost, shortsCost, bounty, insuranceUsed, newUserEquity, newLiquidatorEquity, positionsLiquidated, isPartial.
  • isApprovedLiquidator(address) — Returns true if the address is approved to execute liquidations.
  • setApprovedLiquidator(address, bool) — (Owner only) Approves or revokes an address for liquidation execution.

Settlement Readiness Functions (DiffusalSettlementReadinessLiquidator)

Settlement readiness liquidation is handled by a separate contract (DiffusalSettlementReadinessLiquidator), which also requires approved liquidators:

  • getSettlementReadinessInfo(user) — Returns: isLiquidatable, cashRequired, cashAvailable, cashShortfall, totalPremiumReceivable, premiumReceivableValueAfterDiscount, positionValueAvailable, expiringShortsCount, expiringLongsCount, liquidatablePositionsCount
  • isSettlementReadinessLiquidatable(user) — Returns true if user meets settlement readiness liquidation conditions (expiring positions with obligations and insufficient cash)
  • liquidateForSettlementReadiness(user) — Liquidates using waterfall: non-expiring LONG option positions first, then premium receivables (at discount). Requires caller to be an approved liquidator. Returns: user, liquidator, cashShortfall, cashRaised, premiumLiquidated, premiumProceeds, liquidatorCost, bounty, positionsLiquidated, newCashAvailable
  • isApprovedLiquidator(address) — Returns true if the address is approved to execute settlement readiness liquidations.
  • setApprovedLiquidator(address, bool) — (Owner only) Approves or revokes an address for settlement readiness liquidation execution.
  • getSettlementReadinessBuffer() — Returns the settlement readiness buffer (default 5%, WAD format)
  • getPremiumReceivableDiscountRate() — Returns the discount rate applied to premium receivables (default 5%, WAD format)
  • getLiquidatorBountyRate() — Returns the liquidator bounty rate (default 5%, WAD format)
  • calculatePenaltyRate(pairId) — Returns penalty rate in WAD based on IV

View Functions (DiffusalLiquidationEngine)

  • getLiquidationInfo(user) — Returns comprehensive info: isLiquidatable, portfolioId, debt (USDC 6 decimals), estimatedLongsCost, estimatedShortsCost, estimatedBounty, positionCount
  • calculatePortfolioDebt(user, portfolioId) — Returns debt = max(0, Initial Margin - Equity) for the specified portfolio
  • calculatePenaltyRate(pairId) — Returns penalty rate in WAD (e.g., 0.015e18 = 1.5%). Penalty = Base (1%) + (IV - 50%) / 100
  • getInsuranceFundBalance() — Returns current insurance fund balance

External Insurance Fund

The insurance fund is a separate contract (DiffusalInsuranceFund) with these functions:

  • getBalance() — Current fund balance (USDC, 6 decimals)
  • collateralVault() — CollateralVault reference
  • liquidationEngine() — LiquidationEngine reference
  • cover(shortfallAmount) — Draw funds for shortfalls (callable by LiquidationEngine or SettlementEngine)
  • withdraw(amount) — Withdraw excess funds (owner only)

The insurance fund receives all protocol trading fees by being set as feeRecipient on OrderBook and RFQ contracts.

Deployment Integration

The liquidation engine must be registered as an operator on DiffusalOptionsPositionManager (for updatePosition()) and DiffusalCollateralVault (for creditCollateral() and debitCollateral()). Additionally, the insurance fund must be connected to the liquidation engine, and fees should be routed to the insurance fund.


Contract Implementation

ContractRole
DiffusalLiquidationEngineCore margin-based liquidation logic
DiffusalSettlementReadinessLiquidatorSettlement readiness liquidation
DiffusalInsuranceFundShortfall coverage
DiffusalCollateralVaultCollateral settlement

Protocol Documentation

Contract Documentation

On this page

Liquidation TriggerThe Liquidation ProcessPosition Transfer Cash FlowsCash Flow SummaryDebt CalculationMark Price LiquidationVolatility-Adjusted PenaltyExamplesPenalty Rate BoundsWhy Volatility Adjustment MattersPartial vs Full LiquidationKey InsightThe Asymmetry That Enables Partial LiquidationPosition Selection: Longest-Dated FirstNotional-Based Partial LiquidationLiquidation ProcessWhy Longest-Dated First?Liquidator Incentives1. Penalty Profit (1-2%+)2. Bounty (5% of debt)Bounty ScenariosTotal Liquidator ProfitLiquidator RequirementsLiquidator Health Check ExamplePost-LiquidationInsurance Fund1. Bounty Guarantee2. Bad Debt CoverageDiffusalInsuranceFund ContractInsurance Fund SourcesFlow DiagramSettlement Waterfall (Order of Operations)Settlement Readiness LiquidationThe Problem (Deferred Settlement Model)Solution: Pre-Settlement LiquidationHow It WorksWorst-Case Obligation Calculation (Net Settlement Model)For Expiring SHORT PositionsFor Positions with Premium Payer BalancesLiquidation Waterfall DiagramKey ConstantsMechanicsLiquidator IncentivesWorked Example: Sufficient Cash for SettlementWorked Example: Settlement Readiness LiquidationExample: Complex Settlement ReadinessKey Differences from Regular LiquidationWorked ExamplesRisk ParametersMain Market Maker ExceptionWhy MMM Is ExemptSmart Contract APILiquidation Functions (DiffusalLiquidationEngine)Settlement Readiness Functions (DiffusalSettlementReadinessLiquidator)View Functions (DiffusalLiquidationEngine)External Insurance FundDeployment IntegrationContract ImplementationRelatedProtocol DocumentationContract Documentation