 🌊

# Liquidation

The process of liquidation occurs when the losses of an open leveraged position exceeds the liquidation threshold (i.e. the loss of a position reaches the Collateral value multiplied by the Collateral Factor). To understand how liquidation is executed, please familiarize yourself with the following terms and parameters first:
1. 1.
Collateral value: Asset that a user puts up in order to open a leveraged long/short position.
2. 2.
Collateral Factor: This parameter determines the liquidation threshold. A position will be subject to liquidation if its losses reaches the `Collateral Factor * Collateral Value at the time of deposit - Funding Fees.` The Collateral Factor at Perp88 is currently set at 0.99.
3. 3.
Position Value: This is the value of your position. You can calculate this by multiplying the assets in your position with the asset price. For example, if you open a 5x BTC long at \$20,000 per BTC, your position value is \$100,000.
4. 4.
Profit & Loss (PnL): This is the profit or loss accrued to the position. You can calculate the PnL with the following formula: `PnL = Current Position Value - Position Value at Opening.` If the position is currently at loss, the PnL will be negative. If the position is currently in profit, the PnL will be positive.
5. 5.
Liquidation Buffer: This is the buffer that protects the position from liquidation. The Liquidation Buffer is calculated by the following formula: `Liquidation Buffer = Collateral Value at Deposit * Collateral Factor.` Once the Liquidation Buffer + Position PnL <= 0, the position will run the risk of being liquidated.
6. 6.
Liquidation Price: If the longed/shorted asset reaches this price, liquidation can happen. It is calculated by using the following formula: `Liquidation Price = Asset Price at Position Opening + (if short) or - (if long) (Liquidation Buffer - Funding Fee) / Position Size at Position Opening * Asset Price at Position Opening).`
Below, we share an example of how liquidation is carried out at Perp88.
Assumptions:
• Bob deposits 20,000 USDC as collateral
• Bob opens a leveraged long position on BTC at 5x when BTC is \$20,000
At the time of position opening, here are the key statistics on Bob's position:
• Collateral Value: 20,000 USDC or \$20,000
• BTC price at Opening: \$20,000
• Position Size at Opening: 5 BTC or \$100,000
• Current Position Size: 5 BTC or \$100,000
• PnL = \$100,000 - \$100,000 = \$0
• Collateral Factor: 0.99
• Liquidation Buffer: \$20,000 * 0.99 = \$19,800
• Liquidation Price: \$16,040
• \$20,000 - ((\$20,000*0.99)/\$100,000) * \$20,000
• \$20,000 - (0.198 * \$20,000)
• \$20,000 - \$3,960
• \$16,040
Two weeks later, BTC price dropped to \$16,040. Below are the statistics of Bob's position at that point in time.
• Collateral Value: 20,000 USDC or \$20,000
• Current BTC price: \$16,040
• Position Size at Opening: 5 BTC or \$100,000
• Current Position Size: 5 BTC or (5*\$16,040) = \$80,200
• PnL: \$80,200 - \$100,000 = -\$19,800
• Collateral Factor: 0.99
• Liquidation Buffer: \$20,000 * 0.99 = \$19,800
Since the loss of the position has now reached the Liquidation Buffer (i.e. \$19,800 - \$19,800 < or = 0), the position is now subject to liquidation.
• Collateral Value: 20,000 USDC or \$20,000
• PnL: \$80,200 - \$100,000 = -\$19,800
• Remaining Collateral: \$20,000 - \$19,800 = \$200
Once the position is liquidated, Bob will receive \$200 (in the asset that he longs: BTC) from his remaining collateral value.
Please note that for the sake of simplicity, we have ignored borrowing fees and funding fees incurred while the position is opened as well as the opening / closing fees.