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 OEV (Optimal Extractable Value) capture.
Technical Architecture
OEV Integration with Atlas
The contract integrates with Atlas for OEV (Optimal Extractable Value) capture:
OEV Auction Mechanism: When price updates make positions liquidatable, an off-chain auction (running ~300ms) allows liquidators to bid for execution rights.
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 account abstraction operation.
Collateral Targeting: Each auction targets a specific collateral type, enforced through transient storage during transaction execution.
Auction Buffer System
The contract implements a liquidation buffer that gives auction transactions priority access to liquidations:
Buffer Mechanism: A 10 basis point (0.1%) buffer gives auction transactions priority for liquidations.
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 Penalty: Configurable within 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
unlockAtlasCollateral
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).
Dual-Oracle Architecture
Curvance's pricing system is designed with risk mitigation as its primary focus through a dual-oracle approach that enhances reliability and security.
For each supported asset, Curvance can simultaneously integrate with two independent oracle providers. This creates redundancy and provides additional verification of asset prices, with the following benefits:
Enhanced security: Mitigates risk from oracle failures or manipulation.
Continuous operation: Ensures liquidations can proceed even in volatile markets.
Safety Buffer: Creates a safety buffer when valuing collateral during distressed situations.
Price Selection Logic
When determining an asset's price, Curvance employs the "most safe" selection algorithm:
Each oracle reports its price for the asset.
The system applies sanity checks to both reported prices:
Deviation from previous price must not exceed configured limits.
Price must be above minimum threshold (non-zero).
Oracle must have reported within the maximum allowable reporting window.
For borrowable assets, the system selects the higher of the two valid prices.
For collateral assets, the system selects the lower of the two valid prices.
This approach ensures that in liquidation scenarios, the protocol always errs on the side of protecting itself from bad debt, while giving borrowers the benefit of the most favorable valid price.
Validation Process
Liquidation attempts undergo multiple validation checks.
For example, we check if collateral is unlocked for Atlas transactions:
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
liquidationStatusOf()
Description: Determines whether an account can be liquidated by calculating its liquidation factor (lFactor), based on the ratio of their collateral to outstanding debt. The function returns the lFactor
and current prices for the specified tokens. In Atlas transactions, a 10 basis point buffer is applied to give priority access to liquidations.
Contract: MarketManager
Function signature:
address
account
The account to check liquidation status for.
address
earnToken
The eToken (debt token) to be repaid during potential liquidation.
address
positionToken
The pToken (collateral token) to be seized during potential liquidation.
Return data:
uint256
lFactor - Account's current liquidation factor. A value of 0 indicates a healthy position. A value between 0 and 1e18 (WAD) indicates a soft liquidation state. A value of 1e18 (WAD) indicates a hard liquidation state.
uint256
earnTokenPrice - Current price for the earnToken (debt token).
uint256
positionTokenPrice - Current price for the positionToken (collateral token).
canLiquidate()
Description: Checks if a liquidation should be allowed to occur for a specific account, and calculates how many position tokens should be seized when liquidating. For Atlas transactions, it verifies that the specified collateral has been unlocked using transient storage.
Contract: MarketManager
Function signature:
address
eToken
Debt token to repay which is borrowed by the account.
address
pToken
Position token collateralized by the account that will be seized.
address
account
The address of the account to be liquidated.
uint256
amount
The amount of eToken underlying being repaid.
bool
liquidateExact
Whether the liquidator desires a specific liquidation amount.
Return data:
uint256
The amount of eToken underlying to be repaid on liquidation.
uint256
The number of pToken tokens to be seized in the liquidation.
canLiquidateWithExecution()
Description: Similar to canLiquidate, but this function also executes collateral removal. It applies dynamic penalty and close factor values if the transaction is an Atlas transaction, using parameters stored in transient storage.
Contract: MarketManager
Function signature:
address
eToken
Debt token to repay which is borrowed by the account.
address
pToken
Position token which was used as collateral and will be seized.
address
liquidator
The address that will perform the liquidation.
address
account
The address of the account to be liquidated.
uint256
amount
The amount of eToken underlying being repaid.
bool
liquidateExact
Whether the liquidator desires a specific liquidation amount.
Return data:
uint256
The amount of eToken underlying to be repaid on liquidation.
uint256
The number of pToken tokens to be seized in the liquidation.
Last updated