📉Liquidation Doc

Introduction

Supernova's liquidation process is triggered when a trader's Margin Ratio (MR) falls below the Maintenance Margin Fraction (MMF), currently set at 0.0625. When this occurs, the trader's position is liquidated by a third-party liquidator bot.

The liquidation price for each position is calculated based on the position size and the amount of escrowed funds. The liquidation penalty is deducted from the trader's margin, with 80% directed toward the protocol and the remaining 20% allocated to the liquidator based on the remaining margin balance.

Liquidation Trigger

The liquidation trigger is initiated when a trader's Margin Ratio falls below the Maintenance Margin Fraction.

The Maintenance Margin Fraction is the minimum margin required to keep a position open. If a trader's Margin Ratio falls below the MMF, their position will be liquidated to prevent further losses.

Liquidation Price

The liquidation price for long positions is calculated as follows:

LiquidationPrice = (|EscrowedAmount - PositionValueAtOpen|) / ((1 - MMF) * PosSize)

The liquidation price for short positions is calculated as follows:

LiquidationPrice = (|EscrowedAmount + PositionValueAtOpen|) / ((1 + MMF) * PosSize)

In both cases, the liquidation price is the price at which the position will be liquidated. The position will be automatically liquidated if the current market price falls below the liquidation price.

Liquidation Penalty

The liquidation penalty is deducted from the trader's margin, with 80% directed toward the protocol and the remaining 20% allocated to the liquidator based on the remaining margin balance.

Example

Suppose a trader named Alex deposits 100 WETH and opens a short position of 100 SNV at an opening price of 10 WETH.

Alex's initial Margin Ratio is 0.1 since the position's initial value is 1000 WETH and the collateral held in escrow is 100 WETH.

This is above the MMF of 0.0625, so Alex's position is initially safe.

However, if the market price of SNV changes to 10.36 WETH, Alex's position is now worth 1036 WETH, and his escrowed funds of 64 WETH now only cover 61.77% of the position's value.

Therefore, Alex's Margin Ratio has fallen to 0.0617, which is below the MMF. At this point, Alex's position will be liquidated.

The liquidation price for Alex's position is calculated as follows:

LiquidationPrice = (|EscrowedAmount + PositionValueAtOpen|) / ((1 + MMF) * PosSize)

(|100 + (1000)|) / ((1 + 0.0625) * 100) = 10.3529 WETH. This means Alex's position will be liquidated once the price hits 10.3529 WETH. The liquidation penalty will be 64.71 WETH, with 51.76 WETH going to the protocol and 12.94 WETH going to the liquidator.

Liquidation Functions

The provided code snippets, written in the Solidity programming language, implement the functionality to liquidate a user's position in the system.

1. Constructor

The constructor is a function that gets called when the contract is deployed. It takes three parameters:

These addresses refer to the contracts for managing the order book, margin, and processing taker orders. This function initializes the contract and sets the necessary contract addresses.

function constructor(address _orderBook, address _margin, address _takerOrderProcessor)

2. Update Order Book

This function enables the administrator to update the OrderBook contract address, requiring a single parameter to do so.

function updateOrderBook(address _newOrderBook)

3. Update Margin Ledger

This function allows the administrator to modify the margin contract address and accepts a single parameter as input.

function updateMarginLedger(address _newMargin)

4. Pause Function

The function enables the administrator to pause the liquidation functionality of the contract, thereby preventing any further liquidations until the functionality is resumed.

function _pause()

5. Unpause Function

The function enables the administrator to unpause the liquidation functionality of the contract, which enables liquidations to resume once again.

function _unpause()

6. Liquidate and Sell

This function is specifically designed to liquidate a user's position in the system and accepts a single parameter as input.

The encoded data includes information such as -

  • The addresses of the liquidator.

  • The address of the liquidatee.

  • The amounts to be liquidated.

  • The type of position (long or short).

  • A list of counter-order IDs that match the position amount.

  • The next order ID.

function liquidateAndSell(bytes memory data)

Conclusion

The liquidation process on the Supernova platform is designed to protect traders from excessive losses. If a trader's Margin Ratio falls below the MMF, their position will be automatically liquidated.

The liquidation price is calculated based on the position size and the amount of escrowed funds. The liquidation penalty is taken from the trader's margin and is shared between the protocol and the liquidator. The Liquidator Bot is an open-source tool that can be used to perform liquidations on the Supernova platform efficiently and accurately.

We hope this document provides a comprehensive understanding of the liquidation process on the Supernova platform. If you have any questions or concerns, please feel free to contact our support team.

Last updated