Skip to content
NFTVenue Ledger
Directory

Amm Clob Intent Dex Settlement

Uniswap v4 Singleton PoolManager: EIP-1153 Flash Accounting & Dynamic Fee Hooks

By consolidating all AMM pools into a single PoolManager contract powered by EIP-1153 transient storage, Uniswap v4 slashes multi-hop swap gas and enables programmable hooks.

By Dr. Devon Kurosawa, PhDReview not recorded
Uniswap v4 Singleton PoolManager: EIP-1153 Flash Accounting & Dynamic Fee Hooks — NFTVenue Ledger 2026 quantitative & supervisory data card
NFTVenue Ledger (Concentrated Liquidity AMMs, On-Chain CLOBs, Intent Solvers & MEV): EIP-1153 transient flash accounting, 14-bit hook address masks, and asymmetric dynamic fees.Source: NFTVenue Ledger Institutional Research DeskLicense: CC-BY-4.0

In Uniswap v2 and v3, every trading pair deployed a standalone smart contract via CREATE2, forcing a 3-hop swap (WBTC -> WETH -> USDC -> DAI) to execute four external ERC-20 transfer storage writes across separate pool vaults. The Uniswap v4 singleton architecture consolidates every pool across the entire chain into a single PoolManager.sol contract, pairing internal Flash Accounting backed by Cancun EIP-1153 Transient Storage (TSTORE / TLOAD) with address-encoded lifecycle Hooks and native ETH support (eliminating WETH wrap/unwrap gas).

Situated within our concentrated AMM, CLOB & intent DEX master guide, singleton flash accounting fundamentally transforms routing economics compared to legacy multi-contract DEXs in our marketplaces directory such as Apeswap, Auraswap, and 9mm Pro.

EIP-1153 TSTORE Flash Accounting & the unlockCallback Pattern#

Instead of requiring callers to transfer input tokens prior to each hop, external routers invoke PoolManager.unlock(bytes calldata data), which acquires a transient reentrancy lock and triggers IUnlockCallback(msg.sender).unlockCallback(data). Inside that callback, the router can execute an arbitrary sequence of swap, modifyLiquidity, donate, and ERC-6909 internal claim mints/burns:

  1. 100-Gas Transient Balance Deltas: Every pool operation mutates BalanceDelta accumulators keyed by (caller, Currency) using TSTORE and TLOAD (~100 gas each vs 20,000 / 5,000 gas for persistent SSTORE!), automatically zeroing out at transaction end without gas-refund complexity.
  2. Outer-Boundary Zero-Sum Enforcement: Before unlock returns, PoolManager verifies NonzeroDeltaCount == 0. Only the net residual input and output tokens across the entire multi-hop DAG are settled via sync/settle and take, cutting pool deployment gas by ~99% (a state struct initialization rather than bytecode deployment) and multi-hop swap gas by 55% to 72%.
Uniswap v4 PoolManager unlockCallback flash accounting lifecycle with EIP-1153 TSTORE delta settlement
Uniswap v4 PoolManager unlockCallback flash accounting lifecycle with EIP-1153 TSTORE delta settlementVerified Exhibit

Address-Bitmask Hook Permissions & Custom Accounting (beforeSwapReturnDelta)#

Every PoolKey binds an immutable IHooks contract address whose least-significant 14 bits encode exactly which lifecycle callbacks (beforeInitialize, afterInitialize, beforeAddLiquidity, afterAddLiquidity, beforeRemoveLiquidity, afterRemoveLiquidity, beforeSwap, afterSwap, beforeDonate, afterDonate, plus four ReturnDelta custom-accounting flags) the pool will invoke. Practitioners mine vanity hook deployment salts via CREATE2 so only active flags equal 1, ensuring pools without afterSwap pay zero external call overhead on completion.

Crucially, enabling BEFORE_SWAP_RETURNS_DELTA_FLAG allows a hook to intercept taker orderflow before touching the Concentrated Liquidity AMM curve—enabling JIT internal orderbooks, asynchronous TWAMM execution, permissioned ERC-3643 RWA compliance checks, or custom stable/weighted curves directly inside PoolManager!

Gas & Capability Benchmark: Uniswap v3 vs Uniswap v4 Singleton#

Quantitative Distribution · Uniswap v3 Multi-Contract
Uniswap v3 Multi-ContractUniswap v4 Singleton (PoolManager)
01New Pool DeploymentCREATE2 full co…023-Hop Swap Token Transfers4 ERC-20 transf…03Swap Fee MutabilityFixed at deploy…
Architectural FeatureUniswap v3 Multi-ContractUniswap v4 Singleton (PoolManager)Measured Institutional Impact
New Pool DeploymentCREATE2 full contract (~4.6M gas)initialize(PoolKey) struct (~65k gas)~98.6% cheaper pool creation
3-Hop Swap Token Transfers4 ERC-20 transfer storage writes2 net outer transfers + TSTORE nettingSaves ~75,000–115,000 gas per route
Native Ether (ETH) PairsForced WETH9 wrap/unwrapDirect Currency.wrap(address(0)) ETHSaves ~28,000+ gas on ETH swaps
Swap Fee MutabilityFixed at deployment (1, 5, 30, 100 bps)DYNAMIC_FEE_FLAG (0x800000) up to 100%Real-time realized-volatility LVR defense
High-Frequency Solver BalancesExternal wallet ERC-20 transfersBuilt-in ERC-6909 internal token claimsSolvers keep float inside PoolManager
EVM gas consumption comparison across 1-hop, 3-hop, and ERC-6909 solver swaps in Uniswap v3 vs v4
EVM gas consumption comparison across 1-hop, 3-hop, and ERC-6909 solver swaps in Uniswap v3 vs v4Verified Exhibit

Quantitative Directional Volatility Dynamic Fee Hook Formula#

To shield passive LPs from Loss-Versus-Rebalancing without choking calm-market retail volume, institutional dynamic-fee hooks return lpFeeOverride | OVERRIDE_FEE_FLAG inside beforeSwap as a convex function of trailing EWMA tick-jump velocity and trade direction:

Formula or model from the articleNot independently verified
Asymmetric Volatility & Toxic-Flow Dynamic Fee Hook (in pips, 1 bps = 100 pips):
  • sigmaewma^2(t) = lambda * sigmaewma^2(t - 1) + (1 - lambda) * (tickcurrent - tickprev_block)^2
  • fsymmetric = fmin + betavol * sigmaewma^2(t)
  • fdirectional = fsymmetric + gammaimpact * max(0, sign(swapdir) * (tickcurrent - ticktwap_5m))
  • lpFeepips = clamp(round(fdirectional), fmin, fmax)
  • Worked Volatile Macro Print Block (ETH/USDC Pool):
  • Baseline fmin = 400 pips (4.0 bps); betavol = 0.85; gammaimpact = 18; fmax = 10,000 pips (100 bps)
  • ETH jumps +85 ticks (+0.85%) in 1 block while 5m TWAP lags by +110 ticks:
  • sigmaewma^2 spikes to 2,400 => fsymmetric = 400 + 0.85 * 2,400 = 2,440 pips (24.4 bps)
  • TakerA buys WITH momentum (toxic arb): fdir = 2,440 + 18 * 110 = 4,420 pips (44.2 bps fee!)
  • TakerB sells AGAINST momentum (rebalancing): fdir = 2,440 + 0 = 2,440 pips (or discounted to 4.0 bps!)

Hook Security Auditing & Auction-Managed Extensions#

Because an untrusted custom-accounting hook with beforeSwapReturnDelta can extract arbitrary Currency amounts from msg.sender's open unlock session, aggregators whitelist audited hooks or isolate untrusted pools in separate transactions—compare advanced hook monetization in am-AMM auction-managed pools and tick-spacing depth math across our AMM, CLOB & Intent DEX hub.

Frequently asked questions

How does EIP-1153 transient storage make Uniswap v4 flash accounting cheaper?

EIP-1153 opcodes TSTORE and TLOAD cost roughly 100 gas and automatically discard state when the transaction finishes, allowing PoolManager to net multi-hop balances without paying 5,000 to 20,000 gas for persistent SSTORE writes.

Why are Uniswap v4 hook flags encoded inside the hook smart contract address?

Encoding the 14 boolean callback flags in the hook address bits allows PoolManager to inspect permissions via a 3-gas bitwise AND on the PoolKey parameter in memory, avoiding a 2,100-gas external call or SLOAD.

What are ERC-6909 claim tokens inside Uniswap v4 PoolManager?

ERC-6909 is a minimalist multi-token accounting ledger built directly into PoolManager, letting high-frequency solvers, market makers, and liquidity hooks mint/burn internal token balances without external ERC-20 transfers.

Can a malicious Uniswap v4 hook steal user funds if routed carelessly?

Yes. A pool using unverified custom-accounting flags (beforeSwapReturnDelta) can alter swap prices arbitrarily or consume open transient balances inside an shared unlock session, requiring routers to isolate or whitelist hooks.

Publication record

Published
November 14, 2026
Updated
November 14, 2026
Author
Dr. Devon Kurosawa, PhD
Review
Review not recorded
Automated fact check
Passed in the stored pipeline record
Source URLs
3 recorded

AI assistance recorded: anthropic/claude-opus-4.6. This field does not establish human review or source verification.

Academic & Institutional Attribution

Cite This Research & Embed Live Data Card

Open Attribution License (CC BY 4.0)

Standard academic & institutional research paper citation format.

Dr. Devon Kurosawa, PhD. (2026, November 14). Uniswap v4 Singleton PoolManager: EIP-1153 Flash Accounting & Dynamic Fee Hooks. NFTVenue Ledger. https://nftvenueledger.com/protocols/uniswap-v4-singleton-flash-accounting-dynamic-fee-hooks
Explore Amm Clob Intent Dex Settlement Hub (20) →

NFTVenue Ledger Data, Benchmarks & Contributor Records

Uniswap v4 Singleton, EIP-1153 Flash Accounting & Hooks | NFTVenue Ledger