Practical example: Concentrated liquidity and capital efficiency in Uniswap v2 vs v3

Croco Finance
6 min readApr 17, 2021

--

This article will go through an example from Uniswap Blog that shows how concentrated liquidity in Uniswap v3 increases capital efficiency compared to Uniswap v2. We will see that if we concentrate liquidity into a specific price range, we will need less capital compared to Uniswap v2 and we will still gain the same fees as long as the price stays within the specified range.

Disclaimer: This article does not explain what Uniswap or concentrated liquidity is. If you are not familiar with Uniswap, read this article first. If you don’t know anything about concentrated liquidity or other Uniswap v3 features, check Uniswap Blog.

The example from Uniswap Blog is as follows:

Alice and Bob both want to provide liquidity in an ETH/DAI pool on Uniswap v3. They each have $1m. The current price of ETH is 1,500 DAI.

Alice decides to deploy her capital across the entire price range (as she would have in Uniswap v2). She deposits 500,000 DAI and 333.33 ETH (worth a total of $1m).

Bob instead creates a concentrated position, depositing only within the price range from 1,000 to 2,250. He deposits 91,751 DAI and 61.17 ETH, worth a total of about $183,500. He keeps the other $816,500 himself, investing it however he prefers.

While Alice has put down 5.44x as much capital as Bob, they earn the same amount of fees, as long as the ETH/DAI price stays within the 1,000 to 2,250 range.

Step by step solution

We are looking for the answer to the following question:

If Alice deposits $1m worth of liquidity into ETH/DAI = (0; ∞) price range (default Uniswap v2 range), how much assets does Bob have to deposit into the (1000; 2250) price range so that he earns the same fees as Alice as long as the price stays within the specified range?

Let’s start with visualizing the curve which describes Alice’s and Bob’s selected price ranges:

First, we will compute how many assets Alice has. Once we know that, we will use those results to compute how much ETH and DAI Bob has to invest.

Alice

Alice will deposit all $1m into the ETH/DAI = (0; ∞) price range. This means that 50% of the capital will go into ETH and 50% will go into DAI (this is how depositing assets into an infinite price range works). According to the current ETH and DAI prices (1ETH =$1500, 1DAI = $1), she will deposit:

ETH_reserves_Alice = 500 000 / 1500 = 333.33… ETHDAI_reserves_Alice = 500 000 / 1 = 500 000 DAI

Alice’s reserves can be represented by x * y = k curve:

Bob

Bob also has $1m available and he wants to deposit his assets only in the price range ETH/DAI = (1000; 2250). The question is: “How much assets does Bob have to deposit so that he gains the same fees as Alice as long as the ETH/DAI price stays within the specified range?”.

We can see visually how much Bob has to invest from the following chart (more details about this chart can be found in Uniswap v3 whitepaper):

By looking at the chart we see that in order to compute Bob’s reserves, we have to compute “how much reserves Alice would have if the ETH/DAI price is equal to 1,000 and 2,250” (these are the limit prices of Bob’s interval). We can compute tokens reserves for these prices using the following formulas:

Computing constant product

The curve describing Alice’s token reserves is:

x * y = k(NOTE: this is the curve which describes token reserves on the price range from 0 to infinity, which is what Alice chose to invest in),

where k is a constant, x and y are token reserves. In this particular case:

x = DAI_reservesy = ETH_reserves

We have already computed that Alice invested 500,000 DAI and 333.33… ETH into the pool. This means we can compute the value of k as follows:

k = DAI_reserves * ETH_reserves = 500000 * 333.33… = 166666666.7

Now, when we know the value of k, we can compute the amount of Alice’s token reserves for any ETH/DAI price ratio.

Computing Alice’s token reserves for ETH/DAI = 1,000

ETH/DAI price ratio, in this case, is equal to:

price_ratio = 1000

We know that the x * y = k equation applies to any price ratio, so we can write:

ETH_reserves_1000 * DAI_reserves_1000 = k(NOTE: ETH_reserves_1000 is the amount of ETH Alice would have if price_ratio = 1000)

Moreover, we know that the value of ETH_reserves and DAI_reserves has to be the same at all times (for any price ratio). So we can substitute for DAI_reserves this way:

ETH_reserves_1000 * (price_ratio * ETH_reserves_1000) = k(NOTE: there will be “price_ratio times” more DAI than ETH in the pool. This way we ensure that the value of ETH and DAI reserves is the same)

By modifying the previous equation, we get the formula to compute the size of ETH_reserves for the given price ratio:

ETH_reserves_1000 = sqrt(k / price_atio)ETH_reserves_1000 = sqrt(166666666.7 / 1000) = 408.25

Now when we know Alice’s ETH_reserves, we compute Alice’s DAI_reserves in a similar manner. We just substitute for ETH_reserves this time:

ETH_reserves_1000 * DAI_reserves_1000 = k(DAI_reserves_1000 / price_ratio) * DAI_reserves_1000 = kDAI_reserves_1000 = sqrt(k * price_ratio)DAI_reserves_1000 = sqrt(166666666.7 * 1000) = 408248.3

We just computed that if the ETH/DAI price is equal to 1,000, Alice would have 408.25 ETH and 408,248.3 DAI. Next, we will compute Alice’s token reserves for the price ratio of 2250.

Computing Alice’s token reserves for price ETH/DAI = 2,250

Here we can use the same formulas as in the previous step. We just need to use a different value of price_ratio:

price_ratio = 2250ETH_reserves_2250 = sqrt(k / price_ratio)ETH_reserves_2250 = sqrt(166666666.7 / 2250) = 272.16DAI_reserves_2250 = sqrt(k * price_ratio)DAI_reserves_2250 = sqrt(166666666.7 * 2250) = 612 372.4

Compute Bob’s token reserves

Now, we can take a look at the chart showing Bob’s and Alice’s token reserves again, but with the concrete values we just computed:

If we look at the chart, we see that we can compute Bob’s token reserves as:

ETH_reserves_Bob = 333.33 – 272.16 = 61.17DAI_reserves_Bob = 500000 – 408248.3 = 91751.7

We see that Bob has to invest only 61.17 ETH and 91,751.7 DAI (worth a total of $183,506.7) and he earns the same fees as Alice as long as the ETH/DAI price stays within the (1000; 2250) price range. One of the disadvantages of Bob’s strategy is that if the price moves out of the (1000; 2250) price range, he won’t gain any fees.

Conclusion

We were looking for an answer to the following question:

If Alice deposits $1m worth of liquidity into ETH/DAI = (0; ∞) price range, how many assets does Bob have to deposit into the (1000; 2250) price range so that he earns the same fees as Alice as long as the ETH/DAI price stays within the specified range?

The current token prices are: 1ETH =$1,500 and 1DAI = $1.

And the answer is:

Bob has to invest only 61.17 ETH and 91,751.7 DAI (worth a total of $183,506.7) to earn the same fees as Alice as long as the ETH/DAI price stays within the (1000; 2250) price range. This means Bob has to invest 5.449x less capital than Alice.

Alice’s vs Bob’s strategy (taken from uniswap.org)

--

--

Croco Finance

Analysis of your positions in Uniswap, Sushiswap and Balancer