DeFi 2.0: Leveraged Yield Farming
For those that choose to HODL their crypto, decentralized finance (DeFi) provides means of putting digital assets to work without actually selling them. One such approach is to use “leveraged farming” (LF). LF is best described through examples. Let’s walk through two simple examples:
Example 1: Consider the RAY-SOL pair. Say we have 100 RAY in our wallet and we’d like to farm this pair at 2x leverage.
To fully understand how leveraged farming works we need to first define some terms:
- Equity (E): equals the out-of-pocket investment we bring to the farm.
In our case this is 100 RAY.
- Debt (D): equals the amount of crypto we will borrow from the farm.
In our case we will be borrowing SOL. The actual amount is determined from the level of leverage.
- Total assets (T): equals the sum of equity and debt: T = E + D.
- Debt ratio (R): equals the ratio of debt to total assets: R = D / T = D / (E + D).
- Leverage (L): equals the ratio of total assets to equity: L = T / E = (E + D) / E = 1 + D / E.
From this we can find a simple expression for the debt value: D = (L – 1)E.
In our case: L = 2 so D = (2 – 1)E = E. In other words:
When the leverage is 2x, we borrow an amount equal to our equity.
In our case we will borrow an amount of SOL equivalent to 100 RAY. The cost is determined by the current market RAY/SOL price.
For example if 1 RAY = 4 SOL, we will need to borrow: 25 SOL = 100 / 4 from the farm.
We now have 100 RAY + 25 SOL at our disposal. The farm will deposit this allocation into a RAY-SOL liquidity pool (LP). Most liquidity pools require a 1:1 deposit ratio meaning for every 1 RAY deposited in the pool an equivalent amount of SOL needs to also be deposited at the same time. Fortunately at 2x leverage we already have an exact 1:1 ratio of RAY and SOL, so the farm deposits100 RAY + 25 SOL into the LP. The LP will from time to time return dividends (or yields) to the farm from different sources such as: trading fees accrued when other users swap RAY for SOL and vice-versa. The farm may choose to auto-compound this yield meaning it will immediately return the yield back into the LP instead of returning it to us.
Regardless, after a certain time we choose to close-out our farming position. The farm will instruct the LP to withdraw our allocation. This will return100 RAY + 25 SOL to us. We pay back our debt to the farm (25 SOL) and walk away with our initial equity of 100 RAY (minus transaction fees). Given how small the transaction fees are for Solana we can ignore them for now.
So what exactly did we gain from this leveraged farming position?
Answer: Well, we earned the (compounded) yield accrued during the time our allocation was locked inside the LP. This can be quantified by an APR% (annual percentage rate) or APY% (annual percentage yield), where the later is in the case of auto-compounding. For example, say that we held our position for exactly one year and were awarded 12 RAY tokens by the farm during this time. This means our APR is equal to: 12 / 100 = 12%.
How do price fluctuations affect our leveraged farming gain?
Answer: Obviously, while our assets are locked in the LP, we are subject to price fluctuation in both RAY and SOL. Our exposure, however, is different across the assets. For the borrowed asset (SOL) we hold a “neutral position”. In other words we are not affected by the price fluctuations of SOL during this time. Reason being that once the position is closed, the LP always returns the total amount of borrowed asset (25 SOL in our case), regardless of the price of SOL at the time of closing. We simply return this 25 SOL to the farm and walk away. Our exposure to the equity asset (RAY) is different. We hold a “long position” in RAY which is a fancy way of saying we want the price of RAY to go up while it’s locked up in the LP. This “long position” is equivalent to HODLing RAY instead of farming it. This raises another question:
If our position in RAY is equivalent to HODLing, why even bother with leverage farming?
Answer: We pocketed 12 RAY after a year of leverage framing (remember?!). This obviously would not have happened if we just HODLed RAY in our wallet.
Free money, hooray! Wait, what’s the risk of leverage farming?
Our LF position does not come without risk. The biggest risk is what is called “liquidation”. To understand liquidation we need to understand not only our risk but the risk the farm is taking… Why did the farm choose to lend us the 25 SOL necessary to open the position in the first place? It did so because we put up an equal amount (100 RAY) as a form of “collateral”. Once the farm deposits the total position into the LP we basically no longer have direct access to this collateral. The farm will use this collateral to offset the risk it took in lending us the 25 SOL.
Want to learn how you can invest liquidity pools? Schedule a consultation with our team today.