Skip to main content

Module pyth

Module pyth 

Source
Expand description

Pyth price-feed helpers (PriceUpdateV2 accounts — push or pull).

§Preferred flow (push feed accounts)

The Pyth Data Association maintains continuously-updated price feed accounts at fixed PDAs (heartbeat ~400 ms). Pass crate::consts::PYTH_BTC_USD_PRICE_FEED_ACCOUNT directly to oracle-gated instructions — no Hermes fetch or post_update_atomic required.

§Fallback flow (pull / Hermes)

  1. Caller fetches a signed price-update VAA from the Hermes REST API.
  2. Caller posts it via PYTH_RECEIVER_PROGRAM::post_update_atomic → ephemeral PriceUpdateV2.
  3. Caller passes that account as pyth_price_feed_info.

Both flows use the same PriceUpdateV2 borsh layout. The only difference is the account owner (PYTH_PUSH_ORACLE_PROGRAM for push feeds, PYTH_RECEIVER_PROGRAM for pull). This module accepts either.

Structs§

Price

Functions§

anchor_open_snapshot
Writes open_* fields from a Hermes PriceUpdateV2 account.
assert_pyth_receiver_owner
Assert that info is owned by either the Pyth Receiver program (pull feeds / post_update_atomic) or the Pyth Push Oracle program (continuously-maintained push feed accounts).
load_fresh_price_hermes
Parse a PriceUpdateV2 account into our internal Price type.
outcome_from_open_close
UP/DOWN from open vs close prices at a common exponent (tie → DOWN).