Author: @observerdq
Editor: @Heiyu Xiaodou
Source: BuilderDAO
Author’s Note
About a year ago, I spent some time as an LP for Uni V3 and had a great time. Around the same time, there was a saying that being an LP for Curve Tricrypto Pool was a stable and mainstream asset allocation method for generating continuous profits. This intrigued me and led me to read the Curve V2 whitepaper. I had a vague sense of the differences between Uni and Curve, with Uni pursuing a more free market approach and Curve having a hint of planned economy.
- An Explanation of KINE’s Asset Strength and Technical Team
- LianGuaintera Capital’s Perspective on Cosmos Core Advantages, Innovation, and Important Ecosystem
- Starknet technology stack enters the explosive period, and the first application chain is about to be born.
In order to further explore this, it was necessary to thoroughly understand the technical details of Curve V2, so I started studying it carefully a few months ago. Michael, the founder of Curve and a former researcher in the field of physics, seamlessly combines mathematical formulas in the whitepaper. As a reader with limited knowledge of mathematics, I struggled to grasp the core and less intuitive elements, such as Xcp and its related concepts like D and Virtual Price.
During the research process, I also realized that even for the experts, mastery is not achieved overnight. Curve V2 is a complex and generalized version built upon V1. Therefore, understanding Curve V1 first can provide a clearer grasp of the design principles. I decided to retrace the path of the experts.
In V1, the main characters are A and D. At first glance, the A parameter seems simple: the larger A is, the more liquidity is allocated around the price of 1. However, when reviewing the records from that time (Discord/governance forum/Telegram), various questions related to A kept popping up, including technical aspects and protocol governance. These questions were rich and diverse, which is why I chose to focus on the A parameter. The following is a part of those discussions. First, the influence of A as a unique parameter for a single DEX on the entire market was explored. A parameter with influence raises important issues regarding its management, and the subsequent discussion delves into the technical details of regulating A.
Although I delved into the microscopic topic of the A parameter, I didn’t forget my original intention or my initial interest in comparing the characteristics of Uni and Curve. I often ask myself whether these details reveal a fundamental difference in ideology.
– dq
I. The Relationship between the A Parameter and the Market Price
On September 4, 2020, Andre Cronje posted a proposal on the Curve governance forum, suggesting adjusting the A parameter of the y Pool from 2000 to 1000. This sparked some discussion and opposition, but a few days later, it was calmly approved through voting. It seemed like a topic of little significance compared to the extensive debates on various issues in many other DeFi projects. The mathematical complexity of Curve raised the threshold for discussions, obscuring the importance of certain issues and even hindering a true understanding of Curve’s essence. This series of articles focuses on the A parameter, going back to ancient times and examining several historical events, attempting to simplify the mathematics and bring out some truly important propositions about Curve. This article is the first one, starting with this proposal by AC.
Can the A parameter affect market prices? Statements from AC and opponents
Returning to AC’s proposal, in late August and early September, the yETH vault saw rapid expansion (the operation of the yETH vault is to absorb ETH, mint DAI, deposit it into the yDAI vault, which in turn is deposited into the Curve y Pool as LP, earning CRV rewards, selling them for ETH, and thus achieving ETH-based returns).
This happened to coincide with a rapid decline in ETH prices, which resulted in a significant increase in demand for DAI. The share of DAI in the y Pool plummeted rapidly, reaching as low as 2%.
AC believes that the A parameter of the y Pool is too high (A = 2000), causing the y Pool to supply DAI to the market at a price that should not be so cheap. For example, he makes the following argument.
The opposing voices mainly revolve around two angles, one of which is related to the selling pressure caused by continuous selling of CRV from the yETH vault, 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 such thing as Cheap DAI, as arbitrageurs will equalize prices everywhere. The A parameter only affects the imbalance of the percentages of various coins in the Curve y Pool when the coin price is equal to the market price.
@sjlee has a similar expression. @angelange l0 v suggests that arbitrageurs cannot obtain lower prices just because of a high A parameter.
In summary, the opinions of these three individuals are: The price of DAI is determined by market supply and demand, and the A parameter can only determine the depth of the Curve y Pool at different DAI price points, but not the market price.
The confrontation between the two viewpoints actually raises a question: What is the relationship between the A parameter and market supply and demand?
The significant impact of the A parameter on the supply side
In certain cases, the A parameter has a significant impact on the supply side and therefore is one of the most important variables in price determination.
Before discussing the supply-demand curve, let’s first discuss several important assumptions and basic factors.
First, Curve is a LianGuaissive LP model. My judgment is that as a supplier, LianGuaissive LP is relatively stable, meaning that its frequency of operations is relatively low when facing changing market conditions (“operations” refer to balancing liquidity supply and withdrawal, or accessing liquidity with trading attributes in single-coin mode, and “relatively” is in comparison to Uni V3’s actively managed LP or CEX’s market makers).
Second, a significant portion of Curve LP’s earnings come from CRV token rewards that are not related to transaction fees, especially in 2020, and the absolute value of the return rate is high. Therefore, when facing 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 pool. For example, in 2020, the y Pool was the largest exchange pool for DAI.
If all three points are simultaneously valid, the supply curve of the entire market will be mainly determined by the Curve Pool. Remember these three premises, and let’s move on to the discussion of the supply and demand curves.
First, let’s look at the supply curve of the entire market. The A value affects the shape of the curve. The higher the A value, the “flatter and longer” the curve near price 1, and the more abundant the liquidity.
Market supply and demand curve
Now let’s look at the demand curve. Let’s first assume a stable market situation – demand curve 1. When ETH experiences a sharp decline, the demand for closing CDPs sharply increases, and the market needs more DAI, so the demand curve will shift to the right – demand curve 2.
By observing the intersection of the supply and demand curves, we can clearly see the impact of the A parameter on the price. The lower the A value, the higher the corresponding new equilibrium price.
It can be seen that if a token’s main liquidity is on Curve, then the A parameter has a very important impact on price determination.
Conclusion
The A parameter more or less affects the price determination of the entire market, and the extent depends on factors such as the token reward rate of Curve Pool and the market share of Curve Pool.
Such an important parameter naturally leads to a series of questions. What is the mechanism for setting the A parameter? Who sets it and what are the criteria for choosing the value?
Furthermore, the market is not static, which leads to a series of dynamic questions. When does the A parameter need to be adjusted? What is the impact of adjusting the A parameter at the AMM formula level? and so on
II. Changes in the curve and gains/losses caused by adjusting A
On April 17, 2020, more than a month away from 312, DAI was still in a positive deviation state with a price of around 1.02.
Michael (Founder of Curve) initiated a poll on Twitter to see if people supported adjusting the A parameter of the Compound pool from 900 to 400.
49 people participated in the poll, but only one person responded. 8 hours later, Michael adjusted A to 400 and tweeted again, with 0 replies.
At that moment, there were very few people who could truly participate in the discussion of this issue. Michael may have been immersed in his own experiment, tweaking parameters, observing, and improving. In the fragments of conversation on Telegram, I could feel his enthusiasm and enjoyment.
Returning to the adjustment of the A parameter, it resulted in a daily loss of about 0.1%.
The purpose of this article is to clarify what it means when A is adjusted and why it results in losses.
A Graph Illustrating Different Values of A
I have selected a set of actual parameter settings for illustration. The discussion in this article is about Curve V1 Pool, and the curve formula can be found in the V1 whitepaper.
The parameter values for the black curve are: A = 10, D = 20,000
The current pool is represented by the black dot, with quantities of X_token and Y_token being 2500 and 18105 respectively, and the price is approximately 1X_token = 1.36 Y_token.
At this moment, if A is reduced to 3, the curve will become a red line. The parameters for this curve are: A = 3, D = 19,022.
Comparing the red and black curves, it is clear that the black curve has a higher proportion of approaching straight lines, which is the core function of A. The larger the A value, the more liquidity near the price of 1. The A value of the black curve (10) is higher than that of the red curve (3). Similarly, the liquidity in the range away from the price of 1 is greater for the red curve than the black curve.
At the time of the Twitter poll, DAI was somewhat unanchored. If the red curve with a lower A value is used, it can provide more liquidity than the black curve with a higher A value. This is also the reason why Michael wants to adjust A, as he hopes the pool can capture more fees.
Let’s go back to the changes brought about by reducing A to 3. At that moment, the quantities of the two tokens in the pool did not change, but the D value did change. In addition, it can be seen from the graph that the slope of the tangent line at the current point has changed, and the shape of the curve has also changed.
Next, let’s explore these changes in more detail. The changes in the slope of the tangent line and the shape of the curve will be more intuitive from a different perspective. The change in the D value involves the topic of pool profit and loss evaluation.
Changes After Adjusting the A value from the Perspective of Order Book
The Curve pool can be understood from the perspective of the order book. For a single pool, different A and D parameters correspond to different distributions of order quantities at all price points, and all orders are interconnected and exist as a whole.
In the previous case, when A dropped from 10 to 3, it can be understood as all orders making a comprehensive adjustment, transforming from a set of black orders to a set of red orders.
Let’s start with some basic explanations of the above graph.
The horizontal axis represents 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 the orders with prices < 1.00.
The vertical axis represents the quantity of Y_token (i.e., buy orders for X_token). The black part does not have data in the range where the price is > 1.36. This is because the current price on the black curve is 1.36, and > 1.36 means higher-priced sell orders for X_token. This graph only examines the part of the buy orders using Y_token, so there is no data for the part > 1.36.
We 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 adjustment A, the current price instantly changed to 1.92, and the red part extended to 1.92. In other words, a certain amount of Y_token was placed in batches within the price range of 1.36-1.92 to buy X_token.
This is actually a strange change. The current price of a DEX has changed without any Swap. We can immediately think that this will form a price difference with the market price, and we assume that arbitrageurs will instantly intervene to bring the price down to 1.36.
In addition, it can be seen that the number of orders at each price point from 1.00 to 1.36 is different, and overall, there are more orders at higher prices. This corresponds to the change in the shape of the curve mentioned in the previous section.
Profit and Loss from Adjustment A – The Most Direct Calculation Method
Michael’s suggestion mentioned that reducing the parameters of Compound Pool A would result in some losses (‘Wipe One Day’s Profits’). Before discussing the mathematical relationship behind it, it is necessary to define the “loss/profit” clearly.
According to the most direct idea, defining profit and loss is simple. Convert the values of both tokens into U or either one (X_token or Y_token), from two dimensions to one dimension, and then compare the total value before and after adjustment A. This is also what Michael mentioned as ‘With Impermanent Loss’.
Let’s briefly discuss this notion of profit and loss. For simplicity, let’s assume the transaction fee is 0.
Based on the example we have been using, after adjustment A, the instantaneous price of X_token becomes higher, and arbitrageurs intervene to bring the price back to the price before adjustment A, which will result in losses. The reason is simple. As mentioned in the previous section, after adjustment A, many abnormal buy orders for X_token were placed at prices higher than the market price, and these abnormal buy orders were taken by arbitrageurs, which will inevitably lead to losses.
It will be clearer from the chart.
The black dots and black curve represent the state of the pool before adjustment, corresponding to a price of 1.36. After adjustment A, the pool runs according to the red curve. At the moment of adjustment, the pool price becomes 1.92, and arbitrageurs intervene to quickly move the pool’s state from the black dot to the red dot, corresponding to a price of 1.36.
We need to compare the total value of the pool before and after adjustment A, which is relatively simple.
First, look at the total value after adjustment A (after arbitrageurs intervene). Find the intersection of the tangent line of the red curve at the red dot with the Y-axis, which is the quantity of the two tokens converted into a single Y_token at the current price.
Looking at the total value of A before adjustment. Find the intersection of the black curve and the Y-axis at the black point. Because the prices of A before and after adjustment are the same (after arbitrage intervention), the tangent line is parallel to the tangent line in the first step.
Obviously, the intersection of the black tangent line and the Y-axis is higher, that is, the total value of A before adjustment is higher. The adjustment of A reduces the total value.
The above discussion is limited to the instantaneous loss after the adjustment of A, which is relatively simple. However, if the tracking time is extended and the long-term gains and losses brought about by the adjustment of A under different price trends are discussed, it becomes somewhat complex. This depends on whether the price develops in a more unanchored direction or returns to perfect anchoring. The total value of A after adjustment may be lower than the state without adjusting A, or it may be higher. This will not be further discussed 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 system argument.
Exclusion of Impermanent Loss Evaluation
Converting according to the current prices of the two tokens, that is, considering impermanent loss, is the most intuitive measurement method, but this method is more troublesome. Curve introduces another unique method of profit and loss evaluation, which eliminates the impermanent factors, simplifies the calculation, and can also be applied in most cases.
This is the D value, which is another core parameter of the Curve curve formula outside A. The virtual price we see in each pool on the Curve official website is calculated based on the D value.
The D value is the total quantity of the two tokens in the pool when the pool price is 1 (perfect anchoring). Because the price is 1 at this moment, the quantities of the two tokens can be simply added. The point where the pool price equals 1 is the intersection of the curve and the line x=y.
Returning to the previous example, it is obvious that the D value becomes smaller after the adjustment of A. Therefore, in the long run, if the price can restore anchoring, the change in the D value can reflect the loss caused by the adjustment of A.
In the example I used in the previous text, the current price is 1.36, which is actually a more extreme case. If we look at Curve V1 pools, such as mainstream stablecoin/LSD pools, the price will not deviate too much from 1. When the price is close to 1, the impact of impermanent loss is small, so the change in the D value can be directly used to approximately reflect the profit and loss.
As a one-dimensional measure and one of the parameters of the pool, the D value is easy to calculate and track historical values, and it is more suitable for approximating the evaluation of profit and loss.
Conclusion
Adjusting parameter A is equivalent to a rearrangement of all the pending orders at the price points in the order book, which changes the current price point, changes the value of D, and brings about profits and losses.
Therefore, a one-time significant adjustment of parameter A can feel abrupt and even flawed. The white paper does not mention the dynamic management of parameter A, perhaps because Michael gradually realized the need to revise the way parameter A is adjusted after Curve was launched and operated for a period of time. Under the tweet announcing the completion of the adjustment of Compound Pool A parameter, Michael replied to a comment. In subsequent versions of the pool, the adjustment of parameter A is changed to a gradual completion over a period of time.
Is the one-time adjustment method of parameter A in the old pool just a feeling of flaw? It’s not that simple. There is also a hidden vulnerability behind it. Fortunately, a white hat (with an incredible depth of understanding of the protocol) discovered this vulnerability. A separate article will be written later to explain this attack method.
Like what you're reading? Subscribe to our top stories.
We will continue to update Gambling Chain; if you have any questions or suggestions, please contact us!