What Is an Automated Market Maker (AMM)?
In traditional trading markets, such as stock exchanges, market markers help ensure smooth trading by providing trading liquidity no matter where the price goes. Regardless of whether they are individuals or firms, they’re often the source of trading liquidity in exchange order books. The emergence of decentralized exchange (DEX) trading saw the introduction of the automated market maker (AMM).
This clever solution allows traders to make swaps without anyone in the middle of the transaction. Instead, the AMM sets the price for the token, and the transaction is handled with code.
In this guide, we’ll discuss the different types of automated market makers and how they work. We’ll also detail the advantages of using an AMM as well as some of the potential downsides. Let’s learn how to put automated market makers to work in your crypto trading.
In Short: What Is an Automated Market Maker (AMM)?
An automated market maker is a protocol (a set of rules) that governs trading prices on a decentralized exchange. The AMM uses one of several formulas to allow trading from a pool of tokens, called a liquidity pool, as the price moves and does so without any intermediaries.
The most common of these formulas is the constant product formula, first introduced by Uniswap, a leading decentralized exchange available on 12 blockchains. At the heart of the AMM, you’ll find a math formula that sets the price as people buy and sell against the liquidity pool. For example, Uniswap’s constant product formula uses a simple mathematical formula (x*y = k), with X and Y representing the two types of tokens in the pool, while K is the constant value.
Uniswaps’s AMM allows transactions at any price, adjusting the price of each token based on the amount of each token remaining in the liquidity pool.
How Do AMMs Work?
Most AMMs work in a similar way, although some use different formulas to balance the pool as swaps occur. The AMM adjusts the per-token swap price based on the size of the trade relative to the amount of trading inventory in the pool.
In the example below, you can see the total cost to swap ETH for 10,000 AST tokens ($793.08).
However, a much larger order increases the price per token. If we swap ETH for 100,000 tokens, you might expect the cost to be ten times higher than a 10,000 token swap.
That’s not always the case. Instead, you’ll likely pay more for each token. In the following example, shown below, the total swap cost is $8727.70. Ten times the original swap value in the example above is $7930.80, so making a larger swap costs an additional $796.90, or $0.007969 per token.
Most AMMs are designed to provide liquidity at any price. You might not like the price, but you can make the swap if needed. However, some newer innovations, such as Uniwap V3, allow liquidity providers to limit the price range for the tokens they provide to the pool. The price-limited share of the pool remains inactive when the price is outside the set range.
The AMM Formula: How Prices Are Set
We’ll discuss other types of AMM formulas in a later section. To get a basic understanding, we can use the constant product formula used by Uniswap. While Uniswap is the largest DEX by far, all of its versions (V1, V2, V3) also have open-source code. As a result, countless clones use Uniswap’s code, including the constant product formula.
At its core, the constant product formula seeks to maintain a balanced value for the pool. It does this by using the following formula:
- X * Y = K
Here’s how that applies. Let’s look at a pool with two tokens, Token X and Token Y.
- X = Quantity of Asset X
- Y = Quantity Asset Y
- K = Constant (Quantity of Asset X * Quantity Asset Y)
In the background, the constant product AMM uses this formula to determine how much of Token X to provide when buying with Token Y. However, real-world prices, such as the value in the dollar, are an external calculation. The AMM doesn’t consider the dollar value at all. It simply determines the number of tokens for each side of the swap.
If someone sells a large number of Token X into the pool, Token X becomes cheaper relative to Token Y. The same is true on a larger scale in which the market is selling Token X. Token X falls in value relative to Token Y to keep the pool balanced.
Uniswap also uses “ticks,” which you can think of as exchange rate brackets. The exchange rate changes at each tick and may move up or down depending on the swap’s effect on the pool.
The Role of Liquidity Providers
Liquidity providers is a broad term that can refer to crypto lending, institutional liquidity providers for start-up projects, and DEX providers. The latter can be anyone who wants to earn a yield by depositing tokens in a liquidity pool. As an incentive, DEX liquidity pools pay transaction fees, usually about 0.25%, paid by the people using the pool for swaps.
Impermanent Loss and Risks
We’ll discuss impermanent loss again in a later section. However, impermanent loss refers to the difference in the value of your tokens when you deposit to a liquidity pool compared to holding the tokens for the long term.
For example, if you deposit 100 of Token X and 200 of Token Y based on the current exchange rate for the pool, you have a starting value. Over time, traders will buy and sell against the pool, and you’ll have fewer of one token and more of the other compared to the amount you deposited.
As the token values diverge, you’ll experience impermanent loss. Here’s how it works. Due to swaps, you’ll no longer have a 2 to 1 ratio. The remaining tokens will be lower than the value you’d have if you had held 100 of Token X and 200 of Token Y. This difference in value is called impermanent loss. However, trading fees, discussed in the prior section, help offset this loss and may make it much more profitable to provide liquidity compared to holding.
The Main Types of AMMs (With Examples)
Although the constant product formula is still the most common type of AMM, other types exist, each with a different use case or advantage. The diagram below shows how Uniswap allows traders to transact with pools funded by liquidity providers.
In addition to the constant product formula used by Uniswap, other strategies include the constant sum formula, hybrids, and dynamic AMMs that source pricing data from trusted providers.
1) Constant Product AMMs
Constant product automated market makers use a simple formula to balance the pool, which we discussed in previous sections.
- X * Y = K
In the constant product formula, X equals the quantity for Token X, whereas Y equals the quantity of Token Y. If someone swaps Token X for Token Y, the value of Token X falls relative to the value of Token Y, adjusting the exchange rate.
Example: Uniswap
Let’s look at how the constant product formula works on Uniswap. In this example, the pool starts with 100 of Token X and 50 of Token B.
- 100 * 50 = 5,000
The constant product (K) is 5,000 in this example.
Now, let’s say someone wants to buy 20 of Token X from the pool. The constant product must remain the same, so the math looks like this.
- 100 – 20 = 80 (Buy 20 of Token X)
- 5,000 / 80 = 62.5 (Apply the constant product formula)
- 62.5 – 50 = 12.5 (Cost in Token Y)
While the pool started with a 2:1 ratio, the swap requires 12.5 of Token Y to buy 20 of Token X instead of just 10 of Token Y, as the initial ratio would suggest.
There are also fees to consider, which add a bit of complexity to the equation. However, the above offers a simple example.
2) Constant Sum AMMs
The constant sum formula works similarly but uses addition rather than multiplication to create a constant value.
- X + Y = C
In this case, C equals 150 if the pool holds 100 of Token X and 50 of Token Y.
This formula can work with assets of similar value but can be disastrous for assets that diverge in value. In that case, one side of the pool would be drained quickly. A constant product AMM can provide liquidity at any price. However, a constant sum AMM may “sell out” of one token.
Due to its lack of infinite supply, constant sum AMMs aren’t suitable for most decentralized finance (DeFi) applications as a standalone formula.
3) Hybrid AMMs
Hybrid automated market makers combine two formulas. For example, Curve Finance combines the constant product formula and the constant sum formula.
Example: Curve Finance
As a stablecoin DEX, Curve Finance offers swaps for tokens of similar value. Examples include USDC and DAI, both of which are pegged to the value of the UD dollar. The hybrid formula allows Curve to reduce impermanent loss and provide
Curve’s StableSwap AMM algorithm combines X * Y = K and X + Y = C. This strategy allows stable pricing when the pools are balanced but disincentivizes swaps when the pool is unbalanced.
The math becomes much more complex compared to Uniswap’s AMM because Curve’s StableSwap combines the constant product formula and the constant sum formula.
In effect, StableSwap adapts to the supply of the tokens in the pool, combining the two formulas to provide liquidity while also incentivizing balanced pools when one side of the pool becomes heavier.
4) Dynamic AMMs
A dynamic automated market maker uses oracles to provide prices for tokens. Oracles are trusted providers that bring in data from the outside world. Simpler AMM strategies, like the constant product formula, depend on arbitrageurs to keep prices aligned with market prices. If an ETH/USDC pool is pricing ETH below its current USD price, you can be sure a bot or trader will buy ETH from the pool until the AMM adjustment reaches the market price.
Dynamic AMMs reduce the need for arbitrage to keep the pool price in sync with the market price.
Example: DODO
The DODO DeFi project uses a Proactive Market Maker (PMM) algorithm. In a nutshell, the PMM algorithm decreases the amount of tokens available as the price moves further away from the oracle price for the asset.
The example above compares the DODO curve against the Uniswap curve, showing how DODO considers market prices. Because the price adjusts to the oracle price for each asset, Dynamic AMMs provide better protection against impermanent loss.
Advantages of Using AMMs
The primary advantages of AMMs center on their ability to facilitate transactions without a middleman. All you need is a compatible crypto wallet funded with one of the tokens you want to sell into the pool in exchange for the other token. Liquidity providers may need both tokens, but the deposit transaction is still permissionless. You don’t need to work with a broker, and anyone can participate.
Fully Decentralized
The most obvious benefit of AMMs lies in their ability to enable permissionless trades. You don’t need to use a centralized exchange to swap Token A for Token B. Instead, you can swap tokens through a liquidity pool. Anyone with a compatible crypto wallet and tokens to trade can make a swap.
For example, if you want to swap ETH for USDC, a popular stablecoin pegged to the US dollar’s value, you can make the swap without using Coinbase or a similar decentralized exchange. Your cost for the swap is largely limited to gas fees for small trades, although you’ll also need to consider slippage for larger trades or when using smaller liquidity pools. We’ll discuss slippage in just a bit.
24/7 Availability
You can access decentralized exchanges at any time of the day, although this is also true of centralized crypto exchanges. Regardless, if you need to swap Token A for Token B, you can do so without transferring the tokens to a centralized exchange. The entire transaction happens from a self-custody crypto wallet like MetaMask.
Reduced Slippage on Liquid Markets
Liquidity refers to the ability to trade easily and efficiently. In simple terms, it means there’s enough available trading inventory at a price close to the current market price. Slippage refers to changes in the price of a token when you make a trade. As you buy a larger amount of Token A from a liquidity pool and pay with Token B, the price per token increases. This price change is called slippage, and if you take a significant amount of tokens from the pool, slippage can change the price dramatically.
Larger liquidity pools offer ample liquidity for trades with minimal slippage. You can expect a pool holding popular tokens on Uniswap, like ETH/USDC, to offer ample liquidity to make trades with very little slippage.
Earning Opportunities for Liquidity Providers
Where does this trading inventory come from? Liquidity providers play a crucial role. Anyone can provide liquidity for pools by depositing tokens. As people make swaps using the pool, liquidity providers earn trading fees, often about 0.25% of each transaction, although fees vary.
When well managed, providing liquidity can often be more profitable than holding the tokens for future price appreciation. However, risks like impermanent loss make it essential to weigh the pros and cons related to this method of earning crypto passive income.
Downsides of Using AMMs
The behind-the-scenes math used by AMMs brings some downsides, with some relating to liquidity providers and others affecting traders who make swaps.
Impermanent Loss
Impermanent loss (IL) affects liquidity providers rather than those making swaps. In simple terms, IL refers to the difference between the value you would have if you just held the tokens versus the value of the remaining tokens when you deposit to a liquidity pool. Over time, the values of the tokens in the pool diverge, causing an impermanent loss. However, fees for swaps often offset the loss.
Liquidity Pool Slippage Risk
Traders need to understand slippage, however. Slippage in crypto refers to price changes when completing a trade. When trading through a DEX, the price of the token you’re buying increases with the size of the trade. The same is true when selling, although the price decreases as the trade size grows. In the background, the AMM is adjusting prices to keep the pool balanced. Most DEX protocols, like Uniswap, allow you to set a maximum slippage amount for swaps.
Front-Running Attacks
Front-running attacks can affect virtually any blockchain transaction but are often seen with large DEX swaps. AMMs manage the price of tokens based on the balance of tokens in a pool. Buying pressure for Token A will cause the price to rise. Sophisticated bots can front-run these transactions before they execute and then profit on the back end with a “sandwich attack.” Let’s look at an example.
Let’s say someone places a large swap for ETH. This will cause the price of ETH in the pool to rise. An MEV (maximum extractable value) bot can see this transaction before completion. If the bot bids a higher gas fee, it can make a swap for ETH that executes before the trader’s swap.
In this example, the trader will pay a higher price for ETH than expected. After the trader’s swap executes, the MEV bot sells ETH back to the liquidity pool, scalping a profit. When done with enough volume or against large enough transactions, MEV frontrunning can be highly profitable. According to some estimates, MEV bots earned more than $1.38 billion on the Ethereum chain through early 2023.
What Is The Future of AMMs?
Today’s AMM-powered decentralized exchanges work well for specific purposes and battle-tested AMMs like Uniswap’s constant product AMM are expected to play a role long into the future. However, we’re likely to see more development in two key areas: cross-chain swaps and dynamic AMMs.
While DODO’s dynamic AMM launched in 2020, few DEX projects have followed its lead. This type of AMM’s ability to reduce impermanent loss makes it a promising area for development.
Cross-chain swaps allow traders to swap assets on one chain for the same or different assets on another chain. For example, protocols like Jumper.Fi (powered by Li.Fi) let you swap SOL on the Solana blockchain for USDC on the Ethereum blockchain. However, these more complex protocols can also introduce security vulnerabilities. The Li.Fi Bridge suffered an $11 million exploit in July 2024.
As the tech evolves and developers solve security issues, AMMs could power an increasing number of transactions that would typically require traditional finance providers. Instead, tokenized real-world assets (RWA) may begin trading through decentralized exchanges more commonly. Traditional finance giants have already begun tokenizing RWA on blockchains, such as BlackRock’s tokenized money market fund.
Conclusion
Automated market makers remove the need for a middleman to transact. If you have ETH in your Ethereum wallet, you can swap your ETH for any of thousands of tokens using a popular DEX like Uniswap. Several types of AMMs allow for algorithms customized for certain types of swaps, such as Curve’s hybrid AMM for stablecoins or DODO’s dynamic AMM that reduces the risk of impermanent loss. Each has its pros, cons, and limitations, however. Invest some time in understanding how each type of AMM works before connecting your wallet and making a swap.
FAQs
What is an AMM in crypto?
AMM stands for Automated Market Maker. An AMM uses a mathematical formula to calculate the value of tokens in a pool, allowing traders to make token swaps without an intermediary to set the price.
Are AMMs in crypto safe to use?
Battle-tested AMMs like Uniswap’s constant product formula offer a safe way to swap tokens. However, read up on slippage before trading and impermanent loss before providing liquidity to a DEX pool.
Can you make money with AMMs?
Yes. Liquidity providers can earn trading fees when providing tokens to a DEX pool.
What is the main risk of using AMMs?
The primary risks associated with well-established AMMs like Uniswap center on impermanent loss and slippage. Impermanent loss affects liquidity providers when the prices for pool assets diverge. Slippage occurs when buying or selling pressure causes the price of an asset in a liquidity pool to change.
What is the alternative to AMMs?
DODO’s Proactive Market Maker (PMM) algorithm offers an alternative to traditional AMMs because the price of tokens can adjust to follow exchange prices more closely. Another alternative is to buy and sell using a centralized exchange like Coinbase. In this case, you’re trading against an order book of open buy and sell orders or creating your own fixed-price order.
References
- How Uniswap works (uniswap.org)
- StableSwap – efficient mechanism for Stablecoin liquidity (curve.fi)
- DODO Whitepaper (whitepaper.io)
- Solana sandwich bot makes $30M from MEV arbitrage in 2 months (cointelegraph.com)
- Defi Protocol LI.FI Struck by $11M Exploit (coindesk.com)
- BlackRock Launches First Tokenized Fund on Ethereum Blockchain (wsj.com)






