Constant Function Market Makers: DeFi’s “Zero to One” Innovation | by Dmitriy Berenzon | Bollinger Investment Group | Medium

image

In many markets, there may not be enough organic liquidity to support active trade. Market makers are agents that alleviate this problem by facilitating trade that would otherwise not occur in those markets. “Automated market makers” (AMMs) are algorithmic agents that perform those functions and, as a result, provide liquidity in electronic markets.

While automated market makers have been studied in both theory and practice, “constant function market makers” (CFMMs) are a “zero to one” innovation for both academic literature and financial markets. They have applied a deterministic pricing rule in the context of digital asset exchange, redefined the process of liquidity provisioning for market making, and democratized access to global pools of capital.

In this post, I will:

  • Explain the difference between automated market makers and constant function market makers
  • Explore the pros & cons of constant function market makers and discuss future directions of CFMM designs and use-cases

Clarifying terminology

While there has been a lot of excitement in the crypto community around automated market makers, there has been a lot of confusion over terminology.

While most people think of Uniswap when they think of AMMs, the concept has actually been studied extensively in academic literature for over a decade, the majority of which were primarily designed for information aggregation and implemented in markets where payoffs depend on some future state of the world (e.g. prediction markets).

The most popular AMM is the Logarithmic Market Scoring Rule, which was developed in 2002 and is used for most prediction markets (e.g. Augur V1 and Gnosis). There are a variety of other approaches to AMMs for information aggregation, such as Bayesian market makers (often good for binary markets) and dynamic pari-mutuel market makers (often used for horse racing).

While it is true that Uniswap is an AMM, we could refer to it with more specificity. Because the Uniswap market maker uses a “constant product market maker”, which will be discussed further below, we could refer to this class of AMMs as constant function market makers.

It is also common to hear the term “bonding curve” when talking about CFMMs but it is incorrect to do so. Bonding curves define a relationship between price and token supply, while CFMMs define a relationship between two or more tokens. In fact, the creator of the term stated that “bonding curve” was actually intended to be used in the context of a “bonded together curation community”.

Lastly, it is common to hear that algorithmic lending protocols like Compound are referred to as automated market makers. I believe that these algorithmic markets utilize a type of AMM that is not a CFMM because the interest rate function is dynamic based on the utilization ratio and the goal is not to keep the interest rate constant.

Constant Function Market Makers

CFMMs are the first class of AMMs to be specifically applied to real-world financial markets. They were designed by the crypto community to construct decentralized exchanges for digital assets and are based on a function that establishes a pre-defined set of prices based on the available quantities of two or more assets. Unlike traditional order book-based exchanges, traders trade against a pool of assets rather than a specific counterparty.

The term “constant function” refers to the fact that any trade must change the reserves in such a way that the product of those reserves remains unchanged (i.e. equal to a constant).

CFMMs typically have three participants:

  • Traders: Exchange one asset for another asset.
  • Liquidity providers (LPs): Willingly accept trades against their portfolio in exchange for a fee.
  • Arbitrageurs: Maintain the price of assets within that portfolio in accordance with the market price in exchange for a profit.

CFMMs are often used for secondary market trading and tend to accurately reflect, as a result of arbitrage, the price of individual assets on reference markets. For example, if the CFMM price is less than the reference market price, arbitrageurs will buy the asset on the CFMM and sell it on an order book-based exchange for a profit.

Constant Product Market Makers

A constant product market maker, first implemented by Uniswap, satisfies the equation:

Where R_α and R_β are reserves of each asset and γ is the transaction fee. Trading any amount of either asset must change the reserves in such a way that, when the fee is zero, the product R_α*R_β remains equal to the constant k. This is often simplified in the form of x*y=k, where x and y are the reserves of each asset. In practice, because Uniswap charges a 0.3% trading fee that is added to reserves, each trade actually increases k.

image

A constant product function forms a hyperbola when plotting two assets, which has a desirable property of always having liquidity as prices approach infinity on both sides of the spectrum.

Constant Sum Market Makers

A constant sum market maker is a relatively straightforward implementation of a constant function market maker, satisfying the equation:

image

Where R_i are the reserves of each asset and k is a constant. While this function produces “zero slippage”, it does not provide infinite liquidity and thus is likely unfit as a standalone implementation for a decentralized exchange use-case. In practice, what would happen is that any arbitrageur would always drain one of the reserves if the reference relative price of the reserve tokens is not one.

image

A constant sum function forms a straight line when plotting two assets, resulting in the equation x+y=k.

Constant Mean Market Makers

A constant mean market maker is a generalization of a constant product market maker, allowing for more than two assets and weights outside of 50/50. First introduced by Balancer, constant mean markets satisfy the following equation in the absence of fees:

where R is the reserves of each asset, W is the weights of each asset, and k is the constant. In other words, in the absence of fees, constant mean markets ensure that the weighted geometric mean of the reserves remains constant.

image

Source: Balancer Whitepaper

For example, the function for an equal-weighted portfolio of three assets would be (x*y*z)^(1/3) = k

Hybrid CFMMs

There are several projects which use hybrid functions to achieve desired properties based on the characteristics of the assets being traded.

Curve (a.k.a. Stableswap) had the insight that if the underlying assets are relatively stable-priced (e.g. two USD-denominated stablecoins) then you could reduce the amount of slippage in the function. It uses a hybrid of a constant sum and constant product, and arrives at quite a complex function below:

Where x is the reserves for each asset, n is the number of assets, D is an invariant that represents the value in the reserve, and A is the “amplification coefficient”, which is a tunable constant that provides an effect similar to leverage and influences the range of asset prices that will be profitable for liquidity providers (i.e. the higher the asset volatility, the higher A should be).

This function acts as a constant sum when the portfolio is balanced and shifts towards a constant product as the portfolio becomes more imbalanced. In effect, the function looks like a “zoomed-in hyperbola”.

image

Source: Curve Whitepaper

Shell Protocol has similar goals but takes a different approach. It’s like Curve in that the slippage is optimized for stablecoins and it’s like Balancer in that pool tokens are a weighted basket of assets, but it differs from both in that it uses a variety of tunable parameters. It uses the following functions:

Source: Shell Whitepaper

Where U(x) could be interpreted as a utility function comprised of a gain function, G(x), and a loss function, F(x); and x is the reserves of each asset. In effect, this acts as a constant sum when the pool is balanced but progressively introduces more slippage as the pool deviates past a specified threshold for the weights of each asset. This design ensures that the pool remains balanced according to its pre-set weights for each asset.

Benefits of Constant Function Market Makers

Faster exchange

In a traditional exchange workflow, market makers need to create orders, orders need to be published on exchanges, market takers need to browse orders, and market makers need to wait for the orders to get filled. Because of this matching process, there is the possibility that some orders may take a while to get filled, if ever. By overcoming an economics problem known as the coincidence of wants, CFMMs allow for an exchange to occur immediately, which could be important for certain use-cases (e.g. in-game items that are hard to market make because of low liquidity).

Bootstrapping liquidity

Bootstrapping liquidity in an order-book-based exchange is an extremely tedious and expensive process. Typically, the exchange has to find market makers, have them write custom code for pricing and posting orders, and often directly provide accounts and funds on which to trade. Exchanges often have to handle some of the execution themselves by running an internal trading desk with controls to make sure they’re not front-running their customers. Alternatively, the founders often hack together a python script to offer liquidity with their own assets and simultaneously hedge their risk on other exchanges. “Delta neutral” market makers also have a difficult task at hand if they have to find a way to hedge assets off their books since it is often not possible if a natural buyer or seller does not exist.

Because CFMMs encourage passive market participants to lend their assets to pools, they make liquidity provisioning an order-of-magnitude easier. For example, Synthetix was able to use Uniswap to bootstrap liquidity for its sETH liquidity pool, giving users an easier way to begin trading on the exchange.

On-chain oracles

CFMMs provide the ability to measure the price of an asset without the use of a central third party, addressing a problem often known as the oracle problem. Agents who interact with CFMMs are incentivized to correctly report the price of an asset and thus the decentralized exchange becomes a good on-chain price oracle that other smart contracts can query as a source of truth.

Uniswap v2 hardens this primitive by measuring and recording the price before the first trade of each block, making the price more difficult to manipulate than prices during a block.

Path independence

Path dependence, in a nutshell, means that “history matters”. Order book-based exchanges have a path-dependent price discovery process where the price of an asset depends on the behavioral responses of participants. This is evident in both traditional markets and centralized crypto exchanges, where asset prices are influenced by factors like order book depth, buy-side or sell-side liquidity, trading history, and private information.

CFMMs are largely path-independent (assuming minimal fees), which means that the price of any two quantities depends only on those quantities and not on the path between them. This offers two important benefits:

  • Because a trader gets the same price from participating all at once as in a set of small trades, traders do not need to strategize how they make trades.
  • It provides a minimum representation of state: we only need to know the quantity to price an asset.

Drawbacks of Constant Function Market Makers

Slippage

Slippage refers to the tendency of prices to move against a trader’s actions as the trader absorbs liquidity — the larger the trade, the greater the slippage. CFMMs incur large slippage costs and are thus better for smaller order sizes.

Exotic financial risk

Adding liquidity to a CFMM is simple but comes with some complex financial risks (impermanent loss, short volatility, long volatility/volume correlation, etc.).

For example, the Uniswap payoff curve is concave, meaning that liquidity providers are profitable within a certain price bound and will lose money in large price movements:

image

Source: AlfaBlok

Ideally, we want “convexity” when taking risk, which means having upside on both sides of the risk spectrum. This payoff structure suggests that liquidity providers should be actively monitoring changes in the liquidity pool and acting on changes quickly to prevent significant losses.

The Future of Constant Function Market Makers

Asset-specific functions

Curve and Shell have demonstrated that there exists a design space for constant functions that are tailored for specific types of digital assets.

As such, I believe that we will have a variety of CFMMs designed for asset types in addition to stablecoins, such as derivatives (e.g. collateralized options) and security tokens (e.g. real estate).

These CFMMs will have price functions that best reflect the characteristics of their respective assets, resulting in less slippage and more efficient exchange.

Liquidity sensitivity

This property implies that market makers should adjust the elasticity of their pricing response based on the volume of activity in the market. Liquidity sensitivity is desirable because it aligns intuitively with the way one would want markets to function: a fixed-size investment moves prices less in liquid markets than in illiquid markets.

Liquidity sensitivity for today’s CFMMs is limited to price (i.e. the larger the liquidity pool, the lower the price slippage) but there are additional dimensions that could be dynamic.

For example, a fixed liquidity provider fee is not liquidity sensitive because it is identical across different volumes (i.e. 0.3% regardless of the size of the liquidity pool).

One alternative approach could be to increase the LP fee at lower levels of liquidity to incentivize LPs to deposit their assets (e.g. 0.5% fee below a certain liquidity threshold, 0.3% thereafter).

Another approach could be to have decreased LP fees at the market’s initiation to encourage trading volume and increase the fees as the market matures. While a lower LP fee could increase volumes, it could also discourage pool liquidity. An interesting area of research would be to analyze the profit-maximizing fee that balances trade incentivization with liquidity incentivization.

Additionally, liquidity provider fees could be based on other factors in addition to liquidity. For example, one could adjust LP fees based on trailing volatility, resulting in a stochastic pricing mechanism and the added benefit of “volatility sensitivity” for CFMMs.

Primary markets

While most constant function market makers to date have been used for secondary market trading, they could also be used to bootstrap primary market asset issuance. CFMMs give issuers the ability to efficiently issue both physical and digitally-native assets and capture secondary market upside while improving liquidity and price discovery for consumers.

This was pioneered by Unisocks, which created tokens that entitled holders to a physical pair of limited edition socks. 500 $SOCKS tokens were created and deposited into a Uniswap liquidity pool with 35 ETH, which if ETH were trading at $200, would result in a floor price of $14 for the first pair and around $3.5M for the 499th pair. Saint Fame further legitimized the concept by selling shirts, Zora generalized the concept by creating a marketplace for limited-edition goods, and I expect to see many more projects using CFMMs for this use-case.

Interestingly, this brings us back to the initial use-case of AMMs, which was information elicitation, except this time it is about the price of an asset rather than the probability of an event occurring!

Conclusion

Constant function market makers are a fundamental innovation for financial markets and have introduced an exciting new area for academic research around automated market making.

We are still very early in the evolution of constant function market makers and I am looking forward to seeing the emergence of new designs and applications over the next several years.

Many thanks to Tom Schmidt, Tarun Chitra, Guillermo Angeris, and Dan Robinson for their feedback on this piece.

Sources: