@acurast/oracle-service-sdk
Version:
The Acurast Oracle SDK is a TypeScript library that provides a simple interface to interact with the Acurast Oracle Service. It allows developers to fetch price data for various cryptocurrency pairs, with signatures from multiple oracles.
64 lines (63 loc) • 2.39 kB
TypeScript
import { AcurastOracleSDKOptions, CheckExchangeHealthParams, FetchPricesParams, GetPricesResult } from './types';
/**
* AcurastOracleSDK provides methods to interact with the Acurast Oracle network.
*/
export declare class AcurastOracleSDK {
private client;
private keyPair;
private pendingRequests;
private initPromise;
private oracles;
private wssUrls;
private timeout;
private logging;
private errorThreshold;
private idToPubKeyMap;
/**
* Creates an instance of AcurastOracleSDK.
* @param {AcurastOracleSDKOptions} options - The configuration options.
*/
constructor(options: AcurastOracleSDKOptions);
private init;
private fetchDefaultSettings;
private generateKeyPair;
private handleMessage;
private sendRequestToOracles;
private sendRequest;
private isValidResponse;
private validateFetchPricesParams;
/**
* Fetches price data from the oracle network.
* @param {FetchPricesParams} params - The parameters for fetching prices.
* @param {number} verifications - The number of verifications required (default: 0).
* @returns {Promise<GetPricesResult[]>} A promise that resolves to an array of combined signed prices.
*/
getPrices(params: FetchPricesParams, verifications?: number): Promise<GetPricesResult[]>;
private combineSignedPrices;
/**
* Retrieves a list of available exchanges.
* @param {CheckExchangeHealthParams} params - The parameters for checking exchange health.
* @returns {Promise<string[]>} A promise that resolves to an array of available exchange IDs.
*/
getExchanges(params?: CheckExchangeHealthParams, requiredResponses?: number): Promise<string[]>;
/**
* Pings the oracles.
* @returns {Promise<{ status: string; timestamp: number, pubKey: string }[]>} A promise that resolves to the list reachable oracles.
*/
ping(): Promise<{
status: string;
timestamp: number;
pubKey: string;
}[]>;
/**
* Retrieves the list of oracles.
* @returns {Promise<string[]>} A promise that resolves to an array of oracle IDs.
*/
getOracles(): Promise<string[]>;
/**
* Closes the WebSocket connection.
* @returns {Promise<void>} A promise that resolves when the connection is closed.
*/
close(): Promise<void>;
private log;
}