# Liquidation

The liquidation process in the Fathom protocol involves several key components and steps outlined in detail in the `LiquidationEngine` and `FixedSpreadLiquidationStrategy` contracts. The liquidation mechanism maintains the system's stability by handling under-collateralized positions. Here is an overview of the process:

**Components Involved:**

1. **Liquidation Engine (`LiquidationEngine`):** Manages the overall liquidation process.
2. **Fixed Spread Liquidation Strategy (`FixedSpreadLiquidationStrategy`):** Implements a specific strategy for liquidation.
3. **Collateral Pool Config (`CollateralPoolConfig`):** Provides configuration for collateral pools, including parameters like liquidation ratio, close factor, and liquidator incentives.
4. **BookKeeper (`BookKeeper`):** Records positions, stablecoin balances and collateral.
5. **System Debt Engine (`SystemDebtEngine`):** Manages the system's overall debt and surpluses, including systemBadDebt and systemSurpluses.
6. **Price Oracle (`PriceOracle`):** Provides price feeds for collateral assets.

**Liquidation Process:**

1. **Triggering Liquidation:**

* A position becomes eligible for liquidation when its collateral value falls below a predefined threshold (defined by the liquidation ratio in `CollateralPoolConfig`). The liquidation Ratio is the same as ( *1 / Loan to Value Ratio*).&#x20;
* The `PriceOracle` plays a crucial role in determining the health of positions by providing the latest available prices for collateral assets.

2. **Liquidation Execution:**

* The liquidation process is initiated by a liquidator (which, at the moment, is a role only available to whitelisted addresses) who identifies an under-collateralized position and calls the liquidate function in `LiquidationEngine`.
* The liquidate function checks various conditions, such as the liquidator's whitelist status, the system's operational status (live), and the health of the price feed.
* If the conditions are met, `LiquidationEngine` interacts with the `FixedSpreadLiquidationStrategy` to execute the liquidation.

3. **Fixed Spread Liquidation Strategy:**

* This strategy determines the specifics of the liquidation, such as the amount of debt to be repaid and the amount of collateral to be seized.
* It calculates the required parameters based on current prices, debt accumulated rates, and other factors defined in `CollateralPoolConfig`.

4. **Financial Adjustments:**

* Upon successful liquidation, the `BookKeeper` updates the financial state of the system, including adjusting the debt and collateral amounts for the liquidated position.
* The `SystemDebtEngine` may also handle any resultant bad debt from the liquidation process.

5. **Distribution of Assets:**

* The liquidator typically receives a portion of the seized collateral as an incentive, with the rest used to repay the debt.
* Parameters like liquidator incentives and treasury fees govern the distribution of assets.

6. **Edge Cases and Safeguards:**

* The system includes various safeguards and checks to prevent unauthorized access and ensure the integrity of the liquidation process.
* For instance, roles and permissions are enforced using access control mechanisms.

The following subsection guides you through the liquidation process in detail.
