Oracles

Oracle hooks enable Uniswap v4 pools to function as price oracles by recording price observations and exposing oracle interfaces. For technical details, refer to the API Reference.

Base Oracle Hook

The BaseOracleHook enables a Uniswap v4 pool to record price observations and expose an oracle interface. It transforms the pool into a price oracle by storing historical price data that can be queried by external contracts for time-weighted average price (TWAP) calculations and other oracle functionality.

Oracle Hook with V3 Adapters

The OracleHookWithV3Adapters extends the base oracle functionality by automatically deploying Uniswap V3-compatible adapter contracts. These adapters provide familiar V3 oracle interfaces, making it easy for existing protocols to integrate with V4 pools as oracle sources.

The hook automatically deploys adapters that:

  • Expose V3-compatible oracle interfaces (observe function)

  • Support both standard and truncated price observations

  • Provide seamless migration path from V3 oracles to V4

These oracle hooks transform Uniswap v4 pools into reliable price oracles, enabling other protocols to query historical price data and calculate TWAPs directly from the pool’s trading activity.