The basics of yield farming

By July 18, 2021DeFi
Click here to view original web page at medium.com

What is yield farming?

Yield farming is the practice of generating high returns on the depositing, staking, or borrowing of crypto. This is typically done to increase the yield on an initial deposit or to maximize yield through several different methods and platforms.

For example, you could deposit stablecoins into Compound, a borrowing and lending platform, for a good yield but if you wanted to increase your yield you could deposit the cTokens from your deposit into another platform to get yield on those. This is a very simple example of how an individual could use only a single deposit to increase the yield on their initial capital.

How does yield farming work?

At the very heart of yield farming are liquidity pools, which are the foundation for most DeFi platforms. Liquidity pools are a pool of tokens that users, liquidity providers, have deposited into. Users can borrow from this pool which they will have to pay interest on, or they can be used to swap tokens. Liquidity providers are rewarded with fees from the swaps or a portion of the interest, depending on the type of liquidity pool they deposited into.

Typically, when a liquidity provider deposits funds into a liquidity pool they will receive a token that represents their deposit, which they use to withdraw it from the pool. However, if a user wanted to maximize the yield from their initial deposit into the liquidity pool they could deposit these new tokens, LP tokens, into a different platform and get yield on those. Essentially, the liquidity provider, or yield farmer, is getting two yields on their initial deposit instead of one. This is manual yield farming, where a yield farmer is moving tokens through different platforms and managing their deposits manually.

Yield farming examples

If a yield farmer deposited their 100 USDC into Aave, at 3.58% APY, they would receive 100 aUSDC, Aave’s LP token.

The yield farmer could then deposit their 100 aUSDC into a liquidity pool in Curve Finance and receive 11.06% APY.

So from an initial deposit of 100 USDC a yield farmer could generate 14.64% APY, interest per year. Although, these interest rates are variable. This means that it will change daily depending on the utilization rate. The utilization rate is determined by how much of a total token on the platform is being used for lending. A higher percentage of deposits that are used for loans results in higher interest rates. One day your 100 USDC could receive 15% APY and the next day it could receive 5% APY.

If the yield farmer wanted to take it a step further, they could use their initial 100 USDC in Aave as collateral to borrow 77.49 USDT at 3.97% APR. You can only borrow 77.49 USDT because the Loan to Value (LTV) ratio for USDT is 77.49%. This means that you can only borrow 77.49% of what you used as collateral, 77.49% of 100 = 77.49.

They could then deposit their 77.49 USDT into the USDT pool on Curve Finance for a base 4.15% APY and receive 71.42 Curve usdt LP tokens.

Then they could stake those Curve usdt LP tokens in the DAO and earn an additional 9.25% APY, which is paid out in their native token CRV.

This would bring their total yield to 24.07% from their initial deposit of 100 USDC. It is important to note that yield farming using small amounts of funds wouldn’t be sustainable on Ethereum DeFi platforms because you have to pay a gas fee every time you deposit or borrow on a platform. These gas fees can vary anywhere from $10 to $100 depending on the number of people using the Ethereum network at the time. Since our example used 5 steps of depositing and borrowing, that could cost the yield farmer anywhere between $50 and $500 depending on the gas fees for each transaction. Since this is the case, you would not be able to yield farm on Ethereum with $100 by using that example. Moreover, continually placing deposits into yield pools can increase risk considerably. Yield farming can become incredibly high risk and should be treated as such if going through complicated processes.

Since these strategies for maximizing yield can be complicated and difficult to manage, some platforms automate this process for you. The yield farmer could instead choose to deposit his initial 100 USDC into the USDC vault in Yearn Finance and earn 15.53% APY — growth section. This vault, like the deposits on other DeFi platforms, is variable so the interest rate will change daily.

Yearn Finance can achieve these yields by creating “strategies”. A strategy is a method that is used to maximize the amount of yield on a deposit. Below you can see a map of the strategy for the USDC vault.

These strategies change over time as yields shrink, so they find other platforms to deposit and maximize yields. Similar to placing your own deposits into many different yield farming platforms, there is no decrease in risk by using a yield farming platform that automatically manages your deposit for you. This can be seen with Yearn Finance experiencing an $11 Million hack in February 2021, which is not uncommon for yield farming platforms to experience.

What is liquidity mining?

Liquidity mining is a method of distributing tokens to the users of a platform. When you deposit funds into Compound you will gain interest on your deposit and extra COMP tokens on top of it. Below you can see that a deposit of USDC will give you 3.29% APY as well as 2.49% APY of COMP tokens.

These extra COMP tokens can incentivize users to deposit or borrow from their platform instead of others. This method has become popular among DeFi platforms as a way to attract new users.

For example, when you deposit tokens into a Curve Finance liquidity pool, you will also receive Curve LP tokens. These tokens can be used to deposit and stake in the DAO and earn interest. By depositing tokens into the Aave pool you will receive Curve Aave LP tokens. You can then deposit these tokens in the DAO and earn an additional 9.09% APY, which is paid out in CRV.

Essentially, liquidity mining is any borrowing or lending where you are rewarded with extra tokens on top of your base interest rate.

How are yield farming returns calculated (APY & APR)?

The most common way yield farming returns are calculated is through two metrics; Annual Percentage Yield (APY), and Annual Percentage Rate (APR).

APY is the interest rate over a year. If you deposited 100 USDC into Aave at 10% APY, after one year your deposit would generate $10. Making your deposit now worth $110.

APR is the compounded interest rate over a year. With a compounding interest rate, the interest you generate is added to your initial deposit to generate higher returns. If you deposited 100 USDC at 10% APR, compounded daily, after one year your deposit would generate $10.52. Making your deposit now worth $110.52. This is because your interest is added to the initial deposit, and then the whole amount generates the 10%, unlike APY that only uses the initial deposit. Although $0.52 may not seem like much, the difference becomes greater when you have larger deposits.

Risks of yield farming

While yield farming can increase the yield on your deposits, there are risks to consider when doing complicated strategies or simply using an automatic yield farming platform.

Smart contract hacks

Since smart contracts are used by DeFi platforms to automate many of their processes, like depositing and borrowing, which can expose them to smart contract hacks. This happens when a bug is found in a smart contract which allows a hacker to exploit it, resulting in stolen funds. Although DeFi platforms have their smart contracts checked by reputable auditing firms, there can still be a large amount of risk that is present in using a smart contract. Harvest Finance is a yield farming platform that suffered from a hack where an attacker was able to use a flash loan to steal $24 million from the liquidity pools. Since flash loans operate using smart contracts this is an example of how hackers can exploit smart contracts to steal funds from platforms. This makes yield farming platforms, in most situations, a high risk activity.

Impermanent loss

When depositing tokens into liquidity pools, changes in the price of your token compared to when you deposited them can result in a loss of value. Larger price increases or decreases will result in a larger loss of value when you withdraw them from the pool. Below you can see how an increase in the price of ETH can result in a loss when being stored in a liquidity pool.

Credit to Data Driven Investor

Interconnected platforms

Since yield farming strategies and platforms rely on many different DeFi platforms to maximize yield, there is an increased amount of risk when more platforms are used. When you hold your deposit in one platform, you are only exposed to the risk of that platform. If another platform is hacked then your funds will most likely remain safe. If you have deposits in five different platforms, you are exposed to the risk of five different platforms that could be hacked. If even one of the platforms is hacked, and you lose your funds, this can break your yield farming strategy because you may need those tokens to withdraw tokens from another platform. If one domino falls it could likely cause all the dominoes you have lined up, to fall.

The same principle applies to a platform, like yearn finance. If the platform your deposit is on is reliant on other platforms then it also increases risk. If another platform gets hacked then the deposit on your platform may be at risk if it was being used on the hacked platform.

liquidation when borrowing

When borrowing crypto it is important to pay close attention to the price of your collateral. Since the value of your collateral determines how much you can borrow, if the price of your collateral falls below a certain level it will get liquidated. The amount of collateral you will need to borrow will depend on the platform and asset you wish to borrow. On Compound, when borrowing 100 USDC, with ETH as collateral, there is a Loan to Value ratio of 80% which means you can only borrow a maximum of 80% of the value of your collateral. This means you would need $133 of ETH to borrow $100 worth of USDC. If the value of ETH falls then the LTV will increase. If the LTV goes above 80% then your collateral, ETH, is at risk of being liquidated. Luckily Compound only liquidates 50% of your collateral, instead of 100%. However, if the value of ETH goes up then your LTV will decrease, which gives you protection if the price falls. Taking out loans in DeFi can also be extremely high risk so it is not recommended.

Join Coinmonks Telegram Channel and learn about crypto trading and investing

Also, Read

All Today's Crypto News In One Place