UniSwap V3 Explained
Until the launch of UniSwap in 2018, the cryptocurrency trading ecosystem was dominated by Centralized Exchanges (CEXs) which are a type of cryptocurrency exchange operated by a third party, such as a bank or service provider, to help conduct transactions against certain fees. Centralized and decentralized exchanges (DEXs) have operated in parallel for many years.
Unlike CEXs, DEXs allow for direct peer-to-peer cryptocurrency transactions to take place online without the use of an intermediary. UniSwap provided the much-needed boost to DEXs, being the first Automated Market Maker to solve the problem of high decentralized liquidity. Why is this an issue? Large trades move the market to an alarming degree. This decreases market credibility due to the reality or appearance of manipulation.It also makes people nervous about holding assets, meaning that applications dependent on low volatility have trouble getting off the ground. Finally, it also harms the viability of DEXs, which are far behind centralized exchanges when it comes to price information. Here’s where UniSwap comes in.
What is UniSwap?
UniSwap is a protocol that allows traders to swap Ethereum ERC20 tokens without using an order book. The swap rate is based on the demand for both tokens and the balances of the swapping pair.
Traditional markets heavily rely on liquidity for their success. UniSwap tackles this problem through automated liquidity provisioning using Automated market makers (AMM). This allows for an easy swap of ERC20 tokens without relying on Liquidity Provider tokens (LPs) to create their liquidity.
UniSwap, since its launch, has had resounding success and has become the largest decentralized exchange on Ethereum (Source: Messari)
UniSwap V3 now represents more than 40% of all DEX volum with a market cap of over $10B as of July 2021 (Source: Coinmarketcap). It’s top competitors include Sushiswap and Matcha - but note that these are not built on Ethereum.
History of UniSwap V1 and V2
To fully understand the impact of UniSwap V3, it’s worth taking a look at how it differs from the previous versions. UniSwap V1 was designed merely as a concept (beta) for a decentralized marketplace. It was designed to be simple to use and to provide an interface for the seamless exchange of ERC20 tokens on Ethereum.
V2 was a stability upgrade over V1 and included the following updates:
ERC20/ ERC20 pairs
UniSwap V1 allowed for swapping only between ETH and ERC20 tokens. The use of Wrapped Ether (WETH) allows users in UniSwap V2 to pool any ERC20 token directly with another ERC20 token, without initially converting it back to ETH.
UniSwap V1 price feeds were not completely decentralized and could be manipulated, making them unsafe.
UniSwap V2 introduced an Oracle system that is highly decentralized and manipulation-resistant.
Transactions on Ethereum have a relatively high upfront cost (including gas fees) and a low net profit. Flash Swaps in UniSwap V2 allow users to withdraw any amount of ERC20 tokens with no upfront costs. Such users are expected to pay for the withdrawn tokens with the corresponding pair tokens or to return the withdrawn tokens along with a small fee.
New Features in UniSwap V3
UniSwap V3 was unveiled on May 5th, 2021, launching it on the Ethereum main-net and deploying on Optimism (alphae version) shortly after. Some key features include:
Concentrated liquidity is liquidity allocated within a custom price range. Previously, liquidity was distributed between 0 and infinity, uniformly along the price curve.
V3 allows Liquidity Providers (LPs) to concentrate their capital on smaller price intervals. Rising and falling asset prices may exit bounds set by LPs. When this happens, the position's liquidity is no longer active and no longer earns fees. This offers traders deeper liquidity and allows LPs to earn more with less capital investment.
Concentrated Liquidity allows the market to decide a sensible distribution of liquidity while allowing LPs to create as many positions as they see fit in their price interval.
A quick guide to providing liquidity:
- Select the pair of tokens that you wish to provide as liquidity. Factors to consider include Total Value Locked, trading volume and assessment of risk.
- Select the right fee tier, as every pair of tokens offers three fee tiers depending on stability and correlation. Note that the app will auto-select the fee tier with the most liquidity because that is a good heuristic.
- Select a price range in which to provide liquidity. When making a pricing decision, you should consider the degree to which you think prices will move over your position’s lifetime.
- Decide how much capital to contribute to this position. You should enter a value in one of the ‘Deposit Amounts' boxes and the other box will automatically populate the corresponding amount. The ratio of these two fields is based on the position of your price range around the market price.
- Approve and add. You’re finally ready to submit the transaction, but you may first need to approve the UniSwap router contract to spend tokens on your behalf.
The UniSwap fee calculator enables you to input your investment amount, see current swaps and liquidity, and estimate fee income. For example, for an input of $100 at 0.05% fee, at the time of writing, you’re likely to pay a fee of $0.3.
UniSwap V3’s customizable LPs, along with single-sided asset provisioning, opens up new features to complement market orders called “Ranged Orders.”
Range Orders allow LPs to deposit a single token into a custom price range above or below the current price. If the market enters into the range specified by the LPs, Range Orders allow the selling of one asset for another while earning swap fees.
Multiple Pools Per Pair
UniSwap V3 introduces the new concept of multiple pools per pair of tokens, each with a different swap fee. Traditionally every pair of tokens corresponded to a single liquidity pool, each with a default fee of 0.3% for all swaps. While this approach has worked well in the past, it is likely too low for pools that trade in highly volatile tokens and is too high for relatively stable ones.
With UniSwap V3, all pools are created by the same factory contract, allowing contracts to be created at three different tiers: 0.05%, 0.3%, and 1%. This allows you to route to the pools that give you the final assets.
UniSwap V3 offers significant upgrades to the time-weighted average price (TWAP) oracles. Oracles in V2 worked by storing cumulative sums of UniSwap pairs. This allowed these price sums to be checked only once at the beginning and once at the end of a period.
UniSwap V3 removes the need to track previous values of the accumulator externally. This is achieved by storing an array of cumulative sums instead of just one, making it possible to calculate TWAP within the past on a single chain call.
As an array of historical price-makers, it is far easier and cheaper to create more advanced oracles with greater capabilities. This has reduced gas costs for UniSwap traders by roughly 50% compared to UniSwap V2.
Ticks for holding liquidity within a range
For concentrated liquidity to work, Uniswap has created ticks, which are used to keep liquidity within a specific price range. Every tick has its own set of liquidity provider tokens. Technically, smaller trades shouldn’t need to span more than one tick, but larger ones or those with higher slippage can encompass multiple ones, once liquidity from the initial tick is exhausted.
Due to UniSwap V3’s smart contracts, tick spacing is directly related to the swap fee. Lower fees allow closer active ticks, and higher fees allow wider spacing of these ticks. Narrower ticks increase the granularity of liquidity, which will likely lead to lower prices impact when swapping, resulting in improved prices for stable coin swaps.
Recent Update in UniSwap V3
On July 15th, 2021, after discussions with the UniSwap community, UniSwap announced six new features and updates to the old design to improve the overall user experience while promising new future updates for an even better experience. These include an auto fee tier selection, which leverages a reasonable fee tier for most LP strategies and liquidity range charts, which display real-time liquidity distribution in a given pool.
Also, with previous versions of UniSwap, participants were required to submit executable code alongside their proposal. This has limited the potential number of proposal participants. With the proposal threshold reduced from 10m UNI to 2.5m delegated UNI, no technical delegates can participate in the proposal submission.
Future of UniSwap - Optimism
The Alpha launch of UniSwap V3 has finally been announced on the Optimistic Ethereum Mainnet. Optimism’s roadmap promises great improvements over the traditional DeFi web-user experience, including additional scaling, smart wallet, and decentralization of the transaction sequencing operation. This marks the first major leap in improving the web user experience in DeFi applications.
Optimism has provided a gateway for users to migrate their assets to the Optimism Ethereum network, which is already compatible with popular wallets.
The launch marks a milestone for DeFi based applications in its alpha stage and will provide instant transactions for all users at up to 10x transaction cost savings.
Moreover, Optimism is developing Layer 2 (L2) for Ethereum. This will significantly increase Ethereum’s throughput (transactions per second), lower latency (the time taken to confirm a transaction). It will also lower gas fees and won’t compromise the security of the Ethereum mainnet.