Skip to main content

Oracle

The vault only ever calls one read-only function to learn the BTC-USD price:

(contract-call? .oracle-adapter get-btc-price)

oracle-adapter.clar is a thin normalization + safety layer:

  • enforces positivity — a non-positive price reverts with ERR-BAD-PRICE u110;
  • enforces staleness — a price older than max-age reverts with ERR-STALE-PRICE u109;
  • returns { price, publish-time } so settlement can require the price to be at or after expiry (ERR-STALE-SETTLEMENT u122).

Mock feed on testnet / devnet

On devnet and the current testnet deployment, the adapter reads pyth-mock, and the keeper acts as the price relayer (pyth-mock.set-price-now). The deploy relaxes max-age to 8 days so a demo round stays buyable for the whole week without a live relayer running.

(set-max-age (new-age uint)) ;; deploy sets u691200 (8 days) for the demo

Swapping in real Pyth

For mainnet (or a production testnet), point the adapter's inner call at the deployed Pyth contract (pyth-oracle-v3.get-price), normalizing the expo field to 1e8. Because the vault only depends on get-btc-price, the vault and everything downstream stay unchanged — only the adapter's internals move.

The shared config carries the Pyth BTC-USD feed id (0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43) for the real wiring.