Skip to content

Pricing calculations

A launch token’s price is the price of a standard Uniswap pool. Because the token is always 18 decimals and quotes against 18-decimal native ETH, there is no decimal scaling to worry about.

A coin has no pool contract, so there is no slot0() to call. Its sqrtPriceX96 arrives on every Swap event the PoolManager emits for the coin’s poolId, and execution quotes come from the v4 quoter fed with the coin’s poolKey. The token is always currency1 (native ETH sorts first), so apply the conversion below with tokenIsToken0 = false, always invert. The quoter, not spot, is the honest number: the hook’s decaying sell fee is charged inside the swap, and only a quote includes it.

(V3-generation coins do read price from their pool’s slot0(), same math; see Earlier generations.)

Uniswap V3 stores price as sqrtPriceX96, where:

sqrtPriceX96 = sqrt(price) × 2^96
price = (sqrtPriceX96 / 2^96)² // token1 per token0, raw units

Convert sqrtPriceX96 to ETH per token using the ordering:

const Q96 = 2n ** 96n;
const ratio = (Number(sqrtPriceX96) / Number(Q96)) ** 2; // token1 per token0
// tokenIsToken0 = launch token address < WETH address
const priceWethPerToken = tokenIsToken0
? ratio // token is token0 → token1(=WETH) per token0(=token)
: 1 / ratio; // token is token1 → invert

Because both tokens are 18-decimal, no 10^(decimals) adjustment is needed. If you ever generalize to non-18-decimal pairs, scale by 10^(decimals0 − decimals1).

Each PoolManager Swap event carries the post-swap sqrtPriceX96, so you can update price on every trade without an extra call. Apply the same conversion. The signed amounts give trade size and direction (a negative amount is tokens leaving the pool to the trader).

Multiply the WETH price by an ETH/USD reference:

priceUsd = priceWethPerToken × ethUsd

Merry Men does not publish an oracle; use your existing ETH/USD source. Market-cap = priceUsd × totalSupply / 10^18 (supply is fixed, so FDV = market cap).

Spot price ignores slippage, and it also ignores the hook’s fee legs, so always quote. Call the v4 quoter with the coin’s poolKey: the key carries the hook, and the hook’s live rates (including the decaying sell fee) land in the quote. Then route the swap as described in Trading and pricing.