import { AGENT_LIST, type AgentCategory, type AgentRecord, type AgentSlug } from './agents'; export type ProofAgentSlug = AgentSlug; export type ProofCategory = AgentCategory; export type ProofKind = 'trade' | 'repair' | 'rotate' | 'rebalance' | 'mint'; export interface ProofAgent { slug: ProofAgentSlug; tokenId: string; name: string; category: ProofCategory; wallet: `0x${string}`; backfillOphisTrades: boolean; } /** * Registered agents only: no token id means nothing to attribute a proof to, * and no wallet means there is no settlement history to attribute in the first * place (a record can exist before `fund --gen` creates its key). */ function toProofAgent(record: AgentRecord): ProofAgent | null { if (record.tokenId === null || record.wallet === null) return null; return { slug: record.slug, tokenId: record.tokenId, name: record.name, category: record.category, wallet: record.wallet, backfillOphisTrades: record.backfillOphisTrades, }; } /** * The only identities allowed into the public proof feed, projected from the * shared agent registry so a new agent cannot reach the feed without a record * (and cannot reach it before it is registered on-chain). Wallets are public * ERC-8004 agent wallets (never signer secrets) and are also the owners used * for Ophis settlement backfill. */ export const PROOF_AGENT_LIST: ProofAgent[] = AGENT_LIST.map(toProofAgent).filter( (agent): agent is ProofAgent => agent !== null, ); export const PROOF_AGENTS: Partial> = Object.fromEntries( PROOF_AGENT_LIST.map((agent) => [agent.slug, agent]), ); export interface ProofEvent { id: string; /** ERC-8004 token id. */ agent: string; agentName: string; category: ProofCategory; kind: ProofKind; summary: string; txHash?: `0x${string}`; orderUid?: `0x${string}`; surplusBps?: number; hf?: number; /** For a mint: the position manager the NFT lives on, since Ranger can run on more than one venue. */ positionManager?: `0x${string}`; at: string; } export interface ProofFeedPayload { events: ProofEvent[]; asOf: string; source: 'runner' | 'runner+chain' | 'chain' | 'none'; /** * True when the runner's log tail was read in full and its order * verification finished. False means partial evidence: the runner was * unreachable, answered without the flag, or scanned incompletely. The * chain backfill is not affected by it. */ complete: boolean; }