Advanced12/31/2023, 8:06:52 AM

This article sorts out the structural thinking process of Curve V1 and Uniswap V3 from the starting point. The two rubbed shoulders in the mathematical sense during the construction process, and how they parted ways to different ends.There was a wonderful discovery. When constructing the AMM formula in 2019, Curve V1 had an intermediate formula in the deduction process, and this formula had exactly the same structure as the basic formula of Uniswap V3 more than a year later (the former is a special form of the latter). A completely different path of thought, and a mathematical intersection has appeared, which is wonderful. This article will sort out the structural thinking process of Curve V1 and Uniswap V3 from the starting point. The two rubbed shoulders in the mathematical sense during the construction process, and how they parted ways to different ends.

Uniswap’s xy=k launch at the end of 2018 was a paradigm revolution. However, in the stablecoin trading pair scenario, the flaws are significant. Michael seized this entry point and launched the new AMM Curve V1 at the end of ‘19.

One of the foundations of the construction process for the new AMM formula is still xy = k. In the future, it will be uniformly written as the following formula according to the parameter codes in the Curve V1 white paper.

Most of the time, the price of stablecoin trading pairs only fluctuates in a very small range around 1:1. The formula that only provides liquidity at a single 1:1 price point is x+y = D, which is another foundation of the construction process.

Michael wants to combine the two basic equations, or introduce some x+y = D characteristics based on xy = (D/2) ².

As a result, the two basic formulas were added together, and a mixed formula was obtained.

Among them, the part where x+y=D is added an A parameter, and D is additionally multiplied on both sides of the equal sign. The reason for multiplying D is to de-dimensionalize the A parameter (regardless of whether there are 2 tokens, 3 tokens, or more in the pool, the same A value has the same effect). It’s not discussed here, nor is it the focus of this discussion.

Focus on the A parameter. First, the Curve V1 white paper uses the Greek letter Chi (which looks a lot like x) in the blending formula, not A. I switched to A for ease of writing and reading experience, and it didn’t affect the discussion.

The effect of parameter A can probably be understood by analogy with a black, gray and white color bar. 90 %灰就很像黑了，而10% gray is closer to white. The A parameter determines whether the final product of the formula is more like x+y=d, or xy= (D/2) ².

From the numerical value of limit A, we can better understand this blending process. A = 0, and the mixing formula becomes xy= (D/2) ². A = infinity, and the mixing formula becomes x+y = d. So A is an intermediate state in it. The bigger A is, the more like x+y=D. This combination can be felt more intuitively through graphics, and if you are interested, you can play A in desmos².

Regarding Curve V1, let’s stop here; please keep this formula in mind in general. Then let’s take a look at the Uniswap V3 situation next.

After Uni V1/V2’s xy = k dominated the river, the shortcomings caused by “uniform distribution of liquidity over a complete price range from 0 to infinity” became increasingly apparent, and the launch of Curve V1 directly and accurately cut out the important market for stablecoin transactions.

When designing V3, the Uniswap team first wanted to construct a formula that only provided liquidity within a finite continuous price range. The starting point of their construction was still xy=k.

Imagine if you want to achieve an effect, within the [Pa, Pb] price range (e.g. [0.99, 1.01] or [1500, 1700]), this formula supports transactions exactly like the xy = k of Uni V1/V2, but when the price exceeds [Pa, Pb], it no longer provides liquidity.

The corresponding formula for this effect is as follows:

If you use a graph to present it, it will be very clear, that is, shift xy=k some position down to the left. The exact amount to be moved is determined by Pa and Pb.

The effect achieved by this formula is that all liquidity is concentrated in [Pa, Pb], LP deposits a certain amount of x_tokens and Y_tokens, providing some liquidity within the [Pa, Pb] price range. For this partial liquidity effect alone, if Uni V2’s LP is to be achieved, LP is required to deposit more x_tokens and Y_tokens; the extent depends on Pa and Pb, and may require a lot more.

This translation formula is the basic formula for the further construction of Uni V3. Let’s talk about Uni V3 for now.

Make some transformations of the curve V1 formula in section 1:

If you look at the Uni V3 translation formula in section 2, you’ll see that the two are very similar:

If Pa and Pb in the Uni V3 translation formula are further defined, Pb = 1/Pa, that is, the defined price range is a range similar to [0.5, 2] or [0.01, 100], satisfying the symmetry in the sense of multiples on both sides of the 1:1 price point.

After making this limitation, it can be said that the two equations are exactly the same:

The two formulas have different parameter expressions, and it is easy to deduce the relationship between the two sets of parameters. Let’s calculate L and Pa based on the parameters A and D of the Curve V1 mixture formula, as shown below:

The significance of these parameters is related to the thinking path of each construction of the two protocols. Let’s combine the relationships between the two sets of parameters and then briefly review the two construction processes.

For simplicity, let’s say a pool of stablecoin trading pairs, the initial price is 1:1. The D in the Curve V1 blend formula represents the amount of D/2 each of the two stablecoins invested in the initial LP. A represents the degree to which this mixing equation approaches x+y = d.

Coming to the Uni side, let’s create another Uni V2 stablecoin trading pair pool, which satisfies the following formula:

In other words, if the initial price is 1:1, the initial LP requires investing as much as D (2A+1) /2 of each of the two stablecoins.

At this point, there is a Uni V3 pool. The desired effect is to only provide liquidity within the following price ranges:

Furthermore, the liquidity effect within this range is just like the Uni V2 pool that just came out virtually. The formula corresponding to the Uni V3 pool that satisfies this effect is exactly the same as the Curve V1 blending formula described above.

Briefly summarized, the effect achieved by Curve V1 is exactly equivalent to first creating a Uni V2 pool with a much larger token reserve (2A times more), and then achieving the exact same liquidity effect as this Uni V2 pool in the [(2A/ (2A+1))) ², (2A+1) /2A) ²] price range.

The Curve V1 blend formula is a special form of the Uni V3 translation formula. In fact, if one more parameter is introduced into the Curve V1 mixing formula, and the x+y part is adjusted to x+py, the two are completely equivalent; there isn’t much explanation here.

Curve V1 is based on the fusion formula, and Uni V3 follows their original thought path on the basis of the translation formula and went their separate ways.

Curve V1 has a flaw in the blending formula. It only provides liquidity within a limited price range. Michael needed a formula with liquidity in all price ranges. (As to why is there such a demand? (Perhaps it is natural for the entire price range to have liquidity, in a more complete and sound state, for example, in the sense of providing Oracle to the outside world.)

We can understand his idea of further construction in this way: to make this degree of integration dynamic. A in the previous mixing formula is a constant representing the uniform degree of mixing. Now, further, when x deviates more from D/2 (that is, when x is smaller or larger), or when the price deviates 1:1 more, making the degree of mixing more biased towards xy = (D/2) ², x or when the price deviates from the limit state, it becomes simply xy = (D/2) ², so that the entire price range is liquid.

Michael turned A into Axy/ (D/2) ²

This allows you to achieve the dynamic gradient effect described above. Of course, the construction method is not limited to this one. I have a feeling that Michael did not do a very in-depth comparative study on the differences between the different dynamic gradation implementation methods in this step of the construction process. Perhaps as long as it is convenient to achieve full price liquidity, that’s all.

Finally, we have the final morphological formula for Curve V1 as follows:

The core connotation of the Uni V3 translation formula is the price range [Pa, Pb]. Based on this translation formula, Uni V3 naturally went in one direction; the liquidity in different price ranges can be different (if the liquidity in different price ranges is the same, then back to Uni V2).

There are still different design bifurcations in this general direction. A fork in the road can be agreed upon to determine the liquidity allocation rules for a different price range. LPs are still homogenous; in fact, Curve V1 can be thought of as this type (the price range limit is small).

Another fork in the road. All decision-making power is transferred to LPs. The LPs make independent decisions together to determine how the final liquidity is distributed in different price ranges.

Uni V3 chose the latter. This choice is extremely critical. This greatly enriches the elements of the entire market game. Price judgment, volatility judgment, luck components, etc. are all involved, bringing the liquidity market one step closer to a fully competitive market.

Looking at the further construction of Uni V3 from a mathematical point of view, at first glance, it looks like an unconventional segmented function. Different price ranges correspond to different L values, and accordingly there are different formulas, such as the following minimalist example:

In fact, the above can be converted into a standard segmented function, that is, the subdomain is defined by x. The subfunction is a formula for y and x. This article will not expand.

Curve V1 was launched at the end of 2019. At the time, its main purpose was to better support stablecoin trading pairs and fill gaps in this market. Perhaps it is this that determined Michael’s way of thinking. The focus is on a structure that is symmetrical at 1:1 price points, and liquidity is relatively concentrated around the 1:1 price point. When Michael deduced the blending formula by crossing x+y = d and xy = (D/2) ², it seems to me that the most core and most pioneering work has been completed, because this blending formula already satisfies the symmetric and clustering characteristics described above. Further transforming the blending formula into a formula that supports liquidity across the entire price range, for Michael, is probably just a minor subcalculation and finishing the work.

Uni V3 was launched later, and a white paper was released in March 2021. The Uni team has seen Curve V1 run long enough. A group of extremely smart people, the way to fight back against Curve naturally requires upgrading. The Uni team directly broke a major premise. LPs are no longer “big pot meals” and can no longer uniformly follow a single fixed formula for each pool to provide liquidity.

On the basis of Uni V1/V2 xy=k, Uni V3 constructs a basic formula (that is, the translation formula described above) that only provides liquidity within a specific price range. Uni V3 wanted to break the premise of LP’s “big pot meal,” so it gave LPs the freedom to decide what price range (or several ranges) to provide liquidity. Each individual LP makes decisions freely, and when summed up at each pool level, it also forms a formula (segmented function). However, the shape of this formula changes dynamically, and is definitely not a fixed shape pattern like previous AMM (some AMMs can adjust the shape through governance, such as Curve V1 to adjust the A parameter).

This design not only solved the problem of Uni V2’s low capital efficiency in the stablecoin trading pair scenario (counterattack Curve V1), but also introduced fuller competition in all trading pair scenarios, improving the overall financial efficiency level of the market.

After sorting through the differences in historical background and fundamental starting point, let’s take a look at the similarity between the Curve V1 blend formula and the Uni V3 translation formula, which seemed like nothing more than a simple mathematical coincidence worth mentioning.

- This article is reprinted from [Buidler DAO], and the copyright belongs to the original author [
**observerdq**]. If you have any objections to the reprint, please contact the Gate Learn team, and the team will deal with it as soon as possible in accordance with the relevant procedures. - Disclaimer: The views and opinions expressed in this article only represent the author’s personal opinions and do not constitute any investment advice.
- Articles in other languages are translated by the Gate Learn team, and translated articles may not be copied, distributed, or copied without mentioning Gate.io.

Advanced12/31/2023, 8:06:52 AM

This article sorts out the structural thinking process of Curve V1 and Uniswap V3 from the starting point. The two rubbed shoulders in the mathematical sense during the construction process, and how they parted ways to different ends.

There was a wonderful discovery. When constructing the AMM formula in 2019, Curve V1 had an intermediate formula in the deduction process, and this formula had exactly the same structure as the basic formula of Uniswap V3 more than a year later (the former is a special form of the latter). A completely different path of thought, and a mathematical intersection has appeared, which is wonderful. This article will sort out the structural thinking process of Curve V1 and Uniswap V3 from the starting point. The two rubbed shoulders in the mathematical sense during the construction process, and how they parted ways to different ends.

Uniswap’s xy=k launch at the end of 2018 was a paradigm revolution. However, in the stablecoin trading pair scenario, the flaws are significant. Michael seized this entry point and launched the new AMM Curve V1 at the end of ‘19.

One of the foundations of the construction process for the new AMM formula is still xy = k. In the future, it will be uniformly written as the following formula according to the parameter codes in the Curve V1 white paper.

Most of the time, the price of stablecoin trading pairs only fluctuates in a very small range around 1:1. The formula that only provides liquidity at a single 1:1 price point is x+y = D, which is another foundation of the construction process.

Michael wants to combine the two basic equations, or introduce some x+y = D characteristics based on xy = (D/2) ².

As a result, the two basic formulas were added together, and a mixed formula was obtained.

Among them, the part where x+y=D is added an A parameter, and D is additionally multiplied on both sides of the equal sign. The reason for multiplying D is to de-dimensionalize the A parameter (regardless of whether there are 2 tokens, 3 tokens, or more in the pool, the same A value has the same effect). It’s not discussed here, nor is it the focus of this discussion.

Focus on the A parameter. First, the Curve V1 white paper uses the Greek letter Chi (which looks a lot like x) in the blending formula, not A. I switched to A for ease of writing and reading experience, and it didn’t affect the discussion.

The effect of parameter A can probably be understood by analogy with a black, gray and white color bar. 90 %灰就很像黑了，而10% gray is closer to white. The A parameter determines whether the final product of the formula is more like x+y=d, or xy= (D/2) ².

From the numerical value of limit A, we can better understand this blending process. A = 0, and the mixing formula becomes xy= (D/2) ². A = infinity, and the mixing formula becomes x+y = d. So A is an intermediate state in it. The bigger A is, the more like x+y=D. This combination can be felt more intuitively through graphics, and if you are interested, you can play A in desmos².

Regarding Curve V1, let’s stop here; please keep this formula in mind in general. Then let’s take a look at the Uniswap V3 situation next.

After Uni V1/V2’s xy = k dominated the river, the shortcomings caused by “uniform distribution of liquidity over a complete price range from 0 to infinity” became increasingly apparent, and the launch of Curve V1 directly and accurately cut out the important market for stablecoin transactions.

When designing V3, the Uniswap team first wanted to construct a formula that only provided liquidity within a finite continuous price range. The starting point of their construction was still xy=k.

Imagine if you want to achieve an effect, within the [Pa, Pb] price range (e.g. [0.99, 1.01] or [1500, 1700]), this formula supports transactions exactly like the xy = k of Uni V1/V2, but when the price exceeds [Pa, Pb], it no longer provides liquidity.

The corresponding formula for this effect is as follows:

If you use a graph to present it, it will be very clear, that is, shift xy=k some position down to the left. The exact amount to be moved is determined by Pa and Pb.

The effect achieved by this formula is that all liquidity is concentrated in [Pa, Pb], LP deposits a certain amount of x_tokens and Y_tokens, providing some liquidity within the [Pa, Pb] price range. For this partial liquidity effect alone, if Uni V2’s LP is to be achieved, LP is required to deposit more x_tokens and Y_tokens; the extent depends on Pa and Pb, and may require a lot more.

This translation formula is the basic formula for the further construction of Uni V3. Let’s talk about Uni V3 for now.

Make some transformations of the curve V1 formula in section 1:

If you look at the Uni V3 translation formula in section 2, you’ll see that the two are very similar:

If Pa and Pb in the Uni V3 translation formula are further defined, Pb = 1/Pa, that is, the defined price range is a range similar to [0.5, 2] or [0.01, 100], satisfying the symmetry in the sense of multiples on both sides of the 1:1 price point.

After making this limitation, it can be said that the two equations are exactly the same:

The two formulas have different parameter expressions, and it is easy to deduce the relationship between the two sets of parameters. Let’s calculate L and Pa based on the parameters A and D of the Curve V1 mixture formula, as shown below:

The significance of these parameters is related to the thinking path of each construction of the two protocols. Let’s combine the relationships between the two sets of parameters and then briefly review the two construction processes.

For simplicity, let’s say a pool of stablecoin trading pairs, the initial price is 1:1. The D in the Curve V1 blend formula represents the amount of D/2 each of the two stablecoins invested in the initial LP. A represents the degree to which this mixing equation approaches x+y = d.

Coming to the Uni side, let’s create another Uni V2 stablecoin trading pair pool, which satisfies the following formula:

In other words, if the initial price is 1:1, the initial LP requires investing as much as D (2A+1) /2 of each of the two stablecoins.

At this point, there is a Uni V3 pool. The desired effect is to only provide liquidity within the following price ranges:

Furthermore, the liquidity effect within this range is just like the Uni V2 pool that just came out virtually. The formula corresponding to the Uni V3 pool that satisfies this effect is exactly the same as the Curve V1 blending formula described above.

Briefly summarized, the effect achieved by Curve V1 is exactly equivalent to first creating a Uni V2 pool with a much larger token reserve (2A times more), and then achieving the exact same liquidity effect as this Uni V2 pool in the [(2A/ (2A+1))) ², (2A+1) /2A) ²] price range.

The Curve V1 blend formula is a special form of the Uni V3 translation formula. In fact, if one more parameter is introduced into the Curve V1 mixing formula, and the x+y part is adjusted to x+py, the two are completely equivalent; there isn’t much explanation here.

Curve V1 is based on the fusion formula, and Uni V3 follows their original thought path on the basis of the translation formula and went their separate ways.

Curve V1 has a flaw in the blending formula. It only provides liquidity within a limited price range. Michael needed a formula with liquidity in all price ranges. (As to why is there such a demand? (Perhaps it is natural for the entire price range to have liquidity, in a more complete and sound state, for example, in the sense of providing Oracle to the outside world.)

We can understand his idea of further construction in this way: to make this degree of integration dynamic. A in the previous mixing formula is a constant representing the uniform degree of mixing. Now, further, when x deviates more from D/2 (that is, when x is smaller or larger), or when the price deviates 1:1 more, making the degree of mixing more biased towards xy = (D/2) ², x or when the price deviates from the limit state, it becomes simply xy = (D/2) ², so that the entire price range is liquid.

Michael turned A into Axy/ (D/2) ²

This allows you to achieve the dynamic gradient effect described above. Of course, the construction method is not limited to this one. I have a feeling that Michael did not do a very in-depth comparative study on the differences between the different dynamic gradation implementation methods in this step of the construction process. Perhaps as long as it is convenient to achieve full price liquidity, that’s all.

Finally, we have the final morphological formula for Curve V1 as follows:

The core connotation of the Uni V3 translation formula is the price range [Pa, Pb]. Based on this translation formula, Uni V3 naturally went in one direction; the liquidity in different price ranges can be different (if the liquidity in different price ranges is the same, then back to Uni V2).

There are still different design bifurcations in this general direction. A fork in the road can be agreed upon to determine the liquidity allocation rules for a different price range. LPs are still homogenous; in fact, Curve V1 can be thought of as this type (the price range limit is small).

Another fork in the road. All decision-making power is transferred to LPs. The LPs make independent decisions together to determine how the final liquidity is distributed in different price ranges.

Uni V3 chose the latter. This choice is extremely critical. This greatly enriches the elements of the entire market game. Price judgment, volatility judgment, luck components, etc. are all involved, bringing the liquidity market one step closer to a fully competitive market.

Looking at the further construction of Uni V3 from a mathematical point of view, at first glance, it looks like an unconventional segmented function. Different price ranges correspond to different L values, and accordingly there are different formulas, such as the following minimalist example:

In fact, the above can be converted into a standard segmented function, that is, the subdomain is defined by x. The subfunction is a formula for y and x. This article will not expand.

Curve V1 was launched at the end of 2019. At the time, its main purpose was to better support stablecoin trading pairs and fill gaps in this market. Perhaps it is this that determined Michael’s way of thinking. The focus is on a structure that is symmetrical at 1:1 price points, and liquidity is relatively concentrated around the 1:1 price point. When Michael deduced the blending formula by crossing x+y = d and xy = (D/2) ², it seems to me that the most core and most pioneering work has been completed, because this blending formula already satisfies the symmetric and clustering characteristics described above. Further transforming the blending formula into a formula that supports liquidity across the entire price range, for Michael, is probably just a minor subcalculation and finishing the work.

Uni V3 was launched later, and a white paper was released in March 2021. The Uni team has seen Curve V1 run long enough. A group of extremely smart people, the way to fight back against Curve naturally requires upgrading. The Uni team directly broke a major premise. LPs are no longer “big pot meals” and can no longer uniformly follow a single fixed formula for each pool to provide liquidity.

On the basis of Uni V1/V2 xy=k, Uni V3 constructs a basic formula (that is, the translation formula described above) that only provides liquidity within a specific price range. Uni V3 wanted to break the premise of LP’s “big pot meal,” so it gave LPs the freedom to decide what price range (or several ranges) to provide liquidity. Each individual LP makes decisions freely, and when summed up at each pool level, it also forms a formula (segmented function). However, the shape of this formula changes dynamically, and is definitely not a fixed shape pattern like previous AMM (some AMMs can adjust the shape through governance, such as Curve V1 to adjust the A parameter).

This design not only solved the problem of Uni V2’s low capital efficiency in the stablecoin trading pair scenario (counterattack Curve V1), but also introduced fuller competition in all trading pair scenarios, improving the overall financial efficiency level of the market.

After sorting through the differences in historical background and fundamental starting point, let’s take a look at the similarity between the Curve V1 blend formula and the Uni V3 translation formula, which seemed like nothing more than a simple mathematical coincidence worth mentioning.

- This article is reprinted from [Buidler DAO], and the copyright belongs to the original author [
**observerdq**]. If you have any objections to the reprint, please contact the Gate Learn team, and the team will deal with it as soon as possible in accordance with the relevant procedures. - Disclaimer: The views and opinions expressed in this article only represent the author’s personal opinions and do not constitute any investment advice.
- Articles in other languages are translated by the Gate Learn team, and translated articles may not be copied, distributed, or copied without mentioning Gate.io.

Start Now

Sign up and get a

$100

Voucher!