Innovations of On-Chain Perpetual Protocols Part 1

Bytetrade Lab
10 min readNov 29, 2022

--

The Inner Workings of GMX

By Frank Hu, Kester Wu

As the impending contagion effects from FTX unfold, there has been an increased emphasis on decentralization and transparency. The migration of trading activity from CeFi to DeFi is not a matter of “if” but a matter of “when”.

Perpetual protocols like GMX have gained significant traction in the past couple of months. The unique design of GMX has fluorished into an ecosystem on its own. This research piece will be split into 2 articles.

In Part 1, the focus will be placed on GMX unique multi-asset pool, Tokenomics and its key benefits & challenges. In Part 2 , the focus will be placed on the ecosystem of DeFi protocols that are built on top of GMX.

TLDR:

* GMX functions fully on-chain and uses an AMM feature to enable
leveraged trades.

* On GMX, traders enjoy full transparency regarding their counterparties as
compared to trading on CEXs. Unlike other perpetual protocols like dydx,
GMX functions fully on-chain and uses an AMM feature to enable
leveraged trades.

* The GLP Pool comprises of 50% stablecoins and 50% blue-chip assets ($ETH,
$BTC, $UNI and $LINK). Using the GLP Pool, GMX offers traders 4
Token/USD trading pairs.

* GMX operates a dual-token model - $GLP & $GMX.

* $GLP acts as a "proof-of-liquidity" receipt for LPs while
$GMX is the utility and governance token of the protocol.

* Trading on GMX is a "zero-sum game".
If traders win, LPs lose.
If traders lose, LPs win.

* GMX Key Benefits:
1. Zero Slippage
2. High Capital Efficiency

* GMX Key Challenges:
1. LP exposure to trading skew
2. Lack of Open Interest Balancing
3. Oracle Manipulation
4. Lack of Trading Pairs

GMX

GMX is a decentralized spot and perpetual exchange that provides traders with the ability to trade assets with up to 50x leverage. The protocol is currently live on 2 chains, Arbitrum and Avalanche. On each chain, 4 Token/USD pairs are offered for trading.

On GMX, traders enjoy full transparency regarding their counterparties as compared to trading on CEXs. Unlike other perpetual protocols like dydx, GMX functions fully on-chain and uses an AMM feature to enable leveraged trades.

Single Multi-Asset Pool

As compared to other DEXs that operate with single asset liquidity pools, liquidity providers (LPs) on GMX provide liquidity into a SINGLE multi-asset pool.

LPs provide liquidity by minting $GLP. $GLP is an asset that tracks the price movement of an underlying index. Additionally, $GLP acts as a “proof-of liqudity” receipt for LPs.

The $GLP pool on Arbitrum is an index that comprises of approximately 50% stablecoins ($USDC, $USDT, $FRAX, $MIM) and 50% blue-chip tokens ($ETH, $BTC, $LINK and $UNI).

2M Average Weightages in GLP Pool

Referencing the diagram above, majority of the $GLP pool comprises of $USDC, $ETH and $BTC.

$GLP can be:

  1. Minted using any of the underlying index assets and
  2. Burnt to redeem any of the underlying index assets

The assets within the multi-asset pool is then used for trading, where traders can take leveraged positions in either direction.

30x LONG ETH Example

Worfklow for 30x LONG ETH

A trader posts a collateral of 1 $ETH and opens a 30x long position on $ETH on GMX. Under the hood, the trader borrows 29 $ETH from the pool to create a long exposure of 30 $ETH. Depending on the trading outcome, the $GLP pool is affected differently.

  1. If the trader profits, he withdraws (1+profits) $ETH from the $GLP pool.
  2. If the trader loses, he withdraws (1-losses) $ETH from the $GLP pool.
Effect on $GLP Pool depending on Trading Outcomes and Open Interest

Trade ideas are then translated into differences on Open Interest (OI) on GMX. Referencing the table above, the $GLP pool is directly impacted by the result and direction of trades. Hence, there is a requirement to rebalance the weights of assets within the $GLP pool.

GMX rebalances the $GLP pool through 2 methods:

  1. $GLP Minting/Burning Fee Discounts
$GLP Mint & Burn Fees vs Asset Weight

As mentioned above, LPs are able to mint $GLP with any of the underlying index assets. Since OI dictates the requirement of assets, there is a target weight for each asset within the pool. Hence, GMX encourages each asset to converge towards their target weight by offering lower $GLP minting fees and higher $GLP burning fees.

Using an extreme example for easier understanding, the table above can be interpreted in the following manner.

Referring to $UNI, the most underweighted within the $GLP pool. By minting $GLP with $UNI, LPs will be paying the lowest minting fee. Conversely, burning $GLP for $UNI LPs will be paying the highest burn fee.

2. Swap Fee Discounts

Swap Fee Discounts

Apart from conducting leveraged trades, users can also swap between different index assets with GMX. Given this feature, GMX also tries to rebalance the $GLP pool by making it more expensive to swap for underweighted assets.

Referencing the diagram above, swapping for $UNI (removing $UNI, an underweight asset, from the $GLP pool) has a higher fee of 0.52% while swapping for $USDT (removing $USDT, an overweight asset, from the $GLP pool) has a lower fee of 0.34%.

Tokenomics

GMX operates a dual-token model.

  1. $GLP
  2. $GMX
Tokenomics Summary Table

$GLP

$GLP acts as a “proof-of-liquidity” receipt for LPs. The mechanics of $GLP was elaborated at length in Part 1. However, some salient points to take note of are:

  1. Holding $GLP will expose LPs to the price movements of the underlying assets in the $GLP pool.
  2. Yield that LPs receive on $GLP is dependent on 2 things: 1) trading volume 2) traders have to lose.

Liquidity provison on GMX is a zero-sum game.

Since trading outcomes directly impact the $GLP Pool, LPs are always the counterparty to trades.

Effect on $GLP Pool depending on Trading Outcomes and Open Interest

Key Benefits of GMX

  1. Traders on GMX enjoy zero slippage.

Slippage is defined as the difference between the expected price of a trade and the price at which the trade is executed.

GMX enables “zero slippage” by using custom oracles that extract prices from 3 CEXs (Binance, Coinbase and BitFinex). FTX was previously in the oracle mix but was replaced by Coinbase.

2. High Capital Efficiency

The enabling of leverage allows GMX to have an extremely high asset utilization rate, which translates to higher yield for $GLP LPs. At its peak, GMX AUM Daily Usage was close to 300%.

Source(s): GMX Stats, 11 November 2022

Compare this to a spot DEX like PancakeSwap. The asset utilization on Pancake Swap was only ~15.0% (calculated as Trading Volume/TVL = 433.5/2900 = ~15.0%).

Source(s): Token Terminal, Pancake Swap TVL & Trading Volume

Key Challenges of GMX

Naturally, GMX as a protocol also faces certain challenges.

  1. LPs exposure to trading skew

In strongly trending markets (bull/bear) there might be an exceptional OI skew. In such situations, traders could be unilaterally entering either longs or shorts.

Source(s): GMX Stats, Historical Open Interest

For example, in a bull market, most traders want to be long. When a trader takes a long position, the asset is “rented out” from the $GLP pool. Referencing the figure above, in September 2021, OI for longs were at 97%. In the situation where traders make a windfall, the $GLP pool could be drained of its asset ($ETH or $BTC) holdings.

However, it is important to note that in September 2021, GMX only had ~100 users. As a result, trading skews were easily affected by bigger trades. As the number of users grow, it would be more difficult to affect the overall trading skew on the protocol.

Conversely, in a bear market, when traders are heavily shorting the market
the $GLP pool would be paying out stablecoins while the value of other tokens within the index continue falling. Referencing the figure above, in November 2022, OI for shorts peaked at 76%.

In the scenario where majority of short traders profit, $GLP holders would be impacted from both:

(1) outflow of stablecoins &

(2) falling price of underlying asset. Understanding this, it is understandable that $GLP holders would experience a larger impact from short skews as compared to long skews.

GMX Monthly Open Interest Split

3M data shows that trading skews have not been heavily skewed in one direction.

However, given the recent FTX debacle on the 9th Nov 2022, trading skew was 65% skewed towards shorts and spiked to 76.5% on 11th Nov 2022.

GMX Open Interest on 11th November 2022

Regardless, traders still lost almost ~USD 3mn on 9th Nov.

Trader Net PnL on 9th November 2022

2. Lack of OI Balancing

The challenge stated above is exacerbated as GMX does not have an internal mechanism for balancing OI.

GMX calculates the borrowing rate of an asset based on its utilization. As a result, funding rates are always positive for longs and shorts regardless of the concentration (i.e. traders would always have to pay funding regardless of direction).

On CEXs, the funding rate is usually used to balance the OI. Since funding rates are paid peer-to-peer, it acts as a natural catalyst for perp-spot price convergence.

Little Summary Table

When the funding rate is positive, the price of the perp is higher than the spot price. Traders who are long pay funding to shorts. This incentivises more traders to short the perp to bring the perp price closer to spot price. Vice versa.

3. Oracle Manipulation

Oracle mispricing / manipulation during volatile periods could potentially lead to “toxic arbitrage” (credits to Joo Kian from Delphi Digital).

To combat this problem, GMX uses a custom oracle that retrieves median prices from 3 CEXs (Binance, Coinbase and BitFinex). Additionally, price updates are provided at the start of each block — ensuring that every trade within the same block receives the same updated execution price. This helps to prevent front-running.

Despite the protocol’s efforts, this oracle design is still susceptible to exploits. In September, GMX was exploited on Avalanche and a trader profited ~$565,000 after accounting for fees.

To understand this case study we have to understand several factors:

  1. Opening a long/short position on GMX will not affect the prices on CEXs. This is because GMX is always a price taker as it extract prices from CEXs.
  2. The trader that understood this mechanism executed the following steps. He first opened a leveraged long position on $AVAX on GMX. Subsequently he pushed the prices up on CEXs. When the price feeds update on GMX, he closed his long and profited ~$565,000.
  3. It is important to note that this can only be executed in time of thin liquidity where the market is easily affected by size.

To combat this issue, GMX temporarily issued an articficial cap on $AVAX open interest. Ideally, there should be no need for manual interference as as the trading limits should only be limited by the assets in the $GLP pool.

4. Lack of Trading Pairs

For traders that are interested in trading alt-coins, GMX is not the place to go. Currently, there are only 4 USD trading pairs on GMX for both Arbitrum and Avalanche.

Stay tuned for Part 2 — a survey into GMX’s ecosystem and some interesting protocols that are built on top of GMX.

Key Takeaways:

* On GMX, traders enjoy full transparency regarding their counterparties as
compared to trading on CEXs. Unlike other perpetual protocols like dydx,
GMX functions fully on-chain and uses an AMM feature to enable
leveraged trades.

* Trading on GMX is a "zero-sum game".
If traders win, LPs lose.
If traders lose, LPs win.

ByteTrade Lab, headquartered in Singapore, is backed by Susquehanna
International Group (SIG) Asia Venture Capital Fund and some other leading institutional investors including INCE Capital, BAI Capital, Sky9 Capital and NGC Ventures with a recent 40 Million USD Series-A fundraising in June 2022.

At ByteTrade, we are actively building our Web3 Operating System (OS) based on an open Blockchain-EdgeNode-Client (BEC) architecture, a decentralized version of the original full stack internet protocols, that would massively adopt users and decentralized internet applications to Web 3.0 and ultimately return data ownership back to users.

Apart from being a Web3 OS builder, ByteTrade is also actively involved in
incubating and early stage investing of Web 3.0 projects to build our Web3 OS Ecosystem. We aim to enable the builders of Web 3.0 by providing a variety of resources to them including but not limited to: technology expertise, product definition, business planning, GTM strategies and funding.

Ecosystem Partners:

Coda Ventures, Obridge, Ladder, PeopleMint, FilSwan,
MUADAO, Playerone, ZKCross, CatcherDAO, TokenInsight, Keysafe, ZKSafe, PreAngel, BetterverseDAO, Web3port, AllinWeb3, etc.

For more information, do follow us on Twitter.

--

--

Bytetrade Lab

Web3 Infrastructure Innovator, Builder and Enabler to Return Data Ownership back to Users.