1/5
### Curve V2 Loss When Re-pegging the Price Scale In this lesson, we will graphically demonstrate how Curve V2 incurs a loss when it re-pegs the price scale, focusing on when it re-pegs to where it concentrates liquidity. Let's assume we have a graph of Curve V2 AMM with a price scale equal to 2. To better understand this, we will view the constant sum associated with this curve and the point of equilibrium, where the transform balances of each token are equal. We will also graph the constant product associated with this Curve V2 AMM. The constant product curve is used by Curve V2 AMM to compare different Curve V2 AMMs at different price scales. Now, imagine a swap where Token Y is exchanged for Token X. The token balances after the swap are as shown on the graph. Let's also assume that if Curve V2 were to concentrate liquidity, the price scale would be shown as a straight green line. In practice, Curve V2 does not re-peg to the spot price. Rather, it decides based on the exponential moving average of the prices. Realistically, if it were to re-peg to a different price scale, it would be between the current price scale and the spot price�s price scale. For the sake of simplicity, let�s say Curve V2 is going to re-peg to the price scale represented by the green line. To demonstrate, we will draw another copy of the Curve V2 AMM at the current state. We�ll do the same for the constant sum and the constant product, and highlight the point where the transform balances are equal. If Curve V2 was to re-peg where it concentrates liquidity, it would need to update the price scale. So let�s adjust the price scale to match the new price scale, shown as the green line. Now the green line�s price scale is equal to the pink line�s price scale. In this example, Token X was swapped and Token Y was removed from the pool. Curve V2 retains swap fees on the token that is being swapped out. Therefore, the actual amount of tokens will be slightly higher than what is depicted on the curve. Let�s assume it�s up here. All of Token X came in, but a small amount of Token Y was kept as swap fees. Let's say that point is here. Next, Curve V2 calculates D so that the pink curve will go through the green point. This depicts the actual token balances. Considering the actual token balances and all of Curve V2's parameters, including the price scale, it�s going to solve for D so that the Curve V2 equation is satisfied. On the graph, we can simulate this by adjusting the D value until it intersects the green point. Now, we can compare the two constant product curves that are associated with the Curve V2�s graphs. As we can see, the constant product curve associated with the pink curve has less liquidity than the constant product curve associated with the orange curve. This shows what we meant when we said that Curve V2 incurs a loss when it re-pegs to a different price scale.
A comprehensive course that teaches you how to develop smart contracts using the Vyper programming language. This lesson focuses on a key aspect of Curve V2 AMMs - how they lose value when they re-peg the price scale. The lesson uses a Desmos graph to illustrate this concept and helps to understand how Curve V2 AMMs make decisions about re-pegging based on profit and loss calculations.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
AMM math for Curve Cryptoswap
How liquidity is concentrated
Price-repegging
How function calls interact with the AMM
Curve Cryptoswap state variables
How the function exchange works
How to swap tokens
How to add and remove liquidity
Math for Curve Cryptoswap’s internal price oracle
Implicit differentiation
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on May 15, 2025
DeFi Developer
Curve CryptoswapDuration: 4min
Duration: 1h 21min
Duration: 28min
Duration: 26min
Duration: 14min
Duration: 24min
Duration: 59min
Duration: 5min
Course Overview
About the course
AMM math for Curve Cryptoswap
How liquidity is concentrated
Price-repegging
How function calls interact with the AMM
Curve Cryptoswap state variables
How the function exchange works
How to swap tokens
How to add and remove liquidity
Math for Curve Cryptoswap’s internal price oracle
Implicit differentiation
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on May 15, 2025