Perp v2 Specs
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
Price Feeds
The index price and non-USDC collateral value are both calculated using Chainlink’s decentralized on-chain oracles. A set of independent node operators aggregate price data from many different sources to provide a reliable reference price for our perpetual futures markets.
All price feed contracts can be found here:
Metadata for production: https://metadata.perp.exchange/v2/optimism.json
Metadata for testnet: https://metadata.perp.exchange/v2/optimism-goerli.json
You can find more information about price feeds on Optimism here.
Index Price Source
The index prices for our markets are sourced from Chainlink’s oracle network to be used by Perpetual Protocol’s smart contracts.
To calculate the index prices for markets on Perp, a 7-minute time weighted-average price (TWAP) is applied. A trader’s account value, position value, PnL, and liquidation price are all determined by the index price.
Our oracle contract is open sourced and can be found here: https://github.com/perpetual-protocol/perp-oracle-contract.
Collateral Pricing Source
To accurately calculate the buying power for your account when using non-USDC collateral types, the collateral asset’s price is sourced from Chainlink’s oracles.
For example, when depositing non-USDC collateral types such as ETH or OP, their value is calculated using Chainlink’s ETH-USD or OP-USD price feed and then multiplied by the collateral weight.
Limits & Caps
Price Change Limit
A price change limit is enforced in order to prevent certain types of price manipulation. Please split orders into smaller chunks if you are building a large position.
Increasing a position: no limit
Reducing or closing a position:
250 ticks (roughly 2.5%) per
timestamp
(15 seconds)Notes
Since Q1 2022 Optimism uses internal timestamps, updated every 15 seconds.
Since the cap is per timestamp, the totality of trades during that timestamp count toward the limit. Therefore, the limit may appear to be less than 2.5%.
Deposit Caps
The exchange has global deposit caps for each collateral type.
USDC: 25 million
USDT: 500,000
ETH: 1,000
OP: 700,000
FRAX: 40,000
Above values are accurate as of June 28th, 2023. (Caps do not include leverage).
The caps serve two purposes. One is to limit the amount of funds that can be added in a short interval, which may be done during an attack. Second, non-USDC collateral types are limited by the liquidity of this asset on Optimism (e.g. Uniswap), which would be needed to perform liquidations.
All caps are updated as needed.
Position & Order Caps
You may see the following error if you have too many positions, or positions in too many markets:
Max number of market participation reached. (AB_MNE)
Orders number exceeds. (OB_ONE)
Position and order caps limit the amount of positions and maker orders you can have open at a given time. This ensures that the complexity of updating or closing your positions does not exceed the blockchain’s transaction size limit. (Each block has a limited on the amount of processing that can be done, and it is important to not exceed this limit or transactions will fail.)
Consider using multiple accounts if you need to open more positions or orders.
maxOrdersPerMarket
3
Max orders per market is the upper limit on how many different maker orders you can have in each market. For example, you can have liquidity in up to 3 different ranges on the ETH market.
maxMarketsPerAccount
5
Max markets per account is the upper limit on how many markets with open positions you can have simultaneously. For example, if you have positions open on ETH, CRV, BTC, AVAX and SOL, you could not open a new position in MATIC without first closing a position.
This applies to taker and maker positions.
Mark / Index Spread Limit for LPs
You will not be able to add liquidity when the spread between mark and index prices exceeds ±20%. Limit does not affect removing liquidity.
Insurance Fund
What is an Insurance Fund?
When the markets are highly volatile, it may be the case that liquidators are unable to liquidate positions before the value of some accounts go below zero. The insurance fund provides a safety net and maintains solvency by ensuring that profitable positions can be paid out in full and liquidated traders do not end up with bad debt.
A trader will only get liquidated when the margin ratio is below 6.25%. Based on the margin ratio of the trader, the insurance fund and liquidators are incentivized with a small fee for dealing with almost insolvent positions.
However, if the trader's remaining margin is insufficient to cover fees for insurance fund and liquidators, there is bad debt and assets are drawn from the insurance fund to fill the gap.
The insurance fund balance is shared across all markets on Perp v2, where 20% of the trading fees accrue to the insurance fund (passed via this governance vote). For successful collateral liquidations, a 5% fee is charged by the insurance fund.
How can I track the Insurance Fund balance for Perp v2?
You can track Perp v2’s insurance fund balance in real-time on Dune Analytics: https://dune.com/yenwen/perpetual-protocol_2
Insurance Fund Depletion
Causes
The insurance fund is designed to cover bad debt. Bad debt occurs when a position cannot be liquidated in time, and the position value falls below the value of the collateral backing it. This results in a debt, which typically must be covered by the insurance fund (the user can cover the debt if they deposit more funds into the exchange).
Normally, the insurance fund can easily handle these debts, and funds are replenished using trading fees.
A perpetual futures market (trading pair) that has become unstable or poses a risk to the health of the protocol may be shut down by the team or governance. A governance vote will be held to determine the final market close price so that all remaining positions can exit.
Complete Depletion
In the event one or more very large positions incur large debts, theoretically the insurance fund could be completely expended. If this happens, any associated markets may be closed as described above, and a governance process will begin to decide how any remaining debts should be settled. The governance process does not guarantee debt settlement.
Collateral Weights
To determine collateral parameters such as the collateral ratio and discount ratio, we have adopted the risk methodology used by Aave. By following this methodology, it means factors such as the token’s market capitalization, trading volume, volatility, and so on, are taken into account when considering new assets as collateral and monitoring the existing collateral types supported on Perp.
Weighting System
A weighting system is applied to different types of collateral that are supported by Perp, shown by the table below:
Collateral type | Weight |
USDC | 100% |
USDT | 100% |
ETH / WETH | 82.5% |
FRAX | 75% |
OP | 45% |
Learn more about multi-collateral.
Examples
Trader deposits 1,000 USDC.
Total collateral = 1,000 USDC
Trader deposits 1 ETH (when ETH price is 1,500 USDC).
Total collateral = 0.825 x 1,500 USDC = 1,237.5 USDC
Trader deposits 1,000 FRAX.
Total collateral = 0.75 x 1,000 USDC = 750 USDC.
Trader deposits 500 USDC, 1 ETH (when ETH price is 1,500 USDC), and 500 FRAX.
Total collateral = 500 USDC + (0.825 x 1,500 USDC) + (0.75 x 500 USDC) = 500 USDC + 1,237.5 USDC + 375 USDC = 2,112.5 USDC.
Collateral Caps
Caps on deposits for non-USDC collateral types are enforced as a safety measure. The cap amount depends on liquidity on the Optimism network for each of the supported assets, so we can safely liquidate collateral when necessary.
Deposit caps can be seen on the homepage of app.perp.com.
Last updated