> For the complete documentation index, see [llms.txt](https://calnix.gitbook.io/aave-book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calnix.gitbook.io/aave-book/functions/liquidate.md).

# liquidate

liquidationCall()

## Overview

This function is called by liquidators to liquidate "bad loans". Accounts with a health factor of less than 1 are eligible for liquidation.

**Assuming user's healthFactor < 1:**

* if healthFactor > 0.95 => close factor set to 50%
* if healthFactor <= 0.95 => close factor set to 100%&#x20;

Liquidators are awarded with liquidation bonus, which can be paid in ATokens or the underlying asset as well.&#x20;

{% hint style="info" %}

* user’s health factor: $$0.95 < hf < 1$$, the loan is eligible for a liquidation of 50%.
* user’s health factor: $$hf <= 0.95$$, the loan is eligible for a liquidation of 100%.
  {% endhint %}

<figure><img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2FKNKbQ4ivYydz1FipZDTg%2Fimage.png?alt=media&amp;token=ca635a65-30ca-40f9-9821-71a9553e3576" alt=""><figcaption></figcaption></figure>

<img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2F9JhdtKmoMcOMn48Uvsm2%2Ffile.excalidraw.svg?alt=media&amp;token=0f3a49e7-ca96-4576-a6c2-cebcc1ddd7b6" alt="" class="gitbook-drawing">

* `executeLiquidationCall` contains the core logics&#x20;

## executeLiquidationCall

<figure><img src="https://1829638638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0k7YXwFGMFZcsyqkM4q1%2Fuploads%2Fv1eFIDfMZBGmuKTeA6eH%2Fimage.png?alt=media&amp;token=8226c766-002d-4162-bc86-12350dedde39" alt=""><figcaption></figcaption></figure>

### Execution flow

* [ ] <mark style="color:orange;">cache + updateState + get health factor</mark>
* [ ] \_caluclateDebt
* [ ] validateLiquidationCall
* [ ] getConfigurationData
* [ ] calculateAvailableCollateralToLiquidate
* [ ] <mark style="color:orange;">setBorrowing</mark>
* [ ] <mark style="color:orange;">setUsingAsCollateral</mark>
* [ ] \_burnDebtTokens
* [ ] <mark style="color:orange;">updateInterestRates</mark>
* [ ] <mark style="color:orange;">updateIsolatedDebtIfIsolated</mark>
* [ ] liquidate/burn collateral
* [ ] liquidation fee
* [ ] Wrap-up

We will breakdown and examine the unique sections of logics within **executeLiquidationCall**. Code delineated in orange are common functions and can be explored in that [section](/aave-book/functions/common-functions.md).

## Visual Aid

{% embed url="<https://link.excalidraw.com/readonly/CBWXwogzvmzFhZw3BcJs?darkMode=true>" %}
