blog posts

Uniswap

What is Uniswap (UNI)?

programs that run on the Ethereum blockchain and allow for Uniswap is a set of computer r decentralized token swaps. It works with the help of unicorns (as illustrated by their logo).

Traders can exchange Ethereum tokens on Uniswap without having to trust anyone with their funds. Meanwhile, anyone can lend their crypto to special reserves called liquidity pools. In exchange for providing money to these pools, they earn fees.

How do these magical unicorns convert one token to the other? What do you need to use Uniswap? Let’s read on.

Introduction

Centralized exchanges have been the backbone of the cryptocurrency market for years. They offer fast settlement times, high trading volume, and continually improving liquidity. However, there’s a parallel world being built in the form of trustless protocols. Decentralized exchanges (DEX) require no middlemen or custodians to facilitate trading.
Due to the inherent limitations of blockchain technology, it has been a challenge to build DEXes that meaningfully compete with their centralized counterparts. Most DEXes could improve both in terms of performance and user experience.

Many developers have been thinking about new ways to build a decentralized exchange. One of the pioneers of this is Uniswap. The way Uniswap works may be a bit more difficult to understand than a more traditional DEX. However, we’ll soon see that this model brings some attractive benefits.

As a result of this innovation, Uniswap has become one of the most successful projects that’s part of the Decentralized Finance (Defi) movement.
Let’s see what Uniswap is, how it works, and how you can swap tokens on it simply with an Ethereum wallet.

What is Uniswap?

Uniswap is a decentralized exchange protocol built on Ethereum. To be more precise, it is an automated liquidity protocol. There is no order book or any centralized party required to make trades. Uniswap allows users to trade without intermediaries, with a high degree of decentralization and censorship-resistance.
Uniswap is open-source software. You can check it out yourself on the Uniswap GitHub.
Ok, but how do trades happen without an order book? Well, Uniswap works with a model that involves liquidity providers creating liquidity pools. This system provides a decentralized pricing mechanism that essentially smooths out order book depth. We’ll get into how it works in more detail. For now, just note that users can seamlessly swap between ERC-20 tokens without the need for an order book.

Since the Uniswap protocol is decentralized, there is no listing process. Essentially any ERC-20 token can be launched as long as there is a liquidity pool available for traders. As a result, Uniswap doesn’t charge any listing fees, either. In a sense, the Uniswap protocol acts as a kind of public good.

The Uniswap protocol was created by Hayden Adams in 2018. But the underlying technology that inspired its implementation was first described by Ethereum co-founder, Vitalik Buterin.

How does Uniswap work?

Uniswap leaves behind the traditional architecture of digital exchange in that it has no order book. It works with a design called Constant Product Market Maker, which is a variant of a model called Automated Market Maker (AMM).

Automated market makers are smart contracts that hold liquidity reserves (or liquidity pools) that traders can trade against. These reserves funded by liquidity providers. Anyone can be a liquidity provider who deposits an equivalent value of two tokens in the pool. In return, traders pay a fee to the pool that is then distributed to liquidity providers according to their share of the pool. Let’s dive into how this works in more detail.
Liquidity providers create a market by depositing an equivalent value of two tokens. These can either be ETH and an ERC-20 token or two ERC-20 tokens. These pools made up of stablecoins such as DAI, USDC, or USDT, but this isn’t a requirement. In return, liquidity providers get “liquidity tokens,” which represent their share of the entire liquidity pool. These liquidity tokens can be redeemed for the share they represent in the pool.
So, let’s consider the ETH/USDT liquidity pool. We’ll call the ETH portion of the pool x and the USDT portion y. Uniswap takes these two quantities and multiplies them to calculate the total liquidity in the pool. Let’s call this k. The core idea behind Uniswap is that k must remain constant, meaning the total liquidity in the pool is constant. So, the formula for total liquidity in the pool is:

So, what happens when someone wants to make a trade?

Let’s say Alice buys 1 ETH for 300 USDT using the ETH/USDT liquidity pool. By doing that, she increases the USDT portion of the pool and decreases the ETH portion of the pool. This effectively means that the price of ETH goes up. Why? There is less ETH in the pool after the transaction, and we know that the total liquidity (k) must remain constant. This mechanism is what determines the pricing. Ultimately, the price paid for this ETH is based on how much a given trade shifts the ratio between x and y.
It’s worth noting that this model does not scale linearly. In effect, the larger the order is, the more it shifts the balance between x and y. This means that larger orders become exponentially more expensive compared to smaller orders, leading to larger and larger amounts of slippage. It also means that the larger a liquidity pool is, the easier it is to process large orders. Why? In that case, the shift between x and y is smaller.

Uniswap v3

The technology behind Uniswap has seen several iterations so far. Chances are, if you’ve used Uniswap, you used Uniswap v2. However, there are always new improvements in the pipeline. Let’s go through the most impactful updates brought forth by Uniswap v3.

Capital efficiency

One of the most significant changes coming with Uniswap v3 relates to capital efficiency. You see, most AMMs are very capital inefficient – most of the funds sitting in them at any given moment not used. This is due to an inherent characteristic of this x*y=k model discussed earlier. In a simplified way, the more liquidity there is in the pool, the bigger orders the system can support in a larger price range.

However, liquidity providers (LPs) in these pools essentially provide liquidity for a price curve (range) between 0 and infinity. All that capital is sitting there reserved for the scenario when one of the assets in the pool 5x-s, 10x-s, 100x-s.

If that happens, those idle assets ensure that there’s still liquidity left on that part of the price curve. This means that only a small portion of the liquidity in the pool is sitting where most of the trading happens.

As an example, Uniswap currently has about 5B dollars of liquidity locked, while it does only about 1B of volume per day. You might think this isn’t a particularly elegant way of doing things, and it appears that the Uniswap team agrees. Uniswap v3 addresses this issue.