> ## Documentation Index
> Fetch the complete documentation index at: https://www.diadata.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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](/docs/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 })
    )
)
```

***

## 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:

<Card title="DIA Oracle Grants Program | Apply Now" href="https://www.diadata.org/blockchain-oracle-grant/" horizontal />

***

## 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:

<CardGroup>
  <Card title="Request Custom Oracle" href="/docs/guides/how-to-guides/request-a-custom-oracle" icon="angle-right" iconType="solid" horizontal />
</CardGroup>

## Support

For developer assistance, connect with the DIA team directly on [Discord](https://discord.gg/ZvGjVY5uvs) or [Telegram](https://t.me/diadata_org).
