How to Perpetual Contracts: Beginner

Preface

For beginners, it is challenging to learn crypto. If someone could gather the latest content and summarize it, it would be precious for mainstream adoption of the crypto industry. How to DeFi is a comprehensive introduction, but some of its content is outdated, because too many protocols get pivoted or shut down now and then. The Phezzan team decides to write a Phezzan's edition - How to Perpetuals: Beginner.

In this small digital book we will introduce the typical mechanism of perpetual contracts and some decentralized perpetual contract protocols. It will help readers understand perpetual contracts better.

Long story short, we firmly believe it is vital to understand perpetual contracts, as they count for more than two-thirds of the cryptocurrency trading volume.

Some of the protocols mentioned in this article have issued tokens. Please note that nothing constitutes an investment opinion or recommendation.

Futures Contract

Perception of future commodity prices varies across individuals and corporations. The price of commodities today may not be the same as the price in the following year. Some people think by next year, the price may be higher, so buying at a lower price today can be profitable. Others assume the opposite, so buying at a higher price today will result in losses.

The emergence of futures contracts satisfy everyone's demand for buying the same commodity at different prices in the future. When you buy a futures contract, you purchase a transaction it's agreed purchase of a contract/transaction at a future date based on the current price at the contract time initiation. In practical applications, futures can be used for both hedging and speculation.

Perpetual Contracts

Introduction

A futures contract contains an expiry delivery date, while you can trade Bitcoin and other cryptocurrencies 24 hours a day, 365 days a year. Suppose the corresponding futures contract for Bitcoin has an expiry delivery date. In that case, the contract holder will be required to transfer the position, resulting in additional costs. In contrast, the perpetual contract has no delivery date, so traders can hold positions forever. Perpetual contracts quickly became popular worldwide, becoming a must-have product for major cryptocurrency exchanges.

In perpetual contracts, only a small margin is required, and the leverage can be as high as 200 times. By introducing the funding rate mechanism, the contract price is close to the spot price.

BitMEX is the first cryptocurrency exchange to launch a perpetual contracts. Its official website has a detailed introduction to the perpetual contracts mechanisms, including liquidation, auto-deleveraging, etc. Currently, perpetual contracts on mainstream exchanges are all designed with a mechanism similar to BitMEX.

For normies, perpetual contracts have the following advantages:

● High leverage: Most centralized exchanges offer at least 100x leverage.

● No spot needed: Trade against the index price of the spot market. Traders can long and short without having a spot position.

● No expiry date, no delivery: Traders can hedge much easier without transferring position and can hold position forever before liquidation.

● No interest rates: Using leverage does not require borrowing and therefore does not require traders to pay interest. Traders only need to pay the transaction fee and potential funding rate.

Funding Rate

Funding rate is an effective tool in the crypto market to keep the price of the perpetual contract close or equal to the price of the spot market. Funding rate is a regular charge fee paid between short and long positions. When a perpetual contract trades at a premium (higher than the spot market price), long positions pay short positions, and vice versa. Payment regularly occurs every certain period, and only traders with open positions will pay or receive the funding fee at the time of collection.

Most exchanges use a similar funding rate calculation formula, which consists of two main parts: interest rates and premiums. Exchanges differ in interest rate definition and calculation, but the main idea is assumed that the interest earned by holding cash/stablecoin is higher than the interest earned by holding the equivalent cryptocurrency such as Bitcoin, and the premium varies depending on the price difference between the perpetual contract market and the spot market.

Some people may have this question: Why should the price of the perpetual contract be close or equal to the spot market? Because when you're trading assets on a spot market, you're trading one asset for another. When you're trading assets on a perpetual contract market, you're buying and selling contracts that reference the asset; you're not buying the asset itself. This means that the perpetual contract is traded on an independent market separate from the spot market, but the price of the perpetual contract market closely tracks the price of the spot market.

Mark Price, Index Price

Perpetual contracts usually have two price indicators: a mark price, and an index price. Due to the high leverage of perpetual contracts, trading volume and price volatility are relatively large. To avoid unreasonable liquidation caused by high price volatility, mark price is used to calculate the unrealized profit and loss of the position and the liquidation price. The index price is the most crucial part when calculating the mark price. It tracks the spot price of multiple mainstream exchanges to prevent traders from being liquidated due to the sharp price fluctuations of a particular exchange.

Margin

When a trader opens a leveraged position, the minimum amount that a trader must pay is called the initial margin. Margin is the collateral that a trader has to deposit to cover the risk for the counterparty. For example, a trader could buy 10 ETH with an initial margin of 0.1 ETH at 100x leverage, and the initial margin would be 1% of the order. To keep the position open, traders must hold a maintenance margin, the minimum margin of collateral. If traders’ margin balance drops below the maintenance margin, they will either receive a margin call for adding more collateral or be liquidated.

Liquidation

If the value of traders’ collateral falls below the maintenance margin, the trading account may be subject to liquidation. Traders will be liquidated, and the maintenance margin will be lost if the maintenance requirement cannot be fulfilled.

Insurance Fund

Sometimes the executed price of the liquidation is not precisely equal to the price of the bankruptcy, that is, the margin may not be precisely equal to the liquidation price of positions, there may be a surplus, or it may not be enough to compensate the profit of the counterparty. In this case, the mechanism of the Insurance fund is required.

The insurance fund protects liquidated positions from excessive losses and ensures that those winners are paid in full. The purpose of the insurance fund is to avoid auto-deleveraging. If the insurance fund is depleted, the winner will not get the due profit back. Conversely, the winner needs to contribute capital to make up for the losses of the liquidated positions; the auto-deleveraging system will automatically deleverage profitable positions to cover the excess losses of liquidated positions. More profitable and higher leveraged positions are deleveraged first.

In the case of BitMEX, the income of the insurance fund will be added when the price of the liquidated position is higher than the bankruptcy price, and the expenditure of the insurance fund will be reduced if the price of the liquidated position is lower than the bankruptcy price. If this still does not close the liquidated positions, this will lead to an auto-deleverage.

Profit and Loss

PnL (Profit and Loss) can be either realized or unrealized. When traders have open positions, the PnL is unrealized, and it's still changing. When traders close positions, unrealized PnL becomes realized PnL. The realized PnL is calculated by the executed price, not the mark price, and the unrealized PnL is calculated by the mark price.

Before trading in the perpetual contract, traders should understand the funding rate and the payment cycle for the long-term holding of positions. The cost of the funding rate might be significant.

Decentralized Perpetual Contracts

We have discussed the core mechanisms of perpetual contracts above; we need to dive deeper into the world of decentralized perpetual contract exchanges now.

Perpetual Protocol: vAMM

Perpetual V1 uses vAMM (Virtual Automated Market Maker) as a price discovery mechanism. It doesn't need market makers to provide liquidity as a counterparty. The vAMM mechanism does not require LPs, as it sets up an automated trading mechanism in which traders are counterparties to each other. It avoids the reliance on LPs and the problem of impermanent losses.

How vAMM works: Before setting up the vAMM, traders set the number of virtual assets stored in the vAMM.

Assuming the market price of ETH is $400, traders can set the initial amount of ETH and USDC on the vAMM in a ratio of 1:400. We assume that traders set the initial state of the vAMM to 100 vETH and 40000 vUSDC.

If Alice takes 100 USDC as collateral and opens 10x long on ETH, 1,000 vUSDC is recorded to vAMM, vAMM calculates the amount of vETH received by Alice according to x * y = k, which is 2.439 vETH, and the current state of vAMM is 97.5609756 vETH and 41000 vUSDC.

Bob then takes 100 USDC as collateral and opens 10x short on ETH, which means 1,000 vUSDC is recorded to vAMM, vAMM calculates the amount of vETH received by Alice according to x * y = k, which is -2.439 vETH, and the current state of vAMM is 100 vETH and 40000 vUSDC.

There is no need for LPs to bring liquidity to vAMM. Traders themselves can provide liquidity to each other.

At the same time, there are some problems with V1, due to the formula x * y = k, where the k value is static. When the market price of an asset in an asset pool fluctuates sharply in one direction, it takes a considerable incentive to move the price of the virtual market in the same direction. For example, when the ETH virtual market on V1 was set up, the market price of ETH was $400, and it rushed to $4,000 after six months. Hence, the virtual price of ETH must follow the market price of ETH, which is achieved by using arbitrageur bots opening and keeping long positions. Arbitrageur bot is essentially a public good that tries to maintain the price of the virtual market aligning with the real market, not by trading and trying to be profitable. In this case, the insurance fund pays the arbitrageur bot.

Simply put, to align the price of the virtual market with the real market, someone needs to maintain an unreasonably high ratio of long positions (raise the virtual price) or short positions (drop the virtual price). It takes too much incentive to maintain this ratio. However, the ratio between longs and shorts is almost equal in mainstream markets. While vAMM of Perpetual V1 unleashes capital efficiency, the core mechanism that sustains it is not suitable for a market with high volatility and trend fluctuations.

Perpetual V2 uses vAMM with real liquidity, the vAMM is built on the Uniswap V3. For example, in the ETH/USDC virtual market, LPs deposit USDC to the clearing house (transaction engine of Perpetual V2), which enables LPs to provide virtual liquidity up to 10x of the deposits. LPs can deploy the virtual liquidity to price range orders in vETH/vUSDC in the same way as market making on Uniswap V3.

This change makes the gains and losses of market making on Perpetual V2 closer to market making on Uniswap V3. When LPs withdraw liquidity, the value of ETH must be repaid at the market price, not the price at which the LPs borrowed. This can result in low returns for unhedged LPs in an up-trending market.

GMX: Oracle-based pricing

Unlike the adaption of Uniswap V3, GLP is the liquidity provider for GMX. GLP assets include BTC, ETH, AVAX, UNI, LINK, and stablecoins. Because there are trading counterparties with real assets, GMX only needs to borrow price from the price oracle to be able to carry out perpetual contract transactions, which improves the capital efficiency of LPs. Unlike AMM, GLP does not need to maintain the relative liquidity ratio of trading pairs of liquidity pools at all times. Transactions can be fully executed within GLP's liquidity constraints.

GLP is the traders' counterparty. If traders wish to take positions on ETH, GMX is essentially transferring GLP's PnL of ETH price to the traders. When the trader wins, GLP loses. When the trader loses, then GLP benefits as the counterparty to the trader's position. GLP may face a very unfavorable extreme situation: the market falls, and traders only take short positions. Hence, GLP must hedge against unilateral market conditions.

Due to GMX's reliance on the price oracles. Those oracles only support mainstream assets like BTC and ETH, they do not support long-tail assets or illiquid assets, which may limit the assets that GMX can provide to the most liquid assets.

dYdX: Order book

Regardless of vAMM or Oracle-based pricing, these mechanisms are all designed for price discovery. For dYdX, the mechanism of price discovery is the order book. For those who are unfamiliar with the order book, it refers to the list of buy and sell orders sorted by price. Order books are predominantly used by centralized exchanges. On one hand, it can be attractive to provide liquidity to the order book due to no impermanent losses. On the other hand, it can be challenging to make a profit by providing liquidity to the order book, because it requires LPs to continuously quote the buying and selling orders to traders and accept the buying and selling requests of traders at this price, LPs profit from the bid-ask spread between buys and sells orders.

By introducing professional market makers to provide liquidity on the order book, dYdX has created a market experience that is close to centralized perpetual contract trading. But at the same time, retail investors lack the skill to provide liquidity to the order book, which negatively represents the mission of decentralization.

Phezzan Protocol: Order book with retail liquidity

Market making on order book is complex and can only be done by professional market makers. Phezzan Team wants to develop a series of permissionless automatic market maker strategies to enable retail liquidity. On Phezzan Protocol, retail LPs can earn more predictable profits than on AMMs and oracle-based DEXs. Retail LPs can also market make long-tail assets not available on oracle-based DEXs or other forms of order book DEXs.

At the time of writing, Phezzan Protocol has not yet launched the mainnet, so we won't go into too much detail. If you want to know how Phezzan is bringing retail liquidity to order book DEXs, here is a 10-minute reading.

Challenge

Decentralized perpetual contracts trading is still in its infancy, with less than 3% of the total value locked in DeFi as of September 1, 2022. In fact, bootstrapping liquidity is an issue faced by almost every emerging DeFi protocol, and a decentralized perpetual contract DEX is no exception. Even with liquidity mining incentives, it is challenging to cover losses for LPs. Also, there is still a long way to go before it can compete with major centralized exchanges that offer large trading volumes and up to 200x leverage.

Concluding Remarks

Congratulations on getting this far! Our journey of the perpetual contract in this book has come to an end. However, this is not the end, as there will always be something new to learn and new protocols to explore.

By now, you should have a better understanding of the perpetual contract and how it works. You should know that perpetual contracts are developing extremely fast and are very complex.

By the time we publish this book, some of the information may be out of date! Nonetheless, we hope How to Perpetua Contract: Beginner will be a central reference point on your perpetual contract journey.

Want to discuss the perpetual contracts more?

Follow @PhezzanProtocol on Twitter!

Special thanks to the Phezzan community members who helped the team review this book: Chesse, Iam Da Pone, Imran Shuaibu, Joao1dao, kacperrr0, stihac, Victoria Huang.

Extended Reading

  1. Perpetual Protocol https://support.perp.com/

Last updated