Pricing and slippage
Where to check price today
The Uniswap pool UI for the vault’s pair shows spot, recent volume, and fee tier.
On chain, read
slot0.sqrtPriceX96and convert to price, or read reserves for constant product pools.XVault’s upcoming price API will expose spot, TWAP, depth, and slippage estimates. A beta is available for custodians.
Spot price, constant product intuition
For a constant product pool with reserves X (vault token) and Y (USDC), the invariant is X · Y = k. The spot price of one vault token in quote terms is p = Y / X.
Spot price, concentrated liquidity
In a v3-style pool, price is tracked as sqrtPriceX96, a fixed-point representation of √P. The human price is P = (sqrtPriceX96 / 2^96)^2, adjusted for token decimals. Liquidity earns fees only while the current price is inside your chosen range.
Time-weighted average price (TWAP)
For stability and monitoring, use the pool’s built-in oracle. Call observe([T, 0]) to fetch two cumulative ticks, compute the geometric average tick over window T, convert that tick to price with TickMath, and compare to spot. A large spot vs TWAP gap can indicate a transient move.
Quoting expected slippage before a trade
To estimate execution price and slippage without trading, use a quote helper for the exact pair and fee tier. Provide your intended input or output size and read the returned amount and price limit behavior. For multi-hop paths, pass the route along with fee tiers.
Worked example, constant product:
Reserves:
X = 100,000vault tokens,Y = 2,000,000USDC.Spot
p = 20.00. A buyer sendsΔY = 100,000USDC.Fee tier 0.30 percent, so pool adds
99,700USDC.New
Y' = 2,099,700,k = 200,000,000,000, soX' ≈ 95,217.9.Buyer receives
ΔX ≈ 4,782.1. Effective price≈ 20.91.Slippage
≈ 4.55 percent.
Worked example, concentrated range intuition
Inside a live band with liquidity
L, moving from√P_ato√P_bconsumesΔtoken0 = L · (1/√P_b − 1/√P_a)and mintsΔtoken1 = L · (√P_b − √P_a).Use these to size bands so typical tickets stay within your range.
Last updated