XLinkedInTelegram
Smart Contract

What Is Uniswap v4? (Technical Breakdown)

Explore a detailed technical breakdown of Uniswap v4, innovative uniswap v4 hooks, architecture and impact on decentralized finance.

Author
QuillAudits Team
August 28, 2025
What Is Uniswap v4? (Technical Breakdown)
XLinkedInTelegram

Uniswap has redefined decentralized trading by replacing traditional order books with Automated Market Makers (AMMs), enabling swaps without intermediaries. At the core of this model are liquidity pools with token reserves, funded by liquidity providers who earn fees in return for their contributions. Over the years, Uniswap has refined this design to enhance capital efficiency and user experience. With the release of Uniswap V4, the protocol introduces:

  • Singleton Architecture
  • Customizable Hooks
  • Flash Accounting
  • Native ETH Support

Enabling developers to build highly flexible pools while reducing gas costs and fragmentation. These innovations mark a major step forward in both technical design and ecosystem composability.
 

Evolution of Uniswap: From v1 to v4

Uniswap v1 (2018)

Introduced AMMs using the constant product formula x * y = k. Enabled ETH ↔ ERC20 swaps and permissionless liquidity, but ERC20 ↔ ERC20 swaps required routing through ETH, increasing costs.
 

Uniswap v2 (2020)

Added ERC20 ↔ ERC20 pools, multi-hop routing, flash swaps, and a TWAP oracle. However, LPs still had to provide liquidity across the entire price curve, leading to inefficiency and higher impermanent loss.
 

Uniswap v3 (2021)

Brought concentrated liquidity, letting LPs choose specific price ranges. This improved capital efficiency, boosted fee earnings, and reduced impermanent loss by narrowing exposure. Yet, it introduced complexity for LPs and liquidity fragmentation across chains, while forks diluted network effects.
 

Uniswap v4 (2025)

Introduces a singleton architecture, customizable hooks, and flash accounting for major gas savings. With native ETH support and EIP-1153 transient storage, V4 reduces costs and enables developers to experiment with new AMM designs—including mechanisms that could further address impermanent loss.
 

What is Impermanent Loss?

Impermanent loss (IL) occurs when the value of assets you provide as liquidity grows differently compared to simply holding them. It’s called impermanent because it only becomes permanent once you withdraw your funds from the pool.

Example:

You deposit 1 ETH (worth $2,000) and 2,000 USDC into a pool. Later, ETH’s price doubles to $4,000.

  • If you had simply held your assets, you’d now have 1 ETH + 2,000 USDC = $6,000.
  • In the pool, however, your assets rebalance. You might end up with ~1.41 ETH and ~1,414 USDC, worth about $5,656.

The $344 difference is your impermanent loss.

Liquidity providers accept this risk because they earn trading fees that can offset or exceed the IL over time.
 

How does Providing Liquidity work?

Providing liquidity in Uniswap V4 is orchestrated through the PoolManager contract via the modifyLiquidity flow. Unlike V2/V3, where each pool was its own contract, V4 consolidates all pools under a singleton PoolManager, with pool logic implemented as libraries. This design allows for more efficient liquidity operations, unified accounting, and hook extensibility.

uinswap_liquidity.webp

Adding or removing liquidity follows a clear execution path:

  1. Initiation – User interacts with a periphery contract (e.g., PositionManager).
  2. Unlock – The periphery unlocks the PoolManager, which triggers unlockCallback.
  3. Modify Call – Inside the callback, the periphery calls modifyLiquidity on the manager.
  4. Validation – Manager verifies pool validity and initialization.
  5. Modification Type – Determines whether liquidity is being added or removed.
  6. Pre-hooks – If configured, the manager invokes beforeModifyLiquidity.
  7. Core Logic – Pool executes liquidity modification, updating ticks, balances, and fees.
  8. Event – A ModifyLiquidity event is emitted.
  9. Post-hooks – If configured, the manager invokes afterModifyLiquidity.
  10. Balance Delta – The signed (amount0, amount1) Delta is returned to the periphery.
  11. Settlement – Periphery settles balances via token transfers or ERC-6909 mint/burn.
  12. Finalization – Manager ensures no pending deltas and re-locks itself.
  13. Transaction Complete – Liquidity modification finalizes.

This architecture preserves atomicity while giving hooks the ability to extend liquidity behavior.

 

How Initial Liquidity Provision Works?

When a new pool is created on Uniswap, the very first liquidity provider (LP) has a special responsibility: they must set the starting price and deposit tokens into the pool. Unlike traditional pools, Uniswap uses a concentrated liquidity model, where LPs choose a price range in which their funds will be active.

Example: ETH/USDC Pool

  • Current market price: 1 ETH = 5,000 USDC
  • Liquidity range chosen: 4,545 → 5,500 USDC

This means the LP’s funds will only be used for trades while ETH stays within that range.
 

Key Steps in the Process

  • Price & Range Setup

    • Prices are translated into “ticks” (a numerical scale Uniswap uses internally).
    • The range is rounded to match Uniswap’s spacing rules, ensuring the system runs smoothly.
       
  • Internal Tracking

    • The pool records how much liquidity is available at each boundary (lower and upper price).
    • It also tracks fees earned by LPs and makes sure liquidity doesn’t exceed safe limits.
    • To save gas, data is packed efficiently in storage.
       
  • What Tokens You Provide

    Depending on the current market price and your chosen range, you might need to deposit:

    • Only token0 (e.g., ETH) if the price is below your range.
    • Both tokens (ETH + USDC) if the price is inside your range.
    • Only token1 (e.g., USDC) if the price is above your range.

Uniswap’s math ensures that the right amounts are required, keeping balances accurate and preventing errors.

Want to dive deeper into the mechanics of liquidity provision and the math that powers it? 

Check out our detailed handbook on Uniswap v4’s liquidity design: Liquidity Mechanics in Uniswap V4 Core

Benefits of Using Singleton Contracts

In Uniswap v3, each pool was a standalone contract, with its own state and fees. Multi-hop swaps and liquidity changes were costly due to interactions with multiple contracts.

uniswap (1).webp

In Uniswap v4, pools are library-backed states inside a singleton PoolManager , reducing deployment and multi-hop costs:

1// PoolManager
2using Pools for *;
3mapping (PoolId id => Pool.State) internal pools;
4
5function swap(PoolId id, ...) {
6    pools[id].swap(...); // Library call
7}

All liquidity modifications now funnel through PoolManager.modifyLiquidity , which combines hook composability, efficient tick math, and centralized accounting into a single unified system.

uniswap (2).webp

How Swapping a Token Works?

Swaps are the core of Uniswap V4, executing token exchanges across initialized liquidity ranges and adjusting prices tick-by-tick as liquidity is consumed. Leveraging flash accounting, balances are settled only once per transaction, reducing gas costs, while hooks enable dynamic fee adjustments for greater flexibility. Let’s dive deeper into swaps, flash accounting, and locking.

uniswap_swap.webp

Uniswap v4 swaps follow a precise sequence, optimized for gas efficiency and customizability:

  1. Swap initiation – A user calls a periphery contract (e.g., SwapRouter), which unlocks the PoolManager.
  2. Callback & execution – The PoolManager invokes unlockCallback on the periphery, where the actual swap is triggered.
  3. Validation – The manager ensures the pool is initialized and valid.
  4. Hook checks – If a hook is attached, beforeSwap executes before the swap logic.
  5. Swap logic – Liquidity is consumed tick-by-tick, updating prices as ranges are crossed.
  6. Fees & events – Protocol fees are charged (if applicable), and a Swap event is emitted.
  7. Post-swap hooks – If present, afterSwap runs after execution.
  8. Balance settlement – The manager calculates a BalanceDelta (net token0/token1 changes) and returns it to the periphery.
    • Settlement occurs via direct token transfers or ERC-6909 minting/burning (from previously locked funds).
  9. Finalization – Once balances are settled, the periphery finishes its callback, and the manager re-locks itself to complete the transaction.
     

What is BalanceDelta?

BalanceDelta is a signed pair (amount0, amount1) that tracks net balance changes from the user’s perspective:

  • Positive → Pool owes tokens to the user
  • Negative → User owes tokens to the pool

In Uniswap V4, settlement is delayed until execution completes. This enables flash accounting, where multi-hop swaps require only an initial input and final output transfer. All intermediate transfers are internally netted, reducing gas costs and boosting efficiency.

This mechanism builds on EIP-6909’s token accounting model, standardizing how balance changes are represented and making v4 swaps both more efficient and extensible.

Want to dive deeper into the mechanics of token swaps and the math that drives them? 

Check out our detailed handbook on Uniswap v4’s swap design: Swap Mechanics in Uniswap v4 core 

Secure Your Swaps with QuillAudits!

Ensure your Uniswap v4 swaps and smart contracts are safe and efficient. Take the next step toward secure DeFi transactions.

Request An Audit

What is Flash Accounting?

In V2/V3, multi-hop swaps required intermediate token transfers between pool contracts, incurring high gas overhead. V4’s singleton PoolManager enables flash accounting:

  • Tokens are deposited into PoolManager once.
  • All swap steps (single or multi-hop) are resolved internally.
  • Only final net balances are settled externally.

For example, an ETH → USDC → DAI route:

  • V3: ETH sent → pool → USDC transferred → pool → DAI transferred → user.
  • V4: ETH deposited once → intermediate steps computed in-memory → only final DAI transferred out.

This reduces external token transfers from O(hops) to O(1), cutting gas costs drastically while maintaining invariant correctness.
 

What are the practical applications of Hooks?

One of the most powerful innovations in Uniswap v4 is hooks, custom smart contracts that let developers modify pool behavior at key points, such as before or after swaps and liquidity changes. This flexibility opens up a wide range of possibilities, including:

  • Dynamic fee models that adjust with market conditions
  • On-chain limit orders and advanced trading strategies
  • Auto-compounding yields for liquidity providers
  • MEV-resistant mechanisms to protect users

Hooks effectively turn Uniswap into a developer platform for AMM experimentation, enabling new financial primitives without requiring a protocol fork.

Want to dive deeper into hooks? Check out our detailed blog post here:

Who’s Using Uniswap Hooks?

Uniswap v4 hooks enable protocols to extend and customize AMM functionality, powering innovations such as dynamic fees, automated liquidity management, and MEV protection. This flexibility has quickly made hooks a core building block for new DeFi applications.

Who’s Using Uniswap Hooks_ v2.png

The ecosystem has already produced 3,200+ live hook implementations, created by the broader community, the Uniswap core team, and protocol builders. A comprehensive directory is available at HookRank. Below are some of the leading projects already building with hooks:

  • Euler – A DEX integrated with Euler’s lending infrastructure, leveraging Uniswap v4 hooks to power a native AMM with deeper capital efficiency.
     
  • Aegis – Implements a fully on-chain, self-regulating dynamic fee hook that adjusts swap fees per block based on real-time market conditions. The system mitigates MEV and toxic order flow while protecting LPs during volatility.
     
  • Renzo Protocol – Through its Dynamo DEX, Renzo introduces a dynamic fee hook designed to stabilize pegged LRT assets (like ezETH/ETH). The hook automates liquidity management and helps safeguard against depegging.
     
  • Bunni – Offers liquidity density functions, rehypothecation, and autonomous rebalancing through hooks. LPs can dynamically reshape positions by shifting liquidity, tweaking curves, or transitioning between different tick ranges.
     
  • Angstrom – A DEX built to defend LPs by restricting swaps to staked Angstrom validators. Using Uniswap v4 hooks, it establishes an on-chain trading system powered by a decentralized node network.
     
  • Flaunch – A meme coin launchpad where 100% of trading fees are directed toward creators and token buybacks. Hooks enable fair token launches and automatic fee distribution.
     
  • Uniderp – Another meme coin launchpad that employs hooks to share trading fees among creators, referrers, and the platform itself.
     
  • Clanker – Utilizes Uniswap v4 hooks for protocol-level fee management and MEV module integration in meme coin ecosystems.
     
  • Zora – A creator-focused launch platform that applies hooks to convert fees into payout tokens and streamline reward distribution for communities.
     
  • Paxos & Predicate – USDL stablecoin on Uniswap v4 uses Predicate’s Institutional Hook to enforce AML/CFT checks and jurisdictional restrictions at the protocol level.


Conclusion

Uniswap v4 sets a new benchmark for AMM efficiency through concentrated liquidity, extensible hooks, and flash accounting, cutting multi-hop gas costs by up to 99% while enabling highly customizable strategies. By resolving fragmentation and strengthening security, v4 reinforces Uniswap’s leadership in DeFi, delivering superior capital efficiency and operational flexibility for both LPs and traders.

Contents

Tell Us About Your Project
Request An Audit
Subscribe to Newsletter
hashing bits image
Loading...

STAY IN THE LOOP

Get updates on our community, partners, events, and everything happening across the ecosystem — delivered straight to your inbox.

Subscribe Now!

newsletter
DeFi SecurityplumeUniswap FoundationAethiropt-collectivePolygon SPNBNB Chain Kickstart

Office 104/105 Level 1, Emaar Square, Building 4 Sheikh Mohammed Bin Rashid Boulevard Downtown Dubai, United Arab Emirates P.O box: 416654

audits@quillaudits.com

All Rights Reserved. © 2025. QuillAudits - LLC

Privacy Policy