Uniswap v4

High Level Understanding of Uniswap Versions

Learn the key differences between Uniswap v1, v2, v3 & v4 including liquidity models, swap mechanisms & major features across all versions.

Last updated: 8/28/2025

What is Uniswap?

Think of Uniswap as a digital marketplace where people can trade cryptocurrencies without needing a middleman like a bank or traditional broker. Instead of the usual order books where buyers and sellers place bids, Uniswap uses something called an Automated Market Maker (AMM) to automatically set prices.
 

Understanding AMMs

An AMM uses mathematical algorithms to figure out the price at which you can buy or sell tokens, and it handles the transaction through something called a liquidity pool. A liquidity pool is basically a collection of tokens that allows users to swap or trade the tokens that are available in the pool.

The liquidity comes from "liquidity providers" - these are other users who deposit their tokens into the pool. In return, they get LP tokens that represent their share of the pool, and they earn rewards through trading fees charged to people who use the pool. Different AMMs use different algorithms, and different pools contain different combinations of tokens.
 

Understanding Impermanent Loss

You can think of impermanent loss as the opportunity cost of adding liquidity to a pool. When someone provides liquidity to a pool, they receive LP tokens that represent their portion of that pool. When they decide to exit, they can exchange those tokens for their share of the pool's current value.

Here's a simple example:

A liquidity provider (LP) contributes $5,000 worth of ETH and $5,000 worth of USDC to a pool and receives LP tokens representing a 10% stake. This means the total pool value is $100,000, and the LP's portion is worth $10,000.

After some time, ETH's price increases by 30%, causing trading activity and price changes within the pool. When the pool rebalances (the AMM algorithm handles this automatically), its value increases to $110,000. At this point, the LP can burn their LP tokens and receive 10% of the pool, which equals $11,000 - earning them a $1,000 profit.

However, if we look at their original investment:

  • $5,000 worth of ETH
  • $5,000 worth of USDC

And calculate how those assets would have grown: $5,000 × 1.3 + $5,000 = $11,500

This means their investment would have been worth $11,500, earning a $1,500 profit if they had just held the tokens.

So we can see that by providing liquidity to the pool, they actually earned $500 less than they would have by simply holding. This is impermanent loss.

It's called "impermanent" because ETH's price could fall again and change these numbers. It only becomes permanent when the LP decides to withdraw their funds from the pool.
 

Evolution of Uniswap: From v1 to v4

Uniswap v1

Launched in late 2018, Uniswap v1 introduced the idea of decentralized token swaps using the simple yet powerful constant product formula:

x * y = k

Users could trade ETH <> ERC20 tokens directly on-chain. The Factory contract allowed anyone to spin up a pool, paving the way for true permissionless liquidity.

But there was a catch:

Swapping between two ERC20 tokens required routing through ETH, adding gas costs and extra steps. Not ideal.

Example:

image (67).webp

Uniswap v2

Uniswap v2 then came out in mid 2020 - and is still one of the largest DEXes today by volume - which solved this problem.

  • ERC20 <> ERC20 pools
  • Multi-hop routing
  • Flash Swaps (like Flash Loans, but for swaps)
  • TWAP Oracle for on-chain price feeds

image (68).webp

With v2 then a new problem became more widely talked about. Liquidity Providers (LPs) faced impermanent losses when providing liquidity to a pool since all liquidity needed to be provided across the entire price range since v2 still used the xy = k curve. But the downside of that design was it caused pricing inefficiencies for many tokens since their volatility wasn't high enough to truly warrant liquidity across the entire price range.
 

Uniswap v3

Uniswap v3 launched in 2021 and introduced concentrated liquidity. Instead of LPs being forced to provide liquidity over the entire price range, they could now supply liquidity within a specific range they chose.

This solved several problems:

  • Higher capital efficiency
  • More fee earnings when trades occurred within chosen ranges
  • Reduced impermanent loss (less exposure to wide price swings)

Today, both Uniswap v2 and v3 combined handle billions of dollars in on-chain volume daily, and the official Uniswap frontend seamlessly switches between the two to find the best prices for token swaps.

But with popularity came forks - lots of them. Many Uniswap forks were launched over the years, mostly deployed to newer chains before official Uniswap deployments, and occasionally they modified Uniswap's behavior. For example, PancakeSwap - a Uniswap fork on BNB Chain - slightly changed their governance token mechanics and deployed before Uniswap's official deployment, giving Pancake significant market share on BNB.

This leads to liquidity fragmentation and user confusion, as apps they're familiar with aren't popular on different chains. Another big problem is security - some forks modify the code without proper re-auditing, sometimes leading to hacks or rugpulls that hurt users.
 

Uniswap v4

Uniswap v4 aims to solve these problems and more.

Hooks are the main innovation. Hooks allow anyone to write smart contracts that can modify pool behavior by "hooking into" key parts of the control flow. For example, functions like beforeSwap and afterSwap can run arbitrary code before or after a swap happens in the pool. This lets anyone create derivative DEXes on Uniswap without forking the entire codebase.

It also has a brand new accounting system focused on gas optimization. V4 uses Transient Storage (EIP-1153), Flash Accounting (to only settle balances at the end of transactions while modifying temporary variables throughout), and even allows users to keep their tokens in the contract if they wish. For example, if I regularly trade ETH ↔ USDC, I can keep my funds in the contract and make swaps in either direction, only withdrawing after I'm done trading regularly.
 

Let deep dive into Uniswap v4!

What’s New in Uniswap v4?

Uniswap V4 is the latest upgrade, making trading cheaper, faster, and more customizable. Here’s how it works in simple terms:

1. One Big Smart Contract Instead of Many (Singleton Design)

  • Old Way (v3): Every trading pair (like ETH/USDC) had its own separate contract, which made transactions slow and expensive.
  • New Way (v4): All trading pools are managed by a single contract, reducing gas fees and making swaps smoother.

(will discuss more in other article in detailed)
 

2. Fewer Token Movements = Lower Fees

  • Old Way: If you wanted to swap Token A → Token B → Token C, the system had to move tokens between multiple contracts, costing extra fees.
  • New Way: V4 keeps track of balances internally and only moves tokens at the very end, saving you money.
     

3. Plugins for Custom Features - "Hooks"

hooks allow developers to add additional features to trading pools; think of them as smartphone apps. A few instances are:

Dynamic Fees: Modify trading fees in response to market conditions. Limit Orders: Purchase or sell automatically at a predetermined price. MEV Protection: Stop trade manipulation by bots. Reinvest earnings for liquidity providers with the help of auto-compounding rewards.
 

4. Faster & Cheaper Temporary Storage (EIP-1153)

  • Old Way: It was costly to store temporary data.
  • New Way: V4 uses transient storage, which lowers costs by acting as a scratchpad where data vanishes after the trade.
     

5. "Claim Tokens": Keeping Receipts Rather Than Transferring Money

  • Old Way: Gas was continuously wasted by moving tokens. The new method requires fewer transactions because users receive digital receipts (ERC-6909 claims) for their deposits.
     

6. Smarter Liquidity Management

  • Liquidity providers (LPs) can still choose price ranges (like in v3).
  • But now, with hooks, they can automate strategies (e.g., adjusting liquidity when trading volume spikes).
Next
Liquidity Mechanics in Uniswap...

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