Leveraged Yield Farming: When Do We Get Liquidated?

.ali [yazdan]
3 min readJan 25, 2022

--

Apart from impermanent loss, liquidation is the biggest risk in leveraged yield farming (LYF). If you are new to LYF make sure to first check out this article that explains the concept using simple examples.

As a recap: yield farming is the act of providing capital to a liquidity pool (LP) in hopes of returns in the form of trading-fees and/or incentivized tokens. Leveraging simply implies taking a debt position to increase our exposure to the liquidity pool, hence increasing our potential gains.

Liquidation occurs when the DeFi platform (aka farm) forcefully exits our position from the LP so that it can safely return our debt to the lenders. This occurs when our equity value drops below a certain threshold. This mechanism is expected since our equity was essentially used as collateral for the debt and the farm needs to protect the lenders.

Many DeFi platforms use automated bots (which are just smart contracts) to conduct liquidations. These bots often penalize the users by taking a small percentage off the top of the liquidated position (typically 5%). While these fees are typically returned to the DeFi platform (to cover for example operating costs), they nevertheless pose a loss of capital to the users.

Hence knowing when our position is close to liquidation is of utmost important.

To quantify liquidation we must analyze the mechanics of the underlying LP. Particularly we need to know how our equity position varies when the underlying assets in the LP fluctuate. Fortunately, we computed this value for a simple 2x leveraged token — stable pair model in a previous article:

Position value vs LP asset fluctuation.

Let D and E represent the initial debt and equity value we have staked in the LP, respectively. Our total initial position value is thus: D+E. The fundamental liquidation equation simply states that our current position value (after asset fluctuation) should be more than the debt amount (obviously so that we can fully repay the debt by exiting the LP). The DeFi platform will usually add a buffer for safety meaning our our current position value needs to be more than the debt amount plus a small buffer. Denoting the buffer by T where T<1, this translates to:

Liquidation equation.

Rearranging the terms we can write the liquidation equation above in terms of the debt-ratio defined as the ratio between the debt and the position value: R = D/(D+E).

Simplified liquidation equation.

The figure below plots this equation showing the maximum variation allowed against the debt ratio.

δ (max) vs. R.

Caveat: Our derivation was for 2x leverage and is only an approximation as it does not account for certain nuances of a LPs such as transaction fees.

--

--