@onelabs/suins
Version:
66 lines (65 loc) • 2.46 kB
TypeScript
import type { SuiClient } from '@onelabs/sui/client';
import type { Transaction } from '@onelabs/sui/transactions';
import type { HexString } from './PriceServiceConnection.js';
import { PriceServiceConnection } from './PriceServiceConnection.js';
export type ObjectId = string;
export declare class SuiPriceServiceConnection extends PriceServiceConnection {
/**
* Fetch price feed update data.
*
* @param priceIds Array of hex-encoded price IDs.
* @returns Array of buffers containing the price update data.
*/
getPriceFeedsUpdateData(priceIds: HexString[]): Promise<Uint8Array[]>;
}
export declare class SuiPythClient {
#private;
provider: SuiClient;
pythStateId: ObjectId;
wormholeStateId: ObjectId;
constructor(provider: SuiClient, pythStateId: ObjectId, wormholeStateId: ObjectId);
/**
* Verifies the VAAs using the Wormhole contract.
*
* @param vaas Array of VAA buffers to verify.
* @param tx Transaction block to add commands to.
* @returns Array of verified VAAs.
*/
verifyVaas(vaas: Uint8Array[], tx: Transaction): Promise<{
$kind: "NestedResult";
NestedResult: [number, number];
}[]>;
/**
* Adds the necessary commands for updating the Pyth price feeds to the transaction block.
*
* @param tx Transaction block to add commands to.
* @param updates Array of price feed updates received from the price service.
* @param feedIds Array of feed IDs to update (in hex format).
*/
updatePriceFeeds(tx: Transaction, updates: Uint8Array[], feedIds: HexString[]): Promise<ObjectId[]>;
/**
* Get the price feed object ID for a given feed ID, caching the promise.
* @param feedId
*/
getPriceFeedObjectId(feedId: HexString): Promise<ObjectId | undefined>;
/**
* Fetches the price table object ID for the current state ID, caching the promise.
* @returns Price table object ID and field type
*/
getPriceTableInfo(): Promise<{
id: ObjectId;
fieldType: ObjectId;
}>;
/**
* Fetches the package ID for the Wormhole contract, with caching.
*/
getWormholePackageId(): Promise<ObjectId>;
/**
* Fetches the package ID for the Pyth contract, with caching.
*/
getPythPackageId(): Promise<ObjectId>;
/**
* Returns the cached base update fee, fetching it if necessary.
*/
getBaseUpdateFee(): Promise<number>;
}