Multidimensional Analysis of Head AMM: Uniswap V3, Curve V2 and Balancer V2
This article is sourced from Chain News, authored by Ricky Li, Siddharth Lalwani, and Hongxu Yan, who work at Altonomy Ventures.
The Automated Market Maker (AMM) mechanism, with its advantages of constant levels of time and space occupancy, has been adopted by many decentralized exchanges (DEXs), and many such projects have achieved great success to date. When it comes to the leaders in this field, Uniswap, Balancer, and Curve must be mentioned, as they have recently launched new versions to address various issues and risks that liquidity providers are concerned about. This article will compare the latest versions of these three protocols from multiple perspectives.
Pricing Models and Invariants
The participants in the automated market maker mechanism include two different roles: liquidity providers (LPs) and traders. Liquidity providers deposit funds into the liquidity pool, while traders exchange one currency for another from the pool. The first problem that AMM protocols need to solve is how to price, taking a two-token pool as an example, specifically how to express the price of token 1 (t~1~) in terms of the quantity of token 2 (t~2~).
Assuming the quantities of the two currencies in the pool are R1 and R2, in a transaction, a trader wants to buy Δ1 quantity of t1 using Δ2 quantity of t2. We can describe an AMM protocol using a trading function ψ, which must satisfy the condition that the function value remains unchanged before and after the transaction, represented by the invariant:
Based on this equation, we can derive Δ2 from Δ1 (or vice versa). This transaction will also affect the price, as the total amount of tokens in the pool changes after the transaction. In fact, because the trading price in the liquidity pool differs from the price in external reference markets, arbitrageurs will continuously trade until the price difference returns to normal, and AMM utilizes this mechanism to correct the trading price within the pool. The average price of each transaction is defined as:
When dΔ1->0, we can calculate the marginal price. The marginal prices of the three protocols are summarized in the table below:
Table 1 Marginal Prices
Uniswap V3
The trading function of Uniswap is defined as follows:
From this, the invariant can be derived as:
The expression for Δ2 is derived as:
The marginal price is:
When Δ1->0,
In the new version V3, due to the varying liquidity density across different price ranges, it is necessary to calculate each small interval of the same liquidity density separately. When crossing the boundary of an interval, similar calculations are needed for the next interval.
Balancer V2
The trading function of Balancer is defined as follows:
From this, the invariant can be derived as:
The expression for Δ2 is derived as:
The marginal price is:
When Δ1->0,
The weights ω1 and ω2 also represent the proportion of the total market value of the two tokens. If we set ω1=ω2=1/2, then this pool is equivalent to a Uniswap pool.
Specifically, Balancer allows for a mixed pool of up to 8 tokens, and when the number of token types exceeds two, its trading function is extended to:
Other derivation steps can similarly be extended to the multi-token case, and the derivation steps are omitted here.
Curve V2
The trading function of the Curve protocol is a linear combination of constant sum and constant product functions:
Similarly, we can derive the marginal price when Δ1->0:
Price Impact and Slippage
Based on the marginal price formulas derived in the previous step, we can define the price impact of a transaction by comparing the changes in marginal prices before and after a single trade. Comparing the price impacts of the three protocols, we can conclude the following: assuming the same quantity of token 1 is traded, the higher the ω1 in the Balancer pool, the greater the price impact. If ω1>1/2, then the price impact is greater than that of the same trade in the Uniswap pool, and vice versa. Near the equilibrium point (i.e., when the price shift is not severe), Curve V2 has the smallest price impact.
In the following example, we compare the price impacts of single trades in four different pools, assuming the initial total amount of tokens in the pool is R1=R2=10000:
- A Uniswap V3 pool with an initial price of 1
- A Balancer V2 pool with ω1=0.4, ω2=0.6, and an initial price of 0.666
- A Balancer V2 pool with ω1=0.6, ω2=0.4, and an initial price of 1.5
- A Curve V2 pool with α=1, β=3, and an initial price of 1
The price impact curves of the four pools are shown in the figure below:
Figure 1 Price Impact Curves
Clearly, for trading the same quantity Δ1 of token 1, the order of price impact is as follows: Balancer V2 w1=0.6 > Uniswap V3 > Balancer V2 w1=0.4 > Curve V2.
For Curve, since it has the smallest price impact within a certain range, it is most suitable for trading pairs of stablecoins. Based on past experiences with AMM protocols, the shape of the price impact curve is often related to the earnings of liquidity providers. As shown in the figure above, because Curve's price impact curve is the flattest, it leads to lower slippage, allowing traders to trade more frequently (or in larger amounts) within this range, ultimately resulting in liquidity providers earning more trading fees.
Impermanent Loss
Table 2 Impermanent Loss
For Uniswap V3, liquidity from a single provider is placed within a certain closed interval. When the price of one token decreases, the LP's risk exposure to that token gradually increases until the price reaches the boundary of the interval. At this point, the LP only has risk exposure to that token, while the exposure to the other token is 0. If the price continues to move in the same direction, the exposure remains unchanged.
For Balancer V2 and Curve V2, liquidity is provided across the entire price range, so the exposure gradually changes across the entire interval and does not reach maximum/minimum values.
Figure 2 The Impact of Relative Price Changes on Impermanent Loss in Balancer Pools with Different Weight Configurations
For the Balancer protocol, the smaller the weight ω1 of token 1, the smaller the impermanent loss under the same price fluctuations, which is intuitive, as the amount of token 1 held by the LP has decreased.
Withdrawals and Deposits
For liquidity providers looking to participate in these three protocols, there are no absolute advantages or disadvantages regarding the rules for withdrawals and deposits. However, depending on individual asset types and risk preferences, each protocol has scenarios that are more suitable:
Table 3 Withdrawals and Deposits
For Uniswap V3, the ratio of the two tokens deposited is determined by two factors: (1) the two boundaries of the interval (2) the current trading price. In simple terms, if the current trading price equals the geometric mean of the two boundary prices, the LP needs to deposit equal amounts of the two tokens in a 50:50 ratio. If the current price is more biased towards one side, then the cheaper token will occupy a higher proportion of the tokens that the LP needs to deposit. If the current price is outside the interval, the LP only needs to provide the cheaper token.
The specific calculation method is as follows:
When withdrawing, the amounts of the two tokens that can be withdrawn can be calculated similarly. The earned fee portion is charged and withdrawn in the type of token at the time of the transaction.
For Balancer V2, LPs always need to provide all types of tokens in the pool when depositing, and the ratio is determined by the weight settings of the pool.
For Curve, when depositing, LPs can deposit tokens in any ratio or only deposit a single type of token. However, if the deposit ratio does not match the total amount of tokens in the pool, the LP will incur a certain degree of loss (or gain). When LPs obtain LP tokens, the amount received is calculated using the following formula:
Where D is the total amount of tokens in the pool at the equilibrium point, with its value being D0 before the increase in liquidity and D1 after the increase. However, (assuming the same amount of tokens is deposited) the further the token ratio in the pool is from the equilibrium point, the smaller the D value will be, leading to a smaller amount of LP tokens received by the LP, resulting in a loss. Conversely, if the deposited tokens cause the token ratio in the pool to tend towards returning to the equilibrium point, the LP will receive more LP tokens, resulting in a gain.
Liquidity Concentration
In terms of liquidity concentration, Uniswap V3 provides LPs with the greatest flexibility, allowing them to aggregate any form of liquidity distribution curve according to their preferences. In contrast, Balancer and Curve replace this flexibility with more fixed parameter settings.
Table 4 Liquidity Concentration Methods
Uniswap V3 allows each LP to set any liquidity range, aiming for overall liquidity to concentrate in the most active interval. However, theoretically, based on each LP's autonomous decisions, liquidity can be shaped into any distribution.
For example, a liquidity distribution equivalent to Uniswap V2 is shown in the figure below:
Figure 3 Liquidity Distribution Uniswap V2
This indicates that if all LPs set their liquidity ranges to the maximum possible range, the Uniswap V3 pool will be equivalent to V2.
Below is a liquidity distribution similar to Curve, where all liquidity is concentrated in a narrow range near the equilibrium point:
Figure 4 Liquidity Distribution Curve
However, the above figure is merely an approximation of Curve V3, which is actually more complex. As market conditions change, when the most active price range deviates too far from the original equilibrium point, Curve V3 will readjust the equilibrium point and price curve based on the built-in Oracle.
Below is a liquidity distribution equivalent to Balancer V2, which concentrates on the lower price side of the token with a larger weight:
Figure 5 Liquidity Distribution Balancer V2
However, none of the above are the commonly observed liquidity distributions in Uniswap V3 pools; the common distributions are more similar to the following:
Figure 6 Actual Observed Liquidity Distribution Uniswap V3
Trading Fees
Table 5 Trading Fees
Uniswap V3
Each trading pair has three fee tiers for LPs to choose from: 0.05%, 0.3%, and 1%. Intuitively, LPs tend to prefer high-fee pools, but when the trading activity in high-fee pools is significantly lower than in low-fee pools, LPs have to participate in low-fee pools. Traders prefer low-fee pools, but when the liquidity in low-fee pools is too thin and slippage is too high, they are forced to trade in high-fee pools.
Based on actual observations, for stablecoin trading pairs, the pool with a 0.05% fee is the most active. For other trading pairs, when market volatility is high, high-fee pools become more active, while low-fee pools are more active when volatility is low.
Balancer V2
The Balancer protocol charges two types of fees: (1) trading fees, which are a certain percentage of the trading volume charged to traders, and (2) withdrawal fees, which are charged to LPs when they withdraw from the protocol.
Trading fees can be set between 0.05% and 1%, with the initial value set by the pool creator and dynamically adjusted by the protocol based on multiple factors, including volatility, trading volume, impermanent loss, total liquidity, liquidity mining rewards, etc.
Withdrawal fees can be set by the protocol, but have not been adopted to date.
Curve V2
Fees can be set between 0.04% and 0.4%, and can be dynamically adjusted based on the current token ratio in the pool. The further the current ratio is from the equilibrium point, the lower the fee rate:
Conclusion
Through a multi-faceted comparison, it is evident that each protocol adopts different approaches to meet the diverse needs of LPs and traders.
Uniswap V3 provides LPs with maximum flexibility, allowing almost all parameters to be decided by the LPs themselves, while the team has not added additional auxiliary features to maintain the simplicity of the protocol. LPs need to manage their various risks.
Historically, Curve has focused on stablecoin trading pairs, and this new version V2 aims to expand the types of tokens covered. Unlike stablecoins, in markets with non-stablecoin trading pairs, prices may shift to new active ranges, so this protocol can adjust the liquidity concentration range based on the price feed from the built-in Oracle without requiring LPs to redeploy liquidity ranges themselves. This design is more friendly to individual investors but limits the possibility of developing more complex customized market-making strategies.
Balancer V2 accommodates more than two types of tokens within the same liquidity pool and assigns different weights, meeting the needs of some LPs to treat the risk exposures of different tokens differently. By increasing the risk volatility on one side, it reduces the risk on the other side.
References
[1] G. Angeris, A. Evans, T. Chitra; When does the tail wag the dog? Curvature and market making, 2020.
[2] Hayden Adams, Noah Zinsmeister, Moody Salem, River Keefer, and Dan Robinson. Uniswap v3 Core. (2021).
[3] Michael Egorov, Curve Finance (Swiss Stake GmbH). Automatic market-making with dynamic peg (2021)
[4] Fernando Martinelli, Nikolai Mushegian. Balancer Whitepaper (2019)