> For the complete documentation index, see [llms.txt](https://docs.ducatprotocol.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ducatprotocol.com/how-ducat-works/oracles/price-quotes.md).

# Price Quotes

The current vault commitment is a signed `PriceContract`. A bare BTC/USD price or an unsigned quote response is not sufficient to authorise a vault action.

### Contract fields

| Field           | Encoding                                         | Meaning                                                         |
| --------------- | ------------------------------------------------ | --------------------------------------------------------------- |
| `oracle_pubkey` | 32-byte x-only secp256k1 public key, hex in JSON | Identity that must match an authorised oracle.                  |
| `chain_network` | Network identifier                               | Domain separation for the intended Bitcoin network/profile.     |
| `base_price`    | Unsigned 32-bit integer                          | BTC/USD base price in whole USD.                                |
| `base_stamp`    | Unsigned 32-bit integer                          | Observation time as Unix seconds.                               |
| `thold_price`   | Unsigned 32-bit integer                          | BTC/USD liquidation threshold in whole USD.                     |
| `commit_hash`   | 32 bytes, hex in JSON                            | Tagged hash of the identity, network, prices and timestamp.     |
| `thold_hash`    | 20 bytes, hex in JSON                            | HASH160 of the threshold key.                                   |
| `contract_id`   | 32 bytes, hex in JSON                            | Tagged hash binding the commitment and threshold hash.          |
| `oracle_sig`    | 64 bytes, hex in JSON                            | BIP-340 Schnorr signature over `contract_id`.                   |
| `thold_key`     | Null, or 32 bytes encoded as hex                 | Null while sealed; supplied when the threshold key is revealed. |

The signature is over the derived identifier, not a serialised JSON object. Adding the revealed key does not change the signed identifier: the receiver verifies that the supplied key hashes to the already committed `thold_hash`.

Contract age and preimage release are separate checks: a contract can be too old for a new action without its threshold key having been released. Use the applicable freshness policy and the committed hash rather than inferring one state from the other.

### Validation

A consumer must:

1. Resolve the authorised oracle key from the selected protocol profile; do not trust a response merely because it contains a self-consistent public key and signature.
2. Check the network and recompute `commit_hash` and `contract_id` with the exact byte encoding.
3. Verify the BIP-340 signature and the action's price, timestamp, threshold and freshness requirements.
4. Require the appropriate sealed or revealed state. If a key is supplied, verify `HASH160(thold_key) == thold_hash`.
5. For multiple commitments, enforce distinct oracle indices, the same network and timestamp, and the implementation's price-compatibility checks. The current check permits at most 10% base-price variance relative to the first contract; it does not merge the contracts into a single oracle signature.

The transaction's validator still checks the full vault action. Authenticating a quote alone does not establish that a withdrawal, borrowing request or liquidation is valid.

### Reference HTTP client

The SDK's direct oracle client exposes the following read operations for the compatible service adapter:

| Request                                           | Purpose                                                                           |
| ------------------------------------------------- | --------------------------------------------------------------------------------- |
| `GET /api/status`                                 | Read service status and configuration.                                            |
| `GET /api/price/latest`                           | Read the current price and timestamp.                                             |
| `GET /api/contract?th=<threshold>&ts=<timestamp>` | Request a signed contract; the timestamp query is optional.                       |
| `GET /api/events`                                 | Read published events, which consumers filter and validate for the required type. |

This is an adapter interface, not a promise that every production oracle exposes these endpoints publicly or serves arbitrary historical timestamps. A deployment may distribute contracts through a relay instead. Use its configured transport and verify the returned contract independently.

The cryptographic network string is not necessarily the same as the JSON enum spelling. See [Generating Keys and Signatures](https://docs.ducatprotocol.com/how-ducat-works/oracles/generating-keys-and-signatures.md) before implementing a compatible client.
