# Oracle System

To prevent front-running, every transaction is a two step process

* First, user requests for an order eg. `MarketIncrease`, `CreateDeposit`
* Keepers continuously scan the latest blocks for events emitted by user request
* If found, keepers fetch signed prices from the oracle off chain API (prices are signed by the oracle provider for a given token and block hash)
* Keepers call `executeOrcer()` with the signed prices within 1 block of user request, the smart contract decodes, verifies the provider signature and completes the order
* Both min and max price are signed, this allows info about bid and ask spread to be included

**Lookback Orders**

RFX has also integrated lookback orders which guaranteed the execution price for an order remains the same even if the order is executed in a subsequent block, i.e. if the order was created at block n, it will be executed with oracle prices from block n.

**Hybrid Oracles**

Prices are provided by an off-chain system and posted on-chain upon a transaction being executed:

* Oracle keepers continually check the latest blocks
* When there is a new block, oracle keepers fetch the latest price
* Keepers then sign the median price for each token together with block hash
* Keepers send the data and signature to archive nodes
* Archive nodes display the info for anyone to query

Learn more about Pyth price feeds here: <https://docs.pyth.network/home>

Learn more about Stork price feeds here: <https://docs.stork.network/>


---

# 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.rfx.exchange/oracle-system.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.
