import type { Dnum } from 'dnum'; import type { ConvertAssetBalance, ConvertResolvedAsset, GetConvertBalances } from './types'; /** * One spelling per token address. * - EVM: checksummed; the asset list is checksummed and hosts send lowercase. * - Solana: as-is; base58 is case-sensitive. * - Anything else (Hypercore's `0x` + 32-zero placeholder): lowercase. */ export declare function normalizeTokenAddress(chainId: string, tokenAddress: string): string; /** One asset's identity, `chainId:address`; also the key its balance is stored under. */ export declare function convertAssetKey(chainId: string, address: string): string; export type ConvertBalanceState = { status: 'available'; baseUnits: string; unitPriceUsd: number; } | { status: 'unavailable'; }; /** A readable balance in whole tokens, for display; `undefined` when unknown. */ export declare function getConvertAssetAmount(balance: ConvertBalanceState | undefined, decimals: number): number | undefined; /** A balance read as zero: the token isn't held, so it isn't offered as a source. */ export declare function isEmptyConvertBalance(balance: ConvertBalanceState | undefined): boolean; /** One entry per listed asset, keyed by {@link convertAssetKey}. */ export type ConvertBalances = Record; /** * Turns the host's asset balances into one state per listed asset. An asset * the host left out, or returned with a malformed balance or price, is * unavailable; it never becomes 0. Balances for assets that weren't requested * are ignored. */ export declare function parseConvertBalances({ assets, assetBalances, logPrefix, }: { assets: ConvertResolvedAsset[]; assetBalances: ConvertAssetBalance[]; logPrefix?: string; }): ConvertBalances; /** The balance in USD; `undefined` when the balance is unknown. */ export declare function getConvertUsdAmount(balance: ConvertBalanceState | undefined, decimals: number): number | undefined; /** * What Max fills in for a Convert source, in its base units: the balance less * its fee reserve. `null` disables Max: no source yet, the balance is * unavailable or not yet read, or a native EVM source's gas price is loading. */ export declare function getConvertMaxAmount({ asset, balance, isFeeReserveLoading, getMaxSpendable, }: { asset: ConvertResolvedAsset | undefined; balance: ConvertBalanceState | undefined; /** A native EVM source's gas price is loading, so Max is unknown. */ isFeeReserveLoading: boolean; /** The balance less its fee reserve. */ getMaxSpendable: (balance: Dnum) => Dnum; }): bigint | null; /** * Calls the host getter and parses its result. A throw or timeout is logged * and rethrown so the query keeps the last good read instead of replacing it. */ export declare function fetchConvertBalances({ assets, getBalances, timeoutMs, logPrefix, }: { assets: ConvertResolvedAsset[]; getBalances: GetConvertBalances; timeoutMs?: number; logPrefix?: string; }): Promise;