Looking at Curve's technical details and governance philosophy from the A parameter

A year ago, I made an LP of Uni V3 for a while, and I played it very vigorously. Around that time, there was a saying that being an LP of Curve Tricrypto Pool is a fairly stable and sustainable mainstream asset allocation method, which attracted me to read the Curve V2 white paper. I have some hazy feelings about the temperament of Uni and Curve, and there is a significant difference. **Uni is after the fullest possible free market, while Curve has some precise smell of a planned economy. **

In order to advance this thinking, it is naturally necessary to thoroughly understand the technical details of Curve V2, so I started to study Curve V2 carefully a few months ago. As the founder of Curve, a former physics researcher, Michael freely combined mathematical formulas in the white paper. As an amateur reader of mathematics and science, I struggled to locate the core elements, but not intuitive and easy to understand, Xcp and related D and Virtual Price.

During the research process, I also realized that even a master of ** cannot master it in one day. Curve V2 is a complicated and generalized version modified on the basis of V1. **To understand Curve V1 first, you can grasp the essence of the design more clearly. Retrace the path of masters.

The protagonists of V1 are A and D. The A parameter seems simple, the bigger A is, the more liquidity will be distributed around price 1, and it will be finished in one sentence. But when I read the records of that year (Discord/Governance Forum/Telegram), I kept popping up all kinds of questions surrounding A, some purely technical, some related to protocol governance, all kinds of things, very rich, this is also a single write The origin of the A parameter, the following is part of it. ** Firstly, it discusses the influence of A as a unique parameter of a single DEX on the entire market. An influential parameter, its management becomes an important issue, and the technical details of regulating A are further explored below. **

I wrote about the microcosmic and detailed topic of A parameter, but I haven't forgotten my original intention, and I haven't forgotten my initial interest in the comparison of Uni vs Curve temperament. Often I am still trying to ask, **Is there a fundamental difference in philosophy behind these details? **

1. The relationship between A parameter and the decision of the whole market price

On September 4, 2020, Andre Cronje sent a Proposal in the Curve Governance Forum, hoping to adjust the A parameter of y Pool from 2000 to 1000. It sparked a small amount of discussion, and there were some objections, and it was voted peacefully a few days later. It seems like a topic of no great significance. Compared with the extensive debates on some issues in many DeFi projects later, it seems not worth mentioning.

It is the mathematical complexity of Curve that raises the threshold for discussion, obscures the importance of some issues, and even hinders the understanding of the essence of Curve. **This series of articles focuses on the A parameter, goes back to ancient times, examines several historical events, tries to simplify the mathematics, and makes some really important propositions about Curve appear. **This article is the first one, starting with this proposal of AC.

**A parameter can affect the market price? **

AC and Opponent's Respective Statements

Back to the proposal of AC, the yETH vault expanded rapidly at the end of August and early September (the operation of yETH vault is to absorb and store ETH, Mint DAI, and deposit it in yDAI vault, that is, deposit it in Curve y Pool as LP, get CRV rewards, and sell it into ETH. And then realize the benefits of ETH standard).

As a result, it happened to usher in the rapid decline of ETH. Whenever ETH fell sharply, the demand for DAI increased greatly. The share of DAI in the y Pool has dropped rapidly, reaching as low as 2%.

AC thinks that the A parameter of y Pool is too high (A = 2000), which makes y pool supply a lot of DAI which should not be so cheap to the market. For example, his following discussion.

The opposition mainly revolves around two angles, one of which is related to the selling pressure brought about by yETH vault’s continuous selling of CRV, which will not be discussed here.

What interests me is another angle related to the price determination mechanism.

For example @iamaloop’s view: there is no Cheap DAI, and arbitrageurs will flatten prices everywhere. The A parameter will only affect the imbalance degree of each currency percentage after the currency price in the Curve y Pool is equal to the market price.

@sjlee has a similar expression. @angelangel0v points out that arbitrageurs cannot get lower prices just because of a high A parameter.

The views of these three people can be briefly summarized as follows: the price of DAI is determined by market supply and demand, and the A parameter can only determine the depth of Curve y Pool at different DAI price points, but cannot determine the market price.

The confrontation between the views of the two parties actually leads to a question: What is the relationship between A parameter and market supply and demand?

The important influence of A parameter on the supply side

**In some cases, the A parameter has an extremely significant influence on the supply side, and in turn is one of the most important variables in price determination. **

Before introducing the supply and demand curve diagram, some important assumptions and fundamental factors are discussed.

First, Curve is a Passive LP mode. My judgment is that Passive LP, as the supply side, is relatively more stable, that is, in the face of changing market conditions, its operation frequency is relatively low (“operation” refers to accessing liquidity in a balanced manner, or with The deposit and withdrawal liquidity of the single currency mode of the transaction attribute, "relative" is the active management type LP or CEX market maker relative to Uni V3).

Second, a large part of Curve LP's income comes from CRV token rewards that have little to do with transaction fees, especially in 2020, and the absolute value of the rate of return is relatively high. Then, in the face of relatively small market changes (such as 1-2%), LP is more stable.

The combined effect of the above two points is that Curve LP is more stable.

Third, for some tokens, Curve is the largest liquidity position. For example, the y Pool in 2020 was once the largest exchange pool for DAI.

If the above three points are established at the same time, the supply curve of the whole market will be mainly determined by the Curve Pool. Keeping these three premises in mind, we will enter the discussion of the supply and demand curve below.

Looking at the supply curve of the whole market first, the value of A affects the shape of the curve. **The higher the value of A, the "flatter and longer" the curve near price 1 will be, and the liquidity will be more abundant. **

The supply and demand curve of the whole market

Looking at the demand curve again, we first assume the curve under a stable currency market - demand curve 1. When ETH drops sharply, the demand to close CDP rises sharply, and the market needs more DAI, so the demand curve will shift to the right - demand curve 2.

We observe the intersection of the supply and demand curves, and we can clearly see the influence of the A parameter on the price. **The lower the A value, the higher the new price equilibrium point. **

It can be seen that if the main liquidity position of a token is in Curve, then the A parameter has an extremely important impact on the price decision.

Conclusion

The A parameter more or less affects the price determination of the whole market, and its degree depends on factors such as the reward rate of Curve Pool tokens and the market share of Curve Pool.

Such an important parameter naturally leads to a series of questions. What is the setting mechanism of A parameter? Who will set it, the selection criteria of the value, etc.

Furthermore, the market is not static, which continues to lead to a series of dynamic issues. When do A parameters need to be tuned? What is the effect of adjusting the A parameter at the AMM formula level? etc.

2. Adjusting the curve changes and profit and loss brought about by A

On April 17, 2020, more than a month away from 312, DAI is still in a positive unanchored state, and the price is around 1.02.

Michael (the founder of Curve) launched a poll on Twitter to see if everyone supports adjusting the A parameter of the Compound pool from 900 to 400.

49 people participated in the poll, but only one person responded. Eight hours later, Michael adjusted A to 400, sent another tweet, and got 0 replies.

At that moment, very few people could really participate in the discussion of this issue. Michael may be immersed in one person's experiment, debugging parameters, observation, and improvement. In the few words on Telegram, I feel his interest and fun.

Going back to the adjustment of parameter A this time, it brought about a loss of about 0.1% in daily chemicals.

This article of mine is to explain clearly what does it mean after A is adjusted? Why is there a loss?

An illustration of the corresponding curves for different A values

I selected a set of actual parameter settings and presented them graphically. The object of discussion in this article is Curve V1 Pool, and the curve formula can be found in the V1 white paper.

The parameters corresponding to the black curve are: A = 10 D = 20,000

The current pool is at the black point, the number of X_token and Y_token are 2500 / 18105 respectively, and the price is about 1X_token = 1.36 Y_token.

Now drop A to 3 and the curve will turn into a red line. The parameters of this curve are: A = 3 D = 19,022

Comparing the red and black curves, it is obvious that the proportion of the black curve approaching the straight line is more, which is also the core function of A. The larger the A, the more liquidity around the price 1; the A (10) of the black curve is higher than A(3) of the red curve. Correspondingly, the liquidity in the range far away from price 1 is more in the red curve than in the black curve.

At the time of the Twitter vote, DAI was a bit unanchored. If the red curve with a low A value is used, it can provide more liquidity than the black curve with a high A value. This is why Michael wants to adjust A. He Hope the pool can capture more fees.

Let's go back to the changes brought about by reducing A to 3. At the moment when it is reduced to 3, the number of the two tokens in the pool has not changed, but the D value has changed. In addition, it can be seen from the figure that the slope of the tangent line at the current point has changed, and the shape of the curve has also changed.

These changes are discussed specifically below. The change of the slope of the tangent line and the shape of the curve will be more intuitive if viewed from another angle. The change of D value involves the topic of pool profit and loss assessment.

From the perspective of order book, the change of A value after adjustment

Curve pool can be understood from the perspective of order book. A single pool, according to its A and D parameters, corresponds to different distributions of the number of pending orders at all price points, and all pending orders are linked and exist as a whole.

In the case in the previous section, when A dropped from 10 to 3, it can be understood that all pending orders made an overall major adjustment in an instant, from a black set of pending orders to a red set of pending orders.

Let’s start with some basic descriptions of the image above.

The horizontal axis is the price, 1.00 represents 1 X_token = [ 1.00 ~ 1.01 ) Y_token, 1.01 represents 1 X_token = [ 1.01 ~ 1.02 ) Y_token, and so on. To save space, I have omitted pending orders with prices < 1.00.

The vertical axis represents the quantity of Y_token (that is, the buy order and pending order for X_token). The black part has no data in the range of price > 1.36, because the current price on the black curve is 1.36, > 1.36 means a higher price sell order and pending order of X_token. This picture only examines the part that uses Y_token for pending buy orders, so there is no data for the part > 1.36.

Let's look at the contrast between black and red. First, the current price has changed, corresponding to the change in the slope of the tangent line mentioned in the previous section. After the adjustment of A, the current price instantly changed to 1.92, and the pending order in the red part was extended to 1.92. In other words, a certain number of Y_tokens placed buy orders for X_token in batches within the price range of 1.36 - 1.92.

This is actually a very strange change. The current price of a DEX has changed without Swap. We can immediately imagine that this will form a price difference with the market price, and we assume that arbitrageurs will intervene instantly to push the price to 1.36.

In addition, it can be seen that the number of pending orders at each price point from 1.00 - 1.36 is different, and overall, the number of pending orders at high levels is more. This corresponds to the change in shape of the curve mentioned in the previous section.

Profit and loss from A adjustment - the most direct way to calculate

Michael's tweet mentioned that the reduction of Compound Pool A parameters will bring some losses ('Wipe One Day's Profits'). Before discussing the mathematical relationship behind it, it is necessary to define "loss/profit and loss" clearly.

According to the most direct idea, the definition of profit and loss is very simple, convert the value of two Tokens into U or any one of them (X_token or Y_token), convert two-dimensional to one-dimensional, and then compare the total value of A before and after adjustment . This is also the 'With Impermanent Loss' mentioned by Michael.

Let us briefly discuss profit and loss in this sense. For the sake of simplification, all discussions assume that the handling fee = 0.

Still based on the example that has been used in the previous article, after A is lowered, the instantaneous price of X_token becomes higher, and arbitrageurs intervene to bring the price back to the price before A’s adjustment, which will cause losses. The reason is simple. As mentioned in the previous section, after A is lowered, it is equivalent to placing a lot of purchase orders for X_token at a price higher than the market price. These abnormal purchase orders are eaten by arbitrageurs, which will inevitably bring loss.

It will be more clear from the graph.

The black dot and black curve are the status of the pool before adjustment, and the corresponding price is 1.36. A After lowering, the pool runs according to the red curve. At the moment of lowering, the price of the pool becomes 1.92, and the intervention of arbitrageurs makes the state of the pool quickly move from the black point to the red point, corresponding to the price of 1.36.

It is necessary to compare the total value of the pool before and after A adjustment, and the method is relatively simple.

First look at the adjusted total value of A (after the intervention of arbitrageurs). Find the intersection point of the tangent line of the red curve at the red point and the Y axis, which is the amount of the two tokens converted into a single Y_token at the current price.

Look at the total value of A before adjustment. Find the intersection of the tangent to the black curve at the black point and the Y axis. Because the price before and after the adjustment of A is the same (after the arbitrageur intervenes), this tangent line is parallel to the tangent line in the first step.

Obviously, the intersection of the black tangent line with the Y axis is higher, that is, the total value before A adjustment is higher. A downgrade brings a loss in total value.

The above discussion is limited to the instantaneous loss after A is lowered, which is fairly simple. However, if the tracking time is extended, it becomes a bit complicated to discuss the long-term profit and loss brought about by the lowering of A under different price trends. It depends on whether the price develops in a more unanchored direction or returns to a perfect anchor. The total value of A after adjustment may be lower than the state of A without adjustment, or it may be higher. It will not be expanded here. The purpose of this article is only to briefly demonstrate how the adjustment of A affects the total value of the pool, and does not seek a complete and systematic discussion.

Remove impermanent profit and loss assessment

Converting according to the current price of two Tokens, that is, considering impermanence, this is the most intuitive measurement method, but this method is more troublesome. Curve introduces another unique profit and loss assessment method, which eliminates impermanent factors, simplifies calculations, and is applicable in most cases.

This is the D value, which is another core parameter of the Curve curve formula besides A. The Virtual Price we see in each pool on Curve's official website is calculated based on the D value.

The D value is the total number of two tokens in the pool when the pool price is 1 (perfect anchoring). Because the price is 1 at the moment, the quantities of the two tokens can be simply added. The point where the pool price is equal to 1 is the intersection point of the curve and the straight line x=y.

Going back to the previous example, after A is adjusted down, it is obvious that the value of D becomes smaller. Therefore, in the long run, if the price can be restored to anchor, the change of D value can reflect the loss caused by A adjustment.

In the example I used above, the current price is 1.36, which is actually quite extreme. We look at Curve V1 pools, such as mainstream stablecoin/LSD pools, and the price will not deviate too much from 1. When the price is close to 1, the impact of impermanence is very small, so the change of D value can be directly used to approximately reflect the profit and loss.

**D value, as a one-dimensional measure and as one of the parameters of the pool, is easy to calculate and track historical values, and is more suitable for approximate evaluation of profit and loss. **

Conclusion

The adjustment of A parameter is equivalent to a rearrangement of pending orders at all price points in the order book, which changes the current price point, changes the D value, and brings profit and loss.

Therefore, the one-time large adjustment of the A parameter has a sense of abruptness and even a sense of flaws. The dynamic management of A is not covered in the white paper. Perhaps it was after Curve went online for a period of time that Michael gradually realized that the adjustment method of A parameters needed to be corrected. **Michael followed up with a comment on the tweet announcing that the parameters of Compound Pool A had been adjusted. **In the subsequent new version of the pool, the adjustment of the A parameter has been changed to a mode in which the gradient is completed over a period of time. **

Is the one-time adjustment method of the A parameter of the old pool just a flaw? It's not that simple, and there is a hidden point behind it that can be attacked. Fortunately, it was the white hats who discovered this vulnerability (the depth of understanding of the protocol is really amazing). A separate article will be written later to describe this attack method.

View Original
The content is for reference only, not a solicitation or offer. No investment, tax, or legal advice provided. See Disclaimer for more risks disclosure.
  • Reward
  • Comment
  • Share
Comment
0/400
No comments