/** * Market intelligence — the agent's eyes on-chain. * * Reads real state: gas prices, fee balances, token stats, ETH balance. * Uses the Clawncher SDK for all on-chain reads — no local ABI duplication. */ import { type Address, type PublicClient } from 'viem'; import { type NetworkName } from '@clawnch/clawncher-sdk'; import type { StateStore } from '../state/index.js'; /** Everything the agent needs to know about its current financial state */ export interface MarketSnapshot { timestamp: number; ethBalance: bigint; ethFormatted: string; gasPrice: bigint; estimatedTxCostWei: bigint; estimatedClaimCostWei: bigint; estimatedClaimCostEth: string; unclaimedFeesWeth: bigint; unclaimedFeesWethFormatted: string; unclaimedFeesToken: bigint; unclaimedFeesTokenFormatted: string; claimProfitWei: bigint; claimProfitEth: string; claimIsProfitable: boolean; ownToken: OwnTokenStats | null; txBudget: number; /** USDC balance on Base (null if read failed) */ usdcBalance: bigint | null; usdcBalanceFormatted: string | null; /** BUNKER token balance (null if bunker not configured or read failed) */ bunkerBalance: bigint | null; bunkerBalanceFormatted: string | null; /** Unix ms when bunker runtime expires (null if not deployed) */ bunkerRuntimeExpiresAt: number | null; /** Hours remaining on bunker runtime */ bunkerRuntimeHoursRemaining: number | null; /** Herd on-chain intelligence overlay (populated asynchronously when available) */ herd: HerdSnapshotOverlay | null; } /** * Herd intelligence overlay — enriches the market snapshot with * on-chain intelligence data. Populated separately from the main snapshot * to avoid blocking the fast path. All fields cached with TTLs. */ export interface HerdSnapshotOverlay { /** Token safety audit score (0-100). Null if no token deployed or Herd unavailable. */ tokenRiskScore: number | null; /** Token risk level */ tokenRiskLevel: string | null; /** Whether any key Clawncher contracts were recently upgraded */ contractsUpgraded: boolean; /** Summary of upgrade changes (null if no upgrades detected) */ upgradeSummary: string | null; /** Agent wallet type as detected by Herd */ walletType: string | null; /** Timestamp of last Herd data refresh */ lastRefreshed: number; } export interface OwnTokenStats { address: Address; symbol: string; balance: bigint; balanceFormatted: string; totalSupply: bigint; holdingPct: number; /** Price in ETH per token (null if pool read fails) */ priceEth: number | null; /** Price in USD per token (null if unavailable) */ priceUsd: number | null; /** Market cap in USD (null if unavailable) */ marketCapUsd: number | null; } export interface MarketConditions { feesWorthClaiming: boolean; survivalClaimNeeded: boolean; operationallyHealthy: boolean; estimatedHoursRemaining: number; needsToken: boolean; summary: string; } export declare class MarketIntelligence { private publicClient; private address; private state; private reader; private price; private network; /** Override for min claim profit (from autonomy.claiming.minProfitWei) */ private minClaimProfitOverride?; /** Cached Herd instance (lazy, null if HERD_ACCESS_TOKEN not set) */ private herd; private herdInitialized; constructor(publicClient: PublicClient, address: Address, state: StateStore, network?: NetworkName, options?: { minClaimProfitWei?: string; }); /** * Take a full market snapshot — all data from chain, no caching. */ snapshot(tokenAddress?: Address): Promise; /** * Evaluate conditions from a snapshot — actionable signals. */ evaluate(snap: MarketSnapshot): MarketConditions; /** * Quick check: should the agent wake up? */ shouldWake(tokenAddress?: Address): Promise<{ wake: boolean; reason: string; }>; /** * Populate the Herd intelligence overlay on a snapshot. * Non-blocking: mutates snap.herd in-place. Skips silently when * HERD_ACCESS_TOKEN is not set or Herd is unreachable. */ populateHerdOverlay(snap: MarketSnapshot): Promise; /** * Check key Clawncher contracts for upgrades via Herd. */ private checkContractUpgrades; /** * Lazy Herd initializer. Returns null when HERD_ACCESS_TOKEN is not set. */ private getHerd; private fetchFees; /** * Fetch USDC balance on Base. Non-fatal: returns nulls on failure. */ private fetchUsdcBalance; /** * Fetch BUNKER token balance and runtime info from state. * Non-fatal: returns nulls on any failure. */ private fetchBunkerData; /** * Fetch own token stats using the SDK's ClawnchReader + ERC20ABI + ClawnchPrice. */ private fetchOwnTokenStats; } export declare function formatSnapshot(snap: MarketSnapshot): string; //# sourceMappingURL=index.d.ts.map