Bridge Oracle

The Bridge Oracle contract is a critical component of the Orbit Protocol that provides reliable price feeds for stablecoins by mapping them to their corresponding fiat currencies. This price data is essential for the Blend pools to maintain accurate lending and borrowing operations.

Core Features

Initialization

fn initialize(e: Env, admin: Address, oracle: Address)

The Bridge Oracle initializes with:

  • admin: Address with administrative privileges

  • oracle: Address of the external price oracle contract

During initialization, the contract:

  • Verifies it hasn't been previously initialized

  • Sets up the admin address

  • Configures the oracle address

  • Emits an initialization event

Asset Management

Adding Assets

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

Allows admin to create price mappings:

  • asset: The stablecoin asset to be priced (e.g., oUSD token)

  • to: The reference asset for pricing (e.g., USD)

Oracle Configuration

fn set_oracle(e: Env, oracle: Address)

Enables admin to update the price source:

  • Updates oracle contract address

  • Maintains existing asset mappings

  • Emits oracle update event

  • Requires admin authorization

Price Data Interface

Decimals Retrieval

fn decimals(env: Env) -> u32

Returns the decimal precision of price data:

  • Queries connected oracle

Price Fetching

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

Retrieves current price information:

  • Returns PriceData structure

  • Maps stablecoin to reference asset

  • Handles price conversion

  • Returns None if price unavailable

Events

The contract emits events for:

  • Contract initialization

  • Asset mapping creation

  • Oracle address updates

Upgrade Mechanism

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

Supports contract upgrades:

  • Admin-controlled

  • Preserves existing mappings

  • Maintains system integrity

Error Conditions

The contract handles various error cases:

  • Invalid initialization

  • Unauthorized access attempts

  • Missing asset mappings

  • Oracle connection failures

Last updated