Unlocking DeFi

LPs & AMMs

Disclaimer: This post contains thoughts on crypto, a volatile and risky asset class. It is not investment advice, and you should do your own research. All information is for educational purposes only. Please don’t take risks with money you’re not willing to lose.

DeFi, although now thriving across most Layer 1s, truly conceptualized on Ethereum around 2017. Decentralized exchanges (DEXs) first became popular allowing traders to swap tokens P2P without a central intermediary maintaining their order book. While progressive, the earliest DEXs lacked sufficient market liquidity as there were few native buyers and sellers. The answer: liquidity pools and automated market makers.

What are Liquidity Pools?

Liquidity pools are crowdsourced tokens held in smart contracts that facilitate trades between the respective locked assets. In other words, users pool crypto into code that provides liquidity for traders looking to buy or sell tokens.

Unlike DEXs, centralized exchanges (Coinbase, Binance) manage third-party order books that ‘aren’t really’ settled onchain. In this system, bid and ask orders are matched with their suitable counterparties in order to process transactions. In addition to limited sovereignty over assets, the price / time it takes to fill orders is dependent on exchange liquidity and ever-changing market conditions.

Conversely, liquidity pools unlock a reserve of assets for decentralized exchanges to offer their clients access to. Users are trading against smart contracts, meaning there are no counterparties to deal with and instant liquidity. This speed and convenience is standard for assets with overflowing order books, but enables DeFi to grow ahead of pace.

LPs

Not to be confused with limited partners, those who voluntarily deposit funds into a liquidity pool are aptly named liquidity providers, or LPs.

As a means to incentivize LPs to stake assets in their pools, exchanges often allow providers to earn trading fees and crypto rewards (based on time + amount of locked tokens). When a user adds to a liquidity pool, they receive LP tokens that represent what’s been supplied. Therefore, as the pool facilitates trades, fees are proportionally distributed amongst the LP token holders.

Why?

Markets with limited liquidity are a headache for seasoned traders as slippage becomes a greater concern. Slippage is the difference between the expected price of a trade and the price at which it is actually executed. Although not unique to crypto, slippage is more often considered in volatile markets (i.e. penny stocks). Low volume can quickly make matters worse.

The market order price in traditional books is reflected by the bid-ask spread for any given trading pair (SOL/USDC). The bid-ask spread itself is the average between what sellers are willing to sell for and what buyers are willing to buy for. If a large order is executed on a pair that already has low liquidity, periods of high volatility and/or low volume will result in the executed trading price far exceeding the market order price (incurring unnecessary losses before the trade has even started).

Liquidity pools directly counteract issues of slippage and illiquid crypto markets more broadly. When someone trades with a protocol such as Uniswap, there are no buyers and sellers that need to be matched. Instead, they directly exchange their tokens with user-provided liquidity entirely transacted via smart contracts.

What are Automated Market Makers?

Automated market makers, or AMMs, operate across various decentralized exchanges that trade assets against the pools supplied via LPs. While LPs provide access to liquidity, AMMs disintermediate trading using algorithms that balance token prices based on the ratio of assets in the pool. As such, liquidity pools enable automated market makers, and vice versa.

AMMs can best be thought of as the decentralized order books that substitute traditional market exchanges in crypto. There is no bid-ask spread. There are no direct buyers and sellers. There is no third-party authority. The entire trading process is instead replaced by a neutral counterparty: software.

Uniswap

Launched during the infancy of DeFi, Uniswap pioneered AMMs and has consistently been the most active decentralized exchange ever since.

An AMM replaces the buy and sell orders in an order book market with a liquidity pool of two assets, both valued relative to each other. As one asset is traded for the other, the relative prices of the two assets shift, and a new market rate for both is determined. In this dynamic, a buyer or seller trades directly with the pool, rather than with specific orders left by other parties.

DEXs by Volume via CoinGecko

Constant Product Market Maker

Constant function market makers (CFMMs) define the first generation of AMMs made popular by the likes of Uniswap, Curve, and Bancor. Per the name, these types of exchanges operate based on a constant function which ensure that the combined asset reserves for trading pairs remain unchanged.

Of the various CFMM models, constant product market makers (CPMMs) are the most commonly used.

k = f(x*y)

The above function effectively establishes a range of prices for any given trading pair according to the available liquidity of each respective token.

  • if the token supply of x increases, the token supply of y decreases

  • if the token supply of x decreases, the token supply of y increases

In a similar manner,

  • if the token price of x increases, the token supply of x decreases

  • if the token price of y decreases, the token supply of y increases

These simple mechanics help keep CPMM-based liquidity pools in constant balance, denoted by k. Even in times of high volatility, traders are incentivized to take advantage of the arbitrage opportunity presented by the price differentiation between AMMs and external centralized exchanges.

Profitability & Risk

As is the ethos of most crypto-native protocols (AMMs in this case), LP rewards and compounding yield opportunities financially incentivize participation in liquidity pools. For instance, Uniswap proportionally distributes roughly 0.3% of all trading volume to liquidity providers. Pool APYs can therefore heavily vary contingent upon the pair activity / the LPs selected range. Rewards are then generally paid out in the trading pair’s tokens + the native protocol’s token ($UNI in this case). Extending this flywheel, most AMM-protocol tokens can be natively staked or lent for additional yield.

Although often perceived as passive and risk-free, being an LP requires constant account management and can lead to what’s become novelly known as impermanent loss. This phenomenon occurs when an AMM’s rebalancing algorithm creates a divergence between the price of an asset within a liquidity pool and the price of that same asset on external sources. An example best illustrates this:

Let’s say you enter an ETH/DAI pool on Uniswap. For simplicity, let’s also assume that 1 ETH = $100 DAI and 1 DAI = $1 USD (as it’s a stablecoin). The pool is a 50/50 balance meaning your initial deposits are equivalent in value. You provide 10 ETH and the corresponding 1000 DAI. Suddenly, the price of ETH doubles to $200. 1 ETH is now $200 DAI so arbitrageurs buy up the pool’s undervalued ETH until the price rebalances to match other exchanges. Using the CPMM function, the liquidity pool would now consist of 7.071 ETH and 1414.21 DAI. At ETH’s new price of $200, your LP holdings sum to $2828.42. If you had just held 10 ETH and 1000 outside of the pool, your holdings would have been $3000. Your impermanent loss is effectively -$171.57 (excluding yield generated in the process).

Given this hypothetical, it becomes clear that it’s most ideal to exit liquidity pools at the same price at which you enter. However, this is almost never the reality. Crypto is naturally volatile - the greater divergence between assets in a pool, the greater the impermanent loss. Moreover, this applies to both positive and negative price action. As such, the key to being a profitable liquidity provider is by trading volume as opposed to one directional price movements.

In Sum

The evolution of decentralized finance has largely been propagated by the development of liquidity pools and automated market makers. By enabling users to trade directly against smart contracts without the need for counterparties, these technologies have not only solved issues of slippage and illiquid markets, but democratized access to financial tooling for anyone with a phone + internet connection. However, while the potential rewards for LPs can be substantial, providing liquidity is best when market conditions are relatively stable such that impermanent loss is mitigated.