Introduction and Opportunity
In the last issue of DeFi Digest, we dove into decentralized options, a ‘Zero-to-One’ primitive that can onboard the next wave of DeFi users. Perhaps long overdue, this week we dive into decentralized perpetual futures, an instrument native to the digital asset space.
A regular futures contract is simply a contractual legal agreement to buy or sell an asset at a predetermined price at a specified time in the future. Futures contracts are highly standardized and can be purchased via various futures exchanges. In contrast to options, futures contracts buyers and sellers are obligated to deliver underlying assets at the future expiration date. Additionally, futures contracts allow investors to gain different levels of leveraged exposure to the underlying asset.
Perpetual futures are a type of contract in which there is no specific expiration date. A buyer can hold contracts in perpetuity until they determine the best time to sell. The perpetual future was introduced in 1992 by Robert Shiller to provide derivative markets for illiquid assets. However, the derivative did not gain a lot of popularity until 2016 when BitMEX, the crypto exchange founded by Arthur Hayes, Ben Delo, and Samuel Reed introduced the first perpetual contract for crypto assets.
Since then, perpetual futures have seen massive adoption across the crypto industry and are easily accessible via both centralized and decentralized crypto exchanges, as illustrated by growing open interest across both Bitcoin and Ethereum perpetual contracts.
Although the crypto perpetual futures market has seen less penetration on a relative basis compared to that of the equity futures market, perpetual futures volume already exceeds that of spot volume for both Bitcoin and Ethereum. With that said, on-chain derivatives are still a nascent product and will likely catch up to that of the equity futures market. Perpetual futures’ crypto native origin story, easy-to-understand mechanics, and the addition of new trading pairs are all potential catalysts for increased popularity going forward.
Centralized exchanges have historically been the primary choice for perpetual futures traders given the convenience of integrated on/off-ramps and deeper liquidity. However, following the FTX collapse, there has been an uptick in users moving their assets off of centralized exchanges and finding self-custodial decentralized trading platforms. Increased users and trading volume has driven revenue growth for decentralized perpetual futures exchanges. Notably, dYdX and GMX are both in the top 5 protocols by cumulative revenue over the last 90 days.
To reiterate, perpetual futures are different from traditional futures contracts in that they have no fixed expiration date. Perpetual futures offer users the ability to leverage their positions anywhere from 1x to as high as 150x on some exchanges. To open a position, a trader must deposit what is known as the initial margin. This is the minimum amount a trader needs to open a position and the maintenance margin requirement varies depending on the exchange and funding amounts.
The simplest form of a perpetual futures contract is what is known as a linear contract. The name is derived from the manner in which gains and losses accrue – linearly. Let’s take the example where a trader wants to open a 10x long on Ethereum. The trader has $1,000 initial margin to deposit and open the position. For this example, let’s assume that 1 ETH = $1,000 at the time of opening, so the trader has a notional position of 10 ETH or $10,000. Below is a table representing the potential gains or losses for different prices of ETH.
For a 10x levered position, a trader’s profit or loss will move ten times as much for a given move in the underlying asset. Therefore, if ETH drops by 10% in this scenario, the trader will be liquidated, or have their deposited collateral sold to pay back creditors.
Liquidations can occur due to violent price swings or if traders use high leverage. In some instances rapid price movements blow the contracts price past a trader’s liquidation price prior to the exchange’s liquidation engine closing the trader’s position. When this occurs, the trader’s position is closed with negative equity. On a large enough scale this is similar to OKX socializing over $400m in a whale’s long losses proportionately amongst shorters in profit in 2018.
A trader using a traditional securities broker would likely get chased down to pay down their negative equity. In the case of perpetual futures exchanges, many have implemented an insurance fund that will cover the potential negative equity losses. Additionally, exchanges have implemented a risk management mechanism known as auto-deleveraging (ADL). ADL automatically closes a portion of profitable positions to cover negative equity instead of trying to claw back funds from traders.
When the insurance fund is empty or is insufficient to cover losses, the ADL mechanism will kick in. For example, if there is a sharp drop in Bitcoin’s price and a trader who was long Bitcoin had their position close with negative equity, the exchange would automatically deleverage other traders’ short positions (which are in profit) in order to compensate the exchange for the negative equity of the first trader. The order in which short traders’ positions get reduced from ADL is determined by their unrealized profit and effective leverage. Positions with higher unrealized profit and higher leverage are prioritized in the ADL pecking order.
Pricing and Funding
Typically, perpetual futures contracts are priced relative to their underlying spot index, meaning that Bitcoin contracts are priced by indexing spot Bitcoin prices. Many trading platforms use a basket of centralized exchange prices to come up with their index price, but it varies by platform. The goal is for perpetual futures contracts to track their underlying index price as close as possible.
Deviations between index prices and futures contract prices converge as funding rates fluctuate according to market demand. A positive funding rate means that longs will pay shorts, and a negative funding rate means shorts will pay longs. When the futures price exceeds the index price, traders can long spot, short futures to harvest ‘carry’, and vice versa.
The trader still runs the risk of the futures position being liquidated if the price fluctuates too much while waiting for the two prices to converge. This is a simple financial arbitrage of converging spot and derivative price differences and is known as a “basis trade” or “cash and carry” in traditional futures markets.
Funding rates are calculated typically every 8 hours, and anyone holding a futures position will either receive or pay a funding fee based on their position.
The Funding Fee = Mark Value * Funding Rate, where
- Mark Value = Notional Value of Contracts a Trader is Holding
- Funding Rate = Interest Rate + Premium/Discount
The interest rate calculation varies by platform. Binance, one of the leading perpetual future exchanges, uses a fixed 0.03% daily interest rate (0.01% every 8 hours). The premium/discount is derived from the difference between mark and contract prices. The larger the gap between the two, the larger the premium or discount is. The actual calculations of the premium/discount vary according to different exchanges, which we explore later in this piece. It is also important to note that most exchanges implement a funding floor and ceiling.
Decentralized Perpetual Futures Exchanges
Although the protocols we detailed below feature different designs, they constitute decentralized perp DEXs as they are non-custodial. This allows users to self-custody funds that are not deposited, actively in positions or in limit orders.
This means that funds that are in use are either deposited in Layer 2 (Starknet) or trigger order smart contracts (limit orders on GMX). These funds are impervious to misappropriation by the protocol but are still exposed to hack risk. Funds that are not in use, on the other hand, are self-custodied in users’ wallets. To achieve a true non-custodial DEX, teams need to build towards just-in-time liquidity for trigger orders, eliminating the need for temporary custody of funds before prices trigger orders.
As innovative as some of these DEXs are, regulatory clarity around them is still uncertain. The Commodity Futures Trading Commission (CFTC) maintains that OokiDAO is an entity that operated bZx exchange, although a federal judge recently ruled that the lawsuit should be served to the fraudulent founders instead.
Based on the overview above, GMX evidently dominates in market cap despite facilitating ~⅓ of the volume of dYdX. Perhaps this premium can be partially attributable to the protocol’s popularity among crypto natives and Arthur Hayes’ public support.
We then peruse the decentralized perp protocols across a few criteria, including Profitability, Effective Fee Rate, TVL Efficiency and Protocol Split of Fees. Unsurprisingly, none of the protocols are profitable due to token incentives to attract liquidity, characteristic of most DEXs in the space. GMX also trades at a premium relative to trading volume in spite of its higher Effective Fee Rate, with incumbent dYdX offering the lowest aggregate fees in the comp set.
AMM-based DEXs are more capital efficient than order-book based DEX dYdX. Within AMM-based DEXs, Gains Network is the most capital efficient with TVL as DAI is the only liquidity pair, unlike GLP’s multi-asset source of liquidity. dYdX keeps the entirety of trading fees charged on the platform, while GMX shares 70% of fees with GLP holders, and Gains Network cedes 25% to liquidity providers.
dYdX Exchange ($DYDX)
Representing the first successful iteration of perp DEXs, dYdX is a central limit order-book perp DEX that offers up to 20x leverage on 37 different assets. The DEX launched in the summer of 2017 by Antonio Juliano, an ex-Coinbase engineer and featured margin trading on Ethereum. After perps were introduced by Bitmex in 2019, dYdX sought to become the first fully decentralized derivatives exchange where no centralized party, including the team, would have full authority over the protocol’s fundamental operations.
dYdX transitioned from Ethereum to the StarkEx L2 network in 2021 to benefit from lower latency and costs, offering higher trade throughput and lower minimum order sizes. Although traders must deposit funds to an Ethereum smart contract, trades are settled on Starkex, which publishes zero-knowledge proofs to an Ethereum smart contract to verify the chain’s state transitions.
dYdX holds user collateral in USDC and offers cross-margining by default, although isolated margin can also be achieved by creating different sub-accounts. This means that realized and unrealized profits are both used for the purposes of margin calculations – gains from one position can offset losses from another.
The margin requirements on dYdX can be defined as:
- Total Initial Margin Requirement
Σ abs(Si × Pi × Ii)
- Total Maintenance Margin Requirement:
Σ abs(Si × Pi × Mi), where
- Si = Size of the position (+ if long, – if short)
- Pi = oracle Price for the market
- Ii = Initial margin fraction for the market
- Mi = Maintenance margin fraction for the market
Positions that cannot maintain their maintenance margin will be liquidated by the liquidation engine, based on the following close prices:
- Close Price (Short):
P × (1 + (M × V / W))
- Close Price (Long):
P × (1 − (M × V / W)), where:
- P is the oracle price for the market
- M is the maintenance margin fraction for the market
- V is the total account value, as defined above
- W is the total maintentance margin requirement, as defined above
- V/W remain unchanged as positions are liquidated
Unlike most perp exchanges who quote 8-hour funding rates, dYdX leverages funding rates that are paid hourly and added to positions. Like other exchanges, the funding rate is composed of a premium component and interest rate component. Funding rates are dependent on the price impact of a standard-sized trade. They are calculated every minute at a random point of each minute through the following formula and a simple average of the 60 premiums will be applied to the next hour:
Funding Rate Premium Component:
(Max(0, Impact Bid Price – Index Price) – Max(0, Index Price – Impact Ask Price)) / Index Price,
- Impact Bid / Ask Price = average execution price for a market sell / buy of the Impact Notional Amount, and
- Impact Notional Amount = 500 USDC / Initial Margin Fraction
As such, the platform’s aggregate funding rate can be defined by:
Funding Rate = (Premium Component / 8 ) + Interest Rate Component, where
- Interest Rate Component = 0.00125 (0.01% every 8 hours)
dYdX leverages oracle prices from 15 independent Chainlink nodes to ensure each account is well-collateralized after each trade and when each account should be liquidated. Index prices, on the other hand, determine the funding rate and are used for ‘triggerable order types’ (e.g. Stop-Limit and Take-Profit orders). Index prices are calculated from up to 8 different CEXs, with each exchange’s price calculated as the median of the best-ask, best-bid, and last-traded price of the pair.
As part of its decentralization effort, the team intends to launch a native dYdX blockchain due in Q2 2022. Apart from a standalone blockchain, their v4 update will be built based on the Cosmos SDK and use Tendermint PoS for consensus, driving value to the native token ($DYDX) as a utility token. Apart from the decentralized infrastructure detailed below, the exchange is also incentivizing subDAOs to run its operations using grants.
The v4 exchange will also employ validators that run an in-memory orderbook off the dYdX chain and which do not contribute to consensus. These validators match orders off-chain in real time and then commit the resulting trades on-chain, offering a unique hybrid solution to order book matching and settling.
dYdX has dominated DEX trading volume thus far with nominally higher token incentives, as indicated by its negative profitability above. In addition to these token incentives, 2023 will see an unlock of 30% of dYdX’s total supply by February and 70% by September. It is unclear if organic demand can support the native token price once cliff unlocks vest at the turn of the new year – dYdX’s IDO price was $1.0 (with pre-IDO prices cheaper), not too far below its current trading price of $1.26.
GMX ($GMX, $GLP)
Launched in Sep ‘21, GMX is a perp AMM DEX that started on Arbitrum and expanded to Avalanche in Jan ‘22. It was launched by an anon founder and occupies the most ($725m) in TVL on Arbitrum. The protocol garnered significant attention especially after Arthur Hayes’ recent public endorsements  , but serves as the third iteration after XVIX and Gambit Financial.
Across both Arbitrum and Avalanche, GMX currently accepts 11 assets (GLP constituents) to offer 50x leverage over 8 trading pairs. It does so by featuring a two-token model ($GMX and $GLP) to attract liquidity and reward users/traders, paying out all platform swap and trading fees generated to both tokens.
GMX is the platform’s utility and governance. Users can opt to stake GMX for (i) 30% of swap and trading fees that are distributed on ETH or AVAX per the users network, (ii) Escrowed GMX (esGMX) that can be either converted to GMX by vesting over one year, or re-staked like regular GMX for another loop of rewards. Staked GMX also accrue (iii) multiplier points that boosts rewards at an average of 100% APR. The choice users possess of vesting or compounding their esGMX makes the circulating supply of GMX floating, although the forecasted maximum supply is 13.25m.
GMX also has a Floor Price Fund (FPF) denominated in ETH and GLP. Fees from protocol-owned GMX/ETH liquidity is converted into GLP and deposited in the FPF. Should the price drops below FPF/Circulating Supply, FPF will be deployed to buyback and burn GMX. Currently, the FPF stands at $2.6m, implying a ‘floor price’ of a meager $0.30.
On the other hand, the protocol attracts liquidity through the GLP token that encompasses a basket of tokens (~50% stablecoins, ~35% ETH, ~15% BTC) and accrues 70% of swap and trading fees. The composition of GLP self-adjusts according to open positions – the larger the long open interest for ETH (and the more ETH reserved for the open interest), the higher the percentage of ETH in the index. The protocol allows redemption of GLP tokens for its constituents and vice versa. It also favors redemptions that rebalance the index according to its targets via fee rebates.
By leveraging GLP liquidity and oracle pricing, GMX is essentially a gambling platform, where GLP holders are the brokers providing liquidity. GLP holders benefit from traders losing, and incur losses when traders are profitable. Since its inception, traders have been in the red, profiting GLP stakers with platform and liquidation fees so far.
GMX charges 0.1% to open and close positions, and an hourly borrow fee that scales with utilization below:
Asset Borrowed / Total assets in Pool * 0.01%
When opening positions on GMX, a snapshot of collateral (in USD terms) is taken and a 0.3% swap fee is charged for converting the collateral to USD value. When positions are closed, longs are paid in the underlying token while shorts are paid in stablecoins.
GMX leverages proprietary price feed keepers that submit a median of index prices from Binance, Bitfinex, and Coinbase, but supplements them with Chainlink feeds for low latency.
It is worth noting that GMX has enjoyed success predominantly in a bear market. Due to the zero-sum token design between traders and GLP stakers outlined above, GLP liquidity providers may be at risk of facilitating toxic flow when markets turn.
In fact, GMX was exploited on September 18th for an estimated $565k. Due to the tight spread and zero price impact offered by the exchange, the unidentified exploiter opened multiple large longs and shorts positions on GMX within a 2-hour window for the AVAXUSD pair. They subsequently manipulated the prices on Coinbase on low liquidity, effectively front-running long and shorts to GLP holders.
GLP is arguably GMX’s most meaningful primitive, becoming the bedrock of composability for other Arbitrum protocols such as Umami Finance and Rage Trade to offer delta-neutral yields by hedging the constituent GLP tokens. However, this composability comes at a cost of compounded smart contract risk and design risk, even with the protocol’s own calculation of AUM. Earlier this month, an attacker manipulated the price of plutus vault GLP ($plvGLP) to drain assets on Lodestar Finance against their artificially inflated plvGLP collateral.
Another point worth mentioning about GMX is that due to its oracle design, price appreciation by definition, cannot happen organically. The exchange acts more akin to a casino than an actual exchange, relying on aggregate oracle pricing from other venues. GMX volumes cannot exceed that of its oracle sources, since it opens up vectors of attack for price manipulation that siphons liquidity from GLP.
GMX’s price oracles are also susceptible to MEV manipulation as the price keeper oracles coupled with the public mempools on Arbitrum allow bots to front run price changes on the platform. But this is not the first time a slippage-free, oracle-based perp dex encountered problems – Synthetic also suffered from a frontrunning issues when it launched. GMX’s former selves XVIX and Gambit Financial were also victims of faulty liquidity designs, which begs the question – are slippage-free, oracle-based DEXs an achievable primitive like purely algorithmic stablecoins?
Some have argued that slippage is not a bug, but a feature, reflecting the cost of liquidity of the trade in markets. Offering zero slippage can result in circumstances where GLP liquidity providers are picked off from thinly traded tokens elsewhere. Limiting size based on available GLP liquidity partially solves this, but cannot truly position GMX as a dominant exchange.
Gains Network ($GNS)
While the decentralized perp DEXs landscape is dominated by dYdX and GMX, Gains Network is gaining increased traction. After a white-hat hacker found a bug in the v1 version of Gains in January of 2022, the founders launched v2 later that month. Gains Network’s main product gTrade is a liquidity efficient, powerful, and user-friendly decentralized leverage trading platform with up to 150x leverage on crypto, 1000x on FX, and 100x on stocks. gTrade operates on the Polygon Network with 70 different trading pairs and will soon be deployed on Arbitrum.
Gains Network has three major protocol design components:
- The DAI Vault
- GNS Token / GNS NFTs
- On-Demand Decentralized Oracle Network
The DAI Vault
Similar to GLP, the DAI vault is the source of liquidity for all gTrade traders. Users can deposit DAI into the vault in return for gDAI which represents the depositor’s share of the vault. The DAI vault acts as the broker – when traders lose on their positions, losses get added to the vault, and when traders win, they are paid out from the vault.
Additionally, gTrade takes various platform fees and a portion is then distributed amongst all gDAI holders, helping to incentivize DAI liquidity. As long as fees collected are greater than trader PnL, staking in the DAI Vault is a profitable strategy. As seen here, gTrade users tend to lose money over the long run.
Gains Network’s DAI Vault allows them to offer high levels of synthetic leverage on a large number of trading pairs. Gains Network does not need to hold underlying liquidity like GMX, it simply has to be able to cover potential traders’ profits. By offering this flexibility, depositors of the DAI Vault cannot withdraw immediately; they must wait 1-3 epochs after requesting withdrawal depending on the vault’s collateralization ratio. The higher the ratio, the shorter the withdrawal time. The time-lock is to prevent users from front-running updated trader PnL data feeding to the vault.
Although the synthetic system allows gTrade to offer increased leverage and trading pairs to traders, there are some controls on the platform to prevent the DAI vault from being depleted:
- Limit of 3 open trades per trading pair per wallet
- Maximum collateral per trade of 75,000 DAI
- Maximum open interest (long/short) per pair
- Maximum open collateral (long/short) per asset class
- Max profit percentage on each trade collateral capped at 900%
These parameter controls help Gains Network manage risk and to prevent liquidity from being drained during black swan events.
$GNS / GNS NFTs
Gains Network’s native token is $GNS which is a utility token that acts as a mechanism of liquidity efficiency, helping Gains Network capitalize on resources and offer the best trading experience possible, while rewarding those participating in the ecosystem. Current utility for $GNS includes:
- Supporting liquidity efficiency of the DAI Vault via new mints to subsidize LPs and NFT Bots – keeping the DAI Vault untouched
- Token burns when the DAI vault is adequately overcollateralized (130%). This is done to counteract inflation from GNS/DAI LP rewards and NFT bot rewards
- Serving as the ultimate backstop to traders winning on gTrade
- Future on-chain governance rights
- Roughly 32.5% of trading fees go to $GNS stakers
GNS’s initial supply was 38.5 million with a supply cap of 100 million. To date, over 20% of the $GNS supply has been organically burned due to gTrade activity, bringing the total supply down to 30.4 million.
GNS additionally has NFTs that are boosters to the Gains Network ecosystem. There are 5 different NFT classes that offer benefits, including reduced trading spreads, running a bot to receive rewards from executing liquidations and limit orders, and boosting LP or single-sided-staking (SSS) rewards. There are a total of 1,500 NFTs across the 5 categories and their benefits can be seen in the table below:
On-Demand Decentralized Oracle Network (DON)
Gains Network uses a Chainlink oracle to come up with a reference price for futures contract pricing, which then feeds into the calculation of funding rates. Since price feeds are not generally updated every time someone places a trade on gTrade, gTrade has built an on-demand Decentralized Oracle Network (DON) which will update the oracle price every time someone places a trade. gTrade executes trades at the median of DON’s prices without generating its own pricing data.
When a trader wants to open a trade, the trading contract requests a price from the aggregator contract. The aggregator receives data from gTrade’s 8 on-demand Chainlink oracles which each request the median spot price from 7 different exchange APIs. Additionally, the aggregator contract will cross-reference the corresponding Chainlink Price Feed to filter out any pricing outliers. If the difference in price is more than 1.5%, the contract rejects the node answer and waits for the next. Finally, when a minimum of three answers is reached, the contract takes the median price again, and sends it to the trading contract for execution.
Gains Network’s DON design minimizes the chances of oracle manipulation and large wicks that would normally liquidate traders’ positions as it pulls median prices from various exchanges.
Gains Network has various platform fees that fund protocol incentives, a developer fund, and a project fund. Users pay fees for opening a trade, closing a trade, updating stop losses, as well as rollover and funding fees. Additionally, gTrade fees are unique in that they vary according to what is being traded. The table below represents the fees for the different asset classes available on the platform. Forex fees are the cheapest and Tier 3 Stocks (most volatile stocks) are the most expensive.
In addition to the fees shown in the table, gTrade charges rollover and funding fees. Rollover fees have been implemented to allow traders to use lower leverages while maintaining solid risk management for the protocol. Rollover fees are simply a fee charged per block relative to position size. Rollover fee percentages vary by trading pairs with more volatile assets having a higher fee than less volatile assets. Fees are deducted from the trade value, so traders’ liquidation prices will get closer to the asset price the longer the trade remains open.
The funding fees on Gains Network scale with the net exposure of a trading pair, balancing liquidity between long and short demand. Similar to how other platforms charge funding fees, if net exposure is long, longs will be paying shorts, and vice versa. This incentivizes traders to take the opposite side of where gTrade may be overexposed and helps mitigate risk.
Ultimately, whether Gains Network can continue scaling its synthetic leverage system to compete with dYdX and GMX will depend on if it can offer a seamless trading experience across asset classes despite the safety parameters that it has put in place to mitigate tail risk for gDAI.
The implosion of centralized crypto entities throughout 2022 has undoubtedly made the case for non-custodial DEXs. At the very least, perpetual futures, a crypto-native derivative, deserves to be hosted on transparent, decentralized platforms. While the current iterations of perp DEXs are gaining traction, they incur various design tradeoffs along sources of liquidity, decentralization, and risk of toxic flow.
*Special thanks to Tom Couture for his help writing this piece.
 Classic futures can be cash or asset-settled, while perpetual futures contracts in crypto are cash-settled.