import type { PublicClient, TransactionReceipt, WalletClient } from "viem"; import type { ApplicationsAPI } from "../applications"; import type { AuthAPI, AuthState } from "../auth/index"; import type { FeesAPI } from "../fees"; import type { MarginAccountsAPI } from "../margin-accounts"; import type { Interval, MarketAPI } from "../market"; import type { PositionsAPI } from "../positions"; import type { ProfileAPI } from "../profile"; import type { TradingAPI, TradingMode } from "../trading"; import type { VaultAPI } from "../vault"; import type { ConditionalOrderEvent, OHLCVEvent, OrderbookEvent, OrderbookQuotationMode, OrderEvent, TradeEvent, UserBalanceEvent, UserMovementEvent } from "../websocket"; import type { Network } from "./network"; /** * Configuration options for the Monaco SDK. * * The SDK requires a wallet client for signing operations and an RPC URL. */ export interface SDKConfig { /** Wallet client for signing operations (optional - can be set later via setWalletClient) */ walletClient?: WalletClient; /** * Network to use. Must be one of the preset networks: "local", "development", "staging", "mainnet". * * Each network maps to a default API URL: * - "local": http://localhost:8080 * - "development": https://develop.apimonaco.xyz * - "staging": https://staging.apimonaco.xyz * - "mainnet": https://api.monaco.xyz * * Only "mainnet" uses the Sei mainnet chain. All other networks use Sei testnet. */ network: Network; /** RPC URL for Sei blockchain interactions */ seiRpcUrl: string; } /** * Core SDK interface providing access to all Monaco functionality. */ export interface MonacoSDK { /** Applications operations API */ applications: ApplicationsAPI; /** Auth operations API */ auth: AuthAPI; /** Fees operations API */ fees: FeesAPI; /** Vault operations API */ vault: VaultAPI; /** Trading operations API */ trading: TradingAPI; /** Market metadata API */ market: MarketAPI; /** Margin account operations API */ marginAccounts: MarginAccountsAPI; /** Perp position operations API */ positions: PositionsAPI; /** Profile operations API */ profile: ProfileAPI; /** Orderbook REST API for fetching orderbook snapshots */ orderbook: { getOrderbook: (tradingPairId: string, options?: { /** Number of price levels to return (max 100). Defaults to 10. */ depth?: number; /** Trading mode: 'Spot' or 'Margin'. Defaults to 'Spot'. */ tradingMode?: TradingMode; /** Price grouping magnitude. Valid values: 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000. */ magnitude?: number; /** Quantity denomination: 'BASE' or 'QUOTE'. When 'QUOTE' type, quantities are multiplied by the quote price. */ denomination?: OrderbookQuotationMode; }) => Promise; }; /** Trades REST API for fetching historical trades */ trades: { getTrades: (tradingPairId: string, options?: { /** Page number (starts from 1, default: 1) */ page?: number; /** Maximum number of records to return (default: 25, max: 100) */ page_size?: number; }) => Promise; }; /** WebSocket client for real-time data (orders, orderbook, ohlcv) */ ws: { connect: () => Promise; disconnect: () => void; isConnected: () => boolean; getStatus: () => "connected" | "connecting" | "disconnected" | "reconnecting"; setToken: (token: string) => void; orders: (tradingPairId: string, tradingMode: TradingMode, handler: (event: OrderEvent) => void) => () => void; orderbook: (tradingPairId: string, tradingMode: TradingMode, magnitude: number, quotationMode: OrderbookQuotationMode, handler: (event: OrderbookEvent) => void) => () => void; ohlcv: (tradingPairId: string, tradingMode: TradingMode, interval: Interval, handler: (event: OHLCVEvent) => void) => () => void; trades: (tradingPairId: string, handler: (event: TradeEvent) => void) => () => void; movements: (handler: (event: UserMovementEvent) => void) => () => void; userOrders: (handler: (event: OrderEvent) => void) => () => void; balances: (handler: (event: UserBalanceEvent) => void) => () => void; conditionalOrders: (handler: (event: ConditionalOrderEvent) => void, tradingPairId?: string) => () => void; }; /** Wallet client for all blockchain operations (undefined until set) */ walletClient: WalletClient | undefined; /** Public client for read-only blockchain operations */ publicClient: PublicClient; /** * Complete authentication flow * @param clientId - The client ID for authentication * @param options - Optional configuration for login */ login(clientId: string, options?: { connectWebSocket?: boolean; }): Promise; /** Log out the user */ logout(): Promise; /** Refresh the access token */ refreshAuth(): Promise; /** Get the current authentication state */ getAuthState(): AuthState | undefined; /** Check if the user is authenticated */ isAuthenticated(): boolean; /** Check connection status */ isConnected(): boolean; /** Get the current account address */ getAccountAddress(): string; /** Get the current network ('mainnet' or 'testnet') */ getNetwork(): Network; /** Get the current chain ID */ getChainId(): number; /** Wait for a transaction to be confirmed */ waitForTransaction(hash: string, confirmations?: number, timeout?: number): Promise; /** Set the wallet client (for React SDK to update when wagmi becomes available) */ setWalletClient(walletClient: WalletClient): void; /** Set the authentication state directly (useful for restoring cached tokens) */ setAuthState(authState: AuthState): void; } export type { Network, NetworkEndpoints } from "./network";