Uniswap V4 Hooks
A programmable AMM architecture that lets developers attach custom smart-contract logic ('hooks') to liquidity pools at key lifecycle points, turning Uniswap from a fixed AMM into an extensible platform.
▶ Run interactive simulation animated mechanism with editable parameters
How it works onchain
Summary
Uniswap V4 is the fourth major version of the largest onchain automated market maker (AMM). Its defining innovation is hooks: developer-supplied smart contracts that execute at defined points in a pool's lifecycle (before/after initialize, add/remove liquidity, swap, and donate). Where V3 fixed the AMM's behavior in immutable core code, V4 reframes Uniswap as a platform on which anyone can deploy pools with bespoke logic — dynamic fees, onchain limit orders, time-weighted average market makers (TWAMMs), just-in-time liquidity, MEV internalization, and lending-aware liquidity — without forking the protocol.
The vision was published by Uniswap founder Hayden Adams on 13 June 2023, alongside a draft whitepaper and open-sourced (Business Source License 1.1) core and periphery repositories. After roughly 18 months of development, nine independent audits, a $2.35M security competition (500+ participants), and a $15.5M bug bounty, V4 launched to mainnet and nine other chains on 31 January 2025. The canonical Ethereum PoolManager singleton is deployed at 0x000000000004444c5dc75cb358380D2e3dE08A90.
Design (Mechanism)
Three architectural pillars underpin V4:
- Singleton PoolManager. All pools live inside one contract rather than one contract per pair (as in V2/V3). This collapses pool-creation cost (Uniswap cites up to ~99% / "99.99%" cheaper) and makes multi-hop routing cheaper because trades no longer transfer tokens between many separate pool contracts.
- Flash accounting. Instead of settling token transfers after every individual pool action, the PoolManager tracks running balance deltas and requires only the net balances to be settled at the end of a transaction (the "lock" / unlock pattern). This is made gas-cheap by EIP-1153 transient storage, which V4's launch was timed around (transient storage shipped with Ethereum's Dencun upgrade in 2024).
- Hooks. When a pool is created, its deployer optionally attaches a hook contract. The permissions a hook may exercise are encoded in the low-order bits of the hook's address — the PoolManager reads flags directly from the address to know which callbacks to fire, making the hook's capabilities immutable and transparent once deployed. Hooks can also collect their own fees and, via dynamic-fee flags, adjust swap fees per-block or per-swap.
Native ETH support returns (V2 required WETH), further reducing gas on ETH pairs. Critically, hooks are trusted code: a malicious or buggy hook can misprice, block, or drain the pool it governs, so security shifts partly from Uniswap's audited core onto the (often unaudited) hook authored by third parties.
Outcome
By Uniswap's account, over 150 custom hook plugins existed at launch. Third-party trackers report several thousand hook-enabled pools by 2026 (one figure: 2,500+ custom pools; another tracker cited ~4,689 pools). V4 crossed $1B TVL roughly 177 days after launch (late July 2025); by mid-2026 measured V4 TVL was ~$600M+, though TVL understates activity because hooks like EulerSwap rehypothecate idle capital elsewhere. Cumulative V4 volume was reported near ~$355B by June 2026, with substantial share on Ethereum mainnet and on Uniswap's own L2, Unichain.
Notable hooks that emerged: Bunni v2 (rehypothecating LP liquidity and custom liquidity distribution functions), EulerSwap (LP deposits double as lending collateral for just-in-time borrowing), Angstrom (MEV-aware app-specific ordering), Silo V2, and Flaunch. The core protocol itself has, to public knowledge, not been exploited. However, the hook surface has: Bunni v2 was exploited for ~$8.3–8.4M in early September 2025 via a rounding/precision bug in its own custom withdrawal and liquidity-distribution logic (not in V4 core), and the Bunni team subsequently wound the product down. This cleanly illustrates V4's central trade-off — the platform is robust; the composable logic built on top of it is only as safe as each hook.
Why it worked
- Platform economics. By making pool deployment near-free and letting builders ship arbitrary logic without governance approval, V4 turned Uniswap into a permissionless app platform, capturing innovation that previously required standalone AMM forks (Curve-style, TWAMM, limit orders) directly inside Uniswap liquidity.
- Real gas savings. The singleton + flash-accounting + transient-storage combination delivered concrete cost reductions for multi-hop and ETH routes, giving integrators a rational reason to migrate.
- Credible security process. Nine audits, a large competition, and a record bug bounty (with no critical findings reported) plus Uniswap's incumbent liquidity and brand lowered adoption risk for LPs and integrators.
- Timing with EIP-1153. V4's efficiency story was unlocked by transient storage landing at the base layer, letting Uniswap ship an architecture that would have been prohibitively expensive earlier.
Limitations and criticisms
Real caveats persist alongside the strong adoption numbers:
- Trust surface expansion. Hooks are trusted for the pools they govern; a bug in hook code (Bunni v2) can lose user funds even when Uniswap core is flawless. This shifts security burden to teams with far less auditing budget than Uniswap Labs.
- Fragmentation and complexity. Arbitrary per-pool logic complicates routing, price discovery, and safety guarantees; solvers and aggregators must reason about heterogeneous, potentially adversarial hooks.
- BSL licensing friction. The 4-year Business Source License limits permissionless forking/commercial reuse of core, drawing criticism from open-source purists.
- TVL optics. Headline V4 TVL looks modest partly because capital-efficient hooks reduce idle liquidity, making the metric a poor proxy for real usage.
Lessons
- Programmability multiplies both innovation and attack surface. Making a protocol extensible is powerful, but every hook is trusted code; the platform's audits do not protect users from the logic built on top of it (Bunni v2).
- Address-encoded permissions are an elegant capability model. Encoding hook powers in the contract address makes capabilities immutable and cheaply checkable — a reusable pattern for permissioned plugin systems.
- Architecture should be co-designed with base-layer primitives. V4's economics depended on EIP-1153 transient storage; the biggest gains came from aligning protocol design with an EVM upgrade rather than working around the old cost model.
- TVL is the wrong yardstick for capital-efficient AMMs. As liquidity gets rehypothecated and summoned just-in-time, volume and capital-efficiency metrics describe reality better than locked value.
Redesign (EDITORIAL — hypothesis, not fact)
The following is the researcher's analysis, not established fact.
The largest open risk in V4 is the asymmetry between a hardened core and an unbounded, mostly-unaudited hook ecosystem. A redesign could add a tiered hook trust registry: hooks carry onchain attestations (audit hashes, verified-source flags, bug-bounty coverage) that front-ends and routers can enforce, so retail LPs are steered toward vetted hooks while advanced users opt into unaudited ones explicitly. Second, a standardized, restricted "safe hook" template — a constrained bytecode/interface class that provably cannot re-enter the PoolManager in dangerous ways or mint phantom liquidity — would let most builders ship within guardrails, reserving full arbitrary hooks for audited teams. Third, given that the Bunni exploit stemmed from rounding in a custom liquidity distribution function, a shared, formally-verified math library for liquidity/rounding operations (canonically maintained by Uniswap) would remove the single most repeated class of hook bug. Finally, since TVL misleads, the ecosystem would benefit from a standardized capital-efficiency metric (volume-per-idle-dollar) surfaced natively, so LP risk/return is legible without third-party dashboards. None of these change V4's core thesis; they aim to make the trusted-hook trade-off safer to navigate at scale.
Sources
- Our Vision for Uniswap v4 (Hayden Adams) — primary (docs)
- Uniswap v4 is Here – A New Era of DeFi — primary (docs)
- Uniswap v4 Deployments (developers.uniswap.org) — primary (docs)
- Uniswap V4: Pool Manager (Etherscan) — primary (contract)
- Uniswap/v4-core smart contracts (GitHub) — primary (contract)
- Uniswap v4 Hooks Security Deep Dive (Cyfrin) (analysis)
- Bunni V2 Exploit: $8.3M Drained via Liquidity Flaw (QuillAudits) (audit)
- What's New in Uniswap V4: Three Key Changes and Two New Protocols (DWF Labs) (analysis)
Related experiments
Last verified: 2026-07-26 · Spot an error? Suggest a correction