what is yield farming?

Decentralized Finance (DeFi) has erupted into a ~$90 billion industry, sparking a wave of global disruption. One of the catalysts for this exponential growth is an ROI-optimizing strategy called “yield farming” – a way to make or generate returns on your crypto assets by putting them to work. 

Work? Where? How?

To understand yield farming, you have to first understand a few key terms:

  1. What does yield mean and APY
  2. How does yield farming work?
  3. What liquidity pools are and how do they work?
  4. Risks

In this guide, we will explain it all.

What is Yield Farming?

Yield farming comprises two words: 

1. “Yield” is what you get for investing.

2. “Farming” represents the possible exponential growth that you can receive by finding the right place to invest.

To put it into perspective: when you deposit your money into a bank account, the bank pays you interest. For example, most banks in the US pay $1 on every $1000 deposited. The dollar that you get for investing $1000 in your bank is the yield. Now, you can take that $1000, lock it into a fixed deposit for a specific period, and earn 3.5% on your investment. Or, you can use the same $1000 in a different investment scheme. 

This is called “farming”, which is finding the best strategies to optimize your investment returns. 

In the DeFi world, yields are a lot better than what the traditional financial institutions offer, primarily because no mediator exists that can eat up the earned interest. All a user needs to do is lend crypto assets to the most optimized spots so that it can earn you even more free crypto, usually in the form of additional governance or LP tokens. 

 

What is APY or APR? 

Yield farming returns are typically calculated annualized, which is an estimate of the return you can expect over a year. 

The most commonly used metrics for Yield Farming are Annual Percentage Yield (APY) and Annual Percentage Rate (APR). While APY takes the effect of compounding into account, APR doesn’t. Compounding here is referred to as directly reinvesting profits to generate more returns. 

However, keep two things in mind: 1) many protocols use both APR and APY interchangeably, and 2) these metrics are only an estimate or projection of what you can earn in a year.

How Does Yield Farming Work?

In many cases, yield farming works with liquidity providers that deposit funds to liquidity pools (LPs). 

What are liquidity pools (LPs) and liquidity providers?

Liquidity is a term that refers to how easily you can convert your cryptocurrencies to cash (or other crypto assets) without hurting the market price. For example, a highly liquid market would let you sell $100,000 worth of crypto at one price. Whereas an illiquid market would not have enough buy orders at one price to fill $100,000. Instead, your $100,000 sell order would break down to different buy orders on the order book, lowering the price. This is called slippage and is expected to an extent, but the more liquid a market, the more efficient it is and easy to buy or sell. 

On a centralized exchange like Coinbase, buyers or sellers provide liquidity by placing orders. Buyers state the price for which they are willing to buy a cryptocurrency, and sellers state the price for which they want to sell that cryptocurrency. Coinbase prepares an order sheet, matches buyers’ prices with sellers’ and facilitates the trade. 

But, in a decentralized exchange (DEX) like Uniswap, there is not an order matching engine connecting buyers and sellers each second, mainly because Ethereum’s layer 1 cannot support this transaction load.

It’s done through the help of liquidity pools. 

Liquidity pools are smart contracts that contain two cryptocurrencies to help facilitate transactions quickly and effortlessly. They are pre-funded. Therefore, for the buyer to buy, there need not have to be a seller at that particular moment, only sufficient liquidity in the pool. The underlying smart contract of the liquidity pool manages the trade automatically, without any human intervention. 

However, the liquidity has to come from somewhere. It comes from Liquidity Providers (LPs) who deposit liquidity (in the form of crypto assets) in a pool to create a market.

How do liquidity pools work?

Liquidity pools use the constant product formula (x*y = k ) to mathematically determine the market price of a token in that pool. 

While x and y represent the token balance of a pair, k is a constant that doesn’t change in value. Let’s use the USDT-ETH pool as an example to find the price of a token. 

Say the USDT-ETH pool has 10 ETH and 1,000 USDT, and the current value of ETH is $100 and USDT is $1. Now, if you want to buy 2 ETH, let’s see how much USDT you would have to pay in this pool. 

x*y = k

x = ETH , y = USDT

Total Pool Value: ETH * USDT

: 10 * 1,000 = 10,000

Now, you want to buy 2 ETH from the pool. 

(10-2)ETH * (1000+y)USDT = 10,000

(8)ETH * (1000+y)USDT = 10,000

(1000+y)USDT = 10,000/8

(1000 +y)USDT = 1250

y(USDT) = 1250 – 1000

y (USDT) = 250

When you buy 2 ETH, you are essentially withdrawing 2 ETH out of the pool and depositing some USDT into the pool. So, ETH(x) would decrease and USDT(y) would increase. 

The smart contract automatically computes y to determine the price you need to pay, which in this case is $250 for borrowing 2 ETH. 

After you have made the transaction, the liquidity pool would have 8 ETH and $1250.

This formula is also the foundation of how Automated Market Makers (AMM) work. Uniswap, for example, is an AMM that uses the x*y = k formula to price assets in different liquidity pools. 

How to provide liquidity to a pool?

In the DeFi industry, anyone can become a liquidity provider by adding trading pair tokens into the pool. However, you’d need to add both tokens in a 50:50 ratio. For example,  if you want to add $1000 worth of liquidity to the ETH-USDT pool, you’d need $500 worth of both ETH and USDT. 

Liquidity providers must follow this standard to ensure that the pool always maintains a 50-50 mix of token x and token y. 

Why provide liquidity?

Why would someone provide liquidity to those pools? What is the benefit?

The short answer is “yield farming” The better answer is long. Read on!

Compounding with LP Tokens

When you provide liquidity into a pool, you receive LP tokens in exchange. These tokens act as a receipt, which you can use to claim your original funds. For example, when you provide liquidity to the ETH-USDC pool on Uniswap, you’ll receive ETH-USDC LP tokens, denoting your share of the pool. You will find these tokens in the wallet you used while providing liquidity. If you don’t, you might need to add the smart contract address of the LP token to your wallet. You can perform three activities with these tokens: 

  • Use them to retrieve your deposit and the interest earned.
  • Use them as collateral in a loan – LP tokens provide ownership of an underlying asset, thereby allowing you to use them as collateral. However, to make sense of it, we must first understand how borrowing happens in DeFi:

When it comes to borrowing crypto, all loans are overcollateralized. It means if you want to take a loan, you must provide more money than the loan is worth. For example, if you want to take out $1k worth of USDC, you must deposit $1500 (depending upon the protocol) worth of ETH. This may sound surprising but it’s the only way (as of now) that protocols like Compound ensure that the borrower always repays the loan. 

In this case, you can use your LP tokens as collateral to get a loan. What you can do with this loan is explained later in Leveraged Lending!

  • Use them to compound your yield – A popular way to farm yield with LP tokens is by depositing them in a yield compounder. These protocols regularly harvest rewards for you and even purchase more of the token pair, which are staked back in liquidity pools to compound your interest.  

Earn Fee 

Decentralized exchanges charge a fee for each transaction occurring on the platform. Uniswap, for example, charges 0.3% on each transaction. Instead of keeping these fees, the exchange divides them among the liquidity providers, proportional to their shares of liquidity. 

To simplify it, let’s say:

  • You deposit $1000 worth of ETH and USDC into a $100k worth of ETH-USDC pool. Therefore, you own a 1% share of that pool.
  • If in a single day, $1 million gets traded back and forth on Uniswap between ETH and USDC, the platform makes $300k worth of fees (as per 0.3%/transaction).
  • Since you own 1% of the pool, you’ll make $30 per day for adding $1k on Uniswap.

The $30 you earn is the yield that you earn for providing liquidity or for being an LP on Uniswap. 

Leveraged Lending 

It’s popularly known as “lending on steroids” because users can leverage one token to receive a loan of another token and then use that borrowed token to farm yield. Not only do you earn interest on the tokens provided as liquidity, but can also use the borrowed tokens to reinvest and farm more yield. Sounds confusing? 

To simplify it,

  • Suppose Compound offers 20% APY on ETH deposits, and you have $10k ETH in your wallet. 
  • You deposit it into Compound and take $8k worth of loan in USDC. 
  • You go to a decentralized exchange, swap those USDC with (say)$8k worth of ETH, and resupply it back to the Compound protocol. 
  • So, let’s say you get $8k worth of ETH, which when deposited for another loan would give you $5k worth of USDC. 
  • You can repeat the process, buy more ETH, and redeposit it. By the end of three iterations, you’ll have almost $23k worth of ETH earning you 30% APY. 
  • The important part to learn is that you only initially had $10k, but now you are earning 30% interest on $23k worth of assets. 

Get Governance Tokens as rewards (liquidity mining)

Governance tokens give their holders the right to vote on changes or issues that govern the operations or development of the issuing protocol. Instead of putting these tokens in the market, most protocols give them as a reward to users who put their tokens into a liquidity pool, distributed proportionally to their share of the pool. 

In some cases, you will be able to deposit governance tokens into another pool to earn a return. In other cases, you can use them to put forward a formal governance proposal.

 

Risks in Yield Farming

While Yield Farming is one of the ways to earn high rewards, it is a high-risk adventure that has several pitfalls. For DeFi to grow and for an investor to avoid losses, we must understand various risks associated with Yield Farming. 

  1. Impermanent Loss: As discussed earlier, LPs provide liquidity to liquidity pools. During this time, if the assets go up or down in value, the impermanent loss takes place. Let’s understand it with an example:

Suppose you deposit 10 ETH and 10k USDC in a liquidity pool. Since the deposited token pair needs to be equivalent, it means that the price of 1 ETH is 1000 USDC. Let’s say that you deposit it into a pool that has a total asset value of 100,000 USDC (50 ETH and 50 USDT), which means your share in the pool is 20% (10 ETH and 10k USDC). 

Now, suppose that the price of ETH increases to 2000 USDC. When it happens, arbitrators will remove ETH and add more USDC to the pool to match the price ratio. Therefore, the pool will now have 35 ETH and 70,710 USDC. Since you are entitled to a 20% share of the pool, you can withdraw 7 ETH and 14,142 USDC, totaling 28,142 USDC. That’s a nice profit! But, what if you would have simply held your 10 ETH and 10k USDC? You would have made $30k USDC. 

*Formulas are taken from Amarpreet Singh .

It shows that you could have been better off by holding your assets rather than adding them to a liquidity pool. This is what we call impermanent loss.  

 

2. Smart Contract Risks: DeFi is open to everyone, meaning everyone can create a DeFi smart contract and deploy it on a blockchain. Since anyone can develop, it increases the risks of bugs in a protocol. Though various projects audit their smart contracts before deploying them, vulnerabilities are discovered from time to time. Due to the immutability of blockchains, a broken smart contract can lead to a loss of funds. 

3.Composability: One of the biggest advantages of DeFi, composability, is also one of its greatest risks. We talked about LP tokens and how we can use them to farm yield on other protocols. That’s the beauty of DeFi; protocols can seamlessly integrate. But, it’s also a problem. What if one of the protocols fails? All those dependent on it will suffer. This poses a great risk to yield farmers who not only have to trust the protocol they are providing liquidity to but also others that it relies on. 

Ending Thoughts

This concept of lending for interest has been around for as long as banks have existed. Yield Farming is an improved version that presents an excellent opportunity for investors to make a profit (in the form of new crypto) by lending their assets. 

While it’s possible to make high returns by staking or providing liquidity, doing so is highly risky, especially if you are new to the industry. Plus, due to the open nature of DeFi, there is no way to regulate protocols that offer the Yield Farming opportunity. Therefore, if you fall into any of the pitfalls of Yield Farming, there is no way to hold someone accountable for the loss. 

However, these risks can be managed if individuals gain enough knowledge, evaluate risks, and conduct their research before experimenting with protocols that allow them to farm yield. Nonetheless, it all boils down to a perfectly balanced expression: high rewards often come with high risks. 

If you find it interesting, please check out our blog section, which has both DIY and educational blogs.