import type { Address, Chain, PublicClient, Transport } from "viem"; import type { Asset } from "../router/index.js"; import type { ILogger } from "../types/logger.js"; import { AddressMap } from "../utils/index.js"; import type { PhantomTokenMeta, RWATokenMeta, TokenMetaData } from "./token-types.js"; /** * Options for {@link TokensMeta.formatBN}. **/ export interface FormatBNOptions { /** * Number of decimal places in the formatted output. **/ precision?: number; /** * When `true`, appends the token symbol to the formatted string. **/ symbol?: boolean; } /** * Registry of token metadata (symbol, decimals, phantom type) keyed by address. * * Extends {@link AddressMap} with convenience accessors for formatting token * amounts and looking up tokens by symbol. * * Provides methods to lazy-load information about certain classes of tokens (e.g. phantom tokens) */ export declare class TokensMeta extends AddressMap { #private; constructor(client: PublicClient, logger?: ILogger); /** * Clears all token metadata **/ reset(): void; upsert(address: string, value: TokenMetaData | undefined): void; /** * Returns the symbol string for a token. * @param token - Token address. * @throws If the token is not in the registry. */ symbol(token: Address): string; /** * Returns the decimal count for a token. * @param token - Token address. * @throws If the token is not in the registry. */ decimals(token: Address): number; /** * Returns true if the token is a phantom token, throws if the token data is not loaded * @param t * @returns */ isPhantomToken(t: TokenMetaData): t is PhantomTokenMeta; /** * Returns true if the token is a RWA underlying token, throws if the token data is not loaded * @param t * @returns */ isRWAUnderlying(t: TokenMetaData): t is RWATokenMeta; /** * Returns a map of all phantom tokens * Throws if token data is not loaded */ get phantomTokens(): AddressMap; /** * Returns a map of all RWA underlying tokens * Throws if token data is not loaded */ get rwaUnderlyings(): AddressMap; /** * Formats a raw token amount into a human-readable decimal string, * dividing by `10^decimals` for the token. * * Accepts either an {@link Asset} object or a separate `(token, amount)` pair. * * @param asset - Asset object containing `token` address and `balance`. * @param options - Formatting options. */ formatBN(asset: Asset, options?: FormatBNOptions): string; /** * @param token - Token address. * @param amount - Raw amount (in smallest unit). * @param options - Formatting options. */ formatBN(token: Address, amount: number | bigint | string | undefined, options?: FormatBNOptions): string; /** * Finds a token by its symbol (e.g. `"USDC"`). * @param symbol - Case-sensitive ticker symbol. * @returns The matching metadata, or `undefined` if no token has this symbol. */ findBySymbol(symbol: string): TokenMetaData | undefined; /** * Finds a token by its symbol, throwing if not found. * @param symbol - Case-sensitive ticker symbol. * @throws If no token matches the symbol. */ mustFindBySymbol(symbol: string): TokenMetaData; /** * Loads token information about phantom tokens * In future other custom tokens types that do not have compressors might be handled here * * @param tokens - tokens to load data for, defaults to all tokens */ loadTokenData(...tokens: Address[]): Promise; }