Reading V4 prices

Uniswap V4 keeps every pool inside one PoolManager, at 0x8366a39CC670B4001A1121B8F6A443A643e40951 on Robinhood Chain. Pool state is not exposed…

Developers18 of 211 min read

Uniswap V4 keeps every pool inside one PoolManager, at 0x8366a39CC670B4001A1121B8F6A443A643e40951 on Robinhood Chain. Pool state is not exposed through getters; it is read through extsload.

The slot

bytes32 poolId = keccak256(abi.encode(currency0, currency1, fee, tickSpacing, hooks));
bytes32 slot   = keccak256(abi.encode(poolId, uint256(6)));   // pools mapping
uint160 sqrtPriceX96 = uint160(uint256(IPoolManager(pm).extsload(slot)));

currency0 is the lower address. For NVDA, USDG sorts first; for TSLA, the stock does.

From sqrtPriceX96 to USDG per share

sqrtPriceX96² / 2¹⁹² is the raw price of currency1 in currency0. Blacksite turns it into USDG raw per 1e18 share raw:

if (stockIs0) px = mulDiv(mulDiv(sqrtP, sqrtP, 1 << 64), 1e18, 1 << 128);
else          px = mulDiv(mulDiv(1e18, 1 << 96, sqrtP), 1 << 96, sqrtP);

Many slots at once

extsload(bytes32[]) returns several slots in one call. The site reads slot0 and active liquidity of all nine launch pools in a single eth_call.