DeFi Primitives Unpacked How AMMs Create Liquidity Pools
Introduction
Decentralized finance (DeFi) has reshaped the way we think about liquidity, pricing, and capital efficiency on blockchain networks. At the heart of many DeFi protocols are automated market makers (AMMs), which provide a frictionless way for users to trade assets without a traditional order book. This article delves into how AMMs create liquidity pools, the mechanics behind them, and the evolving concept of Protocol Owned Liquidity (POL). We will explore the core primitives that power these systems, walk through the mathematics of pool dynamics, and examine real‑world examples to illustrate the principles at work.
What is an Automated Market Maker?
An automated market maker is a smart contract that maintains a pool of two or more assets and determines the price of each asset relative to the others through a predefined algorithm. Unlike traditional exchanges that rely on limit orders, an AMM sets a continuous, deterministic price function that updates as traders swap assets. The key idea is that liquidity providers (LPs) supply assets to the pool, and in return receive pool shares and a portion of the trading fees.
The Core Primitives
- Liquidity Pool – A shared reserve of two or more tokens that enables swaps.
(See our guide on the fundamentals of liquidity pools in Core DeFi Foundations From AMMs to Protocol Owned Liquidity.) - Invariant Function – A mathematical rule that keeps the product (or sum) of reserves constant during trades.
- Pool Shares – Tokens issued to LPs that represent their proportional ownership of the pool.
- Trading Fees – A small percentage of each trade that is redistributed to LPs.
These primitives allow for permissionless liquidity provision and continuous pricing, which are the hallmarks of DeFi trading.
How Liquidity Pools Are Created
Adding Liquidity
To create a pool, a developer deploys a smart contract that defines the pair of assets and the invariant function. Once the contract is live, anyone can become an LP by depositing a proportional amount of each asset. The contract then issues pool shares that represent the LP’s stake.
For example, to add liquidity to an ETH/DAI pool:
- The LP sends 10 ETH and 10,000 DAI to the contract.
- The contract calculates the total value of the pool before and after the deposit.
- The LP receives pool shares proportional to the new total supply.
These shares can be traded or simply held; they can be used to claim the underlying assets plus accrued fees at any time.
The Invariant Function Explained
The invariant ensures that the pool’s balance remains in equilibrium. The most common invariant is the constant product formula used by Uniswap v2:
x * y = k
Where x and y are the reserves of each token, and k is a constant. When a trader swaps token X for token Y, the contract must adjust x and y such that the product remains equal to k. This mechanism guarantees that the pool always has enough liquidity to fulfill trades, though the price will adjust based on trade size.
Other AMMs use different invariants:
- StableSwap (Curve) uses a weighted sum invariant that reduces slippage for assets with similar value.
- Balancer generalizes the constant product to multiple assets and allows custom weights.
- SushiSwap v2 introduced a “liquidity bootstrapping” mechanism to give early LPs higher rewards.
Pool Share Accounting
When an LP deposits liquidity, the contract calculates how many pool shares to mint based on the current total supply of shares and the new reserves. The formula is:
new shares = (total supply) * (amount added / total reserves)
Thus, an LP’s share of the pool—and consequently their share of fees—remains proportional to the amount of liquidity they provide.
Trading Within the Pool
The Swap Process
When a trader wants to swap token A for token B:
- The trader calls the
swapfunction on the contract, specifying the amount of A to send. - The contract calculates the output amount of B using the invariant and factoring in the fee.
- The contract updates the reserves and transfers B to the trader.
Because the invariant must hold, larger trades will cause more significant price impact. This price impact is built into the AMM’s design and acts as a natural market maker that absorbs shocks.
Fees and Their Role
Fees serve two purposes:
- Incentivize LPs: Fees are distributed proportionally to LPs based on their pool shares, encouraging continuous liquidity provision.
- Stabilize the Pool: By taking a small percentage of each trade, the pool can absorb price shocks and reduce the probability of extreme slippage.
Most AMMs charge a fixed fee—typically 0.3 % on Uniswap or 0.05 % on Curve. Some platforms allow variable fees, where LPs can vote on fee rates.
Impermanent Loss
A significant risk for LPs is impermanent loss (IL). IL occurs when the price ratio of the two assets in the pool diverges from the ratio at the time of deposit. The pool automatically rebalances to maintain the invariant, which may result in fewer tokens than if the LP had simply held them.
The IL formula for a constant product AMM is:
IL = 2 * sqrt(price ratio change) - 1
While the fee rewards can offset IL for active pools, LPs must weigh the trade‑off between potential fees and price volatility. For a deeper dive into how IL works and how protocols mitigate it, see Why AMMs Matter Core DeFi Principles and POL Innovations.
Protocol Owned Liquidity (POL) Models
Traditional liquidity provision relies on third‑party LPs. Protocol Owned Liquidity (POL) flips this model by having the protocol itself supply liquidity. This approach has several advantages:
- Reduced IL: Since the protocol holds both sides of the pair, it can strategically manage exposures.
- Greater Control: The protocol can adjust liquidity supply based on market conditions, demand, or treasury policies.
- Enhanced Security: Protocol‑held funds are often subject to multi‑sig or timelock controls, mitigating the risk of rogue LP behavior.
Examples of POL Implementation
- SushiSwap’s “SushiSwap v3” introduced a POL strategy where the protocol held a portion of the liquidity and distributed yield to token holders.
- Balancer launched a “Balancer Vault” that pools capital from users to create a POL‑style pool with dynamic weights.
- Curve has a “Pool Token” model where the protocol retains a share of the pool, using the remaining tokens to manage risk.
POL models also open the door to novel yield strategies, such as liquidity mining that rewards users for holding protocol‑owned pool shares. Learn how to build a protocol with AMMs and POL in Building DeFi Protocols with AMMs and Protocol Owned Liquidity.
Comparative Analysis: AMMs vs Traditional Order Books
| Feature | AMM | Order Book |
|---|---|---|
| Liquidity Provision | Anyone can deposit | Relies on traders placing orders |
| Price Discovery | Deterministic formula | Market‑driven |
| Slippage | Depends on trade size | Depends on depth |
| Maintenance | Smart contract only | Requires order matching engine |
| Transparency | On‑chain | On‑chain, but hidden depth |
| Liquidity Incentives | Fees | Margin requirements |
AMMs excel in providing continuous liquidity, especially for less liquid assets. However, they may suffer from higher slippage for large trades and cannot provide the same depth of order matching as centralized exchanges.
Real‑World Use Cases
- Decentralized Exchanges (DEXs): Uniswap, SushiSwap, Curve, and Balancer enable token swaps with minimal friction.
- Liquidity Mining: Protocols reward LPs with governance tokens, boosting engagement.
- Synthetic Asset Platforms: Synthetix uses AMM pools to back synthetic asset issuance.
- Cross‑Chain Bridges: AMMs on sidechains (e.g., zkSync, Arbitrum) provide liquidity for bridging assets between chains.
The Future of AMMs and POL
Layer‑2 Scaling
As gas costs rise, many AMMs are migrating to layer‑2 solutions (Optimism, Arbitrum, zkSync). Layer‑2 AMMs can offer similar functionality at lower fees, encouraging greater liquidity provision. For an overview of how AMMs are evolving on Layer‑2, read Delving Into How AMMs and Protocol Owned Liquidity Shape Modern DeFi.
Multi‑Asset Pools
The next wave of AMMs will support complex multi‑asset pools with dynamic weights, allowing for more sophisticated strategies such as yield farming and risk‑adjusted exposure.
Enhanced Security Models
Protocols are exploring more robust governance structures to manage POL. Concepts like “security by design” and formal verification are becoming standard practice.
Integration with Traditional Finance
Hybrid models that blend AMMs with traditional market data (e.g., price oracles, off‑chain order books) could provide the best of both worlds, offering tighter spreads and better price discovery.
Practical Guide: Adding Liquidity to an AMM
Below is a step‑by‑step walk through adding liquidity to an ETH/USDC pool on a generic AMM platform.
Step 1: Connect Your Wallet
- Open the AMM’s web interface.
- Click “Connect Wallet” and select your preferred wallet (MetaMask, WalletConnect, etc.).
- Approve the connection.
Step 2: Approve Token Spending
- Navigate to the “Approve” section for each token (ETH and USDC).
- The contract will request permission to transfer your tokens.
- Confirm the transaction in your wallet.
Step 3: Deposit Liquidity
- Enter the amount of ETH you want to deposit.
- The interface will automatically calculate the required USDC based on the current pool ratio.
- Review the amounts and confirm.
Step 4: Confirm Transaction
- Sign the “Add Liquidity” transaction.
- Once confirmed, you will receive pool shares that represent your stake.
Step 5: Monitor Your Position
- Use the “Pool” dashboard to view your current share of the pool, earned fees, and potential impermanent loss.
- You can withdraw liquidity at any time by burning your pool shares.
Frequently Asked Questions
What is the difference between liquidity pool shares and the actual tokens I deposit?
Pool shares are fungible tokens that represent your proportional ownership of the pool. They entitle you to a share of the underlying assets and any accrued fees.
How do I calculate the price impact of my trade?
The price impact is the difference between the market price and the AMM price after your trade. For constant product AMMs, it can be approximated by:
impact ≈ (trade size / reserve) * 100 %
Can I create a new AMM from scratch?
Yes, but it requires smart contract development, auditing, and community outreach. Most protocols use established frameworks (e.g., Uniswap v3 SDK) to simplify deployment.
What are the risks of a POL model?
While POL reduces IL, it introduces centralization risks. The protocol’s treasury decisions can affect liquidity, and a bug in the POL contract can lead to loss of funds.
Conclusion
Automated market makers have democratized liquidity provision, enabling anyone to become a market participant with minimal friction. By understanding how liquidity pools are created, how the invariant functions maintain equilibrium, and how LPs earn fees, users can make informed decisions about where to allocate capital. Protocol Owned Liquidity models extend these principles, offering protocols greater control over liquidity and opening new avenues for capital efficiency.
As DeFi continues to mature, we anticipate further innovations in AMM design, layer‑2 scaling, and governance. Whether you are a trader, a liquidity provider, or a protocol developer, grasping the mechanics behind AMMs and POL will be essential to navigating the evolving DeFi landscape.
Lucas Tanaka
Lucas is a data-driven DeFi analyst focused on algorithmic trading and smart contract automation. His background in quantitative finance helps him bridge complex crypto mechanics with practical insights for builders, investors, and enthusiasts alike.
Random Posts
How Keepers Facilitate Efficient Collateral Liquidations in Decentralized Finance
Keepers are autonomous agents that monitor markets, trigger quick liquidations, and run trustless auctions to protect DeFi solvency, ensuring collateral is efficiently redistributed.
1 month ago
Optimizing Liquidity Provision Through Advanced Incentive Engineering
Discover how clever incentive design boosts liquidity provision, turning passive token holding into a smart, yield maximizing strategy.
7 months ago
The Role of Supply Adjustment in Maintaining DeFi Value Stability
In DeFi, algorithmic supply changes keep token prices steady. By adjusting supply based on demand, smart contracts smooth volatility, protecting investors and sustaining market confidence.
2 months ago
Guarding Against Logic Bypass In Decentralized Finance
Discover how logic bypass lets attackers hijack DeFi protocols by exploiting state, time, and call order gaps. Learn practical patterns, tests, and audit steps to protect privileged functions and secure your smart contracts.
5 months ago
Tokenomics Unveiled Economic Modeling for Modern Protocols
Discover how token design shapes value: this post explains modern DeFi tokenomics, adapting DCF analysis to blockchain's unique supply dynamics, and shows how developers, investors, and regulators can estimate intrinsic worth.
8 months ago
Latest Posts
Foundations Of DeFi Core Primitives And Governance Models
Smart contracts are DeFi’s nervous system: deterministic, immutable, transparent. Governance models let protocols evolve autonomously without central authority.
1 day ago
Deep Dive Into L2 Scaling For DeFi And The Cost Of ZK Rollup Proof Generation
Learn how Layer-2, especially ZK rollups, boosts DeFi with faster, cheaper transactions and uncovering the real cost of generating zk proofs.
1 day ago
Modeling Interest Rates in Decentralized Finance
Discover how DeFi protocols set dynamic interest rates using supply-demand curves, optimize yields, and shield against liquidations, essential insights for developers and liquidity providers.
1 day ago