/** * User Balance WebSocket Event Types * * Types for real-time user balance update events. * This is an authenticated channel - requires JWT token. */ /** * Reason for the balance update */ export type BalanceUpdateReason = "lock" | "unlock" | "deposit" | "withdrawal" | "trade"; /** * User balance event data containing current balance state */ export interface UserBalanceEventData { /** Token contract address */ tokenAddress: string; /** Token symbol */ tokenSymbol: string | null; /** Available balance for trading (normalized) */ available: string; /** Available balance in raw format (wei) */ availableRaw: string; /** Locked balance (in orders or pending operations, normalized) */ locked: string; /** Locked balance in raw format (wei) */ lockedRaw: string; /** Total balance (available + locked, normalized) */ total: string; /** Total balance in raw format (wei) */ totalRaw: string; /** Reason for the balance update */ reason: BalanceUpdateReason; /** Reference ID for related entity (e.g., order ID, deposit ID) */ referenceId: string | null; /** Timestamp when the balance was updated (ISO 8601) */ updatedAt: string; } /** * User balance event emitted when a user's balance changes */ export interface UserBalanceEvent { /** Event type identifier */ eventType: "balance_update"; /** User ID (UUID) */ userId: string; /** Balance data */ data: UserBalanceEventData; }