DiaBtcUsdCents (dia_btc_usd_cents.ark) is a reusable Arkade Language library for verifying and reading DIA Lasernet BTC/USD price updates rounded to USD cents. DiaBtcUsdOracle (dia_btc_usd_oracle.ark) wraps that verification in a recursive output identified by a one-unit asset (Asset as Contract ID), so consumer contracts never hardcode DIA’s signer key.
Unlike DIA BTC/USD Expiry Oracle (DiaBtcUsdExpiryOracle), which verifies the same DIA feed and stores eight rolling expiry slots, DiaBtcUsdOracle stores no history and needs no offchain publisher to pre-write fixings. Instead, whoever spends a consumer co-spends DiaBtcUsdOracle as input 1 and attaches a fresh DIA signature directly to that transaction. Use DIA BTC/USD Expiry Oracle for scheduled expiry fixings such as Options, and use DiaBtcUsdOracle when a contract needs a live point-in-time price at any moment, such as margin calls in Loans.
Source
Savedia_btc_usd_cents.ark alongside your consumer contract or alongside dia_btc_usd_oracle.ark. Compile the exact same source on every party, because any edit changes the derived contract addresses.
dia_btc_usd_cents.ark
dia_btc_usd_oracle.ark
Constructor
operatorExitDelay is not a constructor parameter, because the SDK binds it to the operator’s exit delay (CSV delays).
Quote Packet
When a consumer co-spendsDiaBtcUsdOracle, the spending transaction carries a 17-byte extension packet of type 34 (0x22). Integers use 8-byte little-endian sign-magnitude encoding (int2bytes(n, 8)).
Functions
DiaBtcUsdOracle.verify
Runs when a consumer co-spends the oracle output as input 1.
- Enforces DIA’s live validity window (
checkTime(time)and!checkTime(intentExpiry)on the operator’s enclave clock), mirroring DIA’sOracleIntentRegistryso live quotes expire after one hour on Lasernet. - Calls
DiaBtcUsdCents.verifyPriceto check DIA’s EIP-712 signature viacheckSigFromStackand round the 18-decimal price to USD cents. DIA BTC/USD Expiry Oracle calls the same function with its own expiry window. - Checks that packet
34matches(price, time)and recreates the sameDiaBtcUsdOraclescript, satoshi value, and identity unit on output 0.
DiaBtcUsdCents.readPrice
Lets any consumer contract read the verified quote in one call.
- Confirms that input 1 holds the single unit of
oracleIdand parses packet34into aPriceQuote. - Because
migraterequires a single input (tx.numInputs == 1), any multi-input Arkade transaction spendingoracleIdmust executeverify. - Leaves contract-specific timestamps (such as a loan’s setup time or maturity) to the consumer.
DiaBtcUsdOracle.migrate
Moves the identity unit to a new script so adminPk can rotate oraclePk or adopt a newer DIA schema without changing open consumer contracts.
- Requires
tx.numInputs == 1and a valid signature fromadminPk, while keeping the satoshi value and identity asset on output 0. - Because
adminPkcontrols migration, consumers trust both DIA’s signer key and the key holdingadminPk.
DiaBtcUsdOracle.unilateral
Provides the onchain exit if the operator stops cosigning.
- Waits for
operatorExitDelayafter unrolling onchain and requires a signature fromadminPk.
Live DIA Inputs
For liveBTC/USD updates, query getLatestIntentByType("OracleUpdate", "BTC/USD") on DIA Lasernet (https://rpc.diadata.org/, registry 0x5612599CF48032d7428399d5Fcb99eDcc75c06A7). Bind oraclePk to DIA’s Lasernet signer (0x100211ee120bca9f272034d98b1b026bb4ab735ebeb5da8be6a69bf7ee0ea24cfd48, address 0x10e34723aA722C7A9860f5eC6446f22252dB168a). Pass the first 64 bytes of its 65-byte Ethereum signature as oracleSig. When multiple DIA signers publish to OracleIntentRegistry, filter recent IntentRegistered logs by BTC/USD and that signer address before calling getIntent.
Those six bytes32 constants are DIA’s EIP-712 OracleIntent digest for an OracleUpdate. TYPEHASH is keccak256 of OracleIntent(string intentType,string version,uint256 chainId,uint256 nonce,uint256 expiry,string symbol,uint256 price,uint256 timestamp,string source) from OracleIntentUtils.sol. DOMAIN is the separator for name "DIA Oracle", version "1.0", chain 1050, the registry above, and salt 0. INTENT_TYPE, VERSION, SYMBOL, and SOURCE are keccak256 of "OracleUpdate", "1.0", "BTC/USD", and "DIA Oracle". During local testing, bind oraclePk to your own 0x10-prefixed secp256k1 key and sign that digest without editing either contract file.