Summit Class: Uniswap
顶峰AscendEX
2022-05-03 05:31
本文约2334字,阅读全文需要约9分钟
Uniswap is a decentralized financial application (DeFi) built on the Ethereum public chain, allowing people to conduct automatic token exchange transactions in a decentralized manner.

secondary title

What is Uniswap?

smart contractsmart contract, and the main function of this smart contract is to automatically perform token exchange.

secondary title

Function of Uniswap

As mentioned above, Uniswap is essentially a decentralized exchange, so its basic function is to provide cryptocurrency trading services. Through this agreement, traders do not need to escrow funds, and can conduct swap transactions between multiple tokens. The token transaction price is automatically calculated by the protocol algorithm.

secondary title

How Uniswap works

Uniswap uses a liquidity pool and a constant product market maker model to provide real-time quotes and token trading services for different encrypted assets.

Liquidity pools are all tokens and funds locked in smart contracts. It can be simply understood that each liquidity pool in the Uniswap protocol actually corresponds to a trading market composed of a trading currency pair. For example, the ETH/USDT liquidity pool means a trading market composed of ETH and USDT trading pairs. In this fund pool, users can deposit ETH to exchange for USDT in the pool, and vice versa, they can also deposit USDT to the pool to exchange for ETH. Typically, a liquidity pool consists of two tokens. In Uniswap V1, tokens are composed of: ETH and different ERC20 tokens. In V2 and subsequent versions, it supports direct exchange transactions of different ERC20 tokens.

The constant product market maker model is the core mechanism of the Uniswap protocol, which is a variant of the automated market maker (AMM) model. Its operation is based on the following formula:

X*Y=K (K is constant)

Among them, X represents the amount of one token in the fund pool, Y represents the amount of another token in the pool, K is a constant constant whose value is determined by the amount of X and Y deposited together, and specifically refers to The initial deposit of two equivalent tokens by the liquidity provider is determined. Afterwards, if a user exchanges tokens in the pool, the protocol will automatically calculate the buying and selling price of the tokens according to the number of tokens in the liquidity pool.

To facilitate understanding, assume that user A creates an ETH/USDT fund pool by simultaneously depositing 10 ETH and 30,000 USDT on Uniswap. According to the constant product formula, the constant K of the pool at this time is 10*30000=300000.

secondary title

UNI

secondary title

Advantages and Disadvantages

  • The advantages of this agreement are mainly manifested in:

1. Ease of use.When conducting token transactions through the Uniswap protocol, users only need to decide on the currency to buy or sell, and the corresponding buying or selling quantity, click Swap transaction, and the target currency can be obtained immediately after the data on the chain is processed. And generally speaking, any two currency exchanges can be completed with only one transaction, without the need for multiple exchanges with intermediate currencies.

2. Gas usage efficiency is high.Thanks to its constant product market-making mechanism, Uniswap requires less calculation to calculate the transaction price of the corresponding currency, and the amount of Gas it consumes is correspondingly lower, so the miner fee required to pay for transactions on Uniswap is also less.

3. High degree of censorship resistance and decentralization.Censorship resistance is mainly reflected in the fact that there is no threshold for listing new coins on Uniswap, and anyone can create a fund pool by depositing tokens. Decentralization is reflected in the fact that users can conduct transactions without custodial funds.

  • The advantages of this agreement are mainly manifested in:

1. Cannot decide the price of token buying and selling by itself.When trading on Uniswap, the transaction price of tokens is automatically calculated by the agreement according to the market-making mechanism, and individuals cannot choose. Compared with centralized exchanges, it can be understood that the transaction cannot execute the limit order mode.

2. High transaction costs.The transaction fee of 0.3% is relatively high compared to general centralized and decentralized exchanges.

3. Front-running deals.Due to the transaction on-chain process, other people (such as miners) have the opportunity to execute another transaction to make a profit before your transaction is completed, which will cause your transaction transaction price to deviate from expectations.

4. Impermanence loss.This is mainly for liquidity providers. To put it simply, if you become a Uniswap liquidity provider, you may suffer a certain loss due to the sharp rise or fall in the currency price and the change in the currency exchange price when you exit.

顶峰AscendEX
作者文库