# Liquidate Position

Liquidator can liquidate a position if its health factor falls below 1 (unhealthy). The liquidator pays some position debt and, in return, receives inToken from the position's collateral. Liquidation can be partial – partially repays the debt and receives a portion of the position's collateral.

{% hint style="info" %}
Liquidation incentive differs for each pair of repaid debt token and inToken to receive.
{% endhint %}

{% hint style="info" %}
A position can only be liquidated up to a certain health factor to prevent over-liquidation. After the liquidation, the position's health factor cannot be over `MAX_HEALTH_AFTER_LIQ`.
{% endhint %}

```solidity
// Example liquidate function
function liquidate(uint256 posId, address lendingPoolToRepay, uint256 repayShares, address lendingPoolCollateralToReceive, uint256 minInCollateralTokenOut) external {
    // 0. .. pull repay tokens from the caller ..
    
    // 1. approve repay tokens to InitCore
    IERC20(lendingPoolToRepay).safeApprove(INIT_CORE, repayShares);

    // 2. liquidate
    IInitCore(INIT_CORE).liquidate(posId, lendingPoolToRepay, repayShares, lendingPoolCollateralToReceive, minInCollateralTokenOut);
}
```


---

# 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://dev.init.capital/guides/advanced-interaction/liquidate-position.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.
