Definition: AMMs, or automated market makers, provide liquidity to decentralized crypto exchanges through smart contracts and liquidity pools.
Written by: Siyu Ren Heinrich | Updated June, 2024
Reviewed by: Mike Martin
Fact checked by: Ryan Grace
Automated market makers (AMMs) have emerged as a popular alternative to traditional order book-based exchanges for cryptocurrency trading. In this article, we will give you an overview of how AMMs work, explore the various types of AMMs, and highlight their respective pros and cons.
🍒 tasty takeaways
Automated market makers provide an essential function to DeFi as they provide liquidity for market participants.
Individual AMMs use different models to determine the prices of traded assets. DeFi protocols can implement specific models or a mixture of different AMM models.
AMMs offer several advantages over centralized solutions. However, some risks remain, such as impermanent loss.
Decentralized finance (DeFi) represents one of the most important use cases in the blockchain/cryptocurrency space. In June of 2024, the total value locked (TVL) in DeFi Applications is about 95 billion USD according to DeFiLlama. DeFi is mostly associated with the Ethereum (ether) network as the Bitcoin (bitcoin) ecosystem does not support the functionality of smart contracts.
Decentralized exchanges (DEXs) represent one of the main use cases within DeFi. These protocols allow crypto participants to freely swap a wide variety of cryptocurrency tokens. DEXs provide this liquidity through ‘liquidity pools’ and AMMs.
Let’s now learn how AMMs work!
AMMs Summary
Description | |
---|---|
Automated Market Makers (AMMs) | AMMs provide liquidity to decentralized crypto exchanges using algorithms to automate price discovery, reducing the need for traditional order books. |
Liquidity Pools | A liquidity pool is a collection of funds locked in a smart contract. It's used to facilitate trading by providing liquidity and is used by AMMs to determine prices. |
Yield Farming | Yield farming, also known as liquidity mining, involves lending out cryptocurrencies in return for interest and additional tokens. It's a popular method to earn passive income in the DeFi space. |
Decentralized Exchanges (DEX) | Unlike traditional exchanges, DEXs are platforms that allow peer-to-peer trading of cryptocurrencies without a central authority or middleman. |
What is a Market Maker?
A traditional market maker is an individual or an institution that provides liquidity to a market by placing both buy and sell orders on a trading platform using an order book. Market makers profit from the difference between ask-bid prices. This market-making allows other market participants to freely buy and sell securities/digital assets at fair prices.
In the crypto space, the largest market makers are traditional exchanges (CEXs).
📚 Read! CEX vs DEX What’s the Difference?
What are Automated Market Makers?
Automated market makers (AMM) are smart contracts that power all decentralized crypto exchanges (DEXs) as well as other decentralized finance (DeFi) protocols.
AMMs set the prices of digital assets and provide liquidity in the form of liquidity pools.
AMMs have several benefits:
AMMs provide liquidity for traders, even in low-volume markets. This means that users do not need to wait for other traders to buy or sell assets, as is the case with order book-based centralized crypto exchanges.
AMMs operate on permissionless and trustless decentralized blockchain networks, meaning that they do not rely on traditional centralized exchanges such as Coinbase or Binance to operate.
AMMs often offer fees for traders. However, traders still need to pay on-chain transaction fees (gas fees) when moving their crypto assets around.
What are Liquidity Pools and Liquidity Providers?
A liquidity pool (LP) is a collection of funds held within a smart contract, which relies upon algorithms. Liquidity providers (LPs) are users who deposit tokens in DeFi smart contracts so that their crypto assets can be used for trading, borrowing, or lending by other users.
Each liquidity pool is a distinct market for a particular token pairing. By contributing funds, liquidity providers earn a share of trading fees generated by transactions within the pool proportionate to the total liquidity they provide.
Some DeFi protocols reward LPs with other rewards such as tokens. The process of earning rewards by providing liquidity is also called liquidity mining or yield farming.
Impermanent loss
Impermanent loss is a major concern to any liquidity provider.
Impermanent loss occurs when the prices of two assets in a liquidity pool change, causing the value of one asset to increase while the other decreases. This happens as traders buy one token in the pool while selling the other.
This loss is referred to as impermanent because the real loss only occurs if the liquidity provider withdraws their funds from the pool at a time when the prices of the assets are not in the same ratio as when they initially deposited them.
Flexible liquidity pools can help to reduce impermanent loss. This is because these pools do not require a 50:50 coin or token ratio to determine the exact price of a supported asset. By applying other ratios, flexible pools can reduce the impact of an eventual depreciation of a given asset.
How Do Different Types Of AMM Protocols Work?
AMMs implemented by most DeFi applications can be divided into two categories: constant function market makers and token swap market makers.
Both categories use non-custodial smart contracts, and a deterministic pricing rule is implemented between two or more pools of tokens. A DeFi App can implement one type of AMM model or a mixture of several AMM models.
Note: In order to become a liquidity provider, you will need a self-custody crypto wallet.
Constant Function Market Maker (CFMM)
In the CFMM model, the liquidity of a pool is equal to a constant by implementing one of three main methods: the product, the sum, or the mean of all trading pairs or groups.
In all different variations of CFMM, liquidity providers provide assets that are pooled in an open smart contract. A trading pair involves two or more complimentary pools of crypto assets or tokens.
When traders place a transaction to swap crypto they submit an amount of asset A which returns a given amount of asset B. This changes the balance between the pools. A smart contract ensures that the total value of the liquidity pool is the same before and after each transaction. Below I explain how the different variations of CFMM work.
Constant Product Market Maker (CPMM)
The prices of token A and token B are determined by the following mathematical formula:
Quantity of token A * Quantity of token B = Constant
The constant product formula can be illustrated by the following graph:
This model ensures that the total amount of liquidity always stays the same before and after each transaction. However, there are a few problems with it:
When token A becomes more expensive, there will be less token A and more token B in the liquidity pool.
When the trade size is large, there will be significant price slippage (the difference in price between your expectation and what you actually get after the swap).
As a result, for this model to work, token A and token B need to be supplied in the correct ratio by liquidity providers, and the amount of liquidity must be sufficient.
The biggest DEX on Ethereum, Uniswap V4, uses this mechanism.
Constant Sum Market Maker (CSMM)
This model is similar to the CPMM, but the multiplication in the formula is replaced with addition. The liquidity always equals the total quantity of token A plus the total quantity of token B.
Quantity of token A + Quantity of token B = Constant
This can be illustrated by the following graph:
In this model, the slope is constant. This means that the prices of A and B remain the same regardless of how the quantities of the assets change. This model is suitable for swapping crypto with very low price volatility or pegged prices such as stablecoins.
The disadvantage of this model is that it does not provide infinite liquidity.
Constant Mean Market Maker (CMMM)
When there are three or more tokens in a pool, it is best to use the constant mean model; the constant is the geometric mean of the product of the quantities of the number of tokens in the pool.
Let’s look at a pool with three tokens as an example:
(Quantity of Token A*Quantity of Token B*Quantity of Token D)1/3=Constant
Balancer implemented this kind of model in its multi-token pools.
Hybrid Function Market Maker (HFMM)
An HFMM is basically a mix of CPMM and CSMM or CMMM. This can emphasize the advantages of each model while minimizing the disadvantages. For example, a combination of CPMM and CSMM ensures infinite liquidity while lowering price slippage risks. The Curve protocol uses such a combination.
Dynamic Automated Market Maker (DAMM)
In a DAMM the weights of the tokens in the pool are adjusted dynamically to:
“...give market participants incentives to equalize the current balance with the staked balance”
— Bancor
This model is implemented together with the token swap model in Bancor V2 protocol.
What is a Token Swap Market maker (TSMM) and how does it work?
In the TSMM or Token Swap model, the swapping between two tokens is done with the help of an intermediary token.
For example, when a person wants to swap token A for token B, the first step is to change token A into the intermediary token T, then swap token T for token B.
Token T acts as a decentralized exchange medium between the reserves of token A and token B.
Conclusion
As our article shows, automatic market makers have established themselves as an essential component in the DeFi community. Various models are used and the coming years will show which protocols are the best.
Although impermanent loss is an inherent risk when it comes to decentralized trading, this risk can be somewhat limited by using flexible pools or through conservative user behavior.
Lastly, faulty smart contracts still represent an unknown risk, but it is to be expected that this risk will also decrease in the coming years as the experience of developers and users increase.
AMM FAQs
AMM protocols are Web3 platforms that facilitate token trading in a decentralized environment without TrafFi market-makers.
Different types of AMM models include constant product, constant sum, and hybrid pools.
In DeFi, AMM refers to algorithms that automatically adjust token prices in liquidity pools. AMMs are carried out through smart contracts.
Yes, Uniswap operates as an AMM platform.
Siyu Ren Heinrich
5 years of experience in crypto research of writing practical blockchain and crypto analysis on Medium.
MSc in Computer Science, BSc in Smart Engineering, and BSc in Economics and Statistics.
Michael has been active in the crypto community since 2017. He holds certifications from Duke University in decentralized finance (DeFi) and blockchain technology.