# Oracles & Settlement

## Oracles

Oracles are the core of each market within Perennial. Each market pulls in one or more prices from oracles to be used in the payoff function.&#x20;

{% hint style="info" %}
While a simple market will just use a single price feed (ex. ETH), more complex market could use payoffs with multiple price feeds (ex. ETH / BTC).
{% endhint %}

Perennial's modular design supports custom oracles. Currently, Perennial markets use an implementation of [Stork's](https://www.stork.network/) low latency oracles, allowing for fast & efficient price updates.&#x20;

## Settlement

[Market payoffs](/protocol/markets/payoff-and-positions.md) in Perennial are computed directly from oracle prices. To prevent timing advantages or arbitrage against oracle updates, a delay is introduced into the settlement process.

When a user initiates an action to open or close a position, this request is **timestamped**. The actual change to the position doesn't occur immediately. Instead, it remains in a pending state. A **Keeper** later finalizes the trade by providing the oracle price that corresponds to the initial timestamp of the request. Settlement effectively occurs based on this specific oracle price, which is delivered at a subsequent oracle update

{% hint style="info" %}
**Developer Note:**\
The settlement flow happens entirely on-chain, giving strong guarantees for projects building on top of Perennial.&#x20;

Perennial smart contracts store the current version for position adjustments, allowing for the positions opening price & PnL to be retroactively calculated at the next on-chain settlement period (when the contracts are interacted with again), avoiding the need for a second interaction during opens/closing (or the need for a keeper).&#x20;
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://docs.perennial.finance/protocol/markets/oracles-and-settlement.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
