Alexis Direr, a researcher at the University of Orleans in France, has released a paper summarizing the mathematical underpinnings of Uniswap and other exchanges based on Automated Market Makers.

Automated Market Maker is the term for a class of decentralized exchange that reached significant popularity in 2020, spearheaded by Uniswap.

In a nutshell, these exchanges do away with traditional order books and instead rely on liquidity pools governed by a mathematical formula. Traders are always able to make a transaction with the pool for even the most illiquid tokens, but each order will impact the price of the asset they are trading — a phenomenon called slippage.

The mathematical formula defines how the price changes in response to the size of a particular order. For example, the formula may say that exchanging 10 Ether (ETH) into Dai (DAI) yields $3,500, but exchanging 100 ETH only yields $3,400. This means that the price of 1 ETH is $350 in the former case, but only $340 in the latter. The formula is often called the “bonding curve,” as the various possible combinations describe a particular price curve. In the case of Uniswap the curve is a hyperbola, though other AMMs may have more complex shapes to optimize for different scenarios.

AMMs rely on liquidity providers — people and entities committing their capital into liquidity pools to facilitate trades and lower slippage. In return, LPs obtain trading fees paid by users.

While this may sound like a sweet deal, liquidity providers need to deal with “impermanent” loss. LPs may end up with less money than they put in initially when the price swings significantly in one direction. Compared to an equivalent 50:50 portfolio of the assets in question, the pool underperforms significantly with large price deviations.

The researcher explains that this phenomenon occurs due to the presence of arbitrage traders. Outside market prices do not obey the bonding curve, so constant action is necessary to keep Uniswap’s price in balance with the rest of the market. But when arbitrageurs rebalance the pool to the correct value, they do so at a “suboptimal exchange rate” defined by the bonding curve. This action extracts value from liquidity providers in favor of the arbitrageurs.

The loss is generally named “impermanent” because if the price were to return to its initial value, liquidity providers are completely even compared to the benchmark 50:50 portfolio. Discounting the case where the price permanently moves to a new equilibrium, Direr posits the question:

“The fact that the two strategies yield the same result seems at first disturbing. In the pooling strategy, the pool incurs arbitrage costs twice […] In the holding strategy, the investors avoids arbitrage costs altogether, yet ends up with the same final wealth. How is it possible?”

The researcher’s answer is that the way benchmarking is commonly done is misleading. Uniswap constantly rebalances the pool as it moves higher or lower, so that liquidity providers have fewer units of the asset that went up in price, and more units of the asset that went down in relative terms.

LPs effectively conduct a profit and cost averaging technique in both ways of the trip. They lock in some of the profit as one asset’s price moves higher, and progressively buy more as it goes back down.

Similarly to how such an averaging technique would work, a 50:50 portfolio that constantly rebalances will turn a profit, despite the price returning to the initial number. In comparison, the liquidity pool’s value simply remains where it was.

Hence, “impermanent loss” appears to be a misleading term. The loss is always permanent, but in the optimistic scenario it merely cuts into the gains that an equivalent strategy would have netted.

Bancor V2 and Mooniswap have adopted techniques to mitigate this type of loss. The former uses oracles to read true market prices and balance the pool accordingly, while the latter introduces a gradual time delay to minimize the profits of arbitrage traders.

**Original Source**