What Is Uniswap?

BeginnerNov 21, 2022
Uniswap is a decentralized crypto trading protocol built on the Ethereum blockchain that allows anyone to swap ERC-20 tokens directly from their wallet or to create liquidity pools of the tokens.
What Is Uniswap?

Introduction

Uniswap is a Decentralized Exchange running on the Ethereum blockchain that allows users to swap ERC-20 tokens through automatically running Smart Contract and application codes. Users help others to do the swap and earn transaction fees from it.
By fully automating token swap without an intermediary, Uniswap reduces transaction fees greatly and improves efficiency while overcoming the problems of screening, restrictions, and mutual trust associated with centralized exchanges. Its success has made it the leading project in the Decentralized Finance (also known as DeFi) on Ethereum, and one of the most plagiarized protocols for its open source code.
Uniswap issued its governance token UNI in September 2020, in addition as a way to reward users, which is also a further step toward its vision of decentralization as the community is able to participate in decision-making. In this way, Uniswap continues to grow organically in the ever-changing blockchain space.

The Development of Uniswap

Vitalik Buterin, the founder of Ethereum, published a blog on Reddit discussing the feasibility of decentralized exchanges as early as 2016. Considering the fact that any on-chain order requires a Gas fee, this makes it too expensive for market makers to operate on decentralized exchanges where it’s difficult to place pending orders frequently. Paying fees regardless if the order is filled or canceled has become an additional transaction cost, and the Bid-Ask Spread for on-chain tokens trading often exceeds 10%. In this case, the idea of generating continuous quotes through an Automated Market Maker to promote liquidity came into being.
Inspired by that article, Hayden Adams, a former engineer at Siemens, set out his research on how to implement an automated market maker. After receiving a $100,000 sponsorship from the Ethereum Foundation, Uniswap went live on Ethereum in November 2018, supporting swaps between ETH and ERC-20 tokens.
Uniswap quickly attracted the market with its simple UI and easy operation, making it the most traded decentralized exchange on Ethereum within six months. Paradigm, a leading cryptocurrency investment firm, responded quickly with $1 million, and in May 2020, Uniswap was successfully upgraded to V2, which supports direct transactions between ERC-20 tokens, contributing to the glory of the DeFi summer in 2020.

The collapse of the cryptocurrency market on May 19, 2021 backfired on Uniswap: Bitcoin dropped nearly 30% on that day as a result of a number of bearish news, triggering a large number of selling orders which resulted in the collective shutdown of many centralized exchanges. By contrast, Hayden Adams announced on Twitter the next day that Uniswap had passed the extreme stress test by processing a total of 6.3 billion on-chain transactions in one day without missing a single one or getting stuck.
Uniswap has been upgraded to V3 as of May 2021, which allows users to specify a price range for providing liquidity, and is currently available on various blockchains such as Ethereum, Polygon, Arbitrum, Optimism, and Celo.

How does Uniswap work?

In a traditional centralized exchange, a transaction takes place after a series of bids between buyers and sellers, and is completed by mutual agreement. Buyers offer different purchase prices and quantities of a commodity from low to high, and sellers offer corresponding selling prices and quantities from high to low, which create the Order Book of the commodity market. Users and market makers who place pending orders on the order book provide liquidity for the commodities, allowing people to buy or sell without any problems.

Instead of using an order book, Uniswap uses an algorithm called Constant Product Market Maker which calculates the percentage of tokens staked in the Liquidity Pool to provide continuous quotes. There is no need for users to match others as counterparties as they can swap assets directly from the pool.

Similar to an order book, a liquidity pool is a place where users stake assets in a smart contract to create liquidity for bought and sold commodities in the same way that an order book on a centralized exchange does. Liquidity Providers, who stake assets in a liquidity pool, are entitled to an equal share of the pool’s transaction fees based on the proportion of funds provided.

Since all transaction fees are allocated to liquidity providers, Uniswap can be regarded as a kind of public property as it does not have any source of income.

Constant Product Market Maker

Constant Product Market Maker belongs to Automated Market Maker (AMM) that calculates quotes for assets in a liquid pool using the mathematical formula X * Y = K, where X and Y are the assets quantities in the liquidity pool, and K is the constant product. A hyperbola can be seen after drawing the three on a cartesian coordinate.

Only the quantity of asset X and Y changes when users exchange assets through the liquidity pool, and the total liquidity of K is not affected in any way, leading token price moves along the hyperbolic curve. The relative price between asset Y and X can be calculated by dividing the number of Y acquired by the number of X paid when a user pays X to acquire Y in the liquidity pool.

For example, there is a liquidity pool of ETH/USDT on Uniswap with 10 ETH and 1,000 USDT. If Alice spends 1,000 USDT to swap ETH from this pool, according to the Constant Product Market Maker formula, the result without fees charged is,

10 1000 = 5 2000

which means the pool now has 5 ETH and 2,000 USDT. Since Alice pays 1,000 USDT to get 5 ETH, her ETH swap rate is

|(2000 - 1000)/(5-10)| = 200 USDT/ETH

It can be found that this is the absolute value of the reciprocal of the tangent slope between two points on the hyperbola.

This tangent will coincide with the tangent of X * Y = K when the amount swapped is very small. Therefore, according to Constant Product Market Maker, which is the reciprocal of the tangent slope of the hyperbola, X/Y, the relative price of the two assets in the pool is determined by the ratio of their amount.
(Tangent slope)

A change in K happens when liquidity is added or subtracted from the pool, shifting the hyperbola to the right or to the left. For example, there is a liquidity pool of ETH/USDT on Uniswap with 10 ETH and 1,000 USDT. If Bob adds 30 ETH and 3,000 USDT into this pool, according to the Constant Product Market Maker formula, the total liquidity of the pool is:

(10+30) * (1,000+3,000) = 160,000

The hyperbola has shifted to the right after drawing on a cartesian coordinate.
(Rightward shift of hyperbola)

An increase in total liquidity in the pool will make it more able to absorb price fluctuations caused by users’ redemptions and reduce price slippage during trading; conversely, a decrease in total liquidity will make it more susceptible to price changes and increase price slippage.

For example, there is a liquidity pool of ETH/USDT on Uniswap with 10 ETH and 1,000 USDT. Before Bob adds liquidity, Alice is able to spend 1,000 USDT to swap 5 ETH from this pool at the swap rate of 200 USDT/ETH.

If Bob adds 30 ETH and 3,000 USDT to the liquidity pool before Alice, making the total liquidity 40 * 4000 = 160,000, then Alice spends 1,000 USDT to swap ETH from the pool, and according to the Constant Product Market Maker formula, the result without fees charged is,

40 4000 = 32 5000

Since Alice pays 1,000 USDT to get 8 ETH, her ETH swap rate now is

|(5000 - 4000)/(32-40)| = 125 USDT/ETH

What can be seen from the above examples is, given the same number of redemptions, a pool with abundant total liquidity is less prone to price fluctuations due to users’ redemptions, and users are able to obtain required tokens at a lower cost, given the same number of redemptions.

Indifference Curve

The formula of Constant Product Market Maker is a type of Indifference Curve in economics. An indifference curve shows a combination of two goods in various quantities that provide equal utility and value to an individual, and the curve is plotted by connecting these combination points in series. If the slope of this curve is negative, implying that the liquidity pool, with constant total liquidity, has to decrease one asset if it wants to increase another while the decrease can be seen as the opportunity cost of the swap.

To this end, the constant product market maker is essentially a barter model, where users swap assets from pools without matching counterparties and using other currencies while prices are directly quoted by the assets in the pool. It can be said that the liquidity pool demonstrates the three major functions of money to a large extent including value store, transaction medium and pricing unit, enriching the imagination of using multiple assets as multiple currencies. The efficiency and innovation in its operation mechanism have also led to a boom in liquidity mining.

Impermanent Loss

In addition to swapping tokens, users of Uniswap are also able to stake their holdings in the liquidity pool to charge transaction fees as liquidity providers. However, liquidity providers are subject to a risk, or an opportunity cost called Impermanent Loss.

An impermanent loss appears when the relative price of the two tokens in the pool changes. For example, the current market price of 1 ETH is 100 USDT, Alice deposits 1 ETH and 100 USDT into a pool, which has a total of 10 ETH and 1,000 USDT with a total liquidity of 10,000, in this case, Alice holds a 10% share.

When the market price of ETH rises to 400 USDT, arbitrage traders will deposit USDT into the pool for ETH as the price here is lower, resulting in the amount of ETH and USDT in the pool changing until the two prices match, eventually leaving 5 ETH and 2,000 USDT in the pool.

If Alice withdraws her 10% shares now, she will get 0.5 ETH and 200 USDT, with a total value of 400 USDT. However, if Alice did not deposit her assets into the liquidity pool, she would still be holding 1 ETH and 100 USDT, for a total value of 500 USDT. Alice experiences an impermanent loss during the process of ETH price increase as the liquidity pool has converted part of her ETH holdings into USDT, this is why she obtains a lower profit when being a liquidity provider.

An impermanent loss disappears only when the relative price of the two tokens in the pool keeps the same. If the market price of 1 ETH drops back to 100 USDT from 400 USDT, and the total liquidity of the pool reverts back to 10 ETH and 1,000 USDT, Alice is still able to get back the 1 ETH and 100 USDT she initially invested by withdrawing her 10% share at this point. However, Uniswap’s liquidity provider can charge 0.3% for the transaction fee and the final amount of ETH and USDT obtained by Alice will be greater than she initially invested in the practice.

The calculation of impermanent loss is complicated and there are many websites that offer an Impermanent Loss Calculator in a simple way where you only need to enter the prices of two tokens when you deposit them into the liquidity pool and withdraw.

Uniswap V3

Since its launch in late 2018, Uniswap has undergone several upgrades, with Uniswap V3 going live in May 2021 and introducing the concept of capital efficiency. The feature of the constant product market maker is that it can provide a wide range of continuous quotations, and there will always be two tokens in the liquidity pool that can calculate the relative price no matter how violent the price changes. On the other hand, the pool is very underutilized, with only a small portion of the funds being used for trading at any given moment, and almost all of the funds away from the current market price range are in an idle state.

Uniswap V3 enables providing liquidity in a specified price range, liquidity providers are able to set their own liquidity to concentrate in the most popular price range, which ensures that the added liquidity is fully utilized and allows the providers to earn more. Specifying price ranges to provide liquidity also benefits proactive liquidity providers, who will receive much higher transaction fees than passive liquidity providers by constantly tracking quotes and optimizing their strategies.

However, this brings new problems at the same time, the Liquidity Pool Tokens held by different liquidity providers vary in price ranges, making the tokens unique Non Fungible Tokens. The liquidity pool share tokens of Uniswap V2 can be deposited into other DeFi protocols as collateral. Currently, the liquidity pool share tokens of Uniswap V3 do not have such a function. In Uniswap V2, Liquidity Pool Tokens can be deposited as collateral for other DeFi protocols, which is not currently available in V3.

How to Use Uniswap?

Uniswap is quite simple in operation, but before that, a wallet that can be connected to Ethereum is needed. Considering that Uniswap is an open source protocol that anyone can use its code to build a web front-end application, it is strongly recommended to use the official site https://app.uniswap.org/.

The steps are as follows:

  1. Go to the page

  2. Connect your own wallet, such as Metamask and Trust Wallet, or hardware wallets such as Trezor and Ledger Nano S

  3. Select the token you want to swap

  4. Select the tokens you want to receive

  5. Click “Swap”

  6. You can preview the result of the transaction as a pop-up window will appear

  7. Confirm the transaction request in your wallet

  8. You can check the status on https://etherscan.io

The Native Token of Uniswap

UNI, issued in September 2020, is the governance token of Uniswap, allowing holders to propose and vote for the development of the protocol. Giving governance to the community will help decentralize Uniswap and ensure that the development team will focus on its needs and interests in order to gain the support and trust of the community.

Ethereum addresses that have used the Uniswap application before September 1, 2020, are eligible to receive 400 UNI airdrop tokens. The airdrop was worth nearly $1,200 on that day, or $16,000 at the 2021 price high as UNI is one of the airdrop tokens with the highest price growth on Ethereum.

The total supply of UNI tokens is 1 billion, with 60% allocated to the community in the initial offering and the remaining 40% to be unlocked in batches over 4 years to the team, investors, and advisors.

At present, the development team and investors hold a relatively large amount of tokens, and the requirements for initiating a proposal and voting remain high with 2.5 million tokens to initiate a proposal and over 40 million to pass a proposal. It will be a challenge for Uniswap to make the protocol more decentralized and move towards effective community governance.

Source: uniswap.org

Conclusion

Uniswap is one of the leading projects in the decentralized financial sector of Ethereum, which has achieved various blockchain innovations in the years since its birth. It verifies the feasibility of Constant Product Market Maker, and inspires other project teams with its open source code, different kinds of algorithms and decentralized exchanges have sprung up after it.

Uniswap also finds ways to solve the dilemmas that have plagued decentralized exchanges for years, users are able to swap ERC-20 tokens easily while becoming liquidity providers to obtain transaction fees. Uniswap has opened a new door to the blockchain world, leading the boom of decentralized finance. The team behind it and the whole community of Uniswap won’t stop moving forward following the upcoming ETH 2.0.

Auteur : Piccolo
Traduction effectuée par : Yuler
Examinateur(s): Ashley, hugo, Echo, Ashley
* Les informations ne sont pas destinées à être et ne constituent pas des conseils financiers ou toute autre recommandation de toute sorte offerte ou approuvée par Gate.io.
* Cet article ne peut être reproduit, transmis ou copié sans faire référence à Gate.io. Toute contravention constitue une violation de la loi sur le droit d'auteur et peut faire l'objet d'une action en justice.
Lancez-vous
Inscrivez-vous et obtenez un bon de
100$
!
Créer un compte