Algofi
Search…
Liquidation
A user can be liquidated when their borrow value has exceeded their max borrow.

# Understanding liquidation

Borrowed and Max Borrow are dollarized amounts representing how much value a user has borrowed, and their maximum allowable borrow, respectively.
Borrow Utilization = Borrowed (\$) / Max Borrow (\$)
A user's Borrowed is calculated by summing Borrowed Amount * Price over their borrowed assets.
A user's Max Borrow is calculated by summing Collateral Amount * Price * Collateral Factor over their collateral assets. Collateral factors represent what percentage of assets a user can borrow against their collateral.
A user can only be liquidated when their Borrow Utilization exceeds 100%.
User with Borrow Utilization near 100%, they will soon be at risk of liquidation.

# Liquidation example

A user liquidates (the "liquidator") another user (the "liquidatee") by repaying up to 50% of the liquidatee's borrow and seizing their collateral at a discount. To give an example, let's say a user supplied 30 algos and borrowed 20 USDC.

### Asset Collateral Factors

Asset
Collateral Factor
Liquidation Incentive
USDC
80%
7.5%
ALGO
50%
7.5%

Asset
Price
USDC
1.00
ALGO
1.75

### Liquidatee Initial State

Asset
Supply
Borrow
USDC
0
20
ALGO
30
0
The liquidatee's initial Borrowed = 20 * \$1.00 = \$20 and initial Max Borrow = 30* \$1.75 * 0.50 = \$26.25, therefore initial Borrow Utilization = \$20 / \$26.25 = 76.2%.
Now, suppose the asset prices change as tabulated below.

### Final Asset Prices

Asset
Price
USDC
1.00
ALGO
1.30
As the price of ALGO decreases to \$1.30, the user's Max Borrow falls to 30 * \$1.30 * 0.50 = \$19.5, and the Borrow Utilization rises to 102%, which means the user can now be liquidated.
A liquidator identifies this and calls liquidate on the liquidatee via the Algofi smart contracts. The liquidator is allowed to repay up to 50% of the liquidatee's USDC Borrow.
In exchange for repayment, the liquidator seizes a fraction of the liquidatee's ALGO collateral at a discount. If the liquidator repays a full 50% of the 20 USDC Borrow, 10 USDC tokens, then the liquidator seizes \$10 * (1 + Liquidation Incentive) = \$10.75 worth of ALGO from the liquidatee. This amounts to \$10.75 / \$1.30 = 8.27 ALGO.
Afterwards, the liquidatee has a Borrow of 10 USDC vs. a Collateral of 30 - 8.3 = 21.7 ALGO. The liquidatee's borrow is \$10 and Max Borrow is 21.7 * \$1.30 * 0.50 = \$14.1 for a Borrow Utilization of \$10 / \$14.1 = 71%, under the 100% threshold.

# What is the purpose of liquidation?

Simply put, liquidation keeps the Algofi protocol solvent by incentivizing liquidators to repay the loans of liquidatees whose Borrow Utilizations have risen past 100% for one or more of three key reasons:
• Collateral prices fell quickly causing Max Borrow to fall below Borrow
• Borrow prices rose quickly, causing their borrow value to exceed Max Borrow
• Borrow interest caused their Borrow to rise above Max Borrow

# How to liquidate

The ability to liquidate is available in the Python SDK.