# Liquidators' Guide

## What is liquidation?

Liquidation means transferring part of both debt and collateral(+premium) from the account with negative health to the caller.&#x20;

## Can a given account be liquidated?

{% hint style="info" %}
Only users with negative health can be liquidated.
{% endhint %}

To find out if account fall under liquidation or not, one may query liquidator-entry-point(`3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT)`contract,  specifically, `getUserHealth(user)` function.&#x20;

The following snippet queries any waves node on the status of  `3PMZCTZjdsVZe2hePquBpE4LCVuZ5JA2PvK` (the argument of `getUserHealth` function):

```
 curl -X 'POST' \
     'https://nodes.wavesnodes.com/utils/script/evaluate/3PJ6iR5X1PT2rZcNmbqByKuh7k8mtj5wVGw' \
       -H 'accept: application/json' \
       -H 'Content-Type: application/json' \
       -d '{
           "expr": "getUserHealth(\"3PMZCTZjdsVZe2hePquBpE4LCVuZ5JA2PvK\")"
           }'
```

The output would be similar to:

```
 {
    "result": {
        "type":"String",
         "value":"bp:2105388966, bpu:1861495565"
         },
    "complexity":5354,
    "expr":"getUserHealth(\"3PMZCTZjdsVZe2hePquBpE4LCVuZ5JA2PvK\")",
    "address":"3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT"
 }⏎  
```

The important line is #4: it returns `bp` and `bpu` where

&#x20;\- `bp` means "borrow power"\
&#x20;\- `bpu` means "borrow power used"

```
account_health = (bp - bpu) / bp
```

{% hint style="warning" %}
&#x20;If `bp<bpu` , the account falls under liquidation.
{% endhint %}

## How to liquidate an account?

To liquidate, one need to call `transferDebt` function in *liquidator-entry-point* `(`3PJ6iR5X1PT2rZcNmbqByKuh7k8mtj5wVGw`)`.&#x20;

&#x20;There're 4 parameters in `tranfserDebt` function:

* `borrowReserve`: the reserve address with debt,
* `collateralReserve`: the reserve address with collateral,
* `borrower`: address of the borrower with negative health,
* `liquidateDebtAmount`: an amount of debt to be liquidated;

{% hint style="info" %}
Up to 50% of debt can be liquidated within 1 transaction.
{% endhint %}

The caller needs to maintain positive health after this operation.


---

# 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.vires.finance/guides/todo-liquidators-guide.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.
