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:
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:
When retrieving prices:
The contract looks up the reference asset for the requested asset
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
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:
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:
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:
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:
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:
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 addressesadd_asset
: Creation of a new asset mappingset_oracles
: Update to oracle sourcesset_admin
: Admin address update
Last updated