Site icon Blaize

AMM Types & Differentiations

Securing liquidity or performing assets’ exchange are today’s essentials for crypto holders. Yet, it has been a while since the first DEXs were introduced and the modern crypto market has more to offer. In this article we are going to analyze a few different types of AMM and its variations. 

AMMs are automated actors which are built to control and establish price within a certain algorithm. AMMs are driven by smart contracts and therefore enable to fulfill fast and secured exchanges without traditional order book usage. As a financial instrument, the automated market maker has been known before, but the creation of a Constant Function model allowed for its further application to digital assets. 

In terms of CFMM (Constant Function Market Maker) a constant function refers to the meaning, that no matter what happens to equation variables, the product of those stays constant or simply the same. There are basically three types of CFMM applied successfully in the DEX environment until now. 

Classic Uniswap – Constant Product Market Maker 

CPMM (Constant Product Market Maker) is represented by a classic function: 

x*y = c

where X and Y are reserves of a certain (chosen) asset in the pool, and C is an unchangeable constant. The function establishes the price of a chosen token, meaning if the supply of token X increases, the supply of token Y decreases in order to maintain the constant value C. Classic versions of Uniswap (V1) and Bancor (V1) have successfully implemented this model. 

Earlier version of Uniswap allowed pooling just against ETH, renewed V2 enables to put two different ERC-20 tokens, but the basic structure remains the same. The CPMM model, applied here, suffers from several disadvantages which can lead to considerable loss in some cases. One of the main problems is a huge volatility and its direct dependence from arbitrageurs intervention. Therefore, there is a risk to pay more with Uniswap then with traditional centralized exchange. Read more about this in our previous articles.

Second big problem with CPMM pools is the possibility of impermanent loss or gain (but in practice loss has the highest probability). Such happens due to both, high volatility and non-adjustable constant price. Impermanent loss occurs in case the price in AMM models differs in any direction within a certain pool. In such a case, the bigger difference is, the greater impermanent loss occurs. In the best-case scenario, there are arbitrageurs who might get in and balance the pool (by selling one or another asset to the pool). Yet in practice, we often experience that impermanent loss becomes permanent due to the curve function. In case of larger asset supply, the price of a second asset goes down drastically so there is a truly low possibility of new trades within this certain pool.

The issue of impermanent loss and its possible mitigations will be further discussed in the next article. 

CPMM can be both very risky for one and extremely profitable for another. From a wide perspective, if we talk about money making, choosing a “smaller” pool seems more reasonable because the incentive mechanism in Uniswap (V1) works better when at the bottom of the curve. 

One of the variations of constant product equation is a Constant Sum Market Maker (CSMM)  formula, which is represented as follows: 

x+y = c 

and represents just a simple sum of two variables. Accordingly, variables can change multiple times, but the sum has to remain constant. Yet, this approach is not profitable in terms of any DEX, because it cannot provide an infinite liquidity, and there would always be a situation when one of the pool reserves will be emptied. It can be better shown on the graph below. Read: How to Prevent Vampire Attacks in DeFi

Stable Curve.fi – Hybrid Constant Function Market Maker 

Previously discussed Uniswap deals with unstable and highly volatile variables so automatically rebalancing CPMM formula works perfectly in this case. In terms of stablecoins, when there is no such problem as volatility, providing liquidity to the traditional CPMM would not bring much profits basically due to a huge slippage in the Uniswap example. 

In order to reduce the slippage for traders Curve.fi uses hybrid CFMM which combines CPMM and CSMM (x+y=c) and is represented as follows: 

where x is the asset reserve, n is the amount of asset, D is the invariant which reflects the reserve’s value, A is an “amplification coefficient”. While x is dimensionless, A is an adjustable constant which influences the asset price range. Therefore, A indicator grows along with the volatility of a certain asset.

As it is shown on the graph above, there is a part of the curve which remains almost unchanged. The hybrid model allows it to switch between two functions: a CSMM at the flat part and CPMM in the rest. The function changes if there is a price fluctuation and the pool becomes imbalanced. 

Revolutionary Balancer – Constant Mean Market Maker  

The one distinctive and revolutionary feature CMMM has brought is the ability to provide several assets to one pool. Unlike previous CPMM, this type of AMM relies on constant mean of each asset, or other words on its weight. The equation for liquidity pool with three locked assets would look as follows: 

(x*y*z)^(1/3) = c

where x,y,z are chosen tokens, c is a constant product of them. Firstly, this approach was introduced by Balancer Protocol and made a real breakthrough because of the ability to swipe several tokens within one pool.

Due to CMMM type, Balancer users are able to create what is called a “custom pool”. Thanks to the constant relation to the tokens’ weight, not product, there is the possibility of creating a pool with an unequal percentage of provided assets, for instance 30% DAI vs 70% ETH (or 60/30/10, 82/18 etc). In the case of CMMM, such asymmetry does not mean an automatic decrease of one asset price and increase of another, as it is in CPMM model. The token value is equal as long as the weighted reserves remain constant. This determination is applicable to all Balancer pools, meaning with three and more assets in it, where token weights are distributed accordingly. 

The possibility of providing three and more assets to the pool creates a more stable and pleasant environment for traders. Hence, the issue with impermanent loss is less possible in case of three or more tokens placement. More then two variables in the equation ensure higher stability and make lower influence on the curve. 

When it comes to creating custom pools, token development services play an important role in ensuring that the tokens in the pool are secure and operate as intended. Contact us to learn more.

Innovative Perpetual Protocol – Virtual Constant Product Market Maker 

The main idea behind this protocol is to enable profitable deals for derivatives such as perpetual contracts (which are roughly futures with no expiry date). Adapted virtual AMM model used in this case just for price establishment. The real assets are stored in the smart contract vault which is placed outside the AMM models. More information about how the vAMM works can be found here

Perpetual Protocol uses classic CPMM function:

x*y = c

with an additional variable which reflects the spread and is taken while supplying to the pool. The equation looks as follows:

(x-z)*(y+(a-spread- fee)) = c

where x,y are reserves of certain assets, a is the number of assets the user wants to supply to y, z is the amount on which x decreases if provide a number of tokens. Spread rate is shown in percentage and is established by governance of the protocol. 

The spread variable was added in order to compensate for possible loss from AMM and make the market independant from other changes. The spread amount here works as a reserve and is locked in the protocol Insurance fund. It is activated in case of AMM loss in order to cover damages. 

AMM models are used as a price establisher and money is secured into the smart contract, the curve cannot really influence the collateralized assets. Therefore, Perpetual Protocol eliminates impermanent loss possibility for its users. Another advantage of the model is that there is no real need in liquidity providers. Unlike traditional CPMM where pool’s liquidity come from LP, in vAMM traders provide money to the vault and thereby fill the pool by themselves.

The future of AMM

The idea of decentralized finance and direct transactions seemed just amazing a few years ago and remain so today. The AMM model has experienced a huge revolution through its near three years in crypto finance due to the increase of usage and new pricing mechanisms creation. One of the important concerns regarding earlier versions is that the amount LPs get should always remain sufficient in order to incentivize them to stay in or supply more liquidity. Therefore, one of the notable changements was switching from total protocol governance (in Uniswap v1) to introducing the ability of changing and establishing transaction fees to protocol users (Balancer). 

As it is seen in the case of Perpetual Protocol, Balancer has not reached the limit in AMM developing and new, hybrid models are here to come. The interest in crypto investments grows exponentially, therefore we should expect other platforms enabling derivatives for crypto DeFi, so Opyn or Perpetual may expect some competitors soon. Moreover, growing usage and participation in AMM based protocols increased scientific interest in this topic and led to a number of research and a vast set of new possibilities described. This generally contributes to broad understanding of the mechanism and gives one a guidance on how to develop a better CFMM for a certain asset type or volatility resistance. 

Exit mobile version