Lesson 17 - Slippage and Impermanent Loss

Slippage Formula

SlippageAmount=ActualyoutExpectedyout
Actualyout=Δy
(yΔy)(x+Δx)=xy
yx+yΔxΔyxΔyΔx=xy
Δy(x+Δx)+y(x+Δx)=xy
Δy(x+Δx)=xyy(x+Δx)
Δy(x+Δx)=yΔx
Δy=yΔxx+Δx=Actualyout

Expectedyout=pxxin
yxxin

SlippageAmount=yxinx+xinyxxin

Formula for Impermanent Loss

Impermanent loss needs to show the different in V for pair in the liquidity pool versus held in the wallet, where it adjusts based on market price.

Value = (Price Token X)(Amount Token X) + Amount Token Y

This is where Y is the token in which value is expressed, and Price Token X is with respect to price Y.

Impermanent Loss represents the difference in the value of what is in the Pool vs what is in the Wallet

VpoolVhold=pnowxnow+ynow(pnowxold+yold)

The impermanent loss occurs when an arbitrageur trades an (x,y) pair at the price of the AMM pool and is able to take profits. The profit taking comes by, say, trading out a token at a lower price relative to, say, USDC, than the external markets.

This is why xnow and ynow are different from xold and yold