Uniswap Protocol Explained

Description of the Uniswap Protocol

To begin, let’s recall what DEX is. Decentralized exchanges (DEX) are a sort of cryptocurrency exchange that enables secure online peer-to-peer cryptocurrency transactions between two exchanging user wallets without the involvement of a middleman. Decentralized exchanges take a unique approach to buying and selling digital assets by relying on self-executing smart contracts allowing for quicker trades at a lesser cost than centralized crypto exchanges. The 'Constant Product Market Maker Model' distinguishes Uniswap from other decentralized exchanges. Because of this pricing method, any ERC20 token can be exchanged on the exchange as long as it is funded with the same amount of ETH.

Liquidity Pools

The liquidity pools are the next key aspect to understanding how Uniswap works.

Liquidity refers to the availability of assets in a market and is essential for any decentralized exchange to function properly. There is no way to discover an asset's price without significant liquidity and this could affect the trading of tokens. In essence, Uniswap allows users to create a dedicated exchange for any ERC20 token by constructing an exchange contract that contains both ETH and the token's liquidity pool. Users must fund a pool with an ERC-20 token and an equivalent amount of ETH to become a liquidity provider (LP). Let’s walk through the inception of the ETH/DAI market. So, if the price of ETH is $1000 and the price of DAI is $5, a user would have to contribute 1 ETH and 5000 DAI to the ETH-DAI pool.

How does this work exactly?

Whenever it is time for a trade, Uniswap essentially balances the tokens in a pool based on the desire to purchase and sell them from users. As a result, any ERC-20 token with the CPMMM equation x * y = k can be posted and exchanged on Uniswap. "x" and "y" denote the number of ETH and ERC-20 tokens in a pool, respectively, while "k" is a constant. An important detail to note is that the price depends on the size of the order relative to the size of the DAI/ETH reserve. Uniswap’s market-making model will always provide liquidity, meaning reserves will never be depleted.

Concentrated Liquidity

Uniswap V3 introduces concentrated liquidity which allows LPs to concentrate liquidity in the target price ranges, achieving much higher capital efficiency. Uniswap V3 allows focused liquidity rather than requiring liquidity providers (LPs) to supply liquidity throughout the entire price range (as seen in V2). In a nutshell, it allows limited partners (LPs) preferences on a price band in which their liquidity is employed.

Using the stable coin swap (USDC/USDT) as an example, LPs could deploy capital just inside the two-cent price range (US$0.99–1.01), resulting in more liquidity in the middle price range and higher overall trading fees. Their preferred amount of risk determines their position for that pair. To meet the same amount of risk in the case of very volatile tokens, the range would have to be vast, which in some cases would be almost impossible.

LPs don't only deposit their assets in liquidity pools and spread them uniformly throughout the price curve in Uniswap v3. Instead, they get to choose the price range to which they want to assign their assets, and they earn fees when the price falls within that range.

Active Liquidity

If market prices shift outside of an LP's price range, their liquidity is effectively removed from the pool and no longer earns fees. Until the market price swings back into their chosen price range or they opt to alter their range to account for current values, an LP's liquidity is made up completely of the less valuable of the two assets. It is theoretically feasible in v3 for there to be no liquidity in a certain price range. However, we expect rational LPs to revise their pricing ranges on a regular basis to reflect actual market prices.

The Uniswap protocol is complex and has many parts use the above as a summary of the protocol. Please refer to their official documentation for more information: Uniswap Official Documentation

Last updated