UNPKG

@acelon/acelon-sdk

Version:

The Acelon SDK is a TypeScript library that provides a simple interface to interact with the Acelon Service. It allows developers to fetch price data for various cryptocurrency pairs, with signatures from multiple oracles.

64 lines (63 loc) 2.35 kB
import { AcelonSdkOptions, CheckExchangeHealthParams, FetchPricesParams, GetPricesResult } from './types'; /** * AcelonSdk provides methods to interact with the Acurast Oracle network. */ export declare class AcelonSdk { private client; private keyPair; private pendingRequests; private initPromise; private oracles; private wssUrls; private timeout; private logging; private errorThreshold; private idToPubKeyMap; /** * Creates an instance of AcelonSdk. * @param {AcelonSdkOptions} options - The configuration options. */ constructor(options: AcelonSdkOptions); private init; private fetchDefaultSettings; private generateKeyPair; private handleMessage; private isValidResponse; private sendRequestToOracles; private sendRequest; 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; }