Skip to content

Oracle Berachain ​

Git Source

The Oracle module (Skip’s Slinky) is responsible for tracking and managing currency pairs and their associated prices. It provides information about the currency pairs, their prices, timestamps, block heights, and the number of decimals for each pair.

The Oracle module provides several functionalities, including adding and removing currency pairs, checking if a currency pair is being tracked, retrieving the price and metadata of a currency pair, and getting the number of decimals for a given currency pair. It also emits events when currency pairs are added or removed, allowing other parts of the system to react to these changes.

This module can be used in a smart contract system that requires access to up-to-date price information for various currency pairs. By integrating this Oracle module, users and dapps on Berachain can obtain accurate and reliable price data.

TIP

All price feeds offer interfaces based off of Chainlink's AggregatorV3Interface as well. You can find the docs on that here.

Note: Link to existing contract ABI's can be found on Github here.

Interface of the Oracle module's precompiled contract

Functions ​

getAllCurrencyPairs ​

returns all currency pairs tracked by the oracle module.

solidity
function getAllCurrencyPairs() external view returns (string[] memory);
function getAllCurrencyPairs() external view returns (string[] memory);

getPrice ​

returns the price of the given currency pair, along with metadata.

solidity
function getPrice(string memory pair) external view returns (int256, uint256, uint64);
function getPrice(string memory pair) external view returns (int256, uint256, uint64);

Parameters

NameTypeDescription
pairstringthe currency pair to get the price of.

Returns

NameTypeDescription
<none>int256price the price of the currency pair, the timestamp, and block height in that order.
<none>uint256
<none>uint64

hasCurrencyPair ​

returns if a currency pair is being tracked by the oracle module.

solidity
function hasCurrencyPair(string memory pair) external view returns (bool);
function hasCurrencyPair(string memory pair) external view returns (bool);

Parameters

NameTypeDescription
pairstringthe currency pair to check.

getDecimals ​

returns the number of decimals for the given currency pair.

solidity
function getDecimals(string memory pair) external view returns (uint8);
function getDecimals(string memory pair) external view returns (uint8);

Parameters

NameTypeDescription
pairstringthe currency pair to get the decimals of.

addCurrencyPairs ​

write method to add currency pairs to be tracked by the oracle module.

solidity
function addCurrencyPairs(string[] memory pairs) external returns (bool);
function addCurrencyPairs(string[] memory pairs) external returns (bool);

Parameters

NameTypeDescription
pairsstring[]the currency pairs to add.

removeCurrencyPairs ​

write method to remove currency pairs from being tracked by the oracle module.

solidity
function removeCurrencyPairs(string[] memory pairs) external returns (bool);
function removeCurrencyPairs(string[] memory pairs) external returns (bool);

Parameters

NameTypeDescription
pairsstring[]the currency pairs to remove.

Events ​

CurrencyPairsAdded ​

Gets emitted when currency pairs are added.

solidity
event CurrencyPairsAdded(string[] currencyPairs);
event CurrencyPairsAdded(string[] currencyPairs);

Parameters

NameTypeDescription
currencyPairsstring[]all pairs which were added.

CurrencyPairsRemoved ​

Gets emitted when a currency pairs are removed.

solidity
event CurrencyPairsRemoved(string[] currencyPairs);
event CurrencyPairsRemoved(string[] currencyPairs);

Parameters

NameTypeDescription
currencyPairsstring[]all pairs which were removed.