No history yet

DeFi Liquidity Provision

The Heart of DeFi Trading

In traditional finance, markets rely on buyers and sellers creating orders. A stock exchange, for example, maintains an order book, a list of buy orders and sell orders at different prices. The exchange's job is to match a buyer with a seller. Decentralized finance (DeFi) often works differently. Instead of matching buyers and sellers, many decentralized exchanges (DEXs) use a system called an automated market maker, or AMM.

AMMs allow digital assets to be traded automatically and without permission by using liquidity pools instead of a traditional order book.

But for an AMM to work, it needs a ready supply of assets for traders to swap. This is where liquidity providers come in.

Liquidity Provider

noun

An individual or entity that funds a liquidity pool with their crypto assets to facilitate trading on a decentralized exchange. In return, they earn fees from the trades that occur in their pool.

Think of a liquidity provider (LP) as someone who stocks the vending machine. Without them, there's nothing to buy. LPs deposit their assets into smart contracts called liquidity pools. Typically, a pool consists of two different tokens, like ETH and USDC. This pair of assets is what other users can trade against.

Lesson image

How Pools Work

When an LP deposits tokens into a pool, they must deposit an equal value of both tokens. If 1 ETH is worth $3,000, and they want to provide 1 ETH, they must also deposit 3,000 USDC.

The AMM uses a mathematical formula to keep the pool balanced and determine the price of assets. The most common one is the constant product formula.

xy=kx \cdot y = k

When a trader wants to swap one token for another, they interact with the pool. For example, if a trader sells ETH for USDC, the amount of ETH in the pool (xx) increases, and the amount of USDC (yy) decreases. To keep kk constant, the price of the tokens adjusts. This elegant mechanism allows for constant, automated trading without a central order book.

The Catch: Impermanent Loss

Providing liquidity isn't risk-free. The primary risk is something called impermanent loss. This isn't a loss in the traditional sense, but rather an opportunity cost. It's the difference in value between holding your assets in a liquidity pool versus simply holding them in your wallet.

Impermanent loss happens when the price of one of the tokens in the pool changes relative to the other. The more the prices diverge, the greater the impermanent loss.

Let's walk through an example. Alice decides to provide liquidity to an ETH/USDC pool.

ActionETH in PoolUSDC in PoolETH PriceAlice's Share ValueHODL ValueImpermanent Loss
Initial Deposit1 ETH3,000 USDC$3,000$6,000$6,000$0
ETH Price Rises0.816 ETH3,674 USDC$4,500$7,348$7,500$152

Initially, Alice deposits 1 ETH and 3,000 USDC, for a total value of $6,000.

Then, the price of ETH rises to $4,500 on other exchanges. Arbitrage traders step in. They buy the cheaper ETH from Alice's pool and sell it elsewhere for a profit. This rebalances the pool. To maintain the constant product kk, the pool now holds less ETH and more USDC.

If Alice withdraws her funds now, her share is worth $7,348. That's a profit! But if she had just held her original 1 ETH and 3,000 USDC, her assets would be worth $7,500 (1 ETH at $4,500 + 3,000 USDC). The $152 difference is her impermanent loss.

The loss is "impermanent" because if the price of ETH returns to $3,000, the loss disappears. However, if she withdraws her assets while the prices are different, the loss becomes very real and permanent. Successful LPs hope that the trading fees they earn will outweigh any potential impermanent loss.

Quiz Questions 1/5

How does an Automated Market Maker (AMM) differ from a traditional stock exchange's order book system?

Quiz Questions 2/5

A liquidity provider wants to deposit into an ETH/USDC pool. If the current price of 1 ETH is $2,500, and they want to provide 2 ETH, how much USDC must they also deposit?