This article is part 2 of my in-depth series on Uniswap.
Uniswap v3: what it is and how it works
Uniswap V3 is the third version of the Uniswap decentralized exchange (DEX) protocol built on the Ethereum blockchain. It offers improved performance and user experience, as well as additional features and capabilities, compared to previous versions of the platform. It is designed to facilitate the trade of ERC-20 tokens and other digital assets in a trustless and decentralized manner.
Uniswap v3 introduced a mighty innovation that allows liquidity providers to provide liquidity within a specific range.
I know your mind is fried by now so let’s understand this through a simple example.
Uniswap v3 range example
To understand v3 we need to really understand those demand curves. Let’s look at the current liquidity pool for the USDC – DAI pair.
If you visit Uniswap you will see that on April 15th, 2022, there was approximately $86Mn in this pool: 43Mn DAI and 43Mn USDC.
If we were to plot the demand curve we would get something like this
Assuming constant liquidity, most of the time transactions are going to be hovering around the 43K USDC = 43K DAI mark.
Any significant deviation from that point would mean that traders would see an opportunity for arbitrage with other exchanges and they would buy/sell until the price moved back to 1 USDC = 1 DAI.
Note that if more liquidity entered the pool it would just shift the curve outwards.
We might have something like 51K USDC = 51K DAI.
The thing is, most of the activity is hovering between 1 DAI =0.99 and 1 DAI= 1.01.
It is highly unlikely that these two stablecoins will move outside these bands.
However, the liquidity is spread out from 0 to infinity.
Because infinity is hard to imagine let’s say it is spread out from 1 DAI = 0 USDC to 1 DAI = 100 USDC
We could plot how liquidity will be spread out as follows.
Going back to our cave-people analogy here the LPs are putting 11 baskets of apples and cereal with 8.6 in each: 4.3 Apples and 4.3 cereal.
But Ethan is only swapping apples and cereal in the first basket.
The contents of the other baskets are rotting in the sun.
ok, it’s time for aaaaa…wait for it…
Example!!!💥 💥 💥 🎉 🎊 🥳
Uniswap v3 example
Let’s say we have 100K DAI and 100K USDC.
Imagine in the next minute there are 100 transactions for $100 worth of the USDC-DAI pair in the 0.99-1.01 range.
This would translate into 100 * 100* 0.3%=$30 in fees
Ethan has supplied 50K DAI and 50K USDC like you would in v2 i.e. across the whole range.
His friend Effie decides to use v3 and supplies 50K DAI and 50K USDC for the 0.99-1.01 range.
Now, under v2 the $30 in fees would split the reward 50-50. Ethan has provided 50% of the pool and Effie the other 50%.
In contrast, Effie has concentrated her liquidity in a narrow range.
If Effie had 10 baskets she has put all of her liquidity in one basket.
On the other hand, Ethan has split his liquidity across many baskets.
Going with the 10 baskets analogy, Ethan has only put $10K in each of his 10 baskets.
Then the liquidity in the 0.99-1.01 range is $10K from Ethan and $100K from Effie.
This means Effie should be rewarded 100/110 * 30 = $27.3
Whoa, what just happened?
They both put in 100K but Effie’s investment was so much more efficient (get it?).
Actually, if I plug in the correct mathematical formula that Uniswap uses, Effie would have been equally efficient if she had only invested $250 in the 0.99-1.01 range.
In v2 a $100,000 investment would reap 15$ but in v3 you would only have needed $500.
Effie is about 200 times more efficient than Ethan. That is provided that the trades stay within the range she has selected.
How much more efficient can you get on Uniswap v3 compared to v2?
If you go for the narrowest range, Uniswap v3 allows you to potentially reach an efficiency of 4000x.
This means you can put 4000x less liquidity and still earn the same rewards as you would in v2, provided the price stays within that range.
All of the above is assuming we stayed within the specified range.
What happens if we move out of range on Uniswap v3?
If the price moves out of the target range you stop earning fees and your liquidity is composed of 100% of the lower-valued token.
So if the price of 1 USDC = 1.016 DAI we have moved out of our price range and only have USDC in our basket.
We also stop earning fees.
How are price ranges defined in Uniswap v3?
When you decide to provide liquidity on Uniswap v3 you are now asked what price range you want your liquidity to support.
In my example, I split the price ranges into 11 baskets. Therefore there would be 11 tick marks along the axes. But where is the right place to put those tick marks?
Uniswap v3 ticks
Uniswap places a tick mark for every 0.01% change in the price. So in our example that would be a tick at 1 and then at 1.01.
For each price range users can decide on the liquidity they want to provide.
Here is what I just described in the theory:
And here it is in practice for ETH – USDC. Notice how the liquidity is distributed around the center but that there is also liquidity at the more extreme prices.
In contrast, note how much more concentrated liquidity is for stablecoins below.
UNI tokens as NFTS
Like with v2, in Uniswap v3 LPs are issued a token when they provide liquidity to Uniswap.
However, because this position is not uniform Uniswap does not give them a normal token because not all positions are the same.
I may have invested 100K in the 0.99-1.01 range whereas you may have invested in the 1.01-1.02 range.
The returns for these two positions are very different and hence it would not make sense for Uniswap to issue me a token of equal value to yours.
For this reason, it issues me a non-fungible token, an NFT.
Summing up the key differences between Uniswap v2 and Uniswap v3
Uniswap V2 and Uniswap V3 are two versions of the Uniswap decentralized exchange (DEX) protocol. Some of the key differences between the two include:
- Liquidity Pools: Uniswap V2 used a single liquidity pool for each trading pair, while Uniswap V3 allows for multiple pools for the same trading pair, each with its own pricing mechanism.
- Fees: Uniswap V3 introduces a new fee structure, which includes trading fees, pool creation fees, and withdrawal fees.
- Performance: Uniswap V3 uses a new mechanism for pricing and trading called “AMM 2.0” that promises improved performance and increased efficiency compared to Uniswap V2.
- Security: Uniswap V3 includes several security upgrades, such as a new security model and measures to prevent flash loans and front-running attacks.
- DeFi Integrations: Uniswap V3 offers improved compatibility with other DeFi protocols and platforms, making it easier to integrate and use with other DeFi applications.
Overall, Uniswap V3 represents a significant upgrade over Uniswap V2, offering improved performance, security, and compatibility with the broader DeFi ecosystem.
Summing up Uniswap v3 exchange
To sum it all up, Uniswap is a fascinating protocol that has helped kick-start the whole decentralized finance movement.
The automated market maker model allows it to secure liquidity from liquidity providers and deliver a decentralized exchange that does more volume than Coinbase.
With Uniswap v3 allowing LPs to concentrate liquidity provision a whole new ball game is introduced.
I hope you enjoyed reading this article as much as I did writing it. Hey, if you want to check out a different exchange why not look up my explanation for Osmosis? It will be an interesting read now that you know all about Uniswap and it sits on the Cosmos Network.
Please share with others if you liked it.