How Does the Constant Product Formula (X Y = K) Directly Cause Impermanent Loss?
The formula x y = k requires the product of the quantities of the two tokens (x and y) to remain constant (k). If the external market price of one token changes, arbitrageurs trade with the pool until the pool's ratio reflects the new external price.
To maintain the constant product, the pool must sell the appreciating asset and buy the depreciating one. This rebalancing leaves the liquidity provider with fewer units of the asset that appreciated, which is the impermanent loss.