AMM Automated Market Makers: The Complete Trader's Guide
Learn how AMM automated market maker pools work, the constant product formula, impermanent loss, and how to interact with DeFi liquidity pools using Python.
Learn how AMM automated market maker pools work, the constant product formula, impermanent loss, and how to interact with DeFi liquidity pools using Python.
If you've ever swapped tokens on Uniswap without waiting for a buyer to match your order, you've already used an AMM automated market maker — you just may not have known what was happening under the hood. AMMs replaced traditional order books with liquidity pools and a simple mathematical formula, and in doing so, they democratized market making for everyone. Understanding how automated market maker AMM pools work isn't just academic — it directly affects your trading costs, slippage tolerance, and whether you're leaving money on the table every time you swap.
Traditional exchanges like Binance's spot market run on an order book: buyers post bids, sellers post asks, and a matching engine connects them. AMM automated market making throws that out entirely. Instead of matching counterparties, an AMM uses pre-funded liquidity pools — two-sided reserves of tokens — and a pricing algorithm to quote prices and execute trades instantly, 24/7, with no human or bot needing to be on the other side.
When you swap ETH for USDC on Uniswap, you're not buying from another trader. You're trading against a pool that holds both ETH and USDC. The pool's smart contract calculates a price based on the ratio of the two reserves, executes your trade, adjusts the ratio, and updates the price automatically. That's AMM automated market making in its purest form: math, not humans, making the market.
This model has profound consequences. There's no order book to read, no bid-ask spread manipulation, no market maker that can pull liquidity at a critical moment. But there is price impact — the larger your trade relative to the pool, the worse your execution price. This is why professional traders always check pool depth before entering large positions, whether they're on Uniswap, Curve, or Balancer.
Price impact and slippage are not the same thing. Price impact is the change in the pool's quoted price due to your trade size. Slippage is the difference between the price you expected and the price you got — it includes price impact but also accounts for other trades that hit the pool between your submission and confirmation.
Every AMM automated market maker pool is funded by liquidity providers (LPs). When you deposit equal value of two tokens into a pool — say, ETH and USDC — you receive LP tokens representing your share. These LP tokens are your claim on the pool's assets plus accumulated trading fees. On Uniswap V2, LPs earn 0.3% on every swap. On Curve, fees can be much lower (0.04%) because Curve pools are designed for similar-value assets like stablecoins where arbitrageurs provide tighter spreads.
Providing liquidity looks like passive income on paper, but it carries a real risk called impermanent loss. When the price ratio of your deposited tokens changes significantly, the pool rebalances automatically — meaning you end up holding more of the token that went down and less of the one that went up. If you'd simply held the tokens instead of providing liquidity, you would have come out ahead. The loss becomes 'permanent' only when you withdraw.
| ETH Price Change | Impermanent Loss |
|---|---|
| +25% | -0.6% |
| +50% | -2.0% |
| +100% | -5.7% |
| +200% | -13.4% |
| -50% | -5.7% |
This is why many experienced LPs stick to stablecoin pools on Curve or Balancer — assets that don't diverge in price don't generate significant impermanent loss, and the fee income is pure yield. Others accept impermanent loss in high-volume volatile pools because trading fees more than compensate. Platforms like Bybit and OKX have also launched their own on-chain DeFi products offering LP positions, bringing AMM liquidity provision to a wider retail audience.
The core of the automated market maker AMM model is the constant product formula: x × y = k. Here x and y are the quantities of the two tokens in the pool, and k is a constant. Every trade must keep the product of reserves equal to k. This simple rule determines price, slippage, and liquidity depth — everything.
The formula has elegant properties. There's always liquidity at any price (the curve approaches but never reaches zero). Prices adjust continuously based on supply and demand without any external oracle — arbitrageurs keep AMM prices aligned with the wider market like Binance spot by trading whenever a discrepancy appears. Uniswap V2 popularized this model; Uniswap V3 refined it with concentrated liquidity, allowing LPs to allocate capital within specific price ranges for capital efficiency.
def calculate_price_impact(reserve_in, reserve_out, amount_in):
"""
Constant product AMM: x * y = k
Calculates output amount and price impact for a trade.
Assumes 0.3% fee (Uniswap V2 standard).
"""
amount_in_with_fee = amount_in * 997 # 0.3% fee deducted
numerator = amount_in_with_fee * reserve_out
denominator = (reserve_in * 1000) + amount_in_with_fee
amount_out = numerator // denominator
# Spot price before and after the trade
price_before = reserve_out / reserve_in
price_after = (reserve_out - amount_out) / (reserve_in + amount_in)
impact_pct = abs(price_after - price_before) / price_before * 100
return amount_out, impact_pct
# ETH/USDC pool: 1,000 ETH and 2,000,000 USDC reserves
eth_reserve = int(1_000 * 1e18) # in wei
usdc_reserve = int(2_000_000 * 1e6) # in USDC base units
swap_eth = int(1 * 1e18) # swap 1 ETH
usdc_out, impact = calculate_price_impact(eth_reserve, usdc_reserve, swap_eth)
print(f"USDC received : {usdc_out / 1e6:.2f}")
print(f"Price impact : {impact:.4f}%")
# Output:
# USDC received : 1997.00
# Price impact : 0.0999%
Any trader serious about DeFi should know how to read AMM pool state directly from the blockchain. This lets you check real-time reserves, verify prices against centralized exchanges like Binance or OKX, and build your own slippage calculator before committing capital. The web3.py library makes this straightforward on EVM chains.
from web3 import Web3
# Connect to Ethereum mainnet via Alchemy or Infura
w3 = Web3(Web3.HTTPProvider('https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY'))
PAIR_ABI = [
{
"inputs": [],
"name": "getReserves",
"outputs": [
{"name": "reserve0", "type": "uint112"},
{"name": "reserve1", "type": "uint112"},
{"name": "blockTimestampLast", "type": "uint32"}
],
"stateMutability": "view",
"type": "function"
}
]
def get_amm_price(pair_address, decimals0=6, decimals1=18):
"""Fetch current price from a Uniswap V2-style AMM pool."""
pair = w3.eth.contract(
address=Web3.to_checksum_address(pair_address),
abi=PAIR_ABI
)
reserves = pair.functions.getReserves().call()
reserve0 = reserves[0] / (10 ** decimals0)
reserve1 = reserves[1] / (10 ** decimals1)
return reserve0 / reserve1 # token1 price in token0 terms
# Uniswap V2 ETH/USDC pair
price = get_amm_price('0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc')
print(f"ETH price on Uniswap V2: ${price:,.2f} USDC")
With this foundation, you can compare the AMM pool price against VoiceOfChain's real-time signal feed or centralized exchange data from Binance or Coinbase to spot meaningful discrepancies. A 0.5% gap between a Uniswap pool price and Binance spot is often enough for a profitable arbitrage trade after accounting for gas costs — but speed is everything. Block time on Ethereum is ~12 seconds; on chains like Arbitrum or Base it's under 1 second.
Arbitrage between AMM pools is one of the most structured strategies in DeFi. The same token pair — say ETH/USDC — trades across Uniswap, SushiSwap, and dozens of other AMMs simultaneously. Whenever prices diverge, arb bots immediately exploit the gap. Writing your own monitor gives you insight into when these opportunities arise and helps you understand how pool prices stay synchronized with centralized venues like Binance and Gate.io.
import time
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY'))
PAIR_ABI = [{"inputs":[],"name":"getReserves","outputs":[{"name":"reserve0","type":"uint112"},{"name":"reserve1","type":"uint112"},{"name":"blockTimestampLast","type":"uint32"}],"stateMutability":"view","type":"function"}]
def get_pool_price(address, dec0=6, dec1=18):
contract = w3.eth.contract(address=Web3.to_checksum_address(address), abi=PAIR_ABI)
r = contract.functions.getReserves().call()
return (r[0] / 10**dec0) / (r[1] / 10**dec1)
# ETH/USDC pairs on different AMMs
POOLS = {
'Uniswap_V2': '0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc',
'SushiSwap': '0x397FF1542f962076d0BFE58eA045FfA2d347ACa0',
}
ARB_THRESHOLD = 0.3 # % spread to flag as opportunity
def monitor_amm_pools():
prices = {name: get_pool_price(addr) for name, addr in POOLS.items()}
names = list(prices.keys())
spread = abs(prices[names[0]] - prices[names[1]]) / prices[names[1]] * 100
print(f"[{time.strftime('%H:%M:%S')}] " + " | ".join(f"{k}: ${v:,.2f}" for k, v in prices.items()))
if spread > ARB_THRESHOLD:
buy_on = min(prices, key=prices.get)
sell_on = max(prices, key=prices.get)
print(f" >> ARB SIGNAL: buy {buy_on} → sell {sell_on} | spread {spread:.3f}%")
if __name__ == '__main__':
while True:
monitor_amm_pools()
time.sleep(12) # ~1 Ethereum block
On-chain arbitrage is extremely competitive. MEV bots running on Flashbots bundles will front-run naive arb transactions in the public mempool. If you're serious about AMM arbitrage, study private transaction relays and flashloan-based atomic arb before deploying real capital.
The standard constant-product AMM model has a known weakness: it's vulnerable to loss-versus-rebalancing (LVR), a form of value extraction where arbitrageurs continuously profit at the expense of LPs by trading against stale prices. The AM-AMM — auction-managed automated market maker — is a research-driven model designed to address this.
In the AM-AMM framework, the right to set pool parameters (like swap fees) is auctioned off continuously to the highest bidder. The winning bidder — usually a sophisticated market maker — can adjust fees dynamically, meaning they can capture more of the arbitrage flow by raising fees when volatility spikes and attracting volume by lowering fees when markets are calm. The auction revenue flows back to LPs, partially compensating them for LVR losses that standard AMMs don't recover.
This is still largely in the research and early-deployment phase as of 2025, but it represents the frontier of automated market maker AMM model design. Protocols like Uniswap V4 — with its 'hooks' system — and newer layer-2 native DEXs are experimenting with dynamic fee mechanisms that move in the AM-AMM direction. Traders on platforms like Bybit DeFi or OKX Web3 will likely encounter these pool types more frequently as the year progresses.
For practical traders, the key takeaway from AM-AMM research is this: not all AMM pools are created equal. Pool design determines who captures value — LPs, arbitrageurs, or protocol treasuries. Reading pool mechanics before depositing liquidity is as important as reading a company's financials before buying stock. VoiceOfChain's signal platform tracks on-chain liquidity events in real time, helping traders identify pool flows before they show up in price action on centralized venues.
AMM automated market makers have fundamentally rewired how liquidity works in crypto. The constant product formula that powers Uniswap, the stableswap invariant behind Curve, and the emerging AM-AMM auction model — these aren't just technical curiosities. They determine your swap costs, your LP returns, and where arbitrage profits flow. Whether you're a trader looking to minimize slippage on Binance alternatives, a liquidity provider optimizing yield on Curve or Balancer, or a developer building bots that interact with on-chain pools, understanding the automated market maker AMM model at the code level gives you an edge that most participants simply don't have. Pair that knowledge with real-time signal data from platforms like VoiceOfChain, and you'll be operating with both the structural understanding and the market timing that separates consistent winners from everyone else.