Price feed
PriceFeed records each listed coin's price straight from its Uniswap v4 pool. There is no off-chain oracle. Anyone with a normal wallet can record a sample, and every sample lives on-chain.
sample(id)
function sample(uint256 id) external returns (uint256 price)- Permissionless. Any externally owned account can call it.
- EOA only. The caller must be the transaction origin and have no contract code. This also excludes EIP-7702 delegated accounts. It stops a swap, sample, swap sandwich from running atomically inside one transaction.
- Listed markets only. Reverts with
NotListedotherwise. - Minimum interval. At most one sample per market every
minIntervalseconds (20 today). Earlier calls revert withTooSoon. - Readable pool. Reverts with
Unreadableif the pool cannot be read.
The keeper samples every listed market that has backer HYPE, about every 20 seconds. If it stops, anyone can keep sampling.
The 8% per-sample move limit
If the previous sample is recent (within recentWindow, 120 seconds today), the new sample is clamped to within maxSampleMoveBps (800 bps, 8%) of it:
lo = last × (10000 − 800) / 10000
price = clamp(raw, lo, hi)
Sampled event logs both the clamped and the raw price.A single block cannot move the recorded price more than 8%. A real move larger than that is recorded over several samples: a 30% drop needs 5 samples and a 30% rise needs 4, so at the 20 second interval the full move shows within about 1 to 2 minutes.
Sample store
Samples are kept per market in an append-only list of (timestamp, price). Nothing is overwritten, so any past window can be read back for settlement, however late. Read them with sampleCount, sampleAt, samples(id, start, count), lastSample, firstSampleTime and priceAtOrBefore.
Reserves use a separate ring of 7 hourly buckets per market. Each bucket keeps the lowest reserve seen in its hour and is reused 7 hours later.
Medians
function windowStats(uint256 id, uint256 from, uint256 to, uint256 maxGap)
external view returns (uint256 median, uint256 count, bool continuous)Collects every sample with from ≤ ts ≤ to (up to 128), sorts them and returns the median, the count, and whether the window is continuous: the first sample within maxGap of from, no gap above maxGap between samples, and the last within maxGap of to. ShortBook uses it for strikes, settlement and momentum, with maxGap = 90 seconds today.
refReserve
function refReserve(uint256 id) external view returns (uint256)The lowest recorded reserve across the hourly buckets for the current hour and the 6 before it. Returns 0 if none of those hours has a sample. ShortBook uses it for the reserve floor and the open interest and wallet caps.
Feed parameters and bounds
| Parameter | Today | Hard bounds in code |
|---|---|---|
minInterval | 20 s | 10 to 60 s |
maxSampleMoveBps | 800 (8%) | 100 to 5000 |
recentWindow | 120 s | minInterval to 600 s |
listingReserveFloor | 117 HYPE | No bound |
Only the feed owner can change these, with setParams. Contract: 0x769AC26C01700fdf8aD40acAB4AF7F566C51DAbd
