How to Yield Farm on Uniswap and Not Get Rekt

What you need to know to start your career as a Uniswap yield-farmer.

How to Yield Farm on Uniswap and Not Get Rekt

Key Takeaways

  • Liquidity provision isn't a passive strategy for long-term returns
  • Automated market makers use constant function equations to ensure efficiency of pooled capital
  • Oftentimes, Investors can earn a better return by HODLing instead of farming for yields
  • Providing liquidity is a good investment in anticipation of muted volatility

Share this article

Yield farming is back-breaking work. Farmers need to understand the trade-offs to optimize their profits ruthlessly. We lay the groundwork for how DeFi users can ensure they’re making the best returns on their crypto.

Liquidity Provision: A Basic Need for DeFi

New ways of facilitating finance have been accompanied by the rise of DeFi. Centralized exchanges like Binance and Coinbase enable trading through an orderbook. All orders set by traders are put into the orderbook and matched based on a trader’s desired price and the size of the trade.

A new type of exchange has rippled through DeFi—automated market makers (AMMs). Where a traditional exchange needs a market maker to ensure its orderbook is liquid, AMMs pool liquidity from various users and execute it based on a given equation. This equation varies for each AMM.

Anybody can be a liquidity provider on these DEXes. There’s no capital restriction. Adding liquidity to an AMM like Uniswap or Balancer is actually quite simple.

It’s important for people to add liquidity to DeFi’s AMMs, as this gives these DEXes the capability to serve a larger number of customers. Moreover, increased liquidity can attract crypto speculators who trade larger volumes. Right now, the liquidity of DEXes is inadequate for large traders, meaning that working as a liquidity provider is a critical service for these exchanges.

But, becoming a profitable liquidity provider isn’t all that simple. There are certain concepts users should understand before they dive-in. 

How Automated Market Makers Work

To understand liquidity provision, one must first understand how AMMs work. This will get a little complicated, so keep in mind that profitably providing liquidity requires real work and a decent understanding of arithmetic.

Uniswap is the largest AMM, so we’ll start there. Each Uniswap pool has two assets that equally contribute to the pool in a 50-50 allocation. Uniswap’s pools are designed using the equation of X x Y=K.

X is the quantity of the first token, Y is the quantity of the second token, and K is the product of the two, which is to remain constant. This is aptly named the constant product equation.

Let’s say there’s an ETH-USDC liquidity pool with 100 ETH and 20,000 USDC on Uniswap. The constant product is 2,000,000 (100 x 20,000) and the implied price is 200 USDC per ETH.

Somebody wants to buy 10 ETH from the pool; X (amount of ETH) will decrease from 100 to 90. So if K is to remain constant at 2,000,000, Y must increase to 22,222 (2,000,000/90).

The buyer pays 2,222 USDC for 10 ETH, even though the implied price was 2000 USDC for 10 ETH. This extra 222 USDC is called slippage, and it’s the cost a buyer must bear for disrupting one side of the liquidity pool.

At the end of it all, there’s 90 ETH and 22,222 USDC in the pool, implying a price of 247 USDC per ETH. That one trade caused a 23.5% increase in the price of ETH through slippage.

Case Study: How Impermanent Loss Creeps Up

When pressed between two investment options, a rational trader will set emotions aside and choose the more profitable one. Liquidity providers need to stay on their toes if they are to ruthlessly optimize profits.

Consider a LINK-USDC pool on Jan. 1, 2020. The price of LINK is $1 and there’s a Uniswap pool with 1,000 LINK and 1,000 USDC. K, the constant product, is 1,000,000 (1000 x 1000).

Alice contributed 100 LINK and 100 USDC to this pool, giving her ownership of 10% of the pool’s total assets, notwithstanding any new deposits to the pool.

On Jun. 1, 2020, the price of LINK is now $4. If LINK is worth $4 and the constant K is 1,000,000, that means there are 500 LINK and 2000 USDC in the pool.

Alice owns 10%, so she can redeem 50 LINK and 200 USDC—ignoring liquidity provision fees earned—as of June 1. This is worth a total of $400 ($200 of LINK and $200 of USDC). Compared to her initial investment of $200 ($100 of LINK and $100 of USDC), Alice made a pretty sweet return. But let’s put this into perspective.

What if Alice didn’t provide liquidity and just held her 100 LINK and 100 USDC? Today it would be worth $500 ($400 of LINK and $100 of USDC). Further, what if Alice actually had 200 LINK, but sold 100 of them for USDC so she could partake in liquidity provision? She would have 200 LINK, which would now be worth $800.

Chart showing the impact of impermanent loss
Collected fees (red), Impermanent loss (blue), Net Profit (yellow). Providing liquidity for Uniswap’s LEND-ETH pool between January 1 and June 1 would have resulted in an 11% net loss, as LEND went parabolic, via ZumZoom

That $400 doesn’t look all that enticing now. If Alice sat on her hands and HODLed her LINK, she would’ve outperformed her return from liquidity provision.

This is called impermanent loss. It’s the opportunity cost when providing liquidity for an asset that experiences price appreciation. It’s “impermanent” because if prices revert to previous levels, i.e. $1 per LINK, the capital loss is reversed and liquidity providers will still be in the green thanks to trading fees earned.

“AMMs were created to help solve liquidity problems for the long tail of tokens. But the long tail of tokens are specifically the small-cap tokens who have the highest potential to suffer impermanent losses if they grow into a larger cap project,” said Brandon Iles, CTO of DeFi coin Ampleforth.

Losses to liquidity providers due to price variation chart
The impermanent loss for liquidity providers increases as the price of a token increases, via Pintail

Profitable Yield Farming

The best time to provide liquidity for an asset is when it is trading within a defined price range for an extended period. ETH has been stuck in an 11% range for the last month, meaning liquidity providers have done well by earning passive income despite ETH’s muted price action.

However, it is near impossible to predict when the price will start to trend in either direction or range. No one can predict whether a token is going to go 2x or lose 50% of its value over the next few months. But for those who speculate, liquidity provision is a good investment in anticipation of low volatility. 

If you still don’t understand how these elements work and when it is profitable or loss-making, it’s probably best to refrain from providing liquidity.

The bottom line for yield farming is to make sure you’re comfortable with bearing impermanent losses, or you find ways to offset those losses through strategic purchases of crypto derivatives.

Disclosure: Ampleforth is a sponsor of Crypto Briefing.

Share this article

Loading...