What is Uniswap v4?
๐ New to this? Just start reading at the top โ it begins in plain English and gets more detailed as you scroll. Jump to any level:
๐ข The simple version
Plain English โ no jargon. Start here.
Uniswap v4 is the latest version of the world's most-used decentralised exchange, introducing "hooks" โ smart contracts that can attach custom logic to any pool at specific lifecycle events (before/after swaps, before/after liquidity changes) โ enabling developers to build any AMM innovation on top of Uniswap's proven liquidity infrastructure.
The Uniswap evolution
Uniswap v1 (2018): the original constant-product AMM (xรy=k). Uniswap v2 (2020): direct ERC-20 to ERC-20 trading without ETH wrapping. Uniswap v3 (2021): concentrated liquidity โ LPs choose price ranges, dramatically improving capital efficiency. Each version was a separate set of pool contracts. Uniswap v4 (2024): rather than another fixed design, v4 makes Uniswap an extensible platform โ the core protocol is minimal, and arbitrary logic can be added through hooks.
What hooks are
A hook is a smart contract address specified when creating a pool. Uniswap v4 calls the hook contract at eight possible points in a pool's lifecycle: before/after a swap, before/after liquidity is added, before/after liquidity is removed, and before/after a donation. Hook developers can insert any logic at these points: dynamic fee adjustment, limit orders (execute when price crosses a threshold), TWAP oracle integration, liquidity mining, JIT (just-in-time) liquidity, MEV capture โ any innovation becomes possible without modifying Uniswap's core protocol.
The singleton contract and flash accounting
Uniswap v3 deployed a new contract for every pool. With millions of possible hook+token+fee combinations in v4, this is impractical. Uniswap v4 uses a singleton architecture: all pools share one contract. Pool state is internal mappings within the singleton. This dramatically reduces gas costs for deploying new pools and for multi-hop swaps (no token transfers between pools, just internal accounting updates). Flash accounting takes this further: all token transfers in a complex multi-pool operation are deferred to the end of the transaction, with only the net delta settled โ eliminating redundant intermediate transfers.
Is it legal in India?
Yes. UNI is a VDA under Indian law. 30% tax and 1% TDS apply. See India regulation.
๐ก A bit more detail
For when you want to go a little deeper.
Hook use cases โ what's been built
Since Uniswap v4's launch in 2024, the hooks ecosystem has produced innovative applications. Dynamic fee hooks adjust the swap fee based on market volatility (higher fee when price moves fast, protecting LPs from impermanent loss). Limit order hooks allow users to place on-chain limit orders that execute when the pool price crosses a specified level โ no custodian, no off-chain infrastructure. TWAP oracles built as hooks provide gas-efficient time-weighted average prices. MEV-redistributing hooks return a portion of arbitrage profits to LPs. Liquidity mining hooks distribute token incentives without a separate staking contract. Geometric-mean AMM hooks implement different invariants (not just xรy=k) within the v4 infrastructure.
Uniswap v4 launched on Ethereum mainnet, Arbitrum, Optimism, Base, and Polygon simultaneously in January 2024. Despite being a newer version, Uniswap v4's TVL and volume grew rapidly as projects migrated from v3 to take advantage of hooks. The hooks ecosystem attracted hundreds of independent developers building novel AMM designs. Uniswap's UNI governance token gained additional relevance: v4 pool deployments require UNI holders to approve new hook contracts through the protocol governance (for safety), creating governance participation pressure. Major market makers and DeFi protocols have deployed custom hooks for their specific liquidity management needs.
EIP-1153 and transient storage โ the gas savings
Uniswap v4 relies on EIP-1153 (transient storage) โ an Ethereum upgrade that introduced storage that persists only for the duration of a transaction. Flash accounting uses transient storage: during a transaction, the "delta" (net token balance owed) for each token is tracked in transient storage. At the end of the transaction, all deltas must be zero โ proving the transaction is balanced โ and the actual token transfers occur. Because transient storage is much cheaper than permanent storage (both to write and to clear), this significantly reduces gas costs for complex multi-pool operations.
Key Uniswap v4 metrics: TVL (total liquidity across all pools), daily volume, number of active hooks deployed, hook category diversity (fee innovation vs limit orders vs oracle), and UNI governance activity. The risk: hooks are arbitrary code that can behave maliciously or have bugs โ a hook with a reentrancy vulnerability could drain its pool. Uniswap Foundation audits and community-reviewed hook registries are addressing this. Live data: CoinGecko ยท Uniswap app.
๐ฃ The full technical picture
For the technically curious.
The hook permission system
Hook contracts are identified by their Ethereum address, which encodes the permissions the hook requires. The last 14 bits of the hook address specify which of the 8 lifecycle callbacks the hook implements โ a hook with address ending in ...0b10101010101010 implements all 7 "before" callbacks. This bit-encoding is enforced by the pool manager: if a hook claims permissions it hasn't implemented, pool creation fails. This deterministic permission system means the pool manager can check hook permissions via a single address comparison rather than calling the hook contract to discover its interface.
Source: Uniswap v4 whitepaper. Uniswap v4 whitepaper ยท Uniswap v4 docs: docs.uniswap.org/contracts/v4
Pool keys and pool IDs
Every Uniswap v4 pool is identified by a PoolKey: a struct containing currency0, currency1, fee, tickSpacing, and hooks address. The PoolId is the keccak256 hash of the PoolKey. Because all pools share the singleton contract, the PoolId replaces the pool contract address as the pool identifier. Multi-hop routes specify a sequence of PoolKeys โ the router calls the singleton once, providing all PoolKeys and the input/output amounts, and the singleton processes all hops in one transaction with flash accounting ensuring only net transfers occur.
Uniswap v4's custom accounting system uses a BalanceDelta type โ a packed int256 representing the delta for both tokens in a swap simultaneously. During a complex operation (say, a 3-pool route), each pool interaction returns a BalanceDelta that is accumulated in the caller's "currency delta" mapping (using transient storage). At transaction end, the IUnlockCallback implementation must ensure all currency deltas are zero โ either by providing the tokens (settle) or by claiming tokens owed from previous operations (take). This "unlock-settle-take" pattern is more gas-efficient than the traditional "approve-transfer-transfer" pattern because it batches all token movements to the end of the transaction.
Key facts
- Type: DEX (extensible AMM platform)
- Key innovation: Hooks (custom logic at 8 pool lifecycle points)
- Architecture: Singleton contract + flash accounting
- Gas savings: EIP-1153 transient storage
- Launched: January 2024 (Ethereum + L2s)
- UNI: Governance token (pool/hook governance)