logo

aarnâ

crypto & DeFi

get app
logo
homeresources vanguard
launch dApp
home
resources
blogs
media coverage
newsletters
faqs
vanguard

17 January 2025

1 min read
The Math Behind AMMs: Understanding Liquidity Pools and Impermanent Loss

the math behind amms: understanding liquidity pools and impermanent loss

imagine earning fees on every crypto trade without needing sophisticated software or a large bankroll. this is possible with automated market makers (amms), which are a key part of decentralized exchanges (dexs). amms allow anyone to become a liquidity provider (lp), earning fees as traders swap tokens. however, there’s a catch — impermanent loss (il). this blog dives into the math behind amms, liquidity pools, and il, helping you understand the risks, strategies, and smart moves every lp should know.

what are automated market makers?

amms power token swaps on dexs without traditional order books. instead of matching buyers and sellers, amms use liquidity pools — reserves of two tokens controlled by smart contracts. lps contribute tokens to these pools, and prices are set by the x * y = k formula, where x and y are token quantities, and k is a constant.

as traders buy tokens, the pool rebalances — if someone buys ETH in an eth/usdc pool, ETH supply shrinks while USDC increases, driving up eth’s price. this system ensures continuous liquidity and allows anyone to earn fees as an lp, transforming market-making from an exclusive role into an open, decentralized opportunity.

however, to fully grasp the role of amms, it’s crucial to understand how dexs differ from cexs as it explains why decentralized liquidity and pricing are essential for permissionless trading.

dexs vs cexs: key differences

the table below highlights the key differences that are most relevant to the role of amms:

cex-vs-dex.png

now that we’ve understood the key differences between dexs and cexs, let’s explore liquidity pools — the engine that drives amms and enables seamless, decentralized trading.

understanding liquidity pools

in its simplest definition, liquidity pools enable token swaps on dexs without relying on order books. these pools consist of two tokens locked in a smart contract, typically at a specific ratio (e.g., 50:50 for an eth/usdc pool).

here’s how it works:

  • role of lps: lps deposit tokens into the pool, enabling token swaps and earning a share of the trading fees.
  • role of traders: traders swap tokens directly with the pool, with prices adjusting automatically according to the x * y = k formula. while liquidity pools offer lps a way to earn passive income, they also expose them to impermanent loss — a potential reduction in the value of their deposits.

what is impermanent loss?

impermanent loss is a risk faced by lps in amms when the value of the tokens they’ve deposited in a liquidity pool changes relative to simply holding them. this loss is considered “impermanent” because it can reverse if token prices return to their original values. the loss occurs because the x * y = k formula forces the pool to rebalance token quantities when prices shift. as the price of one token rises, lps hold less of it and more of the other, resulting in a difference in value compared to holding the tokens outright. think of it like running a fruit stand: you start with 10 apples and 10 oranges, both priced at $1. if apple prices double, you’re forced to trade some apples for oranges to maintain balance. by the end of the day, you have fewer apples than you started with — that’s impermanent loss.

the maths of impermanent loss

the formula to calculate impermanent loss is: il (k) = (2√k) / (1 + k) - 1

where k is the price ratio of the new price to the original price (p_new / p_old). this formula shows that il increases disproportionately as price differences grow. for example, if an lp deposits 1 ETH ($1000) and 1000 USDC ($2000) into a pool, and the price of ETH rises from $1000 to $1500, the pool rebalances. the price ratio k would be 1500 / 1000 = 1.5. applying the formula:

il = (2√1.5) / (1 + 1.5) - 1 = -0.0202 (or 2.02%)

this means the lp experiences a 2.02% loss relative to the price change. however, this loss is impermanent because it only becomes permanent if the lp withdraws the funds while prices are still diverged. if the price returns to the original value, the loss disappears.

how amms mitigate impermanent loss

while impermanent loss is a key risk for liquidity providers, amms employ various strategies to mitigate its impact such as:

  • lp fees: lps earn a percentage fee (typically 0.3%) on every trade, and in high-volume pools, these fees can outpace il.
  • stablecoin pairs: providing liquidity in stablecoin pairs (like usdc/dai) reduces il as stablecoins experience minimal price fluctuations.
  • diversification: spreading liquidity across multiple pools reduces risk from price volatility in any single pair.
  • concentrated liquidity: models like uniswap v3 let lps target specific price ranges, maximizing fees and reducing il.

common misconceptions about impermanent loss

impermanent loss is one of the most misunderstood concepts in defi. here are four key misconceptions that often confuse liquidity providers:

  • “impermanent loss is only temporary.” il becomes permanent if prices stay diverged when lps withdraw funds.
  • “lps always lose money.” lps earn fees that often outweigh il, especially in high-volume pools.
  • “all liquidity pools have the same risk.” stablecoin pairs (e.g., usdc/dai) have low il, while volatile pairs (e.g., eth/usdc) carry higher risk.
  • “lps have no control.” with protocols like uniswap v3, lps can target specific price ranges, reducing risk and boosting returns.

should you be a liquidity provider?

becoming an lp in defi offers passive income through transaction fees, especially in high-volume pools. however, lps face the risk of impermanent loss, which can reduce the value of their holdings when token prices fluctuate. the key question is whether fees outweigh the potential il.

  • who should consider it? lping is ideal for those who can actively monitor market conditions and use tools like apy calculators and il simulators. focusing on stablecoin pairs (like usdc/usdt) minimizes il risk, while diversification across pools helps spread risk.
  • when is it worth it? liquidity provision is most profitable in high-volume pools and stablecoin pairs, which offer low il. for volatile pairs like eth/usdc, tracking il with simulators is essential.

in essence, the decision to become an lp depends on your risk tolerance, market knowledge, and ability to leverage the right tools. aarnâ’s defi matrix makes this easier by scanning high-yield lp opportunities across platforms like uniswap, curve, and others. our proprietary algorithm identifies the best lp positions for maximized yield, leveraging ai-driven strategies to boost profits while managing impermanent loss and market volatility. with aarnâ, navigating defi liquidity provision becomes more seamless and profitable.

the bottom line

as an lp in defi, earning fees is an attractive opportunity, but understanding and managing the risks, particularly impermanent loss, is crucial. by strategically choosing liquidity pools and leveraging tools like il calculators and diversification, lps can minimize risks and enhance returns. to succeed, it’s important to stay informed about the dynamics of different pools and apply strategies such as stablecoin pairs or concentrated liquidity. actively managing your liquidity provision can turn potential risks into rewarding opportunities in defi.

about aarnâ

aarnâ is an advanced DeFi asset management platform, designed at the intersection of AI and DeFi, to help users manage their digital assets lifecycle.

recent posts