# Liquidation

Liquidation is an essential risk management process in decentralized finance (DeFi) lending protocols, designed to safeguard lenders' capital and ensure protocol stability. The **NELX Lending Protocol** employs automated liquidation mechanisms to address instances where a borrower’s collateral value falls below acceptable thresholds.

### What is Liquidation?

Liquidation involves the sale of a borrower’s collateral to repay their outstanding debt if the **Health Factor** (a measure of loan safety) drops below 1. This process protects the protocol by maintaining adequate collateral levels and reducing the risk of default.

Borrowers must regularly monitor their loans and adjust their collateral or repayments to maintain a healthy position and avoid liquidation. Key factors influencing the liquidation process include the **Loan-to-Value (LTV)** ratio, **liquidation threshold**, **collateral value**, and **debt amount**.

***

### Monitoring Loan Health

The Nebeus protocol evaluates loan health using two primary metrics:

1. **Loan-to-Value (LTV) Ratio:**
   * Determines the maximum borrowing capacity against the collateral value.
   * Lower LTV ratios indicate safer borrowing positions.
2. **Liquidation Threshold:**
   * Marks the point where a loan becomes under-collateralized and at risk of liquidation.

***

### How Does Liquidation Work?

Loan stability is continuously tracked using the **Health Factor**, which compares the collateral’s value to the borrower’s debt. A Health Factor above 1 indicates a safe loan. When it drops below 1, the protocol initiates liquidation to restore collateral adequacy.

**Example Scenario:**

* Borrowed: $5,000 in stablecoins.
* Collateral: $10,000 worth of BTC.
* Liquidation Threshold: 0.8 (Health Factor below 1 triggers liquidation).

If the collateral’s value decreases to $6,250 (Health Factor = 0.8), the protocol sells enough BTC to cover the debt and restore the Health Factor to 1.

### **With Liquidation Penalty:**

* If the penalty is 5%, an additional amount (e.g., $250) is added to the liquidation amount, requiring the sale of $5,250 worth of BTC.

**Alternate Example Scenario:**

* Borrowed: $15,000 in USDT.
* Collateral: $25,000 worth of ADA.
* Liquidation Threshold: 0.85.

If the ADA value drops to $21,000 (Health Factor = 0.85), the protocol automatically sells enough ADA to cover the debt and restore the Health Factor to 1.

**With a Liquidation Penalty of 6%:**\
The protocol sells $15,000 + $900 (penalty) worth of ADA, totaling $15,900.

***

### Why Liquidation Occurs

Borrowers face liquidation when:

1. **Volatile Collateral:** Significant price drops in collateral assets.
2. **Decreasing Collateral Value:** Market downturns reduce the asset’s value below required thresholds.
3. **Increasing Debt Value:** Borrowed debt grows disproportionately high relative to the collateral.
4. **Missed Payments:** Failure to meet interest obligations.

***

### Liquidators and Their Role

Liquidators are advanced users or automated systems that monitor loans at risk of liquidation. They:

* Pay a portion of the borrower’s debt and receive discounted collateral as a reward (**Liquidation Bonus**).
* Interact with the protocol’s smart contracts, initiating liquidation calls through designated endpoints.
* Help maintain the protocol’s stability by ensuring sufficient collateralization.

**Endpoint for Liquidators:** Liquidators connect to the protocol using the following designated endpoints to monitor and execute liquidations:

1. **Health Factor Endpoint:** Provides real-time data on borrowers’ health factors, allowing liquidators to identify positions at risk of liquidation.
   * Example: `/api/v1/health-factors`
2. **Liquidation Call Endpoint:** Allows liquidators to initiate the liquidation process for under-collateralized loans.
   * Example: `/api/v1/liquidation-call`
3. **Profitability Assessment Endpoint:** Enables liquidators to calculate potential profits by factoring in liquidation bonuses and transaction fees.
   * Example: `/api/v1/liquidation-profitability`

**Incentives for Liquidators:**

* Bonuses vary based on the collateral’s risk profile, with higher-risk assets offering greater rewards. These incentives encourage proactive monitoring and ensure the overall health of the protocol.

Liquidators are advanced users or automated systems that monitor loans at risk of liquidation. They:

* Pay a portion of the borrower’s debt and receive discounted collateral as a reward (**Liquidation Bonus**).
* Interact with the protocol’s smart contracts, initiating liquidation calls.
* Help maintain the protocol’s stability by ensuring sufficient collateralization.

**Incentives for Liquidators:**

* Bonuses vary based on the collateral’s risk profile, with higher-risk assets offering greater rewards.

***

### Liquidation Process on Nebeus

The liquidation process involves multiple steps and inputs, which may include automated bots:

1. **Verification:** Confirm the borrower’s Health Factor is below 1.
2. **Input Details:** Identify the wallet address, debt asset, and collateral asset.
3. **Profit Assessment:** Evaluate profitability, factoring in transaction fees and bonuses.
4. **Execution:** Complete the collateral swap and cover the debt using mechanisms like flash loans if needed.

***

### Avoiding Liquidation

To prevent liquidation, borrowers can improve their loan’s Health Factor by:

* **Repaying Debt:** Reducing the outstanding debt significantly improves the Health Factor.
* **Adding Collateral:** Increasing collateral value provides a buffer against liquidation.

Among these options, repaying the loan offers the most immediate and effective improvement.

***

The Nebeus Lending Protocol’s liquidation mechanism plays a vital role in maintaining a secure and efficient DeFi ecosystem. While liquidation safeguards the protocol, borrowers are encouraged to actively monitor their loan health and maintain adequate collateral levels to avoid this process. Through automated liquidations and incentivized participation by liquidators, the Nebeus protocol ensures robust risk management and long-term sustainability.
