Uniswap v4: A Programmable AMM for Power Users

Uniswap v4 reframes a DEX as a programmable liquidity kernel. Where v2/v3 fixed most behaviors in-contract, v4 exposes the swap/LP lifecycle to developer-supplied hooks. Paired with a singleton PoolManager and flash accounting, v4 compresses multi-pool strategies, custom fee policies, vault integrations, and execution safeguards into single transactions, without forking Uniswap. v4 is live across major EVM L1/L2s and positioned as the lowest-cost, most customizable Uniswap to date.
TL;DR
Uniswap v4 introduces a highly flexible and extensible AMM model with key innovations like programmable pools, flash accounting, and native ETH support. By externalizing custom logic into hook contracts and enabling dynamic fees, it allows for more tailored and efficient liquidity management.
To understand the full impact and the projects adopting these features, read on for a detailed breakdown below:
Uniswap v4 externalizes custom logic into hook contracts that run before/after key pool actions (init, add/remove liquidity, swap, donate). Hook permissions are encoded in the hook address, allowing the PoolManager to dispatch only the functions a hook claims to implement. This makes the AMM an extensible platform rather than a fixed design.
All pools live under one PoolManager (singleton). Swaps/liquidity changes accrue transient debits/credits during an unlock call and only net token transfers are settled at the end, enabled by EIP-1153 Transient Storage, reducing gas and enabling cross-pool compositions in a single call.
v4 restores native ETH support (no WETH wrapping) and allows dynamic pool fees (via hooks) plus optional hook fees for custom value flows.
Unlike v3, v4 removes the bundled oracle; projects must compose with external oracles (or v3 pools) or implement bespoke oracle hooks, which has both flexibility and risk implications.
Early notable adopters include Bunni (rehypothecating LP liquidity), EulerSwap (lending-aware AMM compatible with v4 routing), Silo V2 (hook-programmable isolated markets), Angstrom (MEV-aware app-specific sequencing), and Flaunch (fair-launch hook stack).
Technical Architecture
In this section, we look at how the architecture of Uniswap V4 works, and what PoolManager, and Balance Netting are.
Singleton PoolManager
In v3, each pool was its own contract; in v4, all pool state is managed by one PoolManager (the “singleton”). Builders interact by calling PoolManager.unlock to enter a session where they can orchestrate multiple actions, swaps, liquidity mods, donations, across pools before final settlement. This consolidates state access, slashes deployment costs, and allows deep cross-pool orchestration.
Flash Accounting via Transient Storage
Within an unlock session, changes are tracked as BalanceDelta entries in transient storage (EIP-1153). Only the net token deltas are paid at the end, eliminating intermediate transfers (and their SSTORE costs), which is especially impactful for multi-hop/multi-pool routes and integrators composing swaps with LP updates.
Solvency invariant (informal). Let Delta_i be the signed token delta (owed to the PoolManager if >0) for token i across all actions in a session. The PoolManager enforces that after the integrator’s callback finishes, for all tokens i the outstanding Delta_i must be fully settled (via take/settle) or the transaction reverts. Gas gains arise because all intermediate legs are book-kept, not transferred, until the end.
Hooks: Programmable Control Points
Here we see what hooks are, and how they help in fee management, and enabling native ETH instead of WETH for the pools.
What a Hook Is?
A hook is an external contract attached to a pool that can implement any subset of the before/after callbacks for initialize, modifyLiquidity, swap, and donate. The hook’s address encodes which callbacks it implements; PoolManager reads this bitmask to conditionally dispatch without extra storage. One hook can serve many pools; each pool has at most one hook.
Key consequences
Dynamic Fees and Hook Fees
Native ETH, Position Manager, and SDK
Mathematical Foundations (v3 carry-over, v4 generalization)
Uniswap’s core swap step still respects constant-product style invariants within each tick segment. In v3/v4, price is stored as √ P in Q96 fixed-point (a gas-efficient choice):
Liquidity-aware price movement under an amount-in (token0 for example) at current √ P with active liquidity L and next bound √ P’ obeys (rounded to spec rules):
which is the basis of SqrtPriceMath.getNextSqrtPriceFrom{Input,Output} and the Delta amount formulas used to compute exact swap deltas across tick ranges.
Fees. With fee fraction f (static tiers in v3; dynamic in v4) the effective input per step is Delta x_eff = Delta x . (1- f ). Dynamic fees mean f = f(sigma, t, inventory, oracle, …) decided by the hook at execution time; the stepwise math is unchanged except the integrator must query the fee per step.
LP position math (unchanged conceptually from v3): within bounds [a,b] and current √ P, token0/token1 reserves attributable to liquidity L follow the standard closed forms (piecewise by region), and deltas are derived from the above SqrtPriceMath relations; proofs and derivations remain those of v3.
v4 vs v3: A Precise Comparison
| Dimension | v3 | v4 |
|---|---|---|
| Pool topology | One contract per pool | Singleton PoolManager manages all pools |
| Execution model | Direct calls to each pool | unlock session; multi-pool orchestration in one call |
| Accounting | Immediate token transfers each step | Flash accounting with transient balance netting, settle at end |
| Customization | None (beyond fee tiers, CLAMM params) | Hooks for before/after callbacks; dynamic fees; hook fees |
| Fee policy | Static fee tiers per pool | Dynamic via hook + optional hook fees |
| ETH support | WETH only | Native ETH paths allowed |
| Oracle | Built-in TWAP oracle used widely | No built-in oracle, compose externally / via hooks |
| Gas profile | Multiple transfers per hop | Fewer writes/transfers; EIP-1153 powered netting |
| Dev surface | Pool factory + per-pool state | PoolManager + hook interface + Position Manager |
Security Model & Risk Surfaces
Some of the enforced security measures, despite the openness in developing, are:
For builders, see checklists from security firms and reference hook libraries before going live.
Developer Playbook: How to Build and Ship on v4
Some of the important notes developers must take when diving into working with Uniswap v4 are:
- Pool design
Decide static params (tick spacing, initial price) and whether the pool uses dynamic fees (DYNAMIC_FEE_FLAG) and a hook.
- Hook design
Implement only the callbacks you need; mine/deploy an address whose bitmask encodes your implemented set. Validate pre/post-conditions on each callback (e.g., fee bounds, oracle freshness).
- Integrations
Use Position Manager for LP UX and StateView for read paths. Prefer a single unlock session per complex action to maximize flash accounting benefits.
- Testing & audits
Simulate adverse flows (sandwiching, toxic order flow, oracle gaps), verify that BalanceDelta nets to solvency, and fuzz state transitions across hooks. Guidance and example hooks abound.
Who’s Using v4, and What They Optimized
There are some protocols, besides Uniswap, that utilize the Uniswap v4 model. Not all DEXs in the market decided to take the Uniswap v4 model instead of v3, but the following protocols utilize this system.
Bunni, Re-hypothecating LP Liquidity
What it is?
A “shapeshifting” v4 DEX whose hook re-hypothecates deposited assets into yield sources, blending swap fees with external APY.
Why it matters?
Raises effective LP returns without manual vault routing, and can pair with dynamic fees to tune inventory risk.
Evidence:
Public research and the project’s repos brand Bunni as “Built on Uniswap v4”; community data often shows Bunni among the largest v4-hook volumes.
EulerSwap, Lending-Aware AMM Compatible with v4
What it is?
An AMM that natively integrates Euler vaults; hooks allow just-in-time borrowing, custom curves, and IL-hedging behaviors while staying compatible with Uniswap routing/solvers.
Why it matters?
Collapses AMM + money-market legibility; capital serves multiple roles at once.
Evidence:
Euler’s launch materials and docs emphasize v4-hook compatibility and design goals.
Silo V2, Hook-Programmable Isolated Markets
What it is?
A two-sided isolated lending framework exposing a hooks stack to instantiate markets with custom LTV curves, interest-rate models, and oracle choices.
Why it matters?
Encodes isolation and programmability at the market boundary; a natural fit alongside v4 pools for routing collateral/flow.
Evidence:
Silo’s public pages describe hooks-based programmable deployments and isolated-pair core concepts.
Angstrom (Sorella Labs), App-Specific Sequencing (ASS)
What it is?
A v4 hook + off-chain auction network that controls order flow sequencing to rebate MEV and protect swappers/LPs.
Why it matters?
Moves execution welfare inside the app’s mechanism instead of leaking to block builders.
Evidence:
Uniswap Foundation features Angstrom as a v4 hook; multiple write-ups describe ASS and its goals.
Flaunch, Fixed-Price Fair Launches via Hooks
What it is?
A launchpad on Base using a PositionManager-based v4 hook to constrain liquidity during a timed fixed-price phase, plus bespoke controls (e.g., progressive bid walls).
Why it matters?
Codifies fair-launch mechanics at the pool boundary, mitigating bot sniping and chaotic initial price discovery.
Evidence:
Flaunch docs specify their Uniswap v4 hook and additional swap mechanics; ecosystem articles cover their hook designs.
Dozens more (Aegis DFM dynamic fees, community hook libraries, SDK tooling) illustrate an expanding v4 surface area for protocol engineers.
Conclusion
Uniswap v4 generalizes “AMM as a product” into AMM as a platform. The combination of singleton state, flash accounting, and hook-programmability decouples core invariants from policy logic. For sophisticated teams, this unlocks specialized market microstructure, dynamic fees, execution control, vault coupling, without sacrificing Uniswap’s liquidity network or routing surface. The trade-off is complexity: correctness and security move up the stack into your hook. If you get the math and mechanism design right, v4 offers a uniquely capital- and gas-efficient canvas for DeFi innovation.
References & Further Reading
Frequently asked questions
Check out most commonly asked questions, addressed based on community needs. Can't find what you are looking for?
Contact us, our friendly support helps!
How do I migrate strategies from Uniswap v3 to v4?
Port your CLAMM math and ranges, then implement policy in a hook (e.g., dynamic fees, allowlists). Use the v4 Position Manager to batch LP ops within a single unlock session for gas efficiency.
Does removing the built-in TWAP oracle increase risk?
Yes; v4 requires external or bespoke oracle hooks. Pair with robust sources (e.g., v3 TWAP + third-party) and enforce freshness/threshold checks inside the hook to avoid manipulation.
Where do v4 gas savings come from?
From the singleton PoolManager and flash accounting (EIP-1153). Multi-pool routes and LP adjustments net balances during one unlock call, settling only the final deltas, fewer writes and transfers.



