Solana Oracle
This page contains an overview over the DIA Solana oracle.
Demo Application
A demo application has been deployed to the Solana blockchain. It is deployed to this address on Solana mainnet: 6sN1jKnMYsmh5inJ7W9jLCiuxZrYoYp8eEjXUH3o9TQG
The application currently supports this set of asset prices. They are updated approximately daily.
Asset Name | Query Command |
---|---|
Solana | SOL |
Bitcoin | BTC |
Ethereum | ETH |
Diadata | DIA |
Circle USD | USDC |
Cardano | ADA |
Solana Oracle Operations
The Solana blockchain uses a different address to store each oracle index (Read more about Solana Program Derived Addresses).
Therefore, to read the price of an asset, it is a requirement to have the address that stores the price of that asset.
The workflow presented below represents the configuration of the DIA Solana Oracle and how data should be supplied to it through the DIA Data Feeder.
DIA Data Feeder
The feeder gets symbol price informaton available from DIA.
The feeder calls the API https://api.diadata.org/v1/quotation/_symbol_ with each asset obtained from the configured asset list.
For each symbol that the feeder calls to quote, it verifies that the data has been received correctly. If for some reason, the feeder does not obtain the data or the data is incorrect, it continues with the next symbol, and so on, until it ends with all the configured asset symbols.
Once the feeder verifies all the data, it creates an address for each symbol for the first time (creation phase). At the update phase, if the symbol was already stored before, a transaction is sent to the oracle updating the price. If new symbols appear, a new address is created for the symbol and a transaction is submitted loading the price and symbol for the first time and saved. Continue with the next symbol.
Once all the symbols have been traversed, the feeder returns to step 1 to call all the symbols that the API has.
There are several workflows associated with the DIA Data Feeder.
Create Data
The Feeder prepares the following data:
Symbol address: this data can be generated and stored at the moment of being supplied to the oracle or it can be created in a previous instance and stored in a database.
Authority: is the address that will be authorized in the future to update the asset data. Important: it can be the same address as the Symbol address.
Data asset: Price and symbol.
The feeder calls the contract with the data and the function "create_coin_info". This way, the asset of that Symbol address is initialized.
Update Data
Feeder prepares the data to call and update the asset:
Symbol address: address that stores the data.
Authority: previously authorized address, it must also be a signer for the transaction.
Data asset: Price.
Feeder calls the contract with the data and the function "update_coin_info", updating the price of the asset.
Oracle Asset Structure
In the current Oracle architecture, each asset has its own authority address; this address can either be different for each asset or the same for all the assets.
Assets are stored using the following structure: