/** * Common exchange interface for multi-DEX CLI support. * All exchange adapters (Pacifica, Hyperliquid, Lighter) implement this. */ export interface ExchangeMarketInfo { symbol: string; markPrice: string; indexPrice: string; fundingRate: string | null; volume24h: string; openInterest: string; maxLeverage: number; sizeDecimals?: number; stepSize?: string; fundingHours?: number; } export interface ExchangePosition { symbol: string; side: "long" | "short"; size: string; entryPrice: string; markPrice: string; liquidationPrice: string; unrealizedPnl: string; leverage: number; } export interface ExchangeOrder { orderId: string; symbol: string; side: "buy" | "sell"; price: string; size: string; filled: string; status: string; type: string; } export interface ExchangeBalance { equity: string; available: string; marginUsed: string; unrealizedPnl: string; } export interface ExchangeTrade { time: number; symbol: string; side: "buy" | "sell"; price: string; size: string; fee: string; } export interface ExchangeFundingPayment { time: number; symbol: string; payment: string; } export interface ExchangeKline { time: number; open: string; high: string; low: string; close: string; volume: string; trades: number; } export interface ExchangeAdapter { readonly name: string; readonly chain?: string; readonly aliases?: readonly string[]; /** True if perp and spot share the same balance (e.g., Hyperliquid). False if separate accounts (e.g., Lighter). */ readonly isUnifiedAccount?: boolean; init?(): Promise; getMarkets(): Promise; getOrderbook(symbol: string): Promise<{ bids: [string, string][]; asks: [string, string][]; }>; getRecentTrades(symbol: string, limit?: number): Promise; getFundingHistory(symbol: string, limit?: number): Promise<{ time: number; rate: string; price: string | null; }[]>; getKlines(symbol: string, interval: string, startTime: number, endTime: number): Promise; getBalance(): Promise; getPositions(): Promise; getOpenOrders(): Promise; getOrderHistory(limit?: number): Promise; getTradeHistory(limit?: number): Promise; getFundingPayments(limit?: number): Promise; marketOrder(symbol: string, side: "buy" | "sell", size: string, opts?: { reduceOnly?: boolean; }): Promise; limitOrder(symbol: string, side: "buy" | "sell", price: string, size: string, opts?: { reduceOnly?: boolean; tif?: string; }): Promise; editOrder(symbol: string, orderId: string, price: string, size: string): Promise; cancelOrder(symbol: string, orderId: string): Promise; cancelAllOrders(symbol?: string): Promise; setLeverage(symbol: string, leverage: number, marginMode?: "cross" | "isolated"): Promise; stopOrder(symbol: string, side: "buy" | "sell", size: string, triggerPrice: string, opts?: { limitPrice?: string; reduceOnly?: boolean; }): Promise; }