What is yield farming
If you have been living inside the crypto hype you probably have heard about yield farming, but what is it and how does it work? Yield farming is, in its essence, that you provide liquidity to a defi protocol in return for yield.
A protocol is often referred to as an application that are built on top of a smart contract platform, Ethereum is the most common one to use. Ethereum is the infrastructure that enables the protocols to be built on top of it. To illustrate what this really is we can use internet as an example, Ethereum is the internet and protocols are the websites with the UI built on top of it.
The terminology “yield farming” is more related to those who actively seek out the highest yield in different protocols. So, if for instance you just provide liquidity to a protocol without the notion of seeking the highest yield you would not necessarily be farming, but the terminology here is not that important. What's most important here is to illustrate how it works.
To close in on the functionality, the most promising way is to start with an example, let’s dig deeper into a decentralized exchange. Providing liquidity to a pool inside a decentralized exchange such as Uniswap, is one example of yield farming. You as the yield farmer provide liquidity by deposit two tokens — Token A and Token B and in return you collect a proportion of the fees paid by users who use that pool to swap between tokens. Your returns are calculated off the percentage of the pool that your deposit makes up. If your deposit makes up 1% of the pool’s depth, you are eligible to collect 1% of the total fees generated by that pool. To be clear every transaction has a small transaction fee attached to them. However, the smaller the pool, the higher the reward but also, the higher the risk. Talking about risks, what are they? One of the more prominent risks with Yield farming is impermanent loss.
What is Impermanent loss? If we take the pool of Ethereum and DAI for an example, DAI is a stablecoin, so its value is pegged to a fiat currency, in this example the US dollar, so the value should hover around parity with it. But Ethereum has unlimited upside potential as well as downside. As Ethereum appreciates in value, the AMM (automated market maker) or in the example above, a decentralized exchange, adjusts the ratio of the depositor’s two assets to ensure that the value of the two remains constant. It is important that the two assets in the pool have equal value. This is where impermanent loss can occur.
Okay, how can we explain this in a way that makes it “easy” to understand? I think the best way is to provide an example and illustrate it with numbers. If you choose to yield farm by supplying liquidity to a pool you are entitled to support a ration of 50/50 for booth of the currencies inside of that pool. If for example you provide 1 ETH and 100 DAI, (1 ETH is worth 100$ and 1 DAI is worth 1$). Let say that the pool has 1000$ in total liquidity, you will have 10% of the share, you will then be eligible to withdraw 10% of the pool. The ratio of 50/50 is always matched in the pool. If the price of ETH increases by 100%, now worth $200 per ETH, the value of the pool would increase accordingly. The liquidity pool would have changed to 7.071 ETH and 1,414.21 DAI= 2828$. This is because the ratio of the pool has changed, it is no longer 50/50, which affected the price of ETH. Here will arbitrageurs act to buy some cheap ETH and govern the pool so it contains its 50/50 value.
Since you, the liquidity provider has a 10% share of the liquidity pool, you can withdraw 0.7071 ETH and 141 DAI which equals $282. However, if you simply had held your 1 ETH and 100 DAI, they would be worth $300. The difference between the two, $18, is the amount of impermanent loss that you would have experienced. A greater change in the ratio of the pool will result in a larger amount of impermanent loss.
So in conclusion, Yield farming can be risky, but it can also generate a high interest on your money, if you are conscious.