Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

The main use case that users find in the Ethereum blockchain is the ability to exchange encrypted assets without an intermediary. A decentralized exchange or DEX is the platform used for this activity. They can be summarized as an application that allows you to exchange ETH or any token for other tokens using the liquidity available in their pool.

Decentralized exchanges represent the most extensive gas consumption on Ethereum. According to TheBlock’s statistics, the contract (code segment) related to token exchange is one of the contracts that consumes the most blockchain resources.

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Source: TheBlock

Although these systems have permissionless nature, amazing numbers, and undisputed success, operating on the chain is costly and burdens some users. Transaction costs can be broken down into several different cost elements:

  • Price impact
  • Liquidity provider fees
  • Slippage
  • Transaction fees of the underlying blockchain

Understanding these costs is critical to capital efficiency and can save thousands of dollars for users who make the right choice.

The DEX industry has several alternative protocol applications for users to choose from, and they provide the same core service of token exchange. This article aims to compare the cost of transaction fees for the last item when using different indices available in the market.

Why is there a difference in gas cost between transaction and DEX?

Any on-chain operation needs to be priced according to the amount of computing resources it consumes. In the Ethereum network, gas is a unit used to measure the computational workload used to perform each specific operation, and directly affects transaction costs. Since each protocol adopts different methods and needs to perform different functions to exchange, the consumption of each transaction/protocol is also different.

A transaction can call any number of functions and interact with many different smart contracts. Below, we can see the gas consumption details of two different transactions using the tools provided by Tenderly. As you can see, the second transaction ultimately costs 70% more gas than the first transaction.

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Gas segmentation of two general exchange transactions

Comparative method

Each DEX has its own method of performing exchanges, but some patterns can be determined between them. In order to compare the gas cost of transactions between different DEXs, one is selected respectively. UniswapV2 represents the traditional constant product pool. UniswapV3 introduces a centralized liquidity pool, chooses Curve as its hybrid and custom curve pool, and finally chooses BalancerV2 with a weighted pool. For each of them, a Dune dial is set:

The dashboard allows to check each pool individually by entering the pool address in the selection box. It also has a transaction table to filter outliers for more detailed investigation.

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

DEX gas comparison dashboard

When analyzing multiple mining pools of a protocol, only mining pools with more than 100 transactions that meet the above criteria will be drawn to obtain more relevant results. When analyzing transactions that interact with a single pool, the transactions are grouped by the number of hops involved in the exchange.

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Transactions involving multiple exchanges

Exchange execution can be wrapped in a transaction that also executes other codes. In order to eliminate this effect, only the transaction of directly calling the protocol vault/router contract is analyzed. This filter is used to exclude transactions routed by DEX aggregators and contracts, which are bundled with multiple functions that increase transaction costs but are not related to the DEX protocol itself.

Balancer

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Balancer pool distribution

Most of Balancer’s transactions come from DEX aggregator applications, such as 1inch, Metamask, etc. Since these transactions are excluded from analysis, this naturally reduces the amount of data available. Despite this, there are still 14 mining pools that meet the criteria for at least 100 direct invocation transactions. As expected, when evaluating each pool individually, you can see a significant difference between single-hop exchange and multi-hop exchange. Another finding is that the number of tokens in the pool does not change the gas expenditure of transactions using it. It is important to remember that the V2 token pool in Balancer may or may not act as an oracle-if they do, the gas cost will be higher when the memory slot that stores the price data is initialized. This can be viewed on the moving average chart of these pools. Note how the average value suddenly drops once all the memory slots have been initialized.

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

They are LINK/WET, USDC/WETH

And WBTC/WETH pool distribution

Curve

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Curve pool distribution

From the DEX studied in this article, Curve has its own unique mechanism, which makes the comparison sometimes unbalanced. Each Curve pool (except metapool) is customized for its assets.

Curve shows the most significant difference in gas consumption between the analyzed DEX. This is partially explained because Curve allows the exchange of unpackaged tokens, such as DAI or USDC, and the fund pool is designed to not rely on other protocol IOUs, such as cDAI or yUSDC, and the packaging and splitting process is part of the transaction. As a result, although the assets in the pool of funds benefit from these agreements, it makes the transaction quite expensive.

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

The distribution of 3pool, renBTC and Tricrypto pools respectively

Uniswap V2

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

UniswapV2 pool distribution

In addition to being the oldest protocol on this list, UniswapV2 is also widely adopted. More than 2500 fund pools have been created in the agreement to serve the long-tail market of assets. There are some limitations when drawing the above figure, but they can describe the gas cost in the protocol. Some of the most popular tokens, such as stablecoins and BTC, are widely used in multi-hop exchanges in transactions such as ABC<->ETH<->WBTC. Sometimes ABC transfers are gas intensive, which increases the average gas used in transactions involving these popular tokens. Once again, when investigating each pool of funds, the most significant difference between transaction gas usage can be allocated to the number of hops performed by each transaction.

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

They are LINK/WET, USDC/WETH

And WBTC/WETH pool distribution

Uniswap V3

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

UniswapV3 pool distribution

One of the biggest concerns of version 3 of the Uniswap protocol is that exchange transactions may cost more gas. Uniswap V3 transactions are affected by the price caused by it. The higher the order relative to the available liquidity, the more it will push the price across time. The discrete price range represents a 0.0001% price increase or decrease, in which liquidity needs to be adjusted. Since most transactions have a relatively small impact on prices, the median transaction cost is consistent with the previous version. However, when dealing with a moderate liquidity pool, users need to pay attention to the impact of orders on prices.

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

They are LINK/WET, USDC/WETH

And WBTC/WETH pool distribution

Comparison Agreement

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Gas cost per protocol

Three identical digital pools shared by Balancer V2 and Uniswap V2 and V3 were selected for detailed comparison-USDC/WETH, WBTC/WETH and LINK/WETH. Because Curve’s method is different, it chose some of its fund pools to integrate into the picture, but it will not participate in the comparison.

It can be observed that there is no significant difference in the gas consumed between the 3 DEX. The observed difference may be related to the imprecision of the method chosen for the study. For a 2-hop transaction, the difference can be attributed to the second-order effect of the transfer function in one of the token contracts involved in the transaction.

In addition, here is a table that calculates the cost (in U.S. dollars), the current ETH price and the approximate difference observed between DEX. From one point of view, in the $2,000 ETH scenario, the gas is 50gWei, and the difference of choosing Uniswap V2 instead of V3 for the WBTC/WETH 2-hop exchange will save $3.12. If the order amount exceeds 1040 US dollars, the 0.3% LP fee is usually higher than this difference.

Comparison of gas fees of major DEX: the number of hops performed by the exchange is the key indicator that affects the gas difference

Gas cost in different scenarios

in conclusion

The study showed that there were no significant differences between the analyzed DEX. The biggest impact on the gas used by the exchange is the number of hops that must be performed to execute the exchange. The difference between 1-hop and 2-hop transactions is more meaningful than the difference between DEX. In addition, depending on the size of the transaction, other factors of transaction costs, such as LP fees or slippage, may have a more significant impact on the total cost.

Although Curve has some very competitive capital pools in terms of gas expenditures, some of these capital pools are designed with the underlying protocol IOU, and the packaging and unfolding process has a significant impact on their transactions.

Analysis considerations

Executing a transaction usually means calling the transfer function of the participating token contract-the exception is due to Balancer’s single vault model or the use of internal user balances in the Balancer vault, while multi-hop transactions are performed on Balancer. Some tokens can perform more than simple accounting when calling the transfer function, which increases the cost of the transaction. The practical method of using Dune to eliminate this influence has not yet been fully realized. This behavior is especially worrying when the transaction executes multiple hops to exchange and one of the tokens performs poorly. Although, it is believed that this problem will systematically affect all agreements, and rarely will significantly affect the results. Limiting the scope of analysis to single-hop transactions per token pool can mitigate this impact.

Since some protocols have thousands of transactions from the beginning, processing such a large amount of data in the Dune/Internet browser will greatly reduce the usability of the dashboard. Therefore, in these agreements, limits are imposed on the number of transactions analyzed. However, the reduction in the data population will not significantly change the results. For a single pool view, the upper limit of the dashboard is 1000 transactions. Uniswap V2 is limited to transactions in the last month.

Posted by:CoinYuppie,Reprinted with attribution to:https://coinyuppie.com/comparison-of-gas-fees-of-major-dex-the-number-of-hops-performed-by-the-exchange-is-the-key-indicator-that-affects-the-gas-difference/
Coinyuppie is an open information publishing platform, all information provided is not related to the views and positions of coinyuppie, and does not constitute any investment and financial advice. Users are expected to carefully screen and prevent risks.

Like (0)
Donate Buy me a coffee Buy me a coffee
Previous 2021-07-27 09:31
Next 2021-07-27 09:36

Related articles