How AMM works and how AMM price is determined
What is impermanent loss:
Impermanent loss causes liquidity pools investors to lose money whenever the price ratio of the tokens in the pool changes significantly. In other words, if you provide liquidity to a liquidity pool, and the ratio of prices of the tokens changes significantly, you will lose money
Tokens ratio is balanced on deposit
Tokens ratio changes outcome on withdrawal
How to mitigate the risk of impermanent loss:
Make sure you get paid for it in fees, choose a pool with high fees and relative stable token prices
Why and how:
When you invest in a liquidity pool, you deposit two types of tokens with equal value. When the market price for one of the tokens in the pool changes, the pool price does not automatically update, it only updates when traders exploit this wrong / outdated price on the pool
For example, if 1 ETH = 350 USDC when you invest in an ETH, USDC liquidity pool, and you invest 1 ETH and 350 USDC in that pool (50% - 50%). In the following day, ETH market price appreciates and is now worth 360 USDC (on Coinbase), that doesn't cause an automatic price update in the liquidity pool. In the pool, ETH is still sold for 350 USDC, this is an arbitrage opportunity that traders will take.
In order to exploit this arbitrage opportunity, traders will buy ETH from the pool (at $350) and sell it on Coinbase (at $360). This action decreases the amount of ETH in the pool and therefor increase the price of ETH in the pool (the price is determined by the amount of supply, as supply goes down, price goes up). This action corrects the pool's pricing, but the profits that the traders are making is directly on the account of the liquidity providers.
The traders took out ETH from the pool while it was under-priced, and now the pool's liquidity providers are left with less ETH then they deposited.
The pool’s tokens ratio changes, so when you leave the pool, you always get more of the token that depreciated in value in compared to the other token, you are always on the losing side!