AMM Ultimate Note: Five Solutions to Impermanent Loss

BytomDAO
BytomDAO
Published in
16 min readMar 5, 2021

Written by Bytom Institute

Preface — AMM Ultimate Note is a survey of many representative AMM projects and related papers. Because AMM involves a wide range of aspects, this paper chooses impermanent, the most representative AMM essential characteristics and development trends to explain.

Note: AMM (Automated Market Maker), uses the basic mathematical curve to define the supply and demand curve of cryptocurrency trading pairs. Based on the all-weather unattended smart contract, it redefines the basic form of DEX, Uniswap, the representative project.

Impermanent loss, which we are most concerned about is a problem, unsolvable, but there are optimization methods.

From a simple point of view, the impermanent loss is that when the exchange rate of token A / token B rises on the spot (the mainstream trading market outside the AMM capital pool), arbitrage traders will raise token B from the OTC market and transfer to the AMM capital pool to exchange more token a relative to the OTC market, so as to realize risk-free arbitrage. This part of the profit is also the loss of the fund pool (LP), which can be called impermanence loss (temporary loss), because once the exchange rate returns to the original position, it will create reverse arbitrage space (symmetrical), and the number of assets in the whole pool will return to the original state, and LP will return to the original state, LP has no loss, but because of the two changes in the market, it also benefits the profits of the two arbitragers. This profit margin no longer comes from the wealth of LP, but from the market opportunity, which is won only by the smart arbitragers who keep staring at the market. From this point of view, the impermanent loss is the result of the game equilibrium between the smart arbitragers and the LP with the sense of the overall situation. The arbitragers also greatly activate the AMM trading market, especially when many arbitragers begin to realize the opportunities here and start to compete for arbitrage.

From a general point of view, the definition of impermanent loss is that impermanent loss only depends on whether the exchange rate of the trading pairs. Once the exchange rate changes, there will be objective impermanence loss, which has nothing to do with whether the exchange rate rises or falls. Once the exchange rate returns, the loss will disappear automatically. This means that only when the liquidity provider (LP) removes the liquidity in a different price situation than the one originally used, will there be an impermanent loss. If you don’t remove it and wait for a more opportunistic time to withdraw, there won’t be a loss. In contrast, in traditional finance, we can think it as “sell perpetual intertemporal” position. The reason why it is perpetual is that this position has no maturity date and LP can hold it as long as it can.

In addition, it is also an aspect that many players are not aware of today. Although there is no upper limit for impermanent loss in theory, based on the assumption that changes in markets such as bitcoin always have a range, impermanent loss also has a computable upper limit. For example, in BTC / USDT, BTC rises from 20000 usdt to 60000 usdt, the arbitrager’s impermanent loss space will not exceed 13%, that is, LP’s impermanent loss will be controlled at 13% (impermanent loss calculator: https://yieldfarmingtools.com/tools ).

In addition, impermanent loss is a kind of greedy psychology. We always like to compare reality with assumptions or look at BTC / USDT trading pairs. After BTC price rises, in essence, no matter how impermanent the loss is, LP’s wealth always increases in value. However, people often like to compare with assumptions and think, “if I had held so many BTC at the price of 20000 usdt and didn’t participate in AMM, it would be good “, but in fact, many LP’s start to set up their own asset allocation, buy BTC and build trading pairs because of AMM. Therefore, most LP’s wealth appreciation opportunities come from AMM. If we always treat the problem with a greedy attitude, we can be sure that there is no path in any financial market where there is only income but no risk.

Attachment: the following are simulated transactions:

(1) When 1 eth = 500 usdt, the market maker deposits 10 Eth and 5000 usdt. His total asset value is 10000 usdt.

(2) When 1 eth = 550 usdt, there is room for arbitrage. Under the AMM mechanism, the market maker pool will automatically sell eth to arbitragers in exchange for usdt. Therefore, the current assets in the liquidity pool are 9.53 Eth and 5244 usdt, with the corresponding eth price of 550 usdt and the total asset value of 10488 usdt.

(3) If you don’t make a market, the value of usdt standard is 10500, which leads to a relative impermanent loss of 12 usdt.

On the contrary,

(a) When the price drops by 1 eth = 450 usdt, the arbitrager will inject eth into the pool in exchange for a profitable usdt until the exchange price of eth is the same as the market price, so the market maker’s current pool becomes 10.54 Eth and 4743 usdt, and the total asset value is 9486 usdt.

(b) If there is no market making activity, the total asset value is 9500 usdt. Relatively speaking, the overall assets depreciated by 500 usdt, and the market making also lost an additional 14 usdt.

It is not difficult to see from the actual example that no matter the price rises or falls, under the AMM mechanism, the reverse operation of liquidity suppliers will cause certain impermanet losses.

The first solution: constant weighted geometric mean function with dynamic weight

Bancor V2 is the representative project of this kind of solution. The original inspiration is that Balancer introduced the function of the constant geometric weighted average for AMM

The essence is similar to the constant product of Uniswap, but it gives the concept of each index (weight), so it has a more flexible curve shape. It is also the first time for balancer to write an article (Interest-Bearing Stablecoin Pools Without Impermanent Loss https://medium.com/balancer-protocol/zero-impermanent-loss-stablecoin-pool-with-lending-interests-a3da6d8bb782 )It is mentioned in the article that we can prevent the occurrence of impermanent loss from the source by dynamically updating the weight term, while Bancor v2 gives a more general and detailed mathematical description (Calculating Dynamic Reserve Weights in Bancor V2) is given https://blog.bancor.network/calculating-dynamic-reserve-weights-in-bancorv2-538b901bcac4 )(PDF version) https://drive.google.com/file/d/1lYsaUi5du7BdP5eXgVJX60POcg2UkBfZ/view )。

Detailed mathematical description here will not be explained, due to space constraints, this paper only outlines the principles. If the weight terms remain unchanged, the curve shape can be regarded as the same as Uniswap. If the weight changes continuously, the curve will rotate around a point on the curve, so that the tangent slope (i.e. exchange rate) of the rotated curve at that point is consistent with the latest market price, and the calculation of this rotation is driven by the Oracle from the external market price. Update the latest market price at each moment, and deduce the calculation of the weight term, so that the tangent slope of the current point (the point composed of two asset quantities in the pool) in the new curve changes with the market continuously, and thus does not create arbitrage space. The calculation of image is as follows:

Although this kind of method to solve the problem is very essential, the defect is also very obvious and the hidden danger is huge. AMM, which can automatically respond to the market, needs to rely on an external oracle at a single point. Once the Oracle fails, even if it is a small problem, it will bring huge arbitrage attack losses to AMM. This kind of loss is different from impermanent loss. It is a real user loss, and it will also bring fundamental resistance to AMM’s business expansion in the future. In addition, this kind of AMM will completely lose its market pricing power, that is, it will give up becoming the Primary Market. As we all know, with the rise of DeFi, more and more valuable new assets choose DEX as their Primary Market. On the contrary, those centralized mainstream exchanges have become the Secondary Market.

In addition to Bancor V2, DODO, a Chinese project also has a similar way. Although DODO does not use constant weighted geometric average function, but uses a hybrid constructor similar to curve, its essence is to rely on an external Oracle to constantly change the shape of the [pricing / trading] curve, so that the bidding result of the new curve closely follows the external market.

If a system only depends on itself, then its security boundary is itself, which can be calculated; if a system depends on external factors, its security boundary can not be estimated in theory, just like a Byzantine distributed system, no empirical observation or even formal mathematics can be estimated to cover all potential fault paths.

The second type: virtual balance limit routine path

This type exists only in Mooniswap. Different from Bancor V2 and DODO, Mooniswap does not change the essence of AMM (automatic self pricing). Unlike Uniswap, which can only be an onlooker to see arbitragers getting profit when arbitrage space appears in the system, Mooniswap can not change the essence of AMM, it will automatically build multiple virtual curves one by one according to the offset, so that arbitrage traders can only absorb the upper limit of arbitrage specified by each virtual curve, instead of completing a large number of arbitrage on the original curve at one time.

As shown in the figure below, the initial equilibrium point is at A, and a transaction makes the system at X. At this time, there is arbitrage space. In the traditional AMM of Uniswap, any smart arbitrager can pull back to a point at one time through a transaction, and this process is often accompanied by considerable profits. Mooniswap’s virtual construction method is to construct the above three AMM curves in succession. First, the arbitrager is presented with the second curve BC in the figure below. The arbitrager’s arbitrage path is only a short process from B to C. when the arbitrager reaches point C, the system will release the second virtual curve de. similarly, the arbitrager is presented with D to E after the second arbitrager reaches point E, the system releases the last curve, which is also the actual curve ZQ to be changed. The last arbitrager completes the arbitrage from Z to Q, and finally the system curve becomes ZQ, and the equilibrium point is Q. Through a series of virtual structures, the arbitrage space of the three times is far less than the traditional AMM curve one-time arbitrage path, and in this process, the arbitrage also injects more assets into the fund pool, which makes the pool larger and acts as LP, and the curve moves up to the right.

For the specific point calculation and mathematical proof, please refer to the Mooniswap WhitePaper (https://mooniswap.exchange/docs/MooniswapWhitePaper-v1.0.pdf )。

The disadvantages of this method are that it needs to carefully identify the arbitrage opportunities, and to a certain extent, it also needs to rely on external factors; moreover, the process of virtual quantity shortening the arbitrage path needs to build a large number of curves dynamically. For high concurrency systems, this method is too complex in engineering and introduces too much uncertainty.

The third type: infinite grid strategy for market making

The AMM algorithm based on the infinite grid strategy proposed by Bytom’s MOV is taken as an example. This solution does not directly focus on the occurrence of impermanent losses (the first type), nor does it focus on arbitrage (the second category), which is the initiator of impermanent losses. It is managing the wealth of LP as a fund manager and does not want to let LP gets wealth appreciation through saving interest (trading fee) to make full use of LP’s huge wealth pool under the effect of professional fund strategy, follow the general trend of the market, and obtain fund type wealth appreciation. Among them, the infinite grid strategy is the direction of MOV SuperTx V2, and it is implemented on AMM. Although there are still many shortcomings, the construction ideas are given as follows.

On the basis of the original constant product curve market maker mechanism, SuperTx V2 further constructs different shapes of curves by segments to meet the basic definition of infinite grid — “segmented buying and selling, even at the highest point of the market, there is spot to sell, and at the lowest point of the market, it can complete the operation of opening a position”. SuperTx V2 through the above four kinds of piecewise function construction, hope to be able to achieve — “in the rising market, we can appropriately sell BTC, but do not sell a large number of BTC, gradually by volume, not only can help LP to hold the BTC before reaching the highest point, but also can intelligently sell the appropriate quantity in the rising market BTC to deal with the potential risk of a sharp fall; hold to gain wealth appreciation from the usdt wealth accumulated when the market goes down.

In the specific function construction and implementation principle, you can see the following figure with reference to the figure above. As early as August 2020 (BTC 11000, when the SuperTx V2 theory was just born), the designers of SuperTx V2 at that time predicted that the future might reach a bull market of $40000 to $100000, so they made the above four segmented predictions. In the first segment, the SuperTx function is a very common constant product curve, which implements a simple AMM position strategy. When it reaches $40000, the function automatically triggers to switch to a mixed constructor curve, which is a curve with lower curvature and can greatly change the BTC position. In the range of 40000–100000, if it is judged that the highest point of this round may reach $100000, it will be in $100000 Once again, the function switch point is set at the knife, which turns into a very steep hyperbola, which can help LP not return the usdt of high point cash out again in the process of market downturn. The specific data can be seen in the figure below.

The advantage of this solution is that once the strategic forecast is successful, it can not only solve the permanent loss but also greatly help LP to obtain fund level wealth appreciation, which is not given by any AMM in the market, even if there is liquidity mining bonus. Moreover, this strategy does not rely on any external factors, only relies on its own strategy, so it will not introduce other risks. Even if the future market is not as expected, it can change the next function switching point in advance, change the next function shape in time, and avoid large-scale losses. The defects are also very obvious, that is, it needs a very professional fund manager’s prediction and strategy, and it needs to be able to predict a large range of future market. Moreover, the construction of piecewise function is very complex, and it is very difficult in building their own strategy, there is actually a better function construction, but because the mathematical form is too complex and the engineering implementation is difficult, they choose the above implementation case, which is also a compromise.

The fourth type: economic compensation

This is the most familiar method, that is, to compensate the loss of LP in the form of its own token, including Bancor v2.1 and liquidity mining.

Bancor v2.1 is a new scheme of impermanent loss after Bancor realized that Bancor V2 (the first type above) could not solve the impermanent loss and would bring the risk of Oracle system. This method records the positions of each LP in the initial market making from the system level. After the impermanent loss occurs, the system will issue additional Bancor tokens to compensate for the impermanent loss.

Liquidity mining is similar, but Bancor v2.1’s compensation is more refined, and it will subsidize its own token as much as it has lost. While the liquidity mining in the market, many times of APY, at least two or three times, is a crazy wealth-making movement, even if LP participated in a month, the mining wealth is enough to cope with any upper limit of impermanent losses.

Therefore, if liquidity mining can do a good job in the “aftermath” work, it may not be a fundamental solution to the impermanent loss.

The fifth type: option hedge

Also known as Hedge, this kind of research is very rare, almost not seen in any projects on the market, before the Huobi Research Institute had a special report (AMM Market Making Impermanent Loss Hedging Analysis Series 1: Profit and Loss and Option Hedging Model Construction) https://zhuanlan.zhihu.com/p/260141168 )。 The article of the Huobi Research Institute demonstrates the basic conclusion that put options can compensate for impermanent losses, and gives specific quantity and location guidance, which can obviously alleviate impermanent losses to a certain extent, as shown in the figure below.

Later, we also found several excellent industry papers, especially the research work of Placeholder researcher Alex Evans (When does the tail wag the dog? Curvature and market making and Liquidity Provider Returns in Geometric Mean Markets).

In traditional financial theory, dynamic hedging is a strategy that institutional investors use stock index futures or stocks and risk-free assets to create composite put options and seek to protect portfolio value by using composite put options. Under the CFMM mechanism, it is proposed that the Delta value (δ) and Gamma value(γ) of assets can be compared to avoid high LP risk. Next, we will calculate the number of dynamic hedges for LP and show how they perform well in trading. Through the following mathematical derivation, we can also see the relationship between the number of dynamic offsets and curvature.

Portfolio value of reserves

Where m is the market price, R and the amount of R ‘reserve, then we can get

How to prove the correctness of this equation? The function ψ is only related to R and R ‘. In the case of no-arbitrage, the market price m satisfies the following conditions

Then the equation satisfies that the first derivative of the function ψ to the market price m is zero:

we can get the following results:

In the paper “the replicating portfolio of a constant product market” written by Joseph Clark, he proposed to use the European option with CPM income to improve the income of LP. In his view, a certain proportion of transaction costs obtained by LP according to the new asset proportion can be accurately copied with the static combination of futures and options. If these futures and options exist and are tradable, the transaction fee charged per thousand displays will be determined by the option price and the expected trading volume. If futures and options do not exist, CPM’s revenue can be used to create them.

We can discuss the return under CPM mode and the total return of the final portfolio investment in detail.

We assume that the current market price is

Then the reserve can be expressed as

Then the net profit of portfolio investment we get in time is as

Obviously, we can get the total return of the final investment as

Of course, we have another way of thinking, that is, to study the return of the European call option on LP under the CPM model. Different from the portfolio return mentioned above, this option is not static, but it can maintain accuracy under limited hedging. Following the example of option Greeks and Joseph Clark, this paper gives the indexes that affect the option price under the CPM model:

The total return of copy option is equal to the sum of CPM return and original return of futures:

In conclusion, it is not difficult for us to see that Joseph Clark thinks that the risk loss of LP can be hedged by static portfolio, while the dynamic hedging quantity is closely related to curvature. If options and futures are not tradable, the income from CPM can also be used as an alternative to copy options.

To be continued

We have many topics and latest research results to share with you, including

(1) In fact, the mathematical formula expression of LP ultimate revenue and the most essential factors affecting LP revenue can be demonstrated through the formula to help AMM products better carry out iterative improvements, such as curvature that affect LP revenue and information trading ;

(2) The real mission of Yield Farming is not only to compensate for the impermanent loss, but also to play a very good role of the issue of the original token of AMM project itself and the role of token price stability, we believe that the token price issued through liquidity mining will not exist the phenomenon of death spiral, but will create a strong support for the market value of the project. Of course, the premise is that the project is very popular , in addition, the specific subsidy value of liquidity mining also exists mathematical expression and analysis influence factors;

(3) AMM projects will develop towards dynamic AMM form in the future, that is, they will no longer be limited to a curve form, but will be assisted by a variety of curve forms according to different situations; curvature is a curve research field that has been largely ignored, curvature almost determines all AMM product features, and curvature can even change the main market pricing of a new token.

--

--