Pular para o conteúdo

What is an AMM?

Aula 1 de 3Iniciante

Constant-product math, slippage, and impermanent loss explained without hand-waving.

The Constant Product Formula

Seção 1 de 2

An Automated Market Maker (AMM) is a smart contract that holds two tokens and quotes a price by formula instead of matching buyers and sellers in an order book. The classic design, used by many AMMs, is the constant-product AMM, defined by a single equation:

x * y = k

where x and y are the reserves of each token in the pool and k is a constant. When a trader buys token Y, they deposit some token X. The pool's X reserve goes up, so the Y reserve has to fall enough to keep k unchanged. That fall is what they receive. Not every AMM uses this curve; each exchange's documentation says which one it uses.

A worked example, with made-up numbers: a CC/USDCx pool holds 100,000 CC and 15,000 USDCx, so k = 1,500,000,000. A user sells 1,000 CC. New CC reserve = 101,000. New USDCx reserve = k / 101,000 = 14,851.49. The user receives 15,000 - 14,851.49 = 148.51 USDCx, or 0.1485 USDCx per CC. The pool's price before the trade was 15,000 / 100,000 = 0.15 USDCx per CC, so the user got about 1% less than that price. That gap is slippage, and it grows with trade size relative to pool depth.

Impermanent Loss in Plain English

Seção 2 de 2

Impermanent loss (IL) is the gap between holding two tokens yourself and providing them as liquidity to an AMM. It shows up when the two tokens' prices diverge. The mechanism: every time the outside market price moves, arbitrageurs trade against the pool until its price catches up, and that rebalancing takes value from the liquidity providers (LPs).

A worked example, with made-up numbers: you deposit 100 CC and 15 USDCx into a CC/USDCx pool when CC is at $0.15, so the deposit is worth $30. CC then doubles to $0.30 on every other venue. Arbitrageurs buy CC from the pool, paying in USDCx, until the pool's price reaches $0.30. Afterwards your share holds about 70.71 CC and 21.21 USDCx, worth $42.43. Had you simply held the original 100 CC and 15 USDCx, they would be worth $45, so you are $2.57 (about 5.7%) behind: that is the impermanent loss. It is called impermanent because if CC returns to $0.15, the position returns to its original split and the loss disappears.

Impermanent loss is separate from fees: the fees a pool earns can offset part or all of it. A pool with high trading volume can pay enough in fees to outweigh it; a pool with low volume and a volatile pair may not. The four levers to think about when picking a pool: TVL (how deep the pool is), the fee rate (what each swap pays), volume over 14 to 30 days (how often fees are collected) and pair correlation (how much impermanent loss to expect).

Veja ao vivo

A aba DeFi de Mercados lista o que esta aula cobre, na Canton.

Abrir DeFi

Quiz

Carregando