BTC
ETH
HTX
SOL
BNB
View Market
简中
繁中
English
日本語
한국어
ภาษาไทย
Tiếng Việt

How to Understand Price Shocks in Automated Market Makers

ECN以太坊中国
特邀专栏作者
This article is about 3517 words, reading the full article takes about 6 minutes
Price shock, which is the difference between the current market price and the expected transaction price.
AI Summary
Expand
Price shock, which is the difference between the current market price and the expected transaction price.


Source | research.paradigm.xyz



Author |


Thousands of people use decentralized exchanges for the first time every day. However, the nature of public chains often catches novices, even those familiar with traditional markets, by surprise. The result is that traders' money flows to arbitrageurs and frontrunners, causing their operations to be affected in an unexpected way.

On a macro level, we can break down the cost of each transaction into several components:

  • price shock

  • Slippage

  • Slippage

  • Transaction fees on the underlying blockchain


This article on automated market makers (AMMs) serves as an introduction to the series and discusses the first and most critical cost: price shocks. Readers will learn:

  • Uniswap v2,How Sushiswap and Balancer's AMM mechanism determine the price

    Note: Other DEXs that use centralized order books (such as Serum) or batch auctions (such as Gnosis) are not discussed in this article)

  • first level title











What is a liquidity pool?


automated market makerautomated market maker (AMM,automated market maker) exists.

A liquidity pool is a smart contract in which two or more tokens are stored and allows anyone to make deposits and withdrawals, subject to specific rules.

One of the rules isConstant product formula x * y = ksecondary title



How are AMMs priced?




image description



Table 1: Different AMM formulas produce different price curves. Assuming a Uniswap v2 liquidity pool has 15 Y tokens, it will only pay 0.1 X tokens for the marginal Y tokens. But it pays 4.0 X tokens when there are only 2.5 Y tokens. Other price curves are designed to concentrate more liquidity at a certain price (e.g. 1.0 for stablecoins). Source: Curve white paper

As a real example, Uniswap has 2,700 WBTC and 86,000 ETH in the ETH/WBTC pool at the time of writing. This reserve rate means that the market price of ETH at that time is 2,700 / 86,000 = 0.0314 WBTC.

Crucially,AMM will not update this price as other markets move. The market price will only change as the rate of token reserve in the pool changes when someone transacts in it.

As an example, what would happen if the price of ETH in Binance dropped to 0.0310 WBTC? This means that Uniswap LPs are currently buying ETH at a premium, creatingarbitrage opportunity. Arbitrageurs buy "cheap" ETH on Binance and sell it on Uniswap for a profit. They will keep doing this until the Uniswap ETH unit price becomes 0.0310 WBTC (same as Binance), and they can no longer profit by selling ETH. In our example above, this would happen after selling 550 ETH to the exchange pool for 17.2 WBTC (ignoring fees and gas for simplicity).

first level title











What is a price shock?


Although we learned how to calculate the current market price based on the ratio of the two token reserves, this market price only represents what the AMM wantsMarginal Token Price. In practice, however, traders typically buy and sell many tokens at once, each at a higher cost per token than the previous one.

The difference between the current market price and the expected transaction price is the price shock (price impact)。

Price shocks are the result of two factors:

  • The proportion of your trading volume in the liquidity pool;

  • image description



image description



first level title











How to minimize price shocks?


As we mentioned earlier, price shocks represent a significant portion of the total execution cost of a trade. Here are some simple strategies that can minimize price shocks:

  • Find the market with the best depthimage description





Table 4: Liquidity ranking of UNI trading pairs within 2% of market price difference. Note the difference in Uniswap and Bitfinex spreads. Source: Coingecko

  • Focus on markets beyond DeFi: While this is an article about automated market makers, we know users don't always get the best trade execution on-chain. In practice, since the liquidity of the AMM in question is spread over a continuous price range, there is usually little concentration of liquidity around the current market price. This is a problem that many decentralized exchanges are trying to solve. For example, Uniswap v3 allows market makers to concentrate their liquidity around the current market price, thereby providing more competitive prices than centralized exchanges.

    If there is a transaction that changes the price of a token on a decentralized exchange, and that token is still being traded on other markets, an arbitrage opportunity arises. As mentioned above, arbitrageurs will tail trade (i.e. insert their own trade immediately after a trade) to bring the price on the decentralized exchange back to the global market price. Clearly, the very existence of arbitrage is evidence of poor execution, as the trader is effectively donating funds to the arbitrageur. This begs the question: Should you accept price shocks of more than 2%-3% to execute on-chain transactions when other markets exist?

  • Be aware of transaction fees: Automated market makers charge a transaction fee of 0.3%, which means that the spread between the best buy order and the best sell order is 0.6%. Within this range, automated market makers will not quote. In other words,A 0.3% price shock is evident in even the most liquid AMM trades. Keeping transaction fees as low as possible is critical, especially for transactions that are insignificantly affected by price shocks on centralized exchanges, so it is safe to say that centralized exchanges may be better trade execution platforms. (For comparison, the same transaction fee might be 0.1% on Binance and 0.07% on FTX exchange)

    Still, there are other reasons why decentralized exchanges are more expensive, such as full custody, KYC or deposit processes, etc. But even in these cases, traders should be aware that behind the higher transaction pricesDecentralization or Instant Liquidity Premium。

  • Decentralized transaction: First, we can decompose a transaction into several smaller transactions and complete them one after another. This is especially important for traders who prefer to use decentralized exchanges, regardless of the fact that there are other liquid markets outside of the DeFi space. For example, buy 20% each time, and then wait for the arbitrageur to recover the price. The combined price impact of these 5 transactions is lower than one large transaction, but the gas cost will be higher and the execution time will be longer. The larger the size of the transaction, the more advantageous this strategy is because the fixed gas cost decreases with better marginal execution. This strategy works equally well for mean recurring assets like stablecoins.

  • Direct transactions are not necessarily cheaper: Not every transaction has a direct transaction pair, and even if it exists, it is not necessarily better than usingintermediate currencycheaper. For example, while there is a direct trading pair for tokens A and B, the A → ETH → B trading route is usually cheaper when the A-ETH and ETH-B token pairs are more liquid. In terms of trade routes, the aggregator's advice is very helpful.

  • Using a decentralized exchange aggregatorimage description



Table 5: Optimal strategies for buying 10 ($3,200), 50 ($16,000), 100 ($32,000), and 200 ($64,000) AAVEs with ETH. The larger the transaction size, the more exchanges will be included in the transaction path to avoid excessive impact on a single liquidity pool. Source: 1inch












notice


In the second article in this series, we will discuss slippage. Nearly all AMM trades get front-run, ending up with as much slippage as a trader is willing to accept. This is a unique "feature" of public chain transactions, which cannot be avoided in today's decentralized exchange model. This cost can only be transferred, leading to the "sandwich dilemma".


Acknowledgments: Thanks to EvanSS, Georgios Konstantopoulos, Dave White, Dan Robinson, Arjun Balaji, and raul for discussion and review.

ETH
Safety
Developer
Welcome to Join Odaily Official Community