dYdX and Perpetual Swaps

Stanley He
MetaWeb.VC
Published in
11 min readOct 24, 2021

After basic DeFi legos like DEX, lending protocol, and stableswap reach maturity, together with the blockchain scaling efforts generating real utility, the derivative market, whose size is supposed to be 10x or 100x of the spot market, is rapidly developing on-chain. Perpetual swap (perp), a type of derivative product that is mostly seen in crypto market, is among the first derivatives that’s been moved on-chain. dYdX v2 has been the most eye-catching perpetual swap protocol since the recent token launch. We will study dYdX’s solution to decentralize perps, and evaluate other mechanisms.

Perpetual swap (perp) basics

Perpetual swap, or perpetual future / perpetual contract, is a financial product that enables traders to access leveraged exposure to certain asset prices without owning any of the underlying assets. The concept of perps has existed before cryptocurrencies even emerged, but it hasn’t received much attention until being introduced to the crypto world by BitMEX in 2016.

Perps are essentially imaginary assets. One bitcoin perp is one imaginary bitcoin. You can create as many imaginary bitcoins you can but they are non-redeemable. Suppose two people, Alice and Bob, want to long (buy) and short (borrow) one bitcoin respectively, but they have no money — Alice doesn’t have money to buy one bitcoin, and Bob doesn’t have one bitcoin to borrow and then sell. What they choose to do is that they “trade” one perp between each other: Alice lends Bob one imaginary bitcoin, in exchange for the imaginary market price for bitcoin — let’s say, $50K — from Bob. Both are imaginary and they cancel each other out, so neither Alice or Bob need to pay anything. One day later, the price of bitcoin (and also imaginary bitcoin) rose to $55K. Now Bob owes Alice $5K ($55K — $50K). He has to pay Alice $5K to make them back to even.

In reality, three metrics define the simplest perp: index price, mark price, and funding rate. Index price is the market price of the underlying asset. Mark price is the current price of the corresponding perp. In the previous example, the index price of bitcoin already rose to $55K, but what about the imaginary bitcoin (mark price)? Exchange platforms that create perps deploy funding rates as the mechanism to make the gap between index price and mark price converge. When the index price and the mark price diverge, the system transfers a funding fee between those who are long the perp (in our case, Alice) and those who are short the perp (Bob). In our example perp, the funding fee paid by the longs to the shorts is $(mark price — index price) per contract per day. When this number is negative, the shorts pay the longs. Therefore, if Bob cannot immediately pay Alice $5K to make them back to even (mark price and index price converge), he has to pay the funding fee to Alice during this period. In centralized exchanges, funding fees are usually paid every 8 hours.

Traders must also put down collateral, known as margin. When the mark price moves against the trader, the resulting losses are deducted from this margin. If the margin balance gets too low, the trader will be liquidated, meaning their position is automatically closed out. Margin trading in perps often allows high leverage: one can get 100x leverage or higher on centralized exchanges like Binance and FTX.

Due to the fact that perps trading is free from underlying asset limits and allows high leverage, it forms a much bigger and more lucrative market than spot trading — for Binance, at press time perps trading volume is 3 times higher than spot.

dYdX

Before dYdX, the biggest player in decentralized perps was Perpetual Protocol. However, we can see that dYdX perps really disturbed the market after it launched trading incentives in late August. The market grew exponentially since then, with dYdX becoming the industry market leader. We will evaluate its technological solutions, pricing mechanisms, and tokenomics which is behind the mad rally of the platform.

Decentralized Perpetual Swaps trading volume YTD. Source: The Block

Validium

dYdX utilizes StarkWare’s StarkEx, a scalability engine based on zero-knowledge proof algorithms which is also used by DeversiFi, a decentralized exchange. StarkEx is a validum rather than a zkRollup, which means while validity proofs are generated for transactions (which is the “zk” part), those proofs aren’t posted on Ethereum L1. The matrix below gives a straightforward comparison between L2 solutions, and we can see where Validium is at. The advantage of Validium is that, gas fee can be infinitely close to zero (dYdX is gas-free) since there is little interaction between Validium and Ethreuem except for transferring capital between each other. The risk of Validium is that data availability is not guaranteed, and technically it does NOT share Ethereum’s security, unlike zkRollup where transaction validity proofs are posted on Ethereum.

For dYdX this is a necessary trade-off. In order to achieve the same UX like CEX (instant transaction confirmation, 0 network fee, etc.), Validium must be selected over zkRollup in the current stage.

L2 matrix. Source: Buildblockchain.tech

Pricing mechanism

The most significant advantage StarkEx has brought to dYdX is high TPS, which enables dYdX to duplicate the order-book-based CEX model for perpetual swaps, where big market makers provide liquidity and maintain an order book, and funding fees are transferred between traders to move mark price towards index price. In a word, dYdX manages to decentralize CEX perps without changing the underlying mechanisms.

The only salient difference between dYdX and CEXs is that dYdX only offers as high as 25x leverage for ETH and BTC perps trading, while CEXs generally provide 100x or higher leverage. This could be due to two factors: first, higher leverage means more frequent liquidation, which translates to higher pressure on network capacity. StarkEx is a tested solution, but centralized servers still have advantage on this front. The second factor could be insurance fund. When leverage is high, it’s possible that a position’s net value drops below zero before it could get liquidated. In this case, an insurance fund is involved, which liquidates the negative-value position, ensuring systematic solvency. CEXs have insurance funds, so does dYdX. But the current size of the dYdX insurance fund is limited, plus it’s controlled by the dYdX team, which means it can’t afford to buy out too many insolvent positions.

Tokenomics

What really set dYdX to fly is not its fundamentals, though they look good, but instead its tokenomics and associated trading rewards. The total supply of its governance token, DYDX, is 1 billion, of which 50% will be used to incentivize community involvement. Note that DYDX holders do not share trading fees on dYdX, which currently all goes to the team. Therefore the only utility of DYDX is voting. The allocation of the 50.00% (500,000,000 DYDX) to the community is as follows:

  • 25.00% (250,000,000 DYDX) to users who trade on the dYdX Layer 2 Protocol based on a combination of fees paid and open interest (Trading Rewards)
  • 7.50% (75,000,000 DYDX) to past users who complete certain trading milestones on the dYdX Layer 2 Protocol (Retroactive Mining Rewards)
  • 7.50% (75,000,000 DYDX) to liquidity providers based on a formula rewarding a combination of uptime, two-sided depth, bid-ask spreads, and the number of markets supported (Liquidity Provider Rewards)
  • 5.00% (50,000,000 DYDX) to a community treasury (Treasury)
  • 2.50% (25,000,000 DYDX) to users staking USDC to a liquidity staking pool (Liquidity Module)
  • 2.50% (25,000,000 DYDX) to users staking DYDX to a safety staking pool (Safety Module)

Both trading rewards and retroactive mining rewards are aimed for boosting trading volume on the platform. Past users of dYdX had to reach “milestones” on dYdX L2, which are tiers of trading volumes — the higher trading volume you incur, the more DYDX you would be granted. The retroactive mining rewards have ended before August. Then we have the trading rewards, which will be there for 5 years. During this period, all traders will be rewarded with DYDX. The exact mechanism is as follows:

DYDX will be distributed to traders based on a formula that rewards a combination of fees paid and open interest on the dYdX Layer 2 Protocol. DYDX will be distributed on a 28-day epoch basis over five years and is not subject to any vesting or lockups. 3,835,616 DYDX will be distributed per epoch.

The Cobb-Douglas function is used to compute how much DYDX is awarded to each trader during each epoch:

We see that trading fees generated are disproportionately favored over average open interest, meaning that trading volume is dYdX’s main goal, and it has made it. People open new accounts on dYdX as many as possible (because of diminishing returns stipulated by Cobb-Douglas function) and optimize their funds, “water-trading” to generate more fees, and maximize DYDX return.

Another interesting part is liquidity provider rewards — unlike the LP rewards we are familiar with, here it actually rewards market makers. Only makers that have achieved a minimum of 5% of maker volume on the dYdX Layer 2 Protocol in the prior epoch are eligible to receive DYDX as rewards in a given epoch. A proposal to lower the threshold to 1% is likely to pass.

Competitors

In some way, dYdX can be compared to Serum, the order-book-based DEX on Solana. They both use high TPS blockchain technology, while duplicating centralized exchange models. Both are highly dependent on big market makers: Wintermute, Amber, Kronos, Alameda, just to name a few. Market makers bring depth and seamless trading experience for end users, but also make the projects less decentralized and less crypto-native. Here we take a look at the other two decentralized perps mechanisms that don’t rely on order books or market makers.

Perpetual Protocol

Perpetual Protocol, the market leader before dYdX, uses a different pricing mechanism for perps. In dYdX, the mark price is generated from the order book; in Perpetual Protocol, there is no order book, and the market price is discovered from a virtual AMM (vAMM). A vAMM pool contains virtual assets, i.e., vDAI and vETH, and is ruled by x*y=k formula. The initial k is defined by the pool operator and can be changed arbitrarily. Buying a perp works as follows:

Alice deposits 100 DAI to Perpetual Protocol’s Vault (which is independent from the vAMM) and goes 10x long ETH. The protocol therefore “mints” 1000 vDAI and uses them to swap for vETH in the vAMM and credits them to Alice. Alice now holds vETH that is worth 1000 DAI. Note that vTokens are not real tokens in Perpetual Protocol V1, so “minting” is also a virtual concept.

Perpetual Protocol also uses funding rate to drive the mark price towards index price.

AMM has been the go-to option for order-book-less price discovery, and Perpetual Protocol manages to reflect leveraged trading through vAMM. The problem with Perpetual Protocol V1 is that the value of k is hard to determine: if k is low, slippage will be too high for organic traders; if k is set too high, then arbitrageurs will need a huge capital to move the price. With this in mind, Perpetual Protocol will launch its V2 called “Curie”. V1 lives on xDai, while Curie will be deployed on Arbitrum.

Curie

The biggest innovation in Curie is that the vAMM is “actualized” and integrated with Uniswap V3. vTokens are minted as real tokens, either by traders or liquidity providers, and used to form swap pools on Uniswap V3. The incentive behind Curie is straightforward: k value used to be hard to determine, now it can be set by the market; large trades face high slippage in a constant-product AMM, now Uniswap V3 provides concentrated liquidity to lower slippage.

A potential problem with Curie is that the actualization of vAMM introduces liquidity providers (aka pooled market makers) to the system who will decide the k value. Whether this will enhance or worsen the UX is still unknown, considering Curie may not be able to attract enough LPs at the initial stage which translates into high slippage. Nonetheless, the obverse side of it is the LP mining incentive for individual users and decentralization of market making (yes, the magic phrase “liquidity mining”), which could get Curie more clout considering dYdX is dominated by big market makers and individual users can only stake their USDC for big MMs to use.

GMX

GMX is a perpetual and spot exchange deployed on Arbitrum. It has a forerunner Gambit, which is on BSC. GMX utilizes a third mechanism for perpetual trading, which we call the “pooled counterparty” model. GMX allows users to purchase GLP tokens with tradable assets of the platform, such as ETH, USDC, LINK, etc., and become the counterparty of all trades on the platform. The gap between mark price and index price is eliminated at the beginning, since all perpetuals are purchased (or sold) for market price of underlying assets fetched by oracles.

The pooled counterparty model of GMX has eliminated half of the utility of funding rate. Remember a funding rate is used to drive mark price toward index price, which in GMX’s case, are always the same. An expected outcome from the lack of funding rate is that GMX will run without arbitrage activities, which is supposed to constitute a substantial part of the transactional volume of other perpetual exchanges.

The other half of the utility of funding rate is to control the net position of market makers. Imagine in a perpetual market where most traders are long ETH, the market makers will have to short a great amount of ETH, exposing themselves to the downside risk of ETH. In this case, the mark price would go up and pass the index price, making the longs to pay the shorts, as a way both to reduce the net short position of market makers, and to compensate for the risk they are taking. For GMX, however, since there is no funding rate, the pooled counterparty (GLP holders) is almost constantly exposed to a large net position (as for now, GLP holders are net short $14M ETH). This could be mitigated by collecting a different kind of “funding rate”, which directly links to net position of market makers (see Deri Finance example).

The biggest advantage of the pooled counterparty model is slippage-free perpetual trading. In AMM-based models, slippage is ever-present; and since markets are isolated from each other, so are the AMM pools, resulting in siloed liquidity, thus even higher slippage for long-tail markets. In GMX, liquidity is unified for all markets, and GLP holders become counterparties of all traders.

Outlook

dYdX is the market leader for now. But with the further development of the decentralized derivatives market, it’s unlikely to win every niche market. The order book model can satisfy traditional traders, but the accompanying binding with big market markers doesn’t quite suit DeFi degen’s taste. The pooled counterparty model largely solves the liquidity problem and the long-tail asset problem, but the net position management still needs improvement. A competitive advantage of the AMM model used by Curie is that it allows leveraged liquidity provision, just like leveraged trading.

Useful links

The cartoon guide to perps: https://www.paradigm.xyz/2021/03/the-cartoon-guide-to-perps/

Everlasting options: https://www.paradigm.xyz/2021/05/everlasting-options/

Perpetual swaps scan: https://mp.weixin.qq.com/s/NthZSf7XpztNvfNoYoqueA

dYdX token documents: https://docs.dydx.community/dydx-governance/

dYdX FAQs: https://help.dydx.exchange/en/collections/2721747-perpetuals-on-l2

dYdX reduce market maker incentive discussion: https://forums.dydx.community/proposal/discussion/1805-reduce-market-maker-incentives

Perpetual Protocol litepaper: https://docs.perp.fi/library/litepaper

Perpetual Protocol V2 “Curie”: https://medium.com/perpetual-protocol/introducing-perpetual-protocol-v2-curie-730d3e9aa609

--

--