Drixx Academy/Defi Yield Farming Explained/

Defi Yield Farming Explained

Lawrence Zhou
Drixx Quant
April 26, 2021

Drixx - Defi Yield Farming Explained

DeFi Yield Farming: Risk, Rewards, and Metrics

DeFi yield farming is a blanket term for the set of all decentralized yield or interest-generating activities on the blockchain. These activities might include staking, lending, and being a liquidity provider (LP). Each of these activities comes with its own risks, rewards, and general operational issues.

Because of the overall demand for leverage, borrowing, and liquidity, yields in DeFi space can be extremely high. These range from ~10-20% annual percentage yield (APY) for stable-coin lending on a platform like Aave to something like 1,000% APY for providing liquidity to a new token (farms). What is more noteworthy, however, is that some of these APYs are not compounded APYs. This means, that with compounding, the rates of return could be astronomical. For example, a 1000% APY would imply 2.74% daily. With daily compounding, this would be nearly 20,000x per year (ie, if it were in dollars, every 1 dollar invested would become nearly 20,000 dollars in one year). Obviously, these kinds of returns are not sustainable. In practice, returns are significantly lower. In this article, we will briefly explore the three main types of yield farming. We will then go over yield-farming math and scenario analysis.

Different Types of DeFi Yield Farming

There are three main forms of yield farming: staking, lending, and being a liquidity provider (LP). While there might be other more niche yield-farming-like activities (such as providing option liquidity), we will only look at the main three.


Staking is probably one of the more diverse categories of yield farming. In fact, the term “staking” can have multiple definitions. It can refer to staking to validate blocks (like ETH 2.0’s proof of stake), or it can refer to staking a token with a defi project (terms and rewards may vary).

Blockchain Validation

Generally, stakers on a proof-of-stake (POS) chain are responsible for mining/validating the next block. Stakers are liable for losing their stakes if they attempt to act maliciously. Therefore, the “yield” for staking your coins is from working to secure the blockchain network.

Defi Project Staking

Unlike blockchain staking, staking on a defi project does not involve validating blocks. Instead, the meaning, terms, and rewards will vary from project to project. However, staking generally involves locking up your defi tokens in the project itself. In some projects, the act of staking simply rewards additional defi tokens (to counteract the effect of token inflation elsewhere). In other projects, the staked tokens are used by the protocol itself. For example, in AAVE, the staked tokens are used as backstop collateral in their lending markets (the “Safety Module”). While staking the tokens pays additional AAVE tokens, there is a chance of loss if there is a shortfall in their money markets.

Rewards and Risks

Because staking is so broad, it is difficult to fully assess all the rewards and risks. Generally, though, staking rewards tend to be lower than lending and liquidity rewards. In addition, you are (by default) exposed to the price risk of the crypto you are holding. In blockchain staking, you risk losing a portion of your stake if your software is buggy (and you appear malicious). In defi staking, you will be exposed to smart contract risk.


Defi lending is just a form of margin lending. You loan out your crypto on a platform like Aave or Compound. When a borrower borrows your crypto, you get the yield on it (based on a pre-determined interest rate curve). You can refer to our Yield article for a more exhaustive overview of margin lending.

Rewards and Risks

The reward is obviously the APY you get from the borrower (after the platform cut). The main risk is default risk by the borrower (ie, the value of their collateral drops instantly). For example, if the borrower borrows $100 USDT against their $200 worth of ETH. If the price of ETH drops 80% before the lending platform can respond, there will be a $200 * 0.2 - $100 = -$60 shortfall (not including fees). The second major risk is obviously smart contract risk (exploits, locked funds, etc).

Automated Market Maker (AMM) Liquidity Provider (LP)

Being an LP effectively means being a market-marker on DeFi. To learn more about being an LP + liquidity mining, refer to our Liquidity Mining article.

Rewards and Risks

Most AMMs charge a fee for executing a trade. This fee is paid to the liquidity providers and forms the baseline for AMM rewards. In addition, depending on the project you are an LP for, you might be given an additional liquidity reward. If you “stake” your LP tokens (prove that you have provided liquidity), you might receive a reward from a fixed pool of tokens.

Obviously, being an LP can be risky. The biggest risk is price risk (from holding a portfolio with a potentially risky asset). The second biggest risk is impermanent loss (see our liquidity mining article). The third biggest risk is smart contract risk (either at the exchange, or with the defi protocol where you have your tokens staked). Finally, there is always a risk of a scam/rug pull. Being a liquidity provider means that unscrupulous teams can mint an infinite number of tokens to “dump” on the liquidity pool.

Because almost all “yield farming” activities on DeFi are on short-term interest rates (ie, they change constantly), there is also interest rate risk. Obviously, if there is a predetermined, safe 10,000% APY LP farm, new entrants to the farm will drive the APYs down (by diluting your percentage of the pool).

Yield Farming Math and Metrics

So, given what we know about yield farming and the risks, how can a new farmer assess the potential of a farm? We can define the “effective” APY as the actual realized APY after all the interest rate risks, price risks, and impermanent loss risks. Given these risks, we look at how to calculate the APY.

Estimating Effective APY Under Different Conditions and Scenarios


Even though lending through some crypto platforms might automatically compound your yield/interest. Many lending platforms and LP rewards are not compounded. This means that for a certain raw APY:

Let Raw APY = Yield Stated APY Let N = Number of times you compound per year.

Formula - Effective APY - Compounding

So, for an 80% APY and weekly compounding, then the effective APY = (1 + 0.8/52)^52 = 121% instead of 80%. At the limit, you have continuous compounding, or e^R – 1. In that case, the effective APY = e^(0.8) -1 = 122.5%. Of course, this assumes 0 gas fees (which can be significant).

Compounding with Gas Fees

In a frictionless world, the more often you compound the better (with the limit being continuous). However, most DeFi chains (like ETH) have semi-fixed gas fees. Each “compound” will cost you some fixed amount of gas. Therefore, if you are farming with large amounts of money, this fixed cost (as a relative percentage) becomes much smaller. However, if you are farming with only a tiny amount, compounding could become cost-prohibitive. We can then model out the returns as follows:

Formula - Effective APY - Compounding with Gas Fees

Note, that depending on your asset base and the fixed fee, you might end up negative even with a high APY! Going through some scenarios:

Graph - Asset Growth when Compounding with Gas Fees

Above, we see the asset curves assuming 100% raw APY, $100 in fixed gas and transaction fees, and compounded daily. We see that in such a scenario, you would need at least $50,000 to compound daily. Even then, the effective APY is only 45% (which is less than just NOT compounding at all).

Table - Effective APY with $100 Daily Gas and Transaction Fees

From the table above (and the $100 fixed fee, daily compounding) assumption, we see the thresholds of assets where compounding pays more than not compounding.

In general, anyone looking to farm yield will need to consider the fixed fees and their impact. Obviously, if you are a smaller farmer, you might need to compound way less often (like weekly or even monthly).

Variable Short-Term Interest Rates

Most defi platforms do not have fixed interest rates. A fixed interest rate means that you can guarantee some APY over some period. Instead, the APYs are constantly changing in crypto. For lending platforms, the short-term rates can change rapidly depending on how much of an asset is borrowed for collateral. For LP farming pools, the rewards are generally a fixed quantity of tokens. This means that as the number of assets in the liquidity pool increases, you will receive a smaller share of the fixed rewards. How do we account for variable interest rates?

Without compounding, we can simply add up expected APYs. For example, if we think the first month APY will be 100%, the second month APY will be 50%, and then the terminal APY at 15%, we can simply add these figures linearly.

In this case, annual APY = (1 * 1/12 + 0.5 * 1/12 + 0.15 * 10/12) = 0.25 (or 25%)

With compounding, the above example would be:

Annual APY = (1 + 1 * 1/12)^(1) * (1 + 0.5 * 1/12)^(1) * (1 + 0.15 * 1/12)^(10) - 1 = 0.2777 (27.8%)

Note, that this APY difference between compounding and not compounding is not huge in this case because the APYs are low (ie, the difference would be much larger with APYs > 100%).

APYs with Price Risk + Impermanent Loss

Yield farming (especially if you are NOT yield farming stable-coins) is not riskless. Probably the biggest risk is going to be price risk of holding at least one risky asset (for example, ETH in an ETH + USD pool). If you are providing liquidity in two risky assets (for example, AAVE + ETH) this risk is amplified.

Let us assume the base case of only one risky asset. Let us define M as the multiple change of the risky asset relative to the safe asset. For example, if ETH is down 20% vs USD, then M would be 0.8. If it was up 20% vs the risky asset, then M would be 1.2.

Total Portfolio Impact (vs safe asset) = (M * 0.5 + 0.5) * (1 + IL) - 1,

where we define IL by the formula:

Drixx impermanent loss formula

So, let us say that ETH lost 50% relative to the safe asset. What would the overall portfolio value be relative to only the safe asset (USD)?

IL = 2 * sqrt(0.5)/(1+0.5) – 1 = -0.0572 Portfolio Impact = (0.5 * 0.5 + 0.5) * (1 - 0.0572) – 1= 0.707 – 1 = -0.292 (or ~-29%).

A loss of 29% would require 1/(1 – 0.29) – 1 = 41% APY over 1 year to recover from.

When farming a pool, it is important to run scenario analysis on what could happen to the price of the risky asset (if you did not actually want to hold the risky asset). If you wanted to hold the risky asset, it is important to consider the risk of impermanent loss. If a large loss is taken immediately, it could take an entire year to recover (especially if it is a 2 risky asset pool). In addition, you will be exposed to further price risk.

In general, depending on how conservative you are, you might also need to haircut your entire portfolio by some margin (to account for actual fraud). So, if you are farming 10 different pools, and one of them is hacked / fraudulent, you will lose 10% of your money. The more pools you are farming, the less lumpy this risk becomes (if you have all your eggs in one basket, the loss risk could be 100% of principal!).

In Summary

Yield farming in DeFi can be very lucrative. However, there are numerous considerations and risks. These risks can be modeled and analyzed using a combination of the formulas above as building blocks. Of course, yield farming can be daunting for someone new to DeFi. Drixx Yield does all this optimization for you while minimizing the risk of principal loss (though carefully diversifying yield opportunities and the use of an insurance fund).

Disclaimer: The information presented here is for educational purposes only and should not be construed as investment advice. Cryptocurrency trading involves high risk. Drixx will always strive to do it’s best in educating customers and providing high quality products but will not be held responsible for their trading and investment decisions, losses or profits.