Comment on page

# Liquidations

Defining liquidations, health factor, and weighted thresholds.
A new liquidator code for V2 written in typescript: https://github.com/Gearbox-protocol/liquidator-v2. Also here is a sample liquidation bot in RUST for V1: https://github.com/Gearbox-protocol/liquidation-bot. Some tips and tricks here.

#### How does the protocol ensure over-collaterization while allowing users leveraged operations?

When trading with Gearbox, your Credit Account becomes the collateral for external protocols/actions: both your initial funds and the borrowed amount you got from the protocol. Gearbox Protocol sees which tokens your portfolio consists of and can determine its value at all times, which are always calculated in the underlying borrowed asset which you opened that Credit Account in.
Gearbox uses a risk model to continuously assess the quality-value of a Credit Account. For each Credit Account, it computes its health factor.
Anyone can check the health factor and liquidate positions with a health factor less than 1.
As a user with a leverage position, you need to watch out for your health factor. Having it just above 1 puts you in risk of getting liquidated. Learn how to avoid liquidations.
Learn about the current fee model a user pays in case of a liquidation:

### What is a Health Factor?

Health Factor is a numeric representation of your account health. If your health factor drops below 1 or close to it, you might be liquidated. The higher the number is, the safer you are. There are some tips on how you can avoid liquidations, check them here.
$H_{f}(t) =\frac{TWV(t)}{b(t) +interest\;accrued(t)},$
where b(t) is borrowed amount.
Let's dive into some math formulas to clarify how computation of the health factor works.

### Total Value

Represents the Credit Account's balance in the underlying asset.
$TV(t)=\sum{\;c_i(t)*p_i(t)},$
where c_i - balance of i-th asset in credit account, p_i - price of i-th asset calculated in underlying asset(from ChainLink oracle).

### Threshold Weighted Value

$TWV(t)=\sum{\;c_i(t)*p_i(t)*LT_i }$
where: c_i - balance of i-th asset in credit account, p_i - price of i-th asset calculated in underlying asset(from ChainLink oracle), LT_i - liquidation threshold, the credit account manager constant showing the maximum allowable ratio of Loan-To-Value for the i-th asset.

### Liquidation Threshold

Liquidation thresholds represents maximum allowable ratio of Loan-To-Value for the i-th asset (LTV is reciprocal of over-collaterization ratio of i-th asset). LT_i for underlying asset is constant and equals:
$LT_U =100\% - Liquidation\;Premium -Liquidation\;Fee$
How is Liquidation Threshold defined?
Gearbox Protocol uses statistics of 5-min, 15-min, 1h change of i-th asset's price (price is in the underlying asset) for the last 180 days.
Anybody can run a liquidator bot and secure the protocol. You can chat about setting up your bot and other liquidator-things in Discord. Help users minimize the risks!