Be sure to deposit funds to make them available for trading.
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.
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.
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.
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.
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).
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:
When closing the position using the close button or closePosition contract call, PnL is calculated using the following formula:
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:
When calculating PnL this way, it is important to note
Unrealized PnL includes the price impact that would result from closing the position;
Slippage may change the result.
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.
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.
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.
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:
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).
baseAssetReserve are the x and y in the AMM formula. These values can be obtained for each vAMM on Perpetual Protocol using the
perp amm BTC will give you the values needed to calculate the price impact for BTC.
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.