Is there room for improvement in the gas consumption of Ethereum DeFi?

Loading

Now that the value of DeFi has been discovered, people’s trading activity has greatly increased, and the price of Gas has also risen. Each project party has the obligation to complete the business with the least read and write operations, saving valuable block space for the Ethereum ecosystem. In addition, each project party is also obligated to find a cheap and safe L2 solution for users.

Written by: Lei Mingda, founder of DODO

I will introduce the Gas issue here.

Gas usage mechanism

First of all, Ethereum’s Gas is a prepayment mechanism. During the use of DEX, you will see three Gas values

A. Gas displayed on the front end of DEX

B. Gas limit seen when signing the wallet

C. Real Gas consumption seen on Etherscan

For example, you go to a hotel:

A. The hotel price seen on Ctrip is estimated at 1000

B. The hotel wants to pay you 3000 in advance

C. Check out when you leave, the accommodation plus drinks really cost 1,200

Below we first focus on the real consumption, and then discuss how to make this figure as realistic as possible to show users.

What is Gas expensive?

The transaction we are talking about used 100 US dollars Gas, which refers to:

“Gas * GasPrice * ethPrice”

Here, the GasPrice is determined by the user. If you want to make a quick transaction, you will spend more, and if you don’t worry, you will spend less. ethPrice is determined by the market.

What is really affected by the product is the gas consumption itself. So to really understand Gas in depth, the basis of our discussion is to change from USD to Gas quantity.

The concept of magnitude

So where is Gas mainly consumed?

Two parts: 1. Data writing 2. External call

The so-called Gas optimization refers to the use of as little data writing and external calls as possible to complete business logic.

Writing data costs about 20,000~5,000 Gas, and contract calls cost about 3,000 Gas. This is the largest part. Due to the complexity of the calculation execution environment, in the production environment, all the gas consumption mentioned below will fluctuate in a small range. .

  • An ERC 20 transfer involves two writes and costs approximately 60,000 Gas

  • An ERC 20 Approve involves a write and costs approximately 45,000 Gas

  • A Uniswap single hop transaction costs approximately 110,000 Gas (eg USDT→ETH)

  • A Uniswap two-hop transaction costs approximately 170,000 Gas (eg USDT→ETH→UNI)

  • A Uniswap three-hop transaction costs approximately 230,000 Gas (eg USDT→ETH→WBTC→LINK)

It can be seen that, also in Uniswap, there may be a huge gap in gas consumption for one swap!

This is still in the case of a very simple routing strategy. If the routing strategy starts to become complicated, such as 1inch or Matcha, the gas of a transaction can float between 150,000 and 1,000,000.

Therefore, one cannot simply say that gas on a certain platform is expensive.

It seems that the gas of the aggregator is much more expensive than Uniswap, shouldn’t the aggregator be abandoned?

This is not the case.

Although Gas is expensive, aggregators are not stupidly expensive. Expensive because there is extra logic to execute, and these extra logic will bring great profits. If the profit can cover the additional cost of Gas, then an aggregator should be used.

In the past, aggregators may not care much about Gas, but now the increase in Gasprice and Ethereum prices has increased Gas’s dollar spending by 100 times. So in DODOV2, we will comprehensively compare Gas and quotation, and give the solution with the lowest average cost.

DODO is expensive

Expensive, not expensive.

When DODO performs routing, it will outsource a layer of function calls to the original liquidity, which is about 40,000 gas more expensive than the liquidity source.

but:

  1. After gas subsidies, DODO’s gas consumption can be the same as or even cheaper than liquidity sources.
  2. Taking into account the advantages of the quotation, although the cost of Gas is large, the average cost is the lowest in DODO.

How to display Gas reasonably

Recall the previous hotel example.

If you are Ctrip, your goal is to show the user’s actual spending as truthfully as possible.

Ordinary users have already been educated, and when they go to stay in a hotel, they will definitely get more pre-authorization than they consume, and they won’t care too much.

A. Gas displayed on the front end of DEX

B. Gas Limit seen when signing the wallet

C. Real Gas consumption seen on Etherscan

But Ethereum users are far from understanding these mechanisms. They don’t know that the wallet pops up with pre-authorization. If you display the number C directly on the web page, but the number B popped up by the wallet is very large, the user will be very confused.

Therefore, the number B will be displayed on DODO’s webpage first to ensure unity with the wallet. Then display the number C to ensure that users are not discouraged.

Here 0.084 is the number A, which is the wallet pre-authorization. 0.084-0.042 is the number C, that is, DODO estimates your real expenses. In this scenario, your real cost is about the same as Uniswap single hop.

Is there room for improvement in the gas consumption of Ethereum DeFi?

Is there room for improvement in DODO’s Gas?

Yes, it is mainly reflected in the following aspects in DODOV2:

  • Comprehensive comparison of Gas and quotation, to avoid the quotation advantage, but the user’s interests are damaged due to the excessively expensive Gas;
  • Improved routing to reduce upper-layer calculation overhead;
  • Gas optimization of the V2 pool to reduce lower-level computing overhead;
  • More accurate Gas Price estimation, allowing users to accurately jump in the queue (this is thanks to the Gasnow service of Spark Mine Pool);
  • Support BSC, L2 parallel migration.

to sum up

Gas is a pain that all projects can’t avoid, this is a happy trouble. I have experienced the bleak time of Ethereum 1 gwei packaged transactions. At that time, on-chain transactions were like no money, but life was very difficult.

Now that the value of DeFi has been discovered, people’s trading activity has greatly increased, and the price of Gas has also risen. Each project party has the obligation to complete the business with the least read and write operations, saving valuable block space for the Ethereum ecosystem.

In addition, each project party is also obligated to find a cheap and safe L2 solution for users.

DODO has always regarded the Gas issue as a scientific research project and is in the first echelon of scientific research. We expect users to experience the gas optimization brought by V2 as soon as possible, and welcome any suggestions on gas optimization.

Disclaimer: As a blockchain information platform, the articles published on this site only represent the author’s personal views, and have nothing to do with ChainNews’ position. The information, opinions, etc. in the article are for reference only and are not intended as or regarded as actual investment advice.

Let’s block ads! (Why?)