# Feeders (Sourcing Layer) Source: https://www.diadata.org/docs/dia-stack/architecture/core-components/feeders At the heart of Lumina is a decentralized data collection system composed of feeder nodes operating within the Distributed Feeder Network, responsible for sourcing data and feeding it into the Lasernet chain. ## Key components ### **Feeder** **A Feeder** is a single node in a Distributed Feeder Network that fetches granular market data directly from decentralized exchanges (DEXs), centralized exchanges (CEXs), and third-party data sources. Feeders are responsible for sourcing trade ticks and pushing them to Pods—smart contracts running on DIA's Lasernet—at configurable intervals (e.g. 30 seconds). There are four main elements that make up a feeder: #### Scrapers The expected input for a scraper is a set of pair tickers such as `BTC-USDT`. Tickers are always capitalized and symbols separated by a hyphen. It's the role of the scraper to format the pair ticker such that it can subscribe to the corresponding (websocket) stream. #### Collector The collector gathers trades from all running scrapers. As soon as it receives a signal through a trigger channel it bundles trades in *atomic tradesblocks*. An atomic tradesblock is a set of trades restricted to one market on one exchange, for instance `BTC-USDT` trades on Binance exchange. These tradesblocks are sent to the `Processor`. #### Processor The processor is a 2-step aggregation procedure: Aggregate trades from an atomic tradesblock. The type of aggregation can be selected through an environment variable (see Feeder/main). The only assumption on the aggregation implementation is that it returns a `float64`. Aggregate filter values obtained in step 1. The selection of aggregation method and assumptions are identical to Step 1. The obtained scalar value is sent to the Oracle feeder. #### Pods Pods (or feeder contracts) are a simple key-value oracle contracts assigned to each feeder node. They store the value obtained from the Processor. It is worth mentioning that the trigger mechanism for starting a new cycle of the data collection flow can be implemented on-chain using the feeder contract. Find out more about the feeder structure and how to run your own feeder [here](/guides/general-guides/run-a-feeder). ## Staking Incentives To encourage honest behavior, oracle feeders will be rewarded for successful operations and penalized for harmful actions. These incentives ensure that dishonest behavior is punished and becomes economically unviable. Rewards and penalties will primarily be based on uptime and accuracy, measured by the timeliness of updates and the accuracy of prices compared to other feeders. Initially, feeders will gather the last traded price for assets from centralized exchanges (CEXs). For decentralized exchanges (DEXs), we will use trade simulation-based price estimation, which simulates trades to obtain current exchange rates. This approach ensures more accurate pricing, particularly for assets that are infrequently traded. # DIA Chain Information Source: https://www.diadata.org/docs/dia-stack/architecture/core-components/lasernet/chain-information ## Lasernet Overview DIA Lasernet serves as the core aggregation layer in the Lumina oracle architecture. As an Ethereum Layer-2 rollup, it provides a trustless and transparent environment where feeder nodes submit price data to their assigned Pods (smart contracts), and aggregators process this data into final oracle values. The chain ensures full data transparency, and verifiability for DIA oracles. Learn more about how Lasernet works in the [Lumina architecture](/dia-stack/architecture/core-components/lasernet/overview) section. ## Chain Information ### Mainnet | | | | ------------------ | ------------------------------------------------------------------------------------- | | **Chain name** | DIA Lasernet | | **Chain ID** | 1050 | | **Block explorer** | [https://explorer.diadata.org/](https://explorer.diadata.org/) | | **RPC URL** | [https://rpc.diadata.org/](https://rpc.diadata.org/) | | **Websocket** | wss\://rpc.diadata.org | | **Gas token** | [DIA on ETH](https://etherscan.io/address/0x84ca8bc7997272c7cfb4d0cd3d55cd942b3c9419) | ### Testnet | | | | ------------------ | ----------------------------------------------------------------------------------------------------- | | **Chain name** | DIA Lasernet Testnet | | **Chain ID** | 100640 | | **Block explorer** | [https://testnet-explorer.diadata.org](https://testnet-explorer.diadata.org) | | **RPC URL** | [https://testnet-rpc.diadata.org](https://testnet-rpc.diadata.org) | | **Websocket** | wss\://testnet-rpc.diadata.org | | **Gas token** | [DIA on ETH Sepolia](https://sepolia.etherscan.io/address/0xa35a89390FcA5dB148859114DADe875280250Bd1) | | **Faucet** | [https://faucet.diadata.org/](https://faucet.diadata.org/) | # Overview Source: https://www.diadata.org/docs/dia-stack/architecture/core-components/lasernet/overview DIA Lumina employs a flexible and trustless system for processing data into final outputs. After Feeders collect and aggregate data, they're stored in their assigned contract (Pods) on the Lasernet rollup. The final aggregation happens on the meta-contract which collects data from Pods using customizable rules and produces a final value to deliver cross-chain. ## Key Components ## **Lasernet** As the backbone of the system, Lasernet is an optimistic Ethereum Layer-2 rollup. It serves as an open data repository that handles the full lifecycle of data, minimzing trust and supporting full verifiability. The Lasernet chain is built for scalability using the Arbitrum Orbit Stack to handle large oracle transactions at a low cost. The DIA Lumina oracle consists of two major components: the collection of key-value smart contract that collect price data from each feeder. a contract that collates these prices from the key-value contracts and provides an automatically refreshed reading of the latest market price. An exemplary Lumina data flow can be seen here. [Feeders](/dia-stack/architecture/core-components/feeders) scrape trades from exchanges and submit these as last prices into their Pods on Lasernet. The final aggregation of these values is done through the meta-contract (or the Aggregator). To ensure the accuracy of the final value, the meta-contract uses a *threshold* to require a minimum number of valid price submissions before considering the data reliable. Additionally, a *timeout period* in seconds is enforced to discard any outdated price data, so that only fresh and relevant information is used in the final calculation (e.g. 5 data submissions within 1 min). ## **Pods** These are smart contracts that securely store on-chain data. They receive regular updates from their assigned Feeders, ensuring that asset prices are accurate and up-to-date. Feeders make price data openly available for all users on the network. Each decentralized Lumina feeder writes data into its own oracle contract. This feeder contract is a basic key-value store which stores oracle updates accessible by a key, such as `BTC/USD`. The data stored for each entry is the last price of the asset and the timestamp of that price. ### Data Packing In order to pack the data efficiently, the entries (price and timestamp) are packed into the same `uint256` when an update is written to the key-value store. ```javascript theme={"system"} function setValue(string memory key, uint128 value, uint128 timestamp) public onlyRole(UPDATER_ROLE) { uint256 cValue = (((uint256)(value)) << 128) + timestamp; values[key] = cValue; emit OracleUpdate(key, value, timestamp); } ``` ### Read Data Updates You can optionally interact with the individual feeder contracts directly by calling `getValue()` that returns the latest price update stored for the requested asset. 1. Call `getValue(pairName)` with `pairName` being the full pair name such as BTC/USD. The quote asset is always in USD for any asset. 2. The response of the call contains two values: * The current asset price in USD with a fix-comma notation of 8 decimals. * The UNIX timestamp of the last oracle update. ## **Aggregator** A smart contract that picks data from multiple Pods and creates a final median value (also referred to as a meta-contract). Multiple Aggregator smart contracts can be deployed, creating a flexible framework for users. Aggregators operate with customizable rulesets (custom sources, aggregation windows, and more), allowing them to cater to different use cases. Aggregators also have the option to benchmark data against external sources for additional security. The meta-contract exposes a simple `Read` function called `getValue()`. It has one parameter `pairKey`, which consists of the symbol of the queried asset and `/USD` to denominate its price in US Dollars. For instance, the latest Bitcoin price is queried by calling `getValue("BTC/USD")`. The function then returns two values: 1. The value of the asset in US Dollars, with 8 decimals. 2. The timestamp of the block with the latest calculation result. The oracle has several safeguards against becoming stale or having not enough feeders providing updates. ### How it works #### Price Aggregation Methodology The current version of the meta-contract supports the median methodology which is calculated by collecting values from all registered Pods (or feeder contracts), filtering out outdated values based on the timeout period, and ensuring a minimum number of valid values (threshold) are available. The remaining valid values are sorted through a Quicksort algorithm, and the middle value is selected as the median. Later iterations of the meta-contract will allow selecting different methodologies for each price evaluation. #### Roles Each meta-contract has an `admin` address that can setup the meta-contract for its specific usage. The admin is able to add and remove feeders, set a threshold of required feeders, and set a timeout duration after which a feeder update is considered stale. #### Registering Feeders The meta-contract needs to learn about available Pods in the Distributed Feeder Network. The admin can add as many feeders as they wish to the price evaluation using the `addOracle()` method. The required parameter of that method is the address of a Pod on Lasernet. After an oracle is added, its latest prices are immediately part of the price evaluation. #### Removing Feeders If needed, oracle feeders can also be removed by the admin. The required parameter of that method is is the address of a feeder contract on Lasernet. Removal is immediate, so any call made to `getValue()` from the removal block onwards will not include data from the removed feeder any more. #### Acceptance Threshold To make price discovery more robust, a threshold needs to be set by the admin. This threshold corresponds to the number of feeders that need to have submitted a price to reach a valid consensus. You can find all of the deployedcontracts on Lasernet for Lumina components [here](/guides/dia-deployments). ## Key Benefits From data collection, storage and computation, every step in the process is transparent, traceable and verifiable. Lumina's modular design allows developers to deploy their own custom Aggregators, offering unmatched flexibility for different data needs. Alternatively, DIA offers the Oracle Builder, a no-code solution for the same purpose. # Architecture Overview Source: https://www.diadata.org/docs/dia-stack/architecture/core-components/overview Explore how Lumina handles the flow of data and updates across the network using its robust and modular architecture. The data flow is broken down into the following phases: Explore the data sources that are used to power the Lumina oracle: # Spectra (Cross-chain Messaging Layer) Source: https://www.diadata.org/docs/dia-stack/architecture/core-components/spectra DIA Lumina achieves full interoperability, delivering oracle data to any blockchain with minimal friction through the Spectra protocol, a message passing layer powering both the push and pull oracle models. ## **Data Delivery Methods** Spectra is an interchain message passing protocol formed by a network of nodes, running a custom instance of Hyperlane, an open interoperability framework. It facilitates secure and rapid transmission of oracle data to any blockchain, without the need for chain-specific integrations. The Spectra validators observe messages on the mailboxes of the destination and origin chains. The messages are then checked through the ISM (Interchain Security Module) and delivered to these components: * RequestOracle (Pull oracle) * PushOracleReceiver (Push oracle) The gas for processing messages are funded by imposing a fee for calling `request()` on *RequestOracle*, or `handle()` on the *PushOracleReceiver* contracts. The fees are transferred to the ProtocolFeeHook – an instance of Hyperlane's [Post-Dispatch](https://docs.hyperlane.xyz/docs/protocol/core/post-dispatch-hooks-overview#post-dispatch-hooks-overview) hooks - that are then withdrawn manually to the Spectra gas wallet. Let's explore how Spectra contributes to the flow of messages in the Push and Pull oracle models and how that translates to the data you receive on the destination chain. ### Pull Model * User initiates a request to the RequestOracle contract and pays a fee. * RequestOracle processes the request on the origin chain (e.g. Ethereum), creates a message containing the request details (destination chain id, OracleRequestRecipient address, exchange pair, ...etc), then dispatches it through the Mailbox. * The validators observes the mailbox and picks up the request. once it verifies its validity through the ISM and signs it, the relayer carries out the message delivery to the mailbox of the destination chain (DIA lasernet). * OracleRequestRecipient receives and validates the message through the ISM, and passes it forward to OracleTrigger that fetches the values from the [Aggregator](/dia-stack/architecture/core-components/lasernet/overview#aggregator) or meta-contract. It then creates a message with the latest price, and dispatches it back to Lasernet's mailbox. * Message is picked up by Spectra protocol and sent back to the RequestOracle which then checks for data freshness and adds the value to the `updates`mapping. ### Push Model * Go feeder service initiates a price update based on certain parameters (such as deviation, heartbeat, & refresh frequency) on the origin chain (DIA's lasernet). * OracleTrigger processes the update request, reads the latest price from the meta-contract, creates a message, & dispatches it through the Mailbox. * The validators observes the mailbox and picks up the update request. once it verifies its validity through the ISM and signs it, the relayer carries out the message delivery to the mailbox of the destination chain. * PushOracleReceiver receives the update, validates the message through the ISM, checks for the data freshness, the adds the value to the `updates`mapping. ### Fees Cost of updating data on the destination chain is calculated as follows: ```bash theme={"system"} uint256 gasUsedPerTx = 97440; // Fixed gas amount uint256 gasPrice = tx.gasprice; // Current network gas price uint256 cost = gasUsedPerTx * gasPrice; // Total fee ``` ## Key Benefits: Cross-chain data delivery is made simple through Spectra, dramatically reducing time to market for developers, and allowing data to be transmitted across blockchains with minimal friction and no chain-specific setup. # CEXes Data Source: https://www.diadata.org/docs/dia-stack/architecture/data-sources/cexes-data ### Centralized Cryptocurrency Exchanges All trading data is retrieved through Rest APIs or websocket APIs, developed and maintained by the respective trading platform. See the below table for detailed information on all sources. We remark that by the very nature of a websocket API, there is no retrieval frequency, instead, trading data comes in continuously as it is produced. | Exchange | API Link | See live data | | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | [**Binance**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/BinanceScraper.go) | [Binance Websocket Documentation](https://binance-docs.github.io/apidocs/spot/en/#trade-streams) | [https://www.diadata.org/app/source/defi/Binance/](https://www.diadata.org/app/source/defi/Binance/) | | [**Bitfinex**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/BitfinexScraper.go) | [Bitfinex Websocket Documentation](https://docs.bitfinex.com/docs/ws-general) | [https://www.diadata.org/app/source/defi/Bitfinex/](https://www.diadata.org/app/source/defi/Bitfinex/) | | [**BitMax**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/BitmaxScraper.go) | [Bitmax API Documentation](https://bitmax-exchange.github.io/bitmax-pro-api/#bitmax-pro-api-documentation) | [https://www.diadata.org/app/source/defi/Bitmax/](https://www.diadata.org/app/source/defi/Bitmax/) | | [**BitMart**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/BitMartScraper.go) | [BitMart API Documentation](https://www.bitmart.com/open-api-guide/en) | [https://www.diadata.org/app/source/defi/BitMart/](https://www.diadata.org/app/source/defi/BitMart/) | | [**BitMex**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/BitMexScraper.go) | [BitMex API Documentation](https://www.bitmex.com/app/apiOverview) | [https://www.diadata.org/app/source/defi/BitMex/](https://www.diadata.org/app/source/defi/BitMex/) | | **BitStamp** | [BitStamp API Documentation](https://www.bitstamp.net/api/) | [https://www.diadata.org/app/source/defi/Bitstamp/](https://www.diadata.org/app/source/defi/Bitstamp/) | | [**Bybit**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/ByBitScraper.go) | [Bybit API Documentation](https://bybit-exchange.github.io/docs/inverse/#t-introduction) | [https://www.diadata.org/app/source/defi/ByBit/](https://www.diadata.org/app/source/defi/ByBit/) | | [**Coinbase**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/CoinBaseScraper.go) | [Coinbase Websocket Documentation](https://docs.pro.coinbase.com/) | [https://www.diadata.org/app/source/defi/CoinBase/](https://www.diadata.org/app/source/defi/CoinBase/) | | [**Crypto.com**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/CryptoDotComScraper.go) | [Crypto.com API Documentation](https://exchange-docs.crypto.com/spot/index.html#introduction) | [https://www.diadata.org/app/source/defi/Crypto.com/](https://www.diadata.org/app/source/defi/Crypto.com/) | | [**GateIO**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/GateIOScraper.go) | [GateIO Websocket Documentation](https://www.gate.io/docs/websocket/index.html) | [https://www.diadata.org/app/source/defi/GateIO/](https://www.diadata.org/app/source/defi/GateIO/) | | [**Kraken**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/KrakenScraper.go) | [Kraken Rest API Documentation](https://www.kraken.com/features/api#public-market-data) | [https://www.diadata.org/app/source/defi/Kraken/](https://www.diadata.org/app/source/defi/Kraken/) | | [**KuCoin**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/KuCoinScraper.go) | [Kucoin API Documentation](https://docs.kucoin.com/#websocket-feed) | [https://www.diadata.org/app/source/defi/KuCoin/](https://www.diadata.org/app/source/defi/KuCoin/) | | [**MEXC**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/MEXCScraper.go) | [MEXC API Documentation](https://mxcdevelop.github.io/APIDoc/) | [https://www.diadata.org/app/source/defi/MEXC/](https://www.diadata.org/app/source/defi/MEXC/) | | [**OKEx**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/OKExScraper.go) | [OKEx Websocket Documentation](https://www.okex.com/docs/en/#ws_swap-README) | [https://www.diadata.org/app/source/defi/OKEx/](https://www.diadata.org/app/source/defi/OKEx/) | | [**Bitget**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/BitgetScraper.go) | [Bitget Websocket Documentation](https://www.bitget.com/api-doc/common/websocket-intro) | [https://www.diadata.org/app/source/defi/Bitget/](https://www.diadata.org/app/source/defi/Bitget/) | # DEXes Data Source: https://www.diadata.org/docs/dia-stack/architecture/data-sources/dexes-data In contrast to centralized exchanges, in decentralized exchanges, it is possible to retrieve trading data directly from the respective blockchain by subscribing to the corresponding pool events. ## Decentralized Cryptocurrency Exchanges (DEXes) In order to supply data to our community as quickly as possible, we retrieved the trading data for a few exchanges through Rest APIs (see table below). However, we remark that we are implementing data retrieval through the blockchain directly to reduce unnecessary dependencies. This concerns *all* decentralized exchanges. | Exchange | Blockchain | See live data | | --------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [**AerodromeSlipstream**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV3Scraper.go#L108) | Base | [https://www.diadata.org/app/source/defi/AerodromeSlipstream/](https://www.diadata.org/app/source/defi/AerodromeSlipstream/) | | [**Aerodrome V1**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/VelodromeScraper.go#L70) | Base | [https://www.diadata.org/app/source/defi/AerodromeV1/](https://www.diadata.org/app/source/defi/AerodromeV1/) | | [**ApeSwap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | BNB Chain | [https://www.diadata.org/app/source/defi/Apeswap/](https://www.diadata.org/app/source/defi/Apeswap/) | | [**Arthswap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Astar | [https://www.diadata.org/app/source/defi/Arthswap/](https://www.diadata.org/app/source/defi/Arthswap/) | | [**Ayin**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/AyinScraper.go) | Alephium | [https://www.diadata.org/app/source/defi/Ayin/](https://www.diadata.org/app/source/defi/Ayin/) | | [**Balancer v2**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/BalancerV2Scraper.go) | -Ethereum
-Polygon
-Arbitrum | [Ethereum](https://www.diadata.org/app/source/defi/BalancerV2/), [Polygon](https://www.diadata.org/app/source/defi/BalancerV2-Polygon/), [Arbitrum](https://www.diadata.org/app/source/defi/BalancerV2-Arbitrum/) sources | | [**Beets**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Fantom | [https://www.diadata.org/app/source/defi/Beets/](https://www.diadata.org/app/source/defi/Beets/) | | [**Bifrost**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/BifrostScraper.go) | Bifrost | [https://www.diadata.org/app/source/defi/Bifrost/](https://www.diadata.org/app/source/defi/Bifrost/) | | [**Biswap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | BNB Chain | [https://www.diadata.org/app/source/defi/Biswap/](https://www.diadata.org/app/source/defi/Biswap/) | | [**Bitflow**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/BitflowScraper.go) | Stacks | [https://www.diadata.org/app/source/defi/Bitflow/](https://www.diadata.org/app/source/defi/Bitflow/) | | [**Camelot**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go#L193) | Arbitrum | [https://www.diadata.org/app/source/defi/Camelot/](https://www.diadata.org/app/source/defi/Camelot/) | | [**Camelot v3**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/camelotv3/camelotv3.go) | Arbitrum | [https://www.diadata.org/app/source/defi/CamelotV3/](https://www.diadata.org/app/source/defi/CamelotV3/) | | [**Curve**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/CurvefiScraper.go) | -Ethereum
-Arbitrum
-Fantom
-Moonbeam
-Polygon | [Ethereum](https://www.diadata.org/app/source/defi/Curvefi/), [Arbitrum](https://www.diadata.org/app/source/defi/Curvefi-Arbitrum/), [Fantom](https://www.diadata.org/app/source/defi/Curvefi-Fantom/), [Moonbeam](https://www.diadata.org/app/source/defi/Curvefi-Moonbeam/), [Polygon](https://www.diadata.org/app/source/defi/Curvefi-Polygon/) sources | | [**Dfyn**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Polygon | [https://www.diadata.org/app/source/defi/DFYN/](https://www.diadata.org/app/source/defi/DFYN/) | | [**Diffusion**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | EVMOS | [https://www.diadata.org/app/source/defi/Diffusion/](https://www.diadata.org/app/source/defi/Diffusion/) | | [**Hermes**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Metis | [https://www.diadata.org/app/source/defi/Hermes/](https://www.diadata.org/app/source/defi/Hermes/) | | [**Huckleberry**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Moonriver | [https://www.diadata.org/app/source/defi/Huckleberry/](https://www.diadata.org/app/source/defi/Huckleberry/) | | [**Hydration**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/HydrationScraper.go) | Hydration | [https://www.diadata.org/app/source/defi/Hydration/](https://www.diadata.org/app/source/defi/Hydration/) | | [**Maverick**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/MaverickScraper.go) | Ethereum | [https://www.diadata.org/app/source/defi/Maverick/](https://www.diadata.org/app/source/defi/Maverick/) | | [**Netswap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Metis | [https://www.diadata.org/app/source/defi/Netswap/](https://www.diadata.org/app/source/defi/Netswap/) | | [**NileV1**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go#L237) | Linea | [https://www.diadata.org/app/source/defi/NileV1/](https://www.diadata.org/app/source/defi/NileV1/) | | [**NileV2**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV3Scraper.go#L106) | Linea | [https://www.diadata.org/app/source/defi/NileV2/](https://www.diadata.org/app/source/defi/NileV2/) | | [**OmniDEX**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Telos | [https://www.diadata.org/app/source/defi/OmniDex/](https://www.diadata.org/app/source/defi/OmniDex/) | | [**Orca**](https://github.com/diadata-org/diadata/tree/master/pkg/dia/scraper/exchange-scrapers/orca) | Solana | [https://www.diadata.org/app/source/defi/Orca/](https://www.diadata.org/app/source/defi/Orca/) | | [**Osmosis**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/OsmosisScraper.go) | Cosmos | [https://www.diadata.org/app/source/defi/Osmosis/](https://www.diadata.org/app/source/defi/Osmosis/) | | [**PancakeSwap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Binance Smart Chain | [https://www.diadata.org/app/source/defi/PanCakeSwap/](https://www.diadata.org/app/source/defi/PanCakeSwap/) | | [**PancakeSwapV3**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Binance Smart Chain | [https://www.diadata.org/app/source/defi/PanCakeSwapV3/](https://www.diadata.org/app/source/defi/PanCakeSwapV3/) | | [**Pangolin**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Avalanche | [https://www.diadata.org/app/source/defi/Pangolin/](https://www.diadata.org/app/source/defi/Pangolin/) | | [**Pearlfi**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go#L243) | Unreal | [https://www.diadata.org/app/source/defi/Pearlfi/](https://www.diadata.org/app/source/defi/Pearlfi/) | | [**Quickswap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Polygon | [https://www.diadata.org/app/source/defi/Quickswap/](https://www.diadata.org/app/source/defi/Quickswap/) | | [**RamsesV1**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go#L239) | Arbitrum | [https://www.diadata.org/app/source/defi/RamsesV1/](https://www.diadata.org/app/source/defi/RamsesV1/) | | [**RamsesV2**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV3Scraper.go#L104) | Arbitrum | [https://www.diadata.org/app/source/defi/RamsesV2/](https://www.diadata.org/app/source/defi/RamsesV2/) | | [**Solarbeam**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Moonriver | [https://www.diadata.org/app/source/defi/Solarbeam/](https://www.diadata.org/app/source/defi/Solarbeam/) | | [**Spookyswap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Fantom | [https://www.diadata.org/app/source/defi/Spookyswap/](https://www.diadata.org/app/source/defi/Spookyswap/) | | [**Stellaswap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Moonbeam | [https://www.diadata.org/app/source/defi/Stellaswap/](https://www.diadata.org/app/source/defi/Stellaswap/) | | [**SushiSwap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | -Ethereum
-Arbitrum
-Fantom
-Polygon | [Ethereum](https://www.diadata.org/app/source/defi/SushiSwap/), [Arbitrum](https://www.diadata.org/app/source/defi/SushiSwap-arbitrum/), [Fantom](https://www.diadata.org/app/source/defi/SushiSwap-fantom/), [Polygon](https://www.diadata.org/app/source/defi/SushiSwap-polygon/) sources | | [**Tethys**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Metis | [https://www.diadata.org/app/source/defi/Tethys/](https://www.diadata.org/app/source/defi/Tethys/) | | [**Thena**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go#L241) | Binance Smart Chain | | | [**ThenaV3**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV3Scraper.go#L97) | Binance Smart Chain | | | [**Trader Joe**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Avalanche | [https://www.diadata.org/app/source/defi/TraderJoe/](https://www.diadata.org/app/source/defi/TraderJoe/) | | [**Trader Joe 2.1**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/traderjoe2.1/traderjoe.go) | Avalanche | [https://www.diadata.org/app/source/defi/TraderJoeV2.1-Arbitrum/](https://www.diadata.org/app/source/defi/TraderJoeV2.1-Arbitrum/) | | [**Trader Joe 2.2**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/TraderJoeScraper.go#L112) | Avalanche | [https://www.diadata.org/app/source/defi/TraderJoeV2.2-Avalanche/](https://www.diadata.org/app/source/defi/TraderJoeV2.2-Avalanche/) | | [**Trisolaris**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Aurora | [https://www.diadata.org/app/source/defi/Trisolaris/](https://www.diadata.org/app/source/defi/Trisolaris/) | | [**Ubeswap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Celo | [https://www.diadata.org/app/source/defi/Ubeswap/](https://www.diadata.org/app/source/defi/Ubeswap/) | | [**Uniswap V2**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Ethereum | [https://www.diadata.org/app/source/defi/Uniswap/](https://www.diadata.org/app/source/defi/Uniswap/) | | [**Uniswap V3**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV3Scraper.go) | -Ethereum
-Arbitrum
-Polygon
-Celo
-Base | [Ethereum](https://www.diadata.org/app/source/defi/UniswapV3/), [Arbitrum](https://www.diadata.org/app/source/defi/UniswapV3-Arbitrum/), [Polygon](https://www.diadata.org/app/source/defi/UniswapV3-polygon/), [Celo](https://www.diadata.org/app/source/defi/UniswapV3-Celo/), [Base](https://www.diadata.org/app/source/defi/UniswapV3-Base/) sources | | [**Velar**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/VelarScraper.go) | Stacks | [https://www.diadata.org/app/source/defi/Velar/](https://www.diadata.org/app/source/defi/Velar/) | | [**Velodrome**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/velodrome/velodrome.go) | Optimism | [https://www.diadata.org/app/source/defi/Velodrome/](https://www.diadata.org/app/source/defi/Velodrome/) | | [**Wanswap**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go) | Wanchain | [https://www.diadata.org/app/source/defi/Wanswap/](https://www.diadata.org/app/source/defi/Wanswap/) | | [**Zenlink**](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/ZenlinkScraper.go) | -Bifrost
-Bifrost-Polkadot | [Bifrost](https://www.diadata.org/app/source/defi/Zenlink/), and [Bifrost-Polkadot](https://www.diadata.org/app/source/defi/Zenlink-bifrost-polkadot/) sources | # Data Sources Source: https://www.diadata.org/docs/dia-stack/architecture/data-sources/overview Every price point starts with raw trading data from cryptocurrency exchanges (CEXes, & DEXes). We go straight to the source, capturing and storing trade data with the highest precision possible. Explore the sources that power our token price feeds: For an up-to-date list of data sources, visit: } /> ## Verifiable Randomness Explore how DIA leverages drand's distributed randomness beacon to provide verifiable, unbiased random numbers for on-chain applications like games, lotteries, and NFT drops: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp’s needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: # Distributed Randomness Beacon Source: https://www.diadata.org/docs/dia-stack/architecture/data-sources/randomness DIA leverages Drand's distributed randomness beacon to provide verifiable, unbiased random numbers on-chain To offer distributed and verifiable randomness on-chain, DIA leverages [drand](https://drand.love/)'s distributed randomness beacon. The beacon is run by a group of independent actors called the League of Entropy. The [League of Entropy](https://www.cloudflare.com/leagueofentropy/) is a collaborative project to provide a verifiable, decentralized randomness beacon. A decentralized randomness beacon combines randomness from multiple independent high entropy sources to generate a truly unbiased random number for anyone that may need a public source of randomness. Please visit the project site at [drand.love](https://drand.love/) for the most up-to-date information on current operations. To learn how the how distributed randomness beacon is built please [visit this link](https://drand.love/docs/specification/). ## What is randomness? Randomness is the property of lacking any sensible predictability. It is very difficult to create random events on-chain due to the deterministic nature of any EVM or EVM-like environment. Centralized randomness is susceptible for attacks by the randomness source, as a single non-random outcome cannot be distinguished from a random one. Thus, having a single RNG provide randomness via an oracle is not enough. ## Who needs randomness? Random numbers can be very relevant for on-chain applications such as games, lotteries, prediction markets, or NFT launches. Relying on pseudo-random values like the last blockhash can be manipulated by miners and is not advisable. Drand run distributed nodes to produce their randomness beacon. They use [Pedersen's DKG (Distributed Key Generation) protocol](https://drand.love/docs/cryptography/#distributed-key-generation-dkg) to create collective private/public key. Participants in their League of Entropy then generate randomness in rounds and broadcast it together with its signature. ## On-chain publishing process From random number generation to on-chain distribution, DIA xRandom operates as follows: 1. **Drand randomness generation:** in every drand epoch (currently set at 30s for the existing LoE beacons, but [planned to be decreased](https://drand.love/blog/2022/02/21/multi-frequency-support-and-timelock-encryption-capabilities/) on future "unchained" beacons) each of the nodes that form the drand network generates a partial signature, which it broadcasts to the rest of the nodes. Once any node has enough, i.e., a threshold number of signatures, it computes the new randomness beacon, which is the hash of the signature aggregate. 2. **Drand randomness propagation and consumption**: the new beacon is propagated through the network to all other nodes. Any node can verify and accept or reject the hash of the signature (i.e., beacon) that it received. Any client or application can consume randomness out of band (i.e., without needing to be part of the drand network) either through [the public HTTP APIs](https://drand.love/developer/http-api/) or through [libp2p's pubsub protocol](https://drand.love/developer/gossipsub/#public-endpoints), Gossipsub. Clients can also verify that the randomness they received is indeed the one produced by the drand network. 3. **DIA on-chain distribution:** the final randomness signature is shipped on-chain as an oracle smart contract. In order to effectively and securely execute these on-chain transactions, DIA has built a robust, decentralised node infrastructure — dubbed DIA xNode. DIA xNode is a network of third-party, decentralized node providers that grant DIA the blockchain infrastructure to push data on-chain ensuring high rate limits. ## Risk Mitigation It is important to understand the risks of the randomness oracle before using it and to be able to mitigate them. An extensive risk evaluation of the underlying [drand.love](https://drand.love/) protocol can be found [in their documentation](https://drand.love/docs/security-model/#notations). All risks listed there also affect the randomness guest oracle, as it serves as an underlying data provider. Additionally, there are new risks introduced by using the oracle. | Risk | Possible Mitigation | | -------------------------------------- | ------------------------------------------------------------------------------------------------- | | Oracle stops serving data | Check that the oracle has recent updates in its history. | | Specific Round is missed by the oracle | Have your dApp use the next round if a certain round is unavailable (but later ones exist). | | Oracle serves compromised data | Check the associated BLS signature provided by drand (Note: Currently not availabe on most EVMs). | # Fundamental Feeds Source: https://www.diadata.org/docs/dia-stack/data-products/fundamental-feeds Derive asset values from their fundamentals rather than market prices. Ideal for stablecoins, synthetic assets, and yield-bearing tokens. Fundamental Feeds provide an alternative to market-based pricing by calculating an asset's value directly from its fundamentals. Instead of relying on exchange trades or liquidity-driven mechanisms, these feeds derive price from objective on-chain or off-chain proofs of collateral, redemption logic, and reserve holdings. This makes them particularly relevant for synthetic assets, stablecoins, yield-bearing tokens, and structured vaults. # Features * Independent of market volatility or liquidity distortions. * Transparent methodology based on verifiable reserves, liabilities, and contract logic. * Applicable across DeFi instruments ranging from liquid staking tokens to stablecoins and vaults. # Methodologies ## Contract Exchange Rate For tokens with built-in exchange logic (e.g. stETH, aUSDC, cDAI), price is calculated from the ratio of underlying assets to total shares: $$ exchangeRate = totalUnderlying / totalShares $$ ## Reserve-Backing For collateral-backed assets, reserves are divided by circulating supply to produce a backing-based fundamental value: $$ fundamentalPrice = reserves / supply $$ Reserves may consist of multiple assets held across wallets. ## Net Asset Value (NAV) For vault-based tokens, price equals the value of assets minus liabilities, divided by outstanding tokens: $$ fundamentalPrice = (assets - liabilities) / totalSupply $$ ## Redemption Value For mint/burn models, the fundamental value corresponds to the amount of underlying assets received when redeeming one token. This is typically retrievable directly from the redemption contract. ## Proof of Reserves For custodial or synthetic assets, feeds can publish the total value of reserves as reported by verified custodians or proof-of-reserve attestations: $$ reserveValue = \sum_{i=1}^{n} (reserves_i \times price_i) $$ # Architecture Flow Overview * Each feeder is pulling balance sheets (reserves, supply). * Lasernet is the ledger where all feeders submit their reports. * The aggregator contract is consolidating those reports into one official number. * The messaging layer is delivering that number to every chain where it's needed. * Protocols then rely on this official number to decide risk and operations. # Use Cases * **Stablecoins**: Validate peg integrity by comparing market price to backing-based fundamental value. * **Yield-bearing Tokens (LSTs, aTokens, cTokens)**: Track accruing value through exchange rates. * **Vaults and Structured Products**: Monitor NAV in real time to ensure accurate token pricing. * **Synthetic Assets**: Ensure collateralization ratios remain healthy through reserve-backed valuations. # Developer Notes Fundamental Feeds can operate alongside traditional market price feeds. Protocols can consume both sources to implement safeguards such as: * Depeg monitoring (triggering alerts if fundamental value diverges from market price). * Fallback mechanisms to fundamental pricing when market feeds become unreliable. * Enhanced transparency by exposing raw inputs such as reserve addresses or contract state. If you're interested in integrating Fundamental Feeds into your project, request a custom oracle below: # Real-World Asset Feeds Source: https://www.diadata.org/docs/dia-stack/data-products/rwa-price-feeds DIA xReal is designed for Real-World Asset (RWA) applications, bringing hundreds of data feeds for stocks, commodities, FX rates, and more on-chain. ## Overview DIA xReal is designed for Real-World Asset (RWA) applications, bringing hundreds of data feeds for stocks, commodities, FX rates, and more on-chain. It consists of two core components: Secure, transparent price oracles for RWA-powered dApps (options, futures, tokenized index funds & more) On-demand oracles for tokenized assets, bond yields, FX rates, & real-world financial metrics You can access all the available RWA data feeds & integration options below: } /> ## Learn More # Token Price Feeds Source: https://www.diadata.org/docs/dia-stack/data-products/token-price-feeds DIA token price feeds provide smart contracts with real-time price information of cryptocurrencies, transparently sourced from high-volume DEXs and CEXs. ## xMarket Overview DIA xMarket feeds provide smart contracts **real-time price information of 3,000+ cryptocurrencies**, transparently sourced from 100+ trusted, high-volume DEXs and CEXs. The feeds facilitate the development of DeFi use cases such as money markets, lending/borrowing, synthetic asset issuance, options, derivatives and futures markets, and many more. Browse all tokens that DIA's data library currently supports via the link below. New assets can also be supported on demand. } /> You can also check the list of data sources on the app. } /> ## How It Works Each [feeder](/reference/architecture/data-sourcing#feeder) in the Decentralized Feeder Network runs scrapers that collect real-time trade data from CEXes and DEXes for specific trading pairs (e.g., BTC-USDT) that are then forwarded to the Collector which bundles them into atomic tradeblocks (grouped by market and exchange). The Processor then performs a two-step aggregation: first aggregating trades within each atomic tradeblock into a single value, then combining these values into a final price, which is submitted to the designated Pod (feeder contract) on-chain. This enables your dApp to access first-party and verifiable data delivered from our decentralized feeder network! ## Learn More # Verifiable Randomness Source: https://www.diadata.org/docs/dia-stack/data-products/verifiable-randomness DIA xRandom provides smart contracts with unpredictable random numbers. ## xRandom Overview DIA xRandom leverages [drand](https://drand.love/)'s distributed randomness beacon, enabling verifiable, unpredictable and unbiased random numbers. Currently, the randomness is updated every 30 seconds and is expected to upgrade soon. The randomness oracle enables the creation of on-chain applications including but not limited to on-chain gaming, lotteries, prediction markets, and NFT launches​. Browse the latest randomness rounds in the DIA App: } /> ## Learn More # DIA Stack Overview Source: https://www.diadata.org/docs/dia-stack/overview DIA is a fully on-chain, trustless oracle architecture featuring permissionless access and modular design, powered by an Ethereum Layer-2 core. Developed by DIA, open for all. ## Introduction to DIA DIA's architecture focuses on maximizing decentralization and trustless execution. It is composed of state-of-the-art modular components that use Lasernet, DIA’s native Ethereum layer-2 rollup, as its core settlement layer for critical data operations such as computation and verification. DIA tackles traditional blockchain oracles' issues through its rollup-powered architecture: * Independent nodes fetch data directly from sources (CEXs, DEXs, more) * Data is submitted on-chain to DIA Lasernet – DIA's ETH L2 rollup * Processing and aggregation of data happen on-chain * Transactions are settled on-chain transparently ## Features Decentralized data sourcing by independent Feeder nodes, backed by staked assets. DIA’s first-party data sourcing capabilities one of its core benefit, enabling unlimited asset coverage. Seamless data transmission to any chain significantly reduces time to market and friction in the developer UX. Anyone can contribute to the system’s security or self-deploy and manage oracles contracts. From granular data sourcing to immutable processing trails, the stack ensures that everything is fully traceable. Data computation happens on-chain via smart contracts, enabling full verifiability of the end-to-end process. ## Data Flow: From Source to Feed DIA is composed of three main stages, each critical to ensuring the accuracy, reliability, and accessibility of your data. | Component | Description | Learn more | | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | **Feeders (Sourcing Layer)** | Collect real-time data from decentralized exchanges (DEXs), centralized exchanges (CEXs), and other sources through **Feeders**. Learn how our decentralized network of nodes ensures that your data is accurate, timely, and sourced directly from the market. | [Feeders](/dia-stack/architecture/core-components/feeders) | | **Lasernet (Aggregation Layer)** | Process and verify the collected data using **Pods** and **Aggregators** within the **LaserNet** infrastructure. Dive into how these components transform raw data into reliable and secure price feeds for your dApp. | [Lasernet](/dia-stack/architecture/core-components/lasernet/overview) | | **Spectra (Messaging Layer)** | Deliver processed data across multiple blockchains using **Spectra**, our industry-leading cross-chain messaging protocol. Discover how LaserNet makes it easy to integrate DIA’s oracle data into any blockchain environment. | [Spectra](/dia-stack/architecture/core-components/spectra) | For a breakdown of each process, read the [Architecture](/dia-stack/architecture/core-components/overview) section. # Overview Source: https://www.diadata.org/docs/guides/chain-guides-overview Chain-specific guides for accessing DIA oracle price feeds on each supported blockchain network. [Bring DIA Oracles to Your Blockchain Network](/guides/how-to-guides/request-a-custom-oracle) # Alephium Source: https://www.diadata.org/docs/guides/chain-specific-guide/alephium dApps built on Alephium can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. # Token Price Feeds ## Oracle details | Chain | Address | | ------- | -------------------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [285zrkZTPpUCpjKg9E3z238VmpUBQEAbESGsJT6yX7Rod](https://explorer.alephium.org/addresses/285zrkZTPpUCpjKg9E3z238VmpUBQEAbESGsJT6yX7Rod) | | Testnet | [216wgM3Xi5uBFYwwiw2T7iZoCy9vozPJ4XjToW74nQjbV](https://testnet.alephium.org/addresses/216wgM3Xi5uBFYwwiw2T7iZoCy9vozPJ4XjToW74nQjbV) | ## Oracle configuration | | | | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [VWAPIR](/guides/methodologies/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 0.2% and 120 seconds | | **Heartbeat** | 10mins | ## Asset feeds | Asset Ticker | getValue(key) | Asset Markets | | ------------ | ------------- | -------------------------------------------------------------------------------------------------------------- | | BTC | BTC/USD | [BTC markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | USDC | USDC/USD | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | ETH | ETH/USD | [ETH markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | WBTC | WBTC/USD | [WBTC markets](https://www.diadata.org/app/price/asset/Ethereum/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/) | | USDT | USDT/USD | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | ALPH | ALPH/USD | [ALPH markets](https://www.diadata.org/app/price/asset/Alephium/tgx7VNFoP9DJiFMFgXXtafQZkUvyEdDHT9ryamHJYrjq/) | | AYIN | AYIN/USD | [AYIN markets](https://www.diadata.org/app/price/asset/Alephium/vT49PY8ksoUL6NcXiZ1t2wAmC7tTPRfFfER8n3UCLvXy/) | ## How to access data Locate one of the deployed contracts (either testnet or mainnet) and call the `getValue` function. This function expects one parameter, which is the symbols of the asset you want to retrieve and a “/USD”, so for example for the Bitcoin price the parameter must be “BTC/USD”. This will return two values: 1. The price of the asset, with 8 decimals. 2. The timestamp of the last update in Unix time format, in UTC timezone. Below is the `DIAOracle` contract implementation in [Ralph](https://docs.alephium.org/ralph/): ```js theme={"system"} Contract DIAOracle( mut admin: Address ) extends DIAOracleBase(admin) implements IDIAOracle { mapping[ByteVec, DIAOracleValue] onchainValues event OracleUpdate(key: ByteVec, value: U256, timestamp: U256) const MaxBatchSize = 10 enum ErrorCodes { InvalidBatchSize = 1 InvalidKey = 2 } pub fn getValue(key: ByteVec) -> DIAOracleValue { if (!onchainValues.contains!(key)) { panic!(ErrorCodes.InvalidKey) } return onchainValues[key] } @using(preapprovedAssets = true) pub fn setValue(key: ByteVec, value: U256, timestamp: U256) -> () { checkAdmin(callerAddress!()) updateValue{admin -> ALPH: mapEntryDeposit!()}(key, value, timestamp) } @using(preapprovedAssets = true) pub fn setMultipleValues( keys: [ByteVec; 10], values: [U256; 10], timestamps: [U256; 10], batchSize: U256 ) -> () { checkAdmin(callerAddress!()) assert!(batchSize <= MaxBatchSize, ErrorCodes.InvalidBatchSize) for (let mut i = 0; i < batchSize; i = i + 1) { updateValue{admin -> ALPH: mapEntryDeposit!()}( keys[i], values[i], timestamps[i] ) } } @using(preapprovedAssets = true) fn updateValue(key: ByteVec, value: U256, timestamp: U256) -> () { if (!onchainValues.contains!(key)) { onchainValues.insert!(admin, key, DIAOracleValue{value, timestamp}) } else { onchainValues[key] = DIAOracleValue{value, timestamp} } emit OracleUpdate(key, value, timestamp) } } ``` *** # Verifiable Randomness ## Oracle details | Chain | Address | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------- | | Alephium Mainnet | [v1v4cBXP9L7M9ryZZCx7tuXuNb9pnDLGb3JJkPBpbR1Z](https://explorer.alephium.org/addresses/v1v4cBXP9L7M9ryZZCx7tuXuNb9pnDLGb3JJkPBpbR1Z) | | Alephium Testnet | [217k7FMPgahEQWCfSA1BN5TaxPsFovjPagpujkyxKDvS3](https://testnet.alephium.org/addresses/217k7FMPgahEQWCfSA1BN5TaxPsFovjPagpujkyxKDvS3) | ## Oracle configuration The oracle uses [drand](https://drand.love/) randomness from the quicknet mainnet to provide randomness on Alephium. ## How to access data To consume randomness data, you'll need to invoke the `getLastRound` method on the oracle contract. It will return the round ID of the latest update. Using this round ID, you can call `getRandomValue` and will receive a return value of that randomness, the round ID and the BLS signature from the drand API. Note that round IDs are used round-robin and will repeat after 1000 iterations. Below is the `DIARandomOracle` contract implementation in [Ralph](https://docs.alephium.org/ralph/): ```js theme={"system"} Contract DIARandomOracle( mut admin: Address, mut lastRound: U256 ) extends DIAOracleBase(admin) implements IDIARandomOracle { mapping[U256, DIARandomValue] randomValues event OracleUpdate( round: U256, randomness: ByteVec, signature: ByteVec ) const MaxSlot = 1000 enum ErrorCodes { InvalidRound = 1 RoundKeyNotExist = 2 RoundIsExpired = 3 } pub fn getLastRound() -> U256 { return lastRound } pub fn getRandomValue(realRound: U256) -> DIARandomValue { let roundKey = realRound % MaxSlot assert!(randomValues.contains!(roundKey), ErrorCodes.RoundKeyNotExist) let randomValue = randomValues[roundKey] assert!(randomValue.round == realRound, ErrorCodes.RoundIsExpired) return randomValue } @using(preapprovedAssets = true, updateFields = true) pub fn setRandomValue(value: DIARandomValue) -> () { checkAdmin(callerAddress!()) assert!(value.round > lastRound, ErrorCodes.InvalidRound) let roundKey = value.round % MaxSlot lastRound = value.round if (randomValues.contains!(roundKey)) { randomValues[roundKey] = value } else { randomValues.insert!(admin, roundKey, value) } emit OracleUpdate(value.round, value.randomness, value.signature) } } ``` You can learn more [here](/dia-stack/data-products/verifiable-randomness). *** ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Alephium. Learn more about the grant here: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Arbitrum Source: https://www.diadata.org/docs/guides/chain-specific-guide/arbitrum dApps built on Arbitrum can leverage DIA oracles to access up-to-date asset price information. Explore these demo oracles to see how DIA works. For production deployments, [request a custom oracle](#request-a-custom-oracle) and unlock the full power of tailored data feeds for your dApp. ## Demo Oracles Demo oracles are available for testing the new fully verifiable & decentralized [Lumina stack](/dia-stack/overview) on Arbitrum Mainnet & Testnet: #### Oracle Contracts ##### Mainnet | Chain | Oracle Type | Address | | ------- | ----------- | -------------------------------------------------------------------------------------------------------------------- | | Mainnet | Push Oracle | [0xA42217338614B7e67D022C52D1CD38e02D619bb0](https://arbiscan.io/address/0xa42217338614b7e67d022c52d1cd38e02d619bb0) | ##### Testnet | Chain | Oracle Type | Address | | ------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------- | | Sepolia | Push Oracle | [0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0](https://sepolia.arbiscan.io/address/0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0) | #### Oracle Configuration | | | | ------------------------------------- | ------------------ | | **Pricing Methodology** | Median | | **Deviation (%) & Refresh Frequency** | 2% and 120 seconds | | **Heartbeat** | 12h | #### Available Asset Feeds | Asset Ticker | updates(key) | Asset Markets | | :----------- | :----------- | :----------------------------------------------------------------------------------------------------------- | | ETH | ETH/USD | [ETH Markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | BTC | BTC/USD | [BTC Markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | DIA | DIA/USD | [DIA Markets](https://www.diadata.org/app/price/asset/Ethereum/0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419/) | | USDC | USDC/USD | [USDC Markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | #### Oracle Contracts #### Mainnet | Chain | Oracle Type | Address | | ------- | ----------- | -------------------------------------------------------------------------------------------------------------------- | | Mainnet | Push Oracle | [0xEB3b12FB37090ACc6773B59619799941536FA198](https://arbiscan.io/address/0xEB3b12FB37090ACc6773B59619799941536FA198) | ### Oracle Configuration | | | | ------------------------------------- | ------------------ | | **Pricing Methodology** | Median | | **Deviation (%) & Refresh Frequency** | 1% and 120 seconds | | **Heartbeat** | 24h | #### Available Asset Feeds * APPL * XAU/USD * USD/EUR *** ## How to Access Data To consume price data, use the [`updates` method](/guides/how-to-guides/fetch-price-data/push-based-oracles) for Push-based oracles. The price updates are stored in both methods in an `updates` mapping. When accessing the `updates` mapping through the key `BTC/USD`, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. Below is a sample contract that consumes the `BTC/USD` price feed: ### updates Method ```solidity theme={"system"} pragma solidity ^0.8.13; import { PushOracleReceiver } from "@dia-data/contracts-spectra/PushOracleReceiver.sol"; contract DIAOracleSample { PushOracleReceiver public diaOracle; string public key = "BTC/USD"; constructor(address _oracle) { diaOracle = PushOracleReceiver(payable(_oracle)); } function getPrice() external view returns ( uint128 timestampOflatestPrice, uint128 latestPrice ) { (timestampOflatestPrice, latestPrice) = diaOracle.updates(key); } } ``` ## Additional Details You can find the contract addresses for the Arbitrum bridge's components on mainnet and testnet below: * [MailBox Contract](https://arbiscan.io/address/0x979ca5202784112f4738403dbec5d0f3b9daabb9) * [ISM Contract](https://arbiscan.io/address/0x92f0f4c9f769ed83609cd2ccd1acce224bbc8cbf) * [Protocol Fee Hook Contract](https://arbiscan.io/address/0x048050547eb6e68cB37Fb21EEafEad40CF2CbdbB) * [MailBox Contract](https://sepolia.arbiscan.io/address/0x598face78a4302f11e3de0bee1894da0b2cb71f8) * [ISM Contract](https://sepolia.arbiscan.io/address/0xb869617a3CFcdA07A4cC230d996120074e7c817e) * [Protocol Fee Hook Contract](https://sepolia.arbiscan.io/address/0x611c8b288c642336136a436d7125ac49fa71468b) Learn more about DIA's cross-chain messaging layer [here](/dia-stack/architecture/core-components/spectra). *** ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Arbitrum. Learn more about the grant here: *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Astar Source: https://www.diadata.org/docs/guides/chain-specific-guide/astar dApps built on Astar can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Aurora Source: https://www.diadata.org/docs/guides/chain-specific-guide/aurora dApps built on Aurora can leverage DIA oracles to access up-to-date asset price information. Explore these demo oracles to see how DIA works. For production deployments, [request a custom oracle](#request-a-custom-oracle) and unlock the full power of tailored data feeds for your dApp. ## Demo Oracles ### Oracle Contracts | Chain | Address | | ------- | ------------------------------------------------------------------------------------------------------------------------------------ | | Mainnet | [0xf4e9C0697c6B35fbDe5a17DB93196Afd7aDFe84f](https://explorer.aurora.dev/address/0xf4e9C0697c6B35fbDe5a17DB93196Afd7aDFe84f) | | Testnet | [0xf4e9C0697c6B35fbDe5a17DB93196Afd7aDFe84f](https://explorer.testnet.aurora.dev/address/0xf4e9C0697c6B35fbDe5a17DB93196Afd7aDFe84f) | ### Oracle Configuration | | | | ------------------------------------- | ------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [MAIR](/guides/methodologies/pricing-methodologies/mair-moving-average-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 0.5% and 120 seconds | | **Heartbeat** | 30 minutes | ### Available Asset Feeds | Asset Ticker | getValue(key) | Asset Markets | | ------------ | ------------- | ------------------------------------------------------------------------------------------------------------ | | BTC | BTC/USD | [BTC markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | USDC | USDC/USD | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | DIA | DIA/USD | [DIA markets](https://www.diadata.org/app/price/asset/Ethereum/0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419/) | *** ## How to Access Data ### getValue Method To consume price data, you'll need to invoke the [`getValue` method](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from our oracle on Aurora mainnet. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ```solidity theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleV2Consumer{ address immutable ORACLE = 0xf4e9C0697c6B35fbDe5a17DB93196Afd7aDFe84f; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` See the full example [here](/guides/how-to-guides/fetch-price-data/solidity). *** ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Aurora. Learn more about the grant here: *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Avalanche Source: https://www.diadata.org/docs/guides/chain-specific-guide/avalanche dApps built on Avalanche can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Avalanche. Learn more about the grant here: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Base Source: https://www.diadata.org/docs/guides/chain-specific-guide/base dApps built on Base can leverage DIA oracles to access up-to-date asset price information. Explore these demo oracles to see how DIA works. For production deployments, [request a custom oracle](#request-a-custom-oracle) and unlock the full power of tailored data feeds for your dApp. ## Demo Oracles ### Oracle Contracts #### Mainnet | Contract | Address | | ----------- | --------------------------------------------------------------------------------------------------------------------- | | Push Oracle | [0xA42217338614B7e67D022C52D1CD38e02D619bb0](https://basescan.org/address/0xa42217338614b7e67d022c52d1cd38e02d619bb0) | #### Testnet | Contract | Address | | ----------- | ----------------------------------------------------------------------------------------------------------------------------- | | Push Oracle | [0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0](https://sepolia.basescan.org/address/0x9bb71344ed950f9cfd85ee1c7258553b01d95fa0) | ### Oracle Configuration | | | | ------------------------------------- | ------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [MAIR](/guides/methodologies/pricing-methodologies/mair-moving-average-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 2% and 120 seconds | | **Heartbeat** | 12h | ### Available Asset Feeds | Asset Ticker | updates(key) | Asset Markets | | :----------- | :----------- | :----------------------------------------------------------------------------------------------------------- | | ETH | ETH/USD | [ETH Markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | BTC | BTC/USD | [BTC Markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | DIA | DIA/USD | [DIA Markets](https://www.diadata.org/app/price/asset/Ethereum/0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419/) | | USDC | USDC/USD | [USDC Markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | *** ## How to Access Data To consume price data, use the [`updates` method](/guides/how-to-guides/fetch-price-data/push-based-oracles) for Push-based oracles. The price updates are stored in both methods in an `updates` mapping. When accessing the `updates` mapping through the key `BTC/USD`, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. Below is a sample contract that consumes the `BTC/USD` price feed: ### updates Method ```solidity theme={"system"} pragma solidity ^0.8.13; import { PushOracleReceiver } from "@dia-data/contracts-spectra/PushOracleReceiver.sol"; contract DIAOracleSample { PushOracleReceiver public diaOracle; string public key = "BTC/USD"; constructor(address _oracle) { diaOracle = PushOracleReceiver(payable(_oracle)); } function getPrice() external view returns ( uint128 timestampOflatestPrice, uint128 latestPrice ) { (timestampOflatestPrice, latestPrice) = diaOracle.updates(key); } } ``` ## Additional Details You can find the contract addresses for the Base bridge's components on mainnet and testnet below: * [MailBox Contract](https://arbiscan.io/address/0x979ca5202784112f4738403dbec5d0f3b9daabb9) * [ISM Contract](https://arbiscan.io/address/0x92f0f4c9f769ed83609cd2ccd1acce224bbc8cbf) * [Protocol Fee Hook Contract](https://arbiscan.io/address/0x048050547eb6e68cB37Fb21EEafEad40CF2CbdbB) * [MailBox Contract](https://sepolia.basescan.org/address/0x6966b0e55883d49bfb24539356a2f8a673e02039) * [ISM Contract](https://sepolia.basescan.org/address/0xb869617a3cfcda07a4cc230d996120074e7c817e) * [Protocol Fee Hook Contract](https://sepolia.basescan.org/address/0x611C8b288c642336136a436d7125AC49FA71468B) Learn more about DIA's cross-chain messaging layer [here](/dia-stack/architecture/core-components/spectra). *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # GEB Network Source: https://www.diadata.org/docs/guides/chain-specific-guide/bevm dApps built on GEB Network can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on BNB Chain. Learn more about the grant here: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # BNB Chain Source: https://www.diadata.org/docs/guides/chain-specific-guide/bnb-chain dApps built on BNB Chain can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on BNB Chain. Learn more about the grant here: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # BOB Build on Bitcoin Source: https://www.diadata.org/docs/guides/chain-specific-guide/bob-build-on-bitcoin dApps built on BOB Build on Bitcoin can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on BOB Build on Bitcoin. Learn more about the grant here: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Boba Network Source: https://www.diadata.org/docs/guides/chain-specific-guide/boba-network dApps built on Boba Network can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Celo Source: https://www.diadata.org/docs/guides/chain-specific-guide/celo dApps built on Celo can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Clover Source: https://www.diadata.org/docs/guides/chain-specific-guide/clover dApps built on Clover can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # CrossFi Source: https://www.diadata.org/docs/guides/chain-specific-guide/crossfi dApps built on CrossFi can leverage DIA oracles to access up-to-date asset price information. # Token Price Feeds ## Oracle Details | Chain | Address | | ------- | ------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [0x859e221ada7cebdf5d4040bf6a2b8959c05a4233](https://xfiscan.com/address/0x859e221ada7cebdf5d4040bf6a2b8959c05a4233) | | Testnet | [0x33df80cdf0c9ff686261b11263d9f4a3ccc3d07f](https://test.xfiscan.com/address/0x33df80cdf0c9ff686261b11263d9f4a3ccc3d07f) | ## Oracle Configuration | | | | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [VWAPIR](/guides/methodologies/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 0.5% and 120 seconds | | **Heartbeat** | 24h | ## Available Asset Feeds ### Mainnet | Asset Ticker | getValue(key) | Asset Markets | | ------------ | ------------- | ------------------------------------------------------------------------------------------------------------ | | USDT | USDT/USD | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | USDC | USDC/USD | [USDC Markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | XFI | XFI/USD | [XFI Markets](https://www.diadata.org/app/price/asset/Ethereum/0xC8CeED65E236F7d6fB378b8715f9e6912e486A54/) | ### Testnet | Asset Ticker | getValue(key) | Asset Markets | | :----------- | :------------ | :-------------------------------------------------------------------------------------------------------------------- | | WETH | WETH/USD | [WETH Markets](https://www.diadata.org/app/price/asset/Ethereum/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/) | | WBTC | WBTC/USD | [WBTC Markets](https://www.diadata.org/app/price/asset/Ethereum/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/) | | USDT | USDT/USD | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | DAI | DAI/USD | [DAI Markets](https://www.diadata.org/app/price/asset/Ethereum/0x6B175474E89094C44Da98b954EedeAC495271d0F/) | | USDC | USDC/USD | [USDC Markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | FRAX | FRAX/USD | [FRAX Markets](https://www.diadata.org/app/price/asset/Ethereum/0x853d955aCEf822Db058eb8505911ED77F175b99e/) | | LINK | LINK/USD | [LINK Markets](https://www.diadata.org/app/price/asset/Ethereum/0x514910771AF9Ca656af840dff83E8264EcF986CA/) | | WBNB | WBNB/USD | [WBNB Markets](https://www.diadata.org/app/price/asset/BinanceSmartChain/0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c/) | | EUR | EUR/USD | [EUR Markets](https://www.diadata.org/app/price/asset/Fiat/978/) | | XFI | XFI/USD | [XFI Markets](https://www.diadata.org/app/price/asset/Ethereum/0xC8CeED65E236F7d6fB378b8715f9e6912e486A54/) | ## How to Access Data ### getValue Method To consume price data, you’ll need to invoke the [`getValue` method](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from our oracle on CrossFi Testnet. If you pass `WBTC/USD` as the key, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ```solidity theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleV2Consumer{ address immutable ORACLE = 0x859e221ada7cebdf5d4040bf6a2b8959c05a4233; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` *** # Verifiable Randomness ### Oracle Details | Chain | Address | | ------- | ------------------------------------------------------------------------------------------------------------------------- | | Testnet | [0xad19b5b3a0bf2bacf028ed6cc9e3fc153cb405b6](https://test.xfiscan.com/address/0xad19b5b3a0bf2bacf028ed6cc9e3fc153cb405b6) | ### Oracle Configuration The oracle uses [drand](https://drand.love/) randomness from quicknet to provide randomness on CrossFi. ### How to Access Data To consume randomness data, you'll need to invoke the `getLastRound` method on the oracle contract. It will return the round ID of the latest update. Using this round ID, you can call `getRandomValue` and will receive a return value of that randomness, the round ID and the BLS signature from the drand API. Note that round IDs are used round-robin and will repeat after 1000 iterations. Refer to the [Solidity guide](/guides/how-to-guides/generate-randomness/solidity) for detailed steps on fetching random values from the oracle in your contract. You can learn more about the randomness protocol [here](/dia-stack/data-products/verifiable-randomness). *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Edu Chain Source: https://www.diadata.org/docs/guides/chain-specific-guide/edu-chain dApps built on EduChain can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## Oracle Details | Chain | Address | | ------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [0x56BddAc934157c213c37864e3443E5196b47a1d1](https://educhain.blockscout.com/address/0x56BddAc934157c213c37864e3443E5196b47a1d1) | | Testnet | [0x6626f442ebc679f7e35bc62e36e3c1e8820c81c9](https://edu-chain-testnet.blockscout.com/address/0x6626f442eBc679f7e35bC62E36E3c1e8820C81C9) | ## Oracle Configuration | | | | ------------------------------------- | ------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [MAIR](/guides/methodologies/pricing-methodologies/mair-moving-average-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 0.5% and 120 seconds | | **Heartbeat** | 24h | ## Available Asset Feeds | Asset Ticker | getValue(key) | Asset Markets | | ------------ | ------------- | -------------------------------------------------------------------------------------------------------------------- | | EDU | EDU/USD | [EDU markets](https://www.diadata.org/app/price/asset/BinanceSmartChain/0xBdEAe1cA48894A1759A8374D63925f21f2Ee2639/) | | ETH | ETH/USD | [ETH markets](http://diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | WBTC | WBTC/USD | [WBTC markets](https://www.diadata.org/app/price/asset/Ethereum/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/) | | USDC | USDC/USD | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | USDT | USDT/USD | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | DAI | DAI/USD | [DAI markets](https://www.diadata.org/app/price/asset/Ethereum/0x6B175474E89094C44Da98b954EedeAC495271d0F/) | | ARB | ARB/USD | [ARB markets](https://www.diadata.org/app/price/asset/Arbitrum/0x912CE59144191C1204E64559FE8253a0e49E6548/) | | wstETH | wstETH/USD | [wstETH markets](https://www.diadata.org/app/price/asset/Ethereum/0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0/) | | GRAIL | GRAIL/USD | [GRAIL markets](https://www.diadata.org/app/price/asset/Arbitrum/0x3d9907F9a368ad0a51Be60f7Da3b97cf940982D8/) | *** ## How to Access Data ### getValue Method To consume price data, you’ll need to invoke the `getValue` method on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#access-the-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from the oracle on EduChain testnet using the **IDIAOracleV2** interface. If you pass `WBTC/USD` as the key, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 8258705325665 is \$82,587.05325665) along with the Unix timestamp of the last price update. ```js theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleV2Consumer { address immutable ORACLE = 0x6626f442ebc679f7e35bc62e36e3c1e8820c81c9; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` See the full example [here](/guides/how-to-guides/fetch-price-data/solidity). *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Ethereum Source: https://www.diadata.org/docs/guides/chain-specific-guide/ethereum dApps built on Ethereum can leverage DIA oracles to access up-to-date asset price information. Explore these demo oracles to see how DIA works. For production deployments, [request a custom oracle](#request-a-custom-oracle) and unlock the full power of tailored data feeds for your dApp. ## Demo Oracles ### Oracle Contracts #### Testnet | Contract | Address | | ----------- | ----------------------------------------------------------------------------------------------------------------------------- | | Push Oracle | [0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0](https://sepolia.etherscan.io/address/0x9bb71344ed950f9cfd85ee1c7258553b01d95fa0) | ### Oracle Configuration | | | | ------------------------------------- | ------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [MAIR](/guides/methodologies/pricing-methodologies/mair-moving-average-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 2% and 120 seconds | | **Heartbeat** | 12h | ### Available Asset Feeds | Asset Ticker | updates(key) | Asset Markets | | :----------- | :----------- | :----------------------------------------------------------------------------------------------------------- | | ETH | ETH/USD | [ETH Markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | BTC | BTC/USD | [BTC Markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | DIA | DIA/USD | [DIA Markets](https://www.diadata.org/app/price/asset/Ethereum/0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419/) | | USDC | USDC/USD | [USDC Markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | *** ## How to Access Data To consume price data, use the [`updates` method](/guides/how-to-guides/fetch-price-data/push-based-oracles) for Push-based oracles. The price updates are stored in both methods in an `updates` mapping. When accessing the `updates` mapping through the key `BTC/USD`, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. Below is a sample contract that consumes the `BTC/USD` price feed: ### updates Method ```solidity theme={"system"} pragma solidity ^0.8.13; import { PushOracleReceiver } from "@dia-data/contracts-spectra/PushOracleReceiver.sol"; contract DIAOracleSample { PushOracleReceiver public diaOracle; string public key = "BTC/USD"; constructor(address _oracle) { diaOracle = PushOracleReceiver(payable(_oracle)); } function getPrice() external view returns ( uint128 timestampOflatestPrice, uint128 latestPrice ) { (timestampOflatestPrice, latestPrice) = diaOracle.updates(key); } } ``` ## Additional Details You can find the contract addresses for the Ethereum bridge's components on testnet below: * [MailBox Contract](https://sepolia.etherscan.io/address/0xffaef09b3cd11d9b20d1a19becca54eec2884766) * [ISM Contract](https://sepolia.etherscan.io/address/0xb869617a3cfcda07a4cc230d996120074e7c817e) * [Protocol Fee Hook Contract](https://sepolia.etherscan.io/address/0x611c8b288c642336136a436d7125ac49fa71468b) Learn more about DIA's cross-chain messaging layer [here](/dia-stack/architecture/core-components/spectra). *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # ETHPar Source: https://www.diadata.org/docs/guides/chain-specific-guide/ethpar dApps built on ETHPar can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## Oracle Details | Chain | Address | | ------- | ------------------------------------------------------------------------------------------------------------------------ | | Mainnet | [0xA3014376A788b55450c5C1F2bA2A8694a79f0b97](https://dora.ethpar.net/address/0xA3014376A788b55450c5C1F2bA2A8694a79f0b97) | ## Oracle Configuration | | | | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [VWAPIR](/guides/methodologies/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 0.5% and 120 seconds | | **Heartbeat** | 24h | ## Available Asset Feeds | Asset Ticker | getValue(key) | Asset Markets | | ------------ | ------------- | ------------------------------------------------------------------------------------------------------------ | | WBTC | WBTC/USD | [WBTC Markets](https://www.diadata.org/app/price/asset/Ethereum/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/) | | WETH | WETH/USD | [WETH Markets](https://www.diadata.org/app/price/asset/Ethereum/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/) | *** ## How to Access Data ### getValue Method To consume price data, you’ll need to invoke the [`getValue` method](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from our oracle on ETHPar mainnet. If you pass `WBTC/USD` as the key, it will return the most recent price of WBTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ```solidity theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleV2Consumer{ address immutable ORACLE = 0xA3014376A788b55450c5C1F2bA2A8694a79f0b97; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` See the full example [here](/guides/how-to-guides/fetch-price-data/solidity). *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Evmos Source: https://www.diadata.org/docs/guides/chain-specific-guide/evmos dApps built on Evmos can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Fantom Source: https://www.diadata.org/docs/guides/chain-specific-guide/fantom dApps built on Fantom can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Fuse Source: https://www.diadata.org/docs/guides/chain-specific-guide/fuse dApps built on Fuse can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Gnosis Chain Source: https://www.diadata.org/docs/guides/chain-specific-guide/gnosis-chain dApps built on Gnosis Chain can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # GOAT Network Source: https://www.diadata.org/docs/guides/chain-specific-guide/goat-network dApps built on GOAT Network can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## Oracle Details | Chain | Address | | :----------------- | :----------------------------------------------------------------------------------------------------------------------------- | | GOAT Alpha Mainnet | [0x458DAfFcB1507835AAB0C8F2722d1196E9a4fFaB](https://explorer.goat.network/address/0x458DAfFcB1507835AAB0C8F2722d1196E9a4fFaB) | ## Oracle Configuration | Parameter | Value | | :-------------------------------- | :------------------------------------------------------------------------------------------------------------------------- | | Pricing Methodology | [VWAPIR](/guides/methodologies/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter) | | Deviation (%) & Refresh Frequency | 0.5% and 120 seconds | | Heartbeat | 24h | ## Available Asset Feeds ### Mainnet | Asset Ticker | getValue(**key**) | Asset Markets | | :----------- | :---------------- | :------------------------------------------------------------------------------------------------------------ | | BTC | BTC/USD | [BTC Markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | USDT | USDT/USD | [USDT Markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | USDC | USDC/USD | [USDC Markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | ETH | ETH/USD | [ETH Markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | DOGE | DOGE/USD | [DOGE Markets](https://www.diadata.org/app/price/asset/Dogechain/0x0000000000000000000000000000000000000000/) | *** ## How to Access Data ### getValue Method To consume price data, you'll need to invoke the [`getValue` method](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from our oracle on GOAT Network mainnet. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ```solidity theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleV2Consumer{ address immutable ORACLE = 0x458DAfFcB1507835AAB0C8F2722d1196E9a4fFaB; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` See the full example [here](/guides/how-to-guides/fetch-price-data/solidity). *** ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on GOAT Network. Learn more about the grant here: *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Hydration Source: https://www.diadata.org/docs/guides/chain-specific-guide/hydration dApps built on Hydration can leverage DIA oracles to access up-to-date asset price information. ## Oracle Details ### WBTC, DOT, USDT and USDC oracle | Chain | Address | | ------- | ------------------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [0xdee629af973ebf5bf261ace12ffd1900ac715f5e](https://explorer.evm.hydration.cloud/address/0xdEe629af973ebF5bf261aCe12ffD1900ac715f5e) | | Testnet | [0xc756bd338a97c1d2faab4f13b5444a08a1566917](https://explorer.evm.hydration.cloud/address/0xc756bd338a97c1d2faab4f13b5444a08a1566917) | ### tBTC, Aave, ETH, wstETH, sUSDs, & sUSDe oracle | Chain | Address | | ------- | ------------------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [0x48ae7803cd09c48434e3fc5629f15fb76f0b5ce5](https://explorer.evm.hydration.cloud/address/0x48Ae7803Cd09c48434E3FC5629F15fb76f0b5cE5) | | Testnet | [0x5d8320f3ced9575d8e25b6f437e610fc6a03bf52](https://explorer.evm.hydration.cloud/address/0x5d8320f3ced9575d8e25b6f437e610fc6a03bf52) | ## Oracle Configuration | | | | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [VWAPIR](/guides/methodologies/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 0.5% and 120 seconds | | **Heartbeat** | 24h | ## Available Asset Feeds ### Mainnet | Asset Ticker | Adapter Address | Asset Markets | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | WBTC | [0xeDD9A7C47A9F91a0F2db93978A88844167B4a04f](https://explorer.evm.hydration.cloud/address/0xeDD9A7C47A9F91a0F2db93978A88844167B4a04f) | [WBTC markets](https://www.diadata.org/app/price/asset/Ethereum/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/) | | DOT | [0xFBCa0A6dC5B74C042DF23025D99ef0F1fcAC6702](https://explorer.evm.hydration.cloud/address/0xFBCa0A6dC5B74C042DF23025D99ef0F1fcAC6702) | [DOT markets](https://www.diadata.org/app/price/asset/Polkadot/0x0000000000000000000000000000000000000000/) | | USDT | [0x8b0DDfB8F56690eAde9ECa23a7d90E153C268d5B](https://explorer.evm.hydration.cloud/address/0x8b0DDfB8F56690eAde9ECa23a7d90E153C268d5B) | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | USDC | [0x17711BE5D63B2Fe8A2C379725DE720773158b954](https://explorer.evm.hydration.cloud/address/0x17711BE5D63B2Fe8A2C379725DE720773158b954) | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | tBTC | [0xe5AcDfB0d5EC5cE34F7448B41ef4a97c4e83D9c1](https://explorer.evm.hydration.cloud/address/0xe5AcDfB0d5EC5cE34F7448B41ef4a97c4e83D9c1) | [tBTC markets](https://www.diadata.org/app/price/asset/Ethereum/0x18084fbA666a33d37592fA2633fD49a74DD93a88/) | | Aave | [0x9E85d33FD87342762710FB4a1471df1Dc7bb5f8C](https://explorer.evm.hydration.cloud/address/0x9E85d33FD87342762710FB4a1471df1Dc7bb5f8C) | [Aave markets](https://www.diadata.org/app/price/asset/Ethereum/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/) | | ETH | [0x1AF549Fe19A9B73D094173C41e18BF7F357F594b](https://explorer.evm.hydration.cloud/address/0x1AF549Fe19A9B73D094173C41e18BF7F357F594b) | [ETH markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | wstETH | [0x52bBB0BC38C42D60b24EBF0C617E8218D2aB6d36](https://explorer.evm.hydration.cloud/address/0x52bBB0BC38C42D60b24EBF0C617E8218D2aB6d36) | [wstETH markets](https://www.diadata.org/app/price/asset/Ethereum/0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0/) | | sUSDs | [0x4b32bfFC6aCD751446E79e8687ef3815fD7924FD](https://explorer.evm.hydration.cloud/address/0x4b32bfFC6aCD751446E79e8687ef3815fD7924FD) | [sUSDs markets](https://www.diadata.org/app/price/asset/Ethereum/0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD/) | | sUSDe | [0x22CDEa305Cee63D082E79F8C5Db939EEcD0265D0](https://explorer.evm.hydration.cloud/address/0x22CDEa305Cee63D082E79F8C5Db939EEcD0265D0) | [sUSDe markets](https://www.diadata.org/app/price/asset/Ethereum/0x9D39A5DE30e57443BfF2A8307A4256c8797A3497/) | ### Testnet | Asset Ticker | Adapter Address | Asset Markets | | ------------ | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | | WBTC | 0xC9cCBe99bdD9538871f9756Ca5Ea64C2267cb0a7 | [WBTC markets](https://www.diadata.org/app/price/asset/Ethereum/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/) | | DOT | 0x422E745797EC0Ef399c17cE3E2348394F2944727 | [DOT markets](https://www.diadata.org/app/price/asset/Polkadot/0x0000000000000000000000000000000000000000/) | | USDT | 0xb4aC9f0E6E207D5d81B756F8aF6efe3fe7B0E72c | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | USDC | 0xEE7aFb45c094DC9fA404D6A86A7d795d4aA33D28 | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | tBTC | 0x9f7abE73e656DB45F56B1d3755940CB3fc82Fcaa | [tBTC markets](https://www.diadata.org/app/price/asset/Ethereum/0x18084fbA666a33d37592fA2633fD49a74DD93a88/) | | Aave | 0xC9E1415Eb64281aD449f50C454873d92F312d6fE | [Aave markets](https://www.diadata.org/app/price/asset/Ethereum/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/) | *** ## How to Access Data ### getValue Method To consume price data, you’ll need to invoke the `getValue` method on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from the oracle on Hydration testnet using the IDIAOracleV2 interface. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ```js theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleV2Consumer{ address immutable ORACLE = 0xc756bd338a97c1d2faab4f13b5444a08a1566917; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` See the full example [here](/guides/how-to-guides/fetch-price-data/solidity). ### Adapter Contracts To consume price data from our oracle, you can use the adapter smart contract located at the [adapter address](/guides/chain-specific-guide/hydration#asset-feeds) for each asset. This will allow you to access the same methods on the `AggregatorV3Interface` such as `getRoundData` & `latestRoundData`. You can learn more [here](/guides/how-to-guides/migrate-to-dia). This is a sample contract for consuming the `WBTC/USD` price feed on Hydration mainnet: ```solidity theme={"system"} // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface DiaAssetSpecificCallingConvention { function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } contract DIAOracleSample { address wbtcAdapter = 0xeDD9A7C47A9F91a0F2db93978A88844167B4a04f; function getWBTCLatestPrice() external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { // Call the Chainlink adapter's latestRoundData function (, int256 answer, , uint256 updatedAt, ) = DiaAssetSpecificCallingConvention(wbtcAdapter).latestRoundData(); latestPrice = uint128(uint256(answer)); timestampOflatestPrice = uint128(updatedAt); return (latestPrice, timestampOflatestPrice); } } ``` *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Kadena Source: https://www.diadata.org/docs/guides/chain-specific-guide/kadena dApps built on Kadena can leverage DIA oracles to access up-to-date asset price information. DIA Oracles on Kadena are open source, and their source code is available in [this repository](https://github.com/diadata-org/dia-kadena-oracles). dApps built on Kadena can leverage DIA oracles to access up-to-date asset price information. These deployed oracles are designed for production environments and come with a predefined list of supported assets and settings. If dApps require a custom oracle with different assets and configurations, please [contact DIA on Telegram](https://t.me/DIAOracles_Support_Bot). ## Oracle Details As Kadena allows for several chains in parallel, it is important to retrieve the price from the correct chain. Currently, DIA oracles are deployed on these chains: | Network ID | Chain ID | DIA Contract Identifier | | ---------- | -------- | ------------------------------------------------------- | | mainnet01 | 1 | `n_bfb76eab37bf8c84359d6552a1d96a309e030b71.dia-oracle` | | mainnet01 | 2 | `n_bfb76eab37bf8c84359d6552a1d96a309e030b71.dia-oracle` | | mainnet01 | 4 | `n_bfb76eab37bf8c84359d6552a1d96a309e030b71.dia-oracle` | | testnet04 | 4 | `n_bfb76eab37bf8c84359d6552a1d96a309e030b71.dia-oracle` | ### Chainweb EVM Testnet 20 | Network ID | Chain ID | DIA Contract Address | | ---------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | chain20 | 5920 | [`0x2e034f073ee95db83b5498b90a53dd9b26525355`](https://chain-20.evm-testnet-blockscout.chainweb.com/address/0x2E034F073eE95Db83B5498B90a53DD9B26525355) | ## Oracle Configuration | Parameter | Value | | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | Pricing Methodology | [VWAPIR](/guides/methodologies/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter) | | Deviation (%) & Refresh Frequency | 0.5% and 120 seconds | | Heartbeat | 24h | ## Asset Feeds The Kadena oracle includes the following price feeds. Use the Query Symbol as a parameter in the `get-value` (or `getValue` for chainweb EVM) function to receive the latest price information for any of these assets. | Asset | Query Symbol | Sources Overview | | ---------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------- | | Bitcoin (BTC) | BTC/USD | [BTC Sources](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | USD Coin (USDC) | USDC/USD | [USDC Sources](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | Staked ETH (stETH) | STETH/USD | [stETH Sources](https://www.diadata.org/app/price/asset/Ethereum/0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84/) | | Ether (ETH) | ETH/USD | [ETH Sources](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | Wrapped Bitcoin (WBTC) | WBTC/USD | [WBTC Sources](https://www.diadata.org/app/price/asset/Ethereum/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/) | | Moonbeam (GLMR) | GLMR/USD | [GLMR Sources](https://www.diadata.org/app/price/asset/Moonbeam/0x0000000000000000000000000000000000000000/) | | Optimism (OP) | OP/USD | [OP Sources](https://www.diadata.org/app/price/asset/Optimism/0x4200000000000000000000000000000000000042/) | | DIA Token (DIA) | DIA/USD | [DIA Sources](https://www.diadata.org/app/price/asset/Ethereum/0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419/) | | Arbitrum (ARB) | ARB/USD | [ARB Sources](https://www.diadata.org/app/price/asset/Arbitrum/0x912CE59144191C1204E64559FE8253a0e49E6548/) | | Binance Coin (BNB) | BNB/USD | [BNB Sources](https://www.diadata.org/app/price/asset/BinanceSmartChain/0x0000000000000000000000000000000000000000/) | | Avalanche (AVAX) | AVAX/USD | [AVAX Sources](https://www.diadata.org/app/price/asset/Avalanche/0x0000000000000000000000000000000000000000/) | | Celo Dollar (CUSD) | CUSD/USD | [CUSD Sources](https://www.diadata.org/app/price/asset/Celo/0x765DE816845861e75A25fCA122bb6898B8B1282a/) | | Kadena (KDA) | KDA/USD | [KDA Sources](https://www.diadata.org/app/price/asset/Kadena/0x0000000000000000000000000000000000000000/) | | Gnosis (GNO) | GNO/USD | [GNO Sources](https://www.diadata.org/app/price/asset/Ethereum/0x6810e776880C02933D47DB1b9fc05908e5386b96/) | | Wrapped Ether (WETH) | WETH/USD | [WETH Sources](https://www.diadata.org/app/price/asset/Ethereum/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/) | Learn more about DIA's [data sourcing](/dia-stack/architecture/data-sourcing) and [data computation](/dia-stack/architecture/data-computation) architecture. ## How to Access Data Locate one of the deployed contracts (either testnet or mainnet) and call the `get-value` (or `getValue` for chainweb EVM) function. This function expects one parameter, which is the symbols of the asset you want to retrieve and a “/USD”, so for example for the Bitcoin price the parameter must be “BTC/USD”. This will return two values: 1. The price of the asset, with 8 decimals. 2. The timestamp of the last update in Unix time format, in UTC timezone. You can also refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/solidity) for detailed steps on fetching price data from the oracle in your EVM contract. ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Kadena. Learn more about the grant here: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Linea Source: https://www.diadata.org/docs/guides/chain-specific-guide/linea dApps built on Linea can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Linea. Learn more about the grant here: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # LUKSO Source: https://www.diadata.org/docs/guides/chain-specific-guide/lukso dApps built on LUKSO can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## Oracle Details | Chain | Address | | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [0x245ad685F4D89D30fD1a14682C030c6128d08d17](https://explorer.execution.mainnet.lukso.network/address/0x245ad685F4D89D30fD1a14682C030c6128d08d17) | ## Oracle Configuration | | | | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [VWAPIR](/guides/methodologies/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 0.5% and 120 seconds | | **Heartbeat** | 24h | ## Available Asset Feeds | Asset Ticker | Adapter Address | Asset Markets | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | EUR | [0xbCfD839664B5Ad4D0C0C58db0c716D7a28dCd15E](https://explorer.execution.mainnet.lukso.network/address/0xbCfD839664B5Ad4D0C0C58db0c716D7a28dCd15E) | [EUR markets](https://www.diadata.org/app/price/asset/Fiat/978/) | | LYX | [0x3153e4d03Cf97B230fc9c9d0ECCE5b2F0834d130](https://explorer.execution.mainnet.lukso.network/address/0x3153e4d03Cf97B230fc9c9d0ECCE5b2F0834d130) | [LYX markets](https://www.diadata.org/app/price/asset/Lukso/0x0000000000000000000000000000000000000000/) | | GBP | [0x7EA5b4bb2D89B1EfEF00FCC95E139B77Da27d460](https://explorer.execution.mainnet.lukso.network/address/0x7EA5b4bb2D89B1EfEF00FCC95E139B77Da27d460) | [GBP markets](https://www.diadata.org/app/price/asset/Fiat/826/) | | BTC | [0xD19856Bd3Dbd9Cb00BaC76Fc90603FA3bB05aCEA](https://explorer.execution.mainnet.lukso.network/address/0xD19856Bd3Dbd9Cb00BaC76Fc90603FA3bB05aCEA) | [BTC markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | ETH | [0xc7f3aceBe05482eeCD668df1FCF1B59e6d14f77b](https://explorer.execution.mainnet.lukso.network/address/0xc7f3aceBe05482eeCD668df1FCF1B59e6d14f77b) | [ETH markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | wstETH | [0x18f2182B37d46deC1dc236Cf3Aad3a02981796cB](https://explorer.execution.mainnet.lukso.network/address/0x18f2182B37d46deC1dc236Cf3Aad3a02981796cB) | [wstETH markets](https://www.diadata.org/app/price/asset/Ethereum/0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0/) | | DAI | [0x1bB6c1A90c9449A14C184Dd141D2c7d7b788a679](https://explorer.execution.mainnet.lukso.network/address/0x1bB6c1A90c9449A14C184Dd141D2c7d7b788a679) | [DAI markets](https://www.diadata.org/app/price/asset/Ethereum/0x6B175474E89094C44Da98b954EedeAC495271d0F/) | | USDC | [0xc675A8d220E1ba6d14a77C9FbcFDd5f9474BD07A](https://explorer.execution.mainnet.lukso.network/address/0xc675A8d220E1ba6d14a77C9FbcFDd5f9474BD07A) | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | USDT | [0xC00c10499DEF24352475Ae873C51FaFcFC894f03](https://explorer.execution.mainnet.lukso.network/address/0xC00c10499DEF24352475Ae873C51FaFcFC894f03) | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | stETH | [0x2b94002cfFA638B37E4DDe54EDfcF6Efdcb29E6A](https://explorer.execution.mainnet.lukso.network/address/0x2b94002cfFA638B37E4DDe54EDfcF6Efdcb29E6A) | [stETH markets](https://www.diadata.org/app/price/asset/Ethereum/0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84/) | *** ## How to Access Data ### getValue Method To consume price data, you'll need to invoke the [`getValue` method](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from our oracle on LUKSO mainnet. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ```solidity theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleV2Consumer{ address immutable ORACLE = 0x245ad685F4D89D30fD1a14682C030c6128d08d17; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` See the full example [here](/guides/how-to-guides/fetch-price-data/solidity). ### Adapter Contracts To consume price data from our oracle, you can use the adapter smart contract located at the [adapter address](/guides/chain-specific-guide/lukso#asset-feeds) for each asset. This will allow you to access the same methods on the `AggregatorV3Interface` such as `getRoundData` & `latestRoundData`. You can learn more [here](/guides/how-to-guides/migrate-to-dia). This is a sample contract for consuming the `BTC/USD` price feed: ```solidity theme={"system"} // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface DiaAssetSpecificCallingConvention { function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } contract DIAOracleSample { address btcAdapter = 0xD19856Bd3Dbd9Cb00BaC76Fc90603FA3bB05aCEA; function getBTCLatestPrice() external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { // Call the Chainlink adapter's latestRoundData function (, int256 answer, , uint256 updatedAt, ) = DiaAssetSpecificCallingConvention(btcAdapter).latestRoundData(); latestPrice = uint128(uint256(answer)); timestampOflatestPrice = uint128(updatedAt); return (latestPrice, timestampOflatestPrice); } } ``` *** ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on LUKSO. Learn more about the grant here: *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Metis Source: https://www.diadata.org/docs/guides/chain-specific-guide/metis dApps built on Metis can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Moonbase Source: https://www.diadata.org/docs/guides/chain-specific-guide/moonbase dApps built on Moonbase can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Moonbeam Source: https://www.diadata.org/docs/guides/chain-specific-guide/moonbeam dApps built on Moonbeam can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Moonriver Source: https://www.diadata.org/docs/guides/chain-specific-guide/moonriver dApps built on Moonriver can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Nervos Source: https://www.diadata.org/docs/guides/chain-specific-guide/nervos dApps built on Nervos can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data To consume price data, invoke a read function on the oracle contract that takes an asset key as a parameter. For example, If you pass `BTC/USD` as the key, it will return the most recent price of `BTC` in `USD` with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # OKT Chain (OKX) Source: https://www.diadata.org/docs/guides/chain-specific-guide/okt-chain dApps built on OKT Chain can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Optimism Source: https://www.diadata.org/docs/guides/chain-specific-guide/optimism dApps built on Optimism can leverage DIA oracles to access up-to-date asset price information. Explore these demo oracles to see how DIA works. For production deployments, [request a custom oracle](#request-a-custom-oracle) and unlock the full power of tailored data feeds for your dApp. ## Demo Oracles ### Oracle Contracts #### Mainnet | Contract | Address | | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | | Push Oracle | [0x048050547eb6e68cB37Fb21EEafEad40CF2CbdbB](https://optimistic.etherscan.io/address/0x048050547eb6e68cb37fb21eeafead40cf2cbdbb) | #### Testnet | Contract | Address | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------- | | Push Oracle | [0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0](https://sepolia-optimism.etherscan.io/address/0x9bb71344ed950f9cfd85ee1c7258553b01d95fa0) | ### Oracle Configuration | | | | ------------------------------------- | ------------------ | | **Pricing Methodology** | Median | | **Deviation (%) & Refresh Frequency** | 2% and 120 seconds | | **Heartbeat** | 12h | *** ### Available Asset Feeds | Asset Ticker | updates(key) | Asset Markets | | :----------- | :----------- | :----------------------------------------------------------------------------------------------------------- | | ETH | ETH/USD | [ETH Markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | BTC | BTC/USD | [BTC Markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | DIA | DIA/USD | [DIA Markets](https://www.diadata.org/app/price/asset/Ethereum/0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419/) | | USDC | USDC/USD | [USDC Markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | *** ## How to Access Data To consume price data, use the [`updates` method](/guides/how-to-guides/fetch-price-data/push-based-oracles) for Push-based oracles. The price updates are stored in both methods in an `updates` mapping. When accessing the `updates` mapping through the key `BTC/USD`, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. Below is a sample contract that consumes the `BTC/USD` price feed: ### updates Method ```solidity theme={"system"} pragma solidity ^0.8.13; import { PushOracleReceiver } from "@dia-data/contracts-spectra/PushOracleReceiver.sol"; contract DIAOracleSample { PushOracleReceiver public diaOracle; string public key = "BTC/USD"; constructor(address _oracle) { diaOracle = PushOracleReceiver(payable(_oracle)); } function getPrice() external view returns ( uint128 timestampOflatestPrice, uint128 latestPrice ) { (timestampOflatestPrice, latestPrice) = diaOracle.updates(key); } } ``` ## Additional Details You can find the contract addresses for the Optimism bridge's components on mainnet and testnet below: * [MailBox Contract](https://optimistic.etherscan.io/address/0xd4C1905BB1D26BC93DAC913e13CaCC278CdCC80D) * [ISM Contract](https://optimistic.etherscan.io/address/0xe74b7d236a97eed9026926073cbb436638266888) * [Protocol Fee Hook Contract](https://optimistic.etherscan.io/address/0x0ec9C62333E29243B04C934bC924c169c1255027) * [MailBox Contract](https://sepolia-optimism.etherscan.io/address/0x6966b0E55883d49BFB24539356a2f8A673E02039) * [ISM Contract](https://sepolia-optimism.etherscan.io/address/0xb869617a3CFcdA07A4cC230d996120074e7c817e) * [Protocol Fee Hook Contract](https://sepolia-optimism.etherscan.io/address/0x611C8b288c642336136a436d7125AC49FA71468B) Learn more about DIA's cross-chain messaging layer [here](/dia-stack/architecture/core-components/spectra). *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Plume Source: https://www.diadata.org/docs/guides/chain-specific-guide/plume dApps built on Plume can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Plume. Learn more about the grant here: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Polygon Source: https://www.diadata.org/docs/guides/chain-specific-guide/polygon dApps built on Polygon can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Polygon. Learn more about the grant here: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Polygon zkEVM Source: https://www.diadata.org/docs/guides/chain-specific-guide/polygon-zkevm dApps built on Polygon zkEVM can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Shibuya Source: https://www.diadata.org/docs/guides/chain-specific-guide/shibuya dApps built on Shibuya can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Shiden Source: https://www.diadata.org/docs/guides/chain-specific-guide/shiden dApps built on Shiden can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Shido Source: https://www.diadata.org/docs/guides/chain-specific-guide/shido dApps built on Shido can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Somnia Source: https://www.diadata.org/docs/guides/chain-specific-guide/somnia dApps built on Somnia can leverage DIA oracles to access up-to-date asset price information [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## Oracle Details | Chain | Address | | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [0xbA0E0750A56e995506CA458b2BdD752754CF39C4](https://shannon-explorer.somnia.network/address/0x9206296Ea3aEE3E6bdC07F7AaeF14DfCf33d865D) | | Testnet | [0x9206296ea3aee3e6bdc07f7aaef14dfcf33d865d](https://shannon-explorer.somnia.network/address/0x9206296Ea3aEE3E6bdC07F7AaeF14DfCf33d865D) | ## Oracle Configuration | | | | ------------------------------------- | ------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [MAIR](/guides/methodologies/pricing-methodologies/mair-moving-average-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 0.5% and 120 seconds | | **Heartbeat** | 24h | ## Available Asset Feeds ### Mainnet | Asset Ticker | Adapter address | Asset Markets | | ------------ | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | | USDT | [0x936C4F07fD4d01485849ee0EE2Cdcea2373ba267](https://explorer.somnia.network/address/0x936C4F07fD4d01485849ee0EE2Cdcea2373ba267) | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | USDC | [0x5D4266f4DD721c1cD8367FEb23E4940d17C83C93](https://explorer.somnia.network/address/0x5D4266f4DD721c1cD8367FEb23E4940d17C83C93) | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | BTC | [0xb12e1d47b0022fA577c455E7df2Ca9943D0152bE](https://explorer.somnia.network/address/0xb12e1d47b0022fA577c455E7df2Ca9943D0152bE) | [BTC markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | ARB | [0x6a96a0232402c2BC027a12C73f763b604c9F77a6](https://explorer.somnia.network/address/0x6a96a0232402c2BC027a12C73f763b604c9F77a6) | [ARB markets](https://www.diadata.org/app/price/asset/Arbitrum/0x912CE59144191C1204E64559FE8253a0e49E6548/) | | SOL | [0xa4a3a8B729939E2a79dCd9079cee7d84b0d96234](https://explorer.somnia.network/address/0xa4a3a8B729939E2a79dCd9079cee7d84b0d96234) | [SOL markets](https://www.diadata.org/app/price/asset/Solana/0x0000000000000000000000000000000000000000/) | | SOMI | [0x1f5f46B0DABEf8806a1f33772522ED683Ba64E27](https://explorer.somnia.network/address/0x1f5f46B0DABEf8806a1f33772522ED683Ba64E27) | [SOMI markets](https://www.diadata.org/app/price/asset/Somnia/0x0000000000000000000000000000000000000000/) | ### Testnet | Asset Ticker | Adapter address | Asset Markets | | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | | USDT | [0x67d2c2a87a17b7267a6dbb1a59575c0e9a1d1c3e](https://shannon-explorer.somnia.network/address/0x67d2C2a87A17b7267a6DBb1A59575C0E9A1D1c3e) | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | USDC | [0x235266D5ca6f19F134421C49834C108b32C2124e](https://shannon-explorer.somnia.network/address/0x235266D5ca6f19F134421C49834C108b32C2124e) | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | BTC | [0x4803db1ca3A1DA49c3DB991e1c390321c20e1f21](https://shannon-explorer.somnia.network/address/0x4803db1ca3A1DA49c3DB991e1c390321c20e1f21) | [BTC markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | ARB | [0x74952812B6a9e4f826b2969C6D189c4425CBc19B](https://shannon-explorer.somnia.network/address/0x74952812B6a9e4f826b2969C6D189c4425CBc19B) | [ARB markets](https://www.diadata.org/app/price/asset/Arbitrum/0x912CE59144191C1204E64559FE8253a0e49E6548/) | | SOL | [0xD5Ea6C434582F827303423dA21729bEa4F87D519](https://shannon-explorer.somnia.network/address/0xD5Ea6C434582F827303423dA21729bEa4F87D519) | [SOL markets](https://www.diadata.org/app/price/asset/Solana/0x0000000000000000000000000000000000000000/) | | SOMI | [0xaEAa92c38939775d3be39fFA832A92611f7D6aDe](https://shannon-explorer.somnia.network/address/0xaEAa92c38939775d3be39fFA832A92611f7D6aDe) | [SOMI markets](https://www.diadata.org/app/price/asset/Somnia/0x0000000000000000000000000000000000000000/) | *** ## How to Access Data ### getValue Method To consume price data, you’ll need to invoke the [`getValue` method](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from our oracle on Sepolia testnet. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ```solidity theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleV2Consumer{ address immutable ORACLE = 0x9206296ea3aee3e6bdc07f7aaef14dfcf33d865d; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` See the full example [here](/guides/how-to-guides/fetch-price-data/solidity). ### Adapter contracts To consume price data from our oracle, you can use the adapter smart contract located at the [adapter address](/guides/how-to-guides/fetch-price-data/chain-specific-guide/somnia#asset-feeds) for each asset. This will allow you to access the same methods on the `AggregatorV3Interface` such as `getRoundData` & `latestRoundData`. You can learn more [here](/guides/how-to-guides/migrate-to-dia). This is a sample contract for consuming the `$SOMI` price feed: ```solidity theme={"system"} // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface DiaAssetSpecificCallingConvention { function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } contract DIAOracleSample { address somiAdapter = function getSOMILatestPrice() external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { // Call the Chainlink adapter's latestRoundData function (, int256 answer, , uint256 updatedAt, ) = DiaAssetSpecificCallingConvention(somiAdapter).latestRoundData(); latestPrice = uint128(uint256(answer)); timestampOflatestPrice = uint128(updatedAt); return (latestPrice, timestampOflatestPrice); } // SOMI:1.23125165 } ``` *** ## Lumina Stack Feeds Explore these demo oracles to see how DIA Lumina Stack works. [Request a custom oracle](#request-a-custom-oracle) and unlock the full power of tailored data feeds for your dApp. Demo oracles are available for testing the new fully verifiable & decentralized [Lumina stack](/dia-stack/overview) on Somnia testnet. ### Oracle Details | Chain | Contract | Address | | ------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | Testnet | Push Oracle | [0xFb1462A649A92654482F8E048C754333ad85e5C0](https://shannon-explorer.somnia.network/address/0xFb1462A649A92654482F8E048C754333ad85e5C0) | ### Oracle Configuration | | | | ------------------------------------- | ------------------ | | **Pricing Methodology** | Median | | **Deviation (%) & Refresh Frequency** | 1% and 120 seconds | | **Heartbeat** | 24h | ### Asset Feeds | Asset Ticker | updates(key) | Asset Markets | | :----------- | :----------- | :----------------------------------------------------------------------------------------------------------- | | ETH | ETH/USD | [ETH Markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | BTC | BTC/USD | [BTC Markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | DIA | DIA/USD | [DIA Markets](https://www.diadata.org/app/price/asset/Ethereum/0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419/) | | USDC | USDC/USD | [USDC Markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | ### Additional Details You can find the contract addresses for the Somnia bridge’s components on testnet below: * [MailBox Contract](https://shannon-explorer.somnia.network/address/0x7d498740A4572f2B5c6b0A1Ba9d1d9DbE207e89E) * [ISM Contract](https://shannon-explorer.somnia.network/address/0xdBEf26113A6c84f2E1Ad13Bbb43898e4Ff4286dc) * [Protocol Fee Hook Contract](https://shannon-explorer.somnia.network/address/0x67f4e6b2EE6535F9D3Eca74E63a665F8c888C2bc) ## How to Access Data To consume price data, use the [`updates` method](/guides/how-to-guides/fetch-price-data/push-based-oracles) for Push-based oracles. The price updates are stored in both methods in an `updates` mapping. When accessing the `updates` mapping through the key `BTC/USD`, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. Below is a sample contract that consumes the `BTC/USD` price feed: ### updates Method ```solidity theme={"system"} pragma solidity ^0.8.13; import { PushOracleReceiver } from "@dia-data/contracts-spectra/PushOracleReceiver.sol"; contract DIAOracleSample { PushOracleReceiver public diaOracle; string public key = "BTC/USD"; constructor(address _oracle) { diaOracle = PushOracleReceiver(payable(_oracle)); } function getPrice() external view returns ( uint128 timestampOflatestPrice, uint128 latestPrice ) { (timestampOflatestPrice, latestPrice) = diaOracle.updates(key); } } ``` ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Somnia. Learn more about the grant here: ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp’s needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Sonic Source: https://www.diadata.org/docs/guides/chain-specific-guide/sonic dApps built on Sonic can leverage DIA oracles to access up-to-date asset price information. Explore these demo oracles to see how DIA works. For production deployments, [request a custom oracle](#request-a-custom-oracle) and unlock the full power of tailored data feeds for your dApp. ## Demo Oracles ### Oracle Contracts #### Mainnet | Contract | Address | | ----------- | ---------------------------------------------------------------------------------------------------------------------- | | Push Oracle | [0x048050547eb6e68cB37Fb21EEafEad40CF2CbdbB](https://sonicscan.org/address/0x048050547eb6e68cb37fb21eeafead40cf2cbdbb) | ### Oracle Configuration | | | | ------------------------------------- | ------------------ | | **Pricing Methodology** | Median | | **Deviation (%) & Refresh Frequency** | 2% and 120 seconds | | **Heartbeat** | 12h | *** ### Available Asset Feeds | Asset Ticker | updates(key) | Asset Markets | | :----------- | :----------- | :----------------------------------------------------------------------------------------------------------- | | ETH | ETH/USD | [ETH Markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | BTC | BTC/USD | [BTC Markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | DIA | DIA/USD | [DIA Markets](https://www.diadata.org/app/price/asset/Ethereum/0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419/) | | USDC | USDC/USD | [USDC Markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | *** ## How to Access Data To consume price data, use the [`updates` method](/guides/how-to-guides/fetch-price-data/push-based-oracles) for Push-based oracles. The price updates are stored in both methods in an `updates` mapping. When accessing the `updates` mapping through the key `BTC/USD`, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. Below is a sample contract that consumes the `BTC/USD` price feed: ### updates Method ```solidity theme={"system"} pragma solidity ^0.8.13; import { PushOracleReceiver } from "@dia-data/contracts-spectra/PushOracleReceiver.sol"; contract DIAOracleSample { PushOracleReceiver public diaOracle; string public key = "BTC/USD"; constructor(address _oracle) { diaOracle = PushOracleReceiver(payable(_oracle)); } function getPrice() external view returns ( uint128 timestampOflatestPrice, uint128 latestPrice ) { (timestampOflatestPrice, latestPrice) = diaOracle.updates(key); } } ``` ## Additional Details You can find the contract addresses for the Sonic bridge's components on mainnet below: * [MailBox Contract](https://sonicscan.org/address/0x3a464f746D23Ab22155710f44dB16dcA53e0775E) * [ISM Contract](https://sonicscan.org/address/0xE74B7D236A97eED9026926073cBb436638266888) * [Protocol Fee Hook Contract](https://sonicscan.org/address/0x0ec9C62333E29243B04C934bC924c169c1255027) Learn more about DIA's cross-chain messaging layer [here](/dia-stack/architecture/core-components/spectra). *** ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Sonic. Learn more about the grant here: *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Soroban Source: https://www.diadata.org/docs/guides/chain-specific-guide/soroban dApps built on Soroban can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data To consume price data, invoke a read function on the oracle contract that takes an asset key as a parameter. For example, If you pass `BTC/USD` as the key, it will return the most recent price of `BTC` in `USD` with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Stacks Source: https://www.diadata.org/docs/guides/chain-specific-guide/stacks dApps built on Stacks can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## Oracle Details | Chain | Address | | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [SP1G48FZ4Y7JY8G2Z0N51QTCYGBQ6F4J43J77BQC0.dia-oracle](https://explorer.hiro.so/txid/SP1G48FZ4Y7JY8G2Z0N51QTCYGBQ6F4J43J77BQC0.dia-oracle?chain=mainnet) | | Testnet | [ST1S5ZGRZV5K4S9205RWPRTX9RGS9JV40KQMR4G1J.dia-oracle](https://explorer.hiro.so/txid/ST1S5ZGRZV5K4S9205RWPRTX9RGS9JV40KQMR4G1J.dia-oracle?chain=testnet) | ## Oracle Configuration | | | | ------------------------------------- | ------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [MAIR](/guides/methodologies/pricing-methodologies/mair-moving-average-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 5% and 120 seconds | | **Heartbeat** | 15 minutes | ## Available Asset Feeds The Stacks oracle includes the following asset feeds: | Asset Ticker | Asset Blockchain | Asset Address | Asset Sources | | ------------ | ---------------- | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | | STX | Stacks | 0x0000000000000000000000000000000000000000 | [STX Market](https://www.diadata.org/app/price/asset/Stacks/0x0000000000000000000000000000000000000000/) | | stSTX | Stacks | SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token | [stSTX Market](https://www.diadata.org/app/price/asset/Stacks/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token/) | | DIKO | Stacks | SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.arkadiko-token | [DIKO Market](https://www.diadata.org/app/price/asset/Stacks/SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.arkadiko-token/) | | WELSH | Stacks | SP3NE50GEXFG9SZGTT51P40X2CKYSZ5CC4ZTZ7A2G.welshcorgicoin-token | [WELSH Market](https://www.diadata.org/app/price/asset/Stacks/SP3NE50GEXFG9SZGTT51P40X2CKYSZ5CC4ZTZ7A2G.welshcorgicoin-token/) | | VELAR | Stacks | SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.velar-token | [VELAR Market](https://www.diadata.org/app/price/asset/Stacks/SP1Y5YSTAHZ88XYK1VPDH24GY0HPX5J4JECTMY4A1.velar-token/) | | ALEX | Stacks | SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.age000-governance-token | [ALEX Market](https://www.diadata.org/app/price/asset/Stacks/SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.age000-governance-token/) | | sBTC | Stacks | SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token | [sBTC Market](https://www.diadata.org/app/price/asset/Stacks/SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token/) | | aeUSDC | Stacks | SP3Y2ZSH8P7D50B0VBTSX11S7XSG24M1VB9YFQA4K.token-aeusdc | [aeUSDC Market](https://www.diadata.org/app/price/asset/Stacks/SP3Y2ZSH8P7D50B0VBTSX11S7XSG24M1VB9YFQA4K.token-aeusdc/) | | USDh | Stacks | SPN5AKG35QZSK2M8GAMR4AFX45659RJHDW353HSG.usdh-token-v1 | [USDh Market](https://www.diadata.org/app/price/asset/Stacks/SPN5AKG35QZSK2M8GAMR4AFX45659RJHDW353HSG.usdh-token-v1/) | | BTC | Bitcoin | 0x0000000000000000000000000000000000000000 | [BTC Market](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | *** ## How to Access Data You can query for assets like `"STX/USD"` or `"stSTX/USD"` in the `get-value()` read function. It returns two values: 1. The price of STX/USD with 8 decimals 2. The timestamp of the last update (UTC timezone) Below is the DIA oracle contract implementation in [Clarity](https://docs.stacks.co/concepts/clarity): ```solidity theme={"system"} (impl-trait .trait-dia-oracle.dia-oracle-trait) (define-constant err-unauthorized (err u100)) (define-data-var oracle-updater principal tx-sender) (define-map values (string-ascii 32) { value: uint, timestamp: uint } ) (define-public (set-value (key (string-ascii 32)) (value uint) (timestamp uint)) (begin (try! (check-is-oracle-updater)) (update-value { key: key, value: value, timestamp: timestamp }) (ok true) ) ) (define-public (set-multiple-values (entries (list 10 { key: (string-ascii 32), value: uint, timestamp: uint }))) (begin (try! (check-is-oracle-updater)) (map update-value entries) (ok true) ) ) (define-public (change-oracle-updater (new-oracle-updater principal)) (begin ;; #[filter(new-oracle-updater)] (try! (check-is-oracle-updater)) (var-set oracle-updater new-oracle-updater) (print { action: "oracle-updater-changed", data: { old-updater: tx-sender, new-updater: new-oracle-updater } } ) (ok true) ) ) (define-read-only (get-oracle-updater) (var-get oracle-updater) ) (define-read-only (get-value (key (string-ascii 32))) (ok (default-to { value: u0, timestamp: u0 } (map-get? values key))) ) (define-private (check-is-oracle-updater) (ok (asserts! (is-eq tx-sender (var-get oracle-updater)) err-unauthorized)) ) (define-private (update-value (entry { key: (string-ascii 32), value: uint, timestamp: uint })) (begin (map-set values (get key entry) { value: (get value entry), timestamp: (get timestamp entry) } ) (print { action: "updated", data: entry }) ) ) ``` Learn more about DIA’s [data sourcing](/dia-stack/architecture/data-sourcing) and [data computation](/dia-stack/architecture/data-computation) architecture. *** ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Stacks. Learn more about the grant here: *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Superseed Source: https://www.diadata.org/docs/guides/chain-specific-guide/superseed dApps built on Superseed can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## Oracle Details | Chain | Address | | ------- | --------------------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [0xF526dC0D2B73488d32b58E55C17Cef5a53AD002A](https://explorer.superseed.xyz/address/0xF526dC0D2B73488d32b58E55C17Cef5a53AD002A) | | Testnet | [0x6f021bF081840F96bdd90fd756b700072C7E68A5](https://sepolia-explorer.superseed.xyz/address/0x6f021bF081840F96bdd90fd756b700072C7E68A5) | ## Oracle Configuration | Parameter | Value | | --------------------------------- | ------------------------------------------------------------------------------------------------------- | | Pricing Methodology | [MAIR](/guides/methodologies/pricing-methodologies/mair-moving-average-with-interquartile-range-filter) | | Deviation (%) & Refresh Frequency | 0.5% and 120 seconds | | Heartbeat | 24h | ## Available Asset Feeds ### Mainnet | Asset Ticker | Adapter Address | Asset Markets | | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | | WETH | [0xAdEfc2264c21A05D3f83bf7694438F81E119620B](https://explorer.superseed.xyz/address/0xAdEfc2264c21A05D3f83bf7694438F81E119620B) | [WETH markets](https://www.diadata.org/app/price/asset/Ethereum/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/) | | cbBTC | [0x7F760344c9Cde8DD342120FA0F908CE0Cd42B1E6](https://explorer.superseed.xyz/address/0x7F760344c9Cde8DD342120FA0F908CE0Cd42B1E6) | [cbBTC markets](https://www.diadata.org/app/price/asset/Base/0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf/) | ### Testnet | Asset Ticker | Adapter Address | Asset Markets | | ------------ | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | | WETH | [0xA09A4e4297a06e284a4ACdf2Ca1F9998d5280F6e](https://sepolia-explorer.superseed.xyz/address/0xA09A4e4297a06e284a4ACdf2Ca1F9998d5280F6e) | [WETH markets](https://www.diadata.org/app/price/asset/Ethereum/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/) | | cbBTC | [0x61790e8F9bf02E4272E273F2615eD4fc7d8F95D9](https://sepolia-explorer.superseed.xyz/address/0x61790e8F9bf02E4272E273F2615eD4fc7d8F95D9) | [cbBTC markets](https://www.diadata.org/app/price/asset/Base/0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf/) | *** ## How to Access Data ### getValue Method To consume price data, you’ll need to invoke the `getValue` method on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#access-the-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from our oracle on Superseed mainnet using the IDIAOracleV2 interface. If you pass `WETH/USD` as the key, it will return the most recent price of WETH in USD with 8 decimal places (e.g. 177101990135 is \$1,771.01990135) along with the Unix timestamp of the last price update. ```solidity theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleSample { address immutable ORACLE = 0xF526dC0D2B73488d32b58E55C17Cef5a53AD002A; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` See the full example [here](/guides/how-to-guides/fetch-price-data/solidity). ### Adapter contracts To consume price data from our oracle, you can use the adapter smart contract located at the [adapter address](/guides/chain-specific-guide/superseed#asset-feeds) for each asset. This will allow you to access the same methods on the `AggregatorV3Interface` such as `getRoundData` & `latestRoundData`. You can learn more [here](/guides/how-to-guides/migrate-to-dia). This is a sample contract for consuming the `WETH/USD` price feed on Superseed mainnet: ```solidity theme={"system"} // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface DiaAssetSpecificCallingConvention { function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } contract DIAOracleSample { address wethAdapter = 0xF526dC0D2B73488d32b58E55C17Cef5a53AD002A; function getWETHLatestPrice() external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { // Call the Chainlink adapter's latestRoundData function (, int256 answer, , uint256 updatedAt, ) = DiaAssetSpecificCallingConvention(wethAdapter).latestRoundData(); latestPrice = uint128(uint256(answer)); timestampOflatestPrice = uint128(updatedAt); return (latestPrice, timestampOflatestPrice); } } ``` *** ## Oracle Grants Program The DIA Oracle Grants Program provides zero-cost oracle access for up to 1 year, covering deployment and update costs to accelerate dApp development on Superseed. Learn more about the grant here: *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Swell Source: https://www.diadata.org/docs/guides/chain-specific-guide/swell dApps built on Swell can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Telos Source: https://www.diadata.org/docs/guides/chain-specific-guide/telos dApps built on Telos can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Unichain Source: https://www.diadata.org/docs/guides/chain-specific-guide/unichain dApps built on Unichain can leverage DIA oracles to access up-to-date asset price information. Explore these demo oracles to see how DIA works. For production deployments, [request a custom oracle](#request-a-custom-oracle) and unlock the full power of tailored data feeds for your dApp. ## Demo Oracles ### Oracle Contracts #### Testnet | Contract | Address | | ----------- | ---------------------------------------------------------------------------------------------------------------------------- | | Push Oracle | [0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0](https://sepolia.uniscan.xyz/address/0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0) | ### Oracle Configuration | | | | ------------------------------------- | ------------------ | | **Pricing Methodology** | Median | | **Deviation (%) & Refresh Frequency** | 2% and 120 seconds | | **Heartbeat** | 12h | *** ### Available Asset Feeds | Asset Ticker | updates(key) | Asset Markets | | :----------- | :----------- | :----------------------------------------------------------------------------------------------------------- | | ETH | ETH/USD | [ETH Markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | BTC | BTC/USD | [BTC Markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | DIA | DIA/USD | [DIA Markets](https://www.diadata.org/app/price/asset/Ethereum/0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419/) | | USDC | USDC/USD | [USDC Markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | *** ## How to Access Data To consume price data, use the [`updates` method](/guides/how-to-guides/fetch-price-data/push-based-oracles) for Push-based oracles. The price updates are stored in both methods in an `updates` mapping. When accessing the `updates` mapping through the key `BTC/USD`, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. Below is a sample contract that consumes the `BTC/USD` price feed: ### updates Method ```solidity theme={"system"} pragma solidity ^0.8.13; import { PushOracleReceiver } from "@dia-data/contracts-spectra/PushOracleReceiver.sol"; contract DIAOracleSample { PushOracleReceiver public diaOracle; string public key = "BTC/USD"; constructor(address _oracle) { diaOracle = PushOracleReceiver(payable(_oracle)); } function getPrice() external view returns ( uint128 timestampOflatestPrice, uint128 latestPrice ) { (timestampOflatestPrice, latestPrice) = diaOracle.updates(key); } } ``` ## Additional Details You can find the contract addresses for the Unichain bridge's components on testnet below: * [MailBox Contract](https://sepolia.uniscan.xyz/address/0xDDcFEcF17586D08A5740B7D91735fcCE3dfe3eeD) * [ISM Contract](https://sepolia.uniscan.xyz/address/0xb869617a3CFcdA07A4cC230d996120074e7c817e) * [Protocol Fee Hook Contract](https://sepolia.uniscan.xyz/address/0x611C8b288c642336136a436d7125AC49FA71468B) Learn more about DIA's cross-chain messaging layer [here](/dia-stack/architecture/core-components/spectra). *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Units Network Source: https://www.diadata.org/docs/guides/chain-specific-guide/units-network dApps built on Units Network can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## Oracle Details | Chain | Address | | ------- | --------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [0xc9783a5BaBE78D979B7EB5AD43Ea3B57Acb17034](https://explorer.unit0.dev/address/0xc9783a5BaBE78D979B7EB5AD43Ea3B57Acb17034) | ## Oracle Configuration | | | | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [VWAPIR](/guides/methodologies/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 0.5% and 120 seconds | | **Heartbeat** | 24h | ## Available Asset Feeds | Asset Ticker | getValue(key) | Asset Markets | | ------------ | ------------- | ------------------------------------------------------------------------------------------------------------ | | WETH | WETH/USD | [WETH markets](https://www.diadata.org/app/price/asset/Ethereum/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/) | | WBTC | WBTC/USD | [WBTC markets](https://www.diadata.org/app/price/asset/Ethereum/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/) | | USDC | USDC/USD | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | USDT | USDT/USD | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | *** ## How to Access Data ### getValue Method To consume price data, you'll need to invoke the `getValue` method on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#access-the-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from our oracle on Units Network. If you pass `WBTC/USD` as the key, it will return the most recent price of WBTC in USD with 8 decimal places (e.g.11796077504693 is \$117,960.77504693) along with the Unix timestamp of the last price update. ```solidity theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleV2Consumer{ address immutable ORACLE = 0xc9783a5BaBE78D979B7EB5AD43Ea3B57Acb17034; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Velas Source: https://www.diadata.org/docs/guides/chain-specific-guide/velas dApps built on Velas can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # W Chain Source: https://www.diadata.org/docs/guides/chain-specific-guide/w-chain dApps built on W Chain can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## Oracle Details | Chain | Address | | ------- | --------------------------------------------------------------------------------------------------------------------------------- | | Mainnet | [0x47A04f0a1FA94c14f9FcB4EA0dC63aDdbC9Ecbe5](https://scan.w-chain.com/address/0x47A04f0a1FA94c14f9FcB4EA0dC63aDdbC9Ecbe5) | | Testnet | [0x57e70667575c50c26D60BE6Db56e54B579d8CC22](https://scan-testnet.w-chain.com/address/0x57e70667575c50c26D60BE6Db56e54B579d8CC22) | ## Oracle Configuration | | | | ------------------------------------- | ------------------------------------------------------------------------------------------------------- | | **Pricing Methodology** | [MAIR](/guides/methodologies/pricing-methodologies/mair-moving-average-with-interquartile-range-filter) | | **Deviation (%) & Refresh Frequency** | 0.5% and 120 seconds | | **Heartbeat** | 24h | ## Available Asset Feeds ### Mainnet | Asset Ticker | Adapter Address | Asset Markets | | ------------ | ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | | BTC | [0x34E793Bed54bcd6a7EE9479D8E7fDdD957ACd252](https://scan.w-chain.com/address/0x34E793Bed54bcd6a7EE9479D8E7fDdD957ACd252) | [BTC markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | ETH | [0x1145b9bad680089c8724Df0FAB1E68c7871E12a8](https://scan.w-chain.com/address/0x1145b9bad680089c8724Df0FAB1E68c7871E12a8) | [ETH markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | SOL | [0x07CEb7db57759EB6D0b68CAb0cF49a08A52B06bd](https://scan.w-chain.com/address/0x07CEb7db57759EB6D0b68CAb0cF49a08A52B06bd) | [SOL markets](https://www.diadata.org/app/price/asset/Solana/0x0000000000000000000000000000000000000000/) | | BNB | [0x512a846569442a9E69E595A3f030898A1cc052Ec](https://scan.w-chain.com/address/0x512a846569442a9E69E595A3f030898A1cc052Ec) | [BNB markets](https://www.diadata.org/app/price/asset/BinanceSmartChain/0x0000000000000000000000000000000000000000/) | | USDC | [0x9A581384B1A54D0863E20fa7bC6aafd68eB070B3](https://scan.w-chain.com/address/0x9A581384B1A54D0863E20fa7bC6aafd68eB070B3) | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | USDT | [0x29047678110de15199AEb74332EDeCC4C3F83599](https://scan.w-chain.com/address/0x29047678110de15199AEb74332EDeCC4C3F83599) | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | POL | [0x9c42bcc40Ba59F87047434eC5fd9E3960A9d133C](https://scan.w-chain.com/address/0x9c42bcc40Ba59F87047434eC5fd9E3960A9d133C) | [POL markets](https://www.diadata.org/app/price/asset/Ethereum/0x455e53908C49407DDe25B8293c72529b80b9b605/) | | XRP | [0x3f3C850720A2838905cc1Dd50f4A3F5e03F84E92](https://scan.w-chain.com/address/0x3f3C850720A2838905cc1Dd50f4A3F5e03F84E92) | [XRP markets](https://www.diadata.org/app/price/asset/Ripple/0x0000000000000000000000000000000000000000/) | | WCO | [0x58f903ec136c589447fA8db5d22210919c5bc51f](https://scan.w-chain.com/address/0x58f903ec136c589447fA8db5d22210919c5bc51f) | [WCO markets](https://www.diadata.org/app/price/asset/WChain/0x0000000000000000000000000000000000000000/) | ### Testnet | Asset Ticker | Adapter Address | Asset Markets | | ------------ | --------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | | BTC | [0x9D0134e6fbB244dDa210189A5Dfe29BB85FF1E94](https://scan-testnet.w-chain.com/address/0x9D0134e6fbB244dDa210189A5Dfe29BB85FF1E94) | [BTC markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | ETH | [0x6cD4023d7da60c305F1BD2a361DAa7dEeCc8d336](https://scan-testnet.w-chain.com/address/0x6cD4023d7da60c305F1BD2a361DAa7dEeCc8d336) | [ETH markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | SOL | [0xef07fB27696597e9b248Ee7B265D715a8e130f36](https://scan-testnet.w-chain.com/address/0xef07fB27696597e9b248Ee7B265D715a8e130f36) | [SOL markets](https://www.diadata.org/app/price/asset/Solana/0x0000000000000000000000000000000000000000/) | | BNB | [0x5cb4129280cf34bd3D4c3127D910948896752877](https://scan-testnet.w-chain.com/address/0x5cb4129280cf34bd3D4c3127D910948896752877) | [BNB markets](https://www.diadata.org/app/price/asset/BinanceSmartChain/0x0000000000000000000000000000000000000000/) | | USDC | [0xc305427D51eBf5555Df717A562729F1853645e7c](https://scan-testnet.w-chain.com/address/0xc305427D51eBf5555Df717A562729F1853645e7c) | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | USDT | [0x30eFF71073F6ba6E46bF15A417CdB301009c2d69](https://scan-testnet.w-chain.com/address/0x30eFF71073F6ba6E46bF15A417CdB301009c2d69) | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | POL | [0xa8c64239F9939530bf84357D7A9e281986781Ade](https://scan-testnet.w-chain.com/address/0xa8c64239F9939530bf84357D7A9e281986781Ade) | [POL markets](https://www.diadata.org/app/price/asset/Ethereum/0x455e53908C49407DDe25B8293c72529b80b9b605/) | | XRP | [0xBc22d07df5baf273d55eCD7027BdaA70EbCa3076](https://scan-testnet.w-chain.com/address/0xBc22d07df5baf273d55eCD7027BdaA70EbCa3076) | [XRP markets](https://www.diadata.org/app/price/asset/Ripple/0x0000000000000000000000000000000000000000/) | | WCO | [0x9a242f634A324f3621813A7f197206f6AC407b86](https://scan-testnet.w-chain.com/address/0x9a242f634A324f3621813A7f197206f6AC407b86) | [WCO markets](https://www.diadata.org/app/price/asset/WChain/0x0000000000000000000000000000000000000000/) | *** ## How to access data ### getValue Method To consume price data, you'll need to invoke the [`getValue` method](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) on the oracle contract which you can access through the [DIA Oracle library](/guides/how-to-guides/fetch-price-data/solidity#solidity-library) or the [interface](/guides/how-to-guides/fetch-price-data/solidity#using-the-diaoraclev2-interface). Below is an example of a contract consuming data from our oracle on W Chain mainnet. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with **8 decimal places** (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ```solidity theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleV2Consumer{ address immutable ORACLE = 0x47A04f0a1FA94c14f9FcB4EA0dC63aDdbC9Ecbe5; function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(ORACLE).getValue(key); } } ``` See the full example [here](/guides/how-to-guides/fetch-price-data/solidity). ### Adapter contracts To consume price data from our oracle, you can use the adapter smart contract located at the [adapter address](/guides/chain-specific-guide/w-chain#asset-feeds) for each asset. This will allow you to access the same methods on the `AggregatorV3Interface` such as `getRoundData` & `latestRoundData`. You can learn more [here](/guides/how-to-guides/migrate-to-dia). This is a sample contract for consuming the `BTC/USD` price feed on W Chain mainnet: ```solidity theme={"system"} // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface DiaAssetSpecificCallingConvention { function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } contract DIAOracleSample { address btcAdapter = 0x34E793Bed54bcd6a7EE9479D8E7fDdD957ACd252; function getBTCLatestPrice() external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { // Call the Chainlink adapter's latestRoundData function (, int256 answer, , uint256 updatedAt, ) = DiaAssetSpecificCallingConvention(btcAdapter).latestRoundData(); latestPrice = uint128(uint256(answer)); timestampOflatestPrice = uint128(updatedAt); return (latestPrice, timestampOflatestPrice); } } ``` *** ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # Wanchain Source: https://www.diadata.org/docs/guides/chain-specific-guide/wanchain dApps built on Wanchain can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # XRP Ledger (XRPL) Source: https://www.diadata.org/docs/guides/chain-specific-guide/xrp-ledger-xrpl dApps built on XRPL can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## Oracle Details | Chain | Address | | ------- | ---------------------------------------------------------------------------- | | Mainnet | **Provider:** diadata (hex. 64696164617461)
**Oracle Document ID:** 42 | | Testnet | **Provider:** diadata (hex: 64696164617461)
**Oracle Document ID:** 1 | ## Oracle Configuration | | | | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | Pricing Methodology | [VWAPIR](/guides/methodologies/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter) | | Deviation (%) & Refresh Frequency | 1% and 120 seconds | | Heartbeat | 24h | ## Gas Wallets The gas wallets used to push updates to the oracle are the following: | Chain | Address | | ------- | ---------------------------------------------------------------------------------------------------------- | | Mainnet | [rP24Lp7bcUHvEW7T7c8xkxtQKKd9fZyra7](https://livenet.xrpl.org/accounts/rP24Lp7bcUHvEW7T7c8xkxtQKKd9fZyra7) | | Testnet | [r3U1mL5u2SCPr4mApqYyF96nvwvKoGf7aH](https://testnet.xrpl.org/accounts/r3U1mL5u2SCPr4mApqYyF96nvwvKoGf7aH) | ## Available Asset Feeds | Asset Ticker | Asset Ticker (Hex) | Asset Markets | | ------------ | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | BTC | 4254430000000000000000000000000000000000 | [BTC markets](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | | ETH | 4554480000000000000000000000000000000000 | [ETH markets](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | | XRP | 5852500000000000000000000000000000000000 | [XRP markets](https://www.diadata.org/app/price/asset/XRPL/0x0000000000000000000000000000000000000000/) | | RLUSD | 524C555344000000000000000000000000000000 | [RLUSD markets](https://www.diadata.org/app/price/asset/XRPL/rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De/) | | USDC | 5553444300000000000000000000000000000000 | [USDC markets](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | | USDT | 5553445400000000000000000000000000000000 | [USDT markets](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | | EUROP | 4555524F50000000000000000000000000000000 | [EUROP markets](https://www.diadata.org/app/price/asset/Ethereum/0x888883b5F5D21fb10Dfeb70e8f9722B9FB0E5E51/) | ## How to Access Data The DIA oracle object can be retrieved with the [ledger\_entry API](https://xrpl.org/resources/dev-tools/websocket-api-tool#ledger_entry-oracle) call by specifying the account and oracle\_document\_id. This is the Request JSON for mainnet: ```json theme={"system"} { "id": "example_get_oracle", "command": "ledger_entry", "oracle": { "account": "rP24Lp7bcUHvEW7T7c8xkxtQKKd9fZyra7", "oracle_document_id": 42 }, "ledger_index": "validated" } ``` It will return the current price of all the assets in hexadecimal format, which can then be converted to decimal and scaled to obtain the actual price with 8 decimal places. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # zkSync Source: https://www.diadata.org/docs/guides/chain-specific-guide/zksync dApps built on zkSync can leverage DIA oracles to access up-to-date asset price information. [DIA](https://diadata.org/) is a cross-chain oracle provider that sources granular market data from diverse exchanges, including CEXs and DEXs. Its data sourcing is thorough, enabling unparalleled transparency and customizability for resilient price feeds for 20,000+ assets. Its versatile data processing and delivery ensures adaptability and reliability for any decentralized application. ## How to Access Data Refer to the [Solidity guide](/guides/how-to-guides/fetch-price-data/) for detailed steps on fetching price data from the oracle in your contract. If you pass `BTC/USD` as the key, it will return the most recent price of BTC in USD with 8 decimal places (e.g. 9601458065403 is \$96,014.58065403) along with the Unix timestamp of the last price update. ## Request a Custom Oracle DIA offers highly customizable oracles that are individually tailored to each dApp's needs. Each oracle can be customized in the following ways, including: * Data Sources & Asset Feeds * Pricing Methodologies * Update Triggers (Frequency, Deviation, Heartbeat, ...etc) Get a tailored oracle for your dApp, request one below: ## Support For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org). # DIA Deployments Source: https://www.diadata.org/docs/guides/dia-deployments Complete list of DIA contract deployments for the Lumina components on DIA Lasernet Testnet& Mainnet. Explore the deloyments for the Lumina components on DIA Lasernet. If you're unfamiliar with Lumina stack's infrastructure, read the [Lumina Core Components](/dia-stack/architecture/core-components/overview) page to learn more. ## Token Price Feeds ### Mainnet | Contract | Address | | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | MailBox | [0xa016e5E7Ce70E78ba7B914299B3c2d44f69Ad392](https://explorer.diadata.org/address/0xa016e5E7Ce70E78ba7B914299B3c2d44f69Ad392) | | OracleRequestRecipient | [0xA42217338614B7e67D022C52D1CD38e02D619bb0](https://explorer.diadata.org/address/0xA42217338614B7e67D022C52D1CD38e02D619bb0) | | DIAOracleMetaV2 | [0x5eeB8c00CD8F189f62c9BAD352C0C474429F8A27](https://explorer.diadata.org/address/0x5eeB8c00CD8F189f62c9BAD352C0C474429F8A27) | | OracleTrigger | [0x92F0f4C9F769ed83609CD2ccD1ACcE224bBC8cBF](https://explorer.diadata.org/address/0x92F0f4C9F769ed83609CD2ccD1ACcE224bBC8cBF) | | ISM | [0xE74B7D236A97eED9026926073cBb436638266888](https://explorer.diadata.org/address/0xE74B7D236A97eED9026926073cBb436638266888) | ### Testnet | Contract | Address | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | | MailBox | [0x16cD72271498bcaD5aeB9f2D785bA82dC5AfA5E2](https://testnet-explorer.diadata.org/address/0x16cD72271498bcaD5aeB9f2D785bA82dC5AfA5E2) | | OracleRequestRecipient | [0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0](https://testnet-explorer.diadata.org/address/0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0) | | DIAOracleMetaV2 | [0x0087342f5f4c7AB23a37c045c3EF710749527c88](https://testnet-explorer.diadata.org/address/0x0087342f5f4c7AB23a37c045c3EF710749527c88) | | OracleTrigger | [0xb869617a3CFcdA07A4cC230d996120074e7c817e](https://testnet-explorer.diadata.org/address/0xb869617a3CFcdA07A4cC230d996120074e7c817e) | | ISM | [0x61D217a26D0Bff1D2b4c6f5880e621071326aadC](https://testnet-explorer.diadata.org/address/0x61D217a26D0Bff1D2b4c6f5880e621071326aadC) | ## RWA Price Feeds ### Mainnet | Contract | Address | | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | MailBox | [0xa016e5E7Ce70E78ba7B914299B3c2d44f69Ad392](https://explorer.diadata.org/address/0xa016e5E7Ce70E78ba7B914299B3c2d44f69Ad392) | | OracleRequestRecipient | [0xA42217338614B7e67D022C52D1CD38e02D619bb0](https://explorer.diadata.org/address/0xA42217338614B7e67D022C52D1CD38e02D619bb0) | | DIAOracleMetaV2 | [0x30F5A368a1426851C23E90467F6dCc688116194A](https://explorer.diadata.org/address/0x30F5A368a1426851C23E90467F6dCc688116194A) | | OracleTrigger | [0x8ed69fd34A1e29b6c6012e89C555b83b5DC7Dad5](https://explorer.diadata.org/address/0x8ed69fd34A1e29b6c6012e89C555b83b5DC7Dad5) | | ISM | [0xE74B7D236A97eED9026926073cBb436638266888](https://explorer.diadata.org/address/0xE74B7D236A97eED9026926073cBb436638266888) | ## Learn More: # DIA Staking Source: https://www.diadata.org/docs/guides/general-guides/dia-staking ## \$DIA Staking Overview Staking in DIA Lumina is the security layer. Stakers (token holders and [Feeders](https://www.diadata.org/blog/post/dia-distributed-feeder-network/)) lock up [**\$DIA**](https://www.diadata.org/token/) to secure oracle operations. Feeders are responsible for submitting accurate and timely data onchain and are incentivized to act reliably to earn rewards. In this system, staking directly underpins the economic and security model of DIA oracles. Over time, Feeders and delegators will earn performance-based rewards; delivering inaccurate data can lead to penalties. This will evolve into a slashing and delegation framework, where token holders can back feeders of their choice and get rewarded for supporting network reliability. Learn more about the Staking layer: ## How It Works Follow [this video tutorial](https://youtu.be/ufJqdPrAb8Q) or the following instructions below. If you have any questions, get in touch with us via [Telegram](https://t.me/diadata_org). Staking is currently unavailable to residents of the UK, US, or Canada due to local regulatory requirements. ### Staking [https://www.diadata.org/app/staking/](https://www.diadata.org/app/staking/) Check if there are available staking opportunities. If so, connect your wallet on DIA Lasernet to get started. To add Lasernet to your wallet, go to the [Chain Information page](/resources/chain-information). [https://www.diadata.org/app/staking/wrap/](https://www.diadata.org/app/staking/wrap/) Enter the DIA amount you want to exchange for wDIA, review the transaction details, and hit "Wrap". [https://www.diadata.org/app/staking/](https://www.diadata.org/app/staking/) Select an amount of wDIA tokens (min. 1 wDIA), check the transaction preview and if everything looks great, hit "Stake". Staking takes place on DIA Lasernet Mainnet and requires gas fees to be paid for the transactions (in DIA). Review your portfolio to see your staked wDIA tokens, APR, and accrued rewards. Below are the stake statuses: * `x Staking`: total amount of wDIA tokens staked * `x Unstaking`: total amount of wDIA tokens unstaking * `x Available`: total amount of wDIA & DIA tokens available to stake * `x Claimable`: total amount of wDIA tokens claimable after the unstaking period ### Un-staking [https://www.diadata.org/app/staking/](https://www.diadata.org/app/staking/) Review your stakes under "Staked pools" section. Click on the "Unstake" button next to the stake that you want to unstake. This will change the status of your stake to `Unstaking`. By doing this, you're initiating the unstaking process which will take 7 days to complete. Once the cooldown period is over, you can claim your prinicpal along with the rewards. Once the cooldown period is over, you can click on the "Claim" button to withdraw your stake and claim rewards. Your stake and rewards will be available in your wallet as wDIA tokens. [https://www.diadata.org/app/staking/wrap/](https://www.diadata.org/app/staking/wrap/) You can un-wrap your rewards to DIA tokens by entering an amount of wDIA tokens and clicking "Unwrap". ## Audit The staking smart contract has been audited by Mixbytes. The full audit report can be found here: # Run a Feeder Source: https://www.diadata.org/docs/guides/general-guides/run-a-feeder Running a feeder is a way to contribute to the decentralization of the data sourcing process in DIA's feeder network, making the ecosystem robust and giving dApps access to real-time and verifiable data. Please refer to our [Wiki](https://github.com/diadata-org/decentral-feeder/wiki) page and [GitHub](https://github.com/diadata-org/decentral-feeder) repository for the latest documentation on feeder nodes and releases. Start by reviewing the [hardware specifications](/guides/general-guides/run-a-feeder/hardware-specs) and proceed to [running the node](/guides/general-guides/run-a-feeder/setting-up-the-node) based on your preferred deployment method. If you're interested in becoming an official feeder in DIA's feeder network, please reach out to our team over our [dedicated communication channels](/guides/resources/community-and-support). # Hardware Specs Source: https://www.diadata.org/docs/guides/general-guides/run-a-feeder/hardware-specs | Hardware | Normal Usage | Peak Usage | | -------- | ------------ | ----------- | | Memory | \~100 MiB | \~500 MiB | | CPU | \~0.1 cores | \~0.3 cores | | Storage | Minimal | N/A | The storage is minimal because no historical data is stored on the nodes; only real-time data is pushed directly to smart contracts. These resource needs can be sufficiently met by a minimal, entry-level virtual machine from most cloud providers with the following specifications: * 1 vCPU * 1 GB RAM * 10 GB Storage ## Cost Projections ### **Standalone VM** The cost of operating the decentral-feeder primarily depends on the infrastructure selected by the node operator. The following prices are estimates and may vary depending on factors such as region, additional services, network usage, and other considerations. | Cloud Provider | Monthly Costs | | ---------------------------- | ------------- | | Hetzner (CX22) | \~\$4 | | Amazon AWS (t2.micro) | \~\$9 | | DigitalOcean (Basic Droplet) | \~\$5 | ### **Kubernetes Clusters** The costs of running feeder nodes in our Kubernetes clusters are generally higher compared to standalone VMs. It also depends on your setup and the additional overhead of managing Kubernetes infrastructure and other services. ## Performance Metrics * Our nodes are configured with 20-100 websocket connections open in parallel, and a transaction is being sent every 1-20 seconds so a similar configuration would be expected * You can use public RPC endpoints to fetch data and submit txns onchain. However, they’re mostly good for testing purposes so we recommend setting up a private endpoint for consistent usage. Here are some of our recommendations: # Setting Up the Node Source: https://www.diadata.org/docs/guides/general-guides/run-a-feeder/setting-up-the-node Make sure you familiraize yourself with the data flow in the Lumina system before proceeding with the node setup. To learn more, checkout the architecture guide [here](/reference/architecture). ## Requirements * Ensure that Docker or Docker Compose is installed on your machine. * Clone the [decentral-feeder repository](https://github.com/diadata-org/decentral-feeder) to your local machine. * The container has minimal resource requirements, making it suitable for most machines, including Windows, macOS, Linux, and Raspberry Pi, as long as Docker is installed. * An ETH private key from MetaMask or any other Eth wallet. Alternatively to generate private key effortlesly eth-keys tool can be used for this [ethereum/eth-keys](https://github.com/ethereum/eth-keys) * DIA tokens in your wallet. If you're using testnet, you can access the faucet [here](https://faucet.diadata.org/). Next, select your preferred deployment method: Suitable for a single container setup and quick testing Suitable for simple setups without orchestration Ideal for production environments requiring scalability and high availability # Docker Compose Source: https://www.diadata.org/docs/guides/general-guides/run-a-feeder/setting-up-the-node/docker-compose ## Configure Environment Variables Navigate to the docker-compose folder where `docker-compose.yaml` file is located. ```bash theme={"system"} cd docker-compose ``` Create a `.env` file in the same folder. it should contain the following variables: * `NODE_OPERATOR_NAME`: A unique and descriptive name identifying the organization or entity running the node. This name is used for monitoring and should be chosen carefully to ensure it is both meaningful and recognizable (e.g., include your organization name or geographical region). Providing a clear name helps distinguish your node in dashboards and logs. * `CHAIN_ID`: set the chain ID value * `PRIVATE_KEY`: Your private key for the deployment. * `DEPLOYED_CONTRACT`: The contract address. Initially, leave this empty during the first deployment to retrieve the deployed contract. The following pushgateway vars are **mandatory** for official DIA node operators. If you're an official operator, please reach out to the team to get these credentials. For developers testing the system, these credentials are **optional** and can be skipped. * `PUSHGATEWAY_URL`: The Pushgateway endpoint used for pushing metrics to Prometheus. * `PUSHGATEWAY_USER`: to allow decentralized-feeder authenticate towards the monitoring server. * `PUSHGATEWAY_PASSWORD`: to allow decentralized-feeder authenticate towards the monitoring server. For additional environment variable configurations, refer to [Adding Exchange Pairs](https://github.com/diadata-org/decentral-feeder/wiki/Adding-exchange-pairs) and [Watchdog environment variables](https://github.com/diadata-org/decentral-feeder/wiki/Enabling-watchdogs). E.g. Env file: ```bash theme={"system"} NODE_OPERATOR_NAME= CHAIN_ID= PRIVATE_KEY= DEPLOYED_CONTRACT= PUSHGATEWAY_URL= PUSHGATEWAY_USER= PUSHGATEWAY_PASSWORD= ``` Open a terminal in the `docker-compose` folder and start the deployment by running: ```bash theme={"system"} docker-compose up ``` ## Retrieve Deployed Contract Once the container is deployed with `DEPLOYED_CONTRACT` env variable empty the logs will display the deployed contract address in the following format: ```bash theme={"system"} │ time="2024-11-25T11:30:08Z" level=info msg="Contract pending deploy: 0xxxxxxxxxxxxxxxxxxxxxxxxxx." ``` Copy the displayed contract address (e.g., `0xxxxxxxxxxxxxxxxxxxxxxxxxx`) and stop the container with ```bash theme={"system"} docker rm -f ``` Check if the container is running correctly by viewing the logs. Run the following command: ```bash theme={"system"} docker-compose logs -f ``` Look for logs similar to the example below, which indicate a successful startup: ```bash theme={"system"} │ time="2024-10-29T13:39:35Z" level=info msg="Processor - Atomic filter value for market Binance:SUSHI-USDT with 20 trades: 0.7095307176575745." │ │ time="2024-10-29T13:39:35Z" level=info msg="Processor - Atomic filter value for market Simulation:UNI-USDC with 1 trades: 8.008539500390082." │ │ time="2024-10-29T13:39:35Z" level=info msg="Processor - Atomic filter value for market Crypto.com:USDT-USD with 5 trades: 0.99948." │ │ time="2024-10-29T13:39:35Z" level=info msg="Processor - filter median for MOVR: 9.864475653518195." │ │ time="2024-10-29T13:39:35Z" level=info msg="Processor - filter median for STORJ: 0.4672954012114179." │ │ time="2024-10-29T13:39:35Z" level=info msg="Processor - filter median for DIA: 0.9839597410694259." │ │ time="2024-10-29T13:39:35Z" level=info msg="Processor - filter median for WETH: 2626.9564003841315." ``` ## Remove Container (Optional) You can optionally cleanup the deployment once you're done by running: ```bash theme={"system"} docker rm -f ``` Verify the container has been removed: ```bash theme={"system"} docker ps -a ``` # Docker Run Source: https://www.diadata.org/docs/guides/general-guides/run-a-feeder/setting-up-the-node/docker-run Using the same [ENV variables](/how-to-guides/run-a-feeder/setting-up-the-node/docker-compose), run the feeder with `DEPLOYED_CONTRACT` initially empty: ```bash theme={"system"} docker run -d \ -e NODE_OPERATOR_NAME= \ -e PRIVATE_KEY= \ -e CHAIN_ID= \ -e DEPLOYED_CONTRACT= \ -e PUSHGATEWAY_URL= \ -e PUSHGATEWAY_USER= \ -e PUSHGATEWAY_PASSWORD= \ --name decentralized-feeder \ diadata/decentralized-feeder: ``` Retrieve the logs to get the deployed contract address. See the expected logs [here](/how-to-guides/run-a-feeder/setting-up-the-node/docker-compose#retrieve-deployed-contract). ```bash theme={"system"} docker logs ``` Stop the container, update the `DEPLOYED_CONTRACT` value, and restart: ```bash theme={"system"} docker stop docker run -d \ -e NODE_OPERATOR_NAME= \ -e PRIVATE_KEY= \ -e CHAIN_ID= \ -e DEPLOYED_CONTRACT= \ -e PUSHGATEWAY_USER= \ -e PUSHGATEWAY_PASSWORD= \ -e EXCHANGEPAIRS= \ --name decentralized-feeder \ diadata/decentralized-feeder: ``` Retrieve the logs to verify the container is running as expected ```bash theme={"system"} docker logs ``` For additional environment variable configurations, refer to [Adding Exchange Pairs](https://github.com/diadata-org/decentral-feeder/wiki/Adding-exchange-pairs) and [Watchdog environment variables](https://github.com/diadata-org/decentral-feeder/wiki/Enabling-watchdogs). # Kubernetes Source: https://www.diadata.org/docs/guides/general-guides/run-a-feeder/setting-up-the-node/kubernetes Create a Kubernetes `Deployment` manifest. Replace `` with the desired version: ```yaml theme={"system"} apiVersion: apps/v1 kind: Deployment metadata: name: decentralized-feeder namespace: default spec: replicas: 1 selector: matchLabels: app: decentralized-feeder template: metadata: labels: app: decentralized-feeder spec: containers: - name: feeder-container image: diadata/decentralized-feeder: env: - name: PRIVATE_KEY valueFrom: secretKeyRef: {key: private_key_secret, name: private_key_secret} - name: NODE_OPERATOR_NAME value: "" - name: DEPLOYED_CONTRACT value: "" - name: CHAIN_ID value: "" - name: EXCHANGEPAIRS value: "" - name: PUSHGATEWAY_URL value: "" - name: PUSHGATEWAY_USER value: "" - name: PUSHGATEWAY_PASSWORD value: "" - containerPort: 8080 ``` For additional environment variable configurations, refer to [Adding Exchange Pairs](https://github.com/diadata-org/decentral-feeder/wiki/Adding-exchange-pairs) and [Watchdog environment variables](https://github.com/diadata-org/decentral-feeder/wiki/Enabling-watchdogs). Run the feeder with `DEPLOYED_CONTRACT` set to an empty string (`""`) in the Kubernetes manifest. ```bash theme={"system"} kubectl apply -f deployment.yaml ``` Monitor the logs for the deployed contract address. See the expected logs [here](/how-to-guides/run-a-feeder/setting-up-the-node/docker-compose#retrieve-deployed-contract). ```bash theme={"system"} kubectl logs ``` Update the `DEPLOYED_CONTRACT` value in the manifest with the retrieved contract address. Apply the updated manifest: ``` kubectl apply -f deployment.yaml ``` # OracleRequestRecipient.sol Source: https://www.diadata.org/docs/guides/general-guides/smart-contracts/OracleRequestRecipient.sol ```solidity theme={"system"} // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.29; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IMessageRecipient } from "./interfaces/IMessageRecipient.sol"; import { IOracleTrigger } from "./interfaces/oracle/IOracleTrigger.sol"; import { TypeCasts } from "./libs/TypeCasts.sol"; import { IInterchainSecurityModule, ISpecifiesInterchainSecurityModule } from "./interfaces/IInterchainSecurityModule.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; using TypeCasts for address; contract OracleRequestRecipient is Ownable, IMessageRecipient, ISpecifiesInterchainSecurityModule, ReentrancyGuard { IInterchainSecurityModule public interchainSecurityModule; mapping(uint32 => mapping(bytes32 => bool)) public whitelistedSenders; address private oracleTriggerAddress; event ReceivedCall(address indexed caller, string key); event WhitelistUpdated( uint32 indexed origin, bytes32 indexed sender, bool status ); event OracleTriggerUpdated( address indexed oldAddress, address indexed newAddress ); event InterchainSecurityModuleUpdated( address indexed previousISM, address indexed newISM ); event TokensRecovered(address indexed recipient, uint256 amount); error EmptyOracleRequestData(); error OracleTriggerNotSet(); error SenderNotWhitelisted(bytes32 sender, uint32 origin); error UnauthorizedCaller(address caller); error InvalidSenderAddress(); error AlreadyWhitelisted(bytes32 sender, uint32 origin); error InvalidISMAddress(); error InvalidOracleTriggerAddress(); error InvalidReceiver(); error NoBalanceToWithdraw(); error TransferFailed(); function handle( uint32 _origin, bytes32 _sender, bytes calldata _data ) external payable virtual override nonReentrant { if (_data.length == 0) revert EmptyOracleRequestData(); if (oracleTriggerAddress == address(0)) revert OracleTriggerNotSet(); if (!whitelistedSenders[_origin][_sender]) revert SenderNotWhitelisted(_sender, _origin); address sender = address(uint160(uint256(_sender))); if (msg.sender != IOracleTrigger(oracleTriggerAddress).getMailBox()) { revert UnauthorizedCaller(msg.sender); } string memory key = abi.decode(_data, (string)); emit ReceivedCall(sender, key); IOracleTrigger(oracleTriggerAddress).dispatch{ value: msg.value }( _origin, sender, key ); } function addToWhitelist( uint32 _origin, bytes32 _sender ) external onlyOwner { if (_sender == bytes32(0)) { revert InvalidSenderAddress(); } if (whitelistedSenders[_origin][_sender]) { revert AlreadyWhitelisted(_sender, _origin); } whitelistedSenders[_origin][_sender] = true; emit WhitelistUpdated(_origin, _sender, true); } function removeFromWhitelist( uint32 _origin, bytes32 _sender ) external onlyOwner { if (_sender == bytes32(0)) { revert InvalidSenderAddress(); } whitelistedSenders[_origin][_sender] = false; emit WhitelistUpdated(_origin, _sender, false); } function setInterchainSecurityModule(address _ism) external onlyOwner { if (_ism == address(0)) { revert InvalidISMAddress(); } emit InterchainSecurityModuleUpdated( address(interchainSecurityModule), _ism ); interchainSecurityModule = IInterchainSecurityModule(_ism); } function setOracleTriggerAddress( address _oracleTrigger ) external onlyOwner { if (_oracleTrigger == address(0)) { revert InvalidOracleTriggerAddress(); } emit OracleTriggerUpdated(oracleTriggerAddress, _oracleTrigger); oracleTriggerAddress = _oracleTrigger; } receive() external payable {} function retrieveLostTokens(address receiver) external onlyOwner { if (receiver == address(0)) { revert InvalidReceiver(); } uint256 balance = address(this).balance; if (balance == 0) { revert NoBalanceToWithdraw(); } (bool success, ) = payable(receiver).call{ value: balance }(""); if (!success) { revert TransferFailed(); } emit TokensRecovered(receiver, balance); } function getOracleTriggerAddress() external view returns (address) { return oracleTriggerAddress; } } ``` # PushOracleReceiver.sol Source: https://www.diadata.org/docs/guides/general-guides/smart-contracts/PushOracleReceiver.sol ```solidity theme={"system"} // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.29; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IPushOracleReceiver } from "./interfaces/oracle/IPushOracleReceiver.sol"; import { IInterchainSecurityModule } from "./interfaces/IInterchainSecurityModule.sol"; import { ProtocolFeeHook } from "./ProtocolFeeHook.sol"; import { TypeCasts } from "./libs/TypeCasts.sol"; contract PushOracleReceiver is IPushOracleReceiver, Ownable { using TypeCasts for address; IInterchainSecurityModule public interchainSecurityModule; address payable public paymentHook; address public trustedMailBox; mapping(string => Data) public updates; error InvalidISMAddress(); modifier validateAddress(address _address) { if (_address == address(0)) revert InvalidAddress(); _; } function handle( uint32 _origin, bytes32 _sender, bytes calldata _data ) external payable override validateAddress(paymentHook) { if (msg.sender != trustedMailBox) revert UnauthorizedMailbox(); if (address(interchainSecurityModule) == address(0)) revert InvalidISMAddress(); (string memory key, uint128 timestamp, uint128 value) = abi.decode( _data, (string, uint128, uint128) ); if (updates[key].timestamp >= timestamp) { return; } Data memory newData = Data({ timestamp: timestamp, value: value }); updates[key] = newData; emit ReceivedMessage(key, timestamp, value); uint256 gasPrice = tx.gasprice; uint256 fee = ProtocolFeeHook(payable(paymentHook)).gasUsedPerTx() * gasPrice; bool success; { (success, ) = paymentHook.call{ value: fee }(""); } if (!success) revert AmountTransferFailed(); } function setInterchainSecurityModule( address _ism ) external onlyOwner validateAddress(_ism) { emit InterchainSecurityModuleUpdated( address(interchainSecurityModule), _ism ); interchainSecurityModule = IInterchainSecurityModule(_ism); } function setPaymentHook( address payable _paymentHook ) external onlyOwner validateAddress(_paymentHook) { emit PaymentHookUpdated(paymentHook, _paymentHook); paymentHook = _paymentHook; } function setTrustedMailBox( address _mailbox ) external onlyOwner validateAddress(_mailbox) { emit TrustedMailBoxUpdated(trustedMailBox, _mailbox); trustedMailBox = _mailbox; } function retrieveLostTokens( address receiver ) external onlyOwner validateAddress(receiver) { uint256 balance = address(this).balance; if (balance == 0) revert NoBalanceToWithdraw(); (bool success, ) = payable(receiver).call{ value: balance }(""); if (!success) revert AmountTransferFailed(); emit TokensRecovered(receiver, balance); } receive() external payable {} fallback() external payable {} } ``` # DIAOracleV2.sol Source: https://www.diadata.org/docs/guides/general-guides/smart-contracts/diaoraclev2.sol ```javascript theme={"system"} pragma solidity 0.7.4; contract DIAOracleV2 { mapping (string => uint256) public values; address oracleUpdater; event OracleUpdate(string key, uint128 value, uint128 timestamp); event UpdaterAddressChange(address newUpdater); constructor() { oracleUpdater = msg.sender; } function setValue(string memory key, uint128 value, uint128 timestamp) public { require(msg.sender == oracleUpdater); uint256 cValue = (((uint256)(value)) << 128) + timestamp; values[key] = cValue; emit OracleUpdate(key, value, timestamp); } function getValue(string memory key) external view returns (uint128, uint128) { uint256 cValue = values[key]; uint128 timestamp = (uint128)(cValue % 2**128); uint128 value = (uint128)(cValue >> 128); return (value, timestamp); } function updateOracleUpdaterAddress(address newOracleUpdaterAddress) public { require(msg.sender == oracleUpdater); oracleUpdater = newOracleUpdaterAddress; emit UpdaterAddressChange(newOracleUpdaterAddress); } } ``` # DIARandomOracle.sol Source: https://www.diadata.org/docs/guides/general-guides/smart-contracts/diarandomoracle.sol ```solidity theme={"system"} pragma solidity ^0.8.0; contract DIARandomOracle { struct Random { string randomness; string signature; string previousSignature; } mapping (uint256 => Random) public values; uint256 public lastRound = 0; address public oracleUpdater; event OracleUpdate(string key, uint128 value, uint128 timestamp); event UpdaterAddressChange(address newUpdater); constructor() { oracleUpdater = msg.sender; } function setRandomValue(uint256 _round, string memory _randomness,string memory _signature,string memory _previousSignature) public { require(msg.sender == oracleUpdater,"not a updater"); require(lastRound<_round, "old round"); lastRound = _round; values[_round] = Random(_randomness,_signature,_previousSignature); } function getValue(uint256 _round) external view returns ( Random memory) { return values[_round]; } function updateOracleUpdaterAddress(address newOracleUpdaterAddress) public { require(msg.sender == oracleUpdater,"not a updater"); oracleUpdater = newOracleUpdaterAddress; emit UpdaterAddressChange(newOracleUpdaterAddress); } function getRandomValueFromRound(uint256 _round ) external view returns (string memory){ return values[_round].randomness; } function getRandomValueFromRoundWithSignature(uint256 _round ) external view returns (Random memory){ return values[_round]; } function getLastRound()public view returns(uint256){ return lastRound; } } ``` # Build a Scraper Source: https://www.diadata.org/docs/guides/general-guides/tutorials Develop applications and sources on top of DIA using our open-source infrastructure. DIA has a dedicated infrastructure for testing various integrations into the system. In the following pages you can learn how it works. Start here: Or proceed directly to the scraper integration tutorials: # Add a New Exchange Scraper Source: https://www.diadata.org/docs/guides/general-guides/tutorials/add-a-new-exchange-scraper #### Add your scraper > Before you begin writing a scraper, please check if the exchange offers integration through WebSockets. If it does, implement the scraper using the WebSocket protocol instead of a RESTful API. To scrape data from an exchange data source, called "**MySource**" for instance, follow these steps: Create a new file in the directory `pkg/dia/scraper/exchange-scrapers/` with the filename `MySourceScraper.go`. To allow the platform to call your scraper, implement a scraper that conforms to the [APIScraper](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/APIScraper.go#L81) interface from the *scrapers* package: ```js theme={"system"} type APIScraper interface { io.Closer ScrapePair(pair dia.Pair) (PairScraper, error) FetchAvailablePairs() (pairs []dia.Pair, err error) Channel() chan *dia.Trade } ``` Start building your scraper by writing a function with the signature `NewMySourceScraper(exchangeName string) *MySourceScraper`. We suggest that this function calls a `mainLoop()` method in a go routine, constantly receiving trade information through the trade channel of *MySourceScraper* as long as the channel is open. In order to implement the interface, it is necessary to include the `ScrapePair` method, which returns a *MySourcePairScraper* for a specific pair, so our main collection method can iterate over all possible trading pairs. Note that *MySourcePairScraper* should respect and implement the [`PairScraper`](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/APIScraper.go#L103) interface Also, to ensure proper error handling and cleanup, it is recommended to include a method `Error()`, which returns an error as soon as the scraper's channel closes. Additionally, `Close()` and `cleanup()` methods should be included to handle the closing and shutting down of channels. > For a better understanding of how to set up a scraper, you can refer to the [`CoinBaseScraper.go`](https://github.com/diadata-org/diadata/blob/master/pkg/dia/scraper/exchange-scrapers/CoinBaseScraper.go) file, as it provides an example of an existing exchange scraper and its overall structure and logic. To make the scraper visible to the system, add a reference to it in `Config.go` in the *dia* package: ```js theme={"system"} const ( MySourceExchange = "MySource" ) ``` Add a case for your scraper in the switch statement in the `pkg/dia/scraper/exchange-scrapers/APIScraper.go` file: ```js theme={"system"} func NewAPIScraper(exchange string, key string, secret string) APIScraper { switch exchange { case dia.MySourceExchange: return NewMySourceScraper(key, secret, dia.MySourceExchange) } } ``` Finally, add exchange's pairs to `config/MySourceExchange.json` config: ```js theme={"system"} { "Coins": [ { "Exchange": "MySource", "ForeignName": "QUICK-USD", "Ignore": false, "Symbol": "QUICK" } ] } ``` #### Steps to run the scraper locally Modify the `build/Dockerfile-genericCollector` and `build/Dockerfile-pairDiscoveryService` files and add the following two lines before the `RUN go mod tidy` step: ```js theme={"system"} COPY . /diadata RUN go mod edit -replace github.com/diadata-org/diadata=/diadata ``` Build the necessary service containers by running the following commands: ```js theme={"system"} minikube image build -t diadata.pairdiscoveryservice:latest -f build/Dockerfile-pairDiscoveryService . minikube image build -t diadata.exchangescrapercollector:latest -f build/Dockerfile-genericCollector . ``` Create a manifest for the new exchange scraper by creating a new `mysource.yaml` file. You can refer to existing files for guidance or use the following template: ```yaml theme={"system"} apiVersion: "v1" kind: Pod metadata: name: "exchangescraper-mysource" spec: containers: - name: exchangescraper-mysource image: diadata.exchangescrapercollector:latest imagePullPolicy: Never command: ["collector"] args: ["-exchange=MySource", "-mode=current", "-pairsfile=true"] env: - name: USE_ENV value: "true" - name: POSTGRES_USER value: "postgres" - name: POSTGRES_PASSWORD value: "password" - name: POSTGRES_DB value: "postgres" - name: POSTGRES_HOST value: "postgres.default.svc.cluster.local" - name: INFLUXURL value: "http://influx.default.svc.cluster.local:8086" - name: INFLUXUSER value: "test" - name: INFLUXPASSWORD value: "testtest" - name: REDISURL value: "redis.default.svc.cluster.local:6379" - name: KAFKAURL value: "kafka.default.svc.cluster.local:9094" initContainers: - name: pairdiscovery-mysource image: diadata.pairdiscoveryservice:latest imagePullPolicy: Never command: ["pairDiscoveryService"] args: ["-exchange=MySource", "-mode=verification"] env: - name: USE_ENV value: "true" - name: POSTGRES_USER value: "postgres" - name: POSTGRES_PASSWORD value: "password" - name: POSTGRES_DB value: "postgres" - name: POSTGRES_HOST value: "postgres.default.svc.cluster.local" - name: INFLUXURL value: "http://influx.default.svc.cluster.local:8086" - name: INFLUXUSER value: "test" - name: INFLUXPASSWORD value: "testtest" - name: REDISURL value: "redis.default.svc.cluster.local:6379" - name: KAFKAURL value: "kafka.default.svc.cluster.local:9094" ``` Before running the manifest, create a new entry in the database for the new exchange: ``` kubectl exec -it deployment/postgres -- psql -U postgres -c "INSERT INTO exchange (exchange_id, "name", centralized, bridge, contract, blockchain, rest_api, ws_api, pairs_api, watchdog_delay, scraper_active) VALUES(gen_random_uuid(), 'MySource', true, false, '', '', '', 'wss://mysource.com', 'https://mysource.com', 300, true);" ``` Deploy the manifest using the following *kubectl* command: ``` kubectl create -f mysource.yaml ``` Hooray Your scraper should now be running. ### Exchanges Command CEX ```bash theme={"system"} pairDiscoveryService -exchange=ExchangeName -mode=verification go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && collector -exchange=ExchangeName -mode=current -pairsfile=true ``` DEX ```bash theme={"system"} go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && collector -exchange=ExchangeName -mode=current -pairsfile=true ``` ### Exchange Test ```bash theme={"system"} go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && collector -exchange=EXCHANGE_NAME -mode=current -pairsfile=true ``` Centralized: * Bitfinex: `go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && collector -exchange=Bitfinex -mode=current -pairsfile=true` * rm ./collector.go && cp /mnt/env-context/cmd/exchange-scrapers/collector/collector.go ./collector.go && go mod edit -replace github.com/diadata-org/diadata=/mnt/env-context && go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install -a && collector -exchange=Bitfinex -mode=current -pairsfile=true * Bittrex: `go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && collector -exchange=Bittrex -mode=current -pairsfile=true` * CoinBase: `go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && collector -exchange=CoinBase -mode=current -pairsfile=true` * MEXC: `go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && collector -exchange=MEXC -mode=current -pairsfile=true` Decentralized: * PlatypusFinance * Orca: `go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && SOLANA_URI_REST=https://try-rpc.mainnet.solana.blockdaemon.tech/ collector -exchange=Orca -mode=current -pairsfile=true` # Add a New Foreign Scraper Source: https://www.diadata.org/docs/guides/general-guides/tutorials/add-a-new-foreign-scraper Implement `ForeignScrapperer` interface at `pkg/dia/scraper/foreign-scrapers/Scrapper.go` file ```js theme={"system"} type ForeignScrapperer interface { UpdateQuotation() error GetQuoteChannel() chan *models.ForeignQuotation } ``` Add the scraper implementation a `MyForeignScraper.go` Golang file to `pkg/dia/scraper/foreign-scrapers/` folder and add the next implementations: ```js theme={"system"} func (scraper *MyForeignScraper) Pool() chan dia.Pool {} func (scraper *MyForeignScraper) Done() chan bool {} ``` Add a constructor for the scraper: ```js theme={"system"} func NewMyForeignScraper(exchange dia.Exchange) *MyForeignScraper {} ``` Add `MyForeignScraper` case at scraper file `cmd/foreignscraper/foreign.go`: ```js theme={"system"} switch *scraperType { case "MyForeignScraper": log.Println("Start scraping data") sc = scrapers.NewMyForeignScraper(ds) } ``` ## Foreign Command ```js theme={"system"} go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && foreignscraper -foreignType=ForeignType ``` ## Foreign Test ```js theme={"system"} go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && foreignscraper -foreignType=FOREIGN_TYPE ``` # Add a New Liquidity Scraper Source: https://www.diadata.org/docs/guides/general-guides/tutorials/add-a-new-liquidity-scraper Implement `LiquidityScraper` interface at `pkg/dia/scraper/liquidity-scrapers/ScraperInterface.go` file ```js theme={"system"} type LiquidityScraper interface { Pool() chan dia.Pool Done() chan bool } ``` Add a scraper implementation, `MyLiquidityScraper.go` file to `pkg/dia/scraper/liquidity-scrapers/` folder implement the functions: ```js theme={"system"} func (scraper *MyLiquidityScraper) Pool() chan dia.Pool {} func (scraper *MyLiquidityScraper) Done() chan bool {} ``` Add a constructor for the scraper: ```js theme={"system"} func NewMyLiquidityScraper(exchange dia.Exchange) *MyLiquidityScraper {} ``` ## Liquidity Command ```js theme={"system"} go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && liquidityScraper -exchange=ExchangeName ``` ## Liquidity Test ```js theme={"system"} go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && liquidityScraper -exchange=EXCHANGE_NAME ``` * PlatypusFinance: `go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && liquidityScraper -exchange=PlatypusFinance` * Orca: `go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && SOLANA_URI_REST=https://try-rpc.mainnet.solana.blockdaemon.tech/ liquidityScraper -exchange=Orca` # Additional Notes Source: https://www.diadata.org/docs/guides/general-guides/tutorials/additional-notes ## Access data endpoints and UIs ### Kubernetes Dashboard To start the Kubernetes Dashboard, use the following command: ```js theme={"system"} minikube dashboard --url=true --port=8083 ``` Once the dashboard service is ready, you can visit the web interface in your browser. ### Data stores Forward the ports of the data stores services to localhost: * PostgreSQL Database: `kubectl port-forward deployment/postgres 5432:5432` * Redis Cache: `kubectl port-forward deployment/redis 6379:6379` * InfluxDB Database: `kubectl port-forward deployment/influx 8086:8086` ### Other routes available after forward: * REST Server: port 8081 * GraphQL: port 1111, and [Web UI](http://localhost:1111/) * Kafka: port 8080, and [AKHQ Web UI](http://localhost:8080/) * Grafana: port 3000, and [Web UI](http://localhost:3000/) ## Contribute to DIA main package ```js theme={"system"} go mod edit -replace github.com/diadata-org/diadata=/mnt/env-context ``` ## Debug Influx writes To debug InfluxDB writes, just change points in batch to see more frequent writes to influx (`pkg/model/db.go`): ```js theme={"system"} influxMaxPointsInBatch = 10 ``` ## Use a custom pre-populated image data A `.testenv.local` file at root folder is required to pull private images from Docker: ```js theme={"system"} data_docker_registry=docker.io data_docker_username=my_user data_docker_password="my_password" data_docker_email=my_email@domain.com ``` Change image of pre-populated data from [`deployments/k8s-yaml/data-postgres-prepopulated.yaml`](https://github.com/diadata-org/diadata/blob/74070895a72a0add703c8268e31870a7f63d3e4b/deployments/k8s-yaml/data-postgres-prepopulated.yaml#L20) file # Development Cluster Stack Source: https://www.diadata.org/docs/guides/general-guides/tutorials/development-cluster-stack ### Data * Influx * PostgreSQL * Redis * Kafka ### Services * Filterblock * Tradesblock ### Scrapers * Foreign * Liquidity * Collector ### Development Specific * Ping jobs * Prepare job (when install does not depend on external image) ### Additional * Grafana * Loki * Influx ### Helms being tested * DIA Helm chart: DIA platform * Influx: Timeseries db * Grafana: Dashboard for monitoring * Loki: Logging the services * [Jaeger Tracing](https://www.jaegertracing.io/): Tracing system for services * kube-prometheus: Monitoring Minikube cluster # DIA Test‐Space with Docker Compose Source: https://www.diadata.org/docs/guides/general-guides/tutorials/dia-test-space-with-docker-compose Developing, Testing, and Building the DIA platform with Docker Compose ## Prepare ```js theme={"system"} # Start data store services ( cd deployments/local/exchange-scraper docker compose -f docker-compose.yml up --build --force-recreate -d ) # Define env variables needed export USE_ENV=true export INFLUXURL=http://localhost:8086 export INFLUXUSER=test export INFLUXPASSWORD=testtest export POSTGRES_USER=postgres export POSTGRES_PASSWORD=password export POSTGRES_HOST=localhost export POSTGRES_DB=postgres export REDISURL=localhost:6379 # Set config directory export DIA_CONFIG_DIR=./config # Set local directory as Go dependency go mod edit -replace "github.com/diadata-org/diadata=$(pwd)" cmd/exchange-scrapers/collector/go.mod ``` ## Scrapers ### CEX (Kraken as example) #### Prepare ```js theme={"system"} # Initialize the exchange and blockchain metadata go run ./cmd/services/blockchainservice/main.go # Prepare pairs metadata go run ./cmd/services/pairDiscoveryService/main.go -exchange=Kraken -mode=verification ``` #### Run the scraper ```js theme={"system"} go run ./cmd/exchange-scrapers/collector/collector.go -exchange=Kraken -mode=storeTrades ``` ### DEX (CurveFi as example) #### Prepare ```js theme={"system"} # Set needed RPC variables export ETHEREUM_URI_REST=https://rpc.ankr.com/eth export ETHEREUM_URI_WS=wss://eth-mainnet.g.alchemy.com/v2/7X9hL_lpF-Utavuv1aT49SWkWu9oYZTq # Prepare the assets metadata go run ./cmd/assetCollectionService/main.go -source=assetlists -secret=eth_assets -caching=true go run ./cmd/assetCollectionService/main.go -source=assetlists -secret=non_eth_assets -caching=true go run ./cmd/assetCollectionService/main.go -source=assetlists -secret=fiat_assets -caching=true go run ./cmd/assetCollectionService/main.go -source=Curvefi -caching=true # Prepare and populate pools go run ./cmd/liquidityScraper/main.go -exchange=Curvefi ``` #### Run the scraper ```js theme={"system"} go run ./cmd/exchange-scrapers/collector/collector.go -exchange=Curvefi -mode=storeTrades ``` ## Clean ```js theme={"system"} unset USE_ENV unset INFLUXURL unset INFLUXUSER unset INFLUXPASSWORD unset POSTGRES_USER unset POSTGRES_PASSWORD unset POSTGRES_HOST unset POSTGRES_DB unset REDISURL unset DIA_CONFIG_DIR unset ETHEREUM_URI_REST unset ETHEREUM_URI_WS ``` ### Advanced usage #### Access services between Docker Composes On prepare step if you want to connect services between other Compose files, create a `deployments/local/exchange-scraper/docker-compose.override.yml` file: ```js theme={"system"} version: "3.3" services: influxdb: networks: - dia-bridge networks: dia-bridge: driver: bridge ``` And instead of run the services using this command: ```js theme={"system"} # Start data store services ( cd deployments/local/exchange-scraper docker compose -f docker-compose.yml -f docker-compose.override.yml up --build --force-recreate -d ) ``` Now in other Compose file just use like this: ```yaml theme={"system"} version: "3" networks: exchange-scraper_dia-bridge: external: true services: service-x: image: service-x-image networks: - exchange-scraper_dia-bridge ``` Now in Docker context, `service-x` can resolve the `http://influxdb:8086` hostname # DIA Test‐Space with Minikube Source: https://www.diadata.org/docs/guides/general-guides/tutorials/dia-test-space-with-minikube Developing, Testing, and Building the DIA platform with Minikube ## Preparing the local files ```bash theme={"system"} git clone git@github.com:diadata-org/diadata.git cd diadata ``` ## Preparing a local cluster > Note: Minikube runs on a virtualization layer on the host. The [docker](https://minikube.sigs.k8s.io/docs/drivers/docker/) driver is usually the recommended and default option and should be seen as a requirement. For other supported drivers, please refer to [Minikube's official documentation](https://minikube.sigs.k8s.io/docs/drivers/). You can also check [Minikube's handbook](https://minikube.sigs.k8s.io/docs/handbook/) for advanced command usage. First, install dependencies: [Minikube](https://github.com/kubernetes/minikube#installation) and [Docker](https://www.docker.com/). Next, start the development environment by running the following command to start a Minikube node: ```bash theme={"system"} ./testenv.sh start ``` Build the necessary service containers by executing the following commands: ```bash theme={"system"} ./testenv.sh build ``` Run the installation script to set up the necessary services (Redis cache, Kafka streams, PostgreSQL, and InfluxDB databases) by executing the following commands: ```bash theme={"system"} ./testenv.sh install ``` Now that you have the local cluster running, you are ready to start. Import the test data from the diadata snapshot service. This requires the default structure to be empty and created inside the postgres server. The script will automatically download the snapshot, install it and remove the downloaded snapshot again: ```bash theme={"system"} ./testenv.sh snapshot ``` ## Other useful commands To stop the cluster: ```bash theme={"system"} ./testenv.sh stop ``` To delete the cluster node: ```bash theme={"system"} ./testenv.sh delete ``` # Fetch Price Data Source: https://www.diadata.org/docs/guides/how-to-guides/fetch-price-data Learn how to fetch token price data from DIA's decentralized oracle network. DIA offers multiple ways to access price data from oracles. The methods differ based on the oracle type (Push or Pull) and whether you're consuming the oracle through the Nexus or Lumina stack. ## Oracle Access Methods The how-to guides are specifically for EVM-compatible chains. For non-EVM chains (like Stacks, Alephium, etc.), Please refer to the [chain-specific guides](/guides/chain-guides-overview) for chain-specific implementation details. Access Push-based oracles through the Lumina Stack that automatically update price feeds at fixed intervals or when price deviations exceed thresholds. Access Pull-based oracles through the Lumina Stack that fetch price data on-demand when your contract requests it. Direct value retrieval using the standard DIA oracle interface through the Nexus Stack. Simple method for getting current price values. ## When to Use Each Method The method to use depends on the deployed oracle contract you're planning to consume on each chain through the available stacks (Nexus or Lumina). We specify the methods available for each chain in their dedicated [chain-specific guide](/guides/chain-guides-overview). # request Method Source: https://www.diadata.org/docs/guides/how-to-guides/fetch-price-data/pull-based-oracles [Pull (or also known as Request Based Oracle) oracle](/reference/architecture/data-delivery#pull-model) model enables the creation of requests for asset prices on a source blockchain. These requests are sent through a mailbox on the current chain and ultimately delivered to the DIA chain, which retrieves and delivers the required price data. ## How It Works ### Request Creation A request is made from the source chain for an asset symbol whose price is required (e.g. ETH/USD) which then passes through the chain's mailbox to be then delivered to the destination chain. You can check the available contract address on testnet based on the destination chain you're reading from [here](/guides/chain-guides-overview). The request body is formatted as follows in JavaScript: ```javascript theme={"system"} const key = "ETH/USD"; // Assuming key is an address or a bytes32 value const requestBody = abiCoder.encode( ["string"], // Types of the parameters [key] // Values to encode ); ``` And this is how it is formatted in Solidity: ```solidity theme={"system"} bytes memory requestBody = abi.encode("WBTC/USD"); ``` ### Message Delivery Process Once a request is created, it is transmitted to the Hyperlane mailbox. The message is then relayed to the `OracleRequestRecipient` contract , where the price data is fetched from the Oracle Metadata Contract. ### Response and Callback Upon receiving the request, the DIA chain initiates a transaction to deliver the message back to the end contract on the source chain. The recipient contract on the source chain must implement the IMessageRecipient interface, which includes a handle function that will receive the price quotation. ## Making a Price Request ### Solidity ```solidity theme={"system"} // SPDX-License-Identifier: MIT pragma solidity 0.8.29; import { RequestOracle } from "@dia-data/contracts-spectra/RequestOracle.sol"; contract PullOracleSample { address public constant DIA_RECIPIENT = 0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0; // DIA testnet uint32 public constant DESTINATION_DOMAIN = 100640; // DIA testnet chain id RequestOracle public diaOracle; string public key = "BTC/USD"; constructor(address _requestOracle) { diaOracle = RequestOracle(payable(_requestOracle)); } /* * To calculate the request fee on each chain, you can check the script below: * https://github.com/diadata-org/Spectra-interoperability/blob/main/contracts/scripts/sendTestMessage.mjs#L111 */ function requestPrice(string memory key) external payable { diaOracle.request{value: msg.value}( DIA_RECIPIENT, DESTINATION_DOMAIN, abi.encode(key) ); } function getPrice() external view returns ( uint128 timestampOflatestPrice, uint128 latestPrice ) { (timestampOflatestPrice, latestPrice) = diaOracle.updates(key); } } ``` ### JavaScript In this example, we’ll be sending an ETH/USD price request from Base Sepolia to DIA Lasernet. Start by cloning the `Spectra Interoperability` repository to your local machine and switching to the `deploy`branch: ```bash theme={"system"} git clone https://github.com/diadata-org/Spectra-interoperability.git git checkout deploy ``` Then install the node packages and compile the contracts using hardhat: ```bash theme={"system"} npm install npx hardhat compile ``` Next, `cd contracts` folder, and export your wallet's private key in your terminal as follows: ```javascript theme={"system"} export PRIVATE_KEY=[paste_here] ``` Now, the `sendMessage.mjs` script will trigger a `request` transaction to fetch the latest price of ETH/USD from DIA lasernet. To run the script: ```bash theme={"system"} npx hardhat run scripts/sendMessage.mjs --network base_sepolia ``` You can also run the script on other networks by changing the value passed to the `--network` flag (e.g. `--network sepolia`). Once the price update takes place on the destination chain, which you can track from the [hyperlane explorer](/reference/cross-chain-messaging), you can check the txn logs for the `ReceivedMessage`event on the pull oracle contract or call the `updates`function. The price returned is around 2,718\$! # updates Method Source: https://www.diadata.org/docs/guides/how-to-guides/fetch-price-data/push-based-oracles The [Push Oracle ](/reference/architecture/data-delivery#push-model)model enables contracts to receive real-time updates based on predefined criteria such as fixed intervals, specific price deviations, or a combination of both. This design provides flexibility and efficiency for decentralized applications needing accurate and timely data. ### Usage The Oracle maintains updates as a mapping, where each key maps to a Data struct containing the latest timestamp and value. The `updates` mapping is a key-value store where: * Key: A unique identifier, typically a string, representing the asset or data type (e.g., DIA/USD, BTC/USD). * Value: A Data struct containing: * key: The identifier of the data entry (redundant for reference but useful for integrity checks). * timestamp: The timestamp of the latest update. * value: The most recent value associated with the key. Here's an example of a `DIAOracleSample` contract that consumes the `BTC/USD` price feed: ```solidity theme={"system"} pragma solidity ^0.8.13; import { PushOracleReceiver } from "@dia-data/contracts-spectra/PushOracleReceiver.sol"; contract DIAOracleSample { PushOracleReceiver public diaOracle; string public key = "BTC/USD"; constructor(address _oracle) { diaOracle = PushOracleReceiver(payable(_oracle)); } function getPrice() external view returns ( uint128 timestampOflatestPrice, uint128 latestPrice ) { (timestampOflatestPrice, latestPrice) = diaOracle.updates(key); } } ``` To deploy the contract, provide the oracle address for the destination chain you're reading from. You can find the contract addresses in the [chain-specific guides](/guides/chain-guides-overview). As an example, if you want to access the oracle on Ethereum Sepolia, you'll pass the Push Oracle address: [0x9bb71344Ed950F9cFD85EE1C7258553B01d95FA0](https://sepolia.etherscan.io/address/0x9bb71344ed950f9cfd85ee1c7258553b01d95fa0) to the constructor above. You can also change the key to any of the supported assets (e.g. `DIA/USD`). # getValue Method Source: https://www.diadata.org/docs/guides/how-to-guides/fetch-price-data/solidity 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. ## Using DIAOracleV2 Interface The following is an example of how to retrieve price value from a standard DIA oracle. For the purpose of this example, we will be using the following demo oracle on Ethereum: [0xCD5F...f3cB](https://sepolia.etherscan.io/address/0xcd5f78206ca1ff96ff4c043c61a2299b2febf3cb). Access any DIA oracle smart contract. Call `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. The response of the call contains four values: 1. The current asset's price in USD with a fix-comma notation of 8 decimals. 2. The [UNIX timestamp](https://www.unixtimestamp.com/) of the last oracle update. ```solidity theme={"system"} pragma solidity ^0.8.13; interface IDIAOracleV2 { function getValue(string memory) external view returns (uint128, uint128); } contract DIAOracleSample { address diaOracle; constructor(address _oracle) { diaOracle = _oracle; } function getPrice(string memory key) external view returns ( uint128 latestPrice, uint128 timestampOflatestPrice ) { (latestPrice, timestampOflatestPrice) = IDIAOracleV2(diaOracle).getValue(key); } } ``` Find the detailed description of the functions and how to run tests on our GitHub page: ## Using Solidity Library DIA has a dedicated Solidity library to facilitate the integration of DIA oracles in your own contracts. The library consists of two functions, `getPrice` and `getPriceIfNotOlderThan`. ### Access the library ```solidity theme={"system"} import { DIAOracleLib } from "./libraries/DIAOracleLib.sol"; ``` ### Methods #### getPrice ```solidity theme={"system"} function getPrice( address oracle, string memory key ) public view returns (uint128 latestPrice, uint128 timestampOflatestPrice); ``` Returns the price of a specified asset along with the update timestamp. 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" | Return Values: | Name | Type | Description | | ---------------------- | ------- | ------------------------------------------------------ | | latestPrice | uint128 | Price of the specified asset returned by the DIAOracle | | timestampOflatestPrice | uint128 | The update timestamp of the latest price | #### getPriceIfNotOlderThan ```solidity theme={"system"} function getPriceIfNotOlderThan( address oracle, string memory key, uint128 maxTimePassed ) public view returns (uint128 price, bool inTime) { ``` Checks if the oracle price is older than `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 | Return Values: | 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` | Find a detailed integration example and how to run a test on our GitHub page: ### Sample contract ```solidity theme={"system"} pragma solidity ^0.8.13; import { DIAOracleLib } from "./libraries/DIAOracleLib.sol"; contract DIAOracleSample { error PriceTooOld(); address diaOracle; constructor(address _oracle) { diaOracle = _oracle; } function getPrice( string memory key ) external view returns (uint128 latestPrice) { (latestPrice, ) = DIAOracleLib.getPrice(diaOracle, key); } function checkPriceAge( string memory key, uint128 maxTimePassed ) external view returns (uint128 price) { bool inTime; (price, inTime) = DIAOracleLib.getPriceIfNotOlderThan( diaOracle, key, maxTimePassed ); if (!inTime) revert PriceTooOld(); } } ``` # Fund your Oracle Source: https://www.diadata.org/docs/guides/how-to-guides/fund-the-oracle Oracles require a constant stream of updates, thus gas costs reimbursement for updates is needed. To achieve this, all oracles deployed by DIA have a dedicated wallet which calls oracle contracts for updates. This is referred to as the "gas wallet". ## How it works Each oracle deployed by DIA has a gas wallet, which is the only entity capable of calling for an oracle update. The wallet initiates the transaction to import a new value into the oracle smart contract, based on the [data feed's update parameters](/guides/methodologies/data-processing/update-triggers) (that have been previously configured). For the gas wallet to perform new oracle contract updates, it must have a sufficient balance of the blockchain's native token to cover the transaction's gas costs. The gas wallet can be funded with a one-time lump sum, allowing it to keep updating for a while. However, monitoring the gas wallet's balance is necessary to ensure continuity in the oracle's operations. DIA has set up internal gas wallet balance trackers. We recommend protocols to actively monitor them to ensure that the wallet balance remains sufficient for pushing new oracle updates. ## Estimate Updates Count for Oracles DIA has a dedicated endpoint for asset historical updates count to help you estimate the number of oracle updates. This allows to foresee potential gas costs that would be required for running the oracle. ## Get historical Oracle updates count `GET` `https://api.diadata.org/v1/assetUpdates/:blockchain/:address/:deviation/:updateFreq` The endpoint returns information on the asset deviation and updates count if it was used in the oracle. It takes price change (deviation) and oracle's ticker frequency as the main parameters to determine estimated updates count based on historical data. *Example:* [*https://api.diadata.org/v1/assetUpdates/Ethereum/0x0000000000000000000000000000000000000000/20/120*](https://api.diadata.org/v1/assetUpdates/Ethereum/0x0000000000000000000000000000000000000000/20/120) By default it will return data for the last 24h but you can configure the timeframe with starttime and endtime parameters. See example below: [https://api.diadata.org/v1/assetUpdates/Ethereum/0x0000000000000000000000000000000000000000/20/120?starttime=1661736336\&endtime=1661761536](https://api.diadata.org/v1/assetUpdates/Ethereum/0x0000000000000000000000000000000000000000/20/120?starttime=1661736336\&endtime=1661761536) #### Path Parameters | Name | Type | Description | | ------------ | ------- | ------------------------------------------------------------------------------------------------------------- | | blockchain\* | String | A valid blockchain from GET /v1/blockchains, e.g., Bitcoin. | | address\* | String | A valid asset address from GET /v1/token/:symbol, e.g., 0x000000000000000000000000000000000000000 for BTC. | | deviation\* | Integer | Deviation measure in per mille, e.g. 20 will result in 2% deviation | | updateFreq\* | Integer | Oracle's price feed ticker frequency in seconds, e.g. 120 will calculate asset price in 2 minute trade blocks | | starttime | Integer | Unix timestamp setting the start of the return array | | endtime | Integer | Unix timestamp setting the end of the return array | # Generate Randomness Source: https://www.diadata.org/docs/guides/how-to-guides/generate-randomness This guide shows you how to use the randomness oracle within your smart contract and get verifiable random numbers available to your dApp! You can find deployed Randomness oracle contracts for each chain [here](/guides/chain-guides-overview). For EVM chains, follow the instructions in the Solidity guide: ## Learn more # Solidity Source: https://www.diadata.org/docs/guides/how-to-guides/generate-randomness/solidity DIA uses the drand.love public randomness beacon, and updates its oracle with round number, randomness and signature. Anyone can access published random values via round ID. ```json theme={"system"} { "round": 1597683, "randomness": "24138936fcbf7fc3951c928158be6998cee3af622142d0790333608d17a5c5f6", "signature": "8c04905c0adf34f1fb007915d9ccc7d07b97305fc63952726f9367c87f36ab687c5e190c151f6ac4d760a9e009fc54230adb8513885449d649a229bc727be9ff347bdbce1c609cebf993b6ae57133fbcf23f96b15dbd3510cb5f2ade6b30b647", "previous_signature": "ada42197a2db89866da4c44348f77f7868e41e961ec32e636b912d43c625386afae9e54944ac573047dbd227ee495b52059586c8d8cd0edfe18cc15ca0666a66651da1d62b12af2d0fac19735bed9298690a593571965c3ad7c7b11947e76ec0" } ``` The DIA randomness smart contract is structured as follows ```solidity theme={"system"} pragma solidity ^0.8.0; contract DIARandomOracle { struct Random { string randomness; string signature; string previousSignature; } mapping (uint256 => Random) public values; uint256 public lastRound = 0; address public oracleUpdater; event OracleUpdate(string key, uint128 value, uint128 timestamp); event UpdaterAddressChange(address newUpdater); constructor() { oracleUpdater = msg.sender; } function setRandomValue(uint256 _round, string memory _randomness, string memory _signature, string memory _previousSignature) public { require(msg.sender == oracleUpdater,"not a updater"); require(lastRound<_round, "old round"); lastRound = _round; values[_round] = Random(_randomness, _signature, _previousSignature); } function getValue(uint256 _round) external view returns (Random memory) { return values[_round]; } function updateOracleUpdaterAddress(address newOracleUpdaterAddress) public { require(msg.sender == oracleUpdater,"not a updater"); oracleUpdater = newOracleUpdaterAddress; emit UpdaterAddressChange(newOracleUpdaterAddress); } function getRandomValueFromRound(uint256 _round) external view returns (string memory) { return values[_round].randomness; } function getRandomValueFromRoundWithSignature(uint256 _round) external view returns (Random memory) { return values[_round]; } function getLastRound() public view returns(uint256) { return lastRound; } } ``` Users can call `getLastRound()`to obtain the ID of the latest published round. To obtain the randomness of a certain round, users can call `getRandomValueFromRound(uint256 _round)`using the obtaines round ID. The signature can also be requested by calling `getRandomValueFromRoundWithSignature(uint256 _round)`. Please be aware that you should always let all inputs commit before any randomness is used in a later round. For example, if you build a lottery, only call randomness after the last participant has committed their stake. To show this in an example, we will build a simple dice game.