BIFROST Network
Search
K

Oracle Manager Contract API

The oracle manager contract manages the oracle for multiple sources. The round and data of each source may be classified and inquired through an oid (oracle id).

Oracle ID

The id for the currently supported oracle is listed below.
"AggOracleId": {
"bsize": 32,
"NONE": "0x0000000000000000000000000000000000000000000000000000000000000000",
"BFC_PRICE": "0x0000000000000000000000000000000000000000000000000000000000000001",
"BTC_PRICE": "0x0000000000000000000000000000000000000000000000000000000000000002",
"ETH_PRICE": "0x0000000000000000000000000000000000000000000000000000000000000003",
"DAI_PRICE": "0x0000000000000000000000000000000000000000000000000000000000000004",
"USDC_PRICE": "0x0000000000000000000000000000000000000000000000000000000000000005",
"USDT_PRICE": "0x0000000000000000000000000000000000000000000000000000000000000006",
"LINK_PRICE": "0x0000000000000000000000000000000000000000000000000000000000000007",
"KLAY_PRICE": "0x0000000000000000000000000000000000000000000000000000000000000008",
"BNB_PRICE": "0x000000000000000000000000000000000000000000000000000000000000000a",
"MATIC_PRICE": "0x000000000000000000000000000000000000000000000000000000000000000b",
"BIFI_PRICE": "0x000000000000000000000000000000000000000000000000000000000000000c",
"BUSD_PRICE": "0x0000000000000000000000000000000000000000000000000000000000000009"
},
"ConsensusOracleId": {
"bsize": 32,
"NONE": "0x0000000000000000000000000000000000000000000000000000000000000000",
"BTC_HASH": "0x524d2eadae57a7f06f100476a57724c1295c8fe99db52b6af3e3902cc8210e97"
}

Interfaces

Events

// Events that occur to announce the start of a new Oracle registration
event OracleStart(bytes32 oid)
// Events that occur when the latest Oracle information is determined
event Oracle(bytes32 oid, uint256 roundId, bytes32 data)

Query Oracle History

The oracle manager stores data for each source by round. That is, the oracle user may inquire about the data of the corresponding oracle as the round value. The following describes the Solidity API acquiring an oracle answer of a specific round.
// Returns an oracle answer of a specific round.
function oracle_history(bytes32 oid, uint256 round) view returns (bytes32)
// Returns a round value related to the latest oracle answer in the oracle history
function last_oracle_round(bytes32 oid) view returns (uint256)
// Returns the latest oracle answer of the oracle history
function last_oracle_data(bytes32 oid) view returns (bytes32)
// Return comprehensive information of the latest answer of the oracle history
struct Oracle_Manager_Source {
bytes32 data;
uint64 block; uint64 time; uint64 authority_round; uint64 _reserved;
}
function last_oracle_info(bytes32 oid) view returns (uint256, Oracle_Manager_Source memory)

Query an Oracle's New Answer

These functions generate a new round of the corresponding oracle and return the result. However, the consensus-type oracle returns the information from the last round of history.
// In the case of an Aggregated-type oracle, it generates a new round and returns its round value
// For oracle of Consensus-type, returns the same value as last_oracle_round(oid).
function latest_oracle_round(bytes32 oid) returns (uint256)
// In the case of an Aggregated-type oracle, it generates a new round and returns its answer
// For oracle of Consensus-type, returns the same value as last_oracle_data(oid).
function latest_oracle_data(bytes32 oid) nonpayable returns (bytes32)
// In the case of an Aggregated-type oracle, it generates a new round and returns its comprehensive information
// For oracle of Consensus-type, returns the same value as last_oracle_info(oid).
struct Oracle_Manager_Source {
bytes32 data;
uint64 block; uint64 time; uint64 authority_round; uint64 _reserved;
}
function latest_oracle_info(bytes32 oid) nonpayable returns (uint256, Oracle_Manager_Source memory)

Query the oracle feed by the validator

In BIFROST, the relayers provide external data to the BIFROST Oracle. The following functions allow you to check the data submitted by each relayer.
// Returns data sent to the oracle contract by the specific relayer
// For an Aggregated-type of oid, it raises revert.
function get_aggregate_feed(bytes32 oid, address validator) view returns (bytes32)
// Returns data sent to the oracle contract by the specific relayer
// For an Consensus-type of oid, it raises revert.
function get_consensus_feed(bytes32 oid, address validator, uint256 round) view returns (bytes32)