# Liquidation

### **Prerequisites for Liquidation**

Before making a liquidation call, you must:

* **Identify the Borrower**: Know the borrower's wallet address who is under collateralized
* **Understand the Debt Position**:
  * Know the borrower’s outstanding debt, including the type of asset and amount eligible for repayment.
  * Ensure you have a sufficient balance of the repaying asset
* **Identify the Collateral**: Know the collateral asset you’re closing

### **How to gather the required information above?**

* **Monitor User Positions**
  * Usually, you can build off-chain bots tracking all users’ positions to see who is eligible to liquidate, as well as know what their collateral and debt assets are. These bots could continuously query the blockchain for updates on user positions
* **Query Protocol Contracts** to access protocol-specific parameters:
  * **Liquidation Incentives**: The discount offered to liquidators for seizing collateral.
  * **Close Factor**: The maximum proportion of the debt that can be repaid in a single liquidation event.
  * **Liquidation Fee:** A small proportion of the collateral seizure to be shared with the protocol, which varies on the collateral assets

### **Executing liquidation**

On the contract’s address of the borrowed asset’s pToken that represents the debt asset you are going to repay, call `liquidateBorrow`

When making a liquidation call, provide accurate parameters to comply with protocol rules:

* `repayAmount`: Specify the amount of debt to repay. This must be within the limit determined by the protocol's Close Factor, which caps the maximum repayable debt in a single transaction.
* `pTokenCollateral`: This is the pToken of the borrowers supplied asset you wish to seize during liquidation.

**Note**: Make sure you have approved a sufficient token spending allowance for the asset before calling `liquidationBorrow`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pike.finance/developer-docs/smart-contracts/ptokens/liquidation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
