Francium-DeFi

Searchโฆ

Farming Guide

๐งฎ Farming Calculator

๐ Strategy Guide

Dev Resource

๐ก What is Leveraged Farming?

Written by Team Francium. We will be walking you through the basics of leveraged yield farming (LYF), as well as the mathematics behind the product.

Imagine this scenario

Alice is a happy farmer. She earns a good return by planting and selling wheat. Alice wants to farm more wheat, but has a limited amount of money. She knows her neighbor Bob has money and makes him an offer.

Alice asks Bob if she can borrow money to buy more seeds, and in return, sheโll pay Bob part of the harvest.

Now letโs apply Leveraged Yield Farming (LYF) to this example. Imagine Alice having $1,000 USDC to start with. Therefore, she borrows 1,000 USDC from Bob. Now Alice has $2,000 and buys wheat seeds for farming.

Alice pays Bob 10% interest for the $1,000 she borrowed from him. But Alice earns an income from $2,000, and this is farming with 2x leverage.

Investment returns are not guaranteed. When Alice offered to borrow $1,000 USDC from Bob, he understood the risk. If he does not lend Alice $1,000 USDC, his money is safe. If he lends Alice $1,000 USDC, he earns 10% ($100 USDC) interest every year. But if Alice fails to plant wheat or if the price of wheat drops, she might not be able to repay either the principal or interest.

Bob wants to limit his risk when lending money, so he and Alice reach an agreement. If the value of Aliceโs wheat declines to a certain amount, Alice will liquidate all of the wheat and return Bobโs $1,000 USDC. This is an example of Leveraged Yield Farming with a liquidation.

But what if Alice borrows wheat instead of USDC from Bob? And what if the value of Aliceโs assets is not only dependent on wheat?

The above example illustrates a common use of Leveraged Yield Farming (LYF). LYF can increase the income of the farm by borrowing or longing specific assets.

Providing liquidity for two tokens (LP) is the most common use case in Decentralized Finance or DeFi. To understand the performance of LYF, letโs create a stable coin model.

There are two tokens in this model: Token A & Stable Coin USDC. Letโs take** P **as the price of A, using the amount of USDC as a unit. Initially, Charlie holds** N **USDC, and the price of A is **Pโ**. When he participated in LYF with leverage **Y**:

- 1.
**N(Y-1)**USDC were borrowed from the lending pool. - 2.
**NY/2**USDC (half of total USDC) will be swapped for A. - 3.Deposit A & USDC for LP tokens.
- 4.Stake LP tokens into the farming pool.

When closing the position, the following steps are followed:

- 1.Redeem all LP tokens for A & USDC.
- 2.Sell all A for USDC.
- 3.Repay
**N(Y-1)**USDC. - 4.You get the remaining USDC.

Based on the AMM formula, when** P **changes, the amount of USDC we can withdraw by redeeming the LP token is:

So when you close the position, the profit you get is:

In traditional longing, the profit we can get by longing **X** A is **X(P-Pโ)**. Without losing generality, letโs make the initial price **Pโ=100.** The performance of longing with different leverage is illustrated below:

USDC Profits on 1x/2x/3x Margin VS Traditional 1x

But the role of LYF is not only that. If you are a keen trader, you may think that if the price of a certain token falls within a certain period of time, the best way to make a profit from it is to go short this token. The usual steps are: when token A's price is **Pโ**, borrow **X **token A, sell** X **token A for** Y **token B immediately, and when token A's price drops to** P**, buy** X** token A back. By doing so, the profit you get is **X*(Pโ-P)** token B-borrowing interest. With LYF, there is a little difference. If you are holding** X** token A and open a **3X **leverage position, you will automatically borrow** 2X** token A from the lending pool, and half of total token A, **1.5X** of** **A will be swapped to token B immediately, and **0.5X **of token A short exposure is generated instantly. With traditional shorting, you can only earn a profit from a price drop, but with yield farming, you can also earn LP tokens apart from the price drop. Itโs a safer method to short a certain asset since the LP price and the token price have a square-root relationship. You might doubt whether it is a good method to short, so next we will show you the performance of shorting with LYF by using the same model.

Initially, Charlie holds** M** A, whose initial price is **Pโ**, when he participated in LYF with leverage **Y**:

- 1.
**M(Y-1)**A are borrowed from the lending pool. - 2.
**MY/2**A (half of total A) will be swapped for B. - 3.Deposit A and B for LP tokens.
- 4.Stake LP tokens into the farming pool.

When closing the position, it follows the next steps:

- 1.Redeem All LP tokens for A&B
- 2.Sell all B for A
- 3.Repay
**M(Y-1)**A - 4.You get the remaining A

Based on the AMM formula, when P changes, the amount of A we can withdraw by redeeming an LP token is:

The total worth of LP tokens are:

When you the close position, the profit you get is:

In traditional shorting, the profit we can get by shorting is:

Without losing generality, letโs make the initial price** 100. **(Due to the similarity solution, you can get the same performance at other initial prices)

Token A 1x/2x/3x Margin Profit, with USDC as Principal

Token A 1x/2x/3x Margin Profit, with Token A as Principal

From the above figures, you can see the LYF curve is smoother. When the leverage is equal, long & shorting with LYF can reduce the risk when the price is going up/down. When the leverage reaches twice that of the traditional short, it begins to suppress the profit of traditional longing and shorting within a certain range, but the cost is higher when prices fall or rise, or when capital usage is higher. It may look like a simple long/short strategy, but there is an important factor we havenโt taken into account: farming yield, or maybe what we can call self-adjusting leverage. Because our LP tokens keep earning rewards and those rewards are reinvested into our LP tokens, the borrowed tokens are going to take a lower and lower proportion relative to the capital, so we have decreasing leverage. For example, if token A is not likely to fluctuate within a short time, LYF longing/shorting can make it more resistant to market volatility in the future. In a constant APR auto-compound model, the profit can be demonstrated as below:

Illustration of the auto-compound model

Francium Explained: What is Leveraged Yield Farming (LYF)?

Medium

โ

Last modified 7mo ago

Copy link