QHooks Lab / TWAP Oracle

A price your contracts can trust.

Give one pool its own time-weighted average price. The hook records the pool’s price once per block that trades, and any contract can read the average over the last minutes or hours. An optional cap stops a price pushed for one block from dragging the average.

Integration notes

local builds · not independently audited.

Configuration

The pool’s two tokens, lower address first (Uniswap v4 orders them that way). The hook accepts exactly one pool: these tokens with the fee and spacing below.

Build & exports

Downloads

What your build includes

Your configured hook and the complete 48-file Solidity source project (the oracle, Uniswap v4-core as pinned) with its compiler input and third-party notices.

This builder targets local chain 31337. Building here is free and does not connect a wallet, deploy contracts or move funds. To put the hook on Base, Robinhood Chain, Ethereum, Arbitrum One or BNB Chain, use the deploy panel below.

How to read it

consult(seconds) returns the average tick over the last seconds; consultSqrtPriceX96(seconds) returns it as a price. observe([...]) returns raw tick cumulatives for your own windows. oldestAge() says how far back it can reach. A read further back than the history reverts.

The first trade in a block records the price that held since the previous block that traded; trades later in the same block do not record again, so a price moved and moved back inside one block leaves no mark. With truncation on, a price pushed for a single block counts as at most the cap times the seconds since the last observation.

No owner and no fees: the hook only reads the pool and never changes a swap. It is still an oracle on one pool: a pool with little liquidity can be moved over many blocks by anyone willing to pay for it. Pick windows and truncation for the value you secure.

Other Lab templates

All QHooks tools

Your wallet

No wallet extension needed. Your QWallet quantum key stays separate.

Connect your phone with a QR code.

Uses MetaMask Connect, copyright ConsenSys. License

Choose an EVM wallet.

No wallet detected in this browser.

Open qhooks.com in Chrome with your wallet extension enabled, or in your wallet app’s built-in browser.

The in-app preview cannot access Chrome’s wallet extensions. Use MetaMask Mobile above to pair your phone.

Connecting does not authorize spending. Every signature and transaction needs your approval. Never enter your recovery phrase here.