Understand the working principle and characteristics of Perpetual Protocol, and learn how to use it to trade perpetual contracts.
Written by: Weiting Chen, Perpetual Protocol Growth Manager Translation: Nikkor
Perpetual contracts are the most traded derivatives in cryptocurrencies. They can generate billions of dollars in transactions every day.
They enable traders to leverage almost any asset to buy long or short positions, and now all platforms are dominated by perpetual contract trading of ETH and BTC.
If you are my long-term reader, then you know that we have discussed perpetual contracts many times in our articles on dYdX and MCDEX. But now, a new player has joined the group chat.
The Perpetual Protocol went live on the mainnet in December. What’s interesting is that they built the protocol on xDai, which enables a faster and more cost-effective transaction model (without paying a gas fee for transactions after asset migration) without sacrificing too much availability. It is safe to say that they succeeded. Since its inception less than two months, the agreement has resulted in nearly $1 billion in trading volume.
It can be said that quite good results have been achieved in just two months.
Perpetual agreements use the latest vAMM design to replace the order book model, which is similar to Uniswap. Although the perpetual agreement currently only supports a small number of assets, the flexibility of this design allows it to support any asset on Ethereum, as long as the asset can be fed through the oracle.
Various possibilities are brewing in this project. Worth a try!
The following is what you need to know about perpetual agreements and relevant knowledge about trading YFI contracts.
Before we enter today’s Tactic, we need to quickly review the perpetual contract and how it works:
A perpetual contract is a derivative product that allows you to speculate on asset prices and profit without having to hold actual assets. If the user wants the price of the underlying asset (marked price on the perpetual contract) to rise, he can open a long position with leverage; otherwise, he can open a short position.
Today, perpetual agreements are the most traded derivatives of cryptocurrencies, generating billions of dollars in trading volume every day.
In this article, we will first explain what Perpetual Protocol is, how it works, and gain insight into historical growth and how it differs from competitors.
Finally, we will guide you through how to trade YFI contracts with 0 gas fee in the perpetual agreement.
- Goal: understand how to trade YFI contracts on perpetual agreements
- Skills: Advanced
- Duration: less than 10min (if you use Metamask or Ledger hardware wallet)
- ROI: variable-depends on your trading level
What is Perpetual Protocol?
The perpetual agreement makes it possible for contract transactions on the chain with 0 gas fee. The agreement uses xDai to conduct fast, economical and efficient transactions, and uses automated market makers (vAMMs), so that transactions do not require counterparties and can open long or short positions with up to 10 times leverage.
What’s more exciting is that in the future, anyone can create and operate a perpetual market and get a certain amount of transaction fee reduction, similar to the LP on Uniswap.
How does perpetual agreement work?
As implied by the “virtual” part of vAMM, no actual assets are stored in vAMM-the protocol only uses vAMM as a price discovery tool, not token transactions.
Let us assume that Alice wants to use 100USDC as collateral to make 10 times more BTC. The first step she needs to deposit 100USDC (a smart contract that stores real assets) into the Vault
Next, the clearing center, the smart contract that manages user positions in the perpetual agreement, will mint virtual assets (or synthetic assets) and put them into vAMM. In return, this vAMM will calculate the user’s position based on a constant product curve. This price curve is the same as Uniswap.
In our example, since Alice opened a long position with 100USDC and 10 times leverage, the clearing center will mint a virtual position of 1000 vUSDC (if short is -1000vUSDC), and put them into vAMM.
The description of these steps (actually comparing AMM and vAMM) is to help you figure out the status of the margin after adding leverage.
Going back to the example, the current market price of BTC is 40000USDC. In the initial state, there are 10 virtual BTC and 400000 virtual USDC in vAMM.
Note: There are no real assets in vAMM. 10 vBTC and 400,000 vUSDC are just an initial state that is stored in vAMM to calculate the price of derivatives.
After Alice opens a position, he will receive a virtual position in vAMM whose price is determined by a constant product curve. Alice now has a position worth 0.025 BTC. (Reverse opening positions are negative positions)
You can check the price movement in different situations in this table , such as the state after other traders intervene, or check this document .
Price adjustment mechanism for perpetual contracts
After reading the above explanation, people will ask a common question, that is, what will happen if everyone just opens a long position on vAMM?
First of all, the key is to understand that perpetual contracts are derivatives trading tools, so the marked price of the contract is not necessarily the same as the spot price of the underlying asset.
This is why if everyone establishes a long position on vAMM (or perpetual contract), the price of derivatives will continue to rise, which provides an opportunity for arbitrageurs to open shorts to keep prices down.
Moreover, in order to further push the price of the perpetual contract (called the “marked price”) to the spot price of the underlying asset (the “index price”), derivatives exchanges usually use a mechanism called funding rate payment. Incentivize traders to push the mark price to the index price.
On perpetual agreements, the funding rate is paid every hour.
Back to our original question, if every trader opens a long position, assuming there is no arbitrageur and the spot price of the underlying asset remains the same, then the long position holder will pay the funding fee when paying the funding rate To vAMM, the funds will be transferred directly to the Insurance Fund (more on this later). On the other hand, if it is vAMM’s turn to pay the funding costs, it will be paid from the insurance fund.
What is the difference between perpetual agreements and other transactions?
With the vigorous development of DeFi, more and more platforms provide perpetual contract trading. In this section, I will focus on the main differences between perpetual agreements and other trading platforms.
Flexible liquidity adjustment mechanism
Due to the use of vAMM, the perpetual agreement can dynamically adjust the liquidity of vAMM (the “K” in the constant product curve), because there are no physical assets stored in vAMM. Remember: they are synthetic assets!
Now, K is manually set and adjusted by the protocol development team. In the future, one can imagine that with more open positions in the perpetual market, liquidity (K) will automatically increase.
This feature is also a key difference between perpetual agreements and other order book exchanges, which rely heavily on market makers to provide liquidity.
Full asset support
Any asset with an oracle feeding price-whether it comes from Chainlink, Band or Uniswap, a perpetual agreement can create a market for it. The agreement only requires one on-chain price input to calculate the capital cost. In addition, since there are no referential assets stored in vAMM, we don’t need actual BTC, gold or other assets to trade.
This feature makes the protocol very different from exchanges that rely on liquidity providers or other assets.
historical data
The perpetual agreement went live on December 14, 2020. Here are some statistics since going online:
The peak daily trading volume has exceeded 80 million U.S. dollars, and the average daily is over 20 million U.S. dollars. We believe that trading volume will continue to grow because 1) more trading pairs will be launched on the perpetual agreement, and 2) the perpetual agreement will support more order types (so far, mainstream exchanges only support market orders).
At present, we have launched a new trading pair on average a week through the governance process. About this part, you can check here .
Within one month after the agreement was launched, the cumulative transaction volume quickly reached 100 million US dollars. It has now exceeded 1.2 billion US dollars.
Although the price of BTC soared from US$19,000 to over US$40,000 (and then fell back to US$34,000), the settlement procedures of the agreement worked well. In a month and a half, we conducted 49 liquidations in the BTC market, of which only one caused a loss of 0.001 USDC to the system (the reason for the loss was that a user manually closed a position on a dust position). Therefore, we are considering increasing the maximum leverage as soon as possible, and the current upper limit is 16 times.
If you want more relevant information, you can check the Dash Board of Dune Analytics .
The role of PERP tokens
The native token of the perpetual agreement is (PERP). The token position system provides two key operating foundations:
Standby assets
There are two situations that may cause the agreement to lose money:
- Untimely liquidation: The liquidator failed to liquidate unsecured positions in a timely manner.
- Funding fee payment: When the perpetual market is unbalanced, vAMM needs to pay the funding fee.
When either of the above two situations occurs, the funds in the insurance fund will first be used to repay the loss (50% of the transaction costs go to the insurance fund). If the insurance fund runs out, the system will mint PERP and sell it on the market to repay the debt.
Cost & governance
Holders of PERP tokens can put their tokens in the agreement, and in return, they can get equity rewards (calculated in PERP) and part of the transaction fee reduction (calculated in USDC). In addition, the pledger can vote with the PERP pledged on the governance port to determine important decisions of the perpetual agreement, such as the new market to be listed or the transaction fee (%) to be charged.
How to trade YFI contracts on perpetual agreements
If you are interested in trading contracts on perpetual agreements, we can provide you with support. Let us learn how to trade YFI contracts in a few steps.
According to local regulations, users in certain jurisdictions (such as the United States) cannot access this agreement through our website. If you are one of them, you can use our testnet on Rinkeby to try to follow this guide (remember, switch the network settings on the wallet to Rinkeby testnet, and then click “Request USDT” to get test funds )
Step 1: Connect your wallet
Click on perp.exchange and connect to your wallet by clicking the “Connect” button in the upper right corner.
At the time of writing (February 2, 2021), the website only supports trading with Metamask and Ledger, but support for Trezor will be launched soon!
Step 2: Add USDC
Once the wallet is connected, the next thing to do is to add USDC to the balance on the protocol. You only need to click the “Deposit” button in the upper left corner to start the deposit process.
The deposit process is divided into the following 4 steps:
1. Confirm the deposit amount. There is no minimum deposit limit-you can deposit as much USDC as you need. In this tutorial, I will deposit 500 USDC.
2. Allow our smart contract to transfer your USDC on Ethereum. As mentioned earlier, since the entire agreement runs on the xDai chain, we need your permission to “migrate” your USDC. This is how the agreement operates in this step. Click the “Approve” button and submit the transaction.
You only need to approve the smart contract once.
3. Deposit USDC into the smart contract of the perpetual agreement (on Ethereum). After confirming the approval of the transaction, you need to deposit USDC into the smart contract on Ethereum so that we can start migrating to xDai.
Once your deposit transaction is confirmed on Ethereum (Layer1 in the figure above), it will migrate the deposited USDC to the xDai chain where the perpetual agreement is located (Layer2 in the figure above).
After this step, you don’t need to pay any gas fee-the perpetual agreement will pay you for these fees.
4. Approve our smart contract to transfer your USDC on xDai. So far, your USDC has been migrated to xDai. In the last step before the transaction, you need to approve our smart contracts on xDai so that they can use your USDC as margin.
After clicking the “Approve” button, you will receive a warning (“Welcome” logo) from Metamask, as shown below:
Be calm and don’t panic! Before you close the page, please let me explain what this warning is:
Whenever you want to use Metamask on other chains, you need to change the RPC settings on Metamask, which is an obstacle that is difficult to circumvent when using extended solutions.
To overcome this obstacle, we use meta transactions to send messages signed on behalf of the user (eth_sign and EIP-712) to the xDai chain. In this way, users can interact with our smart contract on a completely different chain without needing to understand the underlying mechanism. AggroTrader on Twitter explains it well here .
However, the disadvantage of this method is that when the application uses the eth_sign function, Metamask always displays a warning sign (that is, the warning sign mentioned above). However, since you only need to approve the USDC smart contract for perpetual agreement on xDai once, you will only see a warning once (we use the EIP712 signature method in other interactions on the platform).
Step 3: Open a long position
I hope the above explanation can make you understand and click the “Sign” button with confidence. However, now that xDAI is used, the more important thing is that we can start trading perpetual contracts.
Since we want to trade YFI contracts with this strategy, you need to click the drop-down menu in the upper left corner and select “YFI / USDC”.
When the market information is correctly displayed, you can open a long or short position to speculate on the price trend of YFI tokens. Here I choose to open a 0.1 YFI long position with 10 times leverage.
The agreement charges a 0.1% transaction fee for each transaction. Currently, 100% of these expenses are directly used for insurance funds. When the pledge is open, 50% of the transaction fee will be distributed as a pledge reward.
On perpetual agreements, the price of derivatives seen by traders is determined by the constant product curve (x * y = k) in vAMM. Therefore, the larger the position, the greater the slippage of your transaction amount (similar to Uniswap’s pricing mechanism).
After clicking the “Trade” button, you will see a message similar to the above picture in Metamask. To make this confirmation, we use meta transactions to send their transaction to xDai on behalf of the user, and then the transaction will be executed here.
Currently, we only support market orders, so once you sign a transaction on the wallet, your order will be executed immediately.
Note: Limit orders, stop loss orders and take profit orders are under development and will be launched within a few weeks after the publication of this article.
Step 4: Closing the position
Just click the “Close” button (and then sign the wallet), and you can close the entire position at any time.
If you only want to close a partial position, the only way now is to manually create an order of a certain position size opposite to your current position.
That’s all there is to it! You are already familiar with perpetual contracts, perpetual agreements, and learned how to trade YFI derivatives on Ethereum.