Pool Liquidity | Uniswap (2024)

Uniswap liquidity pools are autonomous and use the Constant Product Market Maker (x * y = k). This model was formalized and the smart contract implementation passed a lightweight formal verification.

Create Exchange

The createExchange function is used to deploy exchange contracts for ERC20 tokens that do not yet have one.

factory.methods.createExchange(tokenAddress).send()

Once an exchange is created the address can be retrieved with getExchange.

Exchange Reserves

Each exchange contract holds a liquidity reserve of ETH and its associated ERC20 token.

ETH Reserve

The ETH reserve associated with an ERC20 token exchange is the ETH balance of the exchange smart contract.

const ethReserve = web3.eth.getBalance(exchangeAddress)

ERC20 Reserve

The ERC20 reserve associated with an ERC20 token exchange is the ERC20 balance of the exchange smart contract.

const tokenReserve = tokenContract.methods.balanceOf(exchangeAddress)

Add Liquidity

Anyone who wants can join a Uniswap liquidity pool by calling the addLiquidity function.

exchange.methods.addLiquidity(min_liquidity, max_tokens, deadline).send({ value: ethAmount })

Adding liquidity requires depositing an equivalent value of ETH and ERC20 tokens into the ERC20 token's associated exchange contract.

The first liquidity provider to join a pool sets the initial exchange rate by depositing what they believe to be an equivalent value of ETH and ERC20 tokens. If this ratio is off, arbitrage traders will bring the prices to equilibrium at the expense of the initial liquidity provider.

All future liquidity providers deposit ETH and ERC20's using the exchange rate at the moment of their deposit. If the exchange rate is bad there is a profitable arbitrage opportunity that will correct the price.

Parameters

The ethAmount sent to addLiquidity is the exact amount of ETH that will be deposited into the liquidity reserves. It should be 50% of the total value a liquidity provider wishes to deposit into the reserves.

Since liquidity providers must deposit at the current exchange rate, the Uniswap smart contracts use ethAmount to determine the amount of ERC20 tokens that must be deposited. This token amount is the remaining 50% of total value a liquidity provider wishes to deposit. Since exchange rate can change between when a transaction is signed and when it is executed on Ethereum, max_tokens is used to bound the amount this rate can fluctuate. For the first liquidity provider, max_tokens is the exact amount of tokens deposited.

Liquidity tokens are minted to track the relative proportion of total reserves that each liquidity provider has contributed. min_liquidity is used in combination with max_tokens and ethAmount to bound the rate at which liquidity tokens are minted. For the first liquidity provider, min_liquidity does not do anything and can be set to 0.

Transaction deadline is used to set a time after which a transaction can no longer be executed. This limits the "free option" problem, where Ethereum miners can hold signed transactions and execute them based off market movements.

Remove Liquidity

Liquidity providers use the removeLiquidity function to withdraw their portion of the reserves.

exchange.methods.removeLiquidity(amount, min_eth, min_tokens, deadline).send()

Liquidity is withdrawn at the same ratio as the reserves at the time of withdrawal. If the exchange rate is bad there is a profitable arbitrage opportunity that will correct the price.

Parameters

amount specifies the number of liquidity tokens that will be burned. Dividing this amount by the total liquidity token supply gives the percentage of both the ETH and ER20 reserves the provider is withdrawing.

Since exchange rate can change between when a transaction is signed and when it is executed on Ethereum, min_eth and min_tokens are used to bound the amount this rate can fluctuate.

Same as in addLiquidity, deadline is used to set a time after which a transaction can no longer be executed.

Pool Liquidity | Uniswap (2024)

FAQs

What is pool liquidity? ›

Liquidity pools make it possible to trade crypto without the need for a central intermediary maintaining an order book. This allows traders to swap tokens directly from their wallets, reducing counterparty risk and exposure to certain risks that centralized exchanges may face, like employee theft.

Do liquidity pools make money? ›

Liquidity pools pave a way for liquidity providers to earn interest on their digital assets. By locking their tokens into a smart contract, users can earn a portion of the transaction fees generated from trading activity in the pool.

How do you calculate liquidity pool? ›

For one, in v2 the liquidity of a pool and the liquidity of a position are conceptually the same, the L = sqrt(x*y) formula works for both. The liquidity of a position is uniform in the range [p_a, p_b] , and zero for prices outside of this range.

Can you lose in liquidity pool? ›

Impermanent loss occurs when the price of a token rises or falls after you deposit it in a liquidity pool. It indicates a loss when the dollar value of your token at the time of withdrawal is less than the amount deposited.

How do you fund a liquidity pool? ›

To start a liquidity pool, users deposit equal values of two tokens into the pool, creating what is known as a trading pair. For instance, if you want to create a liquidity pool for BTC and ETH, you'd deposit an equal value of both assets. Liquidity pools leverage algorithms to determine token prices.

How do you get paid in a liquidity pool? ›

Users who provide liquidity are called 'liquidity providers' and are rewarded with a percentage of the fees that buyers and sellers pay for using the liquidity pool to trade tokens. The fees are distributed proportionally to liquidity providers based on the amount of capital they contributed to the pool.

What is better staking or liquidity pool? ›

Liquidity pools offer potentially higher rewards but require advanced knowledge, understanding of market dynamics, and active participation. Liquid staking is a simpler and more accessible strategy, suitable for beginners or individuals seeking a conservative and consistent approach to earning passive income.

How are liquidity pool fees paid? ›

Fees are collected by burning liquidity tokens to remove a proportional share of the underlying reserves. Since fees are added to liquidity pools, the invariant increases at the end of every trade.

Is liquidity pool safe? ›

Some common vulnerabilities and risks associated with liquidity pools include: Impermanent Loss: Impermanent loss occurs when the price of the assets in the liquidity pool changes relative to the price outside of the pool. Liquidity providers can experience financial losses when withdrawing their assets.

Can you withdraw from liquidity pool? ›

Select or search for a liquidity pool you'd like to withdraw liquidity from. In the "Withdraw Liquidity" panel, enter the amount of tokens you would like to withdraw from the liquidity pool (or use the slider!) and click “Withdraw Liquidity” at the bottom.

Who can create a liquidity pool? ›

A regular user can create a liquidity pool on 1inch with the Balancer protocol in just a click, configuring its size and the weight of each currency. One way to earn an income in the crypto space is by creating and running a liquidity pool — a pool of tokens locked on a smart contract.

Is liquidity pool profitable? ›

Liquidity pools are primarily in pairs e.g. ETH/USD. Providing liquidity for DEXs is a type of yield farming and some investors see it as more profitable than just buying and holding because LPs receive rewards from trading fees. However, LPs lose money due to Impermanent Loss (IL).

What is a liquidity pool? ›

A liquidity pool is a smart contract where tokens are locked for the purpose of providing liquidity. Some of the important concepts required to understand how liquidity pools and decentralised exchanges work include liquidity providers, liquidity tokens and automated market makers.

What assets are in a liquidity pool? ›

Liquidity pools are typically composed of two or more assets that are paired together in a specific ratio, such as 50% ETH and 50% DAI. The ratio is maintained by an automated market maker (AMM) algorithm, which adjusts the price of the assets in the pool based on the relative supply and demand.

What is the liquidity of a pooled fund? ›

Liquidity -the ease with which the assets can be bought and sold. Pooled investment funds are highly liquid and usually trade a number of times per day. Diversification - investing in a large number of assets to reduce overall risk.

What is the difference between liquidity and liquidity pool? ›

Liquidity provision is done through crypto liquidity pools, whereby users contribute assets and play a direct role in facilitating the market. A decentralized exchange (DEX) is a two-sided marketplace and liquidity providers are only one side. Traders (the demand to buy or sell) are on the other side.

How does a liquidity pool balance? ›

Remember that the assets in a liquidity pool are always balanced in value. This means that the pool automatically 'gives away' a portion of the price appreciation to make sure the constant product formula stays true.

What does it mean to burn a liquidity pool? ›

The burning of pools (liquidity burning) on Solana refers to the destruction or removal of liquidity tokens (LP tokens) from a wallet.

Top Articles
January 2019 Side Hustle Report - $1,381.71 - Financial Panther
More Than 50 Brilliant Ideas for How to Save Money on Groceries - Penny Pinchin' Mom
Bucks County Job Requisitions
Undergraduate Programs | Webster Vienna
My Boyfriend Has No Money And I Pay For Everything
Fusion
Arrests reported by Yuba County Sheriff
Ncaaf Reference
Culver's Flavor Of The Day Monroe
Cool Math Games Bucketball
What is the difference between a T-bill and a T note?
What Happened To Maxwell Laughlin
Costco Gas Foster City
2021 Lexus IS for sale - Richardson, TX - craigslist
finaint.com
Colorado mayor, police respond to Trump's claims that Venezuelan gang is 'taking over'
I Touch and Day Spa II
Telegram Scat
Vermont Craigs List
Rachel Griffin Bikini
St. Petersburg, FL - Bombay. Meet Malia a Pet for Adoption - AdoptaPet.com
Geometry Review Quiz 5 Answer Key
Hewn New Bedford
Ups Print Store Near Me
Morse Road Bmv Hours
Coomeet Premium Mod Apk For Pc
Anotherdeadfairy
E32 Ultipro Desktop Version
Directions To Nearest T Mobile Store
Violent Night Showtimes Near Amc Dine-In Menlo Park 12
Znamy dalsze plany Magdaleny Fręch. Nie będzie nawet chwili przerwy
Wood Chipper Rental Menards
Umn Biology
Yu-Gi-Oh Card Database
Issue Monday, September 23, 2024
Devotion Showtimes Near The Grand 16 - Pier Park
Renfield Showtimes Near Marquee Cinemas - Wakefield 12
RUB MASSAGE AUSTIN
Craigslist Hamilton Al
Prima Healthcare Columbiana Ohio
Oreillys Federal And Evans
Omnistorm Necro Diablo 4
888-333-4026
Convenient Care Palmer Ma
Doordash Promo Code Generator
Sour OG is a chill recreational strain -- just have healthy snacks nearby (cannabis review)
City Of Irving Tx Jail In-Custody List
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Christie Ileto Wedding
Cryptoquote Solver For Today
sin city jili
The Significance Of The Haitian Revolution Was That It Weegy
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 5916

Rating: 4.9 / 5 (49 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.