Share Dialog
Every Uniswap V3 swap looks simple from the outside, you send one token in and receive another but; under the hood, it’s a staircase of micro-operations. According to Uniswap’s architecture, each swap transaction climbs through discrete steps that correspond to tick intervals. You can think of it as a trader walking up a staircase made of ticks, where every step represents a price range with its own liquidity depth. The engine moves one step, computes how much input is consumed and output received, updates prices, then moves to the next until the trade completes.
Inside the pool contract, three key data structures orchestrate this process:
swapCache — a set of static data cached in memory for efficiency. It contains immutable parameters relevant to the swap (starting liquidity, protocol fee settings, and block timestamp). These values remain constant throughout the transaction.
swapState — a dynamic cache tracking live progress: the current tick, the current square-root price (sqrtPriceX96), remaining input/output amounts, and cumulative output so far. As the algorithm iterates through ticks, swapState evolves with every step.
stepComputations — the ephemeral micro-cache used for each individual tick step. It stores transient values: the next tick index, the amount of token in or out for that step, the liquidity at the tick boundary, the next sqrtPriceX96, and a flag indicating whether the next tick is initialized. When a tick is initialized, a “jump” occurs and liquidity instantly changes as the algorithm crosses a range boundary.
Although stepComputations lives only for the duration of each tick iteration, the data it produces is extremely rich. By tracing these internal calculations during swap execution, one can reconstruct micro-level dynamics: how much slippage occurred per tick, how rapidly active liquidity was consumed, and how many tick crossings (and therefore gas-heavy jumps) were required. These traces provide an empirical window into execution quality, liquidity utilization, and the root causes of slippage.
Uniswap V3’s fundamental insight is that price is a derivative of available liquidity. Within any active tick range, swaps obey the constant-product formula just like Uniswap V2, but the size of that mini-pool — its local liquidity — determines how much the price moves per unit traded. Thin liquidity amplifies price movement; dense liquidity dampens it.
Mathematically:
Price Impact = 1 / Active Liquidity
Hence:
More liquidity → smaller price change → lower slippage
Less liquidity → larger price change → higher slippage
Active liquidity is the liquidity available at the range of the current price or tick where trading happens. Only this active slice participates in a swap at any given moment. The inactive ranges remain dormant until the market price migrates into them. Consequently, swap outcomes depend not only on total liquidity but on where that liquidity resides.
Capital efficiency in Uniswap V3 comes from allowing LPs to “concentrate their capital within custom price ranges, achieving higher capital efficiency than V2” (Uniswap Whitepaper, 2021). But capital efficiency means little unless it also yields profit. Since LPs earn fees only when trades occur inside their chosen range, their pursuit of profit dictates how liquidity is distributed. The result is not random; it’s behavioral economics embedded in code.
Gauntlet’s 2022 study found that LPs “tend to concentrate around the current price tick, leading to high depth near spot but thinner tails.” Delchain Research described this as a “clustering” effect where “execution for small trades is excellent, but larger orders face gaps.” Panoptic’s 2023 data went further: fewer than 8% of LPs provide more than 80% of total liquidity, and in some pools, just 1% of LPs control the majority — revealing both concentration and centralization.
This hierarchy of participation produces distinct execution regimes depending on how liquidity is distributed across ticks.
When the active tick range is dense, it means multiple LPs have concentrated liquidity tightly around the current tick. This situation is common in stable pairs like USDC/DAI or ETH/USDC, where volatility is low and LPs can confidently expect the price to remain close to its current level for long periods.
For small trades, this is ideal: because the stepComputations within the swap function find abundant liquidity at the current sqrtPriceX96, the price impact per token swapped is tiny. Each step of the swap consumes liquidity smoothly, and the swapState updates gently with minimal slippage. The trader experiences deep liquidity, low price movement, and excellent execution quality.
For large trades, the same density offers partial protection: while the beginning of the trade executes within dense liquidity, as the amount grows, the swap gradually consumes all active liquidity and begins to step into less populated ticks. Once that happens, execution quality drops — not because liquidity disappears, but because each additional step (each new tick crossed) holds progressively less liquidity than the dense band near spot. Thus, even dense active liquidity only supports low-slippage execution up to a limit proportional to its total size. After that limit, the trade suffers incremental slippage as stepComputations cross into thinner zones.
From the LP’s perspective, dense active liquidity represents a competitive zone: many LPs fighting for a share of the same trading volume. Fees per LP may be lower in absolute terms (since they’re divided among many participants), but the fee flow is steady, and capital efficiency remains high because their positions are almost always active.
A thin active tick range — where few LPs provide liquidity near the current tick — represents the opposite extreme. This can occur when the market is volatile, or when many LPs have withdrawn or repositioned to safer, wider ranges away from the spot price.
For small trades, the consequences are immediate: the trade begins consuming the limited active liquidity, and the price impact rises sharply even before crossing into new ticks. The swapState’s sqrtPriceX96 moves more steeply per unit of trade, indicating high slippage.
For large trades, the situation worsens drastically. Each step computation must quickly move from one tick to another, finding little liquidity in each range, and triggering multiple jumps. Gas costs rise due to frequent tick crossing, and the resulting price may deviate significantly from the starting price.
In this state, LPs who remain in the active tick range benefit disproportionately. Because all trades must flow through their limited liquidity, they earn very high fees relative to capital deployed — but the user experience for traders deteriorates due to slippage. Thin active ranges thus amplify the asymmetry between LP income and trade quality.
Sometimes, the current active range is relatively thin, but liquidity exists densely farther away, either above or below the current tick. This can happen when LPs expect a price migration (for instance, anticipating ETH appreciation or a stablecoin depeg). These dense far-away zones represent “liquidity walls” waiting to activate.
For small trades, these distant dense bands are irrelevant, as execution never reaches them. But for large trades that push the price far enough, these zones act as buffers — once stepComputations reach them, slippage slows down because each step now consumes abundant liquidity again. The execution curve flattens temporarily.
However, from a system perspective, this means execution quality across the price range becomes nonlinear — smooth in dense areas, jagged in thin gaps. For LPs in these far-away dense zones, profitability is intermittent: they earn nothing until price migrates into their range, then suddenly capture high fees during active use, before becoming inactive again once the price moves away.
Finally, the most fragile scenario occurs when both the active tick range and far-away ticks are thin. This patchy distribution often appears after large liquidity withdrawals or in less-traded pools. Both small and large trades then suffer: even modest swaps can move the price meaningfully because every tick holds little liquidity. Execution becomes jumpy, with stepComputations leaping across multiple ticks per trade. Gas usage increases, price discovery worsens, and the pool exhibits low resilience to trading shocks.
From an LP standpoint, this environment is unattractive. Thin far-away ticks earn no fees until price volatility triggers large movements — which may or may not happen. It represents unproductive, idle capital. But because LPs are fee-driven, few are willing to populate these zones unless compensated by volatility or high trading activity.
Liquidity Scenario | Small Trade Outcome | Large Trade Outcome | LP Incentive & Result |
---|---|---|---|
Dense active range | Excellent execution, near-zero slippage | Good until active liquidity depletes; mild slippage beyond | High efficiency, low per-LP share due to competition |
Thin active range | Noticeable slippage, unstable price | Severe slippage, frequent tick crossing, high gas | High per-trade fees, but high inactivity risk |
Dense far-away ranges | No immediate effect | Acts as slippage buffer once reached | Intermittent profits when range activates |
Thin far-away ranges | Little effect for small trades | Poor execution and instability | Idle capital, minimal earnings |
The loop completes itself: LPs chase fees → they cluster liquidity near expected trading zones → that distribution determines execution quality → traders gravitate toward pools with better execution → which further rewards the clustered LPs.
Meanwhile, distant LPs adapt by widening or repositioning ranges to capture volatility events, perpetuating a dynamic equilibrium of dense centers and thin tails. Over time, this behavior concentrates both liquidity and fee income in a small subset of addresses — Gauntlet’s Pareto finding quantified exactly that.
Thus, the entire swap experience; slippage, gas cost, and execution smoothness is an emergent property of LP fee incentives interacting with Uniswap V3’s tick-based architecture.
Tracing Uniswap V3’s internal swap variables (swapCache, swapState, stepComputations) exposes how liquidity distribution directly shapes swap quality. The staircase metaphor is literal: every step corresponds to a tick, and the height between steps is the price impact. Dense liquidity flattens the steps; thin liquidity makes them steep.
Because LPs earn only when trades use their range, their rational pursuit of fees sculpts the liquidity landscape itself. This self-organizing pattern where dense clusters near spot and thin or speculative tails, explains why small trades experience seamless execution while large trades sometimes face slippage cliffs. In Uniswap V3, the geometry of liquidity is the geometry of price movement, and understanding it requires tracing not just what the swap returns, but how it walks through its steps.
paul elisha
Comments