A Star Is Born
On November 2, 2018 Hayden Adams made blockchain history by deploying Uniswap, a protocol for decentralized and permissionless exchange of tokens, to the Ethereum mainnet.
Roughly two years later and Uniswap has generated over $1B dollars in fees for its liquidity providers, making it one of the highest fee generating DeFi protocols to date.
It's hard to overstate the affect Uniswap has had on DeFi, cryptocurrency, and financial markets at large. The full impact of its invention is still playing out, but if the trend continues we'll likely see Uniswap and decentralized protocols like it continue to take market share from legacy financial and crypto institutions.
The innovation presented by Uniswap is a fine example of how trading will exist in the decentralized and permissionless future. The United States should be offering Hayden Adams a medal. Instead, Uniswap Labs is under investigation by the SEC.
While US regulators appear to be taking a punitive approach towards cryptocurrency and financial innovation, it is likely too late to stop the momentum gained by decentralized finance. When it comes to DeFi, the cat (or in Uniswap's case the Unicorn) is already out of the bag.
Uniswap has undergone a number of significant improvements since its initial release. This article provides an overview of the latest version of Uniswap (v3) and an explanation of certain key concepts central to its function.
Order Book Model
Before going into the finer details and improvements of Uniswap v3, it's important to understand the innovation that made the first version of the protocol successful. To do so, we must first understand how trading was and is traditionally performed on centralized exchanges.
In traditional equities markets trading between buyers and sellers is facilitated by an exchange using an order book model whereby the two parties are 'matched' so that a trade can take place.
A simple example serves to illustrate how this works. Let's say I have an asset or security I want to sell at a certain price. You, on the other hand, want to buy this asset, but also have a certain price in mind. The exchange facilitates trade between the two of us by keeping track of this information on their order book and brokering an exchange when the minimum price I'm willing to accept for the asset (the 'ask') converges with the maximum you are willing to pay for it (the 'bid').
Pretty simple right? But what happens if the two parties are unable to agree on a price for the asset? In other words, what if a buyer's bid is lower than the seller's ask? Well, in that case neither party would be able to get what they want and a trade would not take place.
To solve this problem, order book model exchanges rely on a third party to liaise between the two trading parties. This third party is a high-volume trader called a 'market maker' who operates in the space between the buyer's bid and the seller's ask, a kind of no-man's land known as the bid-ask spread. Market makers do exactly as their name implies: they 'make the market' by providing liquidity to it, allowing the trade between buyer and seller to take place. Think of them as a middle layer between the buyer and seller that provides liquidity and enables the exchange of an asset between the two parties to occur.
If adding a third party to what is at its root an exchange between two seems overly complicated, that's because it is. This additional complexity adds friction, latency, and cost to the trade, which can result in an inferior user experience. Not to mention the trust a trader must place in the exchange to hold his assets while he trades and the permission he must ask of the exchange in order to trade there. Nevertheless, the order book model is how legacy financial securities and crypto exchanges continue to function.
While high volume and liquidity can be used to mask and compensate for these flaws, the fact remains that the centralized nature of the order book model is inefficient.
But what is the alternative? Until fairly recently, there was none. That was until the creation of protocols like Uniswap and its Automated Market Maker model.
Automated Market Maker
The innovation provided by Uniswap and other Automated Market Makers (or AMMs) is that it decreases the required number of parties involved in any given trade from three to one. When a trader makes an exchange using an AMM, instead of going through a market maker to make an exchange with a buyer or seller, he instead draws from a collection of tokens known as a liquidity pool. The assets in the pool are provided by third parties known as liquidity providers, or LPs.
In the AMM model, LPs effectively fill the role of market makers in the order book model by providing liquidity for assets of the same type as the trading pair the trader would like to swap. When a trader makes an exchange on an AMM, he dips into the liquidity pool and exchanges his tokens for one of the pairs provided by LPs in the pool.
Hang on, you say. If there is no counter-party on the other side of this trade, what determines the price of the asset? The prices of the assets in the pool follows the curve of a simple mathematical formula known as the constant product formula. Expressed as x * y = k in its simplest form, the constant product formula ensures that the pair of tokens in the liquidity pool remain at equal total values.
This means that if one of the asset pairs in the pool is purchased, effectively removing it from the pool, then the price of the assets of the same type remaining in the pool will increase in order to maintain the equilibrium of the total value of the pool's pair. In other words, the price of each asset in the pair may fluctuate, but the total value of the pool remains constant. The addition and subtraction of assets from the pool is what affects the raising and lowering of the pool's asset prices.
AMMs provide trustless, decentralized, and hyper efficient platforms for trading. They do this by removing the order books and market makers from the trading equation and replacing them with liquidity pools whose contents' prices are governed by a constant product formula.
Liquidity providers are incentivized to contribute to to the AMM's liquidity pools by earning a share of the fees generated every time one of the assets inside the pool is swapped for one without. This can provide a nice source of profit for LPs. However, being a liquidity provider is not without risk. One of the downsides of providing liquidity to an AMM is the risk of impermanent loss.
Impermanent loss is the difference in value that results from providing an asset as liquidity versus simply holding that asset as its price fluctuates. It occurs when one side of a liquidity pair experiences price volatility in relation to the other half of the pair. In this instance, the LP would have been better off simply holding the asset instead of providing it as liquidity.
Because impermanent loss is caused by the volatility of one asset in relation to another, it can be mitigated by providing liquidity to more stable asset pools (e.g. USDC/DAI), one-sided staking pools, and uneven liquidity pools (such as Balancer).
Uniswap v3 Upgrades
Since its initial release, Uniswap has undergone a number of improvements marked by successive versions. Uniswap v1 was essentially the proof-of-concept for a new decentralized exchange using the Automated Market Maker model. Uniswap v2 integrated price oracles and introduced ERC20 token pairs.
Uniswap v3 is the latest and most advanced version of the popular open source protocol. It provides a number of improvements to previous versions, the most significant of which is the idea of concentrated liquidity.
In previous versions of Uniswap, LPs earned fees from trades which took place on any area of the price curve. This means that an LP's capital was spread along the curve in order to accommodate trades taking place anywhere along a wide range in price. By contrast, LPs in Uniswap v3 are able to set a specific price range to deploy their liquidity.
The ability to control the price range of provided liquidity drastically increases the LP's capital efficiency. In stablecoin pairs like DAI/USDC for example, the relative price of the two assets normally trades within a very narrow range (between $0.99 and $1.01). The means the vast majority of the fees generated by trades of this pair falls within this range, and an LP who concentrates his liquidity in that range is likely to benefit accordingly.
So what happens when a trade takes place outside of the LP's designated price interval? In that case, the LP's liquidity is no longer considered active and he earns no fees from it.
To counter this affect, LPs may provide liquidity to as many different price intervals as they see fit, even overlapping their intervals for improved efficiency. This creates the opportunity for LPs to create custom, individualized price curves.
By providing liquidity at designated price ranges, LPs can approximate order types found on legacy exchanges. Range orders on Uniswap v3 generate fees while the order is filled, in contrast to a limit order on a centralized exchange which incurs them.
Swap fees on Uniswap are distributed to LPs for every trade that occurs within their designated price range. If the asset's price moves out of a position’s range, the liquidity is no longer active and does not generate fees.
Liquidity pools can be created using one of three fee tiers: 0.05%, .3%, and 1%. Which fee tier any given pool employs is at the discretion of the pool's creator, but will likely end up where the incentives for both swappers and LPs have the most overlap.
Uniswap v3 is the latest version of the seminal decentralized Automated Market Maker protocol. v3's biggest change is the concept of concentrated liquidity, which allows LPs to designate a specific price range in which to concentrate their liquidity.
Uniswap v3 employs the benefits of a stable asset AMM in order to boost LPs' capital efficiency. It is not without its own risks, as choosing the wrong price range when providing liquidity may magnify the chance of incurring impermanent loss.
Making a swap on Uni v3 is ~30% cheaper than on previous versions. When combined with deployment on Optimism's roll-up based Layer 2 scaling solution, it provides cheap, fast, and frictionless trading on Ethereum without compromising on that network's battle-tested security and decentralization.