Understanding Liquidity Pools and Automated Market Makers (AMMs)

Learn how AMMs rely on liquidity pools to facilitate swaps while being aware of their risks.

Understanding Liquidity Pools and Automated Market Makers (AMMs)

Liquidity pools are a key element of decentralized exchanges (DEXs) and automated market makers (AMMs).

A liquidity pool is essentially a smart contract where users can deposit cryptocurrencies and receive liquidity provider (LP) tokens in return. These tokens give users a share of the fees collected by the pool when other users swap tokens through the liquidity pool.

Automated market makers

AMMs use liquidity pools to facilitate swaps. The basic function of liquidity pools is simple: LPs lock an amount of two assets (e.g. ETH and USDC) in a dedicated smart contract, creating a pool. Users who want to swap between these assets can then access the pool, paying a small fee for the service. The LPs receive a share of these fees in proportion to the amount of liquidity they provide.

To maintain accurate asset valuations, AMMs rely on stabilizing asset prices according to their fluctuations within the liquidity pool. They use a mathematical formula, usually the Constant Product Formula (although other variants exist), which ensures that as one asset is deposited and the other is withdrawn, the total quoted price of both assets remains constant.

AMMs rely on arbitrage traders and oracles to maintain accurate prices. Arbitrage traders trade across markets to take advantage of price differences, while oracles communicate real-world information to blockchain-based systems.

Benefits and risks of using Liquidity Pools

AMM-based liquidity pools offer users the ability to swap digital assets without relying on centralized entities.

Swapping on the blockchain without centralised platforms

Furthermore, they also offer users the ability to provide liquidity, earn a pro-rata share of trading fees based on their liquidity contribution, and sometimes additional rewards with a concept called yield farming.

What is Yield Farming - yield farming explained
Yield farming explained, because earning interest on your savings account is so 20th century.

However, liquidity pools and providing liquidity aren't perfect, risk-free opportunities; like everything in DeFi - it comes with risks.

Smart contract exploits

Although liquidity pools are subject to strict rules coded into smart contracts, they may also be subject to exploits by hackers if the code has vulnerabilities. A dozen protocols running liquidity pools have already been exploited historically, such as Balancer and dForce resulting in millions of dollars lost.

Impermanent loss

Another risk of using liquidity pools is impermanent loss, which can happen when the two assets deposited in a pool lose value due to market conditions or the swaps themselves. This loss is called “impermanent” when the assets remain in the pool, but these become permanent, realized losses if/when the user removes their funds from the pool.

Impermanent loss graph showing monetary loss due to changes in prices of the assets in the LP 

How to provide liquidity to a liquidity pool

To provide liquidity to a liquidity pool, two distinct assets of equivalent value are required to be deposited into the pool.

If a liquidity pool is already created, you can provide liquidity directly to it; otherwise, you'd need to set it up first. The ETH/USDC liquidity pool on Uniswap V3 allows users to set a range of prices to provide liquidity.

Uniswap V3

You should be aware of the risks of providing liquidity as illustrated above. Furthermore, timing the entry and exit of a liquidity pool position is also worth considering, as, during times of heightened volatility, the pool may generate a lot of fees. However, this may be at the risk of higher impermanent losses.

For updates and special announcements, follow our Instagram (@stakingbits) and join our community on Telegram.