DIA Nexus Documentation
  • Nexus Overview
  • Intro to Nexus
    • How it works
    • Nexus vs. Lumina
    • Integrated Chains
  • Data products
    • Token Price Feeds
    • RWA Price Feeds
    • Randomness
    • Fair-value Feeds
  • How-to Guides
    • Fetch Price Data
      • Solidity
      • Vyper
      • Demo Oracles
      • Chain-specific Guide
        • Aleph Zero
        • Alephium
        • Edu Chain
        • Hydration
        • Kadena
        • LUKSO
        • Somnia
        • Stacks
        • Superseed
        • XRP Ledger (XRPL)
    • Generate Randomness
      • Solidity
      • WASM
      • Demo Oracles
      • Chain-specific Guide
        • Alephium
    • Migrate to DIA
    • Fund the Oracle
    • Build a Scraper
      • Development Cluster Stack
      • DIA Test‐Space with Docker Compose
      • DIA Test‐Space with Minikube
      • Add a new exchange scraper
      • Add a new foreign scraper
      • Add a new liquidity scraper
      • Additional notes
  • Request a Custom Oracle
  • Reference
    • Architecture
      • Data sourcing
      • Data computation
      • Data delivery
    • APIs
      • Token prices
        • RestAPI
          • Request Samples
        • GraphQL
          • Request Samples
      • RWA prices
    • Pricing Methodologies
      • IR: Interquartile Range Filter
      • MAIR: Moving Average with Interquartile Range Filter
      • VWAP: Volume Weighted Average Price
      • VWAPIR: Volume Weighted Average Price with Interquartile Range Filter
      • LST fair price
    • Data Sources
      • CEXes Data
      • DEXes Data
    • Smart Contracts
      • DIAOracleV2.sol
      • DIARandomOracle.sol
    • Randomness Protocol
  • Resources
    • Audits
    • Community & Support
    • Security Bounty Program
    • Research
      • Return Rates in Crypto Farming
      • Crypto Volatility Index
      • Compounded Rates
      • Polkadot Medianizer
    • T&C
      • Licence Agreement
      • Contributor Covenant Code of Conduct
      • Disclaimer
Powered by GitBook
On this page
  • Oracle details
  • Oracle configuration
  • Asset feeds
  • How to access data​
  • Support
Export as PDF
  1. How-to Guides
  2. Fetch Price Data
  3. Chain-specific Guide

Alephium

dApps built on Alephium can leverage DIA oracles to access up-to-date asset price information.

PreviousAleph ZeroNextEdu Chain

Last updated 1 month ago

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

Testnet

Oracle configuration

Pricing Methodology

Deviation (%) & Refresh Frequency

0.2% and 120 seconds

Heartbeat

10mins

Asset feeds

Asset Ticker
getValue(key)
Asset Markets

BTC

BTC/USD

USDC

USDC/USD

ETH

ETH/USD

WBTC

WBTC/USD

USDT

USDT/USD

ALPH

ALPH/USD

AYIN

AYIN/USD

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.

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

How to access data

Below is the DIAOracle contract implementation in :

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

Developers seeking other specialized, production-grade oracle with tailored price feeds and configurations can initiate the request by .

DIA
​
Ralph
Discord
Telegram
contacting the DIA BD Team via Telegram
285zrkZTPpUCpjKg9E3z238VmpUBQEAbESGsJT6yX7Rod
216wgM3Xi5uBFYwwiw2T7iZoCy9vozPJ4XjToW74nQjbV
VWAPIR
BTC markets
USDC markets
ETH markets
WBTC markets
USDT markets
ALPH markets
AYIN markets