#impermanentloss #liquiditypools #automatedmarketmakers #crypto #tradingfees Impermanent loss happens when the price of your tokens changes compared to when you deposited them in the pool. The larger the change is, the bigger the loss. This is an inherent design characteristic of Automated Market Makers (AMM). Pools that contain assets that remain in a relatively small price range will be less exposed to impermanent loss. Stablecoins, for example, will stay in a relatively contained price range. The main reason to provide liquidity are trading fees. Liquidity pools can be profitable despite impermanent loss through trading fees. What determines the price of the assets in the pool is the **ratio between them in the pool**. While liquidity remains constant in the pool (3,000), the ratio of the assets in it changes. This formula can vary with each protocol. For example, Uniswap uses $x * y = k$, where $x$ is the amount of one token in the liquidity pool, and $y$ is the amount of the other. In this formula, $k$ is a fixed constant, meaning the pool’s total liquidity has to be the same. Other AMMs will use other formulas for the specific use cases they target. The similarity between all of them, however, is that they determine the prices algorithmically. To demonstrate impermanent loss, we will use a liquidity pool (LP) holding SOL and USDC. To deposit to this LP, the pair needs to be of equivalent value. In our example we deposit 1 SOL and 100 USDC since the market price at the time was roughly $100. If we deposit 1 SOL and 100 USDC we have spent approximately $200 in market value. We also assume that there is 10 SOL and 1,000 USDC in the pool at the time (from other liquidity providers) so our share of the pool is 10% since we have 100 of the 1,000 total liquidity. If the price of SOL increased from $100 to $400, arbitrage traders will rebalance pool taking advantage of the lower price ratio 1:100 until it balances at 1:400. Through numerous trades, the pool now holds 5 SOL and 2,000 USDC. If we withdraw our 10% share in the pool, we would receive 0.5 SOL (`0.1 * 5 = 0.5`) and 200 USDC (`0.1 * 2000 = 200`) respectively. The SOL would be worth $200 (`0.5 * 400 = 200`) along with $200 worth of USDC for a total of $400 collectively. Since our initial deposit was $200 worth, and we now have $400 of SOL/USDC, we have made a profit of $200. However, if we had held the original 1 SOL and 100 USDC instead of depositing into the liquidity pool, their value would be $500 combined (`1 * 400 + 100 = 500`). We can see now that we would have been better off by holding the tokens rather than depositing into the liquidity pool. This is what we call impermanent loss. Instead of $500 worth of tokens, we now have $400 worth of tokens, so the loss is around $100. Note it's called impermanent because the loss is only realized when we withdraw from the pool. However, impermanent loss can lead to big losses if not careful. Our example also doesn't take into account the trading fees earned while providing liquidity, which can negate some of the loss and make this profitable.