Verification checklist
- ticks[tick].liquidityNet records net liquidity change when price crosses from left to right. Lower ticks are positive, upper ticks are negative.
- Crossing right (zeroForOne is false, price rises) adds liquidityNet directly: 5000 plus -1000 equals 4000.
- Crossing left (zeroForOne is true, price falls) negates the sign: 4000 minus -1000 restores active liquidity to 5000.
- Omitting sign negation on leftward crossings drops liquidity to 3000, creating an error of 2000; falling past lower tick 100 subtracts +1000 to drop to 4000.
1. liquidityNet signs are defined for upward crossings
In Uniswap V3, concentrated liquidity positions are constrained within discrete tick ranges [tickLower, tickUpper]. Inside the core Tick.update function, adding a liquidity delta assigns distinct algebraic signs to the lower and upper boundaries:
// Tick.sol
liquidityNet = upper
? int128(int256(liquidityNet).sub(liquidityDelta))
: int128(int256(liquidityNet).add(liquidityDelta));
When an LP deposits 1000 liquidity across [100, 200], tickLower = 100 records liquidityNet = +1000, while tickUpper = 200 records liquidityNet = -1000. The physical convention assumes monotonic price growth from left to right: crossing tickLower = 100 activates the position and injects 1000 active liquidity into the pool, whereas crossing tickUpper = 200 exits the position range, requiring that same 1000 to be subtracted.
While liquidityGross always stores the non-negative sum of referencing commitments (both ticks register +1000), liquidityNet represents a directional derivative. Understanding this sign convention is essential for correctly verifying tick transition arithmetic.
2. Crossing right past 200: 5000 plus -1000 becomes 4000
When a swap sells token1 for token0 (zeroForOne = false), token1 reserves increase, token0 reserves decrease, and the marginal price rises as the current tick advances to the right. Inside the swap loop of UniswapV3Pool.sol, hitting an initialized tick triggers the cross transition:
// UniswapV3Pool.sol
if (state.tick == step.tickNext) {
int128 liquidityNet = ticks.cross(step.tickNext, ...);
if (zeroForOne) liquidityNet = -liquidityNet;
state.liquidity = LiquidityMath.addDelta(state.liquidity, liquidityNet);
}
Assume global active liquidity state.liquidity is 5000 prior to crossing 200. Because zeroForOne is false, the code bypasses the negation branch and retains liquidityNet = -1000.
Executing LiquidityMath.addDelta(5000, -1000) yields 4000. Global pool liquidity drops from 5000 to 4000. This integer change mirrors reality: the position's tokens have been entirely converted to token0, and that 1000 liquidity no longer supports trades above tick 200.
3. Crossing left back past 200: subtracting -1000 returns to 5000
Consider the reverse market movement. The price had reached 250 with active liquidity at 4000. A heavy sell order sells token0 for token1 (zeroForOne = true), pushing the price downwards and crossing left back past tick 200.
Upon crossing tickUpper = 200 to the left, ticks.cross reads the static stored value -1000. Crucially, because zeroForOne is true, the pool executes the mandatory sign negation:
if (zeroForOne) liquidityNet = -liquidityNet;
Here, -1000 is negated to -(-1000) = +1000. Calling LiquidityMath.addDelta(4000, 1000) accurately increases active liquidity to 5000. The position is reactivated, restoring pool depth.
| Crossing Scenario | Current Liquidity | Tick Boundary | Stored liquidityNet | zeroForOne Flag | Effective Delta | New Liquidity |
|---|---|---|---|---|---|---|
| Enter range rightward | 4000 | tickLower = 100 | +1000 | false (Up) | +1000 | 5000 |
| Exit range rightward | 5000 | tickUpper = 200 | -1000 | false (Up) | -1000 | 4000 |
| Re-enter range leftward | 4000 | tickUpper = 200 | -1000 | true (Down) | +1000 | 5000 |
| Exit range leftward | 5000 | tickLower = 100 | +1000 | true (Down) | -1000 | 4000 |
Row 3 highlights the common pitfall in offline simulation engines. Naive implementations that simply execute state.liquidity += tick.liquidityNet add -1000 directly to 4000, mistakenly producing 3000 instead of 5000.
4. The 2000-unit discrepancy and compound errors
Miscalculating liquidity as 3000 instead of 5000 does not merely drop 2000 units on a balance sheet; it severely distorts subsequent swap execution.
Immediately after the tick cross, the swap loop proceeds to SwapMath.computeSwapStep, where the price step denominator is the updated state.liquidity:
ΔsqrtPrice = Δy / L
With an actual active liquidity L = 5000, substituting an erroneous L = 3000 magnifies the estimated price drop by 5000 / 3000 ≈ 1.67 (a 66.7% overestimation of slippage). Consequently:
- Arbitrage bots falsely predict slippage limit violations and abandon profitable trades;
- Lending liquidation bots overestimate market impact, issuing unwarranted distress signals;
- Successive down-crossings compound inverted signs, eventually driving simulated liquidity negative and crashing the engine.
5. Exiting lower tick 100: subtracting +1000 drops to 4000
Continuing along the downward price path, as the price breaks below tickLower = 100, step.tickNext hits 100 where static liquidityNet is +1000.
With zeroForOne = true, the value is negated to -1000. Global liquidity drops from 5000 plus -1000 back to 4000. Below tick 100, all position assets are converted to token1, and pool depth correctly resets to 4000, creating an exact symmetric cycle: 4000 → 5000 → 4000.
To verify a tick cross on-chain: confirm the zeroForOne boolean; retrieve the static liquidityNet of step.tickNext; negate it if zeroForOne is true; and add the signed result to previous liquidity. Crossing upper tick 200 to the left must return 5000, never 3000.
This is an analytical framework. Static tick net definitions come from Tick.sol, while directional crossing and liquidity updates come from UniswapV3Pool.sol and LiquidityMath.sol v1.0.0. The integers 4000, 5000, 3000, and 2000 are exact results of this arithmetic and do not constitute investment advice.
6. Common misreadings
Does crossing an initialized tick always increase active pool liquidity?
No. The static liquidityNet of an initialized tick can be positive or negative. When the price moves upward past an upper tick, liquidityNet is negative and active liquidity decreases. When moving downward past a lower tick, negating the sign also reduces active liquidity. Active liquidity increases only when stepping inside an active position range.
Why is liquidityGross positive if liquidityNet is negative at upper tick 200?
Because they measure different properties. liquidityGross tracks the total absolute liquidity referencing that tick boundary, and it is always non-negative. It determines whether the tick remains active or can be cleared from the bitmap. liquidityNet tracks directional signed deltas, which must be negative at upper ticks to signal liquidity removal upon upward breakout.
What happens if an off-chain simulation forgets to negate liquidityNet when moving left?
It creates a doubled error. Starting from 4000 active liquidity and upper tick net of -1000, the correct calculation subtracts -1000 to get 5000. Adding directly yields 4000 + (-1000) = 3000, understating active depth by 2000. In subsequent swap steps, this artificially small liquidity exaggerates price impact and ruins routing predictions.