How it Works

Overview

At its heart, Perpetual Protocol seeks to create a perpetual contracts trading protocol that anyone can use. You will be able to trade with good liquidity and low slippage thanks to our innovative vAMM-based exchange. We use a scaling technology called xDai to increase the speed of trades compared to other Ethereum-based exchanges, as well as to offer zero gas fees on all trades.

Trades on Perpetual Protocol settle in USDC, so all collateral used on the exchange is in USDC.

Perpetual Protocol uses a streamlined system to allow traders to gain the benefits of xDai scaling without having to set up your wallet. Simply use your existing wallet to 'deposit' USDC via our trading interface, and you are ready to trade. Your funds are controlled by your Metamask wallet or other compatible wallet at all times during the trading process.

Stakers on Perpetual Protocol enjoy zero impermanent loss risk while earning fees and rewards on their staked PERP tokens. This is because staked PERP tokens are not stored in our vAMM or used for liquidity — they are safely stored in the smart contract vault and not a liquidity pool, and are therefore not exposed to impermanent loss.

Perpetual Contract Trading

We highly recommend spending some time learning about perpetual contract trading before starting to use Perpetual Protocol. In general, trading perpetual contracts on our platform is largely similar to trading perpetuals on centralized exchanges. The main differences are:

  • Perpetual Protocol does not use an order book - trades are filled right away and there is no need to wait for a counterparty or pay a taker fee.

  • Trades settle somewhat slower than on centralized exchanges, especially during high volume - to mitigate this, we provide slippage controls, and all trading operations take place on xDai, which is significantly faster than the Ethereum base layer.

Trading can result in financial loss, although with Perpetual Protocol, you are assured of never losing more than your initial investment. Keep two principles in mind at all times:

  • Never invest more than you can afford to lose

  • Always do your own research to understand the tokens, wallets and other tools you are using

Perpetual contract basics

Perpetual contracts are a type of futures contract, pioneered in the cryptocurrency space by Bitmex. Perpetual contracts are one of the most popular derivative products in the space.

Perpetual contracts allow traders to speculate on the future price of a given asset by buying (going long) or selling (going short) perpetual futures contracts. Unlike typical futures, perpetuals do not expire and remain effective until the trader closes their position.

The price of perpetual contracts will often diverge from the broader market (aka spot market). These deviations signal sentiment on the exchange - if a majority of traders expect the underlying asset to increase in value over time, the price of the perpetual contract will likely exceed the spot price. Likewise, if most traders expect the price to fall, the price of the perpetual will be below the spot price.

There are two mechanisms that moderate this process, and function to keep the perpetual contract price close to the spot price.

  • Funding payments

    • Every hour, traders with open long or short positions will pay each other a funding payment, depending on market conditions. If the contract price is above the spot price, longs will pay shorts. If the contract price is below the spot price, shorts will pay longs. The size of the funding payment is a function of the difference between the contract price and the spot price, as well as your position size. This incentivizes traders to take the unpopular side of the market.

  • Arbitrage

    • If the contract price diverges significantly from the spot price in other exchanges, arbitrageurs can benefit in two ways. 1. If they hold a position elsewhere, they can use Perpetual Protocol to take the inverse position and earn funding payments. 2. They buy or sell an asset elsewhere, and long or short that asset using Perpetual Protocol, in the expectation that the price will tend to move back toward the spot price.

vAMM

Our exchange model is very different from other exchanges, including AMM based exchanges. Key points to begin with:

  • Perpetual Protocol does not use liquidity or liquidity providers.

  • Perpetual Protocol is 100% AMM based; there is no order book.

  • The on-chain price reflects trades on Perpetual Protocol - the price only moves when positions are opened or closed.

Traders use collateral (USDC) to open long or short positions in a given asset. Every time a trade is made, the vAMM calculates the entry or exit price in the same way prices are calculated on Uniswap or other AMM style exchanges.

An important difference with the vAMM is that no swap is occurring. Unlike Uniswap, for example, where traders arrive with asset A and leave with asset B, on Perpetual Protocol traders always arrive with USDC, and leave with USDC. This allows the protocol to operate without ever having held the underlying asset.

Leverage

Perpetual Protocol allows traders to use leverage by backing a position with a margin - collateral that is less than the total position size. Traders can open positions with leverage up to 10x, and use Margin Mgt to increase the leverage up to 15x.

Note that an effective leverage of 16x, equivalent to a margin ratio of 6.25%, will open your position to liquidation.

Example

You can open an ETH long position worth 1000 USDC backed by a margin of 100 USDC. Your margin ratio is 10%, equivalent to a leverage of 10x. If ETH falls in value, you start to lose money, resulting in a negative PnL. PnL is added to your margin, so in our example, your margin will start to go below 100 USDC, in turn decreasing your margin ratio. If the margin ratio falls to 6.25%, then your position may be liquidated.

Liquidation

Liquidation occurs when your position margin ratio falls to 6.25% or below. This is known as the maintenance margin.

Liquidation is triggered by keeper bots. As a reward for performing this service, keepers earn 1.25% of the remaining notional. The remaining margin (up to 5% of the notional) will be placed in the protocol insurance fund.

Keepers are used with blockchains because smart contracts and blockchains in general are passive and cannot execute code without external triggers. Keeper bots are a decentralized way to accomplish this trigger (anyone can run the bot).

Margin ratio

Each position open on Perpetual Protocol has a margin and a notional. The margin refers to the actual collateral used to back a position. The notional is the size of the position after leverage is considered, denominated in underlying asset. So a position with a margin of 100 USDC and 10x leverage will have a notional value of 1000 USDC (and a size shown in underlying asset, e.g. 1000 USDC worth of ETH.)

The ratio of the margin (including PnL) vs. the notional size gives the margin ratio. If the market moves against you, as your PnL falls, your margin ratio will also fall. If the ratio reaches 6.25% or below, your position will be liquidated.

Example

You open an ETH long position using 100 USDC collateral and 10x leverage. Your position notional value will be 1000 USDC. If the price of ETH falls to a point where your PnL is -37.5, your margin ratio will have reached 6.25% and your position may be liquidated. Your remaining margin (62.5 USDC or less) will be divided between the liquidator (12.5 USDC) and the insurance fund (whatever remains).

Trading

Let's walk through an example trade.

How Perpetual Protocol Works

Example

Step 1 Alice sends 100 USDC to the Clearing House on Perpetual Protocol and specifies to use that amount as the margin to open a 2x leveraged long position.

The primary function of the Clearing House is to record the position ownership and its related information, including initial margin, leverage, and direction (long or short).

Step 2~3 Upon receiving the 100 USDC, the Clearing House deposits the funds into the Vault. After that, Perpetual Protocol updates the asset price in our vAMM according to the margin amount, position direction (long or short), and the amount of leverage.

In contrast to the applications that utilize automated market makers (AMMs) to facilitate token swaps like Uniswap and Balancer, Perpetual Protocol only uses the constant-product curve in our AMMs for price discovery so that we can handle leverage and shorting. This also means there is no risk of impermanent loss for liquidity providers.

As you can see from the diagram above, the deposited tokens from traders aren't stored inside our AMMs, whereas on Uniswap, the deposited tokens from traders are indeed stored inside their AMMs. Due to this difference, we name our AMMs "Virtual AMMs" because there is no actual token swapping involved in our AMMs.

For those who don't know what a constant-product curve is or how Uniswap works, please see:

Back to our trader, Alice. Assume we have 100 ETH/USDC and 10,000 USDC in our vAMM as its initial state.

Action (Chronological)

ETH/USDC (x)

USDC (y)

*Calculation

Initial State

100

10,000

As mentioned before, the amount of ETH/USDC and USDC set in a vAMM aren't real tokens - they're just two numbers credited in a vAMM, and this vAMM uses them as the variables in the constant-product curve formula to calculate the price of the derivative on the platform.

Step 4~5 If Alice uses 100 USDC as the margin to open a 2x leveraged long position, which means that the amount of USDC in our vAMMs will become 10,200 (10,000+100*2), the amount of ETH/USDC will become 98.04 (100*10,000/10,200), which is calculated by the constant-product curve, and the position Alices opens is 1.96 ETH (100-98.04).

Action (Chronological)

ETH/USDC (x)

USDC (y)

*Calculation

Initial State

100

10,000

Alice gets 1.96 long position

98.04*

10,200

100*10,000/10,200

Step 6~ Following Alice, Bob also uses 100 USDC to open a long position with 2x leverage. His position size will be 1.88 ETH (98.04-96.15) as calculated by the vAMM.

Action (Chronological)

ETH/USDC (x)

USDC (y)

*Calculation

Initial State

100

10,000

Alice gets 1.96 long position

98.04*

10,200

100*10,000/10,200

Bob gets 1.89 long position

96.15*

10,400

98.04*10,200/10,400

After Bob gets his long position, Alice decides to close her position and realizes a profit of 7.84 USDC (10400 - 96.15*10,400/(96.15+1.96)- 200)

Action (Chronological)

ETH/USDC (x)

USDC (y)

*Calculation

Initial State

100

10,000

Alice gets 1.96 long position

98.04*

10,200

100*10,000/10,200

Bob gets 1.89 long position

96.15*

10,400

98.04*10,200/10,400

Alice closes her position

98.115

10192.16*

96.15*10,400/98.115

Seeing Alice makes a profit, Bob wants to close his position too, only to find out that he lost -7.84 USDC (10192.16-98.115*10192.16 / (98.115+1.885) - 200) after closing his position.

Action (Chronological)

ETH/USDC (x)

USDC (y)

*Calculation

Initial State

100

10,000

Alice gets 1.96 long position

98.04*

10,200

100*10,000/10,200

Bob gets 1.89 long position

96.15*

10,400

98.04*10,200/10,400

Alice closes her position

98.11

10,192.16*

96.15*10,400/98.115

Bob closes his position

100

10,000*

98.115*10,192.16/100

So what can learn from the example above?

Unique Properties of Perpetual Protocol's vAMM

  • One trader's gain equals another trader's loss. As you can see Alice's gain equals Bob's loss, which is similar to traditional peer-to-peer futures trading.

  • No liquidity providers are involved because we don't store tokens inside our vAMMs.

  • The vault always has enough collateral to pay back every trader because one trader's gain will cancel out another trader's loss.

Trading on xDai Chain

All trading activities occur on the xDai Chain to save gas fees and improve trading speed.

Learn why we chose xDai here.

Here is the updated architecture:

The architecture of Perpetual Protocol with Ethereum as Layer 1 and xDai as Layer 2

As you can probably tell, all of the components related to trading activities such as Clearing House, Insurance Fund, etc., are all on xDai now.

Despite this major change, only one additional step is needed for traders to start trading compared to the above example, which assumes the trading activities happening on the main Ethereum network:

  1. You deposit USDC to the Deposit Proxy (using MetaMask), which is a smart contract that passes your deposit to the Root Bridge Contract, crediting you the same amount of xUSDC to your address on xDai.

When you want to open a position from our trading platform, the only thing you need to do is to sign a transaction with your wallet (using MetaMask); the signature will be submitted to the Meta Transaction Relayer (no gas is involved in this step, since it's a meta transaction). The position is opened on xDai, and the trading platform is updated.

One thing we want to emphasize is that, despite using xDai to launch on Ethereum mainnet, with the above architecture, it’s possible to migrate the whole system to other scaling solutions (L2 and other chains alike) without much hassle. One can imagine the Perpetual DAO voting to pause trading activities on xDai, snapshot the state (traders’ active positions, balances, etc.), and proceed to ‘paste’ every trader’s state onto another L2/chain and resume trading activities.

You can check this Medium post to know the rationale behind the move to xDai and the pros and cons of this decision.

Hourly Funding Payment

Periodic funding payments are the most common mechanism used by exchanges to do perpetual swaps. Funding payments act to converge the mark price (the price on Perpetual Protocol) and the index price (the average price from major exchanges).

Find historical funding rates on Perpetual Protocol here.

Perpetual Protocol follows FTX's method to calculate the funding payments, which is done according to the formula below:

fundingPayment=positionSizefundingRatefundingPayment = positionSize * fundingRate

The fundingRate in the formula above is calculated by, firstly, subtracting the hourly time-weighted average price (TWAP) of the index price from the hourly TWAP of the mark price, and secondly, dividing the result from the previous step by 24.

fundingRate=TWAPperpetualTWAPindex24fundingRate = {TWAP_{perpetual} - TWAP_{index} \over 24}

We use the price feed from Chainlink as the data source for the index price because it is currently the most battle-tested Oracle solution on the market. Other oracles will be added as needed.

If the fundingRate is positive, long position holders need to pay the funding payment while short position holders will receive the funding payment, and vice versa if the rate is negative.

The funding payment happens at the end of each hour on Perpetual Protocol.

Sound complicated? Let's take a look at another example.

Example

Similar to the example from the previous section, 100 ETH/USDC and 10,000 USDC are set as the initial state in our vAMM at launch. Both Alice and Bob use 100 USDC as the margin to open long positions with 2x leverage, one after the other. And right after Bob opens his position, Alice closes her long position and realizes a profit of 7.84012298 USDC.

Action (Chronological)

ETH/USDC (x)

USDC (y)

Mark Price

*Calculation

Initial State

100

10,000

100

Alice gets 1.96 long position

98.0392156862745*

10,200

104.04

100*10,000/10,200

Bob gets 1.89 long position

96.1538461538461*

10,400

108.16

98.0392156862745*10,200/10,400

Alice closes her position

98.1146304675716

10,192.1598770177*

103.880123

96.1538461538461*10,400/98.1146305

If we draw a line chart with the mark price from each action above on the y-axis and each chronological action on the x-axis, below is what we'll get:

Supposing there isn't any action after Alice closing her position and now the time is close to the end of the hour in which all of those actions have happened.

We can imagine two distinct scenarios depending on the difference between the TWAP of the mark price and the TWAP of the index price.

TWAP of the Mark Price > TWAP of the Index Price (Positive Funding Rate)

In this scenario, the long position holders need to pay the funding payment whereas the short holders can receive the funding payment. Participants in our ecosystem will respond in different ways to this situation:

  • Bob might want to close his position or part of his margin will be used to pay the funding payment

  • Arbitrageurs might want to come in and open a short position so they can receive funding payment from the long position holders

TWAP of the Mark Price < TWAP of the Index Price (Negative Funding Rate)

In this scenario, the short position holders need to pay the funding payment whereas the long holders can receive the funding payment. Participants in our ecosystem will behave differently in this situation:

  • Alice might feel frustrated because she could have received the funding payment if she didn't close her position

  • Arbitrageurs might want to come in and open a long position so they can receive funding payment from the short position holders