Band Protocol
Band Protocol is a cross-chain data oracle platform that aggregates and connects real-world data and APIs to smart contracts.
Price Feeds
Testnet
0x8c064bCf7C0DA3B3b090BAbFE8f3323534D84d68
Mainnet
0x9c5490fc68005dF8b2DC124309c2C036B93d785f
Band Protocol's Solidity Standard Reference Contracts
Overview
This repository contains the Solidity code for Band Protocol's StdReference contracts. The live contract addresses can be found in the documentation.
Usage
To query prices from Band Protocol's StdReference contracts, the contract looking to use the price values should reference Band Protocol's StdReference
contract. This contract exposes the getReferenceData
and getReferenceDataBulk
functions.
These can be imported via the IStdReference
interface.
ReferenceData
The ReferenceData
struct is defined as:
where the struct variables:
rate
is defined as the base/quote exchange rate multiplied by 1e18.lastUpdatedBase
is defined as the UNIX epoch of the last time the base price was updated.lastUpdatedQuote
is defined as the UNIX epoch of the last time the quote price was updated.
getReferenceData
Input
The base symbol as type
string
The quote symbol as type
string
Output
The base quote pair result as type
ReferenceData
Example
For example, if we wanted to query the price of BTC/USD
, the demo contract below shows how this can be done.
The result from demo()
would yield:
Where the results can be interpreted as:
BTC/USD
rate = 23131.27 BTC/USD
lastUpdatedBase = 1659588229
lastUpdatedQuote = 1659589497
getReferenceDataBulk
getReferenceDataBulk
takes two lists as the inputs, the base and quote symbols. The return value is ReferenceData[]
.
Input
An array of base symbols as type
string[]
An array of quote symbol as type
string[]
Output
An array of the base quote pair results as type
ReferenceData[]
Example
For example, if we wanted to query the price of BTC/USD
and ETH/BTC
, the demo contract below shows how this can be done.
The result from demo_bulk()
would yield:
Where the results can be interpreted as:
BTC/USD
rate = 23131.27 BTC/USD
lastUpdatedBase = 1659588229
lastUpdatedQuote = 1659589497
ETH/BTC
rate = 0.07160177543213148 ETH/BTC
lastUpdatedBase = 1659588229
lastUpdatedQuote = 1659588229
Last updated