import { AccountAddress, CommittedTransactionResponse, Ed25519Account, MoveOptionType } from "@aptos-labs/ts-sdk"; import { AptosContractWrapperBaseClass } from "./baseClass"; import { OracleContract } from "../contracts/oracle"; import { AptosProvider } from "./aptosProvider"; /** * The `OracleClient` class provides methods to interact with the oracle contract on the Aptos blockchain. * It extends the `AptosContractWrapperBaseClass` and includes functionalities to retrieve and set asset prices, * manage feed IDs, and obtain oracle-related addresses. * * @remarks * This client is designed to work with the oracle contracts and provides a high-level API for price feed * operations. The client can be instantiated in two ways: * 1. Using the constructor directly with a provider and optional signer * 2. Using the static buildWithDefaultSigner method which automatically configures the client with the provider's oracle profile account * * @example * ```typescript * // Using buildWithDefaultSigner * const provider = new AptosProvider(); * const client = OracleClient.buildWithDefaultSigner(provider); * * // Using constructor directly * const provider = new AptosProvider(); * const signer = provider.getOracleProfileAccount(); * const client = new OracleClient(provider, signer); * * // Get asset price * const price = await client.getAssetPrice(assetAddress); * ``` * * @param provider - The AptosProvider instance used to interact with the Aptos blockchain. * @param signer - Optional Ed25519Account signer for transaction signing. */ export declare class OracleClient extends AptosContractWrapperBaseClass { oracleContract: OracleContract; /** * Creates an instance of OracleClient. * * @param provider - The Aptos blockchain provider. * @param signer - Optional Ed25519 account signer. */ constructor(provider: AptosProvider, signer?: Ed25519Account); /** * Creates an instance of OracleClient using the default signer from the provided AptosProvider. * * @param provider - The AptosProvider instance to use for creating the OracleClient. * @returns A new instance of OracleClient. */ static buildWithDefaultSigner(provider: AptosProvider): OracleClient; /** * Returns if an asset price is capped or not. * * @param asset - The address of the asset for which we are checking if there is a cap. * @returns A promise that resolves to a boolean. */ isAssetPriceCapped(asset: AccountAddress): Promise; /** * Retrieves the price of a specified asset. * * @param asset - The address of the asset for which the price is being requested. * @returns A promise that resolves to the price of the asset as a bigint. */ getAssetPrice(asset: AccountAddress): Promise; /** * Retrieves the price plus timestamp of a specified asset. * * @param asset - The address of the asset for which the price is being requested. * @returns A promise that resolves to the price of the asset incl. its timestamp as a bigint. */ getAssetPriceAndTimestmap(asset: AccountAddress): Promise<{ price: bigint; timestamp: bigint; }>; /** * Retrieves the price cap of a specified asset. * * @param asset - The address of the asset for which the price cap is being requested. * @returns A promise that resolves to the price cap of the asset as a bigint. */ getPriceCap(asset: AccountAddress): Promise; /** * Retrieves the prices of the specified assets. * * @param assets - An array of account addresses representing the assets. * @returns A promise that resolves to an array of bigints, each representing the price of an asset. */ getAssetsPrices(assets: Array): Promise>; /** * Retrieves the oracle address from the oracle contract. * * @returns {Promise} A promise that resolves to the oracle address. */ getOracleAddress(): Promise; /** * Retrieves the oracle asset price decimals. * * @returns {Promise} A promise that resolves to the asset price decimals of the oracle. */ getAssetPriceDecimals(): Promise; /** * Sets a price cap stable adapter for a given asset. * * @param asset - The account address of the asset for which the stable price adapter is being set. * @param priceCap - The price cap. * @returns A promise that resolves to a CommittedTransactionResponse once the transaction is committed. */ setPriceCapStableAdapter(asset: AccountAddress, priceCap: bigint): Promise; /** * Removes a price cap stable adapter for a given asset. * * @param asset - The account address of the asset for which the stable price adapter is being remved. * @returns A promise that resolves to a CommittedTransactionResponse once the transaction is committed. */ removePriceCapStableAdapter(asset: AccountAddress): Promise; /** * Sets the feed ID for a given asset in the oracle contract. * * @param asset - The account address of the asset for which the feed ID is being set. * @param feedId - The feed ID to be associated with the asset, represented as a Uint8Array. * @returns A promise that resolves to a CommittedTransactionResponse once the transaction is committed. */ setAssetFeedId(asset: AccountAddress, feedId: Uint8Array): Promise; /** * Sets a custom price for a given asset. * * @param asset - The account address of the asset for which the feed ID is being set. * @param customPrice - The custom price of the asset. * @returns A promise that resolves to a CommittedTransactionResponse once the transaction is committed. */ setAssetCustomPrice(asset: AccountAddress, customPrice: bigint): Promise; /** * Sets the feed IDs for a batch of assets in the oracle contract. * * @param assets - An array of account addresses representing the assets. * @param feedIds - An array of Uint8Array representing the feed IDs for the assets. * @returns A promise that resolves to a CommittedTransactionResponse. */ batchSetAssetFeedIds(assets: Array, feedIds: Array): Promise; /** * Sets the custom prices for a batch of assets in the oracle contract. * * @param assets - An array of account addresses representing the assets. * @param customPrices - An array of bigints representing the custom prices of the assets. * @returns A promise that resolves to a CommittedTransactionResponse. */ batchSetAssetCustomPrices(assets: Array, customPrices: Array): Promise; /** * Removes the feed ID associated with a given asset. * * @param asset - The address of the asset for which the feed ID should be removed. * @returns A promise that resolves to the response of the committed transaction. */ removeAssetFeedId(asset: AccountAddress): Promise; /** * Removes the feed IDs for a batch of assets from the oracle contract. * * @param assets - An array of account addresses representing the assets whose feed IDs are to be removed. * @returns A promise that resolves to a `CommittedTransactionResponse` indicating the result of the transaction. */ batchRemoveAssetFeedIds(assets: Array): Promise; /** * Removes the custom price associated with a given asset. * * @param asset - The address of the asset for which the custom price should be removed. * @returns A promise that resolves to the response of the committed transaction. */ removeAssetCustomPrice(asset: AccountAddress): Promise; /** * Removes the custom prices for a batch of assets from the oracle contract. * * @param assets - An array of account addresses representing the assets whose custom prices are to be removed. * @returns A promise that resolves to a `CommittedTransactionResponse` indicating the result of the transaction. */ batchRemoveAssetCustomPrices(assets: Array): Promise; }