Liquidity Pools & Automated Market Makers (AMMs)

10 June 2025

Liquidity Pools & Automated Market Makers (AMMs)



1. Liquidity Pools & Automated Market Makers (AMMs)

Most modern DEXs (Uniswap, PancakeSwap) rely on **liquidity pools** instead of traditional order books.  


How AMMs Work

- **Liquidity Providers (LPs)** deposit **two tokens** in a pool (e.g., ETH/USDC).  

- The pool uses a **mathematical formula** to determine prices (e.g., `x * y = k` in Uniswap).  

- When traders swap tokens, the pool adjusts prices **automatically** based on supply and demand.  


Example: Uniswap’s Constant Product Formula

- If a pool has **100 ETH** and **200,000 USDC**, then `k = 100 * 200,000 = 20,000,000`.  

- If a trader buys **1 ETH**, the new pool balance must satisfy:  

  - `(100 - 1) * (200,000 + Price) = 20,000,000`  

  - Solving gives **~2,020.20 USDC per ETH** (price adjusts dynamically).  


Slippage & Impermanent Loss

- **Slippage**: Large trades move prices unfavorably (especially in low-liquidity pools).  

- **Impermanent Loss (IL)**: LPs lose value if token ratios change significantly (e.g., ETH price surges vs. USDC).  


2. Order Book DEXs (Like Traditional Exks)

Some DEXs (e.g., **Serum on Solana, dYdX**) use **on-chain order books** where:  

- Buy/sell orders are stored on the blockchain.  

- Matching is done via **smart contracts** (not a central server).  

- Requires **high throughput** (Solana is fast, Ethereum struggles).  


**Hybrid DEXs (Off-Chain Order Book + On-Chain Settlement)**

- **Example**: Loopring, Immutable X.  

- Orders are matched **off-chain** (for speed) but settled **on-chain** (for security).  


---


3. Cross-Chain DEXs (Swapping Between Blockchains)

Some DEXs allow trading between different blockchains **without wrapping tokens**:  

- **Thorchain**: Uses a network of vaults to swap BTC, ETH, BNB, etc.  

- **Chainflip**: Similar, but with improved security.  


How Cross-Chain Swaps Work

1. User sends **BTC** to Thorchain’s vault.  

2. Thorchain locks BTC, mints **synthetic BTC (Rune-based)**.  

3. Swaps to **ETH** via liquidity pools.  

4. ETH is sent to the user’s wallet.  


4. Aggregators (Finding Best Prices Across DEXs)

DEX aggregators (like **1inch, Matcha, Paraswap**) scan multiple DEXs to find the **best swap rates** by:  

- Splitting trades across pools to reduce slippage.  

- Using gas optimization to save fees.  


Example: 1inch’s Pathfinder

- If swapping **1000 USDC → ETH**, 1inch might:  

  - Split 500 USDC on Uniswap.  

  - Route 300 USDC to SushiSwap.  

  - Send 200 USDC to Balancer.  

  - Combine for the **best overall rate**.  



5. DEX Governance & Tokens

Many DEXs have **governance tokens** (e.g., UNI, SUSHI, CAKE) that allow:  

- Voting on protocol changes.  

- Earning fees from trading.  

- Staking for rewards.  


Example: Uniswap’s Fee Switch Debate

- UNI holders can vote to enable **0.05% protocol fees** (currently off).  

- If turned on, fees go to **UNI stakers** instead of just LPs.  


6. Security Risks in DEXs

While DEXs are **non-custodial**, they still face risks:  

Ri s k 

Ex a m p le 

Solution 

Smart Contract Bugs 

2021 Uranium Finance hack ($50M loss) 

Audits, bug bounties. 

Rug Pulls 

Fake tokens with malicious code 

Use verified tokens (CoinGecko). 

Front-Running 

Bots exploit pending trades. 

Use private transactions (Flashbots). 

Oracle Manipulation 

False price feeds trick swaps. 

Use decentralized oracles (Chainlink). 


7. Future of DEXs

- **Layer 2 Scaling**: Uniswap on Arbitrum, Optimism (lower fees).  

- **NFT DEXs**: Blur, Sudoswap (NFT trading via AMMs).  

- **MEV Protection**: CowSwap, Flashbots (reduce bot exploitation).  

- **Institutional DEXs**: Aave Arc, Fireblocks (compliant DeFi).  



Final Thoughts

DEXs are evolving rapidly, solving issues like **high fees, slippage, and security**. While **CEXs still dominate volume**, DEXs offer **true ownership, privacy, and innovation** in DeFi.  



0 comments :

Post a Comment