Reverse Deconstruction of Curve V2

BytomDAO
BytomDAO
Published in
7 min readJun 17, 2021

Abstract: Uni V3 had reached the peak of AMM universal exchange, but Curve V2 gets further progress. While we are pleasantly surprised by the technological change, we are even more surprised to find that these head DEX / AMM projects are moving towards an evolution mode of “unification”. As we will talk about today, Curve V2 is actually a general exchange mode that directly competes with Uniswap, but not long ago, Uni V3 has also formally carried a new mathematical model to intervene and encroach on the stablecoin trading field dominated by Curve V1 for a long time. This paper attempts to present the basic mathematical principles of Curve V2 by means of reverse deconstruction.

Basic model

In short, Curve V2 adopts a basic philosophy very similar to Uniswap V3 — aggregation of liquidity around “equilibrium points.”. Both of them do not rely on the external Oracle to reach the “equilibrium point”, but rely on the trading game in the traditional AMM system until the system equilibrium. In uni V3, it is called “professional market maker LP following the market change to adjust range”, and in curve V3, it is named “internal oracle”. As the two top AMM projects, we can see that they are very awed by any external risk. Although they don’t rely on external factors, these two models, especially Curve V2, provide excellent solutions to a series of problems such as volatile loss, centralized liquidity, improving capital efficiency, low sliding point, dynamic cost and so on. This of course benefits from its “abnormal” mathematical model.

The core of the mathematical model is that it creates a new curve. Intuitively, the two dashed lines are constant product curves, the blue line is the famous Curve V1 stablecoin exchange curve, and the Yellow curve constructed by Curve V2 has two basic characteristics — —

(1) It is between constant product curve and Curve V1 curve;

(2) The tail feature of the curve has obvious constant product curve fitting.

So what problems can it solve

(a) It inherits the advantages of Curve V1 in ultra-low slip point and aggregation liquidity near the “equilibrium point”;

(b) By fitting between the constant product curve and Curve V1 curve, and fitting to the constant product curve in the middle and tail region of the curve, the advantages of constant product curve in rapid response to liquidity changes are obtained, so as to avoid the depletion of pool liquidity and flexibly respond to rapid market changes.

Let’s look at the expression directly:

At first glance, it seems very obscure. Here is a picture shared by Kurt Barry on Twitter:

Yes, the “abnormal” curve of Curve V2 is actually derived from the expression of Curve V1.

When K0 approaches 1, that is, when the curve shape approaches the range of “equilibrium point” (as understood by the comparison with figure 1), the whole Curve V2 expression will degenerate to Curve V1 expression, which makes the conversion curve possess the excellent characteristics of Curve v1.

Gamma is the most complex variable in the formula. Its origin is from two constant product curves in Figure 1. The above constant product curve and Curve V1 expression together achieve the “equilibrium point” region range of V2 curve, while the lower constant product curve is a parameterized reduction of the above constant product curve, that is

Constant product curve above:

Lower constant product curve:

Gamma is a small positive decimal, which will be more indented to the origin in the shape of the curve than the curve above. As mentioned earlier, Curve V2 needs to introduce such a gamma curve to make V2 curve get rid of the disadvantage of V1 curve in the middle and tail segments (liquidity depletion and rapid response to exchange rate changes), that is, to make the curve have greater curvature in the second half segment. Under the guidance of this basic principle, we need to understand the composition of expressions in reverse — —

When the coordinate changes continuously to the distance of the abscissa and ordinate axis, the closer to infinity, the lower the V2 curve shape, the more constant product curve fitting. That is, K0 approaches gamma, Curve V2 expression reduction:

transposition:

Obviously, this will be a new curve that tends to be a constant product curve below.

Here, we can only explain the reason of Curve V2 expression from the basic construction principle of mixed curve, that is, to approach the range of “equilibrium point” and approach to the far end of horizontal and vertical by the idea of limit respectively. The expression will be reduced as Curve V1 and constant product curve respectively, so as to realize the purpose of Curve V2 integrating Uniswap and Curve v1, the complex mixed curve can support the general exchange, and has better centralized liquidity and sliding point advantages, while retaining the protection of Uniswap convective property and the response to the sudden changes of market exchange rate.

Internal Oracle

In fact, Curve V2 also has a very important innovation — internal Oracle repegging mechanism. This mechanism is very beneficial to the implementation of better centralized liquidity and the mitigation of volatile losses.

Curve V2 introduces a price_scale measure. For example, there are usdt and B-token in the pool. If the balance is b = [1000, 500] and the exchange rate is 1 B = 2 usdt, then the price is p = [1, 2]. Finally, the scaled balance is x = [1000, 1000].

Combining with figure 1, at the equilibrium point, the elements in the scaled balance sequence are equal (constant product property) — —

With the change of market exchange rate, exchange rate, and influence of LP market-making behavior, the system coordinate point will gradually deviate from the original “equilibrium point”. If the curve shape is not corrected, it will lead to the weakening of liquidity aggregation and lead to impermanent losses. Curve V2 puts forward the Market Price Update mechanism [1] — —

i) exponentially moving average (EMA) price oracle

ii) profit measurement

iii) repricing algorithm (depends on i and ii)

Generally speaking, the system will continuously capture the movement sequence of exchange rate in the system through the classic internal Oracle mechanism EMA, and then continuously update a variable Xcp named profit according to price Oracle after each transaction and market making.

This variable can be understood as the amplitude of each price offset from the original equilibrium point. It can be directly understood that if the exchange rate change is not large, the system formula will still be based on the original equilibrium point. If the exchange rate changes very large and the coordinate point is offset greatly on the curve, the system should rebuild the formula and replace the new “equilibrium point” foundation, this reduces impermanence losses and reinforces liquidity. Xcp is a variable used to quantify the appropriate means of changing formulas and equilibrium points.

As mentioned above, when Xcp breaks through the threshold, the system updates price_ scale according to the updated Oracle price at this time, to locate the new equilibrium point for the new formula, then update the new d value, get the new expression. In this way, the original fixed curve curve curve of Curve V1 will change the equilibrium point with the large offset of the exchange rate in the field, which will always have the maximum liquidity near the current exchange rate, and fight arbitrage in time to slow down the impermanence loss. In this paper, there are very detailed parametric definitions of this mechanism, and it is also a complex part of the implementation.

Conclusion

Michael Egorov is always reluctant to say more, so we see Curve V2 as very obscure. This paper introduces two innovative mechanisms leading by V2: new curve and repegging. This new curve is not only static and complex, but also has dynamic properties. It can maximize the liquidity of pool within the current exchange rate range according to the displacement of EMA and Xcp intelligent response system, which greatly improves the dynamic capital efficiency, which can surpass Uni V3. We will finally find that Curve V2 can be combined with Uni V3 again.

Quote

【1】https://twitter.com/Kurt_M_Barry/status/1404496502240727041

--

--