Uniswap Developers
website·Indexed 43 days ago
https://docs.uniswap.org/Integration documentation for the Uniswap Protocol, including the Uniswap API, Uniswap LP API, and Uniswap v4. Covers technical implementation for routing, error handling, Permit2, liquidity provisioning, v4 hooks security frameworks, Unichain, and supported swap chains.
What's inside Uniswap
- The Uniswap Smart Wallet, implemented as 'Calibur', provides smart-account capabilities to existing Externally Owned Accounts (EOAs) via EIP-7702 delegation. This enables batched transactions, gas abstraction, alternative signers, and validation hooks.
Overview of the Liquidity Launchpad
The Liquidity Launchpad uses a Continuous Clearing Auction (CCA) system to bootstrap initial liquidity for new tokens. Bidders submit time-distributed bids to discover a clearing price; once the auction completes, proceeds are migrated into a Uniswap v4 pool.Overview of The Compact protocol
The Compact is a resource-lock protocol designed for gasless cross-chain order intents. Users deposit assets into resource locks and sign EIP-712 compacts, which authorize allocators to spend those locks based on verified arbiter conditions.Understand Uniswap v4 core architecture
Uniswap v4 introduces several architectural changes to improve gas efficiency and extensibility:
- Singleton PoolManager: A single contract manages all pools, reducing gas for pool creation and multi-hop swaps.
- Hooks: Custom contracts (
IHooks) that execute logic before/after swaps or liquidity changes. They enable dynamic fees, limit orders, and KYC gating. Permissions are encoded in the hook's address. - Flash Accounting: Token deltas are accumulated and settled once at the end of a transaction, removing intermediate transfer overhead.
- ERC-6909: A multi-token claims standard used for efficient balance accounting.
- Dynamic Fees: Hooks can compute fees per swap based on volatility or volume.
- Subscribers: External contracts that can be notified of position events without owning the position.
Use Uniswap Smart Wallet (Calibur) for Account Abstraction
The Uniswap Smart Wallet (Calibur) uses EIP-7702 delegation to add smart-account capabilities to existing EOAs without changing the user's address. Key features include:
- Transaction Batching: Supported via ERC-7821.
- Gas Abstraction: ERC-4337-style gas management.
- Security & Standards: Implements ERC-7739 (defensive rehashing) and ERC-7914 (ETH transfer allowances).
Understand Uniswap v3 Concentrated Liquidity
Uniswap v3 improves capital efficiency by allowing liquidity providers to specify custom price ranges. Key features include:
- Fee Tiers: Multiple tiers available (0.01%, 0.05%, 0.3%, 1%).
- Position Management: Positions are represented as NFTs (ERC-721) via the
NonfungiblePositionManager. - Oracles: Built-in TWAP price oracles.
- Capabilities: Supports single-hop and multi-hop swapping, flash swaps, and concentrated liquidity management.
Understand the role of Uniswap SDKs
Uniswap SDKs are TypeScript libraries used to compute pool math, build calldata, and model protocol primitives on the client side. They do not submit transactions directly; developers must take the SDK output and submit it using an RPC client such as Ethers or Viem.Integrate Uniswap v2 Constant Product AMM
Uniswap v2 uses the constant-product formula (x * y = k) with full-range liquidity per pair. It is a simpler implementation than v3 and supports flash swaps and TWAP-style on-pair oracles.Choose a Uniswap integration path
Depending on the required complexity and use case, developers can integrate with Uniswap via five primary paths:
- Custom Linking: Best for simple referrals; uses URL query strings to prefill the Uniswap interface.
- Uniswap API: Best for dApps, wallets, and bots; a hosted REST API for routing, quoting, and transaction construction (supports v2, v3, v4, and UniswapX).
- Uniswap LP API: Best for LP UIs and automated strategies; a hosted REST API for managing liquidity position lifecycles.
- Uniswap SDKs: Best for front-ends and custom routing; TypeScript libraries for local computation of routes, quotes, and calldata.
- Smart Contracts: Best for onchain integrations, arbitrage, and custom hooks; direct interaction with the Universal Router, PoolManager, or Solidity hooks.
Understand Unichain network details
Unichain is an OP Stack Layer 2 (L2) aligned with Uniswap. It features Flashblocks (200ms preconfirmations), fair transaction ordering, and MEV protection.{ "mainnet": { "chainId": 130 }, "sepolia": { "chainId": 1301 } }Swap tokens from a smart contract
To perform swaps from a smart contract across v2, v3, and v4 in a single transaction, use the Universal Router as the entry point.Implement Intent-Based Trading with UniswapX
UniswapX is an intent-based protocol where users sign off-chain orders and fillers compete to execute them.
- Benefits: Gasless for users (filler pays gas) and MEV-protected via reactors with price guarantees.
- Auction Types:
- Ethereum and Arbitrum: Dutch auctions.
- Base and Unichain: Priority-fee auctions (OP Stack).
- RFQ Flow: Supports both indicative and hard quotes.
- Chain Availability: V2 is available on Ethereum, Arbitrum, and Base; V3 is available on Arbitrum.