What Is the Constant Product Formula (X Y=k) and How Does It Cause Impermanent Loss?
The formula x times y equals k ensures that the product of the quantities of the two tokens (x and y) remains constant (k). When an external price change makes the ratio x/y in the pool incorrect, arbitrageurs step in.
They trade with the pool until the pool's ratio matches the external market price. This trade changes the quantities x and y, but k stays the same.
The loss arises because the value of the assets inside the pool after the trade is less than the value if the assets were simply held (HODLed).