How does Providing Liquidity to a DEX work?
@shivsakhuja Jan 7, 2022
There are a few ways to earn a yield on your crypto:
- Liquidity Pools
- Farming LP Tokens
In this post, I'm going to try and explain Liquidity Pools, and how you can use them to earn on your crypto.
Liquidity Pools are often the best places to get the highest yield on your crypto. But the concept can be confusing, especially when you're new to DeFi.
In this post, I'll explain:
- How does a DEX / AMM work?
- What is a liquidity provider?
- Impermanent Loss / Tools
- Good LP opportunities right now
What is a DEX? How does it work?
Decentralized exchanges like Uniswap, Sushiswap, TerraSwap are called automated market makers (AMM).
A traditional order-book exchange (think NYSE) will match a buy order with a sell order to facilitate a trade.
A decentralized exchange or DEX works a bit differently..
A DEX has 2 types of participants:
- the trader &
- the liquidity provider.
The liquidity provider puts up an equal amount of both assets. (For example, $ETH and $USDC).
This "liquidity" provided allows traders to trade freely and automatically between the 2 assets.
The most common type of DEX uses a "constant-product" AMM. The basic formula behind these is:
token_a_balance * token_b_balance = k (where k is some constant)
An Example of Providing Liquidity to a DEX
Let's say you provide $500 of $ETH & $500 of $USDC.
Someone now buys $50 of ETH using $50 of USDC. The pool would now have $450 of ETH and $550 of USDC.
So the pool automatically adjusts the price of the ETH-USDC pair so that there is $500-$500 again ⚖️
The gist of it is that the price of the ETH - USDC pair is automatically adjusted by the AMM as people buy and sell ETH and USDC from the pool.
What happens if the pool size is too small (not enough liquidity)?
If the pool is too small or the transaction size is big, there will be "slippage".
This means that your trade's effective price is worse because the price is being driven up by your trade itself. 📈
If there is enough liquidity in the pool, this price adjustment is negligible and there is not much slippage.
Now, you might be wondering if the price on the DEX can deviate from the price on a centralized exchange (CEX) since it adjusts automatically.
Yes, it can -- but usually this will only be for a short while till arbitrageurs come in and profit from the spread. 🤑
Arbitrage example from changing prices on a DEX
Suppose the $ETH - $USDC pair is trading at $3800 on UniSwap but $4000 on Coinbase
You could buy on UniSwap and Sell on Coinbase.
This would eventually lead to prices on the DEX and CEX converging.
Pros of AMMs 👍
- Easy way to add liquidity to markets - especially useful for newer projects
- No need to wait for a counterparty for your trades
- Decentralized + self-executing contracts = no middlemen
- Smart contracts can be plugged into other protocols
Cons of AMMs 👎
- High slippage if pool size is small
- Smart contracts exploit risk
- On-chain trading increases network congestion (UniSwap is one of the biggest gas hogs on $ETH)
- There is a risk of Impermanent Loss (see https://blog.liquid.com/impermanent-loss)
What are some examples of liquidity pool strategies right now?
(Low-risk) If you're bullish on a coin, LP for a stable pair:
- $LUNA/bLUNA (27% APR on loop.markets)LUNA / bLUNA strategy explained
- $FTM / $TOMB (110% APR on tomb.finance + farming rewards)FTM / TOMB strategy explainer / Tomb Finance explained
- $aUST / $UST (42% APY on loop.markets for stablecoins)aUST / UST strategy explained
- $DOLA / $USDC (150% APY on stablecoin pair on Uniswap)
Keep in mind that these yields fluctuate constantly.
Steps to provide liquidity
- Find a good LP opportunity using coindix.com. Let's say you decide on the FTM - TOMB pool on SpookySwap
- Deposit FTM to your metamask wallet on the FTM chain
- One easy way is by buying FTM on a CEX, like Binance or Gate.io, and then withdrawing from there.
- Go to https://spookyswap.finance/swap and swap 50% of your FTM for TOMB
- Now go to the Liquidity tab in SpookySwap
- Select the pair of tokens you want to provide liquidity for
- Click max on one of the tokens in the pair
- Approve and click supply
- (Optional) Now, you can also "farm" your LP tokens on many platforms to earn additional yield in addition to the trading fees from the LP
- (Optional) You can also deposit your LP tokens to an autocompounder like https://app.beefy.finance/#/fantom to let the yields auto-compound. (APR vs APY - What's the difference?)
Good article explaining IL: https://blog.liquid.com/impermanent-loss
As an LP, impermanent loss risk is high if one coin moves a lot relative to the other coin in the pair.
If you think 2 coins will move together (ex: MATIC & ETH), then you can provide liquidity for the ETH-MATIC pair without worrying too much about the Impermanent Loss.
You can also think of it as an automatic profit taking strategy:
- When MATIC goes up relative to ETH, you're taking MATIC profits into ETH
- When ETH goes up relative to MATIC, you're taking ETH profits into MATIC
Automatically balancing your ETH and MATIC positions.
Some good resources for LP strategy and understanding Impermanent Loss:
- What Is IMPERMANENT LOSS? DEFI Explained - Uniswap, Curve, Balancer, Bancor
- Impermanent Loss Calculator
- https://coinhall.org/: Great for finding LP yields on Terra ecosystem
- https://coindix.com/: Great for finding LP yields on all ecosystems
- apy.vision: Tool to help figure out your LP performance and find LPs with good yield.