General theory of AMM: Can other mathematical functions besides constant product reduce impermanent loss?
Original Title: "General Theory of AMM", Author: Zou Chuanwei, Chief Economist of Wanxiang Blockchain.
Constant product AMMs represented by Uniswap have achieved great success in the crypto asset market, but they are also burdened by impermanent loss. Some projects have attempted to improve upon Uniswap by introducing oracle pricing to reduce impermanent loss, but no widely recognized successful improvement has been established yet.
To better understand these issues, we need to return to the general theory of AMM: 1. Besides the constant product formula, can other mathematical functions be used, and what requirements should these functions meet? 2. Will there still be impermanent loss under other mathematical functions? 3. What kind of mathematical function is optimal? 4. What is the core difference between AMM and other trading methods in the crypto asset market?
This article attempts to answer these questions, divided into three parts: the first part discusses the general form of AMM, the second part discusses several special forms of AMM, and the third part compares AMM with other trading methods in the crypto asset market.
General Form of AMM
For simplicity in analysis, this article only studies AMMs for two crypto assets, but related research can easily be extended to cases involving three or more crypto assets.
Consider two crypto assets, referred to as X and Y, with crypto asset X as the unit of account, meaning that all prices and market values are expressed in terms of crypto asset X. The state of the AMM is represented by the quantities of the two crypto assets in the liquidity pool, assumed to be (x,y) at a certain moment. In the general form of AMM, regardless of how the two crypto assets are traded (ignoring the impact of transaction fees), the liquidity pool always satisfies
When the liquidity pool state is (x,y), the relationship between the market values of the two crypto assets in the liquidity pool is
(1) and (7) depict AMM from different perspectives, and they are mutually equivalent. In other words, by restricting the functional relationship between the market values of the two crypto assets in the liquidity pool, AMM can also be defined.
(8) Although this is a simple analysis, it has rich implications for understanding the market value of crypto assets. First, even if the number of crypto assets remains unchanged, trading between them will alter their price relationship, thereby changing the total market value of the crypto assets.
Overall, the analysis of the general form of AMM in this section leads to the following conclusions:
Several Special Forms of AMM
Based on the discussion in the first part, any monotonically decreasing convex function can be used to define AMM.
For convenience in comparison with Uniswap, the following equivalent expression is used
(16) indicates that, under the same other conditions, the larger α is, the smaller the value of impermanent loss. This is also validated by numerical calculations of (15) (Table 1):
Table 1: The impact of α on impermanent loss
If α is set to 1/2, we obtain Uniswap's constant product formula, thus Uniswap is a special case of a broader category of AMM. Since no pair of crypto assets is fundamentally identical (in terms of market value, liquidity, user numbers, etc.), there is no logical necessity for α=1/2. To reduce impermanent loss, α can be appropriately increased. For instance, if crypto asset X is a stablecoin and crypto asset Y is Ether, α can certainly be greater than 1/2, with one option being α=2/3. In general, α can be determined through community governance in the AMM ecosystem.
Comparison of AMM with Other Trading Methods
(2) can be equivalently expressed as
Introducing the following function
In summary, the core mechanism of AMM is: liquidity providers commit based on algorithms to provide certainty about trading prices and quantities for investors. The cost of this certainty is that liquidity providers lock in liquidity and bear impermanent loss.
To better understand this, we need to compare AMM with auction mechanisms. Among various trading mechanisms in the crypto asset market, as long as there is an order book, regardless of the presence of market makers, the core is an auction mechanism. Next, we will illustrate this with the Dutch auction adopted by Algorand. Although this example involves selling assets, the previous analysis of AMM was conducted from the perspective of purchasing assets, but different perspectives do not affect the analytical logic.
Dutch auctions, also known as "descending price auctions": the seller calls out prices from high to low until someone is willing to buy, and that price becomes the transaction price. It can be strategically proven that Dutch auctions are equivalent to first-price sealed-bid auctions. In first-price sealed-bid auctions, all bidders submit "sealed bids" simultaneously, so no bidder knows the bids of others. The highest bidder wins the item and pays their bid.
Algorand's Dutch auction is similar to the primary market auction for U.S. Treasury securities. The U.S. Treasury has a long history of using Dutch auctions in the primary market. From 1929 to 1992, the U.S. Treasury used "multiple price" Dutch auctions. The first step: primary dealers submit the acceptable yield to maturity and the quantity they are willing to purchase at that yield. The second step: all bids are arranged in ascending order of yield to maturity (corresponding to bond purchase prices in descending order) until the desired purchase quantity equals the supply quantity of bonds, with the critical yield to maturity being the clearing price. The third step: all primary dealers who submitted yields below the clearing price receive bonds according to the quantities they wish to purchase, with the purchase price calculated based on their respective yields. Primary dealers at the critical yield to maturity are allocated the remaining quantity based on their desired purchase amounts. Therefore, the prices at which winning primary dealers purchase bonds are different.
Since 1992, the U.S. Treasury has switched to "single price" Dutch auctions. The first two steps of "single price" Dutch auctions are the same as those of "multiple price" Dutch auctions. In the third step, all primary dealers who submitted yields below the clearing price receive bonds according to the quantities they wish to purchase, but the purchase price is calculated based on the clearing price. In "single price" Dutch auctions, two types of bids are introduced: the first type is competitive, where bidders must simultaneously state their acceptable yield to maturity and the quantity they wish to purchase at that yield; the second type is non-competitive, where bidders only need to state the quantity they wish to purchase. In the presence of these two types of bids, the method for determining the clearing price remains the same. However, a priority order is introduced in the allocation of bond quantities: non-competitive bids are satisfied first, and then the remaining quantity is allocated to competitive bids in ascending order of submitted yields.
Algorand's Dutch auction is equivalent to "single price" + competitive bidding. The first step: determine the quantity of Algo to be auctioned and the starting auction price; the second step: the auction price decreases linearly over time (Figure 1), recording the quantity bidders are willing to purchase at each auction price until the cumulative quantity willing to purchase equals the auction quantity, with the critical price being the clearing price (Figure 2); the third step: bidders with auction prices above the clearing price win, and Algo quantities are allocated from high to low based on auction prices, with the price unified at the clearing price.
Figure 1: Algo auction price decreases linearly over time
Figure 2: Determination of Algo clearing price
From the practice of Dutch auctions, it is clear that trading prices and quantities are determined by the market, which appears highly uncertain in advance, while AMM can provide certainty in this regard. The distinction between AMM and other trading mechanisms such as centralized matching and OTC inquiry transactions can also be understood through similar logic.