NEM Glossary - Constant Function Market Makers (CFMMs)

NEM Glossary - Constant Function Market Makers (CFMMs)

Constant Function Market Makers (CFMMs) are the most popular class of AMMs, and are specifically designed to enable the decentralized exchange of digital assets. These AMM exchanges are based on a constant function, where the combined asset reserves of trading pairs must remain unchanged. In non-custodial AMMs, user deposits for trading pairs are pooled within a smart contract, which any trader can leverage for token swap liquidity. Thus, users trade against the smart contract (pooled assets) as opposed to directly with counterparty like in order book exchanges.

There are three primary designs of Constant Function Market Makers: 

- Constant Product Market Maker (CPMM) and it was popularized in the first AMM-based DEXs, Bancor and Uniswap. CPMMs are based on the function x*y=k, which establishes a range of prices for two tokens according to the available quantities (liquidity) of each token. When the supply of token X increases, the token supply of Y must decrease, and vice-versa, to maintain the constant product K. When plotted, the result is a hyperbola where liquidity is always available, but at increasingly higher prices that approach infinity at both ends.

- Constant Sum Market Maker (CSMM), which is ideal for zero slippage trades but does not provide infinite liquidity. CSMMs follow the formula x+y=k, creating a straight line when plotted. This design unfortunately allows arbitrageurs to drain one of the reserves if the off-chain reference price between the tokens is not 1:1. Such a situation would destroy one side of the liquidity pool, forcing liquidity providers to eat the loss and leaving no more liquidity for traders. Because of this, CSMM is an uncommon model of AMMs.

- Constant Mean Market Maker (CMMM), which enables the creation of AMMs that can have more than two tokens and be weighted outside of the standard 50/50 distribution. In this model, the weighted geometric mean of each reserve remains constant. For a liquidity pool with three assets, the equation would be the following: (x*y*z)^(⅓)=k. This allows for variable exposure to different assets in the pool and enables swaps between any of the pool’s assets.

As AMM-based liquidity has progressed, we have seen the emergence of advanced Hybrid CFMMs which combine multiple functions and parameters to achieve specific behaviors, such as adjusted risk exposure for liquidity providers or reduced price slippage for traders.

For example, Curve AMMs combine both a CPMM and CSMM to create denser pockets of liquidity that bring down slippage within a given range of trades. The result is a hyperbola (blue line) that returns a linear exchange rate for most trades and exponential prices only for larger trades.

Author: Artem
Published on: 21/10/2020 14:07 (edited on: 17/11/2020 16:48)




Artem (3.424)
Content Writer
5.738 Reputation
33126 Points
47 Activities