Dynamic Liquidation Engine (DLE)

Overview

The Dynamic Liquidation Engine (DLE) is a sophisticated liquidation management system implemented in the Curvance Protocol. Facilitating market collateral liquidations through a buffer-based approach with Atlas integration for MEV (Maximum Extractable Value) capture.

Technical Architecture

MEV Integration with Atlas

The contract integrates MEV (Maximal Extractable Value) capture:

  • MEV Auction Mechanism: When price updates make positions liquidatable, a short off-chain auction window allows liquidators to bid.

  • Atomic Execution: Winning bids are executed immediately in the same block as an oracle update.

  • Bid Distribution: Successful liquidation bids are distributed to Curvance Protocol through the Auction Manager's revenue logic.

  • Collateral Targeting: Each auction targets a specific cToken, both the market and the target cToken must be unlocked via the transient storage during the transaction, otherwise liquidation reverts.

Auction Buffer System

The contract implements a liquidation buffer that gives auction transactions priority access to liquidations:

  • Buffer Mechanism: A buffer that gives auction transactions priority for liquidations by applying this discount when pricing collateral.

    • Correlated: 10 bps (AUCTION_BUFFER = 9990)

    • Uncorrelated: 50 bps (AUCTION_BUFFER = 9950)

  • Implementation: When MEV-boosted liquidations are detected via transient storage, liquidation health checks apply the buffer as a discount to collateral value.

  • Benefits:

    • Captures liquidations from non-oracle based changes as interest accrual or LST (Liquid Staking Token) yield distribution.

    • Compensates for execution latency.

Transient Storage Risk Parameters

Dynamic liquidation parameters are managed through transient storage:

  • Liquidation Incentive: Configurable within token-specific min/max bounds set by governance.

  • Close Factor: Determines what percentage of debt can be liquidated.

  • Transient Nature: Parameters exist only for the duration of a transaction.

  • Validation: All parameters undergo boundary validation before being applied.

Liquidation Types

The contract supports token-specific liquidations:

  • Token-Specific Liquidations:

    • Targets individual collateral positions within an account.

    • Uses the unlockAuctionForMarket() combined with setTransientLiquidationConfig() mechanism to specify which token can be liquidated.

    • Ideal for soft liquidations where only specific assets need adjustment.

Multi-Liquidation Support

The system is designed to efficiently process liquidations:

  • Batch Processing: Can handle multiple liquidations in a single transaction.

  • Cached Pricing: Retrieves asset prices once per transaction rather than per liquidation.

  • Gas Optimization: Significantly reduces gas costs during liquidation cascades.

  • Debt Repayment Rollup: Combines debt repayment and bad debt recognition into a single action (1,000 liquidations requires 1 debt token transfer, not 1,000 transfers).

lFactor (Liquidation Factor)

Definition: A continuous score showing how close a position is to hard liquidation.

lFactor is denominated in WAD aka 1e18.

Calculation:

  1. Soft Requirement Debt Limit: for each collateral asset, take its USD value and divide by that asset’s soft collateral requirement; add across assets. If an auction liquidation is active, apply the auction buffer discount to this total.

  2. Hard Requirement Debt Limit: same as above but using each asset’s hard requirement; apply the same auction buffer if applicable.

  • If Debt ≤ Soft Requirement Debt Limit: lFactor = 0

  • If Debt ≥ Hard Requirement Debt Limit: lFactor = 1e18

  • Otherwise, lFactor = (debt - soft requirement debt limit) / (hard requirement debt limit- soft requirement debt limit), using rounding up.

Why it matters:

  • Close factor and liquidation incentive scale linearly with lFactor, increasing as the position gets riskier.

Validation Process

Liquidation attempts undergo multiple validation checks.

For example, we check if collateral is unlocked for auction transactions:

// Will revert if this liquidation is an attempted auction liquidator
// and liquidator has chosen incorrect collateral or market.
// Pulls any relevant offchain liquidation configuration.
(tData.auctionBuffer, aData.liqInc, aData.closeFactor) =
    _checkLiquidationConfig(collateralToken);

Risk Mitigation

The system incorporates several safeguards:

  • Transient Storage: Ensures parameters reset after each transaction.

  • Permission Checks: Restricts access to orderflow auction functions to authorized addresses.

  • Collateral Locking: Prevents liquidation of unauthorized collateral during Atlas transactions.

Protocol Benefits

  • Value Capture: Extracts MEV from liquidations that would otherwise go to third parties.

  • Liquidation Efficiency: Ensures timely liquidations even during high volatility.

  • Gas Optimization: Uses efficient code combined with transient storage for parameter management.

  • Graceful Degradation: Protocol remains secure even if OEV auctions fail.

By implementing this sophisticated liquidation system, Curvance balances the needs of protocol security, liquidator incentives, and value capture, creating a powerful framework for position management across diverse market conditions.


User Interaction Functions

canLiquidate()

Description: Validates and processes batch liquidations for multiple accounts, calculating collateral seizure amounts, debt repayment, and bad debt based on account health and market parameters.

Contract: MarketManager

Function signature:

function canLiquidate(
    uint256[] memory debtAmounts,
    address liquidator,
    address[] calldata accounts,
    IMarketManager.LiqAction memory action
) external returns (LiqResult memory, uint256[] memory);
Type
Name
Description

address[]

debtAmounts

The amounts of outstanding debt the liquidator wishes to repay, in underlying assets, empty if intention is to liquidate maximum amount possible for each account.

address

liquidator

The address of the account trying to liquidate accounts.

address[]

accounts

The addresses of the accounts to be liquidated.

LiqAction

action

Instructions for a liquidation action.

Return data:

Type
Description

LiqResult

Hypothetical results for a liquidation action.

uint256[]

An array containing the debt amounts to repay from accounts, in assets.


Last updated