# L2 Perpetual Contracts

Detailed perpetual contracts explainer

### Supported Perpetual Contracts

New contract pairs will be added in time, and an open market creation tool is being proposed for development. Join our Discord to discuss if you have ideas or suggestions!

### Overview

There are a number of high-level components required for the implementation of synthetic perpetual futures on Synthetix, they are outlined below:
Each of these components will be detailed below in the technical specification. Together they enable the system to offer leveraged trading while charging a funding rate to reduce market skew and tracking the impact to the debt pool of each futures market.

### Market and Position Parameters

A position, opened on a specific market, may be either long or short. If it's long, then it gains value as the underlying asset appreciates. If it's short, it gains value as the underlying asset depreciates. As all positions are opened against the pooled counterparty, the price of this exchange is determined by the spot rate read from an on-chain oracle.
A position is defined by several basic parameters, noting that a particular account will not be able to open more than one position at a time: instead, it must modify its existing one.
We will use a superscript to indicate that a value is associated with a particular position. For example
$q^c$
corresponds to the size of position
$c$
. If the superscript is omitted, the symbol is understood to refer to an arbitrary position.
Symbol
Description
Definition
Notes
Position size
Measured in units of the base asset. Long positions have $$q > 0$$, while short positions have
. for example a short position worth 10 BTC will have
. The position size is computed from a user's margin and leverage. See the margin section for a definition of terms used in the definition.
Base asset spot price
-
We also define
, the spot price when position
was entered.
Notional value
This is the (signed) dollar value of the base currency units on a position. Long positions will have positive notional, shorts will have negative notional. In addition to the spot notional value, we also define the entry notional value
.
Profit / loss
The profit in a position is the change in its notional value since entry. Note that due to the sign of the notional value, if price increases long profit rises, while short profit decreases.
Each market, implemented by a specific smart contract, is differentiated primarily by its base asset and the positions open on that market. Additional parameters control the leverage offered on a particular market.
Symbol
Description
Definition
Notes
The set of all positions on the market
-
We also have the positions on the long and short sides,
and
, with
.
Base asset
-
For example, BTC, ETH, and so on. The price
defined above refers to this asset.
Market Size
$Q \ := \sum_{c \in C}{|q^c|} = Q_L + Q_S$
The total size of all outstanding positions (on a given side of the market).
Open interest cap
-
Orders cannot be opened that would cause the notional value of either side of the market to exceed this limit. We constrain both:
The cap will initially be
on each side of the market.
Market skew
The excess base units on one side or the other. When the skew is positive, longs outweigh shorts; when it is negative, shorts outweigh longs. When
, the market is perfectly balanced.
Maximum Initial leverage
-
The absolute notional value of a position must not exceed its initial margin multiplied by the maximum leverage. Initially this will be no greater than 10.

### Leverage and Margins

When a position is opened, the account-holder chooses their initial leverage rate and margin, from which the position size is computed. As profit is computed against the notional value of a position, higher leverage increases the position's liquidation risk.
Symbol
Description
Definition
Notes
Leverage
The sign of
reflects the side of the position: longs have positive
, while shorts have negative
. We also define
, the selected leverage when the position was entered. We constrain the entry leverage thus:
Note that the leverage in a position at a given time may exceed this value as its margin is exhausted.
Initial margin
This is the quantity of sUSD the user initially spends to open a position of
units of the base currency. The remaining
sUSD to pay for the rest of the position is "borrowed" from SNX holders, and it must be paid back when the position is closed.
Remaining margin
A position's remaining margin is its initial margin, plus its profit
and funding
(described below). When the remaining margin reaches zero, the position is liquidated, so that it can never take a negative value.
It is important to note that the granularity and frequency of oracle price updates constrains the maximum leverage that it's feasible to offer. If the oracle updates the price whenever it moves 1% or more, then any positions leveraged at 100x or more will immediately be liquidated by any update.
When a position is closed, the funds in its margin are settled. After profit and funding are computed, the remaining margin of
sUSD will be minted into the account that created the position, while any losses out of the initial margin
, will be minted into the fee pool.

### Exchange Fees

Users pay a fee whenever they open or increase a position. However, we wish to incentivize reduction of skew, so we distinguish between maker and taker fees. A maker is someone reducing skew and a taker is someone increasing it, and so we charge makers less than takers, possibly even zero insofar as this is possible in the presence of front-running. This fee will be charged out of the user's remaining margin. If the user has insufficient margin remaining to cover the fee, then the transaction should revert unless they deposit more margin or make some profit. As the fee diminishes a user's margin, and is charged after order confirmation, they should be aware that it will slightly increase their effective leverage.
The fees will be denoted by the symbol
as follows:
Symbol
Description
Definition
Notes
Taker fee rate
-
Charged against the notional value of orders increasing the skew. Initially,
.
Maker fee rate
-
Charged against the notional value of orders reducing the skew. Initially,
.
There are several cases of interest here, the fee charged in each case is as follows:
Case
Fee
Decrease in the size of a position by
) units.
Increase in the size of a position on the heavy side of the market (and therefore the skew) by
units.
Increase in the size of a position on the light side of the market by
units.
Increase in the size of a position on the light side of the market by
units. The user's order flips the skew, and so they are charged the maker fee up to the size of the skew, and the taker fee for the opposing skew induced.
Note that no fee will generally be charged for closing or reducing the size of a position, so that funding rate arbitrage is more predictable even as skew changes, and in particular more profitable when opening a position on the lighter side of the market. See the funding rate section for further details.

### Skew Funding Rate

Whenever the market is imbalanced in the sense that there is more open value on one side, SNX holders take on market risk. At a given skew level, SNX holders take on exposure equal to
as the price moves from
.
Therefore a funding rate is levied, which is designed to incentivize balance in the open interest on each side of the market. Positions on the heavier side of the market will be charged funding, while positions on the lighter side will receive funding. Funding will be computed as a percentage charged over time against each position’s notional value, and paid into or out of its margin. Hence funding affects each position's liquidation point.
Symbol
Description
Definition
Notes
Proportional skew
The skew as a fraction of the total market size.
Max funding skew threshold
-
The proportional skew at which the maximum funding rate will be charged (when
). Initially,
Maximum funding rate
-
A percentage per day. Initially
.
Instantaneous funding rate
A percentage per day.
The funding rate can be negative, and has the opposite sign to the skew, as funding flows against capital in the market. When
is positive, longs pay shorts, while when it is negative, shorts pay longs. When
, no funding is paid, as the market is balanced.
Being computed against a position's notional value, it is worth being aware that funding becomes more powerful relative to the margin as the base asset appreciates, and less powerful as it depreciates.
As the SNX debt pool is the counterparty to every position, it is either the payer or payee of funding on every position, but it is always receiving more than it is paying. SNX holders receive
in funding: this is a positive value which will be paid into the fee pool.
This funding flow increases directly as the skew increases, and also as the funding rate increases, which itself increases linearly with the skew (up to
). As the fee pool is party to
in open positions, its percentage return from funding is
, so it grows with the square of the proportional skew. This provides accelerating compensation as the risk increases.

### Accrued Funding Calculation

Funding accrues continuously, so any time the skew or base asset price changes, so too does the funding flow for all open positions. This may occur many times between the open and close of each position. The expense of constantly updating all open positions is prohibitive, so instead any time the skew changes, the total accrued funding per base currency unit will be recorded, and the individual funding flow for each position computed from this.
The base asset price in fact changes in between these events, but funding calculations will use the spot rates whenever skew modification occur. If the market is active, any inaccuracy in funding induced as a result is minor.
If the funding flow per base unit at time
, then the cumulative funding over the interval
is:
If the funding rate and price (hence the funding flow) over an interval is constant, then we also have:
If the skew was updated at a finite sequence of times
, we only need to recompute funding at each of these times and so we have
such constant funding-flow intervals. All order-modifying operations alter the funding rate, and so occur exactly at the boundaries of these periods.
Consider the cumulative funding from the initial time
up to the current time
, this expands as a telescoping sum, noting that
:
Furthermore,
So, if the accumulated funding per base unit is tracked in a time series, appended to any time the funding flow changes, it is possible to compute in constant time the net funding flow owed to a position per base unit over its entire lifetime.
In the implementation, it is unnecessary to track the time at which each datum of the cumulative funding flow was recorded. For convenience, we will reuse
for the sequence, to be accessed by index, rather than as a function of time.
Funding will be settled whenever a position is closed or modified.
Symbol
Description
Definition
Notes
-
The timestamp of the last skew-modifying event in seconds.
Cumulative funding sequence
denotes the i'th entry in the sequence of cumulative funding per base unit.
will be taken to be the latest entry.
Unrecorded base funding
The funding (denominated in the base currency) per base unit accrued since the last funding entry was recorded at
.
Unrecorded cumulative funding
The funding per base unit accumulated up to the current time, including since
.
Last-modified index
at initialization.
The index into
corresponding to the event that a position was opened or modified.
Accrued position funding
The sUSD owed as funding by a position at the current time. It is straightforward to query the accrued funding at any previous time in a similar manner.
Maximum funding rate of change
-
This is an allowable funding rate change per unit of time. If a funding rate update would change it more than this, only add at most a delta of
. Initially,
per day.
Then any time a position
is modified, first compute the current funding rate by updating market size and skew, where
is the position's updated size after modification:
Then update the accumulated funding sequence:
Then settle funding and perform the position update, including:

### Aggregate Debt Calculation

Each open position contributes to the overall system debt of Synthetix. When a position is opened, it accounts for a debt quantity exactly equal to the value of its initial margin. That same value of sUSD is burnt upon the creation of the position. As the price of the base asset moves, however, the position’s remaining margin changes, and so too does its debt contribution. In order to efficiently aggregate all these, each market keeps track of its overall debt contribution, which is updated whenever positions are opened or closed.
The overall market debt is the sum of the remaining margin in all positions. The possibility of negative remaining margin will also be neglected in the following computations, as such contributions can exist only transiently while positions are awaiting liquidation. So long as insolvent positions are liquidated within the 24-hour time lock specified in SIP-40, the risk of a front-minting attack is minimal. This will simplify calculations, and for the purposes of aggregated debt, the remaining margin will be taken to be
.
The total debt is computed as follows:
Apart from the spot price
, nothing in this expression changes except when positions are modified, Therefore we can keep track of everything with one additional variable to be updated on position modification:
, holding the sum on the right hand side. Then upon modification of a position, this value is updated as follows:
Where
and
is its recomputed value after the position is modified.
Symbol
Description
Definition
Notes
Aggregate position entry debt correction
-
Market Debt
-
In this way the aggregate debt is efficiently computable at any time.

### Liquidations and Keepers

Once a position's remaining margin is exhausted, it must be closed in a timely fashion, so that its contribution to the market skew and to the overall debt pool is accounted for as rapidly as possible, necessary for accuracy in funding rate and minting computations.
As price updates cannot directly trigger the liquidation of insolvent positions, it is necessary for keepers to perform this work by executing a public liquidation function.
Yet this is not as simple as checking that a position's current remaining margin is zero, as it may have transiently been exhausted and then recovered. Therefore the oracle service that provides prices to the market must retain the full price history, and in order to liquidate a position it will be sufficient to prove only that there was a price in that history that exhausted its remaining margin.
In order to pay for this work, the liquidation point will in fact be slightly above zero remaining margin, and the difference
will go to a liquidation keeper. Therefore when opening a position, the user must post at least
sUSD worth of margin to ensure the keeper can be incentivized.
A position may be liquidated whenever a price is received that causes:
If this is satisfied, the position is closed, the incentive is minted into the liquidating keeper's wallet at the execution time, and the rest of the position's initial margin goes into the fee pool.
Symbol
Description
Definition
Notes
Liquidation keeper incentive
-
This is a flat fee that is used to incentivise keeper duties. Initially this will be set to
sUSD.
Minimum order size
-
The keeper incentive necessitates that orders are at least as large. We will initially choose
sUSD, corresponding to 5x leverage at the minimum order size relative to
. We will require
.
Liquidation price
The liquidation price will be below the entry price for long positions, and above it for short positions, as the sign of
changes.
As the Synthetix system can issue and burn synths as necessary, liquidations occur retrospectively at exactly
, even if the spot price has moved past the exact liquidation point at $$m = D$$. The form of
is found by expanding the left hand side of
and solving for the spot price. As this price depends on the function sequence, it can move around a little as funding accrues into a position's margin. Therefore the indicated liquidation price when position opens is only an estimate; but it becomes more accurate as the margin is exhausted.
It should be borne in mind that if gas prices are too high to allow liquidations to be profitable for liquidators, then liquidations will likely not be performed. In this case the system must fall back on relying on good samaritans until the incentive level can be raised by SCCP. Increasing
will spontaneously modify the liquidation points of already-liquidatable positions, and the extra incentive is ultimately paid out of the debt pool. Future updates should consider a gas-sensitive liquidation incentive.
The liquidation function should take an array of positions to liquidate; if any of the provided positions cannot be liquidated, or has already been liquidated, the transaction should not fail, but only liquidate the positions that are eligible.

#### Extensions

• Paying a portion of the skew funding rate owed to the fee pool to the lighter side of the market, which would enhance the profitability of taking the counter position on market.
• Make funding rate sensitive to leverage - right now a market with
long and
open interest is considered balanced, even though the long exposure is much riskier. Some remedies could include:
• Funding rate that accounts for leverage risk
• Funding rate as automatic position size scaling, which would automatically bring the market into balance.
• Mechanisms to constrain the overall size of each market, other than leverage and available sUSD.