Uniswap V2 vs V3- A Deep Dive

By Raye Hadi

Table of Contents:

  1. Introduction

  2. V2 Structure

  3. V3 Structure

  4. Design Differences

  5. Active Liquidity

  6. Range Orders

  7. Slippage Resistance

  8. Conclusion

  9. Keywords

  10. Sources


Since it was publicly deployed in 2018, Uniswap has established itself as the most reliable and secure DEX* in the Ethereum ecosystem. With a current TVL* of $3.295 billion, Uniswap remains one of the largest and most important AMMs. Over its lifetime, Uniswap has held its competitive advantage by introducing upgrades to its systems that have played a significant role in maintaining its supremacy. With each upgrade Uniswap has improved the usability and efficiency of its application. These upgrades have improved the experience for users and have been a vital catalyst of defi’s growth to over $38 billion. Early Uniswap users will recall its launch on V2 and the highly anticipated transition to Uniswap V3 in 2021. V3 is the version we know today, but with the Uniswap team planning to roll out V4 in the near future, I thought it would be appropriate to give some insight into the V3 model we are using today compared to the initial V2 model.

V2 Structure

Uniswap V2 uses something called a “constant product algorithm” to make sure the product of the quantities of the two supplied tokens are always the same (x * y = k, where k is held constant). This algorithm allows pools in Uniswap to automatically adjust prices so that liquidity is always available. This works because as the desired market quantity demanded of one token increases, it is removed from the pool by traders, while the other token is supplied by traders in its place. Naturally, the price of the deposited token decreases to reflect its increased supply, while the price of the removed token increases to reflect its decreased supply. Through natural forces, this process occurs autonomously and adjusts proportions to maintain the constant k. This algorithm leverages the laws of supply and demand to maintain an optimal value of k that sustains the pool’s liquidity and replicates market prices. Additionally, in extreme cases of liquidity removal or deposits, the algorithm can adjust prices asymptotically to match demand and retain liquidity. The constant product algorithm is how Uniswap enforces the “equal value ratio” in their pools. The quantity and price of tokens in pools change to maintain an equal value between the pair of tokens.

V3 Structure

Uniswap V3 improves on V2 by focusing on maximizing capital efficiency through a concept called “concentrated liquidity”. In Uniswap V2, when LPs provide liquidity to a token pair (pool) their capital is distributed equally across the entire price curve (range of all possible trading prices between a pair of tokens) (see Image 1).

Image 1: Liquidity Distribution on a V2 Price Curve
Image 1: Liquidity Distribution on a V2 Price Curve

This is inefficient as most assets tend to trade almost entirely in certain price ranges. For example, a trader supplying liquidity to a stablecoin pair like DAI/USDC has their liquidity distributed across the price curve to support all possible price scenarios. However, most trades for this pool happen in the price range $0.99-$1.01 which occupies around ~0.5% of the trading range of the pool, meaning 99.5% of supplied liquidity is likely rarely used. As an LP, it would be much more efficient if you could just supply all your liquidity to the pool between the price range of $0.99-$1.01. This would allow the LP to still capture most transaction fees while obtaining a larger portion of those fees (portion of fees an LP obtains is relative to their share of provided liquidity compared to all other LPs). Instead of spreading out their liquidity, LPs could concentrate it in that heavily frequented price range and hold a greater share of the liquidity that is earning a fee-based yield (in that price range) (see Image 2). This would make our LPs’ capital much more efficient as they are maximizing their share of yield to a select high volume range.

Image 2: Possible Distribution of Liquidity on a V3 Price Curve
Image 2: Possible Distribution of Liquidity on a V3 Price Curve

Additionally, concentrating liquidity allows LPs to supply significantly less capital but still earn the same amount of yield, if the price stays within their chosen range. Let’s consider the previous scenario of the DAI/USDC stablecoin pair again. If an LP were to concentrate $25m in the price range of $0.99-$1.01, on average, they would earn the same amount of fees (yield) that supplying $5 billion equally across the entire price curve would generate. How does this make sense? The price range $0.99-$1.01 takes up only 0.5% of the possible price ranges. If you were required to supply liquidity across every possible price range (like in V2) and still wanted to have an equal share of yield that a concentrated $25m in the price range of $0.99-$1.01 would get you; you would need $ (0.05/1 = $25m/x) → (x = $25m / 0.05) or $5 billion. Thus, the concentrated $25m is a much more efficient use of your capital as an LP than the unconcentrated $5b. Allowing LPs to maintain the same yield with a fraction of the capital, enabling them to make their money go further as they can now earn the same with less. This also protects a significant portion of an LPs’ funds from risk such as potential smart contract vulnerabilities including hacks or bugs because not as much capital must be deployed.

Design Differences

The main difference in design between V3 and V2 that enables concentrated liquidity, is the user’s ability to create individualized price curves. These individualized price curves can be combined to provide liquidity that represents an entire pool. In V2, custom price curves were not possible because liquidity positions were represented with fungible ERC-20 tokens. This meant that every liquidity position of a specific pool (token pair) represented the same distribution along the price curve. In order to create custom liquidity positions with unique distributions (concentrated liquidity), a new pool would have to be created with a new ERC-20 to represent its distribution, every time. This means that every new custom position in V2 required a new pool. This divides up liquidity of a token pair between multiple pools, decreasing efficiency and increasing slippage. It would be more optimal if all liquidity was aggregated in a single pool. However, in this model, to obtain sufficient liquidity depth of a pool, and accommodate custom price curves, the V2 protocol would be forced to aggregate all the divided liquidity of a specific token pair by routing trades through multiple pools at a time. This is inefficient and expensive, significantly hindering the trading experience. By representing positions with non-fungible ERC-721 tokens, V3 allows for custom positions to be built that can easily be aggregated to obtain sufficient liquidity depth. In this model, users trade against the combined liquidity of all individual price curves (represented by non-fungible tokens) with no gas cost increase per liquidity position. Routing through multiple pools is not required. This preserves the trading experience while also increasing the efficiency of the AMM.

Active Liquidity

While the concept of concentrated liquidity makes V3 extremely efficient, it begs the question, what happens to the supplied liquidity when the price moves outside of the LP’s selected price range? Crypto tokens are known to be quite volatile, so it is not wrong to assume this may happen often. When market price moves outside the LP’s chosen range, their position is converted entirely to the less valuable of the two assets from whatever pool they are supplying liquidity to. This effectively removes their assets from the pool and their position is no longer earning fees (see Image 3).

Image 3: Example of the process of Active Liquidity
Image 3: Example of the process of Active Liquidity

The position will remain like this until either market price moves back within their specified range, or they update their range to accommodate the current market price. This is one of the drawbacks of V3. The risk of impermanent loss from this mechanism is increased significantly. To mitigate this risk in V3, LPs require much more sophistication and vigilance to successfully execute their positions.

Range Orders

Another novel feature of the V3 architecture that acts as a complement to concentrated liquidity are “range orders”. In their documentation, this is how the Uniswap team describes range orders: “LPs can deposit a single token in a custom price range above or below the current price: if the market price enters into their specified range, they sell one asset for another along a smooth curve while earning swap fees in the process.”. Let’s break this down. What this means is that LPs can provide liquidity to a token pair using solely one of the tokens of that pair, within a specified price range. While market price remains within that range, they will earn yield (fees) and essentially be acting as a conventional LP. However, once market price exits that specified range, the system will automatically convert their position entirely to the other token of the pair. This conversion is done gradually over the specified price range and is completed in full once the upper or lower limit of the range is crossed (see Image 4). This feature is very useful, because it allows traders to automatically execute strategies such as “profit-taking” while earning the fees of an LP during the duration of their trades. For example, if you are a trader who wants to buy token A that is currently trading at $x, and you want to sell token A at $y (currently x < y) by converting token A to token B. You could open a range order position on Uniswap within the price range of z < x < y. So long as x remains between y and z, as an LP you earn trading fees for the supplied liquidity. As x approaches y, your position is gradually converted to token B. Once the limit has fully been crossed such that x > y, your position will have automatically been fully converted to token B. Essentially, this trade has automatically taken profits at y while earning the trader fees throughout its duration.

Image 4: Visualization of Range Order
Image 4: Visualization of Range Order

By conducting this trade on Uniswap as a range order, the trader has brought more liquidity to the Uniswap ecosystem, improving the depth of that pool and its overall trading experience. Additionally, the trader has had their strategy completely automated for them, with the bonus of yield. This makes Uniswap a much more attractive platform with higher utility through novel functionality. However, these trades require increased attention from LPs as positions can only be terminated manually. To understand why this can be a problem let’s reconsider the example above. When the limit is crossed and x > y, the position is automatically converted to token B, exactly what was intended. However, if the trader fails to manually terminate the position and remove funds from the pool, and x changes such that z < x < y again, we reenter our chosen range. This reconverts the position back to token A, resupplying the funds as liquidity, thus disrupting the performance of the profit-taking strategy. Ideally, the trader would have been aware that the limit had been reached initially and circumvented this issue by manually ending their position. Range orders also mitigate both upside and downside risk of strategies because of the gradual conversion across the price range. As the market price moves up or down, a trader’s position is gradually converted to the paired token at that price level. When the limit is crossed (upper or lower) a trader’s position has changed to a lesser extent than if they had done a straight-out swap at that limit. This may slightly decrease the returns to the upside, but it also decreases the losses to the downside. When the yield that was earned during the duration of the position is considered jointly, this side effect becomes less of a concern.

Slippage resistance

Of all the improvements to functionality and utility that V3 enables, there is an argument that its biggest benefit is its ability to attract liquidity and consequently reduce slippage. Liquidity is the most important component to a successful AMM, and as explained in the previous article on AMMS, sufficient liquidity plays a significant role in minimizing the effects of slippage. The novel features implemented by V3 such as concentrated liquidity and range orders make Uniswap a more attractive place to deploy capital. This provides a deep volume of liquidity relative to other AMMs which prevents whales and other high-volume traders from significantly disrupting the balances of pools. In addition, because capital is much more efficient, less liquidity goes farther on V3 than on V2. While V3 is very beneficial, one issue with the concentrated liquidity model, is its apparent nature to unevenly distribute liquidity (see Image 5).

Image 5: Distribution of Liquidity Relative to Price Range
Image 5: Distribution of Liquidity Relative to Price Range

If all the liquidity of a pool were to be concentrated within the most popular price ranges, what happens when price moves outside of those ranges? Wouldn’t there not be deep enough liquidity to sustain efficient trading experiences and slippage resistance? While this makes sense in theory, due to game theoretical decisions, this rarely occurs. For price ranges with low liquidity allocations, there is enormous opportunity for a trader to act as an LP to that range and collect a significantly higher portion of fees than they would in the popular ranges. While this range may not be often frequented, there is a strong incentive to diversify into these ranges to capture higher yield in the event of large price fluctuations. This results in a reasonable allocation of capital to those price ranges, conversely to what one may assume. While the overall capital allocated to these fringe ranges is minimal relative to popular price ranges, it is still sufficient for the low level of trading at these ranges.

Game theoretical incentives are integral to preventing slippage in uncommon price ranges, but overall slippage resistance must also be accredited to an MEV practice known as “Just-In-Time Liquidity” (JIT liquidity). MEV is something known as “Maximum Extractable Value”, this can be thought of as the maximum value that can be extracted from block production, in excess of the standard block reward and gas fee. For the sake of simplicity, that’s as deep as we are going to get into MEV. JIT liquidity is an MEV practice that enhances slippage resistance by supplying liquidity right before trades to minimize the movements of price. This practice works because the Ethereum blockchain is a transparent network. By scouring the mempool (group of transactions waiting to be validated and executed) (waiting to be put into blocks)(see Image 6), JIT LPs are able to identify profitable sandwiching opportunities.

Image 6: Visualization of the Mempool
Image 6: Visualization of the Mempool

Meaning, when a large trade/transaction enters the mempool, JIT LPs will provide liquidity to the intended liquidity pool, capture a share of the transaction fees that trade generates, then immediately remove their liquidity. Pocketing the profits in the process. This practice is profitable in the presence of high-volume trades since those generate significant transaction fees. Due to this, JIT liquidity enhances slippage resistance as pools with lower depth that may be disrupted by larger trades receive an injection of liquidity right before these large trades, thus reducing slippage. In addition to concentrated liquidity and range orders, JIT liquidity is a vital component to Uniswap V3’s extremely reliable and resilient liquidity depth (see Image 7).

Image 7: Distributions of JIT Liquidity Positions by Size and Quantity
Image 7: Distributions of JIT Liquidity Positions by Size and Quantity


Uniswap’s V3 is a very interesting model, built on the foundation of a secure AMM framework, V3 implements a structure that provides greater functionality and utility to all parties interacting with their ecosystem. The system is extremely slippage resistant as a byproduct of range orders, concentrated liquidity, and the capital efficiency these enable. This resistance is further enhanced by leveraging the forces of JIT liquidity as well. V3 was a drastic improvement on V2 and has been influential to the progress of decentralized finance. However, in light of V3’s utility, the structure has had some notable drawbacks. The increased functionality that comes with the novel features requires greater sophistication and vigilance from both traders and LPs, thus increasing the barrier to entry. The risk of impermanent loss on V3 is also much more profound and the yield earned by traders is diluted from the surge in JIT LPs. V3 creates a more difficult environment for LPs to navigate and demands much more from any LP looking to turn a profit. This is why some traders may still prefer the simplicity of previous versions, even today. Regardless, V3 supports the most trading volume, averaging upwards of a billion dollars daily, compared to V2 in the hundreds of millions and V1 in the hundreds of thousands.

In my opinion, Uni V3’s concentrated liquidity model is net beneficial to defi. While it is not as friendly to LPs as V2 was, the benefits to traders and decentralized applications through capital efficiency and decreased slippage are substantial. From its deployment in 2018 to today, by analyzing the levels of TVL and volume over Uniswap’s life, the efficiency improvements from V3 are obvious (see Image 8).

Image 8: TVL and Volume of Uniswap Since Inception, All Versions
Image 8: TVL and Volume of Uniswap Since Inception, All Versions

While TVL fell with the end of the 2021 bull market and continues to fall through the current bear market, volume has persisted and even increased excessively on occasion. Even so, performance and user experience on the application has not declined but improved. This shows the magnitude of difference brought about by V3’s capital efficiency and novel features. It is safe to assume that with the sparce liquidity of this bear market, V2 and V1 alone would not have been able to support such volume without noticeable drop-offs in the quality of operations. With V4 around the corner, it will be interesting to see how the concepts of “hooks” and “flash accounting” change the platform. With the rise of other AMM’s like Curve, Balancer, and 1inch, Uniswap’s V2 to V3 upgrade was imperative to maintaining its supremacy. We will now get to observe the transition to V4 and see if it yields a similar impact.


DEX: Decentralized Exchange, typically interchangeable with the term “AMM”

TVL: Total value locked, total value currently supplied to an application


Subscribe to Blockchain at the University of Virginia
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
This entry has been permanently stored onchain and signed by its creator.