Uniswap v2

Uniswap v2: Your Complete Guide to the AMM That Changed DeFi

Uniswap v2 is the battle-tested decentralized exchange (DEX) protocol that made permissionless token swaps mainstream. Running on Ethereum smart contracts, Uniswap v2 introduced direct ERC-20 to ERC-20 pools, flash swaps, and reliable TWAP price oracles, setting the standard for automated market makers (AMMs). Whether you want to swap tokens, provide liquidity, or build DeFi apps, this guide breaks down how Uniswap v2 works and how to use it safely and efficiently.



What Is Uniswap v2?

Uniswap v2 is a non-custodial protocol for swapping tokens using the constant product AMM model (x*y=k). It lets anyone trade directly from their wallet, and anyone can become a liquidity provider to earn fees. By eliminating order books and centralized intermediaries, Uniswap v2 delivers open, resilient, and composable market infrastructure for the DeFi ecosystem.

  • Direct ERC-20 ⇄ ERC-20 pairs with efficient routing
  • 0.3% swap fee distributed to liquidity providers
  • LP tokens that represent your pool share and earnings
  • Flash swaps for capital-efficient arbitrage and strategies
  • Time-Weighted Average Price (TWAP) oracles for safer pricing
“Power your DeFi flow with permissionless liquidity. Uniswap v2 turns your wallet into a global market access point.”


How Uniswap v2 Works

Automated Market Maker (x*y=k)

The core of Uniswap v2 is its constant product formula. Each pool holds two tokens; the product of their reserves stays constant. Swaps move the price along the curve, and a 0.3% fee is added to the pool. This design offers continuous liquidity at all price points, with price impact determined by trade size versus pool depth.

Liquidity Pools and LP Tokens

Users deposit two assets in equal value to create or join a pool. In return, they receive LP tokens that track their ownership share. Over time, LPs earn a proportional cut of the 0.3% fees. When LP tokens are burned, providers withdraw their underlying assets plus accumulated fees, adjusted for any impermanent loss.

Routing and ERC-20 to ERC-20 Swaps

Uniswap v2 enables native ERC-20 ⇄ ERC-20 trades without routing through ETH as a middle asset. The router searches for the best path across multiple pools to reduce slippage and optimize execution, often chaining several pools when that yields a better price.

Flash Swaps

Flash swaps let you withdraw tokens from a pool and execute arbitrary on-chain logic, provided by the end of the transaction you either return the tokens or pay for them. This unlocks capital-efficient arbitrage, refinancing, and complex multi-step strategies—all in a single block.

TWAP Oracles

To mitigate short-term price manipulation, Uniswap v2 includes built-in time-weighted average price (TWAP) oracles. Protocols can read cumulative prices over time and compute reliable averages, which is especially useful for lending platforms, indices, and other pricing-sensitive DeFi applications.



Why Choose Uniswap v2 Today?

  • Proven reliability: Mature contracts trusted by the DeFi community
  • Deep liquidity across countless long-tail assets
  • Composability: Integrates cleanly with wallets, dApps, and on-chain tools
  • Predictable fees: Flat 0.3% per swap distributed to LPs
  • Developer-friendly router, factory, and pair interfaces

Key takeaway: Uniswap v2 remains a robust, permissionless AMM for swapping tokens, bootstrapping liquidity, and building DeFi strategies—with flash swaps and TWAPs that many protocols still rely on.



Uniswap v2 vs. Other Versions

Feature Uniswap v1 Uniswap v2 Uniswap v3
Pair Types ETH ⇄ ERC-20 ERC-20 ⇄ ERC-20 (native) ERC-20 ⇄ ERC-20
Pricing Model Constant product (full range) Constant product (full range) Concentrated liquidity ranges
Fees 0.3% fixed 0.3% fixed Multiple fee tiers (e.g., 0.05%, 0.3%, 1%)
Capital Efficiency Baseline Improved vs v1 Significantly higher via concentrated liquidity
TWAP Oracle No native Yes (built-in) Yes (enhanced)
Flash Swaps No Yes Yes
Gas Cost Lower Moderate Variable, can be higher for complex positions
Liquidity Management Simple, full range Simple, full range Active management recommended


Getting Started with Uniswap v2

  1. Connect your wallet: Use a reputable Web3 wallet and ensure you have ETH for gas.
  2. Select tokens: Choose the pair you want to trade or provide liquidity for.
  3. Review the route: The router may select multiple hops for better pricing; check the minimum received.
  4. Set slippage tolerance: Balance execution certainty against potential price impact.
  5. Approve, then swap/deposit: Approve token spending once; confirm the transaction in your wallet.
  6. Track results: For LPs, monitor your LP tokens, fees earned, and market movement.

Tip: On Uniswap v2, gas costs and network congestion can vary widely. Execute during low-traffic periods and verify token contract addresses to avoid lookalike assets.



Security and Best Practices

  • Use verified token contracts; be wary of tickers with low liquidity.
  • Limit token approvals and periodically revoke unused allowances.
  • Set sensible slippage to reduce MEV and sandwich risk.
  • Prefer hardware wallets for larger transactions.
  • Double-check routes and minimum-out amounts before confirming.
  • Avoid interacting with unknown links or unofficial interfaces.


Common Use Cases for Uniswap v2

  • Swapping long-tail ERC-20 tokens without centralized listings
  • Bootstrapping liquidity for new token launches
  • On-chain TWAP price feeds for DeFi protocols
  • Capital-free arbitrage using flash swaps
  • Simplified trading strategies directly from self-custodied wallets


Uniswap v2 for Developers

Developers integrate Uniswap v2 using standardized interfaces for the Factory, Pair, and Router contracts. The Router handles pathfinding and token approvals; Pairs expose reserves and pricing; the Factory lists and creates pairs. TWAP oracles are derived from cumulative price data stored in each pair.

Integration Tips

  • Use IUniswapV2Router02 for swaps and liquidity flows.
  • Query pair getReserves() to estimate slippage and price impact.
  • Rely on cumulative prices for TWAPs; avoid single-block spot reads.
  • Simulate complex routes on a fork before mainnet execution.


Costs, Slippage, and Performance

Every swap on Uniswap v2 incurs a 0.3% fee that accrues to LPs. Users also pay network gas fees, which vary with congestion. Slippage is determined by trade size relative to pool depth; larger pools and multi-hop routes can reduce it. For high-value trades, consider splitting orders or executing during quieter network windows.



Limitations of Uniswap v2

  • Slippage on thin pools: Price impact can be significant on low-liquidity pairs.
  • Impermanent loss: LPs face divergence loss when prices move.
  • Capital efficiency: Lower than concentrated-liquidity models like v3.
  • MEV exposure: Transactions can be reordered; use slippage controls.


Uniswap v2 vs. Centralized Exchanges

Unlike centralized exchanges, Uniswap v2 never takes custody of funds. Trades settle on-chain, available 24/7 with transparent pricing. You maintain wallet ownership and can access long-tail assets without gatekeepers. The trade-off is exposure to gas fees, on-chain risks, and the need to self-manage approvals and security.



Frequently Asked Questions about Uniswap v2

What is Uniswap v2 in simple terms?

It’s a decentralized exchange protocol using an AMM to swap ERC-20 tokens directly from your wallet. Liquidity pools replace order books, and a 0.3% fee goes to liquidity providers.

How is Uniswap v2 different from Uniswap v3?

Uniswap v2 uses full-range liquidity with a simple 0.3% fee, while v3 adds concentrated liquidity and multiple fee tiers for higher capital efficiency but more active management.

What fees will I pay on Uniswap v2?

Each swap includes a 0.3% pool fee plus network gas fees. The 0.3% is distributed to LPs in the pool you trade through.

Is Uniswap v2 still safe to use?

Uniswap v2 contracts are widely audited and battle-tested. Always use trusted interfaces, verify token addresses, and follow wallet security best practices.

Can I earn by providing liquidity on Uniswap v2?

Yes. LPs earn a share of the 0.3% fees proportional to their pool share. Returns depend on volume, liquidity depth, and price movements (which can cause impermanent loss).

What are flash swaps on Uniswap v2?

Flash swaps let you withdraw tokens from a pool and repay them within the same transaction, enabling arbitrage and complex strategies without upfront capital.

How do TWAP oracles work in Uniswap v2?

Each pair tracks cumulative prices over time. Consumers compute a time-weighted average between two timestamps, filtering out short-term manipulation and block-level volatility.

How can I reduce slippage and MEV risk?

Use reasonable slippage limits, consider smaller batches for large trades, transact during off-peak times, and confirm minimum-out values before signing.



Ready to experience permissionless trading? Explore, swap, or provide liquidity with Uniswap v2 today—own your keys, own your trades, and power your DeFi strategy.