Welcome to whiteboard programming, where we simplify programming with easy-to-understand whiteboard videos and today I’ll be sharing with you what is yield farming in crypto and how is it different from crypto staking. So let’s get started! Well, Yield farming is also known as liquidity mining and is the method of depositing cryptocurrencies into DeFi protocols in order to gain return for rewards which are generally paid in crypto. Examples of this include Compound and Uniswap. Depositing crypto into DeFi pools is known as providing liquidity, making you a liquidity provider.
Further, to help you better understand what is yield farming let’s first get familiar with a few important terminologies:
1. Yield: On its own, the word yield means to produce. For instance, a carrot plant yields carrots at harvest time. In the context of yield farming, the crypto you deposit into DeFi protocols yields a return paid in more crypto.
2. Farming: So, the pools and protocols wherein you provide liquidity are a lot like farms. You plant your seeds (i.e. provide liquidity), then let them grow over time into fruit-bearing plants (which proportionally means allowing your deposited crypto assets time to generate yields or profits).
3. Liquidity: DeFi protocols like Uniswap, Sushi, and Compound are decentralized exchanges that depend on having crypto assets on hand for people buying and selling or borrowing and lending crypto from one another. Liquidity refers to having those assets on hand. The more liquidity a DeFi protocol has, the better price discovery and overall experience it can offer its users.
4. Mining: In the DeFi world, mining has a similar meaning to farming. In relation, it is used when you provide liquidity to earn rewards in the protocols native token (for eg, if you earn COMP by depositing USDC on Compound), you are mining COMP tokens by providing another token the protocol needs (which in this case is USDC).
5. liquidity pool: It’s basically a smart contract that contains funds. As in return for providing liquidity to the pool, Liquidity Providers get a reward, these incentives can be a percentage of transaction fees generated by the underlying DeFi platform, interest from lenders or a governance token
6.Total Value Locked (or TVL): In some sense, TVL is the aggregate liquidity in liquidity pools. It’s a useful index to measure the health of the DeFi and yield farming market as a whole… also, it’s an effective metric to compare the market share of different DeFi protocols. A good place to track TVL is Defi Pulse. You can check which platforms have the highest amount of ETH or other crypto assets locked in DeFi.
This can give you a general idea about the current state of yield farming. Naturally, the more value is locked, the more yield farming may be going on. It’s worth noting that you can measure TVL in ETH, USD, or even BTC wherein each will give you a different outlook for the state of the DeFi money markets. Also, do note that Yield farming is typically done using ERC-20 tokens on Ethereum, and the rewards are usually also a type of ERC-20 token. Further, As long as the yield farming process is active, users will accumulate rewards.
From the perspective of defi platforms and applications, the main objective of yield Farming is to attract liquidity by rewarding investors who are willing to lend their assets. The platform can redistribute those crypto assets to customers who are interested in using their products and services. In the end, a portion of the fees gained from user transactions is used to repay yield Farmers. Since Defi is decentralised, services like yield farming are automated via smart contracts, which means that there’s almost no risk of losing your assets since developers cannot manually steal your crypto or transfer them without your permission.
Next, let’s discuss How does yield farming works? The concept of Yield farming is closely related to a model called automated market maker (or AMM) and typically involves liquidity providers (LPs) and liquidity pools. Let’s see how it works. Liquidity providers deposit funds into a liquidity pool. This pool powers a marketplace where users can lend, borrow, or exchange tokens. The usage of these platforms incurs fees, which are then paid out to liquidity providers according to their share of the liquidity pool. This is the foundation of how an AMM works.
Here, the rules of distribution will all depend on the unique implementation of the protocol. The bottom line is that liquidity providers get a return based on the amount of liquidity they are providing to the pool. Here, the funds deposited are commonly stablecoins pegged to the USD though this isn’t a general requirement. Some of the most common stablecoins used in DeFi are DAI, USDT, USDC, BUSD, and a few others.
Some protocols will mint tokens that represent your deposited coins in the system. For example, if you deposit DAI into Compound, you’ll get DAI or Compound DAI. Similarly, if you deposit ETH to Compound, you’ll get ETH, or compound ether. As you can imagine, there can be many layers of complexity to this. You could deposit your DAI to another protocol that mints the third token to represent your DAI that represents your DAI. And so on, and so on. Like this, these chains can become really complex and hard to follow but yes, if you do it well, you are sure to earn decent profits.
This boils us down to our next question, How are yield farming returns calculated? Typically, the estimated yield farming returns are calculated annualized. This estimates the returns that you could expect over the course of a year. Some commonly used metrics are Annual Percentage Rate (APR) and Annual Percentage Yield (APY). The difference between them is that APR doesn’t take into account the effect of compounding, while APY does. Compounding, in this case, means directly reinvesting profits to generate more returns.
It’s also worth keeping in mind that these are only estimations and projections and in some cases, even short-term rewards are quite difficult to estimate accurately. Why? Yield farming is a highly competitive and fast-paced market, and the rewards can fluctuate rapidly. If a yield farming strategy works for a while, many farmers will jump on the opportunity, and it may stop yielding high returns. Lastly, the exact reward amount is determined by calculating metrics like Annual Percentage Rate (APR) or Annual Percentage Yield (APY) and interest rate that changes along with the pool’s activity and token value.
Due to this fast pace of DeFi, weekly or even daily estimated returns may make more sense than long-term ones. Seems promising, right? Well, it is, but, there are still yield farming risks involved, and they primarily stem from poor smart contract coding practices. If a project isn’t audited or if a team member unintentionally creates an exploitable smart contract, anyone with sufficient technical knowledge can steal your funds. For example, a lending protocol might use its user funds to fund flash loan services and if this flash loan smart contract has an exploitable attack, John, a hacker, can effectively create loans and not repay them.
Millions of dollars can be drained from liquidity pools within minutes. And unless a developer notices the exploit early on, the team will be unable to recover funds, which may result in losing assets that a yield farmer provided initially.
And if you are planning to venture into this, do note that all Yield farmers are constantly exposed to this form of risk. Next, you should also know about something called Impermanent loss, it is another risk unique for yield farming, but in this case, the risk isn’t tied to security, but instead, Impermanent loss occurs when a cryptocurrency suddenly experiences a gigantic spike in volatility.
Here, if the asset rises in value, the yield farmer would have made more money by simply holding the token. Likewise, the loss is also suffered if an investment declines in value because the yield rate is not high enough to offset the losses. You can understand impermanent loss as very similar to the concept of opportunity cost. And although yield farming generates passive income, users who farm must always think about whether it’s a better idea to sell the asset or store it to speculate profitability.
Next, let’s discuss What is collateralization in DeFi? Typically, if you’re borrowing assets, you need to put up collateral to cover your loan. This essentially acts as insurance for your loan. How is this relevant? Well, this depends on what protocol you’re supplying your funds to, but you may need to keep a close eye on your collateralization ratio as well. Because if your collateral’s value falls below the threshold required by the protocol, your collateral may be liquidated on the open market. But hey! What can you do to avoid liquidation? Well, one thing that can be done is to add more collateral.
To reiterate this, each platform will have its own set of rules for this, i.e., its own required collateralization ratio. In addition, the complete concept commonly works with a notion of over-collateralization. This means that borrowers have to deposit more value than they want to borrow. Why? To reduce the risk of violent market crashes liquidating a large amount of collateral in the system. So now, let’s say that the lending protocol you’re using requires a collateralization ratio of 200%. This means that for every 100 USD of value you put in, you can borrow 50 USD.
However, it’s usually safer to add more collateral than required to reduce liquidation risk even more. With that said, many systems will use very high collateralization ratios (which go as high as 750%) to keep the entire platform relatively safe from liquidation risk. Further, some of the most popular Yield farming platforms and protocols that yield farmers use include Compound Finance, MakerDAO, Synthetix, Aave, Uniswap, and Yearn. Finance lastly, let’s discuss the difference between staking and yield farming, Fundamentally, crypto staking involves a validator who locks up their coins in a network and wait to be randomly selected by the Proof of stake (PoS) protocol at specific intervals to create a block.
So, when yield farming and staking are compared side-by-side, staking usually involves investing a good amount of crypto on the network to boost the chances of being selected as the next block validator. And depending on the coin’s maturity, it can take up to a couple of days before the staking rewards come by for collection.
In contrast, yield farmers move the digital assets more actively from time to time to earn new governance tokens or smaller transaction fees. Unlike staking, yield farmers can deposit multiple coins into liquidity pools across several protocols. For example, yield farmers can deposit ETH (Ether) to Compound to mint cETH (Compound Ether), then consecutively deposit it into one to another protocol that mints third and fourth tokens.
So, you can say that compared to staking, yield farming is more complex, and the chains can be hard to follow. And though yield farming has a higher return rate, it is also risker. With that, I hope this video was helpful to you and served value, if you love my content, feel free to smash that like button and if you haven’t already subscribed to my channel, please do as it keeps me motivated and helps me create more content like this for you.