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

ChainAddress
Mainnet285zrkZTPpUCpjKg9E3z238VmpUBQEAbESGsJT6yX7Rod
Testnet216wgM3Xi5uBFYwwiw2T7iZoCy9vozPJ4XjToW74nQjbV

Oracle configuration

Pricing MethodologyVWAPIR
Deviation (%) & Refresh Frequency0.2% and 120 seconds
Heartbeat10mins

Asset feeds

Asset TickergetValue(key)Asset Markets
BTCBTC/USDBTC markets
USDCUSDC/USDUSDC markets
ETHETH/USDETH markets
WBTCWBTC/USDWBTC markets
USDTUSDT/USDUSDT markets
ALPHALPH/USDALPH markets
AYINAYIN/USDAYIN markets

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:

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

Support

For developer assistance, connect with the DIA team directly on Discord or Telegram.

Developers seeking other specialized, production-grade oracle with tailored price feeds and configurations can initiate the request by contacting the DIA BD Team via Telegram.