Introducing mark price, an important upgrade improving the fairness and stability of trading on Perp, as well as reducing the risk of price manipulation and the likelihood of bad debt.
Perp utilizes the Index Time-weighted Average Price (TWAP) to determine margin requirements and liquidation processes in order to prevent unnecessary liquidations caused by price manipulation. However, this approach also poses a risk to the protocol.
Frequently, the Index TWAP is unable to promptly capture the current market conditions. In particular, when there are swift changes in the market, the market price may diverge from the Index TWAP.
If the market price and the Index TWAP exhibit a significant discrepancy, the following outcomes may occur:
The inability to instantly liquidate the accounts of traders, both takers and makers, who may be close to bankruptcy.
The lack or excess of incentives for liquidators. This is because Perp utilizes the Index TWAP as the closing price for liquidation, which may result in liquidators having insufficient motivation to liquidate positions or being overly incentivized to do so. This could lead to losses that the system would need to compensate for. When liquidating a short position for example, if the index price is higher than the market price, this will give liquidators a huge incentive to liquidate a position and vice versa.
These issues may lead to delayed liquidations of trader accounts and might discourage liquidators from taking over positions, which could result in increased losses and risk of bad debt for the protocol. To reduce potential risks, we have introduced the Mark Price, which provides an accurate and fair reference price for margin requirement calculation and liquidations.
Mark Price = Median of [Price 1, Price 2, Perpetual Contract Price]
Price 1 = Market TWAP (30-minute Basis)
Price 2 = Index Price + Premium (15-minute Basis)*
Previously, we referred to the perpetual contract price as the mark price when computing the funding rate. To prevent confusion regarding naming conventions, we have introduced a new function called getSqrtMarketTwapX96
within the Exchange
contract (link). As a result, we intend to phase out the prior function, getSqrtMarkTwapX96
, in a future release.
Original (to be deprecated):
function getSqrtMarkTwapX96(address baseToken, uint32 twapInterval) external view returns (uint160 sqrtMarkTwapX96);
Added:
function getSqrtMarketTwapX96(address baseToken, uint32 twapInterval) external view returns (uint160 sqrtMarketTwapX96);
We have included a new function in the AccountBalance
contract (link) called getMarkPrice
, which allows for the retrieval of the current mark price for each market.
function getMarkPrice(address baseToken) external view returns (uint256);
PositionValue
will be changed to be calculated based on Mark Price instead of Index TWAP.
UnrealizedPnL
, MarginRequirement
, AccountValue
and FreeCollateral
also change due to the adjusted calculation method for position values.
Price for liquidation: use Mark Price to liquidate positions instead of Index TWAP.
In conclusion, the introduction of the Mark Price is an important upgrade that will help improve the fairness and stability of perpetual contract trading on our platform. These design changes make trading more accessible and user-friendly for traders of all levels, while still maintaining the high standards of reliability and security that Perp is known for.
By providing a more accurate and reliable reference price for the settlement of perpetual contracts, the Mark Price will help reduce the risk of price manipulation as well as the likelihood of bad debts and liquidations.
Finally, we want to remind users that since the calculation of margin requirements will change, please make sure your account leverage is at a healthy level (i.e., a margin ratio well above 10%) before the contract upgrade, which is scheduled to take place on March 14th. Please watch the announcement channels in our Discord for the latest updates.