Skip to main content
DIA 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

Oracle Configuration

Pricing MethodologyMAIR
Deviation (%) & Refresh Frequency0.5% and 120 seconds
Heartbeat24h

Available Asset Feeds

Mainnet

Testnet


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 or the 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.
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.

Adapter contracts

To consume price data from our oracle, you can use the adapter smart contract located at the adapter address for each asset. This will allow you to access the same methods on the AggregatorV3Interface such as getRoundData & latestRoundData. You can learn more here. This is a sample contract for consuming the $SOMI price feed:
// 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 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 on Somnia testnet.

Oracle Details

ChainContractAddress
TestnetPush Oracle0xFb1462A649A92654482F8E048C754333ad85e5C0
TestnetPull Oracle0x4E0BD1602f2FeC717E751F24f4e8178bfb9f5dc6

Oracle Configuration

Pricing MethodologyMedian
Deviation (%) & Refresh Frequency1% and 120 seconds
Heartbeat24h

Asset Feeds

Asset Tickerupdates(key)Asset Markets
ETHETH/USDETH Markets
BTCBTC/USDBTC Markets
DIADIA/USDDIA Markets
USDCUSDC/USDUSDC Markets

Additional Details

You can find the contract addresses for the Somnia bridge’s components on testnet below:

How to Access Data

To consume price data, select the method required for your dapp. The updates method is available for Push-based oracles and request method for Pull-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 are sample contracts that consume the BTC/USD price feed through both methods:

updates Method

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);
    }
}

request Method

// 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);
    }
}

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:

DIA Oracle Grants Program | Apply Now

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 or Telegram.