Oracle System

RFX uses a dual oracle setup with price feeds from both Pyth and Stork to increase system resiliency and provide traders with the best pricing.

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/

Last updated