DeFi: What are Liquidity Pools and Liquidity Providers? What is Impermanent Loss? and What is Yield Farming?

To understand DeFi (Decentralised Finance), the terms; ‘Liquidity Pools’, ‘Liquidity Provider’, ‘Yield Farming’ and ‘Impermanent Loss’ are necessary. Although at first, these new terms can appear overwhelming, a clear explanation will demonstrate that looks can be deceiving.

Edward Wilson
13 min readFeb 8, 2021

How Does Traditional Finance Operate?

Decentralised Finance (DeFi) offers an exciting alternative to its traditional counterpart. However, to understand why it does, it is essential to understand first how traditional finance or Centralised Finance (CeFi) operates.

To trade on a Centralised Exchange (CEX), an order by two separate individuals, one buying and the other selling will need to agree on a price. That can be achieved by using an order book. An order book is an electronic list used in CEXs that contains buy and sell orders organised by price for a specific security or financial instrument, for example; stocks, bonds, options, futures, currency and cryptocurrency.

A screenshot from FTX displaying an order book for ETH/USD spot

I have provided a screenshot from FTX a CEX as an example of an order book. In this example, it contains details for the Ethereum (ETH)/ US Dollar (USD) pair in the spot market. At the top of the order book, it displays the current market price for ETH in USD which is $1306.50 per ETH. Under this on the left in the green displays the most recent buy orders for ETH. The order book reveals the amount of ETH that the buyer wishes to purchase and at what price. The price at the top of this list will be the highest and we can see at the time of this screenshot, this is an order of 6.127 ETH at a price of $1,305.90 per ETH. In this example, the buyer is looking to purchase 6.127 ETH and this order can be met through one or a combination of sell orders that totals the 6.127 ETH at the desired price. The other side of the order book in red displays the sell orders with the same information but with the lowest price at the top. Buy low and sell high. In this case, a seller is looking to sell only 0.001 ETH with an asking price of $1,307.00 per ETH. If a buyer and seller can agree on a price on the order book, then the trade will be fulfilled and will be shown on ‘Market Trades’ with the most recent trade being a buy order of 0.001 ETH at $1306.50.

However, an order placed in an order book, will not always be fulfilled as either the buyer or seller may fail to adjust their price according to market demands. That is why CEXs depend on Market Makers (MM). The MM is a liquidity provider and is typically a large financial company that satisfies market demand for profit. Without MMs, if two separate individuals, one buying and one selling cannot agree on a mutual price on an order book, neither the buyer nor seller will have their trade executed. Therefore, a MM will provide liquidity for the market by buying and selling the in demand asset at a profit so that trading can remain buoyant. However, a MM will not facilitate trade if the order would result in a loss for the MM.

The way MMs generate revenue is through the difference from the quoted price and the immediate price offered in an order book. This is known as a spread. By using the above order book example, the market price of ETH is $1306.50, and the prices which the highest buyer and seller are looking to trade ETH at is $1305.90 and $1307.00 respectively. Therefore, if a MM fulfils these trades, this would be the spread if there was profit to be made. As the MM provides liquidity, they can meet the market demand by buying and selling the assets at a price different from what’s quoted. The profit made from the spread is dependant on how liquid a market is, with the more liquid a market is, the less profit a MM can make.

The problem with traditional finance is multifaceted. Firstly, as the current Wall Street Bet drama unfolds, power within traditional finance is centralised by a single group or a collection of businesses. These actors can use their influence to determine market participation and the rules of the game. In contrast, the majority of DeFi protocols have a governance token that allows holders to express their opinion by voting on the future of the project. By being inclusive, DeFi encourages greater accountability and sustainability for their respective protocol by being accountable to the community.

Additionally, the fee structures for CEXs are high relative to DEXs (Decentralised Exchanges) to cover the increased costs of business. As governance is centralised, salaries are required to pay staff operating the business, MMs charge fees for their services and CEXs provide custody for user funds. While DEXs have development teams, they are significantly smaller to their CEX counterparts. DEXs do not take custody of user funds as funds are on self-hosted wallets that the user maintains. Consequently, DEXs can manage a lower transaction fee returning a portion of this fee to holders of the respective governance token or liquidity pool (LP).

What are Automated Market Makers and Liquidity Pools?

Rather than depending on order books and MMs, DeFi uses LPs to provide the necessary liquidity for decentralised trading. Although DEXs in the past did use order books, for example EtherDelta, this would become unpopular due to the rise of LPs. LPs are tokens, typically two in equal value, locked in a smart contract and are used to facilitate trading on DEXs. If the tokens included in the LP aren’t of equal value, it creates an arbitrage opportunity. Arbitrage is taking advantage of price differences between two or more markets by trading the same pair and then profiting from the imbalance in market prices.

When a trade occurs on a DEX, the LP will have a portion of its liquidity taken out, as the buyer is buying tokens from that LP and not from an order book or MM. That is Automated Market Making (AMM). The trading pairs in DEXs need liquidity within them as this will enable price stabilisation. If a trading pair has low liquidity, a large trade can cause price volatility as it removes a significant percentage of the overall liquidity from the LP.

Who are Liquidity Providers?

Liquidity providers are those who supply their tokens in the LP. For example, in an ETH/DAI LP, a liquidity provider on Uniswap will need to deposit an equal dollar value of ETH and DAI into the ETH/DAI LP. By providing liquidity, the user will lock up their tokens into the protocols smart contract. In exchange, they will receive LP token representing their percentage of the overall pool. This LP token entitles the holder a right to their portion of the fees accumulated in that pool. This fee is divided into an equal dollar value distribution of the tokens contained in the LP. If the liquidity provider no longer wants to provide liquidity, they will need to burn (remove) their LP tokens. That will result in the underlying assets and any fees accumulated. However, these underlying assets will most likely change due to the constant rebalancing in the LP.

Why does DeFi Need Liquidity Pools and Automatic Market Makers?

As DeFi is predominantly on the Ethereum network, its capability of processing transactions explains why the traditional method won’t work for DEXs. In comparison to other payment networks like Swift, Ethereum is incredibly slow. That would prevent MMs from adjusting their prices and ability to provide liquidity for the market, resulting in a slow and expensive user experience. Despite that, if Ethereum payment processing becomes comparable to traditional payment networks, gas fees in their current form would bankrupt MMs due to the volume of required transactions.

Although there are layer two solutions like Loopring (LRC) that enables trade at a fraction of the gas price, these DEXs are still reliant on attracting the necessary liquidity to prevent unnecessary volatility. However, as LRC is a layer two solution, interacting with this protocol will require gas-heavy transactions to move assets between layer one and two. If the user is only making a small volume of transactions, using LRC will not make considerable savings due to the gas-heavy transactions to move assets between the layers. Currently, these layer two solutions only become a viable option for those making a high amount of trades.

For all these reasons, LPs are a necessary alternative to the mechanisms in traditional finance.

What is Impermanent Loss?

Impermanent loss is an important concept to understand when providing liquidity for LPs as it is the temporary loss of tokens within the LP. As tokens contained within the LP rebalance, the stable token can be used to purchase the volatile asset in the LP to maintain equal weighting. For example, an ETH/DAI pair will cause DAI to rebalance the LP when the price of ETH declines, resulting in a temporary loss in DAI. However, this may not be an issue for the liquidity provider as they could value the two tokens in the LP as part of a long-term investment strategy. After all, this volatile asset may recover and be used to buy-back the stable token to maintain the equal weighting resulting in growth in the LP.

But this impermanent loss can become permanent if the volatile token included within the LP fails to recover. If this happens, then the stable or stronger, token will purchase the volatile or weaker, token to maintain equal balance within the LP. If that token continues to decline, then the stable or valuable token will rebalance the LP. That will continue until the liquidity provider removes their liquidity, accepting their losses or the liquidity within the pool becomes worthless.

To gain a greater understanding of impermanent loss, I will now present two hypothetical scenarios.

In the first example, the LP contains a new token called TOKEN (TOK) with its price at $0.01, so the TOK/DAI pair is equal to 100:1. This project has good marketing, and those buying into the TOK LP expect the project to do very well, and as a result, its price has risen to $0.25. The TOK/DAI pair is now at 4:1. That is great for liquidity providers as the LP token has increased in value due to TOK, so TOK is being used to rebalance the LP to ensure its weighted equally. With the performance of TOK, others have started to contribute to the TOK/DAI LP.

Sadly, the price of TOK declines as the hype around the project doesn’t meet expectations. TOK is now worth $0.10, that values the TOK/DAI pair at 10:1, which is unfortunate for the new liquidity providers as their DAI is now being used to buy TOK a declining asset resulting in an impermanent loss. This loss will become permanent if those new liquidity providers take out their investment in fear of further decline or TOK fails to recover. However, in this example, liquidity providers believe in the project, and the price of TOK recovers and grows to $0.50 as the project eventually exceeds expectations. Therefore, when TOK was at $0.10, the loss in the LP was impermanent as the price of TOK was in decline. But, as TOK recovered, it was used to repurchase the DAI preventing the impermanent loss turning permanent.

In contrast, in the second example, the token included is called PROJECT (PROJ) that solves a complicated issue within the blockchain space. As a result, it is currently priced at $0.10, resulting in the PROJ/DAI pair being equal to 10:1. The price of PROJ increases to $0.50, and the LP ratio is now 2:1. That has encouraged new investors to provide liquidity.

However, this team for PROJ is hidden and failed to get their smart contract audited. A bug was spotted, resulting in the price of PROJ to decline to $0.25. However, as PROJ aims to solve a complicated issue, liquidity providers understand issues will emerge, so they decide to hold onto their investment. Currently, this loss is impermanent. As PROJ has started to drop in price, the developers decided to pull their liquidity from a DEX to reap the DAI gains as the project was a scam! The value of PROJ then plummets to $0.0001 and is now worthless. Because the LP needs to be balanced, DAI has been used to buy PROJ, but this has resulted in both sides of the LP being worth significantly less.

A liquidity provider who invested at $0.50 and bought 10,000 PROJ tokens had to match this contribution in DAI which would equate to 5,000 DAI with a market value of $10,000. When the price initially dropped to $0.25, the pool had to rebalance. As DAI remained stable when PROJ declined, the LP had to rebalance using DAI. The initial 10,000 PROJ in the LP would now be worth only $2500, but as the DAI remained stable and was worth $5000, to rebalance, 1250 DAI would be used to purchase 5000 PROJ, the LP is now worth $7,500.

However, when PROJ dropped to $0.0001, the 15,000 PROJ is now only worth $1.50. The DAI was once again used to rebalance the pool. But, with PROJs valuation, 1874.25 DAI is required to buy 18,742,500 PROJ to rebalance the LP. The new total of PROJ is 18,757,500, with the LP now being worth $3750. The stable asset, DAI, has been used to keep the pool equal, and this will continue until there is very little DAI left. This impermanent loss has now become permanent as PROJ is worthless, there is no way to recuperate the loses from the PROJ holdings resulting in a permanent loss of $6,750.

For the second example, I have assumed that the price dropped immediately from $0.5 to $0.25 then $0.0001 to provide a clear example. When this does sadly occur, the rebalancing is gradual than sudden.

What are the Differences Between Automated Market Makers?

The model used to discuss LPs in this article has been based on what Uniswap does. However, Uniswap isn’t the only AMM and nor is their model the only one used. I will now briefly explain how Uniswap, Curve and Balancer work and what makes them different from each other.

Uniswap is the current market leader in DEXs and uses a Constant Product Market Maker (CPMM). The CPMM is based on the function x*y=k which establishes a range of prices for two tokens according to their available liquidity. That ensures that the ratios within the LP will remain balanced so that it can provide liquidity. When ETH is bought from the Uniswap ETH/DAI pool, this will cause the supply of ETH to decline and increase the price of ETH against DAI. In this ETH/DAI example, when the supply of ETH decreases, the supply of DAI increases to maintain the constant product K. Therefore, the CPMM rebalances the LP to represent trading.

With Uniswap, trading tokens with a similar value like stablecoins or a token against its wrapped alternative is expensive and results in losing a significant portion of the like-for-like token. That is why Curve uses an alternative model to Uniswap that combines a CPMM with a Constant Sum Market Maker (CSMM). Where a CPMM follows the x*y=k a CSMM uses x+y=k, this is ideal for trades that have a similar value. However, CSMM can result in one side of the LP being drained, creating an arbitrage opportunity. That is why Curve has combined both CPMM and CSMM together as this creates greater liquidity while bringing down the fees and slippage associated with CPMM. If you are trading tokens with similar values to benefit from their utility or yield opportunities, then a AMM with this model would be suitable as it enables lower fees and slippage making these trades possible when Uniswap couldn’t.

In contrast to both Uniswap and Curve, Balancer allows LPs to contain up-to eight tokens within the pool with unequal weighting. In my opinion, Balancer makes the already interesting subject of AMMs and LPs even more exciting. Balancer can achieve this result as it uses neither CPMM nor CSMM but a Constant Mean Market Maker (CMMM). This third type follows the equation (x*y)^(1/2)=k for two tokens, (x*y*z)^(1/3)=k for three and so on. That enables variable exposure to different assets in a pool within the LP and can change dependant on the LPs strategy. For example, if an individual wants greater exposure to Ethereum against stablecoins, they can either create or join an ETH/DAI/USDC/ USDT pool weighted at 70/10/10/10. The mix of stablecoins within the LP enables price stability across the stablecoins while gaining greater exposure to Ethereum. CMMM, allows liquidity providers to benefit from having exposure to an investment strategy and earn fees for their liquidity that they would otherwise have been unable to do with a Uniswap or Curve LP. That enables Balancer liquidity providers to earn fees for their long-term tokens and the additional benefit of best price execution as the liquidity across the protocol is used and traded against, rather than a specific LP pair.

What is Yield Farming?

As liquidity creates better price stability on AMMs, some protocols like Curve and Balancer provide governance tokens to incentive liquidity providers to use their platform. These tokens can become valuable as DeFi summer illustrated. With these tokens, other protocols like Harvest.Finance will incentivise liquidity providers to lend their LP tokens in their platform to generate greater yields. That yield is created by rewarding LP token holders with the protocols token. While the rewards can be far greater than by holding the tokens in a wallet or benefiting from the fees accumulated in the LP, the higher rewards carry more risk. If gas prices are high, the ability to generate yield is significantly lowered, in tandem with impermanent loss, the losses will compound leaving you without agency while your tokens decline in value.

Final Remarks

I hope that I have managed to explain the terms; Liquidity Pools, Liquidity Providers, Impermamnt Loss and Yield Farming well and I would welcome any feedback with my explanations. I have started to use LPs and thought that others can benefit from my explainer. I was originally cautious with LPs as impermanent loss seemed a daunting prospect as I value the tokens I hold. But, after doing my research, I became comfortable with the risks associated with LPs.

DeFi is an exciting and innovative space that’ll only continue to grow. When using protocols associated with DeFi, it is best to understand how they work and why they’re different from traditional finance before using them. That is why I decided to write this article. With the current outages in trading across CEXs, DeFi protocols like Uniswap have managed to continue, and that’s what makes DeFi so exciting!

If you have any questions, please comment below this post or connect with me on LinkedIn at https://www.linkedin.com/in/wilsonedwardc/

Legal Disclaimer: I am not a financial advisor. The advice here given is not financial advice even though my excitement might make it look like such.

For The Curious Mind

Chainlink explainer on the differences in AMMs

DeFi Token YAM Immediate Price Drop

DeFi Yield Farming Newsletter

--

--