This blog explains how Uniswap v3 works under the hood, focusing on concentrated liquidity, ticks, and key smart contract functions. What Makes Uniswap v3 DiffeThis blog explains how Uniswap v3 works under the hood, focusing on concentrated liquidity, ticks, and key smart contract functions. What Makes Uniswap v3 Diffe

Understanding Concentrated Liquidity in Uniswap v3

2026/04/06 13:35
4 min read
For feedback or concerns regarding this content, please contact us at [email protected]

This blog explains how Uniswap v3 works under the hood, focusing on concentrated liquidity, ticks, and key smart contract functions.

What Makes Uniswap v3 Different?

Unlike earlier AMMs, Uniswap v3 introduces concentrated liquidity.

Instead of providing liquidity across the entire price range (0 → ∞), liquidity providers (LPs) can choose a specific price range where their capital is active.

👉 This makes capital far more efficient.

What is Tick Spacing?

Tick spacing defines which price points (ticks) LPs are allowed to use when setting their liquidity range.

Think of ticks as grid points on the price axis.

If:

tickSpacing = 10

Then valid ticks are:

…, -20, -10, 0, 10, 20, 30, …

Example

An LP can provide liquidity between:

  • 10 → 30 ✅
    But NOT:
  • 15 → 25 ❌ (not multiples of tick spacing)

Why Does Tick Spacing Exist?

If every possible tick were allowed:

  • There would be millions of tick values
  • Storage would explode
  • Gas costs would increase

So tick spacing ensures:

  • Fewer possible positions
  • Lower storage usage
  • Cheaper swaps

💡 Important: Tick spacing does not directly affect price, only how liquidity positions are defined.

What is a Tick?

A tick is an integer that represents a specific price level.

Uniswap defines price as:

Where:

  • price = token0 / token1
  • tick = integer (can be negative or positive)

Intuition

  • +1 tick ≈ +0.01% price increase
  • +100 ticks ≈ +1%
  • +6931 ticks ≈ 2× price

So ticks discretize price into very fine steps.

Why Do Ticks Exist?

Ticks are not for pricing, but for liquidity accounting.

They act as boundaries where liquidity turns ON or OFF.

Without Ticks:

  • Continuous price checks would be needed
  • Gas costs would be very high
  • Managing liquidity would be inefficient

With Ticks:

  • Liquidity activates when price enters a range
  • Liquidity deactivates when price exits
  • Everything becomes discrete and efficient

sqrtPriceX96 (Core Representation)

Instead of storing price directly, Uniswap stores:

sqrtPriceX96 = sqrt(price) × 2⁹⁶

Why?

  • Solidity does not support floating-point numbers
  • This format (called Q96 fixed-point) allows:
  • High precision
  • Efficient math
  • Safer calculations

💡 Most calculations in Uniswap v3 are done using this value, not raw price.

Core Functions Explained

Now let’s walk through the important functions and what they actually do.

initialize()

This is the first function called after pool deployment.

Purpose:

  • Sets the initial price of the pool

Input:

  • sqrtPriceX96

What it does:

  • Initializes slot0
  • Sets the starting tick and price

👉 Without calling this, the pool cannot operate.

mint()

This function is used when adding liquidity.

Purpose:

  • Creates a liquidity position

Inputs:

  • tickLower
  • tickUpper
  • liquidity amount

What happens internally:

  1. Calls _modifyPosition()
  2. Calculates how much token0 and token1 are required
  3. Transfers tokens from user to pool
  4. Updates liquidity accounting

liquidityDelta

This is not a function but an important concept.

  • Positive → liquidity added
  • Negative → liquidity removed

Used internally to update positions.

_modifyPosition()

This is the core internal function for managing positions.

Responsibilities:

  • Validates tick ranges
  • Loads current state (slot0)
  • Updates liquidity
  • Calculates token amounts required

👉 Think of this as the engine behind both mint() and burn().

_updatePosition()

Handles actual updates to a user’s position.

What it does:

  • Updates liquidity balances
  • Tracks fee growth
  • Adjusts position state

Called internally by _modifyPosition().

burn()

Used to remove liquidity.

Inputs:

  • tickLower
  • tickUpper
  • liquidity amount

What it does:

  1. Reduces liquidity in the position
  2. Calculates how many tokens should be returned
  3. Does NOT transfer tokens yet

👉 Important: It only updates accounting.

collect()

This is when tokens are actually transferred to the user.

Purpose:

  • Withdraw earned fees and withdrawn liquidity

What it does:

  • Transfers token0 and token1 to the user

👉 Separation of burn() and collect() helps optimize gas and flexibility.

Key Design Insights

Here are some deeper insights that show strong understanding:

1. Discrete Liquidity Model

Uniswap v3 converts continuous price ranges into discrete ticks → enabling efficient computation.

2. Capital Efficiency

LPs can concentrate liquidity → earn more fees with less capital.

3. Gas Optimization

  • Tick spacing reduces storage
  • slot0 packs variables
  • Fixed-point math avoids floating errors

4. Separation of Concerns

  • mint() → add liquidity
  • burn() → remove liquidity
  • collect() → withdraw tokens

Final Thoughts

Uniswap v3 is not just an AMM — it’s a highly optimized financial engine.

Key innovations:

  • Concentrated liquidity
  • Tick-based accounting
  • Fixed-point math (sqrtPriceX96)
  • Gas-efficient storage design

Github: https://github.com/kshitij011/uniswap-v3-finance

LinkedIn: https://www.linkedin.com/in/kshitijbhoite011

#blockchain #defi #uniswap #finance #solidity #smartcontracts


Understanding Concentrated Liquidity in Uniswap v3 was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.

Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact [email protected] for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

$30,000 in PRL + 15,000 USDT

$30,000 in PRL + 15,000 USDT$30,000 in PRL + 15,000 USDT

Deposit & trade PRL to boost your rewards!