• Basic definition and process of Swaps: Swaps are the most commonly used interaction method with the Uniswap protocol, allowing users to exchange one ERC-20 token for another without permission, with transaction fees rewarded to liquidity providers.


  • Differences from traditional order books: Swaps do not match discrete orders but interact directly with liquidity pools, with the transaction price determined by the liquidity in the pool and the AMM algorithm, allowing liquidity providers to share fees based on their capital allocation.


  • Price Impact mechanism: During a swap, asset prices dynamically change due to the distribution of funds in the liquidity pool, leading to differences between the actual transaction price and expectations. The more abundant the liquidity, the smaller the price impact; conversely, the less liquidity, the greater the impact.


  • Slippage: Slippage refers to the risk of price changes occurring from the time a transaction is submitted to when it is executed. Users can set their slippage tolerance, and if the actual transaction price exceeds this range, the trade will automatically fail to avoid extreme losses.


  • Safety checks to protect user rights: The Uniswap protocol has built-in safety mechanisms, such as automatic cancellation of expired transactions and protection for users when output amounts are insufficient, helping users avoid risks from drastic market fluctuations or delays.


What is a Swap?

A swap is the most common way to interact with the Uniswap protocol. For users, the swap operation is very simple: users choose one ERC-20 token they hold and the other token they wish to exchange for.

  • When executing a swap, the system will sell the tokens currently held by the user in exchange for a proportionally calculated amount of the target tokens, deducting the transaction fees, which will reward the liquidity providers. Conducting a swap through the Uniswap protocol is a permissionless process.


  • Swaps conducted through the Uniswap protocol differ from traditional order book trading in that swaps are not matched with discrete orders on a first-come, first-served basis, but rather transact with a passive liquidity pool. Liquidity providers earn fees proportional to their contribution of funds.


Price Impact

In traditional order book markets, a large market buy order may consume all liquidity of the previous limit sell order and continue to execute at a higher price with the next limit sell order. Therefore, the final transaction price is usually between these two limit sell orders.

  • Price impact can also affect the execution price of swaps, but its causes are different. When using an Automated Market Maker (AMM), the price of one asset relative to another continuously changes during the execution of a swap, and the final transaction price will fall between the relative prices at the start and end of the exchange.


  • This dynamic affects every swap conducted through the Uniswap protocol, as it is an inseparable part of the AMM design.


  • Due to the varying liquidity available at different price points, the price impact for a specific swap size will change based on the amount of liquidity available at that price point. The more abundant the liquidity at a price point, the lower the price impact for the same swap size; conversely, the less liquidity, the greater the price impact.


  • The Uniswap front-end interface provides real-time estimates of the price impact. If there is an unusually high price impact during the swap process, a corresponding warning will be issued. Any user executing a swap can evaluate the price impact situation as needed.


What is Slippage?

When using the Uniswap protocol for swaps, another important detail to consider is slippage. Slippage refers to the potential price changes that may occur after a transaction is submitted and before it is executed.

  • When a transaction is submitted to the Ethereum network, the execution order of the transaction is determined by the 'Gas' fees paid for each transaction. The higher the Gas fee, the faster the transaction is executed. Transactions with lower Gas fees will wait in the mempool for an uncertain amount of time, during which the market price environment may change due to other swaps occurring.


  • Slippage tolerance sets the acceptable price change range for users beyond the price impact. As long as the actual execution price is within the slippage tolerance range (e.g., 1%), the transaction will be executed. If the execution price exceeds the acceptable slippage range, the transaction will fail, and the swap will not occur.


  • In traditional markets, a similar situation occurs when a market order is filled at different prices due to delays. When users submit a market order, they can expect a certain execution price, but during the time from submission to execution, the price may have changed.


Safety Checks

Both price impact and slippage may change during the pending transaction period, so the Uniswap protocol has built-in multiple safety checks to protect end users from drastic changes in the swap execution environment. Common safety checks include:

  • Expired: If a swap remains pending for longer than the preset deadline, it will error out and be canceled. The deadline is set to prevent trades from being unexecuted for long periods, avoiding risks due to significant price changes over time.


  • INSUFFICIENT_OUTPUT_AMOUNT: When a user submits a swap, the Uniswap interface provides the expected amount of target tokens the user will receive. If the actual amount received is not within the slippage tolerance range, the swap will be canceled. This mechanism is designed to protect users from significant adverse price fluctuations during the pending transaction.

#币安Alpha上新 #BNB创新高 #Strategy未增持BTC #ETH重返3800 #币安HODLer空投TREE $SOL $XRP $ETH