Every day, hundreds of thousands of people are using decentralized exchanges for the first time. However, the nature of public chains can often catch newcomers off guard, even those familiar with traditional markets. The result is that traders’ money flows to arbitrageurs and front-runners, causing their operations to suffer unintended consequences. On a macro level, we can break down the costs of each transaction into several parts: 1. Price shock 2. Intermediate fee or transaction fee 3. Sliding point 4

What is a liquidity pool?

The liquidity pools of most decentralized exchanges represent different trading pairs, such as ETH/WBTC. Instead of matching buyers and sellers in order books, these liquidity pools exist as Automated Market Makers (AMMs). A liquidity pool is a smart contract that stores two or more tokens and allows anyone to make deposits and withdrawals from it, but subject to specific rules. One of these rules is the constant product formula x * y = k, where x and y represent the reserves of tokens A and B. In order to withdraw A certain amount of Token A, the user must deposit A proportional amount of Token B to maintain A constant K value (note: the cost of each transaction causes the K value to rise slightly).

How is AMM priced?

According to the constant product formula, the price of token A can be obtained simply by dividing the amount of token B by the amount of token A (PRICE_TOKEN_A = RESERVE_TOKEN_B/RESERVE TOKEN_A). What is the price shock?

Although we learned how to calculate the current market price based on the reserve ratios of the two tokens, this market price only represents the marginal price of tokens that AMM wants. In practice, however, traders typically buy and sell many tokens at once, with each unit costing more than the previous one. Price impact is the difference between the current market price and the expected transaction price. Price shocks are the result of two factors:  the size of your trading volume as a percentage of the liquidity pool;  Trading rules used by liquidity pools (e.g. constant product formula). How to minimize price shocks? Defi- Decentralized Finance – Decentralized Application – DAPP As we mentioned earlier, price shocks are a large part of the total execution cost of a transaction. Here are some simple strategies that can minimize price shocks:  Find the market with the best depth: So far, we have determined that price shocks depend on the size of the transaction as a percentage of the liquidity pool or market size. Therefore, we want to find the trading pool that is the most liquid within a certain price range so that the transaction price is as close to the market price as possible. The market depth table on Coingecko is a good place to start. Focus on markets outside of DEFI: While this is an article on automated market makers, we know that users don’t always get the best trade execution on the chain. In fact, since the liquidity of automatic market makers in question is distributed over a continuous price range, there is usually very little liquidity concentrated near current market prices. This is a problem that many decentralized exchanges are trying to solve. Uniswap V3, for example, allows market makers to concentrate their liquidity near current market prices, thus offering prices that are more competitive than those offered on centralised exchanges. [This article was compiled and published by qkljys123.]