There are two ways that you can access the oracle in your dApp. You can either declare an IDIAOracleV2 interface or import the solidity library.
getValue(pair_name)
with pair_name
being the full pair name such as BTC/USD
. You can use the “Read” section on Etherscan to execute this call.Solidity integration example
getPrice
and getPriceIfNotOlderThan
.
Name | Type | Description |
---|---|---|
oracle | address | Address of the oracle that we want to use |
key | string | The asset that we want to use e.g. “ETH/USD” |
Name | Type | Description |
---|---|---|
latestPrice | uint128 | Price of the specified asset returned by the DIAOracle |
timestampOflatestPrice | uint128 | The update timestamp of the latest price |
maxTimePassed
Parameters:
Name | Type | Description |
---|---|---|
oracle | address | Address of the oracle that we want to use |
key | string | The asset that we want to use e.g. “ETH/USD” |
maxTimePassed | uint128 | The maximum acceptable time passed in seconds since the the price was updated |
Name | Type | Description |
---|---|---|
price | uint128 | Price of the specified asset returned by the DIAOracle |
inTime | bool | A boolian that is true if the price was updated at most maxTimePassed seconds ago, otherwise false |