💫
Star Perps
  • 💫Welcome to Star Perps
  • Getting Started
    • ⭐Understanding Intent Based Trading
    • ✨What Problem Does Star Perps Solve?
  • Basics
    • ✍️On-Chain Perpetual Future Contracts
    • 📃Collateral & Cross-Margin Account
    • 💱Funding Rates
    • 🗞️Key Terms and Definitions
    • 🫗Liquidation
  • Star Token
    • 📩Overview
    • 🪙Tokenomics
    • 🥩Staking
    • 🔗Official Channels
Powered by GitBook
On this page
  1. Basics

Liquidation

Liquidation Process Overview

In the Star Perps system, liquidation occurs when a user's account balance and open positions become insufficient to support ongoing losses. The process involves moving funds from the "pending" state to the "locked" state and triggering liquidation when the user's total unrealized profit and loss (UPNL) reaches critical negative levels. Liquidation applies to both Party A (the user opening the trade) and Party B (the hedger or counterparty).

Liquidation Phases

1. Pending and Locked Amounts

When a user sends a quote request, the position amount associated with that request enters a pending state. During this time, the user cannot use the same amount for other positions. However, the pending amount still counts toward the user's overall allocated balance, which is considered when assessing liquidity.

Once the quote is accepted by Party B, the position moves from "pending" to locked. Locked values represent positions that are now active and committed in the system.


Liquidation of Party A

Let's break down an example of liquidation for Party A with a $1,000 allocated balance. All positions are cross-margined, meaning multiple positions share the same margin, and losses or gains from different positions are summed together.

UPNL States:

  • Total UPNL > 0: The user is in profit.

  • -500 < Total UPNL < 0: Locked Maintenance Margins (MMs) are used to support the positions.

  • -700 < Total UPNL < -500: The free balance starts to support the positions.

  • -900 < Total UPNL < -700: Pending locked values are now used to support the positions.

  • Total UPNL < -900: The user is liquidated.

Once liquidation is triggered, all of the user's positions, both pending and open, are closed and canceled. The system operates on a cross-margin basis, meaning liquidation impacts all open positions and not just the specific losing position.

Liquidation Process for Party A (Contract Side)

  1. Mark Liquidation: The liquidator first marks Party A as liquidated and records the liquidation timestamp.

    function liquidatePartyA(address partyA, SingleUpnlSig memory upnlSig);
  2. Set Symbol Prices: The liquidator sets the prices for all the symbols associated with Party A's positions to calculate liquidation values accurately.

    function setSymbolsPrice(address partyA, PriceSig memory priceSig);
  3. Liquidate Pending Positions: Pending positions (those in the pending state but not yet active) are liquidated and canceled.

    function liquidatePendingPositionsPartyA(address partyA);
  4. Liquidate Open Positions: Finally, the liquidator closes and liquidates all open positions tied to Party A.

    function liquidatePositionsPartyA(address partyA, uint256[] memory quoteIds);

Liquidation of Party B

Party B, who accepts quotes and locks positions for Party A, must maintain sufficient collateral. If Party B's collateral becomes insufficient due to Party A’s realized profits across positions, Party B can be liquidated specifically for that user. This system operates on a per-user cross-margin basis. Party B's relationship with other users will not affect their liquidation risk for a particular Party A.

Liquidation Process for Party B (Contract Side)

  1. Mark Liquidation: The liquidator first marks Party B as liquidated in relation to Party A, ensuring that Party B cannot continue to hold positions for this user.

    function liquidatePartyB(address partyB, address partyA, SingleUpnlSig memory upnlSig);
  2. Liquidate All Positions: After marking the liquidation, the liquidator closes all positions that Party B holds for Party A.

    function liquidatePositionsPartyB(address partyB, address partyA, PriceSig memory priceSig);

Summary

The liquidation process in Star Perps revolves around ensuring that collateral and positions are properly managed to prevent insolvency. If Party A or Party B experiences significant losses that reduce their available balances below required thresholds, the system enforces liquidation, automatically closing all open positions to protect the network's solvency. Both users and hedgers must maintain collateral to cover their positions, and liquidation occurs in a structured manner to minimize risks to the broader trading ecosystem.

PreviousKey Terms and DefinitionsNextOverview

Last updated 10 days ago

🫗