Thoughts on Automated Market Makers

Kevin Xu
6 min readDec 15, 2020

Introduction

Automated market makers (AMMs) are an alternative to limit order books as a way to offer markets for assets to be exchanged. With a traditional limit order book, a liquidity provider sets their own prices for assets to be traded; in an AMM, however, a liquidity provider deposits two or more assets into a liquidity pool, and an algorithm automatically determines an exchange rate for each asset in the pool based on their relative supply. As a result, if the value of one asset inside the pool increases externally, arbitrageurs will execute trades in order to adjust the ratio of assets within the pool to accurately reflect the existing market.

Why AMMs are so prevalent in decentralized finance

While automated market making has existed as a strategy in traditional finance for a while, AMMs as a market structure have taken over the DeFi space due to limitations in blockchain technology. In limit order books, market makers must manually adjust their offered prices to reflect changing market conditions. However, managing a limit order book on-chain is highly impractical because of the slow speed and gas fee incurred every time a change is made. Any improvements to the user experience would require the market liquidity and asset custody to move off-chain and be managed by centralized entities, which both defeats the purpose and goes against the ethos of decentralization.

AMMs remove the need for liquidity providers to manually adjust their pricing, enabling users to trade assets on-chain in a completely decentralized and non-custodial manner. Further, without the need for manual pricing, AMMs make it easy to bootstrap liquid markets across lesser known assets without the need for professional market makers to operate them.

Providing liquidity in an AMM

Traditionally, market makers earn money by offering a bid/ask spread on an asset and occasionally taking positions that expose them to price movements for that asset. In limit order books, good market makers can differentiate themselves through their pricing strategy and how they manage their positions/overall exposure.

In AMMs, however, liquidity providers have none of these options: they don’t choose the prices they offer, nor do they choose the positions they take on assets. Rather, liquidity providers are forced to take positions in the market based on the relative balance of asset values in the pool; this means that as the ratio of assets in the liquidity pool changes, so does a liquidity provider’s position. As a result, liquidity providers don’t always withdraw the same amount of assets from a pool that they deposit. Instead, the final amount they receive of each asset is determined by the net change in price ratio of the assets during the liquidity provision period.

Oftentimes, due to arbitrage, the final net value of assets withdrawn is lower than the total value deposited, particularly if the price ratio of the assets changed from deposit to withdrawal. This phenomenon is called “impermanent loss”, but the name isn’t entirely accurate: these losses are only considered “impermanent” due to the assumption that the ratio of asset prices in the liquidity pool will eventually revert back to the original ratio upon deposit. In reality, however, this is rarely the case (particularly for volatile assets), and liquidity providers often incur very permanent losses due to price movements.

Liquidity providers may still be inclined to take on this volatility risk because they earn a portion of the fees from the trading that occurs within a pool. Because of this, liquidity providers should find pools with the lowest expected long-term price divergence and highest trading volume for the best opportunities; for the DeFi markets today, without the addition of alternative incentives like yield farming, these opportunities seem to be mostly in stablecoin to stablecoin pairs.

Design considerations for AMMs

Due to the popularity of DeFi, AMMs are becoming more widely used in blockchain projects. However, it’s essential to recognize that not all AMMs are the same: various factors need to be considered when designing an AMM for it to be compatible with the specific characteristics of the market it serves.

The main factor to consider is the type of function used for the AMM’s pricing algorithm. While a constant product market maker (CPMM) is by far the most common type of curve being implemented, there are many different types of functions that can be used with AMMs, each resulting in different parameters around liquidity, price slippage, and even price boundaries in the exchange rates of assets within the pool. Certain functions will be better suited for specific applications, and projects should pay attention to the curve that they use.

One example is the use of logistic pricing functions (Hanson’s Logarithmic Market Scoring Rule) in prediction markets. With this use case, assets (outcome shares) in a liquidity pool stay between $0 and $1 based on the probability of a market’s expected outcome. AMMs that use logistic functions will not only enforce these price boundaries, but also offer liquidity at every probability in a market, with the greatest price discovery around the middle of the curve (~50%).

It’s important to choose the right type of algorithm for the right type of market; poorly chosen functions for an AMM can result in suboptimal market outcomes. One such example is Zora’s use of a constant product market maker (CPMM) for their product marketplace. While CPMMs are commonly used by decentralized exchanges today, they have very different market requirements. Decentralized exchanges need to maintain reserves for all the assets in the liquidity pool, otherwise attackers can drain one side of the liquidity pool, leaving it worthless and causing large financial losses to the liquidity providers. However, maintaining the liquidity pool reserves is not a desired property of the AMM, but a necessity; the extreme distortion near the bounds of a constant product curve creates significant price slippage and capital inefficiency for traders.

In Zora’s exchange, however, manufacturers offer a market of exclusive items to be sold (“drops”), where each item in stock is represented by an ERC-721 token. This creates three key differences from a normal decentralized exchange: first, manufacturers are the only liquidity providers in the market, since they are the only ones who can create the product being sold; second, manufacturers are able to quite literally create new liquidity on demand in the event that the tokens in the liquidity pool are “drained” (the corresponding product sells out); third, Zora is the only exchange that offers a price on the products, so there’s no opportunity for an arbitrage attack to happen in their markets.

When considering these factors, Zora’s marketplace would greatly benefit from using a constant sum market making curve (CSMM) rather than the CPMM they currently use. However, because of their choice in AMM algorithm, manufacturers on their exchange are required to lock up more capital per product launch, experience significantly worse price discovery for their products in the market, and can never sell their last product, making it highly impractical.

Future innovations in AMM design

While AMMs are still a nascent technology, projects are continuing to innovate on their AMM designs. One such innovation is the combination of different functions (hybrid function market makers) to borrow the best elements of each. Curve’s AMM, for example, uses a combination of CPMMs and CSMMs to create denser pockets of liquidity along the center of the curve, resulting in smoother price movements for most trades and exponential prices only as trades get larger. As a result, their markets are more capital efficient and generate more trading fees for liquidity providers while offering better prices to users.

Another innovation is Bancor V2’s use of oracles to update a liquidity pool’s exchange rate, rather than relying on arbitrageurs to move the price within the pool. By doing so, Bancor can drastically reduce the risk of impermanent loss for their liquidity providers, likely resulting in higher earnings from trading fees overall across their markets as well. Other projects like Kyber have a similar idea of using oracles to adjust their exchange rates for reduced impermanent losses, and are also experimenting with using permissioned liquidity pools and professionally managed exchange rates to combine elements of AMMs and limit order books to get the best of both worlds.

In the grand scheme of things, though, there is still a lot more room for exploration and innovation, and I’m excited to see how the space develops. One idea that interests me is time-volume adjusted curves, or dynamic algorithms that can adjust and respond to real-time trading activity by using past block data as an input for the pricing function. Would it be possible, for example, for an AMM to borrow liquidity from the future in order to stabilize market prices during unexpected spikes and shocks such as flash crashes or margin calls? I’m curious to find out.

Sources (in no particular order)

  1. https://cipher.substack.com/p/an-introduction-to-automated-market
  2. https://medium.com/multi-io/automated-market-makers-amm-breakdown-d3338f027230
  3. https://blog.chain.link/challenges-in-defi-how-to-bring-more-capital-and-less-risk-to-automated-market-maker-dexs/
  4. https://medium.com/terra-money/survey-of-automated-market-making-algorithms-951f91ce727a
  5. https://store.zora.co/introducing-zora
  6. https://medium.com/gauntlet-networks/can-one-hear-the-shape-of-a-cfmm-part-1-d0d0d249bf81
  7. https://medium.com/gauntlet-networks/can-you-hear-the-shape-of-a-cfmm-part-2-6bf8ec6ddcf6

--

--