import { SupportedChainSlug, SupportedChainType, EvmChainSlug as EvmChainSlug$1, StarknetChainSlug as StarknetChainSlug$1, CosmosChainSlug as CosmosChainSlug$1, SolanaChainSlug as SolanaChainSlug$1 } from './chains.js'; export { COSMOS_CHAIN_SLUGS, DB_IDENTIFIER_TO_CHAIN_SLUG, EVM_CHAIN_SLUGS, STARKNET_CHAIN_SLUGS, SUPPORTED_CHAINS, SUPPORTED_CHAIN_MAP, SUPPORTED_CHAIN_SLUGS, SUPPORTED_CHAIN_TYPES } from './chains.js'; import { JsonRpcErrorEnvelope, jsonRpcSuccessEnvelopeSchema, JsonRpcId, JsonRpcRequest } from './json-rpc.js'; export { JsonRpcId, JsonRpcRequest } from './json-rpc.js'; import { z } from 'zod'; import { ChainHealthData, ReceiptData, BlockHeightData, GasComparisonData, BlockTransactionsData, GetBlockByNumberParams, BatchBlockResultsData, GetBlockByHashParams, GetTransactionByHashParams, BatchTransactionResultsData, GasEstimateData, SimulateCallData, BalanceData, ContractCodeData, TraceTransactionData } from './core.js'; export { BalanceData, BatchBlockResultsData, BatchTransactionResultsData, BlockHeightData, BlockTransaction, BlockTransactionsData, ContractCodeData, GasComparisonData, GasComparisonEntry, GasEstimateData, GetBlockByHashParams, GetBlockByNumberParams, GetTransactionByHashParams, ReceiptData, SimulateCallData, SimulateCallParams, TraceTransactionData } from './core.js'; import { GetLogsParams, GetTransfersParams, TokenAllowanceData, LogsData, TransfersData } from './logs.js'; export { LogEntry, LogsData, TokenAllowanceData, TransferEntry, TransfersData } from './logs.js'; import { TokenMetadataData } from './tokens.js'; export { TokenMetadataData } from './tokens.js'; import { GetYieldsBestParams, BestYieldEntry, LendingProtocol as LendingProtocol$1, StakingProtocol as StakingProtocol$1, VaultProtocol as VaultProtocol$1, PoolFilterParams, YieldsData, BestYieldsData, GetYieldsBalanceParams, PoolBalanceData, GetYieldsPriceParams, PoolPriceData, GetYieldsPendleImpliedApyParams, MorphoVaultsData, MorphoVaultDataList } from './yields.js'; export { ADDRESS_POOL_PROTOCOLS, ALL_YIELD_PROTOCOLS, ApyBreakdown, BestYieldEntry, BestYieldsData, GetYieldsBalanceParams, GetYieldsPendleImpliedApyParams, GetYieldsPriceParams, LENDING_PROTOCOLS, MorphoVault, MorphoVaultDataItem, MorphoVaultDataList, MorphoVaultsData, PRICE_YIELD_PROTOCOLS, PoolBalanceData, PoolFilterParams, PoolPriceData, STAKING_PROTOCOLS, TvlBreakdown, VAULT_PROTOCOLS, YieldPoolDetail, YieldsData } from './yields.js'; import { GetAvantisPriceParams, GetUniswapV3QuoteParams, GetUniswapV4QuoteParams, DefiPositionProtocolSlug, ProtocolPositionData, PendleInfoData, DefiSummaryData, RevokeTxData, SwapQuoteData, GetJupiterQuoteParams, JupiterQuoteData, GetJupiterPriceParams, JupiterPriceData, CurvePoolsData, CurveLlamaLendMarketsData, AvantisVaultPriceData, ApprovalsData, FundingRatesData, HyperliquidFundingData, DydxFundingData } from './defi.js'; export { AAVE_V2_PROTOCOL_SLUG, AAVE_V3_PROTOCOL_SLUG, ApprovalEntry, ApprovalsData, AvantisVaultPriceData, COMPOUND_V2_PROTOCOL_SLUG, COMPOUND_V3_PROTOCOL_SLUG, CURVE_LLAMALEND_PROTOCOL_SLUG, CURVE_PROTOCOL_SLUG, CurveLlamaLendMarketsData, CurvePoolsData, DEFI_POSITION_PROTOCOL_SLUGS, DydxFundingData, FundingRateEntry, FundingRatesData, GetJupiterPriceParams, GetJupiterQuoteParams, HyperliquidFundingData, JupiterPriceData, JupiterQuoteData, JupiterRoutePlanStep, LIDO_PROTOCOL_SLUG, MORPHO_PROTOCOL_SLUG, PENDLE_V2_PROTOCOL_SLUG, SwapQuoteData } from './defi.js'; import { PriceData, PriceHistoryData, TopPricesData, TokenSearchData, TokenAddressesData } from './prices.js'; export { PriceData, PriceHistoryData, PriceHistoryPoint, TokenAddressesData, TokenSearchData, TopPricesData } from './prices.js'; import { NftBalanceData, NftBatchBalanceData, NftCollectionData, NftStandard, NftMetadataData, NftTokensData, NftTokenOwnerData } from './nfts.js'; export { NftStandard, NftTokenOwnerData } from './nfts.js'; import { EnsResolveData, EnsReverseData } from './ens.js'; export { EnsResolveData, EnsReverseData } from './ens.js'; import { ProtocolEntry as ProtocolEntry$1, RegistrySlugsData, ProtocolContractsData, ProtocolAddressData } from './registry.js'; export { ProtocolAddressData, ProtocolContractsData, RegistrySlugsData } from './registry.js'; import { RpcRequest, RpcResponse } from './rpc.js'; export { RpcErrorResponse, RpcRequest, RpcResponse, RpcSuccessResponse } from './rpc.js'; import { MulticallResult as MulticallResult$1, SimulateContractResult as SimulateContractResult$1, ReadContractParams, SimulateContractParams, AbiParam } from './contracts.js'; export { AbiParam, ContractAbi, ContractAbiFunction, ReadContractParams, SimulateContractParams } from './contracts.js'; import { GetSolanaSignaturesParams, SolanaTokenAccountsData, SolanaTokenAccount as SolanaTokenAccount$1, SolanaAccountInfo, SolanaTransactionData, SolanaSignatureInfo } from './solana.js'; export { SolanaAccountInfo, SolanaBalanceData, SolanaSignatureInfo, SolanaSignatureStatus, SolanaTransactionData } from './solana.js'; import { CosmosAccountData, CosmosDelegationsData, CosmosUnbondingDelegationsData, CosmosStakingRewardsData, CosmosValidatorsData, CosmosValidatorData, CosmosStakingPoolData, DenomSupplyData, CosmosBlockResultsData } from './cosmos.js'; export { CosmosAccountData, CosmosBlockResultsData, CosmosCoinAmount, CosmosDelegationsData, CosmosStakingPoolData, CosmosStakingRewardsData, CosmosUnbondingDelegationsData, CosmosValidatorData, CosmosValidatorsData, DenomSupplyData } from './cosmos.js'; import { PortfolioData, SolanaPortfolioData } from './portfolio.js'; export { PortfolioData, PortfolioToken } from './portfolio.js'; import { ListMarketplaceMethodsParams, ListMarketplaceMethodsData, MarketplaceContractData, MarketplaceMethodCallParams, MarketplaceMethodCallData } from './marketplace.js'; export { ListMarketplaceMethodsData, ListMarketplaceMethodsParams, MarketplaceContractData, MarketplaceMethodCallData, MarketplaceMethodCallParams, MarketplaceMethodEntry } from './marketplace.js'; import { GetNetworkCalendarParams, GetNetworkCalendarData } from './network-calendar.js'; export { GetNetworkCalendarData, GetNetworkCalendarParams, NetworkCalendarChainType, NetworkCalendarEntry, NetworkCalendarEventType } from './network-calendar.js'; import { StarknetBlockId } from './starknet.js'; export { StarknetBlockId } from './starknet.js'; /** All supported chain slugs, with a forward-compatible string escape hatch for the SDK. */ type ChainSlug = SupportedChainSlug | (string & {}); /** Chain type categories */ type ChainType = SupportedChainType; /** Chain information returned by the API */ interface ChainInfo { name: string; slug: ChainSlug; chainId: string; type: ChainType; archive: boolean; spectrumChainName: ChainSlug; } /** EVM-only chain slugs, with a forward-compatible string escape hatch for the SDK. */ type EvmChainSlug = EvmChainSlug$1 | (string & {}); type CosmosChainSlug = CosmosChainSlug$1; type StarknetChainSlug = StarknetChainSlug$1; type SolanaChainSlug = SolanaChainSlug$1; /** Cache configuration */ interface CacheConfig { /** Enable/disable response caching. Default: true */ enabled?: boolean; /** Default cache TTL in milliseconds. Default: 5000 (5s). Block heights, gas, raw RPC, and health methods are never cached. Yields and token metadata have longer built-in TTLs. */ ttl?: number; /** Max number of cached entries (LRU eviction). Default: 1024 */ maxEntries?: number; /** Per-method TTL overrides in milliseconds */ overrides?: Record; } /** Logging configuration */ interface LogConfig { /** Log level. Default: 'warn' */ level?: 'debug' | 'info' | 'warn' | 'error' | 'silent'; } /** Request/response lifecycle hooks */ interface Hooks { onRequest?: (req: { method: string; path: string; params?: Record; }) => void; onResponse?: (res: { status: number; duration: number; path: string; }) => void; onError?: (err: { message: string; status?: number; path: string; }) => void; } /** Main SDK configuration */ interface SpectrumConfig { /** Full Spectrum API URL. */ api?: string; /** Default chain for all calls. Override per-method. */ defaultChain?: ChainSlug; /** Request timeout in milliseconds. Default: 30000 (30s) */ timeout?: number; /** Max retries on transient failure. Default: 3 */ retries?: number; /** Response cache settings */ cache?: CacheConfig; /** Logging configuration */ logging?: LogConfig; /** Request/response lifecycle hooks */ hooks?: Hooks; } /** Resolved config with all defaults applied */ interface ResolvedConfig { baseUrl: string; defaultChain?: ChainSlug; timeout: number; retries: number; cache: Required> & { overrides: Record; }; logging: Required; hooks: Hooks; } interface RequestOptions { cacheTtl?: number; noRetry?: boolean; signal?: AbortSignal; } interface HistoricalQueryOptions { blockHeight?: number; } interface StarknetBlock { block_hash?: string; block_number?: number; parent_hash?: string; new_root?: string; timestamp?: number; sequencer_address?: string; status?: string; transactions: Array>; [key: string]: unknown; } interface StarknetTransaction { transaction_hash?: string; type?: string; version?: string; [key: string]: unknown; } interface StarknetCallRequest { contract_address: string; entry_point_selector: string; calldata: string[]; } interface StarknetEventsFilter { from_block?: StarknetBlockId; to_block?: StarknetBlockId; address?: string; keys?: string[][]; chunk_size?: number; continuation_token?: string; } type MulticallResult = Omit & { result?: T; }; type SimulateContractResult = Omit & { result?: T; gasUsed?: bigint; }; type ChainHealthResult = Omit & { type: string; }; type LogsFilter = Omit; type TransfersFilter = Omit; type ReceiptResult = ReceiptData & Record; type LendingProtocol = LendingProtocol$1 | (string & {}); type VaultProtocol = VaultProtocol$1 | (string & {}); type StakingProtocol = StakingProtocol$1 | (string & {}); type DefiProtocolSlug = DefiPositionProtocolSlug | (string & {}); type StakingFilter = Omit & { chain?: string; }; type BestYieldsFilter = Omit & { type?: BestYieldEntry['type'] | 'all'; }; type UniswapQuoteParams = Omit; type UniswapV4QuoteParams = Omit; type AvantisVaultParams = Omit; type ProtocolPositionResult = ProtocolPositionData & Record; type PendleInfoResult = PendleInfoData & Record; type DefiSummaryResult = DefiSummaryData & Record; type RevokeTxResult = Extract; interface HealthResponse { status: string; } type JsonRpcSuccessResponse = z.infer>>; type JsonRpcErrorResponse = JsonRpcErrorEnvelope; type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse; type NftCollectionResult = Omit & { standard: NftStandard | null; }; type NftBalanceResult = Omit & { balance: string; }; type NftTokensResult = Omit & { tokenIds: string[]; total: string; capped: boolean; }; type NftBatchBalanceResult = Omit & { results: Array<{ address: string; tokenId: string; balance: string; }>; }; type NftTokenMetadataResult = Omit & { standard: NftStandard; owner: string | null; tokenURI: string | null; metadata: unknown; }; type ProtocolEntry = Omit & { version: string; }; type SolanaTokenAccount = Omit & { account: Omit & { data: Omit & { parsed: Omit & { info: Omit & { tokenAmount: Omit & { uiAmount: number; }; }; }; }; }; }; type SolanaTokenAccountsResult = Omit & { value: SolanaTokenAccount[]; }; type SignaturesFilter = Omit; /** Base error class for all Spectrum SDK errors */ declare class SpectrumError extends Error { readonly status?: number; readonly path?: string; constructor(message: string, status?: number, path?: string); } /** API returned an error response */ declare class ApiError extends SpectrumError { readonly body?: unknown; constructor(message: string, status: number, path: string, body?: unknown); } /** Request was rate limited (HTTP 429) */ declare class RateLimitError extends SpectrumError { readonly retryAfter?: number; constructor(path: string, retryAfter?: number); } /** Chain slug not recognized */ declare class ChainNotFoundError extends SpectrumError { readonly chain: string; constructor(chain: string); } /** Request timed out */ declare class TimeoutError extends SpectrumError { readonly timeout: number; constructor(path: string, timeout: number); } /** Network/connection error */ declare class NetworkError extends SpectrumError { constructor(path: string, cause?: Error); } /** Invalid parameter passed to the SDK */ declare class ValidationError extends SpectrumError { readonly field: string; constructor(field: string, message: string); } /** Simple in-memory TTL cache with LRU eviction */ declare class Cache { private store; private readonly maxEntries; constructor(maxEntries?: number); get(key: string): T | undefined; set(key: string, value: T, ttlMs: number): void; has(key: string): boolean; delete(key: string): void; clear(): void; get size(): number; } type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'; declare class Logger { private level; constructor(level?: LogLevel); setLevel(level: LogLevel): void; debug(message: string, ...args: unknown[]): void; info(message: string, ...args: unknown[]): void; warn(message: string, ...args: unknown[]): void; error(message: string, ...args: unknown[]): void; } /** * Internal HTTP transport for the SDK. Owns the only path that talks to the * network. Every namespace ultimately routes through one of `jsonRpc`, * `rpcProxy`, or `rpcProxyBatch` here. * * Not exposed to end users — they use the `Spectrum` class. Exported for * SDK-internal use and for unit tests. */ declare class HttpClient { readonly config: ResolvedConfig; readonly cache: Cache; readonly logger: Logger; /** * Build a client from an already-resolved config. Sets up the in-memory * cache and logger; does no network I/O. */ constructor(config: ResolvedConfig); /** * Send a raw POST with the given JSON body to the configured `baseUrl`. * Bypasses the cache — used by `Spectrum.jsonRpc(...)` for caller-supplied * raw envelopes. */ post(body: unknown, options?: RequestOptions): Promise; /** * Send a single JSON-RPC call to `POST /v1`. Reads + writes the cache when * the resolved TTL is positive (see `getJsonRpcCacheTtl`). Throws a typed * `SpectrumError` subclass on failure; on success returns the inner `data`. */ jsonRpc(method: string, params?: Record | unknown[], options?: RequestOptions): Promise; /** * Wrap a node-level JSON-RPC call (e.g. `eth_call`) inside Spectrum's * `rpcProxy` server method. Forces `cacheTtl: 0` — node RPC results are * never cached because chain head moves. */ rpcProxy(chain: string, request: { method: string; params?: unknown[]; id?: JsonRpcId; }, options?: RequestOptions): Promise; /** * Send a batch of node-level RPC calls as a single outer JSON-RPC batch * where each entry is an `rpcProxy` envelope. The inner array is returned * with each entry already unwrapped (envelope errors throw `ApiError`). * Cache forced off; ids default to `index + 1` when not supplied. */ rpcProxyBatch(chain: string, requests: Array<{ method: string; params?: unknown[]; id?: JsonRpcId; }>, options?: RequestOptions): Promise; /** Drop every cached response. Doesn't affect inflight requests. */ clearCache(): void; /** * Validate a JSON-RPC 2.0 envelope and return its inner result. * * - Missing/non-object payloads → `ApiError` (invalid response) * - Envelope-level `error` field → `ApiError` (server-reported failure) * - Envelope `result` present → unwraps the `data` envelope if shaped that way * - Envelope with neither `result` nor `error` → `ApiError` (malformed) */ private unwrapJsonRpcResponse; /** * Strip Spectrum's `{ data: ... }` wrapper if present. Some responses embed * the payload one level deep; others (raw RPC pass-through) don't. */ private extractDataEnvelope; /** * Compose a deterministic cache key from a JSON-RPC `method` + `params`. * Uses `stableStringify` so logically-equivalent params (e.g. `{a:1,b:2}` * vs `{b:2,a:1}`) produce the same key. */ private buildJsonRpcCacheKey; /** * Stable JSON serializer for cache keys: sorts object keys alphabetically * and drops properties whose value is `undefined`. Arrays preserve order * (it matters for ABI args, RPC params, etc.). Not RFC-compliant — output * is meant for cache key equality only. */ private stableStringify; /** * Core request orchestrator. Wraps `fetch` with: * 1. retry (`withRetry`) — driven by `isRetryable` (5xx, 408, NetworkError, etc.) * 2. lifecycle hooks — `onRequest` per attempt, `onResponse` on success, * `onError` once at the end for non-abort SDK failures * 3. error mapping — non-2xx → `handleErrorResponse`; thrown DOMExceptions * become `TimeoutError`; other thrown errors become `NetworkError`; * caller-aborted requests rethrow the raw `DOMException` and skip the * `onError` hook */ private execute; /** * Wrap `globalThis.fetch` with a config-driven timeout and combined abort * signal. The caller's `signal` (if any) is merged with our internal * timeout signal so either can cancel the request. Cleans up event * listeners + the timeout in `finally`. */ private fetch; /** * Polyfill for `AbortSignal.any` on runtimes that don't have it yet. * Forwards aborts from `external` to our internal `controller`, returning * the controller's signal plus a cleanup function the caller MUST run to * remove the listener (avoids leaks on long-lived external signals). */ private linkSignals; /** * Map a non-2xx HTTP response to the SDK's typed error hierarchy. * * 429 → `RateLimitError` (parses `Retry-After` if present) * 404 + chain msg → `ChainNotFoundError` (case-insensitive, * tolerates trailing punctuation in the server text) * anything else → `ApiError` with original status + body * * Always throws — return type is `Promise`. */ private handleErrorResponse; /** Return the configured `baseUrl` with any trailing slash stripped. * Also used as the `path` label populated on errors and hook payloads. */ endpointUrl(): string; /** * Resolve the cache TTL (ms) for a given JSON-RPC method. Order: * 1. user-supplied `cache.overrides` — first substring match wins * 2. uncacheable: `rpcProxy`, `getHealth`, `getChainHealth`, `compareGas`, * `estimateGas`, `getBlock*` → 0 * 3. `getYields*`, `getNft*`, `getCurve*`, `getMorpho*`, `getPendleV2Info`, * `getDefiSummary` → 60 s (slow-moving on-chain data) * 4. `getTokenMetadata`, `getRegistry*`, `getProtocols`, `getProtocol` * → 5 min (effectively static) * 5. fallback: `config.cache.ttl` (default 5 s) */ private getJsonRpcCacheTtl; } /** Shared mutable reference to the current default chain. */ declare class ChainRef { current?: ChainSlug; constructor(initial?: ChainSlug); } /** * Base for namespaces whose methods accept an optional `chain` argument and * fall back to the SDK-wide default chain (`Spectrum.setChain` / config). * * Provides the shared `resolve()` helper so each namespace doesn't redeclare it. */ declare abstract class ChainNamespace { protected readonly client: HttpClient; protected readonly chainRef: ChainRef; constructor(client: HttpClient, chainRef: ChainRef); protected resolve(chain?: ChainSlug): ChainSlug; } /** Block height and gas data */ declare class CoreNamespace extends ChainNamespace { /** * Get the current block height for a chain. */ getBlockHeight(chain?: ChainSlug, options?: RequestOptions): Promise; /** * Get gas fee comparison across all EVM chains. * Returns base fee, priority fee, and estimated USD cost per chain. */ getGasComparison(options?: RequestOptions): Promise; /** * Get all transactions in a specific block. */ getBlockTransactions(chain: ChainSlug | undefined, blockNumber: number, options?: RequestOptions): Promise; /** * Fetch one or more blocks by height across any supported chains in a single * batch (max 50 items). Bitcoin is supported; its `block` field carries a * Bitcoin block height (integer), and the response contains the full Bitcoin * Core `getblock` payload — including a `confirmations` field that drifts * over time as new tip blocks arrive. */ getBlockByNumber(items: GetBlockByNumberParams, options?: RequestOptions): Promise; /** * Fetch one or more blocks by hash across any supported chains in a single * batch (max 50 items). EVM and Solana chains use this method; Bitcoin's * JSON-RPC handler accepts hashes too, but no test vector currently exercises * it — Bitcoin block lookups generally go through `getBlockByNumber`. */ getBlockByHash(items: GetBlockByHashParams, options?: RequestOptions): Promise; /** * Fetch one or more transactions by hash across any supported chains in a * single batch (max 50 items). Same batch shape as `getBlockByHash` — * pass an array of `{ chain, hash }` pairs. */ getTransactionByHash(items: GetTransactionByHashParams, options?: RequestOptions): Promise; /** * Estimate gas (EVM) or fees (Starknet) for a transaction. EVM + Starknet. */ estimateGas(chain: EvmChainSlug | StarknetChainSlug | undefined, params: { to: string; from?: string; value?: string; data?: string; }, options?: RequestOptions): Promise; /** * Simulate a read-only contract call without submitting a transaction. * * EVM chains return `{ chain, result }` (hex `eth_call` output). Starknet returns * `{ chain, contractAddress, entryPointSelector, calldata, result }`, mapping `to` → * contract address, `data` → entry-point selector, and `value` → a single calldata felt; * for multi-felt calldata use `starknet.call(...)`. Other chain types are rejected by the server. */ simulateCall(chain: EvmChainSlug | StarknetChainSlug | undefined, params: { to: string; data: string; from?: string; value?: string; block?: string; blockHeight?: number; }, options?: RequestOptions): Promise; } /** Token balances and metadata */ declare class TokensNamespace extends ChainNamespace { /** * Get the native token balance for an address. */ getBalance(chain: ChainSlug | undefined, address: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; /** * Get a specific ERC-20/SPL token balance for an address. */ getTokenBalance(chain: ChainSlug | undefined, address: string, token: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; /** * Get token metadata. EVM chains return name/symbol/decimals/total supply; Cosmos * chains return denom metadata (pass the denom as `tokenAddress`); Solana returns * name/symbol/decimals/supply/uri from Metaplex or the Token-2022 extension. */ getMetadata(chain: EvmChainSlug | CosmosChainSlug | SolanaChainSlug | undefined, tokenAddress: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; /** Get ERC-20 token allowance. EVM only. */ getAllowance(chain: EvmChainSlug | undefined, tokenAddress: string, params: { owner: string; spender: string; blockHeight?: number; }, options?: RequestOptions): Promise; } /** DeFi yield data — lending, vaults, staking, best yields */ declare class YieldsNamespace { private readonly client; constructor(client: HttpClient); /** * Get lending protocol yields (APY, TVL). * Requires chain, protocol, and pool to be specified. * * Supported protocols: aave, compound, morpho, hyperlend */ getLending(filter?: PoolFilterParams, options?: RequestOptions): Promise; /** * Get vault protocol yields (APY, TVL). * Requires chain, protocol, and pool to be specified. * * Supported protocols: beefy, yearn, pendle, hyperliquid */ getVaults(filter?: PoolFilterParams, options?: RequestOptions): Promise; /** * Get staking yields across protocols and chains. * * Calls the `getYieldsBest` JSON-RPC method with `type=staking` for * server-side filtering. Chain filtering is applied client-side after fetch. * * Sources: Lido, Rocket Pool, Jito, Marinade, BlazeStake */ getStaking(filter?: StakingFilter, options?: RequestOptions): Promise; /** * Get the best yields across lending, vaults, and staking. * Returns a ranked list sorted by total APY. */ getBest(filter?: BestYieldsFilter, options?: RequestOptions): Promise; /** * Get user balance in a specific yield pool. * Requires chain, protocol, pool, and address. */ getBalance(filter: GetYieldsBalanceParams, options?: RequestOptions): Promise; /** * Get pool price for a yield protocol. * Supported protocols: aave, morpho, pendle, midas. */ getPrice(filter: GetYieldsPriceParams, options?: RequestOptions): Promise; /** * Get Pendle implied APY for a user's position. * Requires chain, pool, and address. */ getPendleImpliedApy(filter: GetYieldsPendleImpliedApyParams, options?: RequestOptions): Promise; /** * List all available Morpho vaults on a chain. */ getMorphoVaults(chain: string, options?: RequestOptions): Promise; /** * Get detailed data for specific Morpho vaults (APY, TVL, fees, rewards). * Maximum 50 vaults per request. */ getMorphoVaultData(chain: string, vaults: string[], options?: RequestOptions): Promise; } /** Utility and infrastructure methods */ declare class UtilsNamespace { private readonly client; constructor(client: HttpClient); /** * Check API health status. */ health(options?: RequestOptions): Promise; } /** Token prices, price history, and token discovery */ declare class PricesNamespace { private readonly client; constructor(client: HttpClient); /** Get current price for a token symbol. */ getPrice(symbol: string, options?: RequestOptions): Promise; /** Get price history for a token symbol. */ getPriceHistory(symbol: string, params?: { days?: number; currency?: string; }, options?: RequestOptions): Promise; /** Get top tokens by market cap. */ getTopPrices(params?: { limit?: number; currency?: string; }, options?: RequestOptions): Promise; /** Search for tokens by name or symbol. */ searchTokens(query: string, params?: { limit?: number; }, options?: RequestOptions): Promise; /** Get known contract addresses for a token symbol across chains. */ getTokenAddresses(symbol: string, options?: RequestOptions): Promise; } /** DeFi protocol interactions — swaps, positions, approvals, funding rates */ declare class DefiNamespace extends ChainNamespace { private getPositionMethod; /** Get a Uniswap V3 swap quote. */ getUniswapV3Quote(chain: ChainSlug | undefined, params: UniswapQuoteParams, options?: RequestOptions): Promise; /** Get a Uniswap V2 swap quote. */ getUniswapV2Quote(chain: ChainSlug | undefined, params: Omit, options?: RequestOptions): Promise; /** Get a Uniswap V4 swap quote. */ getUniswapV4Quote(chain: ChainSlug | undefined, params: UniswapV4QuoteParams, options?: RequestOptions): Promise; /** Get a Jupiter swap quote (Solana only). */ getJupiterQuote(params: GetJupiterQuoteParams, options?: RequestOptions): Promise; /** Get Jupiter price (Solana only). */ getJupiterPrice(params: GetJupiterPriceParams, options?: RequestOptions): Promise; /** Get a user's position in a specific DeFi protocol. */ getPosition(chain: ChainSlug | undefined, protocol: DefiProtocolSlug, address: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; /** Get Curve pools for a chain. */ getCurvePools(chain?: ChainSlug, options?: RequestOptions): Promise; /** Get Curve LlamaLend markets. */ getCurveLlamaLendMarkets(chain?: ChainSlug, params?: HistoricalQueryOptions, options?: RequestOptions): Promise; /** Get Curve LlamaLend positions for an address. */ getCurveLlamaLendPosition(chain: ChainSlug | undefined, address: string, params?: HistoricalQueryOptions, options?: RequestOptions): Promise; /** * Get Avantis vault deposit and redemption prices. * Returns both the gross share value (deposit) and net after fees (redemption). */ getAvantisPrice(chain: ChainSlug | undefined, params: AvantisVaultParams, options?: RequestOptions): Promise; /** Get Pendle V2 info for a chain. */ getPendleInfo(chain?: ChainSlug, options?: RequestOptions): Promise; /** Get DeFi summary for an address across all protocols on a chain. */ getSummary(chain: ChainSlug | undefined, address: string, options?: RequestOptions): Promise; /** Get all token approvals for an address. */ getApprovals(chain: ChainSlug | undefined, address: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; /** Get unsigned revoke transaction for a token approval. */ getRevokeTransaction(chain: ChainSlug | undefined, address: string, params: { token: string; spender: string; }, options?: RequestOptions): Promise; /** Get funding rates across all perps protocols. */ /** * Get the combined funding-rate overview across all perps providers. * * Returns the server's aggregate shape `{ hyperliquid, dydx, timestamp }` — * one array per provider, not a flattened union. If you want a single flat * list, splat in the caller: `[...res.hyperliquid, ...res.dydx]`. */ getAllFundingRates(options?: RequestOptions): Promise; /** Get Hyperliquid funding rate(s). */ getHyperliquidFunding(params?: { coin?: string; }, options?: RequestOptions): Promise; /** Get dYdX funding rate(s). */ getDydxFunding(params?: { ticker?: string; }, options?: RequestOptions): Promise; } /** NFT collection data, balances, ownership, and metadata */ declare class NftsNamespace extends ChainNamespace { /** Get NFT collection info. */ getCollection(chain: ChainSlug | undefined, contract: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; /** Get NFT balance (count) for an address. */ getBalance(chain: ChainSlug | undefined, contract: string, address: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; /** Get token IDs owned by an address (ERC-721 Enumerable only). */ getOwnedTokens(chain: ChainSlug | undefined, contract: string, address: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; /** Batch balance query for ERC-1155 tokens. Max 100 pairs. */ getBatchBalance(chain: ChainSlug | undefined, contract: string, params: { addresses: string[]; tokenIds: string[]; }, options?: RequestOptions): Promise; /** Get ERC-1155 balance for a specific token ID. */ getTokenBalance(chain: ChainSlug | undefined, contract: string, address: string, tokenId: string, options?: RequestOptions): Promise; /** Get owner of a specific token ID. */ getTokenOwner(chain: ChainSlug | undefined, contract: string, tokenId: string, options?: RequestOptions): Promise; /** Get metadata for a specific token ID. */ getTokenMetadata(chain: ChainSlug | undefined, contract: string, tokenId: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; } /** ENS name resolution */ declare class EnsNamespace { private readonly client; constructor(client: HttpClient); /** Resolve an ENS name to an address. */ resolve(name: string, options?: RequestOptions): Promise; /** Reverse lookup — get ENS name for an address. */ reverse(address: string, options?: RequestOptions): Promise; } /** Protocol registry — protocols, contracts, chain metadata */ declare class RegistryNamespace { private readonly client; constructor(client: HttpClient); /** List protocols, optionally filtered by category or chain. */ getProtocols(filter?: { category?: string; chain?: string; }, options?: RequestOptions): Promise; /** Get full details for a protocol by slug. */ getProtocol(slug: string, options?: RequestOptions): Promise; getRegistrySlugs(filter?: { category?: string; chain?: string; }, options?: RequestOptions): Promise; /** Get contract ABIs and addresses for a protocol. */ getProtocolContracts(slug: string, params?: { chain?: string; }, options?: RequestOptions): Promise; /** Resolve a specific contract address for a protocol on a chain. */ getAddress(slug: string, contract: string, chain: string, options?: RequestOptions): Promise; /** Get all protocol categories. */ getCategories(options?: RequestOptions): Promise; /** Get all supported chains. */ getChains(options?: RequestOptions): Promise; } /** Direct JSON-RPC proxy to chain nodes */ declare class RpcNamespace extends ChainNamespace { /** * Send a raw JSON-RPC request to a chain's node. * Proxies directly to the node — supports any standard JSON-RPC method * (eth_*, trace_*, debug_*, net_*, web3_*, etc.) */ request(chain: ChainSlug | undefined, req: RpcRequest, options?: RequestOptions): Promise; /** * Send a batch of JSON-RPC requests to a chain's node. * Max size is enforced by the shared `MAX_JSON_RPC_BATCH_SIZE`. */ requestBatch(chain: ChainSlug | undefined, requests: RpcRequest[], options?: RequestOptions): Promise; /** * Shorthand: send a single RPC method and return just the result. * Throws if the node returns an error. */ send(chain: ChainSlug | undefined, method: string, params?: unknown[], options?: RequestOptions): Promise; } /** Smart contract read operations via RPC proxy */ declare class ContractsNamespace extends ChainNamespace { private executeRpcBatch; /** * Call a read-only (view/pure) function on a smart contract. * ABI-encodes the call, sends eth_call via the RPC proxy, and decodes the result. */ readContract(chain: ChainSlug | undefined, params: ReadContractParams, options?: RequestOptions): Promise; /** * Execute multiple contract reads in a single batch RPC call. */ multicall(chain: ChainSlug | undefined, params: { calls: ReadContractParams[]; }, options?: RequestOptions): Promise; /** * Simulate a contract write call without sending a transaction. * Uses eth_call with full tx params to check if a write would succeed, * and eth_estimateGas to estimate gas cost. */ simulateContract(chain: ChainSlug | undefined, params: SimulateContractParams, options?: RequestOptions): Promise>; /** * Check if an address is a contract and get its bytecode (Starknet: its class). EVM + Starknet. */ getCode(chain: EvmChainSlug | StarknetChainSlug | undefined, address: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; private findFunction; } /** * Solana-specific convenience methods. * All calls proxy through the Spectrum API JSON-RPC `rpcProxy` method. */ declare class SolanaNamespace { private readonly client; constructor(client: HttpClient); /** * Get the current slot (equivalent to block height). */ getSlot(options?: RequestOptions): Promise; /** * Get the current block height. */ getBlockHeight(options?: RequestOptions): Promise; /** * Get SOL balance for an address in SOL (not lamports). */ getBalance(address: string, options?: RequestOptions): Promise; /** * Get raw SOL balance in lamports. */ getBalanceLamports(address: string, options?: RequestOptions): Promise; /** * Get account info for a Solana address. */ getAccountInfo(address: string, encoding?: 'base64' | 'jsonParsed', options?: RequestOptions): Promise; /** * Get all SPL token accounts for a wallet. */ getTokenAccountsByOwner(owner: string, opts?: { mint?: string; programId?: string; }, options?: RequestOptions): Promise; /** * Get a confirmed transaction by signature. */ getTransaction(signature: string, options?: RequestOptions): Promise; /** * Get recent transaction signatures for an address. */ getSignaturesForAddress(address: string, filter?: SignaturesFilter, options?: RequestOptions): Promise; /** * Get the latest blockhash. */ getLatestBlockhash(options?: RequestOptions): Promise<{ blockhash: string; lastValidBlockHeight: number; }>; /** * Get minimum balance required for rent exemption. */ getMinimumBalanceForRentExemption(dataSize: number, options?: RequestOptions): Promise; /** * Check if a blockhash is still valid. */ isBlockhashValid(blockhash: string, options?: RequestOptions): Promise; /** * Get the current epoch info. */ getEpochInfo(options?: RequestOptions): Promise<{ epoch: number; slotIndex: number; slotsInEpoch: number; absoluteSlot: number; blockHeight: number; }>; /** * Get token supply for an SPL token mint. */ getTokenSupply(mint: string, options?: RequestOptions): Promise<{ amount: string; decimals: number; uiAmount: number; uiAmountString: string; }>; /** * Send any Solana JSON-RPC method directly. */ request(req: { method: string; params?: unknown[]; }, options?: RequestOptions): Promise; private send; } declare class CosmosNamespace extends ChainNamespace { getAccount(chain: CosmosChainSlug | undefined, address: string, options?: RequestOptions): Promise; getDelegations(chain: CosmosChainSlug | undefined, delegator: string, options?: RequestOptions): Promise; getUnbondingDelegations(chain: CosmosChainSlug | undefined, delegator: string, options?: RequestOptions): Promise; getStakingRewards(chain: CosmosChainSlug | undefined, delegator: string, options?: RequestOptions): Promise; getValidators(chain?: CosmosChainSlug, options?: RequestOptions): Promise; getValidator(chain: CosmosChainSlug | undefined, validatorAddr: string, options?: RequestOptions): Promise; getStakingPool(chain?: CosmosChainSlug, options?: RequestOptions): Promise; getDenomSupply(chain: CosmosChainSlug | undefined, denom: string, options?: RequestOptions): Promise; getBlockResults(chain: CosmosChainSlug | undefined, block: number, options?: RequestOptions): Promise; } /** Logs, transfers, receipts, portfolio, and chain health */ declare class DataNamespace extends ChainNamespace { /** Query event logs. EVM + Starknet. */ getLogs(chain: EvmChainSlug | StarknetChainSlug | undefined, filter?: LogsFilter, options?: RequestOptions): Promise; /** Get token transfers for an address. EVM only. */ getTransfers(chain: EvmChainSlug | undefined, address: string, filter?: TransfersFilter, options?: RequestOptions): Promise; /** Get a transaction receipt by hash. */ getReceipt(chain: ChainSlug | undefined, hash: string, options?: RequestOptions): Promise; /** Get portfolio for an address on a chain. EVM only. */ getPortfolio(chain: EvmChainSlug | SolanaChainSlug | undefined, address: string, paramsOrOptions?: HistoricalQueryOptions | RequestOptions, options?: RequestOptions): Promise; /** Get health status for a specific chain. */ getChainHealth(chain?: ChainSlug, options?: RequestOptions): Promise; /** * Trace a transaction's internal execution. EVM + Starknet. * Returns call traces showing internal calls, delegatecalls, and value transfers. */ traceTransaction(chain: EvmChainSlug | StarknetChainSlug | undefined, hash: string, options?: RequestOptions): Promise; } /** Marketplace custom ABI discovery, reads, and simulations */ declare class MarketplaceNamespace { private readonly client; constructor(client: HttpClient); /** List published marketplace methods (functions and events). */ listMethods(params?: ListMarketplaceMethodsParams, options?: RequestOptions): Promise; /** Fetch one marketplace contract and its deployments by app id. */ getContract(appId: string, options?: RequestOptions): Promise; /** * Call a published marketplace method by its JSON-RPC name * (`spectrum__[_]__`). * Operation is `call` (eth_call), `simulateCall` (eth_simulateV1), `getLogs`, * or reserved `write`. Concrete deployments resolve chain and address from * the method name. Template methods (no chain segment) require `chain` and * `address` in `params`. */ call(method: string, params?: Partial, options?: RequestOptions): Promise; } /** Approved network calendar entries (releases / upgrades). */ declare class NetworkCalendarNamespace { private readonly client; constructor(client: HttpClient); /** * List approved network calendar entries (releases / upgrades). * Optional filters: `month` (`YYYY-MM`), `day` (`YYYY-MM-DD` or `"today"`), * `chain` (network slug, e.g. `"ethereum"`). */ getNetworkCalendar(params?: GetNetworkCalendarParams, options?: RequestOptions): Promise; } /** * Top-level entry point for the Spectrum SDK. * * Holds a shared {@link HttpClient} + {@link ChainRef} and exposes typed * namespaces (`core`, `tokens`, `defi`, `cosmos`, `marketplace`, `networkCalendar`, …) plus low-level * escape hatches ({@link Spectrum.jsonRpc}, `rpc.*`). * * @example * const sdk = new Spectrum('https://spectrum-01.simplystaking.xyz/MY_KEY/'); * const eth = await sdk.tokens.getBalance('ethereum', '0xd8dA...'); */ declare class Spectrum { readonly core: CoreNamespace; readonly tokens: TokensNamespace; readonly yields: YieldsNamespace; readonly utils: UtilsNamespace; readonly prices: PricesNamespace; readonly defi: DefiNamespace; readonly nfts: NftsNamespace; readonly ens: EnsNamespace; readonly registry: RegistryNamespace; readonly rpc: RpcNamespace; readonly contracts: ContractsNamespace; readonly solana: SolanaNamespace; readonly cosmos: CosmosNamespace; readonly data: DataNamespace; readonly marketplace: MarketplaceNamespace; readonly networkCalendar: NetworkCalendarNamespace; private readonly client; private readonly chainRef; /** * Build a new SDK instance. * * Accepts either a {@link SpectrumConfig} object or the bare api URL string * as a shortcut (`new Spectrum(api)` ≡ `new Spectrum({ api })`). * * Throws if `api` is missing or isn't an http(s) URL. */ constructor(config: SpectrumConfig | string); /** * Send a raw JSON-RPC request (or batch) to Spectrum's `POST /v1` endpoint. * * Escape hatch for cases the typed namespaces don't cover — e.g. calling a * server method the SDK doesn't wrap yet. Batches are capped at * `MAX_JSON_RPC_BATCH_SIZE` (50); larger batches throw {@link ValidationError}. */ jsonRpc(request: JsonRpcRequest | JsonRpcRequest[], options?: RequestOptions): Promise; /** * Set the default chain used by methods called with `chain: undefined`. * Returns `this` so calls can be chained, e.g. `new Spectrum(cfg).setChain('base')`. */ setChain(chain: ChainSlug): this; /** Current default chain, or `undefined` if never configured. */ getChain(): ChainSlug | undefined; /** Drop every cached response. Use after writes that invalidate read state. */ clearCache(): void; } /** * ABI encoder/decoder powered by ethers.js. * Provides: encodeCall, decodeResult, parseHumanReadableAbi. * * Wraps ethers to (a) lowercase decoded addresses and (b) flatten ethers' Result * objects into plain JS arrays, so callers see consistent values. */ /** Internal normalized ABI function — api-spec's `ContractAbiFunction` has optional inputs/outputs. */ interface AbiFunction { name: string; type?: 'function' | 'constructor' | 'receive' | 'fallback'; inputs: AbiParam[]; outputs: AbiParam[]; stateMutability?: string; } /** ABI-encode a function call (0x + selector + encoded args). */ declare function encodeCall(fn: AbiFunction, args: unknown[]): string; /** Decode ABI-encoded return data into an array of values. */ declare function decodeResult(outputs: AbiParam[], data: string): unknown[]; /** * Parse a human-readable ABI string into an AbiFunction. * * @example * parseHumanReadableAbi('function balanceOf(address owner) view returns (uint256)') */ declare function parseHumanReadableAbi(sig: string): AbiFunction; export { type AbiFunction, ApiError, type AvantisVaultParams, type BestYieldsFilter, type CacheConfig, type ChainHealthResult, type ChainInfo, ChainNotFoundError, type ChainSlug, type ChainType, ContractsNamespace, CoreNamespace, type CosmosChainSlug, CosmosNamespace, DataNamespace, DefiNamespace, type DefiProtocolSlug, type DefiSummaryResult, EnsNamespace, type EvmChainSlug, type HealthResponse, type HistoricalQueryOptions, type Hooks, HttpClient, type JsonRpcErrorResponse, type JsonRpcResponse, type JsonRpcSuccessResponse, type LendingProtocol, type LogConfig, type LogsFilter, MarketplaceNamespace, type MulticallResult, NetworkCalendarNamespace, NetworkError, type NftBalanceResult, type NftBatchBalanceResult, type NftCollectionResult, type NftTokenMetadataResult, type NftTokensResult, NftsNamespace, type PendleInfoResult, PricesNamespace, type ProtocolEntry, type ProtocolPositionResult, RateLimitError, type ReceiptResult, RegistryNamespace, type RequestOptions, type ResolvedConfig, type RevokeTxResult, RpcNamespace, type SignaturesFilter, type SimulateContractResult, SolanaNamespace, type SolanaTokenAccount, type SolanaTokenAccountsResult, Spectrum, type SpectrumConfig, SpectrumError, type StakingFilter, type StakingProtocol, type StarknetBlock, type StarknetCallRequest, type StarknetChainSlug, type StarknetEventsFilter, type StarknetTransaction, TimeoutError, TokensNamespace, type TransfersFilter, type UniswapQuoteParams, type UniswapV4QuoteParams, UtilsNamespace, ValidationError, type VaultProtocol, YieldsNamespace, decodeResult, encodeCall, parseHumanReadableAbi };