Orbit Documentation
  • Github
  • Protocol Overview
    • What is Orbit Protocol
    • Ecosystem Participants
    • Smart Contracts
    • Whitepaper
    • Litepaper
  • Technical Documentation
    • Treasury
    • Bridge Oracle
    • PegKeeper
    • DAO
    • System Diagram
Powered by GitBook
On this page
  • Price Feed Management
  • Asset Mapping
  • Price Retrieval
  • Decimal Precision
  • Administration
  • Setting Oracle Sources
  • Setting the Admin
  • Contract Upgrades
  • Contract Initialization
  • Events
  1. Technical Documentation

Bridge Oracle

The Bridge Oracle contract provides reliable price feeds for the Orbit Protocol by connecting different assets to their reference values. It serves as a critical price discovery mechanism that enables accurate asset valuations within the protocol.

Price Feed Management

The Bridge Oracle manages price feeds by mapping assets to their reference counterparts and retrieving price data from specialized oracle sources.

Asset Mapping

Assets are mapped to their reference assets using the add_asset() function:

fn add_asset(e: Env, asset: Asset, to: Asset)

This function:

  • Creates a mapping between the source asset and its reference asset

  • Can only be called by the admin

  • Allows bridging between Stellar assets and external assets

  • Emits an event recording the mapping

Price Retrieval

The Bridge Oracle provides price data through the lastprice() function:

fn lastprice(env: Env, asset: Asset) -> Option<PriceData>

When retrieving prices:

  1. The contract looks up the reference asset for the requested asset

  2. Based on the type of reference asset, it routes the request to the appropriate oracle:

    • For Stellar assets, it queries the Stellar oracle

    • For USD, it returns a fixed value of 1 with the current timestamp

    • For other external assets, it queries the external oracle

  3. Returns the price data if available, or None if not found

Decimal Precision

The contract provides information about the decimal precision used by the Stellar oracle:

fn decimals(env: Env) -> u32

This function relays the decimal precision information from the underlying Stellar oracle.

Administration

The Bridge Oracle provides administrative functions to manage protocol configuration.

Setting Oracle Sources

The data sources for the Bridge Oracle can be updated using:

fn set_oracles(e: Env, stellar_oracle: Address, other_oracle: Address)

This function:

  • Updates the addresses for both the Stellar and external oracles

  • Can only be called by the admin

  • Emits an event recording the change

Setting the Admin

The admin address can be updated by the current admin:

fn set_admin(e: Env, new_admin: Address)

This function updates the admin address and emits an event recording the change.

Contract Upgrades

The Bridge Oracle supports upgradability through Soroban's native upgrade mechanism:

fn upgrade(e: Env, new_wasm_hash: BytesN<32>)

This function allows the admin to upgrade the contract to a new implementation while preserving all contract storage.

Contract Initialization

The Bridge Oracle is initialized with three key parameters:

fn __constructor(e: Env, admin: Address, stellar_oracle: Address, other_oracle: Address)

During initialization:

  • The admin address is set (the DAO contract)

  • The Stellar oracle address is configured

  • The external oracle address is configured

  • An initialization event is emitted

All future administrative operations will require authorization from this admin address.

Events

The Bridge Oracle emits events for all major operations:

  • init: Contract initialization with admin and oracle addresses

  • add_asset: Creation of a new asset mapping

  • set_oracles: Update to oracle sources

  • set_admin: Admin address update

PreviousTreasuryNextPegKeeper

Last updated 18 days ago