How it Works

Trading

How PP Works

Step 1 Alice sends 100 USDT 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, level of leverage, and its direction.

Step 2~3 Upon receiving the 100 USDT, the Clearing House deposits the incoming 100 USDT to the Vault. After that, Perpetual Protocol updates our vAMM by the margin amount, position side, and the level 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.

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/USDT and 10,000 USDT in our vAMM as its initial state.

Action (Chronological)

ETH/USDT (x)

USDT (y)

*Calculation

Initial State

100

10,000

​

As mentioned before, the amount of ETH/USDT and USDT 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 Considering Alice uses 100 USDT as the margin to open a 2x leveraged long position, which means that the amount of USDT in our vAMMs will become 10,200 (10,000+100*2), the amount of ETH/USDT will become 98.0392156862745 (100*10,000/10,200), which is calculated by the constant-product curve, and the amount of ETH/USDT that Alices gets is 1.9607843137255 (100-98.0392156862745), which is recorded in the Clearing House.

Action (Chronological)

ETH/USDT (x)

USDT (y)

*Calculation

Initial State

100

10,000

​

Alice gets 1.96 long position

98.0392156862745*

10,200

100*10,000/10,200

Step 6~ Following Alice, Bob also uses 100 USDT as the margin to open a long position with 2x leverage. In return, he receives 1.8853695324283 long positions (98.0392156862745-96.1538461538461) from our vAMM with the price calculated by the constant-product curve.

Action (Chronological)

ETH/USDT (x)

USDT (y)

*Calculation

Initial State

100

10,000

​

Alice gets 1.96 long position

98.0392156862745*

10,200

100*10,000/10,200

Bob gets 1.89 long position

96.1538461538461*

10,400

98.0392156862745*10,200/10,400

After Bob gets his long position, Alice decides to close her position and realizes a profit of 7.84012298 USDT (10400 - 96.1538461538461*10,400/(96.1538461538461+1.9607843137255)- 200)

Action (Chronological)

ETH/USDT (x)

USDT (y)

*Calculation

Initial State

100

10,000

​

Alice gets 1.96 long position

98.0392156862745*

10,200

100*10,000/10,200

Bob gets 1.89 long position

96.1538461538461*

10,400

98.0392156862745*10,200/10,400

Alice closes her position

98.1146304675716

10192.15987701770*

96.1538461538461*10,400/98.1146304675716

Seeing Alice makes a profit, Bob wants to close his position too. But only to find out that he lost -7.84012298 USDT (10192.1598770177-98.1146304675716*10192.1598770177/ (98.1146304675716+1.8853695324283)-200) after closing his position.

Action (Chronological)

ETH/USDT (x)

USDT (y)

*Calculation

Initial State

100

10,000

​

Alice gets 1.96 long position

98.0392156862745*

10,200

100*10,000/10,200

Bob gets 1.89 long position

96.1538461538461*

10,400

98.0392156862745*10,200/10,400

Alice closes her position

98.1146304675716

10192.1598770177*

96.1538461538461*10,400/98.1146305

Bob closes his position

100

10,000*

98.1146304675716*10192.1598770177/100

So what can learn from the example above?

Unique Properties on 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 the result of traditional peer-to-peer futures trading.

  • No liquidity providers involved because we don't store real 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.

Hourly Funding Payment

Funding payment is the most common mechanism used by the perpetual Protocol swap exchanges to converge the mark price (the price on the exchange) and the index price (the average price from major exchanges).

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

fundingPayment=positionSizeβˆ—fundingRatefundingPayment = 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 hourly TWAP of the mark price, and secondly, dividing the result from the previous step by 24.

fundingRate=TWAPperpetualβˆ’TWAPindex24fundingRate = {TWAP_{perpetual} - TWAP_{index} \over 24}

We use the price feed from Chainlink as the data source for the index price because it's the most battle-tested Oracle solution on the market.

If the fundingRate is positive, long position holders need to pay the funding payment and the 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, which is similar to the conventional futures contract that expires once per day.

Sounds complicated? Let's take a look at an example.

Example

Similar to the example from the previous section, 100 ETH/USDT and 10,000 USDT are set as the initial state in our vAMM at launch. Both Alice and Bob use 100 USDT as the margin to open a long position 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 USDT.

Action (Chronological)

ETH/USDT (x)

USDT (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

10192.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 see 2 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 differently 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

Staking

PERP holders can lock-up, or "stake", the PERP in their possession for a fixed amount of time to the Staking Pool. In return, stakers are rewarded with the staking incentive, which includes staking rewards in PERP and a part of the transaction fees in USDT.

There are five things that stakers need to be aware of:

  • During a staking period, which is known as "an epoch" on Perpetual Protocol, stakers cannot withdraw their tokens from the Staking Pool. An epoch lasts for 7 days at the time of writing and can be adjusted through the governance process.

  • If stakers want to withdraw their staked PERP after the end of the current epoch, they must submit a transaction to unstake their tokens in the present epoch.

  • PERP holders can start staking their PERP tokens anytime during an epoch, but the staking incentives are time-weighted in each epoch. In other words, the earlier you join an epoch, the more staking incentive in this epoch you will receive proportionally.

  • Transaction fees are claimable right after the epoch, but staking rewards for that epoch are locked until the first day of the same month in the subsequent year.

  • By default, if a staker doesn't unstake their tokens in an epoch, their staked PERP will be rolled over to the next epoch.

Example

Step 1

Assuming the first epoch on Perpetual Protocol starts at 0:00 AM on 4/24/2020. Right after the first epoch starts, PERP token holder Bob stakes 100 PERP to the Staking Pool, and that amount accounts for 10% of the value stored inside it.

Even though anyone who holds PERP can stake their tokens during any given epoch, to make it easier for readers to understand, we assume there is no staker depositing PERP into Staking Pool after Bob.

Step 2

Throughout an epoch, 50% of the transaction fees will be deposited into the Insurance Fund, which is used as the first line of defense when the system faces unexpected losses such as losses in the liquidation process and funding payments. The other 50% will be deposited into the Transaction Fees Pool, which is used to reward stakers to back-up trading activities on Perpetual Protocol.

Should the Insurance Fund be depleted, the Insurance Fund will trigger PERP’s smart contract to mint new PERP and subsequently sell them for collateral in the Vault to ensure the system’s solvency.

Step 3

Assuming there are 1,000 USDT accumulated in the Transaction Fees Pool at the end of this epoch.

In light of Bob's 10% ownership of the Staking Pool, he is eligible to claim 10% of transaction fees generated in this epoch, which is 100 USDT.

Besides the transaction fees, Perpetual Protocol also provides staking rewards in PERP and issued from the Staking Reward Pool as an extra way to incentivize PERP holders to secure the network. If the total amount of staking rewards for this epoch is 10,000 PERP, then Bob is eligible for 1,000 PERP from that. However, it's not claimable until 4/1/2021.

​

​

​

​