Perpetual Protocol
🖥️ Trading Interface FAQ
Learn more about the features and functions found on the Perpetual Protocol trading platform. Join our Discord for more discussion!

Why do I see an 'insufficient balance' error?

Be sure to deposit funds to make them available for trading.

Further explanation

Perpetual Protocol uses the xDai network for scaling. This means you must 'deposit' funds from your regular Ethereum wallet (eg. Metamask) to the xDai network. This process is performed entirely within your existing wallet without additional setup. Funds remain in your wallet and under your control at all times.

Why do the funding payments seem to be paid to the wrong side?

Funding payments follow the convention used on other exchanges like FTX and Binance: A negative number in your Position History indicates you received a funding payment, while a positive number in your Position History indicates you payed a funding payment.
The logic is that you make a payment; a positive payment means you end with less money; a negative payment means you end with more money.

How is the Index Price calculated?

The index price (also called 'Oracle price') generally refers to the price of the underlying asset on the spot market. Perpetual Protocol bases the index price on price feeds from Chainlink.
To mitigate frontrunning, we use the 1-hour TWAP (time weighted average price). This may result in the index price shown differing somewhat from the price you see on other major exchanges, especially when the market is volatile.
The price shown in the Perpetual Protocol trading interface is updated when a new price is received from Chainlink. Note, however, that the index price is only used when calculating hourly funding payments.
Timing of updates to the index price is determined by updates in the Chainlink price feed -- a surprisingly complex topic. Deep dive here. Keep in mind that Perpetual Protocol uses the 1-hour TWAP.

How is the Mark Price calculated?

The mark price is the current price for perpetual contracts of the asset you are viewing (ie. the price the AMM is at right now). Subsequent trades will move this price to a new level; without a trade happening, the price will not move.
It is normal for this price to diverge, sometimes dramatically, from the index price (the open market price referenced by Perpetual Protocol, aka spot price). The mark price is a general indicator of trading sentiment on Perpetual Protocol.
Mark price and the price of the last trade shown on will not be the same. This is because the price of the last trade is the average of the prices at which the order was filled, while the mark price is the current price on the AMM curve. A trade moves the price along the AMM curve from point A to point B, with the order filling as the price moves. The prices shown in trade history are the average of prices between points A and B.

How is the margin ratio calculated?

Margin ratio is calculated by adding your margin size and PnL for a given position, and then dividing by the position notional (position size multiplied by mark price).
marginRatio=(margin+unrealizedPnL∗)positionNotionalmargin Ratio = \frac{(margin + unrealizedPnL^*)}{positionNotional}
*PnL is calculated using one of two methods, causing the margin ratio to also have two potential values. Learn more here or see the next FAQ on PnL calculation.
Oracle Based Calculation During Severe Market Conditions
In order to combat flash crash risk, if the mark price diverges more than 10% from the index price (oracle price), margin ratio will be calculated using the oracle price.
This measure will greatly reduce the risk of liquidation during a flash crash where the price on Perpetual Protocol diverges severely from spot prices.

How is PnL calculated?

PnL or P&L (profit and loss) shows how much value your position has lost or gained. Until you close your position, these are unrealized profits or losses, and are not guaranteed.
PnL is calculated using the following formula:
Partial close / reverse position / unwind
When closing the position using the close button or closePosition contract call, PnL is calculated using the following formula:
PnL=(currentPrice1−entryPrice)∗positionSizePnL = (current Price^1 - entry Price) * position Size
  1. 1.
    currentPrice is one of two values (the value most favorable to the trader is chosen): 1. the current exit price as calculated by the vAMM, or 2. the 15 minute TWAP of the mark price. This is done to prevent an attacker from manipulating the price on the exchange and triggering liquidations.
When closing part of a position using a reverse trade, e.g. short 10 ETH to close half of a 20 ETH long position, PnL is calculated using the following formula:
PnL=positionClosedSizetotalPositionSize∗unrealizedPnLPnL = {positionClosedSize \over totalPositionSize} * unrealizedPnL
When calculating PnL this way, it is important to note
  1. 1.
    Unrealized PnL includes the price impact that would result from closing the position;
  2. 2.
    Slippage may change the result.
PnL=10 ETH50 ETH∗1,000 USDC=200 USDCPnL = {10\space \text{ETH} \over 50\space \text{ETH}} * 1,000\space \text{USDC} = 200\space \text{USDC}
Important PnL shown on includes the price impact of closing your postition. When you close your position, the vAMM price will move. This move is factored into the PnL shown on the UI.

What happens when I open a second position?

If you open a second position for a given asset, the new position will be combined with your existing (active) position. E.g. if you have a 1 ETH long position and open a 0.5 ETH short position, your active position will be updated to a 0.5 ETH long position. (Note that your margin will not change—instead, your leverage will be updated. You will need to use Margin Management to reduce or add to your margin).
Note that if you open a 100 ETH long and then a 100 ETH short, you will be left with a dust position due to rounding. Therefore it is best to simply close the position rather than taking an equal, opposite position.
If you want to open multiple positions for the same trading pair, we suggest creating a new account in Metamask, and connecting with this account to the trading platform.

How can I control slippage?

You can set a maximum slippage tolerance on the left side of the trading interface. The slippage tolerance applies when opening or closing a position.
The default is 0.5%, or you can also set your own tolerance. Setting slippage tolerance is especially useful in volatile or high volume market conditions on the Perpetual Protocol exchange, when large numbers/sizes of concurrent trades may result in significant slippage.

What is slippage vs price impact?

Both slippage and price impact are changes in price due to trades happening. Price impact is a predicted change in price; increasing price for longs, and decreasing price for shorts. Size of the price impact depends on the size of the trade.
Slippage is an unexpected change in the price which happens between the time a trader places an order and the time the order is filled. For example, if you place a trade at $10 but by the time the trade executes the price has moved to $11, you may no longer wish to place the order. This is where slippage control becomes essential.
Transaction price impact

How is price impact calculated?

Price impact is calculated using the same x*y=k formula used by Uniswap and many other AMM based exchanges. The price is based on the ratio of x to y. So if you buy x, you receive an amount of y, and in doing so the ratio (and therefore the price) of x and y changes. The more you buy, the greater this change will be. This is price impact.
Calculating price impact is a technical process. First, the formula:
priceImpact=(entryPricespotPrice)−1priceImpact = ({entryPrice \over spotPrice}) - 1
entryPrice=openNotionalpositionSizeentryPrice = {openNotional \over positionSize}
spotPrice=quoteAssetReservebaseAssetReservespotPrice = {quoteAssetReserve \over baseAssetReserve}
openNotional and positionSize are the value of the position you want to open in quote asset (USDC), and the size of the position in base asset, respectively (both are after leverage).
quoteAssetReserve and baseAssetReserve are the x and y in the AMM formula. These values can be obtained for each vAMM on Perpetual Protocol using the perp-cli tool.
GitHub - perpetual-protocol/perp-cli: CLI for Perpetual Protocol


The command perp amm BTC will give you the values needed to calculate the price impact for BTC.

What happens if margin reaches 0?

If PnL is high enough, in theory you can remove all margin from a position. In this case, the position will stay open as long as margin ratio is above the liquidation threshold.
If the position pays funding, a bad debt will occur, and you will have to add margin to pay for the debt before the position can be closed. Liquidation will not occur if there is a debt as long as the margin ratio is healthy.