A Guide to Yield Farming on Ethereum

A Guide to Yield Farming on Ethereum
Yield Farming
Yield farming is an innovative new way to earn passive income using the Ethereum blockchain. The phrase became widely popularized following the distribution of the Compound Finance governance token (COMP), which saw investors earn Annual Percentage Yields (APY) in excess of 100%.
The extraordinary returns on investment that can be earned via yield farming are borne from a variety of factors, not least the associated risk. That said, with a good understanding of yield farming and Ethereum, it is possible for investors to capitalize on this rapidly growing income and capital growth strategy while minimizing one’s exposure to risk. This guide attempts to explain what yield farming is, how to effectively farm yields and the risks involved along the way.
A Guide to Yield Farming on Ethereum
An Introduction to Decentralized Finance
Before we can delve into the concept of yield farming, we must first understand the basics of decentralized finance (DeFi).
DeFi is a catch-all term for financial products that operate on Ethereum. These products have their logic written into code (“smart contracts”) and this code lives on the Ethereum blockchain. The Ethereum blockchain itself is distributed among thousands of nodes, each keeping a record of not only the state of the network (who owns what) but also the code.
The blockchain is then secured by consensus, meaning that nodes cannot arbitrarily change the state of the blockchain or inject malicious code to move funds into their own pocket. The decentralized aspect of DeFi is therefore revolutionary for financial applications, allowing users from anywhere in the world to lend, borrow, trade and more with enormous freedom.
While smart contracts can be used to express all manner of computations, financial applications were one of the first to harness the Ethereum blockchain. These applications have been under development since 2016 and now, several years later, their value is being realized at scale. Sometimes described as “money lego”, decentralized finance is permissionless by nature, meaning that financial applications can be built, connected and leveraged without restriction.
A Guide to Yield Farming on Ethereum
What is Yield Farming?
Yield farming is the accrual of interest through the use of decentralized financial applications, often as a reward for providing liquidity to a platform. Returns in yield farming are typically made up of exchange/platform fees and interest (i.e lending) although capital growth of the underlying asset/rewards are commonly taken into account.
Yield farming is often a managed process, with “farmers” moving from one protocol to another to maximize their returns at any given time, although “set and forget” strategies are also viable.
To explain yield farming more clearly, let’s look at one of the simplest ways to farm yield on Ethereum.
Uniswap
Uniswap is an Automated Market Maker (AMM) that allows users to swap between two different cryptocurrencies i.e. KNC-ETH, SNX-DAI and so on. Each swap (trade) on Uniswap is charged a 0.3% fee that is passed onto the liquidity providers (LPs).
What is a liquidity provider?
A liquidity provider is someone who provides assets (liquidity) to a pool of funds. In the case of Uniswap, each pool relates to a market pair such as KNC-ETH. The more liquidity provided to a pool, the less slippage there is on a trade and the better the price discovery (thanks to profit-making arbitrageurs).
By providing liquidity to Uniswap, the LP is rewarded by receiving a share of the fees earned in that pool proportional to the liquidity provided.
This is one of the simplest and lowest risk forms of yield farming on Ethereum.
Rewards
Liquidity is the life blood of any DeFi application; more liquidity leads to more users which in turn leads to more liquidity and so on. The importance of liquidity and the challenge of acquiring it resulted in a unique incentive structure that was popularized by Compound Finance in June 2020.
Compound’s COMP token, which grants the holder voting rights in the protocol, was issued to those that used the platform to borrow and/or lend crypto assets.
In the first few weeks of distribution, the price of COMP soared from $60 to $330, earning COMP farmers an APY that exceeded 100% at the time.
This bootstrapping of liquidity has been applied to other protocols including Balancer and Curve Finance, with more financial products likely to follow suit.
The challenge for yield farmers is in determining the expected value of these token rewards and allocating their liquidity in a way that optimizes returns.
Various tools have been developed in order to help assess these returns:
- Calculating “return on liquidity” at Predictions Exchange
- Calculating leveraged COMP returns on InstaDapp
Leverage
It is possible to leverage a position to earn a greater yield (at greater risk). For instance, borrowing tokens on Compound and depositing them into a Balancer pool may be a profitable exercise if the fees and rewards from Balancer exceed the interest paid on the Compound loan.
Leverage was most widely used in the COMP token distribution, as users were awarded COMP for both borrowing and lending on the Compound platform. This led users to adopt the following strategy:
- Supply (lend) USDC
- Borrow USDT against supplied USDC
- Swap USDT to USDC
- Supply (lend) USDC
- Borrow USDT against newly supplied USDC
And so on. With this strategy, users were able to leverage their positions multiple times over, achieving as much as 30x the COMP return they would have otherwise had by just depositing USDC in step one.
This particular loop was closed by a Compound governance vote as it introduce significant risk to the platform and – in many ways – violated the spirit of the distribution. The tactic was later applied to Basic Attention Token (BAT) before the loop was again closed.
Other forms of leverage are available for yield farming, however it is not without its risks. You can read more about the risks in the Risks section below.
Stacking Yields
When providing liquidity to a DeFi platform the user is often issued a token representing their stake in the pool. This new token can then be staked in other platforms to generate yet further yields. This concept is best explained with a real-world example. Below we look at how the Synthetix, Curve, Ren and Balancer platforms were used to generate yields from a single source of liquidity.
First, let’s look at the platforms involved:
- Curve
- Balancer
- Ren
- Synthetix
The flow of this farm is relatively straightforward, although it looks enormously complex at first.
1. Provide sBTC, renBTC and/or WBTC to the BTC Curve liquidity pool
This is the first step and the backbone of this strategy. Curve benefits by having a liquid pool that allows users to swap between the various types of BTC on Ethereum (BTCe). renBTC, sBTC and WBTC benefit by having greater liquidity for their tokens and the network effects that come with it. The user benefits by being rewarded CRV tokens and pool swap fees.
When adding liquidity to the pool, the user receives Curve LP tokens that are a claim on the supplied liquidity.
Rewards: CRV, pool fees
2. Staking Curve LP Tokens
With liquidity now provided to Curve, the Curve LP tokens can then be staked on Synthetix. The purpose of staking Curve LP tokens is to provide proof of your deposit in the sBTC Curve pool. This then distributes the appropriate REN and SNX to the staker’s address.
Rewards: REN, SNX
3. Balancer
This step operates behind the scenes and doesn’t require any use input.
A Balancer pool for SNX and REN was set up by their respective teams and was used as the source for the rewards paid out in step 2. These rewards are paid in Balancer BPT tokens that can be used to redeem the earned SNX and REN from the Balancer pool.
BPT tokens also collect BAL rewards.
Rewards: BAL
While the process seems long-winded, it can all be managed in the Curve and Synthetix user interfaces.
A Guide to Yield Farming on Ethereum
What is the return on investment?
The return on investment falls into three categories
- Transaction fee income
- Token rewards
- Capital growth
Transaction fee income
Transaction fees vary between protocols and pools. In the case of Balancer, the fee is set by the user at the pool creation stage and can vary between 0.001% and 10%. Other pools such as Uniswap charge a flat fee (0.03%).
Currently, all fees are passed onto liquidity providers, however in the future it is likely that governance token holders will receive a portion of the proceeds.
Token rewards
Token rewards are used as an incentive to provide liquidity but are not always available. These rewards are typically distributed over a set period of time whether it’s weeks, months or even years.
The tokens rewarded are often used for governing the system, either at the time of issuance or at some point in the future. These tokens can be traded on decentralized exchanges and some centralized exchanges like Coinbase.
Capital growth
Capital growth (or the lack thereof) makes calculating the profitability of any given yield farming opportunity challenging.
In some cases, the rewards, fees and assets supplied may be in the form of stablecoins. In this instance, there is no capital growth and calculating income is a lot more straightforward.
However, in the majority of cases, speculative assets join the mix and their appreciation or depreciation can make or break the yield.
Taking the BTCe example given above; this yield farming strategy provides exposure to BTC, REN, SNX and CRV. These assets are volatile and can move without correlation.
It is wise, therefore, to adopt yield farming strategies that align with a positive future outlook for the tokens involved. Alternatively, those looking to avoid token volatility entirely can opt for yield farming strategies that are exposed only to stablecoins.
Capital growth is also hindered by the concept of impermanent loss; a type of opportunity cost that can – in some instances – leave AMM liquidity providers with less than what they would have had if they just held.
Learn more about Impermanent Loss.
A Guide to Yield Farming on Ethereum
What to Consider Before Farming Yield
Misleading APY
Annual percentage yield can be extremely misleading in the short term. In some instances, APYs may be advertised in the hundreds of percent. These yields take into account the value of the fees and tokens rewarded. In instances where the token rewards experience a short and sharp bubble (as was seen with COMP quickly moving from $60 to $330), yields can be misleading.
Liquidity provision can be fickle; users are able to move their liquidity from one place to another, hunting out the best possible return at the time. This means that the APY of a certain strategy can shift dramatically day to day.
Price volatility
When determining a strategy, price volatility of the underlying assets should be considered. If an asset is providing a high APY but is considered to be one that may see massive capital losses, the strategy is likely to be unfavorable. Equally, this can work in the other direction. In the case of the COMP distribution, yield farmers were most excited by their ability to access a token which, they expected, would see significant price appreciation.
Risks
Returns in yield farming are never risk free. The high yields are a reflection of the significant risks taken on by the liquidity provider. These risks include but are not limited to:
- Smart contract risk
- Platform risk
- Oracle risk
- Exchange rate risk
- Black swan
These risks are elaborated on at the bottom of this article.
A Guide to Yield Farming on Ethereum
Tools Needed to Yield Farm
Web3 Wallet
The most important tool for any yield farmer is a web3 wallet that can store funds and interact with the Ethereum blockchain.
Some of the most popular web3 wallets include:
MetMask is an open source Chrome/Firefox extension that displays in-browser prompts whenever interacting with an Ethereum smart contract. It is the most user-friendly and easy to set up wallet, however the wallet is an online or “hot” wallet and is therefore exposed to the associated risks.
MetaMask is great for storing small amounts of funds or for those who are adept at private key management.
Coinbase Wallet is a mobile wallet that works through the scanning of QR codes. Funds are stored in Coinbase which allows for convenience but does add counter-party risk (Coinbase holds your coins). That said, Coinbase has operated for several years without any major incident involving user funds and is generally trusted around the world.
Ledger is a hardware or “cold” wallet that exists offline and is practically unhackable. A Ledger wallet is the preferred option for those looking to yield farm with significant holdings. Unfortunately, the Ledger wallet has a poor user experience when it comes to web3 and it can be a source of confusion for those new to Ethereum.
Blockchain Explorer
Blockchain explorers are essential for following the progress and completion of any given transaction on the Ethereum network. Explorers also provide information about address balances as well as a detailed breakdown for each transaction.
Advanced users can even use blockchain explorers like Etherscan to read and audit smart contract code as well as execute particular smart contract functions.
ETH Gas Station
When transacting on the Ethereum blockchain a gas fee must be paid. Gas fees increase with smart contract complexity and given that many of the yield farming strategies call functions that are fairly complex, gas fees can be high.
The actual dollar amount paid for each transaction comes down to 2 factors:
- Gas price (gwei)
- Gas limit (total gas needed to “fuel” the smart contract)
ethgasstation.info provides critical information about what gas price to set for varying time preferences. The gas limit is calculated by your web3 wallet and should (unless an advanced user) be left as is. Any gas that is not used in the transaction is returned to your wallet.
Tracking Tools
Tools for tracking the ROI for any given yield strategy are few and far between with the most common being a simple Excel spreadsheet that is updated manually from time to time.
As and when official tools become available (and no doubt they will) this section will be updated.
In the meantime, some community-built tools have been created for specific projects. You can discover more about these tools by using any of the resources listed towards the end of this article.
A Guide to Yield Farming on Ethereum
What is Liquidity Mining?
The term “liquidity mining” was originally coined by Hummingbot to describe the rewards paid to users for providing liquidity to centralized exchanges.
Liquidity mining continues to have a similar meaning, however it has now been co-opted by the DeFi community to describe the rewards paid out by any of the various DeFi applications.
Liquidity mining is a subset of yield farming, where the “mined” liquidity is considered part of the yield (along with exchange fees and other interest payments).
The term “mining” is used purely for its association with crypto (Bitcoin and Ethereum miners are paid block rewards for finding blocks) and does not involve any specialized software or hardware.
A Guide to Yield Farming on Ethereum
Non-exhaustive List of Risks
Smart contract risk
Smart contract code is immutable and operates exactly as specified. However for this reason, if a smart contract has been poorly written, it can be exploited without recourse. While exploits like these are uncommon, they do happen and happen they will.
With the expansion of the DeFi space and the enormous volume of liquidity being poured into applications thanks to yield farming, the incentive for bad actors to exploit smart contracts is ever-increasing.
The most famous exploit of a smart contract was in The DAO hack of 2016, where the now famous “re-entrancy attack” was observed for the first time.
The risk of poorly written contract code is mitigated somewhat by smart contract auditors of which there are now dozens. Audits do not guarantee security, but they do provide additional due diligence that can provide some reassurance. Some of the main players in the smart contract auditing space include:
- Trail of Bits
- Zeppelin
- Quantstamp
- Consensys
Platform Risk
The Ethereum blockchain itself has never been hacked, however the risk remains. Ethereum is ultimately an enormous experiment – a fact that is often forgotten when billions of dollars flow through its network each year.
Ethereum, unlike Bitcoin, regularly introduces network upgrades that aim to reduce gas costs, increase throughput or introduce features that support developers. While these upgrades are thoroughly reviewed and vetted, the introduction of a bug is not outside the realms of possibility.
Oracle risk
Oracles provide data to smart contracts that is then used in the execution of functions. Price feeds are one of the critical pieces of infrastructure in decentralized finance and their failure or exploitation can lead to negative outcomes for users and platforms.
DeFi project, bZx, famously suffered from an oracle attack with the hackers stealing some 630,000 ETH.
Chainlink and other decentralized oracle networks are helping to mitigate this risk.
Exchange rate and liquidation risk
The assets used for yield farming are often highly volatile. This volatility can lead to large capital losses over the period that someone wishes to farm yield. While assets are never “locked” and can always be withdrawn by the user, it does add friction to the process if an asset needs to be sold quickly.
Exchange rates can also impact the viability of a position in DeFi. For instance, in the borrowing and lending platform, Compound, a user farming COMP may find that their position is liquidated as the collateral used for borrowing falls too far in value.
Black swan
As was seen following the coronavirus outbreak, significant global events can see their impact tear through the cryptocurrency markets without warning. Such market crashes can lead to strange behavior among decentralized finance applications, whose price oracles – in the case of March 2020 – were not able to keep up with the rate at which assets were being devalued. This led to one major exploit in the MakerDAO system that saw an attacker siphon thousands of ETH by using an exploit in the protocol’s auction software.
Yield farming on Ethereum can tolerate volatility but it has not been properly battle tested under exceptional market circumstances.
A Guide to Yield Farming on Ethereum
Resources
Further reading and community resources can be found at the following:
Discord Communities
Twitter Accounts
FAQ
Ethereum is currently the only blockchain that can be used for yield farming.
Liquidity mining is a subset of yield farming and describes an incentive structure that rewards liquidity providers with token rewards. Those token rewards are then considered part of the yield (along with exchange fees, interest payments and so on).
Yes, however with current gas fees in the range of $20-$50 on the Ethereum network, farming yields can be prohibitive to those with relatively small amounts. This is expected to change with layer 2 scaling solutions.
The only trust needed for yield farming is in the smart contract code that produces the yield. However, without being able to audit the code yourself (very few can), you must also trust the auditing companies that review the contracts. Still, audits alone cannot guarantee security.
Leave a Reply