An Introduction to Yield Farming

GreenField
11 min readFeb 1, 2023

--

Preface

This article will provide a deepdive into yield farming, with a focus on liquidity providing on Decentralised Exchanges (DEX). The first section will provide a quick overview of the DeFi market, explain the difference between centralized- and decentralized exchanges, and explain the different types of incentives that make-up the yield of yield farms. In the penultimate section the concept of ‘Impermanent Loss’ will be explained by exploring a strategy that is currently available. In the final section we will explore how to farm during the bearmarket by including perpetual futures into a farming strategy.

Total Value Locked in DeFi 2021–2023 (source: Stelarium.io)

The emergence of DeFi

One of the promises of the blockchain has been to provide individuals with the tools to participate in the financial system without being reliant on centralised parties in the legacy financial system. While Bitcoin has proven that blockchains are excellent tools for the transfer ofvalue, it lacks the smart contract capabilities to develop decentralised alternatives to exchanges, loans and financial derivatives. After the launch of the Ethereum network and its Ethereum Virtual Machine (EVM) in 2015, several teams started experimenting with projects that have provided the foundation of the DeFi landscape we currently know and love. Projects like MakerDAO, Uniswap and AAVE have build a toolkit of financial instruments that have opened up a decentralised system that rivals the legacy financial system.

From Centralised- to Decentralised Echange

The most common way to trade cryptocurrency is by using a centralized exchange(CEX) like Binance, Kraken or Coinbase. The permissioned nature of a CEX provides users witha great user experience for storing, and exchanging cryprocurrencies, but also has several downsides. For example, the collapse of exchanges like Mt. Gox and FTX have shown the risks of storing coins on centralised exchanges. On top of the security risk users also run the risk of being excluded by the exchange based on their identity or nationallity.
To mittigate these risk users can also decide to store their assets on a non-custodial hardware wallet, and trade their assets on a Decentralised Exchange(DEX). Decentralised exchanges consist of various smart contracts that encode the mechanics needed to facilitate trading of cryptocurrencies. The majority of decentralised exchanges are based on the Automated Market Making (AMM) model populairised by Uniswap. The AMM model allows users to trade assets trough the use of a liquidity pool. A liquidity pool usually consists of two different crypto assets (e.g. Ethereum and USDC) allowing users to freely exchange between the assets in the pool. Users can also provide liquidity to this pool to facilitate trading. The pool is regulated by the formula: x * y = k. This formula maintains that the total value of one token in a Uniswap liquidity pool must always equal the total value of the other token in the pool. Maintaining the equal value relationship between the token pair is the basis of the automated pricing mechanism.

An Introduction To Yield Farming

Users that are willing to provide utility to an AMM can earn different forms of yield. Namely, trading fees, protocol tokens and ecosystem incentives.

Fee-sharing

The majority of DeFi platforms charge fees to use their service. For example, decentralised exchanges usually charge 0.3% for trades on their platform. The majority of this fee is used to incentivise the liquidity providers that provide their capital to facilitate trading.

Protocol tokens

On top of fee-sharing the majority of Lending Markets and Decentralised Exchanges (Dex) started issuing protocol tokens to further incentivise users to provide liquidity to their project. For example, when Sushiswap launched their exchange in 2020 they rewarded liquidity providers with their $SUSHI token to incentivise them to migratetheir liquidity from their competitor Uniswap. The inclusion of $SUSHI rewards was so succesfull that Sushiswap was able to attract over 150.000.000,00$ in the hours after the protocol was launched. The introduction of these so called Liquidity Mining rewards resulted in an exponential growth of protocols and resulted in the first DeFi boom of 2020.

Example of a Blockchains’ (KAVA) incentive program (Source: kava.io)

Ecosystem incentives

In 2021 the third layer of incentives was introduced by the various new blockchains that tried to gain marketshare from the established Ethereum ecosystem. In Januari of 2022 Polygon announced a $15M incentive program for liquidity providers on Uniswap. Resulting in a massive migration of TVL towards Polygon. The success of this program triggered competitors to launch similar programs. And so, in March, Avalanche announced their multiyear incentive program of 4m AVAX tokens with a value of $290M at the time of the announcmenet. In the following months the majority of new blockchains launched similar programs to attract liquidity, like the $750M ‘Developer Incentive Program’ on the Kava blockchain.

Yield Farming & Impermanent Loss

In the first section of this article we have explained the concept of liquidity providing, and the various incentives that are used to reward liquidity providers. In the following section we will explore a real-world example, and the impact of Impermanent loss on the profitabillity of the strategy. In the remainder of the article we will explore the USDC-ETH pool on Velodrome, a decentralised exchange on Optimism. Velodrome is able to provide an APR of 13% because they: 1) share their fees 2) get $OP incentives from the foundation incentive program, and 3) issue $VELO tokens as a reward for providing liquidity.

Impermanent Loss

Providing Liquidity to Velodrome currently yields 13%, but also carries the risk of Impermanent Loss(IL). The Velodrome USDC-ETH pool requires you to provide two assets with the same value. So, 1000$ in ETH and 1000$ in USDC. Whenthe price of ETH changes people will trade USDC for ETH and change the total amount of ETH in the pool, therefore leaving you with less ETH and more USDC exposure. So the further ETH rises the more your ETH exposure reduces. IL discribes the difference in value between just holding the two assets individually and the shift in exposure due to price changes while providing liquidity. Liquidity providers are rewarded for their risk exposure by getting payed in trading fees, and incentives. Ideally, these fees will outway the losses incurred by the shift in balance of the assets in the pool.

💡 If you are unfamiliar with the concept of Impermanent Loss we highly recommend reading the work of Finematics , or watching the video he produced on the topic.

The exposure to IL scares a lot of people away from providing liquidity, as they overestimate the acutal impact IL has on a farming position. To get a grasp on the impact of IL it is recommended to use a IL-calculator to understand the impact of price changes on the position value. In the case of a pair that combines a volatile asset with a stablecoin (ETH-USDC), you can assume that if ETH either doubles or halves in price, the Impermanent Loss is 5%. So, to account for the risk of Impermanent Loss, yieldfarms should have sufficiently high rewards to compensate for the potential price action of the coins in a pool. As an example, the yield on the Velodrome pool is 13%, so you would gain a 5% return in yield in roughly 4 months. Therefore, if the price of ETH would double in that sametimeframe you would break even on the strategy.

The graph below shows how variations in price can impact the amount of impermanent loss a liquidity provider will experience in a 50/50 pairing. When a token increases 300% in price compared to the other coin in the pool, you can see that the liquidity provider will incur an impermanent loss of approximately 12.5%. This is 12.5% less than the value of the tokens if they were simply held.

Losses to liquidity providers due to price variation (Source: medium.com/coinmonks)

To sidestep the impact of IL on yieldfarming you can also decide to provide liquidity in a liquidity pool with assets that do not deviate in price from each other. For example, providing liquidity in a pool that combines ETH and stETH has no exposure to IL. stETH represents a claim on ETH and therefore tracks the ETH price, thus mittigating the risk of IL for providing liquidity.

Farming in the bear market

During the bear market holding volatile cryptocurrencies is not always desireable. So, most people that are looking to preserve capital decide to convert their crypto into stablecoins. Once people hold stablecoins they usually still want to earn some yield, so they decide to provide liquidity in a stablecoin pool. As a result the yield on stablecoin pools significantly reduces, and the gap between stablepools and non-stablepool widens. For example, the DAI-USDC pool only yields 4,75% compared to the 13% on ETH-USDC. To benefit from the higher yield of the ETH-USDC pool, without having exposure to the price of Ethereum, you can hedge your ETH exposure by shorting the same amount of ETH. To achieve this hedge you can either use a lending market or perpetual futures.

Using perpetual contracts to hedge your exposure

To understand how hedging price exposure actually works we will use the example of the Velodrome ETH-USDC pool. In the following example we assume that ETH trades at a 1000$ price, and we want to provide 2000$ in liquidity to the Velodrome pool. To achieve this we provide 1ETH and 1000$ to the liquidity pool. To negate our ETH exposure we have to short 1 Ethereum. If the price of ETH drops this short position will gain the exact amount value that the ETH in our LP position loses, thus negating the exposure in price.

What is a perpetual contract

The most common way to short ETH is by going short with perpetual contracts(perp) on the price of ETH. These contracts are available on the majority of centralized exchanges. To buy these contracts you have to post collateral, and you can use leverage to improve your capital efficiency (the collateral you post should be considered as part of your LP position to calculate the effective returns of the strategy). In the case of the Velodrome position we have to short 1000$ of ETH. To minimize the chance of getting liquidated we only use 2x leverage, so we transfer 500$ to our preffered exchange, and short the 1000$ of ETH exposure. To ensure we do not get liquidated we have to watch the price of ETH and post more collateral if the price of ETH gets close to 1500$.

Funding rates

To asses if using perpetuals to hedge our position makes sense we also need to consider funding rates. The funding rate is based on the difference between the perp price and the spot price. So in the case of Ethereum our spot price is $1000 dollars, while the perp price depends on the aggregate of long- and short- position. If most traders think the price of ETH will go lower the perp price might trade at 990$ because more traders want to go short compared to long. To ensure that the perp price stays close to the spot price exchanges work with funding rates. If the perp price is below the spot price (indicating more demand for shorts), traders holding the short contracts have to pay the traders holding the long contracts. Depending on what exchange you use there can be differences in funding rates, and the frequency of payments. To check what exchange has the best rates you can use a website like Coinglass.

Funding rate across exchanges for various coins (Source:https://www.coinglass.com/FundingRate)

As of the time of writing you pay 4% a year to short ETH on Deribit. Based on the position size of 1000$ you have to pay 40$ a year to maintain this position. While the Velodrome position will yield 260$ (13% over 2000$). So assuming those rates stay the same over the year you will earn a total of 220$. To achieve the strategy 2500$ of capital was commited. So, the real return is (220/2500)*100= 8.8%, beating out the 4,75% available on the stablecoin pool. It should be noted that funding rates can fluctuate based on market sentiment and should be monitored once a position is opened to ensure the strategy is still profitable.

Liquidity pools and delta hedging

The ETH-USDC strategy discribed in the previous section is an example
of a pseudo delta-neutral strategy. A true delta-neutral strategy, like the ETH-stETH LP, would have zero exposure to price changes in the underlying assets, but our strategy can get exposure to underlying assets due to how liquidity pools rebalance so that both tokens in the pool have the same dollar value.

In the case of our Velodrome example, we started of with 1ETH(1000$) and 1000USDC(1000$). If the price of ETH goes to 1500$, and nobody trades in the liquidity pool the price of ETH would stay at 1000$, so arbitrageurs put USDC into the pool and take out ETH untill the price of ETH in the liquidity pool is in line with the market price. The new equilibrium would be 0.81ETH(1225$) and 1225USDC(1225$).This change in the price of ETH has reduced our eth exposure to 0.81 ETH.

If we account for the fact that we have opened a 1 ETH short position, we now have a net-short position of 0.19 ETH. If the price of ETH keeps rising the strategy can spiral out of control. The further the price of ETH increases the lower your exposure to ETH becomes. Therefore your net-short position grows, and the more you will lose on your ETH short. Therefore it is advisable to either rebalance your position, or close the position. For an overview of the considerations of rebalancing the strategy you can read this article. By closing our position at an ETH price of 1500$, we would end up with 2450$ in LP value. Our short position would get liquidated at the price of 1500$, so we would lose the 500$ we put up as collateral, resulting in a loss of 50$ (2.5%) on the strategy. Accounting for the 8.8% APR of the strategy, we would need to have the position open for almost 4 months to break even.

Strategy assessment

If we account for the potential price action of ETH we can conclude that the risk adjusted return on the USDC-ETH Velodrome pool is inferior to farming a stablecoin pool. ETH exposure should yield at least 20% to offset the potential price-risk of ETH. Compounding the 20% yield mittigates most of the IL risk of the strategy. Finding pools that offer a yield that exceeds 20% requires allot of research and understanding of where to find these protocols, and understanding the risks asociated with using lesser-kown protocols. For example, you should always check if contracts are audited by a reputable firm.

💡DeFi can be a dangerous place, especially if you are unaware of the risks of DeFi. On top of these risks you should also be aware of the ‘wallet risk’. Browsing to a malicous website and signing a transaction can result in all your assets being drained. For the best practices regarding wallet hygene read the following thread.

Conclusion

In this article we have provided an overview of the various sources of yield, and how liquiditiy providing can be a great strategy to benefit from the oppertunity these incentives have to offer. Concepts like Impermanent Loss are hard to truly understand without experiencing it yourself. Even if you are not interested in getting yield on your coins we would encourage anyone to allocate a fraction of their portfolio to yieldfarming, as to get some first-hand experience. This experience can help you understand what the user experience of various protocols are, allowing you to experience the differences between traditional financial services and their DeFi counterparts, and will allow you to make more informed investment decissions for your portfolio.

--

--

GreenField

GreenField FInance is a Yield fund and growth incubator in the Web3 space.