How KMM Swap mitigates Impermanent loss

#dev DeFi
3 min readDec 21, 2021

The main risk of KMM to liquidity providers is still impermanent loss. For example, in the BTC-USDT trading pair, a user provides BTC to the LP. His BTC may be exchanged, partially or entirely, to USDT. When BTC price rises compared to the initial price when he deposited, he will suffer impermanent loss compared to the scenario in which he had held his BTC instead.

However, KMM mitigates this loss by ensuring that the asset, in the above example BTC, is always exchanged at the current market price or better. Therefore, none of the assets will be exchanged at an inferior price. Moreover, by concentrating all the liquidity at the market price, KMM utilizes 100% of the liquidity provided, generating more trading fees to compensate them for the impermanent loss risk.

If you have no idea what is Impermanent loss, take a look at our previous blog of Impermanent loss explanation.

Visualization

To visualize how KMM mechanism actually mitigates impermanent loss to liquidity providers, let’s go into an example in which you can see the effect of impermanent loss on KMM liquidity pool and a 50/50 liquidity pool (based on x*y=k).

Initially, we have 2 BNB/BUSD liquidity pools with the same ratio and value of assets, one is using KMM mechanism and one is using the Constant product model. In both the 2 pools, there are 5,000,000 BUSD and 10,000 BNB. BNB/BUSD price is now 500.

Impermanent loss in Constant product model

Assume that the market price moves to 550 creating arbitrage opportunities, arbitragers exploit the difference and help to adjust the price on the 50/50 liquidity pool to 550. After the arbitrage, following the formula x*y=k we can calculate the current assets in the pool:

Assets in 50/50 pool: 5,244.044 BUSD & 9,535 BNB

This means 244.044 BUSD is added to take out 465 BNB.

Impermanent loss in KMM Swap model

Since KMM Swap leverages on Chainlink price oracle to obtain the market price then adjust its price, there is nearly no arbitrage opportunity, and the ratio of asset is not affected; we will use the exact input in the above case of the 50/50 pool to find out the impermanent loss on KMM Swap — add 244.044 BUSD to KMM’s pool.

(You can see the mathematical function in KMM Whitepaper)

Using the mathematical function of KMM and its default parameter (maxPriceImpact = 5%), we have the output is 442.7367 BNB.

Impermanent loss in KMM versus Impermanent loss in the Constant product model

As the price increases 10%, the Impermanent loss is 0.1134% on the Constant product pool and it’s -0.0051% on the KMM pool, which means there is an increase in the value of the KMM pool. This is because KMM Swap always fetches the market price to automatically adjust its actual trading price instead of relying on arbitragers. Without arbitrage, no value was taken out from the pool, and even when the trading price is so close to the market price fetched from Chainlink it still has a small price impact, this small price impact is the factor that increases the value in the KMM pool.

Given another scenario in which the market price increases 100% to 1000, the impermanent loss that occurred on the Constant product pool becomes apparent — 5.71% loss. Otherwise, the value in the KMM pool slightly increases.

--

--

#dev DeFi

#dev DeFi is an aggregate lending and borrowing protocol on the Binance Smart Chain (BSC). https://devdefi.finance/#/