For the complete documentation index, see llms.txt. This page is also available as Markdown.

Switchboard Solana/SVM Feeds Skill

Purpose

Integrate Switchboard on-demand feeds into Solana/SVM transactions and programs:

  • Compose transactions that verify/update and then consume feed values correctly

  • Implement on-chain verification patterns (Anchor/Rust) when your program consumes feeds

  • Support “cranking” patterns to keep canonical quote accounts warm (push-like behavior)

Dependencies

Use exact pins from the SDK Version Matrix.

  • @switchboard-xyz/on-demand@3.10.3

  • @switchboard-xyz/common@5.8.2

  • @solana/web3.js@1.98.0

  • @coral-xyz/anchor@0.31.1 (TypeScript client)

  • switchboard-on-demand = "0.13.0" (Rust on-chain)

This skill is about integration correctness, not designing new feed definitions (handled by switchboard-feed-design).

Preconditions

  • OperatorPolicy exists (network, RPC allowlist, autonomy/spend limits).

Inputs to Collect

  • network: mainnet-beta / devnet / custom

  • rpcUrl (optional override)

  • crossbarUrl (public or self-hosted)

  • feedId list (32-byte 0x... hex)

  • consumer program ID / instruction shape (if integrating)

  • validation targets: max staleness (slots), max deviation, min responses

Solana/SVM Integration Invariants

  • Consumer instruction must occur after Switchboard verification/update instructions in the same transaction.

  • Use deterministic/canonical accounts; do not accept arbitrary “quote accounts” without canonical checks.

  • New feed-hash integrations use queue.fetchManagedUpdateIxs(...) and canonical quote-program accounts. Do not suggest PullFeed.fetchUpdateIx(...) unless the user is maintaining an existing classic PullFeed account and confirms queue/gateway support for that legacy path.

  • Variable overrides are secrets-only (never selectors/URLs/paths/IDs/multipliers).

Minimal Example

Playbook

1) Resolve queue and canonical accounts

  • Load the correct oracle queue for the network (default unless user specifies).

  • Derive or verify canonical quote storage addresses as required by the SDK/program pattern.

  • If your program accepts a quote account, enforce that it is canonical for the queue + feedId.

2) Update + consume in one transaction (TypeScript skeleton)

Goal: fetch Switchboard-managed update instructions, then call the consumer instruction.

Indexing rule:

  • If you insert pre-instructions (compute budget, setup ixs), you must adjust instructionIdx.

3) On-chain verification (Rust/Anchor pattern)

Use the on-demand verifier and enforce staleness:

Note: quote.feeds() contains feed outputs (such as price values). Randomness uses a different path: read bytes from RandomnessAccountData::get_value(...) in the Randomness Tutorial.

Also enforce, when applicable:

  • canonical quote address constraints

  • deviation checks vs stored “last good” value for high-risk logic

4) Cranking pattern (push-like / heartbeat imitation)

Use this when you want other transactions/users to read the most recently cranked value from the canonical quote account without providing updates every time.

Tradeoffs:

  • Pros: readers can do cheaper reads; UI dashboards can stay warm.

  • Cons: loses atomic update+use guarantees; must enforce staleness at read-time.

Minimal crank loop: send a transaction that contains only the managed update instructions.

Operational guidance:

  • Run cranks from a dedicated wallet with explicit spend limits.

  • Monitor failures and staleness; treat missed cranks as “feed stale” for consumers.

Outputs

Produce a SolanaFeedIntegrationPlan including:

  • network + RPC/Crossbar URL

  • feedId(s) and queue resolution method

  • exact instruction ordering (list)

  • consumer instruction shape (accounts/args) if integrating

  • optional safety policy (staleness/deviation/signatures) if requested

  • crank plan (if requested): cadence, cost bounds, monitoring

Troubleshooting Checklist

  • Signature verification index mismatch → re-check instructionIdx vs final tx instruction order

  • Missing sysvars → include SlotHashes + Instructions sysvars in accounts

  • Non-canonical quote account → derive canonical address; reject non-canonical inputs

  • pullFeedSubmitResponseConsensus or PullFeed.fetchUpdateIx(...) returns ORACLE_UNAVAILABLE, but managed Ed25519 quote updates work → user is on the legacy PullFeed path; move to queue.fetchManagedUpdateIxs(...) and canonical quote accounts

  • Successful simulation but signed updates fail with RangeExceeded → feed validation issue; check raw v2 maxJobRangePct scaling separately from PullFeed-vs-quote-program routing

  • Compute limits → add compute budget ixs; reduce feeds/oracles per tx

References

  • https://docs.switchboard.xyz/docs-by-chain/solana-svm

  • https://docs.switchboard.xyz/docs-by-chain/solana-svm/price-feeds

  • https://docs.switchboard.xyz/tooling/crossbar

Last updated