125 total views
AMM cannot eliminate the risks of slippage and impermanence, but only makes a trade-off between the interests of liquidity providers and traders.
Original Title: “New Understanding of AMM Solving the Problem of Slippage and Impermanence | TokenInsight”
Written by: TokenInsight
In the financial sector, risks cannot usually be eliminated but can only be transferred. This is the same in the DeFi field. For the DEX of the AMM protocol, the design of different mechanisms is actually more of a trade-off between the interests of different participants (LPs and traders). The current AMM agreement project does not eliminate risks. Uniswap’s AMM mechanism is simple and elegant. For Uniswap, slippage is essentially to protect the interests of LP and harm the experience of traders; while the impermanence loss is to protect the experience of traders and harm the interests of LP. This is a natural risk for AMM. At present, the projects on the market cannot eliminate these risks, but only make some trade-offs.
Under the automatic market maker (AMM) mechanism, the market-making threshold is lowered, and the participation of ordinary users is greatly improved, so it is easier to gather liquidity. But at the same time, compared with the trading platform of the order book model, problems such as slippage and impermanence losses are what makes AMM criticized. As liquidity mining led the AMM to explode in the third quarter, the industry began to pay more attention to the deficiencies of existing AMMs. New entry AMMs focused their attention on solving problems such as slippage and impermanence.
What is slippage and impermanence loss
Slippage and impermanence loss are widely mentioned concepts in the DeFi ecosystem, which bring a lot of risks to AMM users. In these two concepts, slippage refers to the difference between the expected transaction price and the actual transaction price. Slippage is not a new concept after the emergence of AMM, but a problem that exists in the traditional trading market. For exchanges under the traditional order book model, the higher the liquidity, the better the trading depth and the lower the slippage. Simply put, the more assets sold, the lower the price. The more assets bought, the higher the price.
The concept of impermanent loss (Impermanent Loss) was first proposed after the emergence of AMM, which means that in the operating environment of AMM, when liquidity providers (LPs) provide liquidity to AMM’s asset pools, the Losses due to market price fluctuations. The impermanence loss only exists in the AMM mode and may disappear after the asset price recovers. However, in most cases, since asset prices cannot be restored to their original positions, impermanence losses are actually permanent, which is why they are called differential losses (Divergence Loss).
 Uniswap: A Good Deal for Liquidity Providers?
Different from the traditional order book form, AMM uses a fund pool model to make market. The asset price in the asset pool is determined by the function, which means that the price of the trading pair in AMM is directly related to the reserve of its trading asset in the asset pool. Therefore, once a transaction occurs, resulting in a change in the reserve of the transaction asset in the asset pool, the actual transaction execution price of the asset will change, resulting in a slippage. Therefore, the larger the transaction volume and the deeper the destruction of the liquidity reserve of the capital pool, the higher the slippage.
The low slippage of AMM also depends on the mechanism it uses. First, slippage does not exist under the constant sum market maker function. That is, X and Y represent the reserves of the two assets in the asset pool, K is a constant, and the slippage is 0 when X+Y=K (as shown in the figure below) Straight line). However, this mechanism will lead to the exhaustion of asset liquidity, that is, Y will be 0 when X is large enough, and vice versa, so it is not used in practical applications.
To prevent the liquidity of the capital pool from drying up, transactions must be punished by slippage. Take Uniswap which uses a constant product market maker system (X*Y=K) and Curve which mixes constant sum and constant product market making as examples. The function curves are shown as the dashed and solid curves in the figure below. It is known that the slippage is 0 when the line is straight in the figure below, so the slippage becomes smaller when the curve fits the straight line. Curve focuses on trading pairs with stablecoins and asset prices at 1:1, making it possible to reduce slippage, but at the same time, this mechanism cannot be applied to trading pairs with violent price fluctuations, otherwise the cost of arbitrage under low slippage will be low , Easily lead to liquidity exhaustion.
Different market-making function curves; source: Curve white book
In addition, because the AMM capital pool must use a large amount of liquidity and idle capital to ensure that the asset transaction price remains competitive after the slippage occurs, the low utilization rate of capital has become another problem of AMM, and The income of LP comes from the transaction fees of actual transaction capital assets. This problem directly affects the income of LP. Reducing slippage can not only bring better prices to traders, but also bring more transaction fee income to LPs.
In the original definition, impermanence loss was only detected as a risk of Uniswap. Under Uniswap’s mechanism, the loss of LP due to the deviation of asset prices in the external market from production is very typical. Specifically, as Uniswap’s asset pricing is related to asset pool reserves, price discovery is completed on the chain and is not connected to external market prices. Therefore, when asset prices in the external market fluctuate, Uniswap needs to rely on arbitrage (Arbitrageurs) to correct the on-chain price to make it consistent with the external market price.
On the other hand, after LP provides liquidity to the capital pool, it obtains partial ownership of the capital pool, that is, the “shares” of the capital pool assets. In the process of arbitrage correcting the price on the chain, the profit they obtain is the loss of the capital pool, which makes the LP suffer a loss compared with passive holding of assets. Excluding transaction renewal fees and slippage, the specific steps of impermanence loss are as follows:
- Assume that the ETH/DAI resource pool has 10 ETH and 5,000 DAI, the internal price is 1ETH=500DAI, and the initial market price is 1ETH=500DAI. The internal price of the capital pool is equal to the market price, and the capital pool is balanced︔
- Assuming that LP Alice provides 1ETH/500DAI for the above-mentioned capital pool, Alice owns 10% of the “shares” in the above-mentioned capital pool;
The price of ETH in the external market rises, 1ETH=700DAI, and the internal price of the capital pool is still 1ETH=500DAI, resulting in arbitrage space;
Arbitrageur Bob buys 1 ETH from the asset pool at a price of 500DAI, with 9ETH and 5500DAI remaining in the asset pool. The asset pool is out of balance, the ETH reserve decreases and the price of ETH in the asset pool rises, and the arbitrage space continues until ETH The price rose to 700DAI (external market price);
- Alice wants to withdraw her capital when her capital pool is 9ETH/5500DAI. What Alice actually withdraws is 10%*9ETH/5500DAI, which is 0.9ETH/550DAI. Alice’s asset value at this time is 0.9*700+550=1180DAI;
- If Alice passively holds 1ETH/500DAI, her asset value should be 1*700+500=1200DAI. As an LP, Alice incurs an impermanence loss of 20 DAI .
According to the above-mentioned production logic of impermanent loss, the magnitude of impermanent loss is positively correlated with the degree of asset price fluctuations, and all AMMs that use asset reserves to price assets and rely on arbitrageurs to adjust asset price models on the chain must exist. Impermanence loss. Depending on the size of the external price fluctuation of the asset, the impermanent loss of LP production may be compensated by transaction renewal fees and liquidity mining revenue. At the same time, deduced from the mathematical formula, the function curve shape of impermanence loss is shown in the figure below:
Impermanence loss function curve; Source: TokenInsight
In addition to the risk of slippage and impermanent loss, the utilization rate of funds analyzed in the above paper is also considered to be insufficient by AMM. In addition, when the AMM asset pool requires users to pledge more than one asset and provide evidence for the liquidity of the LP’s cash proceeds in the form of “shares” in the transaction pair asset pool, the LP that only holds one asset will be Forced to assume the risk exposure of multiple assets.
In general, according to the above analysis, the risks and shortcomings of the AMM mechanism are mainly as follows:
- Slippage: high slippage, especially unfriendly for large transactions;
- Low capital utilization rate: the high degree of capital idleness hinders LP fee income;
- Impermanent loss: LP loss caused when asset prices fluctuate and deviate from asset prices in the fund pool;
- Multi-asset risk exposure: Liquidity providers may be forced to assume multi-asset risk exposure.
Problem optimization solution
The above analyses the deficiencies and risks of the AMM mechanism and the reasons for the deficiencies and risks. It can be seen from the above reasons that in view of the problems of slippage and capital utilization, the optimization solutions that can be adopted include changing the market-making function curve and using an oracle to feed the trading assets. However, because slippage can also prevent the loss of capital in the capital pool and protect the liquidity of assets in the capital pool, a market-making curve that fits zero slippage only has a good application scenario for trading pairs that have a 1:1 asset price.
Aiming at the problem of impermanent loss, the optimization plan also includes introducing an oracle to feed prices, so that the price in the fund pool is consistent with the external market price, and does not rely on arbitrageurs to correct the price in the pool; at the same time, the risks caused by impermanent losses and asset price fluctuations can also be It is managed through hedging. For the issue of multi-asset risk exposure, LP can be given a single asset pool of “shares” so that LP can only assume a single risk exposure.
In general, the effective optimization plan is as follows:
- Change the market-making function curve, narrow the trading application scenarios, and only provide transactions with relatively stable assets, such as stable currency transactions including Curve;
- Introduce an oracle machine to feed prices on the assets in the fund pool. This solution has been adopted by many projects, such as Bancor V2, DODO, and CoFix;
- Introduce risk hedging strategies, such as CoFix;
- Allow single asset risk exposure, such as DODO, Bancor V2.
The introduction of the oracle machine can effectively improve slippage and impermanence losses and become a solution provided by new entry AMM (such as DODO, Cofix) and AMM upgrades (such as Bancor V2).
The risks that still exist after the introduction of the oracle
The introduction of the oracle machine can simultaneously improve the slippage and the risks caused by asset price fluctuations. However, after the introduction of the oracle machine, does the AMM bring new risks while improving existing problems? First of all, as a third-party price-feeding tool, the oracle itself has certain risks: it is not uncommon for oracle attacks to cause a lot of losses in the DeFi ecosystem.
In addition, the principle of the AMM mechanism represented by Uniswap seems simple, but the design is exquisite, and its successful operation is reasonable. The overall mechanism design affects the whole body. Any optimization or even elimination for slippage and impermanence loss is often required. At the cost of other sacrifices.
In the following, the newly entered AMM DODO and CoFix are represented, and a specific analysis of the AMM that introduces oracles to reduce risks and improve deficiencies is made.
DODO introduces Chainlink as an oracle to feed prices to its trading assets, and uses PMM (active market maker) as its market-making algorithm. The PMM algorithm is to use an oracle to feed prices to the trading pair in the fund pool. When the external market price changes, it actively adjusts the internal transaction price.
First of all, the DODO asset transaction price does not change due to the asset reserve of the fund pool. Instead, it is actively adjusted according to the price feed of the oracle, so it can reduce the slippage and eliminate the impermanent loss caused by external price fluctuations and the imbalance of the capital pool in the narrow sense. At the same time, in order to balance the imbalance of the fund pool reserve caused by the transaction, DODO still needs to allow the existence of arbitrageurs; as shown in the figure below, taking the user selling B as an example, when the reserve of B in the pool rises (left side of the figure), DODO The price of B will be adjusted below the market price to encourage arbitrageurs to buy B from the pool. Therefore, this model needs to continuously, quickly and accurately adjust the price in the pool, which tests the price-feeding ability of the oracle. Once the market price cannot be tracked in time, it will not be able to effectively balance the fund pool and cause LP losses.
Principles of DODO Fund Pool Balance; Source: DODO White Paper
TokenInsight observed DODO’s 7 trading pair fund pools. As shown in the figure below, when the value of the Y axis is 1, it corresponds to the dotted position of B and Q in the above figure; theoretically, the fund pool should keep one side greater than one side. The status is less than 1. However, only WBTCUSDC in the 7 fund pools maintained this state well:
DODO fund pool balance; source: DODO Pool Tracker
The reliance on the oracle also creates the risk of front-running -arbitrageurs can look for arbitrage opportunities by monitoring the price of the oracle. When the difference between the two quotes of the oracle machine is greater than the transaction fee required for arbitrage, the arbitrageur can earn the price difference and make the LP suffer losses. This loss DODO is called arbitrage loss.
At the same time, DODO allows a single risk exposure, that is, allows LPs to provide liquidity of a single asset, and distribute income to LPs in the form of liquidity “shares” of that asset (not a trading pair). Taking the above figure as an example, when the reserve of B rises, it is necessary to sacrifice the interests of LP in the Q pool to encourage arbitrageurs to buy B. When the fund pools on both sides are less than 1 (the current status of most DODO fund pools), it means that both LPs have suffered losses.
In addition, DODO gathers liquidity near the market price to reduce slippage. Therefore, as the transaction volume increases, there will be a surge in slippage. Compared with Uniswap, DODO is more suitable for small transactions.
In general, the advantages and risks of DODO can be summarized as follows:
CoFix is bolder than DODO in improving traditional AMM. CoFix directly cancels algorithmic pricing and uses the external market price given by the Nest Protocol oracle as the transaction price. Since prices are determined by the supply and demand of assets in the external market, CoFix claims that its pricing model is an equilibrium pricing model (EPM).
In CoFix mode, slippage can be eliminated. However, if slippage is lost as a protection of the liquidity of the fund pool, there will be a risk that the assets of the trading pair in the fund pool will be consumed and the fund pool will be exhausted. As shown in the figure below, the total lock-up value of CoFix continues to decrease:
CoFix total lock-up value; source: DeBank
CoFix’s approach to this problem is to introduce “shock cost”, that is, when a single transaction volume is large enough, the shock cost is triggered and the transaction price is increased. However, after the shock cost is touched, the difference between the increased transaction price and the normal transaction price is very small (compared to other AMMs), so the protection of the liquidity of the fund pool is also limited.
CoFix slippage difference; source: CoFix official website
On the other hand, since the internal price of the fund pool is consistent with the market price, there will be no risk of impermanence loss, but this does not mean that the LP provides liquidity without risk.
Although CoFix allows LPs to be deposited into a single asset type, the calculation of LP’s return is still based on the transaction to the fund pool, that is, it does not provide risk exposure for a single asset, and LPs still need to bear multi-asset risk exposure. Since asset prices are completely decoupled from asset reserves in the fund pool, prices cannot be used as adjustment factors for balance reserves as in the DODO model; to ensure that LPs will not bear all losses when unilateral asset reserves fall, CoFix must make LPs Undertake the risk exposure on both sides of the fund pool. Dual asset risk exposure is a kind of protection for LP to some extent.
In order to optimize LP risks caused by changes in asset reserves, CoFix adopts risk quantification and risk hedging methods. Specifically, it is to develop a script to hedge by selling incremental assets or buying shrinking assets on a centralized exchange when the change in the asset reserve of the fund pool is greater than the preset threshold .
Overall, the advantages and risks of CoFix can be summarized as follows:
Based on the above analysis, TokenInsight has made a multi-dimensional summary of Uniswap V2, DODO, CoFix and Bancor V2, and measured data such as capital utilization and slippage.
Consistent with the analysis of TokenInsight, DODO has a better price for small transactions. When the liquidity is much lower than Uniswap, the price of small transactions is still better than Uniswap; the capital utilization rate is also higher. CoFix has no slippage, which is beneficial to traders, so its trading volume has performed better; but at the same time, its lock-up value has continued to decline since its launch, and its trading volume has far exceeded its lock-up value. Although Uniswap has been questioned by slippage and impermanence in its mechanism design, it is still the most liquid DEX, and due to its sufficient liquidity, the slippage problem is actually relatively not serious. At the same time, although Bancor V2 also introduced an oracle, it does not have a strong price advantage, so the transaction volume is relatively low.
From the various data , CoFix is undoubtedly a better choice for traders; DODO has a better price for small transactions, and at the same time provides LPs with a choice of single asset risk exposure. Uniswap has high liquidity and a smoother price growth curve.
The information and data details of each DEXs are shown in the following table (data deadline is November 24, 2020):
Uniswap: A Good Deal for Liquidity Providers?
Impermanent Loss Explained:
How to Bring More Capital and Less Risk to Automated Market Maker DEXs:
DODO white paper:
CoFix white paper:
Curve white paper: