DomFiDomination Finance

Oracle Feeds

Oracle contract addresses, how to discover live pairs, and how to read the dominance price from the SDK or a contract.

Addresses

ContractRoleBase MainnetBase Sepolia
DomfiOracleStores the latest published price for every pair.0x1aB9c3A2E1A09f2D06bf4A75d1721c7e113B8D4D0x47959A2f92335587cf2956dA450b956dA6ca3A84
DomfiVerifierChecks that every price is signed by a registered signer.0xdF2B2F7eb9740bFDa2555467fc3DD277608321880xF1BD03dC32a6c62BE9F817b6AeA6cDae3445bBdf
DomfiPriceRouterTakes price requests from trading and routes them to the price upkeep.0x9c726Be74B4cFa97c8DCF3c7111A231cd2014cec0x62b39Fc1C8a402fbb3A98E9f52961c3Cc61b8681
DomfiPrivatePriceUpKeepReceives signed prices and settles the orders waiting on them.0x8cA1E038feDd8FC81bda98b072D307911ca0c9b90xE544c8e26441635E68D3Bc5F4e2F66d621eC84e0
DomfiPairsStorageMaps each pair index to its feed ID.0x444079DDCaFd4feE3812E2fF79c5F74a1F4f9Be10x3D5EE28985F8C382cCB112B9054f89d054b6f23E

All other contracts are on Contract Addresses.

Discovering Pairs

Every pair has a pair index and a feed ID. The pair index identifies the market in trading calls; the feed ID identifies its price on the oracle. Read the current list instead of hardcoding it:

import { createDomfiClient } from "@domfi/sdk";

const domfi = createDomfiClient({ chain: "mainnet" });
const { data: markets } = await domfi.api.markets.list();

for (const m of markets) {
  console.log(m.priceAsset, m.pairIndex, m.feedId, m.status);
  // e.g. BTCDOM 0 0x425443444f4d00…00 active
}

A pair is live when its status is active.

Without the SDK: GET https://api.domination.finance/api/v2/markets. Each entry has price_asset, pair_index, feed_id, is_listed, is_paused and is_done; a pair is live when it is listed and neither paused nor done.

From a contract

interface IDomfiPairsStorage {
    function pairsCount() external view returns (uint16);
    function isPairIndexListed(uint16 pairIndex) external view returns (bool);
    function pairFeed(uint16 pairIndex) external view returns (bytes32);
}

// for (uint16 i = 0; i < pairs.pairsCount(); i++) {
//     if (!pairs.isPairIndexListed(i)) continue; // removed pair
//     bytes32 feed = pairs.pairFeed(i);
// }

On-chain, a removed pair is no longer listed. Whether trading is paused is read from the API above.

Pair index 0 is BTCDOM. Look up every other index from the list above.

Reading the Price

From a contract

DomfiOracle is keyed by feed ID. Read the pair's feed from DomfiPairsStorage, then its value from DomfiOracle:

interface IDomfiPairsStorage {
    function pairFeed(uint16 pairIndex) external view returns (bytes32);
}

interface IDomfiOracle {
    function getValue(bytes32 feed)
        external
        view
        returns (int192 value, uint64 timestamp, uint256 publishId);
}
import { createPublicClient, http } from "viem";
import { base } from "viem/chains";

const client = createPublicClient({ chain: base, transport: http() });

const feed = await client.readContract({
  address: PAIRS_STORAGE_ADDRESS, // from Addresses above
  abi: [{
    name: "pairFeed",
    type: "function",
    stateMutability: "view",
    inputs: [{ name: "pairIndex", type: "uint16" }],
    outputs: [{ name: "", type: "bytes32" }],
  }],
  functionName: "pairFeed",
  args: [0], // pair index 0 = BTCDOM
});

const [value, timestamp] = await client.readContract({
  address: ORACLE_ADDRESS, // from Addresses above
  abi: [{
    name: "getValue",
    type: "function",
    stateMutability: "view",
    inputs: [{ name: "feed", type: "bytes32" }],
    outputs: [
      { name: "value", type: "int192" },
      { name: "timestamp", type: "uint64" },
      { name: "publishId", type: "uint256" },
    ],
  }],
  functionName: "getValue",
  args: [feed],
});

console.log("BTCDOM:", Number(value) / 1e18); // e.g. 60.5

value is the dominance in percent with 18 decimals: BTCDOM at 52.5% returns 52500000000000000000. getValue reverts with OracleValueUnset for a feed that has never been published. Reading the price is a view call. It costs no gas and no oracle fee.

From the SDK

domfi.api.prices.head() returns the latest price of every pair as { asset, productId, price, timestamp }. price is an 18-decimal value. It comes from DomFi's API, which indexes every on-chain price update; read DomfiOracle directly when you need the on-chain value itself.

import { createDomfiClient } from "@domfi/sdk";

const domfi = createDomfiClient({ chain: "mainnet" });
const { data: headPrices } = await domfi.api.prices.head();

Checking freshness

getValue also returns timestamp, the time the price describes, in milliseconds since the Unix epoch. The oracle publishes every pair at least once a minute, so a timestamp more than a minute old means publishing has stopped.

Compare the publish time with the current time before you act on a price. See Oracle › Freshness and Staleness for how the contracts treat older prices.