/** * @name perps/adrena/adrena-oracle-relay * @description Switchboard On-Demand oracle relay for Adrena perp trading. * * Adrena's multi-oracle config (main-pool) requires `minAgree = 2` fresh * provider prices (staleness 15s) at trade time. Since 2026-08-29 only the * Autonom provider is fresh in the oracle PDA (Switchboard stopped cranking), * so every trade fails with error 6088 MissingOraclePrice. * * This module implements the same refresh pattern the Adrena frontend uses: * * TX A [Ed25519 verify] + [SB quote verified_update] * — writes fresh signed prices into the canonical quote account * TX B [Adrena update_oracle (switchboard_oracle_prices)] + [trade ix] * — pulls the fresh quote into the Adrena oracle PDA, then trades * * Both builder outputs return unsigned transactions; the caller signs and * submits them in order (TX A must land before TX B). * * @module perps/adrena/adrena-oracle-relay */ import { Connection, PublicKey, TransactionInstruction, type TransactionSignature } from '@solana/web3.js'; /** The canonical SB quote account that verified_update writes to. */ export interface AdrenaOracleRefreshPlan { /** Unsigned TX A: [Ed25519 verify, verified_update]. Sign + submit first. */ updateTransactionBase64: string; /** Base58 of the canonical quote account updated by TX A. */ quoteAccount: string; /** The pre-built update_oracle instruction to prepend to the trade tx. */ updateOracleInstruction: TransactionInstruction; /** Feed map entries included (for logging/telemetry). */ feedIds: number[]; /** Max age slots passed to update_oracle. */ maxAgeSlots: number; } /** * Build the Switchboard oracle refresh bundle for the Adrena main pool: * an unsigned TX A that refreshes the canonical quote account, plus the * `update_oracle` instruction to prepend to the trade transaction. * * The caller must: * 1. Sign + submit TX A (`updateTransactionBase64`) and wait for confirmation. * 2. Prepend `updateOracleInstruction` to the trade tx instructions. * * @param connection — Solana RPC connection (any version; objects are converted). * @param feePayer — Transaction fee payer (must be writable on SB quote create). */ export declare function buildAdrenaSbOracleRefresh(connection: Connection, feePayer: PublicKey, maxAgeSlots?: number): Promise; /** * Build the Adrena `update_oracle` instruction with * `switchboard_oracle_prices = Some({ max_age_slots, feed_map })` and the * canonical quote account as the first remaining account. * * UpdateOracleParams borsh layout (3 options): * [0] oracle_prices = None → 0x00 * [0] multi_oracle_prices = None → 0x00 * [1] switchboard_oracle_prices = Some({ * max_age_slots: u64, * feed_map: Vec<{ adrena_feed_id: u8, switchboard_feed_hash: [u8;32] }>, * }) * Remaining accounts: [canonical quote account (writable)]. */ export declare function buildUpdateOracleInstruction(quoteAccount: PublicKey, maxAgeSlots?: number): TransactionInstruction; /** * End-to-end oracle refresh: submit TX A (SB update) and confirm, returning * the instruction to prepend to the trade transaction. Used by the * auto-healing path in the builders when simulation returns oracle errors. * * @returns The update_oracle instruction, ready to prepend. */ export declare function refreshAdrenaSwitchboardOracle(connection: Connection, feePayer: PublicKey, signAndSubmit: (base64Tx: string) => Promise, maxAgeSlots?: number): Promise; /** Detect oracle-related Adrena errors that the relay can auto-heal. */ export declare function isOracleRecoverableError(errorMessage: string | undefined): boolean; //# sourceMappingURL=adrena-oracle-relay.d.ts.map