
{"id":147604,"date":"2026-04-06T05:35:19","date_gmt":"2026-04-06T05:35:19","guid":{"rendered":"https:\/\/mycryptomania.com\/?p=147604"},"modified":"2026-04-06T05:35:19","modified_gmt":"2026-04-06T05:35:19","slug":"understanding-concentrated-liquidity-in-uniswap-v3","status":"publish","type":"post","link":"https:\/\/mycryptomania.com\/?p=147604","title":{"rendered":"Understanding Concentrated Liquidity in Uniswap v3"},"content":{"rendered":"<p>This blog explains how Uniswap v3 works under the hood, focusing on <em>concentrated liquidity<\/em>, ticks, and key smart contract functions.<\/p>\n<h3>What Makes Uniswap v3 Different?<\/h3>\n<p>Unlike earlier AMMs, Uniswap v3 introduces <strong>concentrated liquidity<\/strong>.<\/p>\n<p>Instead of providing liquidity across the entire price range (0 \u2192 \u221e), liquidity providers (LPs) can choose a <strong>specific price range<\/strong> where their capital is\u00a0active.<\/p>\n<p>\ud83d\udc49 This makes capital far more efficient.<\/p>\n<h3>What is Tick\u00a0Spacing?<\/h3>\n<p><strong>Tick spacing<\/strong> defines which price points (ticks) LPs are allowed to use when setting their liquidity range.<\/p>\n<p>Think of ticks as <strong>grid points on the price\u00a0axis<\/strong>.<\/p>\n<p>If:<\/p>\n<p>tickSpacing =\u00a010<\/p>\n<p>Then valid ticks\u00a0are:<\/p>\n<p>\u2026, -20, -10, 0, 10, 20, 30,\u00a0\u2026<\/p>\n<p>Example<\/p>\n<p>An LP can provide liquidity between:<\/p>\n<p>10 \u2192 30 \u2705<br \/>But\u00a0NOT:15 \u2192 25 \u274c (not multiples of tick\u00a0spacing)<\/p>\n<h3>Why Does Tick Spacing\u00a0Exist?<\/h3>\n<p>If every possible tick were\u00a0allowed:<\/p>\n<p>There would be <strong>millions of tick\u00a0values<\/strong>Storage would\u00a0explodeGas costs would\u00a0increase<\/p>\n<p>So tick spacing\u00a0ensures:<\/p>\n<p>Fewer possible positionsLower storage\u00a0usageCheaper swaps<\/p>\n<p>\ud83d\udca1 Important: Tick spacing does <strong>not directly affect price<\/strong>, only how liquidity positions are\u00a0defined.<\/p>\n<h3>What is a\u00a0Tick?<\/h3>\n<p>A <strong>tick<\/strong> is an integer that represents a specific price\u00a0level.<\/p>\n<p>Uniswap defines price\u00a0as:<\/p>\n<p>price = 1.0001 ^\u00a0tick<\/p>\n<p>Where:<\/p>\n<p>price = token0 \/\u00a0token1tick = integer (can be negative or positive)<\/p>\n<p>Intuition<\/p>\n<p>+1 tick \u2248 +0.01% price\u00a0increase+100 ticks \u2248\u00a0+1%+6931 ticks \u2248 2\u00d7\u00a0price<\/p>\n<p>So ticks discretize price into <strong>very fine\u00a0steps<\/strong>.<\/p>\n<h3>Why Do Ticks\u00a0Exist?<\/h3>\n<p>Ticks are <strong>not for pricing<\/strong>, but for <strong>liquidity accounting<\/strong>.<\/p>\n<p>They act as <strong>boundaries<\/strong> where liquidity turns ON or\u00a0OFF.<\/p>\n<p>Without Ticks:<\/p>\n<p>Continuous price checks would be\u00a0neededGas costs would be very\u00a0highManaging liquidity would be inefficient<\/p>\n<p>With Ticks:<\/p>\n<p>Liquidity activates when price enters a\u00a0rangeLiquidity deactivates when price\u00a0exitsEverything becomes <strong>discrete and efficient<\/strong><\/p>\n<h3>sqrtPriceX96 (Core Representation)<\/h3>\n<p>Instead of storing price directly, Uniswap\u00a0stores:<\/p>\n<p>sqrtPriceX96 = sqrt(price) \u00d7\u00a02\u2079\u2076<\/p>\n<p>Why?<\/p>\n<p>Solidity does not support floating-point numbersThis format (called <strong>Q96 fixed-point<\/strong>) allows:High precisionEfficient mathSafer calculations<\/p>\n<p>\ud83d\udca1 Most calculations in Uniswap v3 are done using this value, not raw\u00a0price.<\/p>\n<h3>Core Functions Explained<\/h3>\n<p>Now let\u2019s walk through the important functions and what they actually\u00a0do.<\/p>\n<h3>initialize()<\/h3>\n<p>This is the first function called after pool deployment.<\/p>\n<p><strong>Purpose:<\/strong><\/p>\n<p>Sets the initial price of the\u00a0pool<\/p>\n<p><strong>Input:<\/strong><\/p>\n<p>sqrtPriceX96<\/p>\n<p><strong>What it\u00a0does:<\/strong><\/p>\n<p>Initializes slot0Sets the starting tick and\u00a0price<\/p>\n<p>\ud83d\udc49 Without calling this, the pool cannot\u00a0operate.<\/p>\n<h3>mint()<\/h3>\n<p>This function is used when adding liquidity.<\/p>\n<p><strong>Purpose:<\/strong><\/p>\n<p>Creates a liquidity position<\/p>\n<p><strong>Inputs:<\/strong><\/p>\n<p>tickLowertickUpperliquidity amount<\/p>\n<p><strong>What happens internally:<\/strong><\/p>\n<p>Calls _modifyPosition()Calculates how much token0 and token1 are\u00a0requiredTransfers tokens from user to\u00a0poolUpdates liquidity accounting<\/p>\n<h3>liquidityDelta<\/h3>\n<p>This is not a function but an important concept.<\/p>\n<p>Positive \u2192 liquidity addedNegative \u2192 liquidity removed<\/p>\n<p>Used internally to update positions.<\/p>\n<h3>_modifyPosition()<\/h3>\n<p>This is the <strong>core internal function<\/strong> for managing positions.<\/p>\n<p><strong>Responsibilities:<\/strong><\/p>\n<p>Validates tick\u00a0rangesLoads current state\u00a0(slot0)Updates liquidityCalculates token amounts\u00a0required<\/p>\n<p>\ud83d\udc49 Think of this as the engine behind both mint() and\u00a0burn().<\/p>\n<h3>_updatePosition()<\/h3>\n<p>Handles actual updates to a user\u2019s position.<\/p>\n<p><strong>What it\u00a0does:<\/strong><\/p>\n<p>Updates liquidity balancesTracks fee\u00a0growthAdjusts position\u00a0state<\/p>\n<p>Called internally by _modifyPosition().<\/p>\n<h3>burn()<\/h3>\n<p>Used to remove liquidity.<\/p>\n<p><strong>Inputs:<\/strong><\/p>\n<p>tickLowertickUpperliquidity amount<\/p>\n<p><strong>What it\u00a0does:<\/strong><\/p>\n<p>Reduces liquidity in the\u00a0positionCalculates how many tokens should be\u00a0returnedDoes NOT transfer tokens\u00a0yet<\/p>\n<p>\ud83d\udc49 Important: It only updates accounting.<\/p>\n<h3>collect()<\/h3>\n<p>This is when tokens are actually transferred to the\u00a0user.<\/p>\n<p><strong>Purpose:<\/strong><\/p>\n<p>Withdraw earned fees and withdrawn liquidity<\/p>\n<p><strong>What it\u00a0does:<\/strong><\/p>\n<p>Transfers token0 and token1 to the\u00a0user<\/p>\n<p>\ud83d\udc49 Separation of burn() and collect() helps optimize gas and flexibility.<\/p>\n<h3>Key Design\u00a0Insights<\/h3>\n<p>Here are some deeper insights that show strong understanding:<\/p>\n<p><strong>1. Discrete Liquidity Model<\/strong><\/p>\n<p>Uniswap v3 converts continuous price ranges into discrete ticks \u2192 enabling efficient computation.<\/p>\n<p><strong>2. Capital Efficiency<\/strong><\/p>\n<p>LPs can concentrate liquidity \u2192 earn more fees with less\u00a0capital.<\/p>\n<p><strong>3. Gas Optimization<\/strong><\/p>\n<p>Tick spacing reduces\u00a0storageslot0 packs variablesFixed-point math avoids floating\u00a0errors<\/p>\n<p><strong>4. Separation of\u00a0Concerns<\/strong><\/p>\n<p>mint() \u2192 add liquidityburn() \u2192 remove liquiditycollect() \u2192 withdraw\u00a0tokens<\/p>\n<h3>Final Thoughts<\/h3>\n<p>Uniswap v3 is not just an AMM\u200a\u2014\u200ait\u2019s a <strong>highly optimized financial engine<\/strong>.<\/p>\n<p>Key innovations:<\/p>\n<p>Concentrated liquidityTick-based accountingFixed-point math (sqrtPriceX96)Gas-efficient storage\u00a0design<\/p>\n<p>Github: <a href=\"https:\/\/github.com\/kshitij011\/uniswap-v3-finance\">https:\/\/github.com\/kshitij011\/uniswap-v3-finance<\/a><\/p>\n<p>LinkedIn: <a href=\"https:\/\/www.linkedin.com\/in\/kshitijbhoite011\">https:\/\/www.linkedin.com\/in\/kshitijbhoite011<\/a><\/p>\n<p>#blockchain #defi #uniswap #finance #solidity #smartcontracts<\/p>\n<p><a href=\"https:\/\/medium.com\/coinmonks\/understanding-concentrated-liquidity-in-uniswap-v3-518c4ac24b22\">Understanding Concentrated Liquidity in Uniswap v3<\/a> was originally published in <a href=\"https:\/\/medium.com\/coinmonks\">Coinmonks<\/a> on Medium, where people are continuing the conversation by highlighting and responding to this story.<\/p>","protected":false},"excerpt":{"rendered":"<p>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 \u2192 \u221e), liquidity providers (LPs) can choose a specific price range where [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":147605,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-147604","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-interesting"],"_links":{"self":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts\/147604"}],"collection":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=147604"}],"version-history":[{"count":0,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts\/147604\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/media\/147605"}],"wp:attachment":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=147604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=147604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=147604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}