AMMs, what are they and how do they work?

By: Raye Hadi

Table of Contents

  1. Introduction

  2. Background

  3. Liquidity Pools

  4. Example- Maintaining the Ratio

  5. Impermanent Loss

  6. Slippage

  7. Conclusion

  8. Sources


AMMs are short for “Automated Market Makers” and are critical components to the structure of a decentralized financial system. AMMs are what enable seamless one-way trading for parties, allowing people to buy and sell assets in a decentralized fashion. AMMs are built as “Layer 3” applications on top of smart contract platforms such as Ethereum, Cosmos, or Solana. By leveraging the settlement layer of their respective “Layer 1” chain, AMMs allow for autonomous execution of trades automatically posted to and verified by the underlying blockchain. The deterministic nature of Layer 1 networks like Ethereum empower AMMs like Uniswap, Balancer, Curve, and 1inch to operate effectively. AMMs give way to a paradigm shift towards financial transactions not previously possible. In this article, we are going to cover what AMMs are; how they work; and some important concepts surrounding their internal mechanisms.


Like all markets, for every buyer there must be a seller. However, systems become inefficient if every buyer must be matched with an identical seller for every transaction. To mitigate this inefficiency, centralized systems developed what we know as “Market Makers”. These are entities that are always willing to buy or sell a particular asset at market price. These entities typically possess large amounts of liquidity to accommodate these trades and take a fee for all traders exchanging through their service. (see Image 1)

Image 1: Order Book Model
Image 1: Order Book Model

Initially, to try to replicate this system, decentralized applications explored order book models. These models relied on multiple market makers to provide liquidity by matching buy orders and sell orders across platforms. This was not only slow and inefficient, but extremely expensive as every time a transaction passed through a smart contract, a gas fee was incurred. And in this model, transactions were often routed through multiple smart contracts at a time in search of a match. This issue was eventually solved with the implementation of something called liquidity pools.

Liquidity Pools

What are liquidity pools and why are they important? Liquidity pools are the novel idea behind AMMs. Liquidity pools are essentially smart contracts existing on the blockchain. These smart contracts hold 2 types of tokens that are balanced against each other at an equal value to create a market for that particular pair of tokens. Buyers and sellers can then interact with the AMM’s interface to access these smart contracts and “trade” with this pool. This “trading” consists of a trader either depositing token X into the pool to retrieve an equal value of token Y, or vice versa (see Image 2).

Image 2: Liquidity Pool Diagram
Image 2: Liquidity Pool Diagram

These pools maintain the amount of liquidity sufficient to support this trading through transaction fee-based yield incentives. As a decentralized system, there is no one entity supplying the quantity of tokens (liquidity) required to maintain an efficient trading experience. By leveraging the global market, liquidity pools use yield derived from the pool’s transaction fees to incentivize investors to supply liquidity. This yield is defined as a percentage of the transaction fees that the pool generates relative to the quantity of token suppliers (investors). For example, if there is a frequently traded token pair, logically, that pair’s pool will have deep liquidity (many tokens supplied to it) as there is an abundance of transaction fees generated by that pool. This creates an incentive for investors to supply tokens to try and capture a percentage of that high transaction fee volume. The percentage they receive is relative to the quantity of other token suppliers in the pool. So even though the pool may be generating significant fee volumes, dividing up those fees among a large group will diminish the returns to each investor. Conversely, if there is a less popular liquidity pool, one with a low frequency of trading volume, then investors may be incentivized to supply liquidity on the notion that they can obtain a larger share of the lower volume of transaction fees. In some cases, this can be more profitable than supplying liquidity to a more popular pool.

Investors who supply tokens to these pools are known as LPs (Liquidity Providers). Investing in these pools to capitalize on the transaction fees or yield can be classified as a practice that falls under the term “yield farming”. Through yield farming incentives, LPs are encouraged to supply tokens to these pools. When you consider the scale of investors looking for yield globally, understandably many of these pools possess sufficient depth in liquidity to support a decentralized market. Tokens are supplied to these pools at a ratio that replicates the current market price of the tokens in the pool. This is done by using a concept known as an “equal value ratio”. For any arbitrary liquidity pool, LPs are incentivized to provide liquidity such that the value of token X is equal to that of token Y. To understand why, we must acknowledge what LPs receive when supplying liquidity. From supplying tokens to a pool, LPs receive “LP tokens”. These tokens represent their share of assets in the pool and can be burned when the investor wants to “cash out” and retrieve the initial tokens and accumulated yield.

Example- Maintaining the ratio

For example, let’s use a liquidity pool that has an ETH/DAI ratio of 50/50. In the market, 1 ETH is worth $500 and 1 DAI is worth $1 (stablecoins will always be ~$1) and the ETH/DAI pool has liquidity depth of $2000 (2ETH and 1000DAI). If a trader supplies 1 ETH and 500 DAI to the pool, the pool now has a depth of $3000 (3ETH and 1500DAI). This is good, the value of the pool is split 50/50 between ETH and DAI. The ratio of DAI/ETH is 1500/3 which equals the market price of $500 per ETH. The price a trader pays each asset when interacting with the pool is the same as the market price for both assets.

Now, let’s say we have the same pool, and 1 ETH is still worth $500, and the ETH/DAI pool has liquidity depth of $2000 (2ETH and 1000DAI). If a trader supplies 0.5 ETH and 750 DAI, the pool has a depth of $3000 (2.5ETH and 1750DAI). This may seem fine, but it will cause huge problems that compromise the integrity of this pool. The value of the pool is now split: 58% DAI and 42% ETH when based on the market price of both tokens, the equal value ratio should result in a distribution 50/50. The ratio of DAI/ETH is now 1750/2.5 which reflects a $700 price of ETH. We know the market price is $500. So now there is an arbitrage opportunity. Arbitrageurs will notice this price discrepancy and deposit ETH into the pool and retrieve DAI. This is profitable as one can purchase 0.5 ETH on the market for $250, deposit it into the pool, and receive 350 DAI (due to the price discrepancy). They can sell this DAI on the market and pocket a profit of $100. After this arbitrage, the pool is now distributed 1400DAI and 3ETH with a market value of $2900 and a DAI/ETH ratio of 1400/3 or $467 per ETH. There is now another arbitrage opportunity as an arbitrageur can deposit DAI into the pool to extract more ETH than usual market value would permit. Thus, this creates a disaster of arbitrage opportunities that destroy the balance of this pool. In addition, as an LP, your LP tokens that allow you to redeem your share in this pool were initially worth 42% ETH and 58% DAI of a $3000 pool. They are now worth that same percentage but of a $2900 pool. Essentially destroying ~4% of your token value, which is not a great investment.

The example above is why pools require all LPs to provide an equal value allocation of both tokens relative to the specified ratio.(see Image 3)

Image 3: Equal Value Ratio in a Liquidity Pool
Image 3: Equal Value Ratio in a Liquidity Pool

For all AMMs, this ratio fluctuates to maintain an equal value distribution of tokens and mirror the constantly changing market price. As market price changes, the ratio of quantities between a token pair will change to keep the total value of both token products (price x quantity) in the pool equal. Looking back at image 3, if the market price of TK fluctuated to 300 TK per 1 ETH. The equal value ratio for quantities of both tokens would change as arbitrageurs will take advantage of the cheap 250 TK/ETH (lower than market value) from this pool. They will deposit TK into the pool and extract ETH, selling the ETH on the market until this strategy is not profitable anymore. This will naturally rebalance the pool. The new equal value ratio in this market after these arbitrages have occurred would leave the pool balanced (50 * 300 = 15k) 50 ETH and (0.8 * 18750 = 15k) 18750 TK. The pool has leveraged market forces to automatically rebalance itself to represent the 20% increase in the value of ETH relative to TK and the 20% decrease in the value of TK relative to ETH, yielding accurate market prices.

Most AMMs model their mechanisms after the equal value ratio and set the initial ratio of their pools at 50%. However, some AMMs, like Balancer, use alternative models with unique algorithms that allow for asymmetrically weighted pools such as an 80/20 ETH/DAI pool. The benefit of this type of pool is that it reduces something called “impermanent loss”.

Impermanent Loss

Impermanent loss is an important concept when it comes to understanding the process of supplying liquidity to AMMs. Impermanent loss can be thought of as the temporary loss of funds incurred when supplying liquidity. This can be thought of as the tradeoff between holding an asset compared to providing liquidity to a pool of that asset. When acting as an LP, one token may be more volatile than the other. This leads to price changes that decrease the quantity of one token in the pool and increase the quantity of the other to maintain the equal value ratio. This brings us to another arbitrage situation. Let's assume we have a token pair X/Y that makes up a pool, where X is a volatile token and Y is a stablecoin. If token X increases in market value, then arbitrageurs will purchase token X at the lower price offered by the X/Y pool by depositing token Y into the pool. They will then sell token X at the higher market price and pocket the difference. The ratio of X/Y in the pool has now decreased as a quantity of token X was removed from the pool and a quantity of token Y was supplied. Internally, token X is now more scarce and token Y is now less scarce. The price of each token in the pool now changes to reflect this. This process is repeated until the price of each token in the pool reflects the new market price.

As an LP, your LP tokens are worth a set percentage of the pool relative to what share of the total liquidity you are supplying. However, the ratio of tokens in the pool fluctuates to accommodate changes in market price. While your share of the pool stays the same, the ratio of tokens that make up that percentage changes. For example, if you supplied 10% of the liquidity in the X/Y pool, initially your position was 50% token X and 50% token Y. But because token X increased in market value, the ratio of X/Y in the pool has now decreased to maintain equal value between tokens. Withdrawing your 10% position right now means you exit with less of token X and more of token Y then you initially started with. However, because token X increased in market value, and you now have more of token Y, you may have still made money, while earning yield the entire time. What’s the issue then? While you may still have made money, unless yield was significant, you would have been better off just holding token X and token Y without supplying them as liquidity. Let’s take the example below (see Image 4):

Image 4: Impermanent Loss Visual
Image 4: Impermanent Loss Visual

In this example, by supplying liquidity your position increases by ~$976 after an increase of $50 in the price of ETH. However, you would have made $1000 by not supplying liquidity and just holding your tokens outright. You now own 0.93 less ETH and suffered an impermanent loss of $23.41.

This is a common issue LPs face, but there is always the possibility to recoup the value you may have missed from impermanent loss. The loss is only realized if you withdraw your funds, and over time there is the chance that market prices change, and LPs retain their initial quantity of funds. Impermanent loss may make becoming an LP seem unattractive, but there are many ways to mitigate this. The first is to supply liquidity so that the impermanent loss is smaller than the value of collected fees (yield). Another is if the AMM sets aside a portion of their token supply for “Liquidity Mining”, meaning they will compensate LPs with a token reward for providing liquidity to certain pools. Additionally, AMMs like Balancer, Curve, and Bancor have built in mechanisms oriented solely towards the minimization of impermanent loss.


The last concept important to understanding AMMs is slippage. Slippage is essentially the price impact on tokens relative to the size of a trade taking place in the liquidity pool. Slippage is generally negative, as a lot of slippage creates a worse trading experience for users. For example, let’s consider two token pools: X/Y pool and X/Z pool. Let’s say the market price for token X is $100, the market price for token Y and token Z is $10, and the X/Y pool has liquidity depth of $10,000 and the X/Z pool has a liquidity depth of $100,000. Let’s also assume both pools are distributed 50/50 between the tokens. If a trader were to buy 10 of token X for 100 of token Y (deposit 100 Y and remove 10 X) from pool X/Y, the ratio of X to Y would go from 50/500 to 40/600. In this pool token X is now worth $125 and token Y is now worth ~$8.3. Here, a lot of slippage has occurred as a result of this trade. Now, if we do the same trade in the X/Z pool, the ratio will go from 500/5000 to 490/5100. In this pool, token X is now worth ~$102 after the trade and token Y is worth ~$9.8. Here much less slippage has occurred as neither price has diverged much from the market price. It is evident that deeper liquidity decreases slippage and is beneficial to the trading experience on an AMM. High slippage allows whales (entities trading in large volumes) to move the market and manipulate price signals. This is a net negative as smaller traders do not want to participate in a playing field that is heavily skewed against them. Additionally high slippage environments attract arbitrageurs and MEV* bots that profit on the chaos caused by large price divergences and destroy the value of everyday traders.


AMMs are a staple of decentralized financial systems and are integral to the success of smart contact platforms such as Ethereum, Solana, and Avalanche. For a functional financial system to exist, the ability to efficiently trade assets without the need for an identical receiver is paramount. AMMs enable this, and most importantly in a decentralized way. AMMs are commonly known as DEXs (decentralized exchanges) and are most recognized in dApps such as Uniswap. Through leveraging the global market, AMMs are able to support decentralized trading on the back of yield farming based incentives. These yield farming incentives encourage LPs (investors) to supply liquidity, which is the backbone of what makes these systems efficient and user friendly. Most pools use an equal value ratio, which allows them to adapt and reevaluate their assets to meet market price valuations. However, being an LP comes with the drawbacks of impermanent loss and in pools of low liquidity depth, significant slippage. AMMs are one of the most unique ideas that have evolved out of blockchain, and they enable behaviors and trading activities not previously possible. For decentralized finance to rival traditional finance, user experience and services of decentralized systems must be comparable if not superior to their centralized counterparts. AMMs are an essential component of working towards this ambition and play a critical role in the new paradigm that decentralized finance brings about.


Subscribe to Blockchain at the University of Virginia
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
This entry has been permanently stored onchain and signed by its creator.