import { TokenInfo } from '@premia/pair-lists/src/types'; import { Token, TokenExtended, TokenMinimal } from '../entities'; import { BaseAPI } from './baseAPI'; import { Provider } from 'ethers'; export declare type TokenOrAddress = Token | string; /** * Represents a class for handling Token operations related to the voidnode server. * * @class TokenAPI * @extends {BaseAPI} */ export declare class TokenAPI extends BaseAPI { /** * Checks if the given address corresponds to the native token on the current chain. * * @param {string} address - The address to check. * @returns {boolean} True if the address corresponds to the native token; otherwise false. */ isNativeToken(address: string): boolean; /** * Checks if the given address corresponds to the wrapped native token on the current chain. * * @param {string} address - The address to check. * @returns {boolean} True if the address corresponds to the wrapped native token; otherwise false. */ isWrappedNativeToken(address: string): boolean; /** * Fetches the current spot price of a given token in USD. * * This function retrieves the spot price for a given token from the underlying data source. * If the token's USD price is not available, an error is thrown. * * @param {string} address - The address of the token for which to fetch the spot price. * * @returns {Promise} A promise that resolves to the spot price of the token in USD. * * @throws {Error} An error if the USD price for the token is not found. */ getSpotPrice(address: string): Promise; /** * Fetches minimal information of a given token including its symbol and decimals. * * @param {string} address - The address of the token for which to fetch the minimal information. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to an object containing the token's address, symbol, and decimals. */ getTokenMinimal(address: string, provider?: Provider): Promise; /** * Fetches information of a given token from voidnode, coingecko, or token contract. * * @param {string} address - The address of the token for which to fetch the detailed information. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to an object containing the token's name, symbol, decimals, * whether it's native or wrapped native, price in ETH and USD, address, and chain ID. * * @throws Will throw an error if the token information cannot be fetched from either the voidnode server, coingecko, or token contract. */ getToken(address: string, provider?: Provider): Promise; /** * Fetches extended information of a given token from the voidnode server. * * @param {string} address - The address of the token for which to fetch the extended information. * * @returns {Promise} A promise that resolves to an object containing the extended information of the token. */ getTokenExtended(address: string): Promise; /** * Fetches information for multiple tokens given their addresses. * * This function retrieves information for multiple tokens specified by an array of addresses. * It uses caching with an hourly time to live to prevent frequent calls to the voidnode server. * If voidnode call fails, it switches to skip the voidnode server and fetches the tokens' information directly. * * @param {string[]} tokens - An array of token addresses for which to fetch the information. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to an array containing the information of the tokens. */ getTokens(tokens: string[], provider?: Provider): Promise; /** * Retrieves extended information of multiple tokens given their addresses. * * @param {string[]} tokens - An array of token addresses for which to fetch the extended information. * * @returns {Promise} A promise that resolves to an array containing the extended * information of the specified tokens. */ getTokensExtended(tokens: string[]): Promise; /** * Retrieves the information for a list of tokens given their details. * * This function fetches information for multiple tokens specified by an array of * token information objects. If voidnode querying is not skipped and fails, the function * resorts to fetching token details directly. * * @param {TokenInfo[]} tokenList - An array of token information objects for which to fetch the token data. * @param {Provider} provider - The custom provider to use for this call. * @returns {Promise} A promise that resolves to an array containing the information of the specified tokens. * * @throws Will throw an error if the voidnode server fails to load. */ getTokenList(tokenList: TokenInfo[], provider?: Provider): Promise; /** * Retrieves the extended information for a list of tokens given their details. * * This function fetches extended information for multiple tokens specified by an array of * token information objects. * * @param {TokenInfo[]} tokenList - An array of token information objects for which to fetch the token data. * * @returns {Promise} A promise that resolves to an array containing the extended information of the specified tokens. */ getTokenListExtended(tokenList: TokenInfo[]): Promise; }