import type { PythLazerClient, Channel } from "@pythnetwork/pyth-lazer-sdk"; import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc"; import { Transaction, type TransactionResult } from "@mysten/sui/transactions"; import { TOKEN } from "../../../src/constants"; export type MoveApiVersion = "v1" | "v2"; export interface PythLazerSuiClientOpts { /** * Long-lived-key source (WebSocket). Node-side crankers and scripts pass * this. Do NOT use it in a browser — the key would ship in the bundle. */ lazer?: PythLazerClient; /** * Client-safe alternative: returns a short-lived Pyth JWT per call, and * price fetches go over REST instead of the WS. The JWT is accepted on * `POST /v1/latest_price` and `/v1/price` (verified against mainnet), and * that host sends `access-control-allow-origin: *`, so the browser can call * it directly. Takes precedence over `lazer` when both are supplied. */ getAccessToken?: () => string | Promise; restEndpoint?: string; channel?: Channel; /** Which Lazer Move API to call. See DEFAULT_MOVE_API. */ moveApiVersion?: MoveApiVersion; sui: SuiJsonRpcClient; network: "MAINNET" | "TESTNET"; lazerPackage: string; oraclePackage: string; oracleV2Id: string; stateObjectId?: string; } export declare class PythLazerSuiClient { readonly lazer?: PythLazerClient; readonly getAccessToken?: () => string | Promise; readonly restEndpoint: string; readonly channel: Channel; readonly moveApiVersion: MoveApiVersion; readonly sui: SuiJsonRpcClient; readonly network: "MAINNET" | "TESTNET"; readonly stateObjectId: string; readonly lazerPackage: string; readonly oraclePackage: string; readonly oracleV2Id: string; constructor(opts: PythLazerSuiClientOpts); /** `_v2` suffix on the Lazer/oracle entries when on the v2 Move API. */ private get v(); /** * Fetches a signed `leEcdsa` update over REST using a short-lived token. * Mirrors typus-rust `lazer_ingestion::rest_client`. */ private fetchUpdateOverRest; private resolveFeedIds; private resolveTypeArgument; /** * Fetches a Pyth Lazer `leEcdsa` update covering every requested token, adds * `pyth_lazer::parse_and_verify_le_ecdsa_update` to the PTB, and returns the * verified `Update` argument for use in subsequent move calls. */ updatePythLazer(tx: Transaction, tokens: TOKEN[], timestamp?: number): Promise; /** * Calls `oracle_v2::update_latest_price(oracle_v2, update, clock)`. A single * call updates every feed in the verified update. */ updateOracleV2WithPythLazer(tx: Transaction, tokens: TOKEN[]): Promise; /** * Calls `oracle_v2::update_settle_price(oracle_v2, update, timestamp, clock)`. * Authority-gated on-chain. `timestamp` is in seconds. */ updateOracleV2SettlePriceWithPythLazer(tx: Transaction, tokens: TOKEN[], timestamp: number): Promise; /** * Calls `oracle_v2::add_latest_price_new_token(oracle_v2, feed_id, update, clock)`. * One-shot initializer for a brand-new token in the oracle's `feed_id_map`. */ addLatestPriceNewToken(tx: Transaction, token: TOKEN, tokenTypeArgument?: string): Promise; /** * Calls `oracle_v2::add_settle_price_new_token(oracle_v2, feed_id, update, timestamp, clock)`. * `timestamp` (seconds) is forwarded to the Lazer fetch when supplied and * passed on-chain; defaults to now, matching the freshness window. */ addSettlePriceNewToken(tx: Transaction, token: TOKEN, timestamp?: number, tokenTypeArgument?: string): Promise; }