/** * TxTracker — async tx confirmation + DataStore sink. * * After a command sends a transaction, it calls `trackInBackground(hash, ctx)` * and returns immediately. The tracker waits for the receipt in parallel and * writes a TransactionRecord + balance snapshot once the tx finalizes. * * Week 2 scope: * - Transfer flows (transfer in/out) and dry-run trades * - No on-chain event log decoding yet — we capture block info, gas, * status, and a "known amount" passed from the caller * * Week 3 scope (not done here): * - parseEventLogs for TokenManager2.TokenPurchase / TokenSale * - Holdings re-accounting (avgBuyPrice / realizedPnl) * * Fire-and-forget: tracker failures are silent — they must never break the * CLI's exit path or mask the original tx hash returned to the agent. */ import type { Address, Hash, PublicClient } from 'viem'; import type { TxType } from '../datastore/types.js'; export type TrackContext = { ca: Address; groupId: number; walletAddress: Address; txType: TxType; /** * Signed BNB delta known at submit time (positive = inbound, negative = outbound). * Used for transfers where the amount is part of the request, not an event. */ knownAmountBnb?: number; /** * Counterparty address (for BNB balance snapshot refresh). * Optional — if present, we also refresh their balance. */ counterparty?: Address | undefined; }; export type TrackingResult = { txHash: Hash; status: 'confirmed' | 'failed' | 'timeout'; blockNumber?: number | undefined; blockTime?: number | undefined; fee?: number | undefined; }; /** * Await a transaction, record it, refresh balances. * Always resolves — never throws. * * If `preReceipt` is provided the receipt wait is skipped entirely — use this * when the caller already awaited the receipt (e.g. sequential buy loop). */ export declare function trackTransaction(client: PublicClient, txHash: Hash, context: TrackContext, timeoutMs?: number, preReceipt?: { status: string; blockNumber: bigint; gasUsed: bigint; effectiveGasPrice: bigint; } | undefined): Promise; /** * Fire-and-forget variant. Does not block the caller and swallows all errors * so the CLI can exit immediately after returning the tx hash to the agent. */ export declare function trackInBackground(client: PublicClient, txHash: Hash, context: TrackContext, timeoutMs?: number, preReceipt?: { status: string; blockNumber: bigint; gasUsed: bigint; effectiveGasPrice: bigint; } | undefined): void; //# sourceMappingURL=tracker.d.ts.map