Glossary

Liquidation Bot

A liquidation bot is automated software that monitors DeFi lending positions and executes liquidations when collateral falls below required thresholds.

Key Takeaways

  • A liquidation bot is automated software that monitors DeFi lending positions and executes liquidations when a borrower's health factor drops below 1, earning a discount on the seized collateral (typically 5 to 15 percent depending on the asset and protocol).
  • Multiple bots competing for the same liquidation creates MEV opportunities: bots bid up transaction fees or use private relay channels to be included first, with research showing roughly 74% of early Aave and Compound liquidations paid above-average gas fees.
  • Bot competition benefits lending protocols by ensuring that undercollateralized positions are closed quickly, protecting depositors from bad debt and maintaining overall protocol solvency.

What Is a Liquidation Bot?

A liquidation bot is a program that continuously monitors borrowing positions on lending protocols such as Aave, Compound, and MakerDAO. When the value of a borrower's collateral drops relative to their outstanding debt (pushing their health factor below 1), the bot submits a transaction to liquidate the position. In exchange, it receives a portion of the collateral at a discount, known as the liquidation bonus or liquidation incentive.

Liquidation bots serve a critical role in DeFi infrastructure. Without them, undercollateralized loans would remain open indefinitely, risking insolvency for the entire protocol. By providing a financial incentive for third parties to close unhealthy positions, lending protocols outsource risk management to a competitive market of bot operators, sometimes called keepers.

How It Works

A liquidation bot operates in a continuous loop: monitoring positions, detecting opportunities, and executing transactions. The core workflow follows a consistent pattern across most lending protocols:

  1. The bot tracks all active borrowing positions by indexing on-chain events (deposits, borrows, repayments, withdrawals) to build a local view of each user's collateral and debt balances
  2. It monitors oracle price feeds to recalculate health factors whenever asset prices change
  3. When a position's health factor drops below 1, the bot identifies it as eligible for liquidation
  4. The bot calculates whether the liquidation bonus minus gas costs and swap fees yields a profit
  5. If profitable, it submits a transaction calling the protocol's liquidation function (such as Aave's liquidationCall())
  6. The protocol transfers a portion of the borrower's collateral to the bot at a discount, and the bot repays part of the borrower's debt

Health Factor and Liquidation Thresholds

The health factor is a single number that summarizes a position's safety. It is calculated as:

Health Factor = (Collateral Value × Liquidation Threshold) / Total Debt

Example:
  Collateral: 10 ETH at $2,000 = $20,000
  Liquidation Threshold: 80%
  Debt: $15,000

  HF = ($20,000 × 0.80) / $15,000 = 1.067 (safe)

If ETH drops to $1,850:
  HF = ($18,500 × 0.80) / $15,000 = 0.987 (liquidatable)

Protocols typically allow partial liquidation when the health factor is between 0.95 and 1.0 (often up to 50% of the collateral), and full liquidation when it drops below 0.95. The exact thresholds vary by protocol and collateral type.

The Liquidation Bonus

The liquidation bonus is the discount a bot receives on seized collateral. On Aave, this typically ranges from 5% to 15% depending on the asset's risk profile. Lower-risk assets like ETH and stablecoins carry smaller bonuses, while more volatile or illiquid assets carry larger ones. For example, a 5% bonus on a $10,000 liquidation means the bot pays $10,000 of debt but receives $10,500 worth of collateral.

Flash Loan Liquidations

Many liquidation bots use flash loans to execute liquidations without holding any capital upfront. The entire sequence happens atomically within a single transaction:

  1. Borrow the debt asset via a flash loan (from Aave, Uniswap, or another provider)
  2. Repay the borrower's debt by calling the protocol's liquidation function
  3. Receive the discounted collateral
  4. Swap the collateral back to the debt asset on a DEX
  5. Repay the flash loan plus fees
  6. Keep the profit

If any step fails, the entire transaction reverts, meaning the bot risks only the gas cost of a failed transaction. This dramatically lowers the barrier to entry for liquidation bots, since operators do not need large capital reserves.

A Simplified Liquidation Contract

A flash loan liquidation contract follows this general pattern:

// Pseudocode: Flash loan liquidation flow
function executeLiquidation(borrower, debtAsset, collateralAsset, debtAmount) {
    // 1. Flash borrow the debt asset
    flashLoan(debtAsset, debtAmount);

    // 2. Approve and call protocol liquidation
    debtAsset.approve(lendingPool, debtAmount);
    lendingPool.liquidationCall(
        collateralAsset,
        debtAsset,
        borrower,
        debtAmount,
        receiveCollateral: true
    );

    // 3. Swap received collateral to repay flash loan
    uint256 collateralReceived = collateralAsset.balanceOf(address(this));
    dex.swap(collateralAsset, debtAsset, collateralReceived);

    // 4. Repay flash loan (debtAmount + fee)
    // Remaining balance = profit
}

Competitive Dynamics and MEV

Liquidation is one of the most competitive domains in MEV extraction. When an oracle price update makes a position liquidatable, every bot monitoring that protocol detects the opportunity simultaneously. The result is a race to be included first in the next block.

Priority Gas Auctions

In the early days of DeFi liquidation bots, competition played out through priority gas auctions (PGAs). Bots would submit the same liquidation transaction with progressively higher gas prices, bidding against each other for block inclusion. Research from 2021 found that roughly 74% of liquidations on Aave and Compound paid above-average transaction fees, confirming the intensity of this competition.

Modern MEV Infrastructure

Today, most competitive liquidation bots bypass the public mempool entirely. They submit transaction bundles through private relay channels such as MEV-Share on Ethereum, Timeboost on Arbitrum, or similar mechanisms on other chains. This avoids front-running by other bots who might copy the liquidation transaction from the mempool.

Some block builders run their own liquidation bots, giving them a structural advantage: they can include their liquidation transaction at the optimal position within the block they are constructing, immediately after the oracle update that triggers the opportunity.

Backrunning Oracle Updates

A common strategy is to backrun oracle price updates rather than front-run other liquidators. The bot monitors the mempool for pending oracle transactions, calculates which positions will become liquidatable once the new price is confirmed, and bundles its liquidation transaction to execute immediately after the oracle update. This approach captures opportunities at the earliest possible moment.

Infrastructure Requirements

Running a competitive liquidation bot requires significant infrastructure:

  • A full or archive node with WebSocket subscriptions for real-time event streaming and mempool monitoring
  • An event indexer that reconstructs borrower positions from on-chain data, tracking every deposit, borrow, repayment, and withdrawal
  • Oracle price feed integration to recalculate health factors as prices change
  • Transaction simulation capabilities (using tools like eth_call or Tenderly) to verify profitability before submission
  • Private transaction relay access (Flashbots, MEV-Share, or protocol-specific channels) to avoid front-running
  • Low-latency networking, ideally co-located with validators or block builders, to minimize submission delay

These requirements create a high barrier to entry. In practice, a small number of sophisticated operators capture the majority of liquidation revenue on major protocols.

Use Cases

Protocol Risk Management

Liquidation bots are the primary mechanism through which DeFi lending protocols manage credit risk. When asset prices move sharply, bots ensure that positions are closed before the debt exceeds the collateral value. Without this layer, protocols would accumulate bad debt during market downturns, threatening depositor funds.

Liquidation Cascades

During severe market drops, liquidation bots trigger liquidation cascades: selling seized collateral pushes prices lower, which triggers more liquidations. While this can amplify volatility, it also rapidly de-risks the protocol, preventing worse outcomes. The speed of automated liquidation bots helps protocols survive events that would overwhelm manual intervention.

Keeper Networks

Some protocols formalize the liquidation bot role through keeper networks. These networks coordinate bot operators, distribute opportunities more evenly, and reduce the MEV waste from redundant gas spending. MakerDAO's keeper ecosystem is one of the longest-running examples, using a Dutch auction mechanism where collateral starts at a high price and decreases until a keeper bids.

Cross-Protocol Arbitrage

Advanced liquidation bots integrate with multiple protocols and DEXs, routing seized collateral through the most efficient swap path. Some bots combine liquidation with arbitrage: if the seized collateral is mispriced across venues, the bot captures both the liquidation bonus and the arbitrage spread in a single atomic transaction.

Why It Matters

Liquidation bots are essential infrastructure for DeFi lending. The security model of protocols like Aave and Compound depends entirely on external actors rationally liquidating undercollateralized positions. If bots fail or become unprofitable (for example, if gas costs exceed the liquidation bonus on small positions), bad debt accumulates and depositors bear the loss.

This dynamic is particularly relevant for stablecoin lending. Protocols that issue collateral debt positions rely on liquidation bots to maintain their peg. If collateral backing a stablecoin drops in value and is not promptly liquidated, the stablecoin becomes undercollateralized. For a deeper look at how stablecoins manage these risks, see the research article on stablecoin peg mechanisms compared.

On Bitcoin Layer 2 networks, the approach differs. Platforms like Spark focus on self-custodial architecture that minimizes the need for complex liquidation mechanics by using a different security model. For more context on how Bitcoin-native approaches handle these challenges, see What Is Spark.

Risks and Considerations

Unprofitable Small Positions

Positions where the liquidation bonus does not cover gas costs may go unliquidated, creating bad debt. This is sometimes called "dust risk" and becomes more acute during periods of high network congestion. Some protocols address this with insurance funds or backstop mechanisms to handle positions that bots ignore.

Smart Contract Risk

Liquidation bots interact with multiple protocols in a single transaction (lending protocol, flash loan provider, DEX). A bug in any of these contracts or an unexpected interaction between them can result in lost funds. Bot operators must audit their liquidation contracts carefully and use simulation before submitting live transactions.

Oracle Dependency

Liquidation bots depend on accurate oracle price feeds. If an oracle is manipulated, bots may execute illegitimate liquidations (seizing collateral that should not be liquidatable) or miss legitimate ones (failing to act because the oracle reports a stale price). Both scenarios harm either borrowers or the protocol's solvency.

Centralization Concerns

The high infrastructure costs of running competitive liquidation bots mean that a small number of operators capture most liquidation revenue. This concentration creates a systemic risk: if dominant bot operators go offline during a market crash, liquidations stall. Keeper networks and protocol-operated backstop bots (such as Aave's own liquidation bot) aim to mitigate this risk by ensuring a baseline level of coverage.

This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.