Uniswap is a very interesting project launched on Ethereum. It is a open source decentralized token exchange protocol, but very different from the general protocol currently seen. Uniswap is a set of smart contracts deployed on the Ethereum network where the entire process is performed on the chain.
It does not have its own token, completely decentralized, and there is no fee to the founder. Although its mechanism takes some time to get used to, we will find that this token trading protocol has some significant advantages compared with traditional decentralized exchanges (DEX).
Uniswap's unique structure completely got rid of the concept of limit orders. What is unusual is that market makers no longer specify the transaction price when providing liquidity, but only provide funds, and Uniswap will take care of the rest.
On a typical traditional exchange like Coinbase, market makers often provide different liquidity at different prices. Suppose a trader has 1,000 USD and 10 ETH in hand. He may buy 5 ETH at 80 USD and 10 ETH at 60 USD to place a buy order. At the same time, he may sell 4ETH at $120 and 6ETH at $140 to place a sell order.
They will choose to make the market at various prices they are willing to trade. In general, all traders' pending orders form the exchange's limit order book. As market conditions rise or fall, traders may or may not trade at their designated price. Generally speaking, the "quotation" of ETH is the middle value of the highest buy order and the lowest sell order.
Now suppose that Coinbase aggregates everyone's buy and sell orders into two large trading pools-as you can imagine, some traders may not like this approach. They don't want their orders to be mixed with others, or they don't want Coinbase to execute transactions at any price on their behalf. However, Uniswap does that exactly. Market makers no longer specify the price at which they are willing to buy or sell ETH.
On the contrary, it will pool everyone's current assets together and make the market according to a certain algorithm. This algorithm is called the "Automatic Market Maker" (AMM), and it will offer prices to end users based on some predefined set of rules. Take a very simple example of AMM: A certain trading robot strategy will be based on the median value of the market price, and will provide buy and sell orders every 1 US dollar, and follow the changes in the market to modify orders.
AMM is not rigid, and different algorithms have trade-offs. Uniswap uses an algorithm called the "constant product market maker model". One of the major features of this AMM is that it can provide liquidity no matter how large the order book is or how small the liquidity pool is.
The trick is to gradually increase the price of tokens as the number of buying orders increases. Although this is not very friendly to larger orders, the system never has to worry about insufficient liquidity, it can almost always operate effectively.
Take a simple example of the ETH/DAI trading pair. Assume that the market maker has invested 100,000 DAI and 1,000 ETH into this liquidity pool. Uniswap multiplies these two quantities (100,000 x 1,000 = 100,000,000).
Uniswap's goal for this particular trading pair is: regardless of the amount of trading activity, the product will always maintain a 100 million trading pair product quantity (hence the name "constant product market maker").
Remember the key formula x * y = k, where x and y are the number of tokens in the liquidity pool and k is the product. In order to keep k constant, x and y can only vary in opposite directions. For example, if a trader buys ETH with DAI in this contract, they are increasing x and at the same time decreasing y.
But this reverse change is not a linear growth relationship. If you want to buy 100 ETH instead of 10 ETH now, then 10 times the DAI required to purchase 10 ETH may not be enough. In fact, the required DAI is gradually increased. The easiest way to understand is to draw the x * y = k curve.
As shown in the figure, the horizontal direction measures the number of coins A spent. The more you move to the right, the less the unit of revenue, and the smaller the change in Y value.
The key point to note in this system is that the quotation directly depends on the size of the order. The more you move to the right end of the curve, the less income you get from unit investment. Assuming that the current ETH/DAI price is 100, the premiums paid for orders of different quantities are shown in the following table:
As shown in the table, when the amount of ETH purchased exceeds 2% of the liquidity pool, it will be very expensive to purchase a large amount of ETH. But remember that these premiums are determined by the size of the current liquidity pool.
If the liquidity pool is 100 times larger, buying only 50 ETH at this time is not that expensive. Ultimately, the price paid reflects the extent to which the transaction size changes to the x/y ratio. The larger the liquidity pool, the easier it is to process large orders.
One thing worth noting is the front running, which is a problem with all DEXs on Ethereum today. To alleviate this problem, Uniswap allows users to specify the highest price when placing an order. In this way, even if miners preemptively trade an order, users will not be forced to accept higher prices.
Although users may miss this transaction, they do not need to pay a higher price. Another feature of Uniswap is "order expiration", which prevents miners from shelving signed transactions and waiting for the price to change before processing.
The exchange of ERC-20 to ERC-20 tokens does not require the use of a special liquidity pool. For example, when processing REP <> ZRX orders, the system will first pass the REP/ETH trading pair and then automatically pass the ZRX/ETH trading pair.
Compared to regular exchanges based on limit order books, Uniswap sounds much more complicated. The premium also makes the cost of large transactions too high. So what are the benefits of it? The collection of liquidity solves the problem of the depth of orders, and there is no longer a large bid-ask spread.
Those small and medium traders who don't want to process limit orders will like this. On Uniswap, there is no need to place buy or sell orders, nor do heavy calculations. Liquidity providers can also do it once and for all, and the cost of order and position management is also significantly reduced.
This model is actually very similar to the Bancor network launched last year but Uniswap does not charge any currency listing fees, consumes much less Gas, and is more decentralized. Bancor requires the listing party to pledge BNT, need to fill in the listing application form, and BNT can easily be frozen at will but Uniswap does not have these problems. As long as the Ethereum network is live, Uniswap will continue to operate.
Currently, all Uniswap contracts have only a few thousand liquid ETH funds, so it is still in the early stages. Since there will always be giant crocodiles who want to trade large orders, Uniswap is unlikely to replace other types of DEX, but its unique features will certainly attract many ordinary traders who want to quickly and easily obtain various tokens.