Velmar Stocks

Using the tracker

How prices are computed

Five steps from raw pool state to one reference price and one spread, all on-chain.


The five steps

  1. Read each pool’s price. Uniswap v2 from its reserves, v3 from slot0, v4 through the StateView contract.
  2. Measure each pool’s depth. Depth is how many dollars it takes to move that pool’s price by 2%, taking the smaller of the buy and the sell side. It is exact for v2 and an estimate from active liquidity for v3 and v4, capped by what the pool really holds.
  3. Drop pools that cannot be trusted. Pools with less than $1K of depth are ignored, and so are v4 pools with hooks, because a hook can change the price a trader actually gets.
  4. Reference price. The depth-weighted median of the remaining pool prices: the price backed by the most depth wins, so one small pool with a wild price cannot drag it.
  5. Spread. The average distance of the pools from the reference, again weighted by depth.

The formulas

reference  = weighted median of pool prices   (weight = depth)
gap(pool)  = pool price / reference − 1
spread     = Σ depth × |gap|  /  Σ depth

Worked example

Four made-up pools for one token, run through the same code the board uses:

PoolPriceDepth ±2%Gap
v3 · 0.05%$160.06$420K0.00%
v4 · 0.3%$159.95$180K−0.07%
v3 · 1%$158.87$6K−0.74%
v2$163.40$400ignored

Reference $160.06Spread 0.03%Widest gap −0.74%Aligned

One pool sits 0.74% away from the rest, but it holds very little depth, so it barely moves the spread. The v2 pool is ignored altogether: its depth is under $1K.