Last updated
Was this helpful?
Last updated
Was this helpful?
Demex EVM has built-in oracle smart contracts allow enable EVM developers to query the same set of oracle data that L1 modules use, without using a third-party like Chainlink or Band Protocol. This means all market data available to the L1 modules is also available to EVM smart contracts.
Each oracle created on Demex L1 automatically deploys a corresponding EVM oracle smart contract that is constantly updated with the latest data from the oracle.
Smart contract authors can make use of the same oracles that power Demex's perp trading and CDP capabilities to develop their own unique dApps such as binary options, gaming, DCA strategies etc.
Oracle contracts possess a few simple methods for querying:
Decimals Returns the the number of decimal places that the data contains. Different contract may implement a different number of decimals and incorrect conversion will result in erroneous data.
Creator Users should verify that the contract deployed by Demex's Oracle module by checking the creator's address originate from Demex Core's Oracle Module. List of modules address are listed .
GetLatestData Returns the latest results from the oracle which contains the latest price and the the timestamp of the data. The price data contains a specified number of decimals and need to be appropriately converted for usage.
GetLastUpdateTime Returns the unix timestamp of which the contract was last updated. This method allows the callers of the contract to ensure that the contract is still lively and active.
Developers should always verify the validity of the oracle results using the above methods and timestamps provided.
The list of available oracles and their corresponding built-in smart contract addresses can be found .
The last result and parameters of the oracle can also be queried using the following API endpoint:
https://api.carbon.network/carbon/oracle/v1/contract_params/<OracleID>
e.g.: