# 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](https://docs.perennial.finance/protocol/markets/payoff-and-positions) 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 %}
