Author: Jackson
AMM (market maker) runs through the DeFi world, and the AMM model also builds the foundation for the prosperity of the DeFi world. If you want to build a basic understanding of the DeFi world, it is recommended to read the following carefully, Let's for fun.
What is AMM (Automated Market Maker)
Before understanding AMM, let us see what is a market maker in the traditional sense? The so-called market maker (AMM) is an entity responsible for providing liquidity to the exchange and performing price operations at the same time. This is achieved through MM buying and selling assets from their own accounts. Their purpose is to make a profit. Their trading activities create liquidity for other traders, which reduces the slippage of large transactions. Before the large-scale popularization of computer trading , market makers are an integral part of the trading market.
The cryptocurrency market also has the need to provide liquidity and pricing, but in the pursuit of decentralized cryptocurrency markets, this centralized market maker mechanism is not used by people. Hence the emergence of automated market makers (AMMs), mechanisms that use algorithmic “bots” to simulate these price actions in electronic markets such as DeFi. We can think of AMM as an original, robot-style market maker that provides quotes between two assets at any time for users to trade according to a self-defined pricing model.
1. AMM categories and their pricing models
Constant Function Market Makers (CFMMs) are currently the most popular AMM.
This AMM uses a constant function as its pricing mechanism when a trader wishes to trade between AB tokens. A "constant function" here means that some function value of a reserve of two or more traded assets must remain constant across any trade.
The current mainstream CFMMs are as follows:
A. Constant Product (Uniswap)
This AMM enforces that the product of the two asset reserves always remains constant, namely:
x * y = k
In this equation, X and Y represent the number of units of the two assets in the liquidity pool. For example, suppose the ETH/DAI pool contains 100ETH(X) and 10000DAI(Y). At this time K=1,000,000. The goal now is to keep the value of k constant regardless of the volume of transactions to the liquidity pool. The only way to do this is if the quantities of x and y vary inversely. In other words, when the amount of x increases (trader adds ETH to the pool), the amount of y must decrease (trader removes DAI from the pool). Ultimately, the quote on any given exchange is a function of the constant product formula and the proportion of tokens in the pool. The figure below approximates the exchange relationship between the two types of assets in this model.
It can be seen that in this way, the exchange between two types of assets is not a linear relationship, but a hyperbolic curve. In this mode, liquidity is always available, but the disadvantages are also obvious:
There will be slippage in the transaction, especially when the larger transaction is carried out, the slippage will be greater.
The price of the asset is likely to go higher and higher, with both ends approaching infinity
Unable to meet the needs of pending order transactions
B. Constant Sum (CSMM)
This type of AMM follows the formula x + y = k, allowing for zero slippage in transactions. But its fatal point is that it cannot provide unlimited liquidity. If the reference price of the reserve token is not equal to 1, all arbitrageurs will continue to buy one of the tokens until its liquidity is exhausted. So it is not a common AMM mechanism.
C. Constant Average (Balancer)
The constant average market maker is extended from the concept of the constant product market maker, which can be used for more than two assets, and the weight ratio is not limited to 50/50.
This type is actually a variant of the constant product model, the formula is as follows, where Bt is the quantity of asset t, Wt is the weight
Similar to Uniswap, the goal is to keep k constant by only changing the asset balance while keeping the asset weight unchanged. In the case of a 3-asset Balancer Pool, transactions can occur between any two of the three assets. Users can exchange ETH for DAI, ETH for BTC, or DAI for ETH. By keeping the value of k constant, a value surface can be generated between the three assets. This value is actually not much different from Uniswap's curve, it just has a few more dimensions.
The difference is that in this model, the pricing model becomes more complex
There are 2-8 assets allowed in the Balancer fund pool. Each pair of tokens in the pool has a price that depends on the balance B and weight W of that particular token. Formally, the price of transaction execution is calculated according to the ratio of token balance to token weight.
In the above formula, token A represents the token being sold (entering the pool) and token B is the token being bought (leaving the pool). If the holders of the pool do not change the asset reserve, it is easy to see that the price changes are purely based on transactions, because the asset weight must always remain the same. This mechanism, combined with the constant surface shown in Figure 2, ensures that the price of assets bought increases and the price of assets sold decreases. In the same situation as Uniswap, arbitrage opportunities ensure that the price offered by Balancer Pools moves in tandem with the rest of the market.
D. Hybrid CFMM (Curve)
After analyzing the above three models, we can see that they all have their own advantages and disadvantages, so some projects want to use the mixed function to obtain ideal properties based on asset characteristics. The representative project is Curve
Curve is an exchange liquidity pool in which assets that are expected to be stable in price can be efficiently traded between them (such as stablecoins or wrapped bitcoin). Uniswap and Balancer are primarily exchanges for volatile and price-unstable tokens. However, low price slippage is paramount when dealing with transactions between assets that want to be mutually stable. The inherent curvature of the various AMMs in previous iterations was problematic, as the larger the transaction size, the greater the slippage.
From the above we see that the constant sum mechanism can achieve no slippage, but it cannot stimulate liquidity, so Curve creates a hybrid AMM based on CSMM combined with a constant product function:
This function creates a relatively flat curve around the equilibrium point of the constant product curve, similar to the constant sum function, to keep the price relatively stable, while making the ends more sloped, similar to the constant product function, so that at each point of the curve There is liquidity. In the case of two assets (x and y), the end result is the complex function below.
Among them, n is the number of assets (n=2 in the case of dual assets), and A is the "amplification factor" parameter, which determines the similarity of the function to the constant product function. The smaller the value of A, the more similar to Uniswap's constant product function. We There is no need to understand the composition of this function, as long as the purpose of the function is to keep the constant K constant during the transaction. Plot the function as follows:
It can be seen that at the terminal of the function, it is more similar to a straight line, which is expressed as a constant sum function, but as x and y increase, it moves closer to a constant product function. This shape keeps the price in the middle section of the curve stable, and at the same time can Provides liquidity at both ends.
2. Market-making model and potential risks
Market-making model:
CFMM mainly has the following three types of participants:
Traders: wish to exchange one type of asset for another in CFMM
Liquidity providers: Provide asset portfolios (trading pairs) to meet transaction needs and earn transaction fees
Arbitrageur: maintain the assets in the trading pair at the market price through arbitrage behavior
Among these three types of participants, the most important role is the liquidity provider (LP), which is responsible for injecting its own assets into the smart contract of DEX, as an asset reserve pool, providing liquidity for transactions, and obtaining transaction fees in this way income. The second is arbitrageurs, who are responsible for correcting the transaction price to ensure that the transaction price is consistent with the market price, but they will also generate impermanent losses (Impermanent Loss), which brings the risk of loss to liquidity providers.
Let's take the transaction of asset A and asset B in Uniswap as an example. Before the transaction starts, we need to inject x amount of asset A and y amount of asset B into the blockchain smart contract as a liquidity reserve, that is, in the formula x*y=k, the initial value of x, y and k The value is determined by the Liquidity Provider (LP). Because the initial price between asset A and asset B is P = x / y, when the first liquidity provider (LP) recharges asset A and asset B that he thinks are of equal value into this smart contract, it can be realized The setting of the initial price P. After the opening of the transaction, combined with the different types of pricing models we mentioned in the first part, the price of the asset will continue to change according to the number of assets in the liquidity pool.
From the above, we can see that the automatic market maker system breaks the traditional trading system model, does not require order books, market maker quotations or system matching, but uses the liquidity in the reserve pool to complete asset transactions Exchange; most importantly, the transaction price of AMM is not determined by the quotation of the market maker or the order of the trader, but by the ratio of the two assets in the asset pool, so it is a liquidity-driven transaction system.
impermanent loss
impermanent loss
Due to the flaws in the model design, AMM had to introduce an arbitrage mechanism to improve its price mechanism. However, this also brings another serious consequence --- impermanent loss (Impermanent Loss)
The impermanent loss actually comes from the arbitrage behavior. We mentioned earlier that the transaction price of AMM is derailed from the fair market price. For this reason, arbitrageurs need to come in to buy undervalued assets or sell overvalued assets until the price provided by AMM matches the external market. Therefore, the profit of the arbitrageur actually comes from the liquidity provider, and the part of the loss caused by the arbitrage to the liquidity provider is called impermanent loss.
The following figure is an example. After the arbitrage occurs at T3, the total asset value in the liquidity pool is missing compared with the actual market value. This part of the value is the value that the arbitrageur earns from the liquidity provider.
The reason why liquidity providers (LP) provide liquidity for AMM is because they can obtain transaction fees, but the existence of impermanent losses increases the risk of liquidity providers. If the impermanent loss exceeds the liquidity gain, then LP will no longer provide liquidity. Therefore, the size of the impermanent loss is the key to determine whether the AMM DEX can operate normally.
Multi-Token Exposure
AMMs typically require liquidity providers (LPs) to deposit two different tokens to provide equal liquidity on both sides of the transaction. Therefore, liquidity providers (LPs) cannot maintain their long-term exposure to a single token, but instead must divide their exposure by holding additional ERC20 reserve assets. Teams with large amounts of one token, or individual holders wishing to provide liquidity, are forced to purchase another asset in order to provide liquidity, thereby reducing their holdings in the pool’s base token and increasing their interest in Exposure to another asset.
3. Advantages and disadvantages
advantage analysis:
The advantages of AMM are obvious. Its appearance coincides with people's pursuit of decentralization, automation, and fast transaction needs in the DeFi market. At present, most of the transaction volume in the DeFi market occurs on the DEX that uses AMM. It fully reflects the user's trust in this transaction model. DEX is also the most usable digital currency transaction type in the current defi market. However, there are still many problems in the current AMM mechanism. In some respects, compared with the traditional centralized bidding, the market maker mechanism still has shortcomings. These Aspect is also the direction that the AMM projects currently on the market will focus on in the future, which will be summarized here.
Disadvantage analysis:
Cannot be priced independently
As we mentioned earlier, the price of AMM is driven by liquidity, and the transaction price is determined by the asset status of the reserve pool, not the order price. That is, AMM can only generate transaction prices, but cannot find market prices. For this reason, AMM has to introduce the important role of arbitrageur: once the price on the AMM platform is different from the fair market price, there will be room for arbitrage and the price will be brought back on track.
This means that without the existence of a centralized exchange on the market, the trading platform using AMM cannot reflect the real asset price, so it cannot completely replace the existing bidding system and market maker system.
Trading Depth (Slippage):
Transaction depth is one of the important indicators to measure the quality of market transactions, reflecting the market's ability to withstand large-scale transactions without large price fluctuations. Many people in the industry believe that as long as sufficient liquidity is provided to the market, the problem of transaction depth can be solved. This is true for order book-based bidding systems and market maker systems, but for AMMs, the model itself also affects transaction depth.
Compared with the traditional trading system, under the condition of providing the same liquidity, AMM users put more assets A into the trading contract, and the less asset B is exchanged, that is, the higher the transaction price. Therefore, the transaction depth of AMM depends not only on the size of LP (that is, k value), but also on the model itself. Therefore, although the simple trading model of many DEXs has brought them great advantages, it also brings the problem of high slippage. Especially for assets with a small reserve pool, it cannot support large transactions, otherwise it will pay a higher price.
Capital inefficiency:
Since AMMs allocate funds evenly across the entire price range (0, +∞), only funds allocated around market prices are effectively utilized, and a significant portion of funds is only available when the pricing curve begins to shift exponentially. As a result, AMMs require massive amounts of liquidity to match the slippage in traditional order book trading.
However, Uniswap's V3 has greatly improved capital efficiency through the reform of the market-making mechanism on the original basis. And judging from the latest news, uniswap will also improve the transaction efficiency of large-value transactions by splitting large-value orders. can look forward to~
4. Representative product and its economic system design
At present, there are many DEX products that apply the AMM mechanism in the market, and their trading volume occupies a large part of the Defi market. Here, we will select several representative products in the market for analysis. It mainly includes the pricing model used, the economic system, and where are the advantages and characteristics of these products (where do they focus on)
According to CoinMarketcap, the top ten DEX trading volumes are as follows:
Uniswap(V3)
Uniswap has occupied the leading position of DEX trading since its launch, and it was his appearance that introduced AMM into the defi world. During this process, this project has also undergone many updates. Uniswap basically represents the standard of AMM DEX projects, and most other projects are Fixes and improvements based on Uniswap. Uniswap itself is also constantly iterating its version. Not long ago, V3 just went online, and its latest version will be used for research here.
pricing model
Economic system
Economic system
UNI is the native token of the Uniswap protocol, which empowers holders with governance rights. This means that UNI holders can vote on protocol changes. The total initial minting of this token is 1 billion, 60% of which will be shared by existing Uniswap community members, and the remaining 40% will be distributed to team members, investors and advisors within four years.
characteristic
characteristic
concentrated liquidity
concentrated liquidity
In Uniswap's liquidity pool, the price curve corresponding to the liquidity provided by liquidity providers (LP) actually ranges from 0 to infinity. All of these funds are deposited in it, in case one of the assets in the pool has 5x-s, 10x-s or 100x-s.
If this happens, these idle assets will ensure that the corresponding part of the price curve remains liquid. This means that only a small fraction of the liquidity in the pool is concentrated in the price range where most deals are made.
Today, liquidity providers can set their own price ranges for pools that inject liquidity. As a result, liquidity is more concentrated into the price range corresponding to most trading activity. Greatly improved capital efficiency.
The principle of Uniswp V3 to achieve liquidity aggregation is also very simple: two parameters are mainly added on the basis of the V2 version,
(x+m)*(y+n)= k
m= L/√(p_b )
n= L √(p_a )
L^2=k
In Uniswap V3, x and y are actual reserve assets, (x+m) and (y+n) are virtual assets, and virtual assets are equivalent to x^' in the V2 version (x^'*y^'=k) and y^'. For example, in the V2 version, the quantities of x^' and y^' are 300 and 600 respectively. In the V3 version, if m is 100 and n is 200, then x and y only need 200 and 400 respectively. From the above, we can find that under the premise of ensuring that the model liquidity is consistent with the V2 version, the V3 version reduces the actual quantity requirements of x and y assets, thereby improving capital efficiency.
PancakeSwap
Pancakeswap runs on BSC, which can be regarded as the DEX version of binance, which is not much different from Uniswap in terms of core
Similar to other AMM exchanges, the Pancake transaction fee is 0.2%, of which 0.17% is used as liquidity mining rewards and 0.03% is used as system income. Pancakeswap is like a decentralized version of Binance. In addition to trading businesses, it also has many other subsidiary functions. The combination of these functions makes Pancakeswap no longer a pure DEX, but a comprehensive DeFi service platform.
MDEX
Similar to Pancake, MDEX is backed by HECO and also has a high transaction volume. The transaction fee of MDEX is 0.3%. What is special is that MDEX supports transaction mining, and users can obtain MDX tokens through transactions
Sushiswap
Sushiswap is a fork of Uniswap. It is not different from DEX itself. The difference lies in the operation and governance strategy outside DEX. Unlike Uniswap, which focuses on the improvement of swap itself and its liquidity mechanism, Sushi is more inclined to expand other functions and businesses that can help increase its liquidity.
Curve(V2)
As we mentioned before, Curve uses the mechanism of hybrid CFMM to create a curve that has the characteristics of constant and no slippage stability in its core range, and guarantees flow at both ends of the curve. The existence of such a mechanism is that it can provide extremely low slippage for stablecoin transactions on DEX while ensuring liquidity.
V2 curve
At the same time, in the latest version V2, the project has made improvements to the curve:
The core part of this latest mathematical model is that it creates a new shape of the curve. Intuitively from the figure above, the two dotted lines are constant product curves, the blue line is the famous Curve V1 stablecoin exchange curve, and the yellow curve constructed by Curve V2 has two basic features——
(1) Between the constant product curve and the Curve V1 curve;
(2) Its curve tail feature has obvious constant product curve fitting.
So what problem does it solve:
(a) Inherited the advantages of Curve V1's ultra-low slippage and accumulated liquidity in the area near the "equilibrium point";
(b) By fitting between the constant product curve and the Curve V1 curve, and fitting to the constant product curve in the middle tail area of the curve, the advantage of the constant product curve responding quickly to changes in fluidity can be obtained, avoiding the depletion of pool fluidity, and flexible response Rapid market changes.
In addition, there is another very important innovation:
Internal oracle repeating mechanism.
This mechanism is very beneficial for implementing better centralized liquidity and slowing down impermanence loss.
To put it simply, this mechanism makes the originally fixed Curve V1 curve continuously change the equilibrium point with the large deviation of the exchange rate on the market, so that it will always have the greatest liquidity near the current exchange rate, timely resist arbitrageurs, and slow down impermanent losses.
It can be seen that Curve uses a very complex mathematical model to create a curve that can dynamically balance between the constant product curve and the constant sum curve, so that the stable currency transaction on Curve can have both low slippage and high liquidity of the two curves characteristics.
At the same time, the new introduction mechanism solves the problems of impermanence loss and capital efficiency to a certain extent. The mathematical ability of the team is their core competitiveness.
Curve's Incentive Mechanism
In addition to the low slippage and low impermanence loss we mentioned above due to Curve’s unique curve design, Curve’s low transaction fees were its selling point at the beginning of its establishment, but this resulted in a corresponding decrease in LP’s income. This Curve has a liquidity incentive mechanism that is different from most DEXs.
AMM is one of the transaction models driven by liquidity. Although it is not original in the blockchain ecology, it lacks in the development and growth of the blockchain ecology. The reasons, we believe, are as follows:
1: Simple pricing and market-making models lower the threshold for liquidity aggregation
2: Uniswap and other products have no censorship and restrictions, and the highly commercialized currency listing mechanism has promoted its barbaric growth
3: Simple UI and product logic lower the threshold for users to use
4: The spirit of open source promotes the evolution of combinatorial innovation
5: The liquidity mining mechanism promotes the demand for AMM
The composability of DeFi gives AMM a new meaning, that is, "infrastructure". In the overall ecology of DeFi Lego, AMM and lending, insurance, synthetic assets and other products play the role of infrastructure. Various types of products Combinations also inspire more innovation. Innovation is also faced with the pressure of financial risks and compliance risks, especially the recent event that Uniswap’s front-end delisted stock tokens, which also aroused many practitioners’ concerns about regulation. Fortunately, this kind of worry is more aimed at the project side. The essence of the DeFi ecology will not be affected, and the future is still promising.
Risk warning: Digital assets are a high-risk investment target. The general public is requested to view the blockchain rationally, raise risk awareness, and establish correct currency concepts and investment concepts.
About SeerLabs:
SeerLabs (Prophet Labs) is a leading institution in Asia that focuses on blockchain market incubation. We have global cutting-edge marketing concepts and growth hackers, and are committed to helping project parties and startups achieve lightning-fast growth. Successfully participated in the incubation of 30+ projects such as Ploygon (MATIC), HoDooi.com, DIA, Paralink, Swingby, XEND Finance, BOSON, etc.
Risk warning: Digital assets are a high-risk investment target. The general public is requested to view the blockchain rationally, raise risk awareness, and establish correct currency concepts and investment concepts.
