# Maximum Liquidation and Repayment Amount

Determining the maximum amount for liquidation and loan repayment
When users supply assets as collateral and borrow against them, the assets supplied as collateral are at risk of being liquidated, or sold off in order to cover the borrower’s debts and ensure the protocol remains solvent.
The maximum amount that can be liquidated is the maximum amount of collateral that can be liquidated to repay the outstanding debt, in a liquidation event.
It is determined by:
• Health Factor: Measures the collateralization level of the borrower's position (i.e. Ratio of the value of the collateral to the outstanding debt)
• Close Factor: Sets the maximum percentage of the borrower's collateral that can be liquidated in the event of default.
When the Health Factor falls below a certain threshold (the Liquidation Threshold), the CDP module will automatically initiate a liquidation, afterwhich the collateral is sold at a discount to incentivize liquidators to repay the outstanding debt.

## Calculation

To determine the maximum amount that can be liquidated, the borrower's debt is multiplied by the Close Factor; This gives the maximum amount of collateral that can be liquidated.

### Example

Suppose
• Loan to Value (LTV) = 85% or 0.85;
• Liquidation Threshold = 88% or 0.88;
• Liquidation Bonus = 5% or 0.05;
• Liquidation Bonus Fee = 10% or 0.10;
• Minimum Close Factor = 0.10;
• Close Factor = Variable factor; The close factor determines the percentage of the borrower's collateral that can be liquidated.
A borrower provides \$100,000 in USDC and borrows \$85,000 in ATOM (max LTV).
 Collateral \$100,000 in USDC Borrowings \$85,000 in ATOM Loan to Value (LTV) 85% < Liquidation Threshold Health Factor = (Collateral Value * Liquidation Threshold) / Borrow Value = (100,000 * 0.88) / 85,000= 1.03529> 1
The value of the borrowed ATOM increases to \$92,500, bringing the user’s LTV ratio to 95.2% (thus exceeding the Liquidation Threshold of 88%).
 Collateral \$100,000 in USDC Borrowings \$92,500 in ATOM Loan to Value (LTV) 92.5% > Liquidation Threshold Health Factor = (Collateral Value * Liquidation Threshold) / Borrow Value = (100,000 * 0.88) / 92,000= 0.95652< 1
The borrower will be liquidated in order to ensure their position remains over-collateralized.

### Working

The Critical Borrowed Value is defined as:
B = LT + (CV-LT) * CLT, where
• B = Critical Borrowed Value;
• CV = Collateral Value;
• LT = Liquidation Threshold;
• CLT = Complete Liquidation Threshold; CLT determines how far between LT and CV a borrower’s borrowed value must have progressed in order to allow a full liquidation. For example, 0.3 indicates 30% of the way from LT to CV.
The exact calculation is as follows:
1. 1.
Find Close Factor
Critical Borrowed Value (B)
= LT + (CV-LT) * CLT
= \$88,000 + (\$100,000 - \$88,000) * 0.7
= \$96,400
Close Factor = 1 when Borrowed Value hits the critical amount of \$96,400.
Close Factor (CF)
= (Debt - LT) / (CV - LT) * (1 - Minimum CF) + Minimum CF
= (92,500 - 88,000) / (100,000-88,000) * (1-0.1) + 0.1
= 0.4375 Relationship between Close Factor and Borrow Value
1. 2.
Calculate Maximum Liquidation Amount
Maximum amount that can be liquidated
= Close Factor * Debt (i.e. Current value of borrowings in USD)
= 0.4375 * \$92,500
= \$40468.75
The maximum amount that can be liquidated is \$40468.75. The liquidator can initiate a liquidation and sell up to \$40468.75 in collateral to repay the outstanding debt.
In return, the liquidator should expect to receive \$40,468.75 * 1.045 = \$42289.84 worth of the collateral after repaying the debt.