“DeFi transaction costs are generally higher compared to CeFi. In 2022, with the collapse of various CeFi crypto trading platforms, DeFi has once again attracted a lot of attention due to its built-in self-custody and transparency. We compared trading 100 on different exchanges The cost of ETH position perpetual contracts and conclude that DeFi perpetual contract trading does not come with high costs.”

In a recent study by Barbon and Ranaldo [1], “On Cryptocurrency Market Quality,” they found that DeFi spot trading is accompanied by high transaction costs, which need to be weighed against the risks and delays involved in delegated custody on CEXs. However, is this a necessary trade-off for perpetual contracts?

cost source

The trading costs of perpetual contracts can be broken down into different components: trading fees, gas fees, slippage, and carrying costs.

  • Trading fees: These fees are incurred on every trade when a trader buys or sells a perpetual contract. Typically, the trading fee is a fixed percentage of the notional position size. The nominal position size is also known as the "contract size", for example, if you place a 2 ETH long trade with a margin of 1000 USDC, the nominal position size is 2 ETH (the transaction fee is independent of the margin).

  • Gas fees: On DEX, transactions are accompanied by gas fees, and these fees vary between different blockchains and smart contract codes. For most blockchains, gas costs also depend on the state of the network. Gas fees are typically paid in the blockchain’s base currency and are independent of position size, whereas transactions on CEX have no gas fees.

  • Slippage: Slippage is the difference between the (mid) price and the price you get when you trade. For a given exchange and time, the larger your position, the higher the slippage. Some DeFi protocols differentiate between terminology, using price impact as expected price deviation, while slippage is defined as an unexpected deviation from the mid-price (for example, due to a limit order being canceled or another trader entering first). In this article, we only consider price effects.

Example: In an order book system like the perpetual contract exchange on Binance, the mid-price is the best bid (the price you get when you sell on the market) and the best ask (the price you get when you buy on the market). average value. Figure 1 shows a screenshot of the order book for the ETH perpetual contract on Binance. We can see that the best selling price is $1,098.63 and the best buying price is $1,098.62. If we buy no more than 263.0731 ETH, we will trade at the best sell price unless another trader executes before us, or the limit order at this price is canceled. If we trade above this amount, the price will drop slightly. A decrease in price compared to the mid-point price is called slippage.

Figure 1: Order book on Binance
  • Carrying costs: Perpetual contracts typically have a funding rate. The funding rate is usually calculated every 8 hours. If the demand for long positions is greater than the short position, the funding rate is paid from the long position to the short position. If the demand for the short position is greater than the long position, the funding rate is paid from the short position to the long position. This is the classic perpetual contract design introduced by BitMex in 2016. Historically, shorts have received about 1 basis point (0.01%) from longs every 8 hours most of the time. However, some DeFi protocols such as GMX subvert this design and charge "borrowing rates" to longs and shorts, calculated on an hourly basis (meaning that this 0.01% rate is 8 times higher than BitMEX's practice). This could result in a significant increase in carrying costs. On Gains Network, a “rolling/flip rate” is levied on collateral and is used in conjunction with the funding rate.

competitors

In this section, we detail how we collected and compared the data. We use Binance as our representative CEX, which at the time of writing ranks first in terms of trading volume and has low fees compared to other CEXs. For DEX, we collect data from GMX, Gains Network, Perpetual Protocol and dYdX. We compare these results to our own D8X perpetual contract. Since the D8X perpetual contract has not yet gone live on mainnet at the time of writing, we determined all cost components using agent-based simulations with our expected highest cost tier.

dYdX is the only DEX in our selection that uses an order book rather than an Automated Market Maker (AMM). Although non-custodial, dYdX’s current partnership with StarkWare enables off-chain order books and bottlenecks through a single centralized sequential processor, see Blogmates for details, which dilutes the advantages of DeFi itself.

AMM-based protocols, such as Perpetual Protocol, Gains Network, and GMX, use pricing functions to determine transaction prices. Each trader trades with a "liquidity pool" through the AMM's pricing function. Liquidity pools allow anyone to contribute tokens to the protocol (usually tokens in the form of USD, such as DAI or USDC) and participate in the profits and losses of the AMM.

GMX’s pricing function differs from other protocols in that it has zero slippage. This can lead to potential abuse in some cases, as detailed by Joshua Lim, but can result in lower costs for traders. The lower costs due to the elimination of slippage are compensated by borrowing fees charged to longs and shorts (different from the funding rate).

Gains Network charges funding fees and borrowing fees. Gains Network adopts a linear pricing method. In other words, Gains will add a certain spread to the index price and linearly worsen the price with the size of the transaction. For details, see Gains Network's gTrade v6.1: In-depth.

Perpetual Protocol offers classic perpetual contracts that pay funding fees peer-to-peer (from long to short or vice versa). In V2, the protocol borrowed the pricing function from Uniswap v3’s centralized liquidity AMM, and therefore, Perpetual Protocol V2 inherited Uniswap V3’s slippage.

D8X also provides classic perpetual contracts and peer-to-peer payment of funding fees. D8X is significantly different in its pricing approach, adopting a derivatives pricing approach where the AMM sets the price to incentivize traders to minimize AMM risk. For example, if there are equal numbers of longs and shorts in a particular perpetual contract, and there is sufficient liquidity, the risk of an AMM losing money due to price fluctuations is very low. In this case, slippage will be very low. Conversely, if there are more longs than shorts, then the D8X AMM will provide better prices to traders who are short, thereby reducing the AMM's market risk and providing significantly higher prices and slippage to traders entering long positions. This results in better price impact during good times compared to Perpetual Protocol and Gains, and when supply and demand differ greatly, prices can be arbitraged.

data

Our goal is to estimate the price of a 100 ETH trade with a holding period of 8 hours. In this section, we detail the data collection process and how slippage is determined.

Transaction fee data

Transaction fee data are collected directly from the documents of the different exchanges in our sample (data 1, 2, 3, 4 and 5). If an exchange offers a trading fee rebate option, we use the lowest level of fee data (i.e. "regular user"). If the exchange distinguishes between taker fees and pending order fees, we use the taker fee.

Slippage data

Slippage data was collected in October-November 2022. Collection methods vary by exchange and are described below:

Gathering Order Book Slippage Data: Binance and dYdX

For the two order book-based exchanges in our sample, dYdX and Binance, we collect order book data through their REST APIs. Our Python code downloads the order book data every minute and aggregates the data in a PostgreSQL database. We then calculate the average price of long and short 100 ETH trades for each order book observation. All results are averaged to give the final slippage figure.

Binance

Observed 1556 times on October 30 and 31, 2022,

The average slippage for longs is 0.50 basis points and the standard deviation is 0.56 basis points.

The average slippage for shorts is 0.53 basis points, with a standard deviation of 0.61 basis points.

The following image uses a histogram to visualize the data:

Figure 2: Slippage on Binance. On average, placing a trade of 100 ETH on October 30-31, 2022 will result in approximately 1 basis point of slippage. The maximum observed was 12 basis points at level 50 of the order book. In both observations, layer 50 was insufficient to support a 100 ETH transaction.

dYdX

Observed 799 times on October 31, 2022,

The average slippage for longs is 1.87 basis points, with a standard deviation of 0.61 basis points.

The average slippage for shorts is 1.76 basis points, with a standard deviation of 0.69 basis points.

The following image uses a histogram to visualize the data:

https://lh7-us.googleusercontent.com/huN9oODLn71ulxMsqv8zTuSqY0Te6S52M4crbdjQ1SxG58PfkUH2HA4pm0Mc4qwRW7XRymUbT4ewH4L2xTW71wQumtkGUPwalgAcyqxhMwswMi1eEvuOouLRIl3WbYsbvqjZNSJO5DFGPdsiDpn76AY

https://lh7-us.googleusercontent.com/2rL6H2f6MALNYrHrD7oJ332K_5a2BXweYc3NqpU6e_9VkqK-i67nPTPIQpPfq3Qxu3PuML5qoRTgqgnwhdsKLl6PqJWR43LfV-QHrn8YHQtSNGtnaap5uwDxVx_fehGhN2amWd4a_XXnUxNvT5LJ32Q

Figure 3: Slippage on dYdX. On average, placing a trade of 100 ETH on October 31, 2022 will result in approximately 2 basis points of slippage. The maximum observed was 11 basis points across the 799 order book.

Collecting AMM slippage data: Perpetual Protocol, Gains Network and GMX

For the two AMM-based exchanges with slippage in our sample (Perpetual Protocol and Gains Network), we collected data directly from the protocol’s DApps. GMX is designed with zero slippage.

Perpetual Protocol

We collected the total USD amount required to open a 100 ETH position from the DApp, calculated the implied price provided by the AMM, and calculated the percentage difference between the (middle) price and the price we would have received on the 100 ETH trade. We observed 3 times on October 30, 2022, and the average slippage was 54.41 basis points.

Gains Network

We set the total DAI amount required to take a 100 ETH position with 10x leverage and captured the price impact directly from the Gains DApp. We conducted observations on November 5, 2022, and November 22, 2022, and observed an average slippage of 10.5 basis points.

Collecting D8X Slippage Data: Agent-Based Simulation

The simulation mimics the D8X's AMM. The perpetual index price is obtained from the historical data of the corresponding perpetual contract. Participating agents include liquidity providers and traders. Liquidity providers randomly add funds to the system and then withdraw funds after a deterministic holding period. Traders have randomized individual trading preferences in terms of cash holdings, leverage selection, long/short selection, trading frequency, and have different trading strategies. These strategies include momentum trading, noise trading (which is not essentially a strategy), and arbitrage traders who compare the perpetual contract price to the index when deciding whether to trade.

We parameterize the simulation so that the number of traders increases over time, simulating up to 1,000 traders by the end of a quarter. Finally, we selected a good period similar to what our competitors evaluated and averaged the slippage.

Holding cost data

For exchanges with classic funding rates, we assume a funding rate of 1 basis point every 8 hours.

Rather than charging a mandatory funding rate, GMX charges a borrowing rate that covers all holding costs. We average historical borrowing rates from August 30, 2022, to October 30, 2022, and the result is 0.32 basis points/hour.

For Gains Network, we observed flip fees on November 5, 2022, and November 22, 2022, averaging 0.86 basis points. These fees are applied to collateral deposits, not notional positions, so at 10x leverage they are roughly equivalent to applying 0.09 basis points per hour to position size. These flip fees are added to our assumed funding rate, and in line with other exchanges that impose a funding rate, we assume a funding rate of 1 basis point every 8 hours, resulting in a calculation of 0.215 basis points per hour. Carrying costs.

Gas fee data

CEXs, including Binance, have no gas fees, and executing trades on dYdX does not involve any gas fees.

For other DEXs, we collected gas fee data from Dune Analytics:

  • Perpetual protocol: Average gas fee between October 22, 2022 and November 11, 2022: $0.12

  • GMX: Average gas fee between October 22, 2022 and November 11, 2022: $0.11

  • Gains Network: We were unable to find a reliable data source specifically tracking the gas fees associated with executing transactions. Given that Gains Network runs on Polygon, we assume the gas fee is comparable to D8X.

  • According to the Testnet data we collected between November 11, 2022 and November 22, 2022, the average gas fee of D8X is $0.0015.

Given the position size of 100 ETH, the observed gas fees are insignificant and we will exclude them from the analysis that follows.

result

The chart below shows that total transaction costs vary widely, from a high of 129bps (=1.29%) to 11bps.

Figure 4: Transaction costs
  • For AMM-based exchanges Perpetual Protocol and Gains Network, the total transaction costs reached 129bps and 53bps respectively. Most of these costs are related to the high slippage that traders face. High slippage is a result of the pricing method used by AMMs.

  • For GMX, transaction costs remain high (22bps), and more importantly, the costs become higher the longer you hold a position. While high carrying costs may not affect speculative traders who flip positions in the short term, they do affect (institutional) investors who wish to hedge using perpetual contracts.

  • For dYdX, the total transaction cost is lower (15bps) compared to AMM-based DEX. This result is primarily due to relatively low slippage, which dYdX achieves through its order book. But please note that the order book is off-chain.

  • Compared to the DEXs mentioned above, CEX has lower fees. Figure 4 shows that Binance charges 11bps transaction fees. The majority of these transaction costs are due to fixed transaction fees. Because unlike AMM-based DEXs, CEXs do not make money from slippage, fixed trading fees are usually the main source of revenue they use to maintain their services.

  • D8X offers low fees that compete with Binance, while being fully decentralized and non-custodial. Among the exchanges we studied, D8X is the one that offers the best trading conditions in the DeFi and CeFi sectors.

To learn how D8X provides these competitive prices, stay tuned for our upcoming introduction to the D8X Perpetual Contract.

references

[1] Barbon, Andrea, and Angelo Ranaldo. “On The Quality Of Cryptocurrency Markets: Centralized Versus Decentralized Exchanges”

[2] BitMEX, “Perpetual Contracts Guide”

[3] GMX, “Decentralized Perpetual Exchange”

[4] Gains Network, “Rollover & Funding Fees”

[5] Perpetual Protocol, “Perpetual Protocol”

[6] dYdX

[7] Blogmates, “What is dyDx, the DYDX Token & dYdX Chain?”

[8] Joshua Lim, “Quick thread on the GMX ‘exploit’ last night”

[9] Gains Network, “gTrade v6.1: In-depth”

[10] Perpetual Protocol, “How Perp V2 Works”

[11] Perpetual Protocol, “Trading Fees and Gas Fees”

[12] GMX, “Trading”

[13] Binance, “Trading Fees”

[14] dYdX, “Fees”

[15] Gains Network, “Low trading fees”

[16] dYdX, “Perpetual Order Types”

[17] Dune, “Avg OP Gas Fee — Last 30 Days”

[18] Dune, “Cost-of-transactions-on-gmx-arbitrage”

Copyright statement: The content of this article is provided by D8X.Exchange and may not be reproduced without permission.

risk warning

Nothing contained herein constitutes an offer, invitation or recommendation to sell, buy or recommend securities or other products (tokens) or services, whether or not such securities, products (tokens) or services are mentioned herein.

Original English information: https://medium.com/@d8x.exchange/are-defi-perpetual-futures-more-expensive-than-their-cefi-counterparts-81d4a813fe9d