import BN from 'bn.js'; import { HermesClient } from '@pythnetwork/hermes-client'; import { AccountInfo, Connection, Keypair, PublicKey, TransactionInstruction } from '@solana/web3.js'; import { OracleSettings } from '../../layouts/oracle'; import { TxBatchData } from '../../txUtils'; import { OraclePrice } from './oracle'; export type VerificationLevel = { kind: 'Partial'; numSignatures: number; } | { kind: 'Full'; }; export declare function parseVerificationLevel(buf: Buffer, offset: number): { level: VerificationLevel; size: number; }; export declare const TIP_ACCOUNTS: string[]; export declare function getRandomTipAccount(): PublicKey; export declare function buildJitoTipInstruction(payer: PublicKey, lamports: number): TransactionInstruction; /** * Derives the Pyth price feed account address */ export declare function getPythPriceFeedAccountAddress(shardId: number, priceFeedId: string | Buffer, pushOracleProgramId?: PublicKey): PublicKey; export interface InstructionWithSigners { instruction: TransactionInstruction; signers: Keypair[]; computeUnits?: number; } export interface PythUpdateResult { postInstructions: InstructionWithSigners[]; closeInstructions: InstructionWithSigners[]; signers: Keypair[]; priceFeedAccounts: Map; } export declare function parsePriceFeedMessage(message: Buffer): { feedId: Buffer; price: Buffer; confidence: Buffer; exponent: number; publishTime: Buffer; prevPublishTime: Buffer; emaPrice: Buffer; emaConf: Buffer; }; /** parsing of accumulator update data (VAA + updates) */ export declare function parseAccumulatorUpdateData(data: Buffer): { vaa: Buffer; updates: { message: Buffer; proof: number[][]; }[]; }; /** * Get the size of a transaction that would contain the provided array of instructions */ export declare function getSizeOfTransaction(instructions: TransactionInstruction[], versionedTransaction?: boolean, addressLookupTable?: { state: { addresses: PublicKey[]; }; }): number; /** Get the size of n in bytes when serialized as a CompressedU16 */ export declare function getSizeOfCompressedU16(n: number): number; export interface InstructionBatch { instructions: TransactionInstruction[]; signers: Keypair[]; computeUnits: number; } /** * Fetch Pyth price accounts from RPC and extract feed IDs */ export declare function fetchFeedIdsFromAccounts(connection: Connection, priceAccounts: PublicKey[]): Promise<{ feedIds: string[]; feedIdToAccount: Map; }>; export interface PythUpdateTxResult { txBatchData: TxBatchData; /** Keypairs that must sign their respective transactions before sending */ extraSigners: Map; } /** * Build Pyth price feed update as TxBatchData compatible with SDK txUtils. * * TxBatchData.batches layout: * batch 0 (sequential): [createAccount + initEncodedVaa + writeVaa_part1] * batch 1 (sequential): [writeVaa_part2 + verifyEncodedVaa] * batch 2 (parallel): [updateFeed_0], [updateFeed_1], ... [updateFeed_N-2] * batch 3 (sequential): [updateFeed_last + closeEncodedVaa] * * Transactions within each batch are sent in parallel by sendVersionedTxs. * Batches are sent sequentially. */ export declare function buildPythPriceFeedUpdateIxs(payer: PublicKey, priceFeedIds: string[], defaultShardId?: number, hermesClient?: HermesClient): Promise<{ vaaCreateInitEncodeIxs: { ixs: TransactionInstruction[]; signer: Keypair; }[]; vaaWriteVerifyIxs: TransactionInstruction[][]; updateFeedIxs: TransactionInstruction[]; closeVaaIxs: TransactionInstruction[]; }>; export declare class PriceFeedMessage { feedId: Buffer; price: BN; conf: BN; exponent: number; publishTime: BN; prevPublishTime: BN; emaPrice: BN; emaConf: BN; constructor(params: { feedId: Buffer; price: BN; conf: BN; exponent: number; publishTime: BN; prevPublishTime: BN; emaPrice: BN; emaConf: BN; }); static decode(buf: Buffer, offset?: number): [PriceFeedMessage, number]; } export declare class PythState { writeAuthority: PublicKey; verificationLevel: VerificationLevel; priceMessage: PriceFeedMessage; postedSlot: BN; constructor(writeAuthority: PublicKey, verificationLevel: VerificationLevel, priceMessage: PriceFeedMessage, postedSlot: BN); static decode(buf: Buffer, offset?: number): [PythState, number]; } export declare class PythOracle { static fetch(oracleParams: OracleSettings, accountInfos: AccountInfo[], solPrice?: OraclePrice, usdPrice?: OraclePrice): OraclePrice; }