The Rise of Automated Market Makers (AMMs)

A Comprehensive Guide

Ahmed Ali
12 min readJul 29, 2023

What is Market Maker

A market maker is a participant in a financial market who provides liquidity by actively buying and selling assets. Market makers play a crucial role in ensuring smooth trading operations and maintaining a liquid market environment. They are typically entities or individuals that are willing to quote both bid and ask prices for assets, thus creating a market for buyers and sellers to transact.

Let’s consider a market maker facilitating the market for Ethereum (ETH) with an example of a sell-and-buy order.

A market maker for ETH would actively quote both bid and ask prices, creating liquidity and enabling smooth trading for participants. Let’s assume the current market conditions for ETH are as follows:

  • Bid Price: $2,500
  • Ask Price: $2,510

Now, let’s explore how the market maker operates:

Sell Order:

Suppose a trader wants to sell 1 ETH. The market maker, as a liquidity provider, is willing to buy ETH from the trader. Based on the current market conditions, the market maker quotes a bid price of $2,500. The trader agrees to sell 1 ETH at the bid price, and the transaction is executed. The market maker now holds 1 ETH in their inventory.

Buy Order:

On the other hand, if another trader wants to buy 1 ETH, the market maker is ready to sell ETH from their inventory. The market maker quotes an ask price of $2,510. The trader agrees to buy 1 ETH at the ask price, and the transaction is completed. The market maker now no longer holds any ETH in their inventory.

In this example, the market maker provided liquidity by actively participating in both sides of the market. They bought ETH from the seller at the bid price and sold ETH to the buyer at the ask price, effectively creating a market for ETH trading.

It’s important to note that the bid and ask prices quoted by the market maker may vary based on factors such as market conditions, order book depth, and their own risk management strategies. Market makers aim to profit from the bid-ask spread, which is the difference between the bid and ask prices.

By continuously providing liquidity and actively trading, market makers contribute to the stability and efficiency of the market, attracting more participants and fostering liquidity for cryptocurrencies like ETH.

What is an Automated Market Maker

Photo by Pierre Borthiry - Peiobty on Unsplash

Automated Market Makers (AMMs) have emerged as a groundbreaking solution within the decentralized finance (DeFi) ecosystem, revolutionizing the way digital assets are traded. By leveraging smart contract protocols and predefined mathematical formulas, AMMs enable seamless and direct token swaps, eliminating the reliance on traditional order books and intermediaries.

The fundamental concept behind an AMM is to provide liquidity and determine asset prices through automated processes governed by smart contracts. Instead of relying on centralized exchanges with order book-based systems, where buyers and sellers must wait for counterparties to match their trades, AMMs offer a more efficient and instantaneous trading experience.

Through the use of mathematical formulas embedded in smart contracts, AMMs calculate token prices based on the available liquidity in the pools. This liquidity is provided by individuals known as liquidity providers, who deposit their assets into the AMM’s liquidity pools. These pools serve as the backbone of the AMM ecosystem, facilitating the seamless swapping of tokens.

AMMs utilize various mathematical models to determine asset prices and ensure balanced liquidity. Some popular models include Constant Product, Constant Sum, Weighted Average Price, Constant Mean, and Constant Function Market Makers. Each model has its unique characteristics and is designed to address specific requirements or optimize different aspects of liquidity provision and token pricing.

By implementing AMMs, the DeFi space has witnessed significant advancements in terms of liquidity provision, trading efficiency, and accessibility. The absence of intermediaries enables anyone with an internet connection to participate in decentralized trading, contributing to the democratization of financial markets.

It is important to note that while AMMs offer numerous advantages, they also come with certain limitations. One notable challenge is the potential for impermanent loss, which occurs when the value of tokens in the liquidity pool fluctuates compared to holding them in a standalone wallet. Liquidity providers must carefully assess the risks and rewards before committing their assets to AMM pools.

Types of AMMs

There are various types of AMMs that have gained popularity within the DeFi ecosystem. Some notable ones include:

1. Constant Product Market Maker:

The primary concept underlying Constant Product AMMs is that the product of token quantities in a liquidity pool remains constant throughout all trades. This product also referred to as the “constant product” or “invariant,” undergoes proportional adjustments in token prices within the pool as the supply and demand of tokens change.

Uniswap, the prominent Constant Product AMM operating on the Ethereum blockchain, exemplifies this concept. Uniswap’s liquidity pools consist of two tokens, and their pricing is determined by the ratio of these tokens in the pool.

source: constant function market makers

x * y = k

where:

  • x represents the quantity of Token A
  • y represents the quantity of Token B
  • k represents the constant product (invariant)

For example, let’s consider a CPMM liquidity pool with Token X and Token Y, and the constant product value (k) is 1000. If initially, Token X has a quantity of 20 and Token Y has a quantity of 50, the product of their quantities is 1000.

If a user wants to buy 5 units of Token X, the formula would require adjusting the quantities to maintain the constant product. After the trade, the new quantities might be Token X = 25 and Token Y = 40, resulting in a product of 1000.

Whenever a trade is executed on a Constant Product AMM, the constant product remains the same, while the token quantities in the pool adjust accordingly. This ensures a balanced on-chain economy and facilitates the determination of token prices based on available liquidity.

2. Constant Sum Market Maker:

Constant Sum Market Makers (CSMMs) represent a distinct type of Automated Market Maker (AMM) that deviates from the commonly known Constant Product AMMs like Uniswap. While Constant Product AMMs maintain a fixed product of token quantities, Constant Sum AMMs focus on preserving a constant sum of token values within a liquidity pool.

The fundamental principle underpinning Constant Sum AMMs revolves around sustaining a stable value for the tokens in the pool, offering an alternative approach to price determination and trading. The concept aims to establish markets where the total value of two or more assets remains constant, enabling traders to speculate on the relative worth of different tokens within the pool.

source: constant function market makers

x + y = k

where:

  • x represents the quantity of Token X
  • y represents the quantity of Token Y
  • k represents the constant sum value

For example, let’s assume we have a CSMM liquidity pool with Token X and Token Y, and the constant sum value (k) is 100. If initially, Token X has a quantity of 40 and Token Y has a quantity of 60, the sum of their values is 100.

If a user wants to buy 10 units of Token X, the formula would require adjusting the quantities to maintain the constant sum. After the trade, the new quantities might be Token X = 50 and Token Y = 50, still resulting in a constant sum value of 100.

Constant Sum AMMs expand the scope of possibilities within the AMM ecosystem by introducing diverse trading dynamics and strategies. They offer traders fresh avenues to speculate on the relative values of assets and contribute to the ongoing innovation and diversification of the decentralized trading landscape.

3. Weighted Average Price Market Maker:

Weighted Average Price (WAP) Automated Market Makers (AMMs) is a variant of AMMs that introduce a weighted mechanism to determine token prices within liquidity pools. Unlike Constant Product AMMs, which maintain a constant product of token quantities, Weighted Average Price AMMs allow for more control over token pricing by assigning weights to different tokens in the pool.

Each token in the liquidity pool is assigned a weight, representing its relative importance or value within the pool. These weights can be determined based on factors such as token liquidity, market capitalization, or user-defined parameters. The sum of all weights in the pool is typically equal to 1 or 100%.

The formula used for calculating the weighted average price is as follows:

Price = (Price_A * Weight_A + Price_B * Weight_B + … + Price_N * Weight_N) / Total_Weight

Where:

  • Price_A, Price_B, …, Price_N represent the prices of tokens A, B, …, N
  • Weight_A, Weight_B, …, Weight_N represent the weights assigned to tokens A, B, …, N
  • Total_Weight represents the sum of all weights in the liquidity pool

By assigning different weights to tokens, Weighted Average Price AMMs enable the creation of customized pools that reflect specific market dynamics or user preferences. For example, a Weighted Average Price AMM could be designed to give more weight to a stablecoin to maintain price stability or prioritize tokens with higher liquidity for better market efficiency.

An example of Weighted Average Price AMMs is Balancer which allows users to create liquidity pools with multiple tokens and customize their weights according to specific strategies. PowerSwap, on the other hand, implements a dynamic weight adjustment mechanism based on trading activity to optimize token prices.

Weighted Average Price AMMs offer greater flexibility and control over token pricing compared to Constant Product AMMs. They provide opportunities for more sophisticated trading strategies and can cater to specific market needs, making them valuable addition to the AMM ecosystem.

4. Constant Mean Market Maker:

Constant Mean Market Makers (CMMMs) represent a distinct type of Automated Market Maker (AMM) designed to uphold a steady average price for tokens within liquidity pools. In contrast to other AMM models like Constant Product or Weighted Average Price AMMs, CMMMs prioritize maintaining stability around a target mean value.

The fundamental principle behind Constant Mean Market Makers involves dynamically adjusting token prices in response to changes in supply and demand, with the goal of preserving a constant average price. As buying pressure increases, the token price rises, while selling pressure leads to a decrease, gradually converging toward the desired mean price.

source: balancer and constant function market makers

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.

To achieve this constant mean price, CMMMs rely on various mathematical formulas or algorithms. For instance, Bancor’s Automated Pricing Mechanism (APM) offers one such algorithm. It proportionally adjusts the token price based on alterations in its supply: as the supply increases, the price per token decreases, and vice versa.

One notable advantage of Constant Mean Market Makers lies in their ability to provide price stability and mitigate the volatility often associated with cryptocurrencies. This stability proves particularly valuable for stablecoins or tokens aiming to maintain a consistent value relative to a specific asset or benchmark.

However, maintaining adequate liquidity in the liquidity pools while upholding the constant mean price remains a significant challenge for CMMMs. Liquidity providers play a vital role in supplying assets to the pool and earning fees based on their contributions.

It is essential to recognize that while CMMMs offer price stability, they might not always provide the same depth of liquidity as other AMM models. Traders should carefully consider the trade-offs between stability and liquidity when engaging with CMMMs.

5. Constant Function Market Maker:

Constant Function Market Makers (CFMMs) represent a class of Automated Market Makers (AMMs) designed specifically for decentralized exchanges dealing with digital assets. They rely 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, CFMMs enable trading against a pool of assets rather than a specific counterparty.

The term “constant function” refers to the condition that any trade must alter the reserves in a way that the product of those reserves remains unchanged, equal to a constant. This property ensures a consistent ratio between the quantities of tokens in the pool regardless of the pool’s total value or liquidity.

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.

One prominent example of CFMMs is Uniswap v3, which allows liquidity providers to define price ranges or “ticks” for each provided liquidity position. The price within these ranges follows a constant function or curve, and as the token price moves within the defined range, the liquidity provider’s position adjusts to maintain the constant function.

CFMMs offer several advantages, including better price granularity, more precise control over price ranges, and potentially reduced slippage for traders. However, they may require more active management from liquidity providers compared to other AMM models, as they need to monitor and adjust their positions as prices move within the defined ranges.

Challenges of AMMs in DeFi

Automated Market Makers (AMMs) have gained significant popularity within the decentralized finance (DeFi) space for their ability to provide liquidity and enable seamless token swaps. However, like any technological innovation, AMMs come with their own set of challenges and limitations. In this article, we will delve into the key challenges faced by AMMs in the realm of DeFi and discuss their potential impact on the market.

1. Impermanent Loss:

One of the primary challenges of AMMs is the concept of impermanent loss. Impermanent loss occurs when the value of assets held in an AMM liquidity pool fluctuates compared to simply holding those assets in a standalone wallet. This can happen when there is a significant divergence in the prices of the tokens in the pool. Liquidity providers may experience losses due to the imbalance between their initial deposits and the value of their assets at the time of withdrawal.

2. Limited Asset Coverage:

AMMs typically operate within a specific ecosystem, such as the Ethereum network, and are limited to the tokens that are supported within that ecosystem. As a result, there may be a lack of asset coverage, meaning that not all tokens or cryptocurrencies are available for trading on AMMs. This can hinder the overall liquidity and accessibility of certain assets, especially those that exist outside of popular blockchain networks.

3. Slippage:

Slippage refers to the difference between the expected price of an asset and the executed price of the trade. In AMMs, slippage can occur when there is insufficient liquidity in the pool to accommodate a large trade. As a result, the price of the asset may be impacted, leading to potential losses or suboptimal trading outcomes for users. Managing slippage is a critical challenge for AMMs to ensure efficient trading and minimize adverse effects on users.

4. Front-Running:

Front-running is a practice where traders exploit their knowledge of pending transactions to execute trades that benefit from the price movements caused by those transactions. In the context of AMMs, front-running can occur when an opportunistic trader observes pending transactions on the blockchain and quickly executes similar trades to take advantage of the anticipated price movement. This unethical practice can negatively impact the fairness and integrity of AMMs.

5. Scalability:

Scalability is an ongoing challenge for the entire blockchain ecosystem, and AMMs are not immune to this issue. As the number of users and transactions on a particular AMM platform increases, it can strain the underlying blockchain network, leading to congestion and higher transaction fees. Ensuring high transaction throughput and low latency is crucial for the long-term viability and usability of AMMs.

6. Regulatory Compliance:

The decentralized nature of AMMs presents challenges in terms of regulatory compliance. As regulatory frameworks around the world evolve, there is a need for AMMs to navigate and adhere to these regulations, such as KYC (Know Your Customer) and AML (Anti-Money Laundering) requirements. Balancing the principles of decentralization with regulatory compliance poses a complex challenge for AMMs and the broader DeFi ecosystem.

Curated Resources

  1. https://www.coindesk.com/learn/what-is-an-automated-market-maker/
  2. https://chain.link/education-hub/what-is-an-automated-market-maker-amm
  3. https://medium.com/dragonfly-research/what-explains-the-rise-of-amms-7d008af1c399
  4. https://coinsbench.com/amm-constant-product-and-il-469ca606e9c7
  5. https://blog.bancor.network/beginners-guide-to-getting-rekt-by-impermanent-loss-7c9510cb2f22
  6. https://susu0108.medium.com/all-you-need-to-know-about-the-automated-market-maker-protocols-amm-5be4b14b677a
  7. https://xord.com/research/curve-stableswap-a-comprehensive-mathematical-guide/
  8. https://medium.com/bollinger-investment-group/constant-function-market-makers-defis-zero-to-one-innovation-968f77022159
  9. https://www.youtube.com/watch?v=1PbZMudPP5E
  10. https://www.paradigm.xyz/2021/07/twamm

Hope this was of some help. 😊

Drop your fav DeFi and AMM resources in the comments section.

Don’t forget to connect with me on Twitter, Medium, and Github to stay updated and visit my Website to learn more about me.

--

--