> For the complete documentation index, see [llms.txt](https://docs.delphirhc.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.delphirhc.com/the-oracle/overview.md).

# How it works

Every Delphi pool keeps a history of its own price, and the hook is what writes it. On each swap the hook takes the pool's tick after the trade, applies the rate limit described under [Manipulation resistance](/the-oracle/manipulation-resistance.md), and stores the result together with the block timestamp as an observation. Observations live in a ring buffer inside the hook, one buffer per pool, with room for up to 8,192 entries.

Each observation also stores the running sum of tick multiplied by elapsed time, which is what makes the average cheap to compute. To get the time-weighted average tick over the last thirty minutes, the hook reads the accumulator now and the accumulator thirty minutes ago, subtracts, and divides by the elapsed seconds. Because the accumulator is stored, a read costs a couple of storage loads no matter how many trades happened in the window.

The average tick is converted to a price using the same maths as the pool itself, and reported in the quote asset per whole token. This is the value that `consult` returns.

## Why a tick and not a price

Uniswap pools track price as a tick, an integer where each step is a 0.01% change in price. Averaging ticks gives a geometric mean of the price rather than an arithmetic one, which is the standard the Uniswap v3 oracle set and which most of DeFi integrates against. It also means a doubling and a halving cancel out exactly, so a symmetric wobble around a level averages to that level.

## Windows

A reader chooses the window when it reads. Shorter windows follow the market more closely and are easier to influence; longer windows are slower and harder to move. The app shows five-minute, thirty-minute and one-hour windows, and a contract can ask for any window as long as the buffer holds observations that far back. The oldest observation still available is reported by `oldestObservation`.

## Lineage

The observation buffer, the accumulator and the binary search over past observations are taken from Uniswap v3. The differences are that the logic lives in a v4 hook rather than in the pool, that the tick written is rate-limited, and that the oracle exposes maturity and depth so that readers can judge whether to trust it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.delphirhc.com/the-oracle/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
