Trading Perps

Perpetual Swaps Market

Margin, Leverage & PnL

Notional Value

The notional of a position corresponds to the total position size in USDC value

Notional Value = Position Qty * Mark Price

Account Margin Ratio

The margin ratio of an account is equal to the total collateral value (ie the USDC balance + any unrealized profit/loss) divided by the total open notional of the account (the sum of the absolute notional value of all positions)

For an account having positions on multiple contracts:

Account Margin Ratio = Total Collateral Value / Sum(Abs(Position Notional i))

The margin ratio defines the risk level of your account: a higher margin ratio equates to a lower risk level (with a default margin ratio set to 1000% when there are no open positions).

Maintenance Margin Ratio

An account will be liquidated if the Margin Ratio of the account is lower than the Maintenance Margin Ratio required.

MMR i = Max(Base MMR i, Base MMR i / Base IMR i * IMR Factor i * Abs(Position Notional i)^(4/5))

PnL (Profit and Loss)

The unrealized PnL of an open position refers to the profits or losses of that position based on the Mark Price:

Unrealized PnL(Perp Market i) = Position Qty * (Mark Price - Position Average Entry Price)

The realized PnL refers to the profits or losses after closing a position:

Realized PnL(Perp Market i) = Position Qty * (Average Price - Position Average Entry Price)

PnL settlement

Settling PnL allow traders to move their profit or loss from all perpetual markets to their balance. PnL Settlement has no impact on the Account Margin Ratio or open positions.

It should be noted that settled/unsettled PnL and realized/unrealized PnL are different. PnL is realized when closing or reducing a position. The resulting realized PnL moves into the balance only when the trader triggers a PnL settlement.

Settled PnL into balance can be used for spot trading or withdrawn, but doing so will impact your margin ratio.

The process of PnL Settlement is as follows:

When account X makes a call to settle PnL, Orderly will choose the top accounts with the largest unsettled opposing PnL. Starting from the largest account, each account’s unsettled PnL will be offset with account X, until account X has no more remaining PnL to settle.

As an Example: Account X has +20,000 USDC unsettled PnL with a balance of 100 USDC. The top 2 facing Accounts A and B have -15,000 USDC and -5,000 USDC unsettled PnL respectively:

  • First, settling Account X vs Account A will increase Account X’s balance by 15,000 USDC and decrease Account A’s balance by 15,000 USDC. Account X has a remaining unsettled PnL of +5,000 USDC and a balance of 15,100 USDC.

  • Then, settling Account X vs Account B will increase Account X’s balance by 5,000 USDC and decrease Account B’s balance by 5,000 USDC. Account X has a remaining unsettled PnL of 0 and a balance of 20,100 USDC. The settlement process ends since Account X has no remaining unsettled PnL.

Settling PnL will NOT change the user’s balance as displayed user balance already includes unsettled PnL in the calculation.

Withdrawable balance will change after settling PnL as it doesn’t include unsettled profits in the calculation.

All settling PnL does is move profits into user’s account so user is able to withdraw.

Mark Price, Index Price and Last Price

Mark Price

The Mark Price represents the best estimate of a Perpetual Futures contract value and prevents unnecessary liquidations that would potentially be caused by market manipulation: it is less volatile than the Index Price or Last Price.

First we compute the Median Price of the three following components :

Median Price = Median(P1, P2, Futures Price)
where:
    P1 = Index Price * (1 + Last Funding Rate * Time until next Funding / dt)
    P2 = Index Price + 15 Minute Moving Average[Basis]
    Futures Price = Median(Bid0, Ask0, Last_Price)

Last Funding Rate is expressed on a 8h basis
Basis = Median(Bid0, Ask0) - Index Price, calculated as a snapshot every minute
dt = Funding Period = 8 hours

Then we apply a cap to the Mark Price relative to the Index Price defined by Factor (see table below) and Cap/Floor funding (cf Funding Rate section)

Mark Price = Clamp(Median Price, Index Price * (1 + Factor * Cap Funding), Index Price * (1 + Factor * Floor_funding))

cap_funding and floor_funding depend on the perpetual market (cf Funding Rate section)

Index Price

For a given contract, the Index price is the volume-weighted average of the underlying asset prices listed on major spot exchanges.

In order to mitigate the risk of market manipulation on one specific venue or exchanges outages or connectivity issues, Orderly undertakes the following protection measures:

  1. If, for any source, the price deviates by more than 5% from the median price of all sources, Orderly caps/floors the value at +/- 5%. Once the source price falls within the 5% range, its original value will be taken.

  2. If multiple sources show a deviation of more than 5% from the median, Orderly will use the median instead of the volume-weighted average.

  3. If a specific source is not sending any price for over 10 seconds, it will be disregarded from the Index Price calculation completely.

In the Index Price calculation, the weights are computed every 5 minutes and are based on the 4-hour trading volume over the spot trading pairs of the selected centralized exchanges.

Weight (CEX_i) = Volume (CEX_i) / Total Volume (CEXes)
where:
    Volume (CEX_i) refers to the 4-hour trading volume of the CEX i
    Total Volume (CEXes) refers to the sum of the 4-hour trading volume accross all relevant CEXes for the specific pair

Last Price

The Last Price refers to the last traded price of a Perpetual Futures contract.

Last updated