import { Address, Amount } from '@safeblock/blockchain-utils'; import { Network } from 'ethers'; import { default as SafeBlock } from '../sdk'; import { default as SdkExtension, PartialEventBus } from '../sdk/sdk-extension'; import { BasicToken } from '../types'; declare const events: { /** Fired after the first successful price update */ onPriceStorageInitialLoadFinished: () => null; /** Fired after each subsequent price update */ onPriceStoragePricesUpdated: () => null; /** Fired when `forceRefetch` is invoked */ onPriceStorageForceRefetch: () => null; }; interface IPriceStorageExtensionConfig { /** Automatic price‑update interval in ms */ updateInterval?: number; /** Minimum ms that must elapse between `forceRefetch` calls */ forceRefetchTimeout?: number; } /** * SDK extension that manages prices of registered tokens. * * Requires the following extension: * - `TokensListExtension` */ export default class PriceStorageExtension extends SdkExtension { #private; private readonly sdk; private readonly eventBus; private readonly config?; static name: string; events: { /** Fired after the first successful price update */ onPriceStorageInitialLoadFinished: () => null; /** Fired after each subsequent price update */ onPriceStoragePricesUpdated: () => null; /** Fired when `forceRefetch` is invoked */ onPriceStorageForceRefetch: () => null; }; private readonly _prices; /** * SDK extension that manages prices of registered tokens. * * Requires the following extension: * - `TokensListExtension` * * @param {SafeBlock} sdk SDK instance * @param {PartialEventBus} eventBus partial event bus * @param {IPriceStorageExtensionConfig} config extension configuration */ constructor(sdk: SafeBlock, eventBus: PartialEventBus, config?: IPriceStorageExtensionConfig | undefined); onInitialize(): void; /** * Wait until the initial price update is complete. If prices were already * updated at least once, the promise resolves immediately. * * @param {number} pollingInterval polling interval in ms * @returns {Promise} resolves after the first price update */ waitInitialFetch(pollingInterval?: number): Promise; /** * Request a price refresh. A new request is issued only if none is * currently in progress. * * @param {symbol} forceTask if set, cancels the current request and starts a new one * @returns {Promise} */ requestPricesUpdate(forceTask?: symbol): Promise; /** * Force a price refresh. * * @returns {Promise} */ forceRefetch(): Promise; /** * Get the price of a specific token. * * @param {Network} tokenOrNetwork network of the token * @param {Address} address token address * @returns {Amount} token price */ getPrice(tokenOrNetwork: Network, address: Address): Amount; /** * Get the price of a specific token. * * @param {BasicToken} tokenOrNetwork token object * @returns {Amount} token price */ getPrice(tokenOrNetwork: BasicToken): Amount; private fetchTokenPrices; } export {};