Non-Auction Liquidations

Step 1: Check if a Position is Liquidatable:

See: Monitoring Position Health.

Step 2: Executing Liquidations

You have two choices of functions to call when executing a liquidation:

liquidate() - Used for maximum liquidations.

Use when:

  • You want to liquidate the maximum allowed amount.

  • You don't know the exact optimal amount.

function liquidate(
    address[] calldata accounts,
    address collateralToken
) external nonReentrant;

liquidateExact() - Used for exact amount liquidations.

Use when:

  • You want to repay an exact amount of debt.

function liquidateExact(
    uint256[] calldata debtAmounts,
    address[] calldata accounts,
    address collateralToken
) external nonReentrant;

Token Flows

What the Liquidator Pays:

What the Liquidator Receives:

Examples

Executing maximum liquidations

Executing Exact Amount Liquidation

Liquidation Tips

Finding Liquidation Opportunities:

  • Monitor price feeds for significant collateral price drops or debt price increases.

  • Track accounts with debt close to their maxDebt limit (high-leverage positions).

  • Focus on volatile collateral assets during market downturns.

  • Set up event listeners for Borrow events to catch new leveraged positions early.

Using Smart Contracts vs Scripts:

Smart contracts are strongly recommended over off-chain scripts for executing liquidations:

  • Atomic profitability checks - Contract can calculate profit on-chain and revert if unprofitable, saving you from wasting gas on bad liquidations.

  • Flash loan integration - Borrow capital, liquidate, and repay all in one atomic transaction with zero upfront capital.

  • Composability - Can integrate with DEX swaps to instantly convert seized collateral to stablecoins.

A typical smart contract liquidator pattern: check profitability → revert if not profitable → execute liquidation → swap collateral → ensure profit threshold met. This guarantees you never execute an unprofitable liquidation.

Last updated