description |
---|
This page contains an overview over the DIA Solana oracle. |
A demo application has been deployed to the Solana blockchain. A simple frontend showing current asset prices is hosted as a static site and can be accessed here:
The application currently supports this set of asset prices.
Asset Name | Query Command | Address (Devnet) |
---|---|---|
Solana | SOL | PD8AXFHHqVFqrywQYTrJfrDNY4oAENBKSHq6ctQXPfa |
Bitcoin | BTC | FJpv98TrcWURFaGXVRnzwQ7gfdF2ZWzKYeRo6Y3Jim9Z |
Ethereum | ETH | GzBueExjjLxHbUK5QYBUKVHxUh4vU4wztKdtQ1UyejT3 |
Diadata | DIA | 4xfZ1FhvuDqMLSUUMyLBKdJpEjfC6VQYsnZqAFV182BR |
Circle USD | USDC | E6nLSeutmECcp1USAWUnuYJ3NRKNAtKyv1SBMNLPRv5V |
Cardano | ADA | EieYNn9t56ma52Jt3UYbeMCVyzf3jt4bGXE55gQJFRJK |
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.
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.
- 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.
- 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.
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:
#[account]
pub struct CoinInfo {
price: u64,
supply: u64,
last_update_timestamp: u64,
authority: Pubkey,
symbol: String
}