# 2. Impermanent Loss

This piece is written by @Edyta from Phezzan Discord server
In most Automated Market Maker (AMM) DEX, its pools hold a` x * y = k` invariant, where x and y are the amount of quote token and base token of the market. For example, in a \$PHE-USDC pool, if the initial \$PHE amount is 10, and initial USDC amount is 1000, then `k = x * y = 10 * 1000 = 10000`. Unless someone add or remove liquidity, k stays constant.
Also, LPs have to deposit equal value of quote token and base token. Let's take a look at an example.
LP contributes 1 \$PHE and 100 USDC to the liquidity pool. Since the deposited token pair must be of an equivalent value. 50/50. This means that the \$PHE price at the time of deposit is 100 USDC. It also means LPs dollar deposit value is \$ 200 at the time of the deposit.
In addition, there is a total of 10 \$PHE and 1000 USDC in the pool - funded by other LPs. So LP has a 10% stake in the pool and the k = 10 * 1000 = 10,000.
Let's say the price of \$PHE rises to 400 USDC. While this is happening, arbitrage traders trade \$PHE in AMM until the ratio reflects the current price. Remember that AMMs do not have an order book. What determines the price of assets in a pool is the ratio between them in that pool. While the k remains constant (10,000) if there is no addition/removal of liquidity, the ratio of the assets in it changes.
If the \$PHE price is now 400 USDC, the ratio between the amount of \$PHE and the amount of USDC in the pot has changed. There are currently 5 \$PHE and 2,000 USDC in the pool.
LP decides to withdraw his funds. As we know from earlier, he is entitled to a 10% share in the pool. As a result, it can withdraw 0.5 \$PHE and 200 USDC for a total of \$400. He has made a nice profit since depositing \$200 tokens, right? But wait, what would happen if He just kept her 1 \$PHE and 100 USDC? The total dollar value of these assets would now be \$500.
We can see that LP would do better on HODLing than putting in the liquidity pool. This is called an impermanent loss because losses are only real when funds are withdrawn from the liquidity pool. An impermanent loss occurs regardless of the direction of the price movement.
With this in mind, the LP example completely ignores the trading fees and native token reward it would earn for providing liquidity. In many cases, the resulting fees and token reward would neutralize the losses and nevertheless make the provision of liquidity worthwhile.