The Journal of Digital Assets
- Volume 1
- December 2022
- Issue 1
- Impermanent Loss and Gain of Four Automated Market Maker Algorithms
- Hyoung Joong Kim, Soohyuk Choi, Yong Tae Yoon, and Shiyong Yoo
- First Published: 05 December 2022
- Abstract | Full Text(1,175) | PDF download(349)
Content (Full Text)
Impermanent Loss and Gain of Four Automated Market Maker Algorithms |
||||||||||||||||||||||||||||||||||||||||||||||
Abstract |
||||||||||||||||||||||||||||||||||||||||||||||
Automated market makers are working without an order book, and they determine the price of assets automatically. It is reported that he automated market makers have the impermanent loss, which causes financial damage to liquidity providers. Impermanent loss makes the liquidity providers hesitant to deposit assets in the liquidity pool. Therefore, their participation incentive from liquidity provision should be anticipated by automatic market makers inherently. However, the existence of impermanent gain has never been reported. Impermanent gain is important to attract liquidity providers without giving compensation incentives. This study shows that for some automated market makers, impermanent gain coexists with impermanent loss. Examples showing the coexistence and conditions are provided.
Keywords: Blockchain, cryptocurrency, decentralized finance, impermanent gain, impermanent loss, market maker. |
||||||||||||||||||||||||||||||||||||||||||||||
I. INTRODUCTION |
||||||||||||||||||||||||||||||||||||||||||||||
BLOCKCHAIN[1][22]is an important building block for many applications, including smart grid [2][13], energy trading[15], vehicular device[1], cryptocurrency[23], voting[14], education system[20], identity authentication[5], and decentralized finance (DeFi). Among the applications, DeFi has grown explosively from 2020, securing credibility and liquidity. These DeFi services include lending, asset management, and decentralized exchange. An automated market maker (AMM) is a crucial part of the DeFi ecosystem, in particular, for the decentralized exchange systems. Meanwhile, AMMs rely on mathematical formulas to facilitate trading and automatically set the price of an asset or multiple assets. AMMs of the decentralized exchanges recently have replaced the traditional order book so that all trades are conducted through swaps on their liquidity pools. AMMs allow the users to buy and sell in real-time without matching orders. The buyand-sell orders listed in the order book are arranged by price. Moreover, the price of the assets at an exchange is set by the matching order algorithms, such as price-time priority algorithm or price pro-rata |
||||||||||||||||||||||||||||||||||||||||||||||
This research was supported by a grant of the Korea Health Technology R&D Project through the Korea Health Industry Development Institute (KHIDI), funded by the Ministry of Health & Welfare, Republic of Korea (grant number: HI19C0785). This paper is an extension of the prepublication available at [10]. H. J. Kim is with the School of Cybersecurity, and the Cryptocurrency Research Center, Korea University, Seoul, 02841, South Korea (e-mail: khj-@korea.ac.kr). S. Choi is with the SymVerse, Seoul, 02841, South Korea (e-mail: choi@symverse.com). Y. T. Yoon is with the Department of Electrical and Computer Engineering, Seoul National University, Seoul, 08826, South Korea (e-mail: ytyoon@snu.ac.kr). S. Yoo is with the Business School, Chung-Ang University, Seoul, 06974, South Korea (e-mail: sy61@cau.ac.kr). Corresponding author: H. J. Kim Received: August 25, 2022; Revised: October 15, 2022; Published: December 5, 2022.
|
||||||||||||||||||||||||||||||||||||||||||||||
algorithm. It is determined by double auction. Sellers and buyers can offer market, limit, or conditional orders on the centralized exchanges. Meanwhile, the AMMs have provided the decentralized exchanges mathematical price valuation models. As those formulas are adopted, market makers are price setters, whereas traders are price takers. That is to say, sellers and buyers have no choice but to accept the price determined by the market maker. Wang[21]suggested the following requirements to be a good AMM algorithm. Constant function market maker (CFMM) needs to be convex curves or convex hyperplanes to conform to the principle of supply and demand. Another requirement is the robustness against malicious attacks, such as front-running (slippage) attacks [7][8]. Front-running is an action plan where an attacker benefits from prior access to privileged market information about upcoming transactions and trades[7]. Wang[21]also suggested the computational efficiency of the asset amount determination. Meanwhile, Hanson [9][10] has proposed market-scoring rule for the market prediction. Recently, Hanson’s market-scoring rule, the ogarithmic market scoring rule (LMSR), showed the potential of the AMM tool. LMSR is one of the CFMM and AMMs. Note that the LMSR is quite popular because of the following three reasons [17]: (1) it was the first AMM for prediction markets and decentralized exchanges; (2) it has a simple analytical form that is rather complicated than constant function market makers; and (3) it has bounded loss. Othman et al. [18] have proposed liquidity-sensitive LMSR (LS-LMSR) by introducing a parameter and adaptive to the market situation; they aim to make the scoring liquidity sensitive. The LMSR and LS-LMSR algorithms set the price of a cryptocurrency pair by keeping the constant cost value unchanged. A logarithmic function expresses the cost. A bonding curve is a mathematical curve that defines a relationship between price and supply of assets. Bonding curve (between two assets as a pair, such as ETH and USDC, where the ETH is a cryptocurrency with price volatility, and the USDC is a stablecoin) or bonding hyperplane (for more than two assets) can be used for setting the price. CFMM [2] sets the price by maintaining the cost value unchanged (i.e., equal to a constant). Other types of algorithms, such as constant product market maker (CPMM) algorithm [4], constant sum market maker (CSMM) algorithm, and constant mean market maker (CMMM) algorithm [12], also set the price in such a way that the cost value remains unchanged over the bonding curves or bonding hyperplanes. Meanwhile, a hybrid approach called StableSwap [6] combines the CPMM and CSMM algorithms to take the advantages of both methods. Constant circle market maker (CCMM) and constant ellipse market maker (CEMM) also do similar thing. Liquidity providers supply asset pairs to the liquidity pool, and they may lose money and suffer from an
impermanent loss (a.k.a. divergent loss). Impermanent loss is the temporary loss of asset values occasionally
experienced by liquidity providers because of volatility in a trading pair. Liquidity provider’s asset value can
be increased or decreased after trading. The composition ratio of assets is changed, and, as a result, the asset
price and value are changed after asset trading. Impermanent loss occurs when the deposited asset value is decreased; it is still a loss, whether large or small. This loss is impermanent because it can only be temporary. The contributions of this paper can be summarized as follows. To the best of our knowledge, this study is the first to show that impermanent gain and impermanent loss coexist for some AMMs. Previous study has already shown that CPMM has the property of impermanent loss [12]. Meanwhile, this present study shows that the CPMM does not have impermanent gain property at all. Moreover, it was known that CSMM does not have the property of impermanent loss because the price is invariant. However, this study shows that the relative price in the CSMM is not invariant, and the CSMM has both the property of impermanent gain and impermanent loss. For the LS-LMSR and CCMM and AMMs, this study also shows that both impermanent gain and impermanent loss coexist. This paper is organized as follows. Section 2 introduces real-world examples and the mathematical background of various AMM asset cost functions and asset value functions to define the value difference functions,
which indicates impermanent loss and impermanent gain. Section 3 derives the condition to obtain an impermanent gain and shows that impermanent gain can coexist with impermanent loss. Section 4 concludes the
paper with some suggestions. |
||||||||||||||||||||||||||||||||||||||||||||||
II. MATHEMATICAL BACKGROUND WITH AN EXAMPLE | ||||||||||||||||||||||||||||||||||||||||||||||
Consider an example that explains the impermanent loss or impermanent gain in an easy to understand way. There are 10 ETH and 1,000 USDT in pairs deposited in a liquidity pool (LP). In this particular AMM, the deposited token pair needs to be of equivalent value. This means that the price of ETH is 100 USDT at the time of deposit. This also means that the dollar value of the total deposit is 2,000 USD at the time of deposit since she has 10 ETH for 1,000 USD and 1,000 USDT for 1,000 USD as well. In this paper, it is assumed that one of the coin pairs deposited in the LP is a stablecoin and the other is a non-stablecoin. In the LP, there is a pair of coins and where and denote the number of ETH and USDT, respectively. Hence, the price of is determined by , and the total value of the assets in the pool is given as .
(Case 1) In this LP, the coin price is determined by the AMM algorithm satisfying the simple equation where is a fixed constant. At the initial moment, since there were 10 ETH and 1,000 USDT, is obviously 10,000 such as (10 ∙ 1,000 = 10,000). Now, Alice sold 1 ETH at the pool. Since has to be changed from 10 to 11, has to be decreased from 1,000 to approximately 909.09 to keep unchaged. After the swapping, the price of ETH has been changed from 100 USD to approximately 82.64 USD. Thus, total asset value of the LP has been changed from 2,000 USD to 1,818.18 USD. Assuming that the liquidity provider who deposited 10 ETH and 1,000 USDT did not participate in the LP, he calculated the value of his assets at the current coin price. Since the current ETH price has fallen to 82.64 USD, his asset value is 1,826.4 USD by adding 826.4 USD from his original 10 ETH and 1,000 USD from his original 1,000 USDT. He realized that by becoming a liquidity provider, his current asset value is 1,818.18 USD, but if he had not participated in the LP, it would have been close to 1,826.4 USD, resulting in a loss of 8.22 USD. The AMM algorithm of the LP is CPMM one. This loss is called impermanent loss because it does not always occur. Impermanent loss is also called divergence loss.
(Case 2) Let’s consider another example. In another LP, the coin price is determined by the AMM algorithm satisfying the simple equation where is a fixed constant. At the initial moment, since there are 10 ETH and 1,000 USDT, is obviously 1,010 such as (10 + 1,000 = 1,010). Now, Bob sold 1 ETH at the pool. Since hasto be changed from 10 to 11, hasto be decreased from 1,000 to 999 to keep unchaged. After the swapping, the price of ETH is changed from 100 USD to approximately 90.8 USD. Thus, the total asset value of the LP is still 2,000 USD. If he had not participated in the LP, his asset value would be 908 USD from 10 ETH and 1,000 USD from the original 1,000 USDT, adding up to 1,908 USD. Thus, he made a gain of 92 USD by participating in the LP running CSMM AMM. This gain is called impermanent gain or divergence gain. CSMM AMM has always been known to have zero divergence loss, but from this example it seems clear that this is not the case and positive divergence gain certainly exists. The difference between the claim that the divergence loss of CSMM is always 0 and that it can be positive sometimes comes from the difference in the definition of the divergence loss. In the above example, the initial asset value of CSMM LP and that after swapping are the same at 2,000 USD. Therefore, the difference in the asset value of CSMM LP before and after a certain swapping is always zero. If the definition of divergence loss is defined as the value obtained by subtracting the initial asset value from the asset value after swapping, it is true that the divergence loss of CSMM LP is always 0. However, in this paper, divergence loss is defined as the difference between the asset value after swapping and the value of the initial asset converted to the price after swapping. The difference of the definitions is clear; see Equation (4) in [12] and also Equation (4) in this paper. In calculating the total asset value, the former considers both the asset pairs and prices before and after the swapping, whereas the latter considers the initial asset pair and the price before and after the swapping.
(Case 3) See the same example of CPMM LP given above. At the initial moment, since there were 10 ETH and 1,000 USDT, is 10,000. Now, Carol bought 1 ETH from the pool. Since has to be chan gefrom 10 d to 9, has to be increased from 1,000 to approximately 1,111.11 to keep unchaged. After the swapping, the price of ETH has been changed from 100 USD to approximately 123.46 USD. Thus, total asset value of the LP has been changed from 2,000 USD to 2,222 USD. According to Equation (4) in [12], the divergence loss is 222 USD (i.e., 2,222−2,000) which is positive. Impermanent loss is known to be non-positive as shown 1 Figure 1 [19], but here it is positive, so it goes against common sense. On the other hand, according to Equation (4) in this paper, the divergence loss is −13 USD (i.e.,
2,222−2,235) which is negative. This case conflicts with reports that the CPMM divergence loss is nonpositive (see Figure 1). Table 1 illustrates the mechanism by which impermanent loss occurs. |
||||||||||||||||||||||||||||||||||||||||||||||
Fig. 1. Impermanent loss for Uniswap and Balancer pools compared [19]. |
||||||||||||||||||||||||||||||||||||||||||||||
Table 1. The mechanism by which impermanent loss occurs. |
||||||||||||||||||||||||||||||||||||||||||||||
Consider a pair of two assets where denotes the asset pair with the number of assets and at time . The AMM uses a cost function to set the price of cryptocurrency pairs at a trading. Suppose a liquidity provider has deposited an asset pair , where the asset is a stablecoin. Note that is considered a unit of account because it is a stablecoin; it is also divisible, fungible, and countable. Its price is unity. Then, the asset value of the liquidity provider at time 0 is given as follows: |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Composition ratio of the two assets is changed from to by trading two assets. One can add to the pool to make ; thus, . Similarly, one can add to the liquidity pool to make ; hence, . The asset value of the pair at time is computed as follows: | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
However, the value of the original pair composition assessed by the relative price at time is computed as | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
In addition, impermanent loss is computed from the difference of the two asset values and , such that | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
If the value of is negative, there exists an impermanent loss. Many research works [3][4][6][7][11][12][16][18][21] have tackled the impermanent loss. Scholars have tried eliminating or mitigating the impermanent loss. If the value of is positive, an impermanent gain exists. This paper introduces the concept of impermanent gain for the first time. |
||||||||||||||||||||||||||||||||||||||||||||||
A. Constant Product Market Maker |
||||||||||||||||||||||||||||||||||||||||||||||
CPMM starts from the cost function from the product of and , such as | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
At time , the number of given is computed from the following equation | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Note that the CPMM cost function is a hyperbola. Uniswap, a decentralized exchange, uses this formula for a pricing purpose. One can add to the pool to make ; then, . The cost function in Equation (6) is used to determine by using and obtaining by subtraction such that . Hence, is computed from Equation (6) as follows: |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
For the CPMM, the relative price of asset with respect to at time is computed from Equations (2) and (7): | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Thus, the asset value of the pair |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Hence, |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
B. Liquidity-Sensitive Logarithmic Market Scoring Rule |
||||||||||||||||||||||||||||||||||||||||||||||
Similarly, for the LMSR and LS-LMSR, the cost function is given as follows: | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Hence, |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Thus, the asset value of the pair |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
For the LS-LMSR, the relative price of the asset |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
C. Constant Sum Market Maker |
||||||||||||||||||||||||||||||||||||||||||||||
For the CSMM, the cost function is given as follows: | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Hence, |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Thus, the asset value of the pair |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
D. Constant Circle Market Maker |
||||||||||||||||||||||||||||||||||||||||||||||
CCMM has been proposed by Wang [21]. For the CCMM, the relative price and the change in the asset values are computed with the given cost function as follows: | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Hence, |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Thus, the asset value of the pair |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
III. IMPERMANENT LOSS AND IMPERMANENT GAIN |
||||||||||||||||||||||||||||||||||||||||||||||
The asset value difference is a good barometer to show whether there is impermanent loss. The difference value |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Equation (21) is simplified: | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
If Theorem 1: If Proof: If |
||||||||||||||||||||||||||||||||||||||||||||||
A. Constant Product Market Maker |
||||||||||||||||||||||||||||||||||||||||||||||
For the CPMM, the CPMM AMM has the property of impermanent loss because showing that the sign of |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Note that |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Equation (24) contains a quadratic function of |
||||||||||||||||||||||||||||||||||||||||||||||
B. Constant Sum Market Maker |
||||||||||||||||||||||||||||||||||||||||||||||
The number of assets for the CSMM AMMs is determined by Equation (15). The price of |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Here, note that the relative price of |
||||||||||||||||||||||||||||||||||||||||||||||
For the CSMM, from Equations (15) and (22), |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Note that |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Fig. 2. Loss and gain regions of three AMMs |
||||||||||||||||||||||||||||||||||||||||||||||
Equation (27) contains a quadratic function of |
||||||||||||||||||||||||||||||||||||||||||||||
Theorem 2: If |
||||||||||||||||||||||||||||||||||||||||||||||
Proof: See the paragraph above the Theorem 2. |
||||||||||||||||||||||||||||||||||||||||||||||
Observation 1: If |
||||||||||||||||||||||||||||||||||||||||||||||
Figure 2(a) shows that impermanent gain occurs for a set of two |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Thus, for |
||||||||||||||||||||||||||||||||||||||||||||||
In this example, impermanent loss region and impermanent gain region coexist for all initial asset pairs |
||||||||||||||||||||||||||||||||||||||||||||||
C. Liquidity-Sensitive Logarithmic Market Scoring Rule |
||||||||||||||||||||||||||||||||||||||||||||||
For the LS-LMSR, the value of |
||||||||||||||||||||||||||||||||||||||||||||||
Observation 2: If |
||||||||||||||||||||||||||||||||||||||||||||||
D. Constant Circle Market Maker |
||||||||||||||||||||||||||||||||||||||||||||||
For the CCMM AMMs, the value of |
||||||||||||||||||||||||||||||||||||||||||||||
The asset cost function, in this case, is given as Equation (18), where |
||||||||||||||||||||||||||||||||||||||||||||||
Appendix A shows the condition when the |
||||||||||||||||||||||||||||||||||||||||||||||
Observation 3: If |
||||||||||||||||||||||||||||||||||||||||||||||
IV. CONCLUDING REMARKS |
||||||||||||||||||||||||||||||||||||||||||||||
This study reviews four constant function market makers: LS-LMSR, CPMM, CSMM, and CCMM. For the first time, this study showed the existence of impermanent gain mathematically and computationally thorough experiments. This paper showed that CPMM has impermanent loss property only. Meanwhile, LS-LMSR, CSMM, and CCMM can have both impermanent loss and impermanent gain altogether. For a specific condition, they have impermanent loss property only (see Observations in the previous section). Even though an impermanent loss exists in CPMM AMM, this market maker attracted a large amount of total valued locked (TVL) and leads the decentralized exchange markets. Liquidity providers want impermanent gain rather than impermanent loss. The existence of impermanent gain will be fully exploited in the future DeFi systems. However, impermanent gain also has the problem. Liquidity providers want to withdraw the assets from the liquidity pool when impermanent gain occurs. When liquidity providers encounter impermanent gain, the liquidity provider earns extra profits in addition to the deposited assets. Thus, the liquidity providers are motivated to leave the pool, taking advantage of the assets they deposited and the kind of windfall profit that comes from impermanent gain. Meanwhile, impermanent loss makes the liquidity providers passive in joining the pool as they lose by depositing the asset, whereas impermanent gain makes the liquidity providers take extra profit and leave the pool. However, liquidity providers may prefer impermanent loss to impermanent gain. Whether liquidity providers will prefer impermanent loss or impermanent gain will be the subject of important research. A study on the attitudes of arbitrage traders in a market where impermanent loss and impermanent gain coexist would also be interesting. It is well known that impermanent loss exists, but that impermanent gain is not. The reason is probably because the definition of divergence loss was not correct. In CSMM LP, it seems that further research has not been carried out by accepting the divergence loss as zero according to the wrong mathematical definition. Therefore, it seems that studies on divergence loss for LS-LMSR LP, etc., with more complex formulas have not been conducted. Since the existence of impermanent gain has been proven through examples in this paper, it is hoped that further research on impermanent gain will proceed in the future. |
||||||||||||||||||||||||||||||||||||||||||||||
ACKNOWLEDGMENT |
||||||||||||||||||||||||||||||||||||||||||||||
The authors would like to thank the anonymous reviewers for their time and effort to improve the quality of the paper by providing constructive comments. |
||||||||||||||||||||||||||||||||||||||||||||||
REFERENCES | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
APPENDIX A |
||||||||||||||||||||||||||||||||||||||||||||||
For the CCMM asset cost function |
||||||||||||||||||||||||||||||||||||||||||||||
The condition that |
||||||||||||||||||||||||||||||||||||||||||||||
where | ||||||||||||||||||||||||||||||||||||||||||||||
and hence, | ||||||||||||||||||||||||||||||||||||||||||||||
The left-hand side of the equation is a fourth-order polynomial open downward, whereas the right-hand side is a quadratic polynomial open upward. Thus, the following three possibilities exist: 1. When both side polynomials do not meet, then the right-hand side polynomial has larger value for all
Hyoung Joong Kim is currently a professor at Korea University, Korea and the president of the Korea Fintech Society. He received his Ph.D. in Control and Instrumentation Engineering from Seoul National University, Korea. His main research areas are cryptocurrencies, decentralized finance and fintech security.
Soohyuk Choi is currently the CEO of SymVerse, a crypto company in Korea, and president of the Korea Blockchain Startup Association. He received his Ph.D. in Economics from Northwestern University, USA.
Yong Tae Yoon is currently a professor at Seoul National University, Korea and head of the Electric Power Research Institute. He received his Ph.D. in Electrical Engineering from MIT, USA.
Shiyong Yoo is currently a professor at Chung-Ang University, Korea. He received his Ph.D. in Applied Economics/Finance from Cornell University, USA | ||||||||||||||||||||||||||||||||||||||||||||||