Managing Risk

Content Out of Date

This content is not maintained and refers to an out-of-date version of Perpetual Protocol.

For the latest documentation, see https://docs.perp.com

Leverage & Margin Ratio

Cross Margin

Perpetual Protocol v2 uses cross margining, so all your funds are in a pool that backs each position. It is useful to think of your funds as collateral which you use to take out a loan from the exchange. This loan is referred to as your position.

For example, assuming 1 ETH is $3000, if you put up 300 USDC of collateral, the exchange will let you open a position of up to 1 ETH—in this case you are borrowing $2700 worth of ETH.

This means you can use Perpetual Protocol to trade more funds than you own.

It also means that the exchange takes on risk of your position defaulting—see more in the section on liquidation penalties below.

Buying Power

When you deposit funds as collateral, the amount you can deploy as margin is called buying power. Currently, Perpetual Protocol allows up to 10x leverage, meaning your buying power is 10 times greater than the collateral you deposit.

For example, if you deposit 100 USDC, your buying power will be 1000 USD.

Warning

The more buying power you use, the higher the leverage. High leverage exposes you to risk of liquidation

Margin Ratio

tl;dr: margin ratio = account value / total position value

Margin ratio is the ratio of your position value and collateral value.

For example, if your long position of 1 ETH is worth $1000 and your collateral is worth $200, your margin ratio will be 20%.

Let's say the position's value increases to $3200 because the price of the ETH goes up. Your unrealized profit would then be $2200, bringing the total collateral to $2400. With the position value now equal to $3200, the margin ratio is found by dividing the collateral value by position value, which gives 75% (=$2400/$3200).

For a short position, when the price increases the unrealized losses decrease your total collateral but the position value also increases.

When shorting 1 ETH at $1000 using collateral worth $200, the margin ratio is 20%. If the price of ETH increases to $1100, the position value now becomes $1100 but the unrealized loss reduces the total collateral to $100. As a result, the margin ratio then falls and is now equal to 11%.

Maintenance Margin

You must maintain a margin ratio above 6.25% or risk liquidation. This is called "maintenance margin". Below 6.25% your position is considered at high risk of default, and will be proactively liquidated in order to protect the exchange.

Liquidation Penalties

Liquidators will target your largest position by USD value for liquidation. This position will be liquidated completely, with a portion of the underlying margin going to the liquidator as a reward, and the remainder going to the exchange insurance fund.

Increase/Decrease Leverage

To adjust your leverage, simply deposit or withdraw from the exchange.

  • Deposit funds to decrease leverage.

  • Withdraw funds to increase leverage.

Changes apply to all of your taker positions and maker orders.

Liquidation

Leveraged trading allows you to trade with more funds than you own. In essence, you are borrowing funds from the exchange. When your position's value reaches a critical point, it will be proactively liquidated to insure against a loss to the exchange.

Liquidation Trigger

Perpetual Protocol uses index price to evaluate liquidation conditions.

Maintenance margin: 6.25%

Liquidation is triggered when your position margin ratio is below 6.25%. Margin ratio is calculated using 7-minute TWAP of the index price.

Positions with a value of $100 or lower will be subject to full liquidation, unlike larger positions where partial liquidation is used.

Liquidation Price

Each position has an associated liquidation price. Note that this price depends on how much collateral you deposited, and the PnL of each position. Depositing, withdrawing, and funding payments all affect your collateral, and therefore affect liquidation price.

Cross-margin

The PnL of each position will affect the liquidation price of other positions. If the profit on one position increases, the liquidation price of all positions will decrease (longs) or increase (shorts).

Liquidation Penalty

Some or all of your margin will be taken as a liquidation penalty. Perpetual Protocol uses cross-collateral, so if you have multiple positions, liquidators can only attempt to liquidate one at a time, and will likely choose the biggest position so they can liquidate the maximum allowable amount.

The amount that is liquidated depends on a few factors.

  • Amount of margin available in the liquidator's account. Since they are taking on the liquidated position, they require margin to back it.

  • Competion with other liquidators. Liquidators may opt to only liquidate part of the position to increase their chances of success compared to trying to liquidate the entire position. If parts of the position are taken by other liquidators first and not enough remains, their transaction will revert. For example, if 1 ETH is available to liquidate, and the liquidator attempts to liquidate 100% of it, if another transaction liquidating 0.25 ETH is sent faster and succeeds, the 1 ETH transaction will fail. Therefore liquidators are encouraged to liquidate a smaller amount to increase the chance of success.

Calculating liquidation price

For accessing the values of various parameters, see Smart contract addresses

#long
liqPrice = indexPrice - ((accountValue - totalPositionValue * mmRatio) /  ((1 - mmRatio) * positionSizeOfTokenX))

#short
liqPrice = indexPrice - ((accountValue - totalPositionValue * mmRatio) /  ((1 + mmRatio) * positionSizeOfTokenX))

Note that totalPositionValueincludes both maker and taker positions.

There is also a helper contract function that returns getLiquidationPrice()

https://optimistic.etherscan.io/address/0xa18fa074a2A5B01E69a35771E709553af4676558#readContract

Example

Let's look at an example to illustrate how to calculate liquidation prices.

If the index price of ETH is $2,000 and you have $100 in collateral, then accountValue will be $100.

Let's say you open a position of 0.10 ETH, so that the totalPositionValue is equal to $200. The maintenance margin ratio is represented by mmRatio, which is equal to 6.25%. Finally, the positionSizeOfTokenX is the position size in terms of the base token, so for this example it will be +0.10.

Liquidation price = 2000 - ((100 - 200*0.0625) / ((1 - 0.0625)*0.10))

= 2000 - (100-12.5) / (0.9375*0.10)

= 2000 - (87.5)/(0.09375)

= 2000 - 933.3333

= 1066.6666

The 0.10 ETH long position with entry price of $2,000 and $100 in collateral will be liquidated once the index price reaches $1066.6666.

Now let's look at calculating the liquidation price for a short position with the same inputs as above. In this case positionSizeOfTokenX will be negative at -0.10.

Liquidation price = 2000 - ((100 - 200*0.0625) / ((1 + 0.0625)*-0.10))

= 2000 - (100 - 12.5) / (1.0625*-0.10)

= 2000 - (87.5) / (-0.10625)

= 2000 - (-823.5294)

= 2823.5294

The 0.10 ETH short position with entry price of $2,000 and $100 in collateral will be liquidated once the index price reaches $2823.5294.

Liquidators

Liquidations are performed by keeper bots which anyone can code and run.

These bots call the clearinghouse contract to trigger liquidations, and the clearinghouse determines whether a position meets the conditions for liquidations or not. Liquidators receive a bonus when successfully triggering a liquidation, paid from a portion of the collateral backing the liquidated position.

Further reading

Multi-collateral liquidation

Maker Liquidation

Cross-margin

Perpetual Protocol uses cross margin, which means your funds are kept in one pool and all of your positions use this pool as collateral. Learn more about margin.

This makes managing your collateral easier, since you don't need to add or remove margin for each position.

Risks

Using cross-margin, one position can affect your other positions. If you have several highly leveraged positions, one position being liquidated can cause others to be at risk and face possible liquidation as well.

Isolated Margin

If you want to use isolated margin, you will have to create separate wallets. If you plan to do this, it is fairly simple to achieve using MetaMask and (recommended) a hardware wallet. Use MetaMask to select different addresses from the hardware wallet, one for each of your isolated positions.

Position Health

An account's position health is shown to the right-hand side of the app's homepage by the colored lever and a message that indicates low, moderate or high risk for your position(s).

When the margin ratio is above 50%, the position health lever is green (indicating low risk of liquidation). If the margin ratio is between 6.25% and 50%, then the status is amber. Below 6.25% and the status is red.

As the margin ratio falls and the account leverage increases, the position health deteriorates, going from green to amber then to red once the account is nears liquidation.

Last updated