freecoding.school100% FREE · NO SIGNUP
Yield OceanISSUE #3 of 34

ticks · ranges · active liquidity

Liquidity LuVSThe Sandwich Bot
Liquidity Lu saysUniswap v3 prices live on a discrete tick lattice spaced as 1.0001^tick — each tick is one basis point, and tick spacing per fee tier controls position granularity.

Uniswap v3 does not work with continuous prices — it uses a discrete tick lattice where each tick represents a price 1.0001^tick. One tick is exactly one basis point (0.01%). Each fee tier has its own tick spacing: 1 (0.01% pool), 10 (0.05%), 60 (0.3%), 200 (1%) — wider spacing for higher-fee pools where MEV is heavier.

Positions snap to tick boundaries. A ±5% range around p=1.0 covers about 1000 ticks. The demo computes tick boundaries for that range and counts 60-spaced positions that fit.

Power-ups you unlock

The Sandwich Bot attacks — common mistakes

Boss battleCompute the tick range for ±5% around p=1.0 and the number of 60-spaced positions that fit.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>
const priceToTick = (p) => Math.floor(Math.log(p) / Math.log(1.0001));
const tickToPrice = (t) => Math.pow(1.0001, t);
const tickLow = priceToTick(0.95);
const tickHigh = priceToTick(1.05);
const spacings = [1, 10, 60, 200];
const fits = spacings.map(s => Math.floor((tickHigh - tickLow) / s));
document.getElementById('o').textContent = [
  'range ±5% around p=1.0:',
  '  tickLow  = priceToTick(0.95) = ' + tickLow + '   (price ' + tickToPrice(tickLow).toFixed(5) + ')',
  '  tickHigh = priceToTick(1.05) = ' + tickHigh + '   (price ' + tickToPrice(tickHigh).toFixed(5) + ')',
  '  span = ' + (tickHigh - tickLow) + ' ticks',
  '',
  'positions that fit at each tick spacing:',
  ...spacings.map((s, i) => '  spacing=' + String(s).padStart(3) + '  ' + fits[i] + ' positions  (' + ['0.01%','0.05%','0.3%','1%'][i] + ' fee tier)')
].join('\n');
</script></body></html>
▶ Open the interactive comic issue
‹ Uniswap V3 · Concentrated Liquidity MathUniswap V4 · Hooks · The Singleton ›