What is Uniswap?
Uniswap is a protocol on Ethereum for swapping ERC20 tokens. Unlike most exchanges, which are designed to take fees, Uniswap is designed to function as a public good — a tool for the community to trade tokens without platform fees or middlemen. Also unlike most exchanges, which match buyers and sellers to determine prices and execute trades, Uniswap uses a simple math equation and pools of tokens and ETH to do the same job.
Uniswap v1 vs v2
Before we take a look at Uniswap v3, we must remind ourselves of its evolutionary path and the difference between v1 and v2. It will help us understand why the new features are the only natural thing that could happen for Uniswap to be one of the leaders in the DeFi space.
Uniswap V1 & V2
Uniswap v1 was first launched on the Ethereum mainnet on November 2, 2018. Even though it wasn’t the first DEX, it certainly was the first one to catch the eye of Crypto lovers.
Uniswap is based on the Automated Market Maker (AMM) model. This model relies on a mathematical formula to price assets. Rather than placing orders, AMMs rely on Liquidity Providers (LPs) who invest in trading pairs in Liquidity Pools.
Uniswap is a Constant Function Market Maker, or more specifically, a Constant Product Market Maker. That means that the ratio of trading pairs in every liquidity pool must respect the Constant Product Formula:
where k is a constant, x is the reserve of the first asset, and y is the reserve of the second asset.
This means that all the LPs are to provide additional liquidity in a way that wouldn’t change k. Also, everyone traded had to be aware of the total amount of the funds locked to avoid high slippage.
Uniswap v1 supported only ETH-ERC20 trading pairs, so you could only swap ETH for a single ERC20 token. So, if you wanted to swap USDC for DAI, you had to swap USDC for ETH and then go to the ETH-DAI pool to get DAI.
Uniswap V1: DAI to USDC Swap
Another feature Uniswap v1 introduced was LP tokens. Every liquidity provider would get the amount of LP token proportional to the percentage of total liquidity they added. These LP tokens represent LP’s contribution to the pool and could be sold/traded or burned to redeem the deposited tokens. Furthermore, every trade on Uniswap incurred a 0.30% trading fee. These fees were automatically sent to the liquidity reserve as a reward for LPs providing liquidity.
Uniswap v1 was a proof-of-concept for a new type of decentralized marketplace. Its initial success was a signal for the team to immediately reiterate for an even better solution. Uniswap v2 was launched in May 2020.
In short, Uniswap v2 was a much better and more user-friendly version of Uniswap v1. The main problem of v1 addressed in this new version was the absence of ERC20-ERC20 token pools. This incurred much higher costs and slippage for users who wanted to swap one ERC20 token for another.
Uniswap v2 introduced ERC20-ERC20 liquidity pools to solve this so-called “ETH bridging” problem. They even used Wrapped ETH instead of native ETH in the core contracts. However, end-users could still use ETH through helper contracts.
Uniswap V2: DAI to USDC Swap with Router
This second version of Uniswap also implements a new functionality that enables highly decentralized and manipulation-resistant on-chain price feeds.
Another groundbreaking feature that v2 introduced was Flash Swaps. These Flash Swaps allowed users to withdraw as much as they wanted of any ERC20 token on Uniswap at no upfront cost and do anything they wanted with them (execute arbitrary code), provided that by the end of the transaction execution.
Even though Uniswap v1 still existed after v2 was launched, it didn’t take too long for LPs to transfer most of the liquidity from one version to another. Uniswap v2 experienced huge success, passing even some of the most famous centralized exchanges in daily trading volume. This success made Uniswap v2 one of the most forked projects — SushiSwap being its biggest competitor that was created as a fork.
What is Uniswap V3?
Uniswap v3 is the forthcoming new and improved DEX that will run on the Ethereum blockchain and be powered by the same automated market maker (AMM) model as v2 but loaded with new developments aimed at maximizing returns for traders and liquidity providers, minimizing price slippage, and managing downside risks.
Why Did Uniswap Launch Another Version?
Uniswap has been a victim of its own success, receiving heavy criticism that its popularity is slowing down the Ethereum network and causing transaction gas fees to skyrocket. Also, Uniswap has seen the repeated exploitation and copying of its code by competitors like Sushiswap and Binance Smart Chain.
Uniswap v3 boosts the efficiency of its AMM model, which is one of the most significant features to observe when comparing DEXs.
Through the introduction of a concentrated liquidity concept, liquidity providers have the ability to supply their assets in a definite price range for which they deposit liquidity. Moreover, they have given tier-based rewards based on the degree of risk they are taking on in any particular pool. This can incentivize more liquidity providers to participate as the rewards would potentially help offset some of their potential losses in supplying liquidity to a wider price range.
The combination of these features enhanced the efficiency of the AMM model that supports Uniswap v3’s DEX, which would benefit traders thanks to more liquidity. Furthermore, liquidity providers can also possibly gain higher returns on their capital with as much as 4000x efficiency.
What’s New in Uniswap V3?
Uniswap v3 launched on May 5, 2021, on the Ethereum mainnet. There are the main feature updates that were introduced in Uniswap V3:
- More Decentralization
- Concentrated liquidity
- Better Security
- New fee tiers
- Oracle feed developments
- Range Orders
- Non-Fungible Liquidity
These features will work together in achieving better capital efficiency for the platform’s traders and greater risk management for liquidity providers.
Uniswap v3 Features
Now, let’s go through some of the Uniswap V3 features one by one to understand them a bit better.
Concentrated liquidity is the main concept behind V3.
When LPs provide liquidity to a V2 pool, liquidity is distributed evenly along the price curve. Although this allows for handling all price ranges between 0 and ∞, it makes the capital quite inefficient. This is because most assets usually trade within certain price ranges. This is especially visible in pools with stable assets that trade within a very narrow range. As an example, Uniswap DAI/USDC pool only uses around 0.5% of capital for trading between $0.99 and $1.01 — a price range where the vast majority of trading volume goes through. This is also the volume that makes the majority of trading fees for the LPs.
Liquidity price curve
This means that in this particular example, 99.5% of the remaining capital is pretty much never used.
In V3, LPs can choose a custom price range when providing liquidity. This allows for concentrating capital within ranges where most of the trading activity occurs.
Liquidity price curve
To achieve this, V3 creates individualised price curves for each of the liquidity providers.
Before V3, the only way to allow LPs to have individual curves was to create a separate pool per curve. These pools if not aggregated together resulted in high gas costs if a trade had to be routed across multiple pools.
What is important is that users trade against combined liquidity that is available at a certain price point. This combined liquidity comes from all the price curves that overlap at this specific price point.
LPs earn trading fees that are directly proportional to their liquidity contribution in a given range.
Concentrating liquidity offers much better capital efficiency for liquidity providers.
Liquidity Capital efficiency graph
To understand it better, let’s go through a quick example.
Uniswap liquidity capital efficiency example
Alice and Bob both decide to provide liquidity in the ETH/DAI pool on Uniswap V3. They each have $10,000 and the current price of ETH is $1,750.
Alice splits her entire capital between ETH and DAI and deploys it across the entire price range (similar to V2). She deposits 5,000 DAI and 2.85 ETH.
Bob, instead of using his entire capital, decides to concentrate his liquidity and provides capital within the price range from 1,500 to 2,500. He deposits 600 DAI and 0.37 ETH — a total of $1200 and keeps the remaining $8800 for other purposes.
What is interesting is that as long as the ETH/DAI price stays within the 1,500 to 2,500 range, they both earn the same amount of trading fees. This means that Bob is able to provide only 12% of Alice’s capital and still makes the same returns — making his capital 8.34 times more efficient than Alice’s capital.
On top of that, Bob is putting less of his overall capital at risk. In case of a quite unlikely scenario of ETH going to $0, Bob’s and Alice’s entire liquidity would move into ETH. Although they would both lose their entire capital, Bob puts a much smaller amount at risk.
LPs in more stable pools will most likely provide liquidity in particularly narrow ranges. If the $25M currently held in the Uniswap v2 DAI/USDC pool were instead concentrated between the 0.99–1.01 price range in v3, it would provide the same depth as $5B in Uniswap v2 as long as prices stayed within that range.
Capital efficiency example
When V3 launches, the maximum capital efficiency is at 4000x when compared to V2. This will be achievable when providing liquidity within a single 0.1% price range. On top of that, the V3 pool factory will be able to support ranges as granular as 0.02% — which translates to a maximum of 20,000x capital efficiency relative to V2.
V3 also introduces the concept of active liquidity. If the price of assets trading in a specific liquidity pool moves outside of the LP’s price range, the LP’s liquidity is effectively removed from the pool and stops earning fees. When this happens, the LP’s liquidity shifts completely towards one of the assets and they end up holding only one of them. At this point, the LP can either wait until the market price moves back into their specified price range or they may decide to update their range to account for current prices.
Active liquidity graph
Although it is entirely possible that there will be no liquidity at a specific price range, in practice this would create an enormous opportunity for liquidity providers to indeed provide liquidity to that price range and start collecting all trading fees. From the game theory point of view, we should be able to see a reasonable distribution of capital with some LPs focusing on narrow price ranges, others focusing on less likely but more profitable ranges and yet another one choosing to update their price range if the price moves out of their previous range.
Uniswap LPs price ranges
Range Limit Orders
Range Limit Orders is the next feature enabled by concentrated liquidity.
This allows LPs to provide a single token as liquidity in a custom price range above or below the current market price. When the market price enters into the specified range, one asset is sold for another along a smooth curve — all while still earning swap fees in the process.
This feature, when used together with a narrow range, allows for achieving a similar goal to a standard limit order that can be set at a specific price.
For example, let’s assume that DAI/USDC trades below 1.001. An LP can decide to deposit their DAI to a narrow range between 1.001 and 1.002. Once DAI trades above 1.002 DAI/USDC the whole LP’s liquidity is converted into USDC. At this point, the LP has to withdraw its liquidity to avoid automatically converting back into DAI once DAI/USDC goes back to trading below 1.002.
Range order @ 1.001–1.002 DAI/ USDC
As each LP can basically create its own price curve, the liquidity positions are no longer fungible and cannot be represented by well-known ERC20 LP tokens.
Instead, provided liquidity is tracked by non-fungible ERC721 tokens. Despite this, it looks like LP positions that fall within the same price range will be able to be represented by ERC20 tokens either via peripheral contracts or through other partner protocols.
On top of this, trading fees are no longer automatically reinvested back into the liquidity pool on LPs’ behalf. Instead, peripheral contracts can be created to offer such functionality.
Uniswap v3 offers LPs three separate fee tiers per pair — 0.05%, 0.30%, and 1.00%. This array of options ensures that LPs tailor their margins according to expected pair volatility: LPs take on more risk in non-correlated pairs like ETH/DAI and, conversely, take on minimal risk in correlated pairs like USDC/DAI.
Although distinct fee tiers may lead to some degree of liquidity fragmentation, we believe that most pairs will calibrate to an ‘obvious’ fee tier, which then serves as the canonical market. We expect like-kind asset pairs to congregate around the 0.05% fee tier and pairs like ETH/DAI to use 0.30%, while exotic assets might find 1.00% swap fees more appropriate. governance can add additional fee tiers as needed.
Uniswap v2 introduced a protocol fee switch, which allowed a flat 5 basis point (16.66% of LP fees) fee to be turned on by governance. Uniswap v3 protocol fees are far more flexible. Fees will be off by default but can be turned on by governance on a per-pool basis and set between 10% and 25% of LP fees.
Uniswap v3 LPs Fee Tiers
Uniswap v2 introduced time-weighted average price (TWAP) oracles. These oracles serve as a critical piece of DeFi infrastructure and have been integrated into dozens of projects, including Compound and Reflexer.
V2 oracles work by storing cumulative sums of Uniswap pair prices on a per-second basis. These price sums can be checked once at the beginning of a period and once at the end to calculate an accurate TWAP over that period.
V3 makes it possible to calculate any recent TWAP within the past ~9 days in a single on-chain call.
On top of this, the cost of keeping oracles up to date has been reduced by around 50% when compared to V2.
These are pretty much all the main features behind Uniswap V3.
Uniswap v3 TWAP Oracles
What is interesting is that all of these features haven’t caused an increase in the gas cost. Rather the opposite, the most common feature — a simple swap will be around 30% cheaper than its V2 equivalent.
License — Preventing Uniswap v3 Copycats
This could be seen as contrasting to the open-source philosophy of Blockchain. The team announced the time-delayed license for Uniswap v3. This means that Uniswap v3 Core has launched under the Business Source Licence 1.1. This has limited the use of the Uniswap v3 source code in commercial or production use for up to two years.
They decided to do this to prevent potential future copycats, such as SushiSwap. However, all code needed for external integrations isn’t affected by this license.
Since its inception, Uniswap has been the leading DEX and one of the world’s most popular DeFi platforms. They brought innovation with every new iteration.
Uniswap v3 is not only enabling a higher return on capital for its users, but it also brings new possibilities to the developer community to build an ecosystem around it.
It looks like Uniswap V3 can be a game-changer when it comes to AMMs. It basically combines the benefits of a standard AMM with the benefits of a stable-asset AMM — all of this while making capital way more efficient. This makes V3 a super flexible protocol able to accommodate a whole range of different assets.
With the super high capital efficiency of V3, even if the existing liquidity is split between V2, V3 and V3 on Optimism, it should still be way more than enough to facilitate trading with low slippage across all of these 3 protocols.
Uniswap v1, v2, v3
One challenge of Uniswap V3 is that providing liquidity may become a bit harder, especially for less sophisticated users. Choosing the wrong price range may magnify the chances of being affected by impermanent loss and it will be interesting to see the development of third-party services that could help with choosing optimal strategies for allocating liquidity.