export type Address = `0x${string}`; export type RoutingPolicy = 'net' | 'balanced' | 'fast' | 'simple'; export interface Asset { chainId: number; address: Address } export interface ExecutionPerformanceGroup { key: string; fromChainId: number; toChainId: number; mode: string; samples: number; successes: number; reverted: number; verified: true; lastObservedAt: number; successRate: number; eligibleForSelection: boolean; completionP50Ms: number | null; completionP95Ms: number | null; outputGapP50Bps: number | null; outputGapP95Bps: number | null; timedSuccessSamples: number; matchedOutputSamples: number; } export interface RoutingPerformance { schemaVersion: 1; generatedAt: string; windowDays: number; scope: string; groups: ExecutionPerformanceGroup[] } export interface Source extends Asset { amountRaw: string } export interface QuoteInput { account: Address; recipient?: Address; from: Source; to: Asset; slippageBps: number; routingPolicy?: RoutingPolicy } export interface PortfolioInput extends Omit { sources: Source[] } export interface PositionRoutePreviewInput { account: Address; position: Asset & {kind: 'lp-token' | 'concentrated-nft' | 'vault-shares' | 'aave-supply'; tokenId?: string}; to: Asset; slippageBps?: number; routingPolicy?: RoutingPolicy } export interface PositionRoutePreview { kind: 'position-route-preview'; advisory: true; executable: false; account: Address; source: Asset & {kind: string; positionId: string | null; shareRaw: string | null; blockNumber: string; maxRedeemSharesRaw: string | null; exitStatus: 'limited' | 'not_verified'}; destination: Asset; legs: Array<{source: Source; status: 'quoted' | 'already_destination' | 'unavailable'; quote: {mode: string; estimatedAmountRaw: string; minimumAmountRaw: string; estimatedNetUsd: number | null; expiresAt: string | null} | null}>; quotesComplete: boolean; comparedNetUsd: null; netWinner: null; checkedAt: string; caveat: string } export interface RequestOptions { signal?: AbortSignal; idempotencyKey?: string; authorization?: `Bearer ${string}` } export interface RouteSummary { mode: string; pathKey: string; estimatedAmountRaw: string; minimumAmountRaw: string; estimatedOutputUsd: number; totalGasUsd: number; estimatedNetUsd: number; estimatedSeconds?: number | null; estimatedActions?: number | null; discoveryConnectors?: Address[] } export interface Quote { engine: 'Unify'; quoteId: string; account: Address; recipient: Address; source: Source & {symbol?: string; decimals?: number}; destination: Asset & {symbol?: string; decimals?: number}; slippageBps: number; routingPolicy: RoutingPolicy; winner: RouteSummary; alternatives: RouteSummary[]; expiresAt: string; caveats?: string[] } export interface PlanSource { index: number; source: Source; status: string; orderId?: string; deliveredAmountRaw?: string; checkError?: string; execution?: {quoteId: string; hash: string | null; startedAt: string} } export interface ConversionPlan { planId: string; account: Address; recipient: Address; version: number; durable: boolean; status: string; request: PortfolioInput; sources: PlanSource[]; createdAt: string; updatedAt: string; executionPayloadIncluded: false } export interface PlanReview { planId: string; sourceIndex: number; quoteId: string; quote: Omit; expiresAt: string; requiresWalletReview: true; newBridgeRequired?: false; bridgeAlreadyDelivered?: true } export interface Usage { partner: string; singleQuotes: number; portfolioQuotes: number; quotedAssets: number; quota: {limit: number; used: number; remaining: number; resetsAt: string; shared: boolean}; caveat: string } export interface UnsignedSwapPlan { kind: 'unsigned-swap-plan'; quoteId: string; mode: string; pathKey: string; account: Address; recipient: Address; source: Source; destination: Asset; minimumAmountRaw: string; estimatedAmountRaw: string; slippageBps: number; checkedAt: string; expiresAt: string; deadline: string; spender: Address; approvalAmountRaw: string; status: 'ready' | 'approval_required' | 'funds_required' | 'gas_required'; snapshot: {blockNumber: string; blockHash: string}; checks: {deployment: true; poolMappings: true; balance: boolean; allowance: boolean; simulation: 'passed' | 'not_run'; gas: boolean}; steps: Array<{kind: 'reset_approval' | 'approval' | 'swap'; requiresReceipt: true; requiresFreshSimulation?: true; transaction: {chainId: number; from: Address; to: Address; data: `0x${string}`; value: '0x0'}}>; executionPayloadIncluded: true; userSignsTransactions: true; serverSignsTransactions: false; serverBroadcastsTransactions: false; } export interface UnifyClient { chains(options?: RequestOptions): Promise>; arcCapabilities(options?: RequestOptions): Promise>; routingPerformance(options?: RequestOptions): Promise; arcAssets(cursor?: number, options?: RequestOptions): Promise>; sources(options?: RequestOptions): Promise>; usage(options?: RequestOptions): Promise; executionPlan(quote: Quote, selection?: {mode: string; pathKey: string}, options?: RequestOptions): Promise>; quote(input: QuoteInput, options?: RequestOptions): Promise; streamQuote(input: QuoteInput, options?: {signal?: AbortSignal; onCandidate?: (quote: Readonly) => void | Promise}): Promise>; verify(quoteId: string, selection?: {mode: string; pathKey: string}, options?: RequestOptions): Promise<{quoteId: string; valid: boolean; route?: RouteSummary}>; portfolioQuote(input: PortfolioInput, options?: RequestOptions): Promise>; portfolioPlans(input: PortfolioInput, options?: RequestOptions): Promise>; positionRoutePreview(input: PositionRoutePreviewInput, options?: RequestOptions): Promise>; verifyPortfolio(quoteId: string, options?: RequestOptions): Promise>; compare(input: QuoteInput, options?: RequestOptions): Promise>; liquidity(chainId?: number, options?: RequestOptions): Promise>; assetAvailability(chainId: number, address: Address, options?: RequestOptions): Promise>; assetRouteAvailability(chainId: number, address: Address, input: {direction: 'buy' | 'sell'; counterpart: Asset; amountRaw: string; account: Address; recipient?: Address; slippageBps: number; routingPolicy?: RoutingPolicy}, options?: RequestOptions): Promise>; stockQuotes(input: {chainId: number; stockAddress: Address; buyAmountRaw: string; sellAmountRaw: string; account: Address; recipient?: Address; slippageBps?: number; routingPolicy?: RoutingPolicy}, options?: RequestOptions): Promise>; rfqCapabilities(options?: RequestOptions): Promise>; rfqPreview(input: Record, options?: RequestOptions): Promise>; createPlan(input: PortfolioInput, options?: RequestOptions): Promise<{plan: ConversionPlan}>; plans(account: Address, options?: RequestOptions): Promise<{plans: ConversionPlan[]}>; plan(planId: string, account: Address, options?: RequestOptions): Promise<{plan: ConversionPlan}>; linkPlanBridge(planId: string, body: {account: Address; sourceIndex: number; orderId: string}, options?: RequestOptions): Promise<{plan: ConversionPlan}>; linkPlanRelay(planId: string, body: {account: Address; sourceIndex: number; requestId: string}, options?: RequestOptions): Promise<{plan: ConversionPlan}>; refreshPlan(planId: string, body: {account: Address}, options?: RequestOptions): Promise<{plan: ConversionPlan}>; reviewPlanSource(planId: string, body: {account: Address; sourceIndex: number}, options?: RequestOptions): Promise; finalPlanQuote(planId: string, body: {account: Address; sourceIndex: number; selection?: {mode: string; pathKey: string}}, options?: RequestOptions): Promise; recordPlanReceipt(planId: string, body: {account: Address; sourceIndex: number; quoteId: string; hash: string}, options?: RequestOptions): Promise<{plan: ConversionPlan}>; beginPlanExecution(planId: string, body: {account: Address; sourceIndex: number; quoteId: string; hash?: string}, options?: RequestOptions): Promise<{plan: ConversionPlan}>; } export function createUnifyClient(options?: {baseUrl?: string; apiKey?: string; fetcher?: typeof fetch; timeoutMs?: number}): Readonly; export class UnifyApiError extends Error { status: number; code: string | null; requestId: string | null; retryable: boolean; retryAfterMs: number | null; constructor(status: number, message: string, details?: Record) } export function assertPortfolioResponse(result: unknown, input: PortfolioInput, now?: number): void; export function assertPlanResponse(plan: unknown, account: Address, planId?: string): void; export function createUnifyEmbedUrl(origin: string, options?: {fromChain?: number; fromToken?: Address; toChain?: number; toToken?: Address; amount?: string; preference?: RoutingPolicy; sources?: Array}): string;