TLDR: Uniswap allows users to quickly swap any two Ethereum-based tokens in a permissionless fashion. Traders can earn fees by supplying capital to the underlying liquidity pools.
How it Works
Uniswap is a decentralized protocol for automated liquidity provision for Ethereum token trading pairs. Every ERC-20 to ERC-20 trading pair has a dedicated smart contract that holds reserves of each token and rules for how the reserves can be changed. Anyone can become a liquidity provider by depositing tokens into a smart contract and receive pool tokens in return. These pool tokens track the liquidity provider’s share of the total reserves and can be traded in for the underlying asset at any time.
Uniswap charges a 0.30% fee on all trades which is added to the reserve pool. When a liquidity provider burns their pool tokens to reclaim their stake of the total reserve, they receive a proportionally distributed amount of the total fees accumulated while they were staking.
Uniswap’s easy-to-use interface has functionality for trading tokens, sending tokens to another address through automatic swapping, and adding or removing liquidity from pools. This article walks through the steps to provide liquidity to pools through both Uniswap and DeFiZap.
To read more about Uniswap, check out our full writeup.
Walkthrough – Adding Liquidity Through Uniswap
To start providing liquidity on Uniswap, you must hold ETH and the target ERC20 token (say Dai) in the same wallet. If you already have ETH, you can connect your wallet and swap for Dai directly through the ‘Swap’ functionality on uniswap.exchange.
However, it’s important to note that you can only enter liquidity pools with an equal dollar value of ETH and the ERC-20 token. The amount of liquidity you can provide will be limited by whichever balance is less. In this walkthrough, I will provide liquidity to the Uniswap ETH-DAI pool.
Once you have your tokens, click the ‘Pool’ tab and make sure ‘Add Liquidity’ is selected at the top of the page. You will see ETH automatically selected in the top box, and select your ERC-20 token in the bottom box. You may need to click ‘Unlock’ next to the token and approve the contract interaction notification.
Select the amount of tokens you want to add to the liquidity pool and the corresponding ETH amount will automatically populate in the top box. At the bottom you can see the current exchange rate and pool size. Click ‘Add Liquidity’ and approve the transaction notification through your wallet.
After the transaction is confirmed on the blockchain, you will see the amount of ETH and DAI liquidity provided and your pool share as a percentage. This liquidity is tapped into when users make ETH-DAI trades on Uniswap, meaning the ratio of your ETH to DAI may change over time. You could end up with more ETH or DAI depending on which way people are trading, but the dollar value will remain constant.
With each liquidity providing transaction, you will automatically receive Uniswap liquidity provider (LP) tokens. These tokens track your contribution to the pool and are used for distributing your share of the transaction fees accumulated in the time period that you provide liquidity for.
To remove liquidity and receive your rewards, make sure you are on the ‘Pool’ tab again and select ‘Remove Liquidity’ from the drop-down menu. Select the ERC-20 token you provided liquidity for and the balance shown above it will equal your number of LP tokens. Click this number to populate the box with the entirety of your pool stake.
You will see the estimated output below which includes your share of the accumulated transaction fees. Once again, the ratio of ETH to DAI may be different than the amount you contributed due to the trades made by other users. Click ‘Remove Liquidity’ and approve the transaction notification.
After the transaction is confirmed on the blockchain, you will receive the ETH and DAI output in your wallet, the LP tokens will be burned, and your pool share will return to 0.
Walkthrough – Adding Liquidity Through DeFiZap
Another option for adding liquidity to Uniswap pools is to use DeFiZap. DeFiZap is a platform that offers smart contracts to quickly deploy assets across multiple DeFi protocols with a single transaction, saving time and gas fees.
In this example, I will provide liquidity to the same Uniswap ETH-DAI pool. However, instead of trading for DAI to begin with, DefiZap only requires an ETH input. (Note – this can be done with only DAI as well).
Navigate to https://defizap.com/zaps/unipooldai and connect your wallet. Click ‘Zap In’ and select ETH as the input and Uniswap under ‘Swap Via’. You will see the current pool size, your estimated pool share, and the amount of LP tokens you will receive.
It’s important to note that unlike providing liquidity on Uniswap where the selected ETH amount is matched with DAI, the amount selected here will be split between ETH and DAI. In this example, I chose to add 0.03 ETH, which is going to be split into 0.015 ETH and 2.746 DAI before being added to the pool.
Select your desired transaction speed, click ‘Zap In’, and approve the transaction notification in your wallet. In this single transaction DeFiZap traded half the ETH for DAI, provided the ETH and DAI to the liquidity pool, and transferred the LP tokens to your wallet, all of which can be seen in the transaction overview.
To remove your liquidity through DeFiZap navigate back to https://defizap.com/zaps/unipooldai and click ‘Zap Out’. You will see your LP token balance at the top – select a fraction of the total or click ‘Withdraw Maximum’ to completely exit the liquidity pool. Unlike Uniswap, there is an option to receive your proceeds in ETH, DAI, or ETH & DAI. After selecting an option you will see your estimated output (including accumulated rewards), remaining pool share, and the DeFiZap convenience fee.
Click ‘Zap Out’ and confirm the transaction notification. Your LP tokens will be burned and you will receive the output in your chosen asset.
Key Use Cases
On top of adding liquidity to the aforementioned pools, we also want to highlight the ETH/sETH liquidity pool for a number of reasons:
- Due to the pegged 1:1 ration of ETH:sETH liquidity providers do not incur impermanent loss (described below)
- Synthethix currently offers liquidity incentives for pooling on Uniswap. To learn how to earn weekly SNX inflation by providing sETH liquidity, please reference this tutorial.
- The profit to be earned off pooling for any given pool will vary relative to the usage and pool size. We recommend using tools like pools.fyi and uniswap.info to keep track of which pools are seeing the highest returns, volume and liquidity at any given time.
Key Points to Consider
One of the critical aspects to consider about Unsiwap LP rewards is impermanent loss. Given the need for Uniswap pools to always share an equal ratio of 50% ETH 50% ERC20 (Dai), liquidity providers incur a small opportunity cost as the value of one asset appreciates relative to the other.
“If you sell half of your ETH for DAI so that you can stake both assets in the Uniswap contract, if ETH shoots up in price, you missed out on half of the gains you would have realized if had held the ETH. It is impermanent because given sufficient volume and time, the value of your stake will grow thanks to collected trading fees, and so those unrealized gains will be mitigated by the earnings from staking.”
Trying to boil it down further, if you are supply liquidity to a pool like ETH/DAI and ETH shoots up in price, it’s very likely that the amount of returns made from Uniswap trading fees will be less than the increased price of ETH. This means that when you remove liquidity from the pool, you may have less ETH than when you started – solely due to the fact that 1ETH is now equal to more DAI then when the position was entered.
We understand this is a difficult concept to grasp, so the key takeaway here is that liquidity pooling is most effective during times of relatively stagnant markets in which price is not too volatile in any one direction.
For those looking to do a deep dive on impermanent loss, please reference this article.