Perpetual Protocol 🥨

Posted on Jan 26, 2023Read on Mirror.xyz

Setting Up For Long-term Success: Perp's Path Forward

We have some exciting things planned for 2023! This article outlines our thoughts on the protocol’s future development for the next two quarters and our current thinking about what the future has in store for Perp.

However, it should be emphasized that this piece does not represent a strict roadmap.

The ideas and directions detailed here are an indication of Perp’s path forward, but can potentially change. In our view, it’s beneficial to be nimble, to experiment with new ideas to see what works and be agile enough to double down on these goals and execute them. Taking this approach means that we can rapidly ship new features or products, while also giving the team a chance to address and overcome new challenges as they arise.

For a recap of our progress during 2022, check out the post below:

https://perpprotocol.mirror.xyz/XYMR5vHqQWfv9SaY8aoBWsIm0InONskn-tEm33_wglg

Horizontal Expansion: Delta Neutral Vaults

As a leading on-chain perpetual swaps DEX, we want to achieve broader adoption by introducing a variety of different products to appeal to a wider audience, especially those that are more interested in passive investing.

New products generate additional revenue streams, but there’s also an opportunity to benefit the core product: the DEX. To boost liquidity, and at the same time, attract retail investors seeking a low-risk yield, several delta-neutral vault designs are being researched and tested.

Vaults have proven to be a popular crypto-related product and are much simpler than trading perpetuals. Users that prefer passive investing and simply want to earn a low-risk yield can just ‘set and forget’: they just deposit their funds and then come back to the vault from time to time to harvest the returns.

One example of such a vault would run an arbitrage strategy between perpetual and spot markets for ETH-USD, giving depositors the chance to earn some of the profits and also choose whether they want to earn yield in ETH or USDC.

We expect the first delta neutral vault to launch in Q1 2023. One of our main points of focus in the months ahead will be successfully launching several types of vaults (delta neutral as well as others), expanding them to different pairs and then scaling these products. Some other separate products geared towards retail investors are also being considered.

The success of these vaults will bring more volume to Perp, generating more fees and setting off a snowball effect where it becomes more attractive for LPs to market make, depending liquidity even further and benefitting traders that want to trade larger positions. Greater fee revenue also translates into higher yields for vePERP holders! But we won’t share any specifics of these as we don’t want to leak too much alpha just yet!

New Collateral Types, New Markets

As more liquidity finds its way to Optimism, this will open up opportunities to add more collateral types to be used by our traders. The next asset we’re assessing to add as a new collateral type is wrapped staked ETH (wstETH), which would allow you to earn yield while simultaneously taking directional trades or earning fees from providing liquidity as a maker.

New markets are also on the horizon! The Token Listing DAO is currently eyeing two new assets: GMX and OP.

Improving Resilience and Security

Perp weathered the LUNA death spiral well and managed to shut down the market in an orderly way without any adverse impact on traders. We also implemented some other improvements to secure the protocol against extreme market conditions, such as position transferring liquidations and a soft circuit breaker for the insurance fund.

Instead of market selling liquidated positions, they are transferred to liquidators at index price to reduce the likelihood of liquidation cascades. A soft circuit breaker was put into place to enhance the security measures in place to protect users’ funds and improve our resilience against insolvency in the event of an exploit or extreme market conditions.

We’re also very thankful to the various whitehats for their discoveries of unknown bugs or exploits, which have helped make the protocol more robust. We paid out five bounties in partnership with Immunefi in the past year:

  • A bad debt attack was identified and to address the issue, we added a maximum price spread check whenever liquidity is added to reduce the effectiveness of such an attack.

  • Incorrect accounting in the liquidation process led to exploitable bad debt. This issue was fixed by introducing position transferring liquidations, since an attacker cannot manipulate the exit price of a liquidated position and positions are transferred to liquidators based on the index price.

  • A whitehat discovered that the liquidity mining initiative (Pool Party) could be abused through wash trading. Since Pool Party rewards were previously based on the volume facilitated by makers, an attacker could siphon the rewards by wash trading. A new formula was applied to account for the duration of time a liquidity position is open and in range to calculate the Pool Party rewards in a fairer way.

  • Bad debt attacks that exploited closeposition() in the clearinghouse contract were discovered. The issue was patched with a hot fix and further work is being done to determine if the attack is reproducible after the contract is modified in the future.

  • Finally, one bug was discovered and addressed that was low severity where the contract failed to return the correct input but no value was at risk: a missing maker check of order ID which maximized the liquidation fee.

Security is our number one priority and we will dedicate the bulk of the team’s efforts in the upcoming two quarters to strengthening the protocol. The list below details the key challenges we are reflecting on and how we will overcome these:

Fallback Oracle Using the Uniswap v3 Pool’s Time-Weighted Average Price (TWAP)

Any protocol is only as strong as its weakest link. Having a fallback oracle in place means there’s no longer a critical dependence on Chainlink’s price feeds, which are controlled by a 4-of-9 multi-sig and have the potential to be manipulated.

If a market’s Chainlink price feed experiences downtime or bad data is submitted, then the index price on Perp will switch to the fallback oracle after a certain period of time to try prevent any adverse impact on traders’ positions or forced liquidations.

Replacing the TWAP Oracle Price with Fair Price for Liquidations

The index price derived from the TWAP of an oracle’s price feed is currently in use for liquidations, since it’s more difficult to manipulate compared to a situation where an oracle just relays the last price.

However, the drawback of this approach is that a TWAP may not be responsive enough to market conditions. If it’s too unresponsive, then some positions will not be liquidated when they should be. Also, liquidators will have no incentive under certain conditions to take over positions if there’s a significant difference between the index price and the market price (for example if market price exceeds index price, then there’ll be a greater incentive to liquidate a long position but reduces the incentive to liquidate of short positions).

To avoid these issues, we plan to make liquidations based on a fair price (instead of a TWAP) which is calculated as the median of the following three variables:

  1. current index price plus a 15-minute time-weighted premium (where premium is the difference in the market and index prices),

  2. the TWAP of the market price over 30 minutes,

  3. and the current market price.

Improving the Accuracy of the Funding Rate

Work is being done to improve the funding rate mechanism to keep mark and index prices more closely in line with each other. With a tighter link between mark and index prices, this means takers and makers are less likely to experience unfavorable funding rates, and liquidators will always be incentivized to take over positions. Some of this work includes backtesting several funding rate and mark price mechanisms to find one that’s optimal to implement.

Admin Key Time-lock

A time-lock forces a delay for any contract upgrades to give our community time to examine the transaction and see the upcoming changes to the protocol before being put into place. Currently, contracts are upgraded by an admin key that follows a multi-signature scheme (more details here) and rotates between engineering team members every week.

The benefit of adding a time-lock is that it provides more transparency and improves security by eliminating the possibility that the protocol developers may collude to introduce changes that could drain user’s funds.

One positive side effect of focusing on security is that it opens up the possibility of increasing the maximum leverage parameter. More time and resources are required to figure out how leverage can be lifted without compromising security. After we’re sure it’s safe enough to do, the team plans to increase this parameter incrementally, first to 15x from 10x, and then observe how usage is affected.

We Want to Hear From You

One last note: we’d also like to emphasize that the opinions of our communities of builders, makers and traders are very important to the foundation team. If you have any ideas or suggestions that can improve the protocol, we’d love to hear from you!

Our vision for the future of the DEX is to be managed by the community, for the benefit of the community. But while the protocol is still under the stewardship of the Perp foundation, you can offer your input through our Discord server or post your ideas in the governance forum.

Get the latest updates by following our social channels listed below!

Links