Skip to main content

How the adapter works

Each adapter instance wraps a single DIA oracle and one asset key (e.g. BTC/USD). When your contract calls latestRoundData(), the adapter reads the latest value from DIA’s oracle via getValue() and maps it onto Chainlink’s round format:
  • answer: the latest DIA price, returned with 18 decimals by default.
  • updatedAt: the timestamp of DIA’s most recent update.
  • roundId : set to the current block.number.

Before and after

In practice, only the feed address changes.
solidity

Migrate in three steps

1

Get the DIA oracle address and asset key

From your network’s page in the chain-specific guides, copy the DIA oracle contract address and the asset key you need (e.g. BTC/USD).
2

Deploy or obtain the adapter

Deploy DiaAssetSpecificCallingConvention(diaOracleAddress, description, pairKey). The repo ships a Hardhat deploy script (scripts/deployAdapter.ts). One adapter is deployed per asset.
3

Swap the address

Replace the Chainlink feed address in your contract with the adapter address. No other code changes are required.

Availability

The adapter works on any network where a DIA oracle is deployed (see the supported chains). Because it is asset-specific, a separate adapter is deployed for each price feed you need.

Reference

Chainlink Adapter