/** * Token pricing. * * Dual-path: * 1. Bonding curve (liquidityAdded=false) → read on-chain * TokenManagerHelper3.getTokenInfo.lastPrice directly. No network round-trip * to a third-party pricing API. * 2. Graduated (liquidityAdded=true) → query GeckoTerminal * (`/api/v2/networks/bsc/tokens/{address}`) for PancakeSwap-derived price. * * BNB→USD conversion uses CoinGecko's free simple-price endpoint, cached for * 60 seconds in DataStore's global/bnb-price.json. * * All price outputs are in BNB per token (float). The raw on-chain lastPrice * is BNB-wei per smallest-token-unit (18 decimals); for meme tokens the price * is tiny (well below 1e-6 BNB), so converting via Number() is safe in * practice. If Week 3 bot code cares about sub-wei precision we'll switch to * BigInt-to-string formatting. */ import type { Address, PublicClient } from 'viem'; import type { TradingPathKind } from '../datastore/types.js'; /** * Where the price value came from (freshness axis). * * - `live` → just fetched from Helper3 or GeckoTerminal this invocation * - `cache` → served from DataStore pool-info within TTL * - `stale` → cache hit beyond TTL but upstream fetch failed (best-effort) */ export type PriceOrigin = 'live' | 'cache' | 'stale'; export type TokenPrice = { ca: Address; priceBnb: number; priceUsd: number; /** Trading path: bonding-curve / pancake (static token property) */ path: TradingPathKind; /** Freshness of this value */ origin: PriceOrigin; /** Unix ms */ updatedAt: number; liquidityAdded: boolean; }; /** * Get the current price of a Four.meme token. * * Cache-through: checks DataStore pool-info first; on miss or expiry, * fetches live and writes back. Network failures are surfaced via * throwing, but we fall back to cache if the fresh fetch fails and a stale * value exists. */ export declare function getTokenPrice(client: PublicClient, ca: Address, options?: { fetchImpl?: typeof fetch | undefined; }): Promise; /** * Get BNB → USD price with 60s cache. * * Primary source: on-chain PancakeSwap WBNB/USDT pair reserves (no external * API dependency — uses the same viem client that's already working for RPC). * * Fallback: CoinGecko simple/price endpoint (may fail in restricted networks). */ export declare function getBnbUsdPrice(clientOrFetch?: PublicClient | typeof fetch | undefined): Promise; //# sourceMappingURL=pricing.d.ts.map