@xapy/orderbook 0.1.29 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/exchanges/aster/index.d.cts +1 -1
- package/dist/exchanges/aster/index.d.ts +1 -1
- package/dist/exchanges/binance/index.d.cts +1 -1
- package/dist/exchanges/binance/index.d.ts +1 -1
- package/dist/exchanges/bingx/index.d.cts +1 -1
- package/dist/exchanges/bingx/index.d.ts +1 -1
- package/dist/exchanges/bitget/index.d.cts +1 -1
- package/dist/exchanges/bitget/index.d.ts +1 -1
- package/dist/exchanges/bybit/index.d.cts +1 -1
- package/dist/exchanges/bybit/index.d.ts +1 -1
- package/dist/exchanges/coinex/index.d.cts +1 -1
- package/dist/exchanges/coinex/index.d.ts +1 -1
- package/dist/exchanges/deribit/index.d.cts +1 -1
- package/dist/exchanges/deribit/index.d.ts +1 -1
- package/dist/exchanges/edgex/index.d.cts +1 -1
- package/dist/exchanges/edgex/index.d.ts +1 -1
- package/dist/exchanges/gate/index.d.cts +1 -1
- package/dist/exchanges/gate/index.d.ts +1 -1
- package/dist/exchanges/hyperliquid/index.d.cts +1 -1
- package/dist/exchanges/hyperliquid/index.d.ts +1 -1
- package/dist/exchanges/kucoin/index.d.cts +1 -1
- package/dist/exchanges/kucoin/index.d.ts +1 -1
- package/dist/exchanges/lighter/index.d.cts +1 -1
- package/dist/exchanges/lighter/index.d.ts +1 -1
- package/dist/exchanges/mexc/index.cjs +729 -0
- package/dist/exchanges/mexc/index.cjs.map +1 -0
- package/dist/exchanges/mexc/index.d.cts +57 -0
- package/dist/exchanges/mexc/index.d.ts +57 -0
- package/dist/exchanges/mexc/index.js +721 -0
- package/dist/exchanges/mexc/index.js.map +1 -0
- package/dist/exchanges/okx/index.d.cts +1 -1
- package/dist/exchanges/okx/index.d.ts +1 -1
- package/dist/exchanges/whitebit/index.d.cts +1 -1
- package/dist/exchanges/whitebit/index.d.ts +1 -1
- package/dist/index.cjs +325 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +325 -1
- package/dist/index.js.map +1 -1
- package/dist/{stream-D5-FyNGW.d.cts → stream-Dyq24thx.d.cts} +1 -1
- package/dist/{stream-D5-FyNGW.d.ts → stream-Dyq24thx.d.ts} +1 -1
- package/package.json +12 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/symbol.ts","../../../src/transport/http.ts","../../../src/core/errors.ts","../../../src/exchanges/mexc/contracts.ts","../../../src/exchanges/mexc/symbols.ts","../../../src/exchanges/mexc/rest.ts","../../../src/core/book-merger.ts","../../../src/core/event-emitter.ts","../../../src/core/stream.ts","../../../src/core/reconnect.ts","../../../src/utils/runtime.ts","../../../src/transport/ws.ts","../../../src/exchanges/mexc/ws.ts","../../../src/exchanges/mexc/index.ts"],"names":[],"mappings":";;;AAkBO,SAAS,YAAY,MAAA,EAA8B;AACxD,EAAA,MAAM,CAAC,IAAA,EAAM,MAAM,CAAA,GAAI,MAAA,CAAO,MAAM,GAAG,CAAA;AACvC,EAAA,MAAM,KAAA,GAAA,CAAS,IAAA,IAAQ,EAAA,EAAI,KAAA,CAAM,GAAG,CAAA;AACpC,EAAA,MAAM,IAAA,GAAO,KAAA,CAAM,CAAC,CAAA,EAAG,WAAA,EAAY;AACnC,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,CAAC,CAAA,EAAG,WAAA,EAAY;AACpC,EAAA,IAAI,CAAC,IAAA,IAAQ,CAAC,KAAA,EAAO;AACnB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,mBAAmB,MAAM,CAAA,qDAAA;AAAA,KAC3B;AAAA,EACF;AACA,EAAA,IAAI,MAAA,IAAU,MAAA,CAAO,WAAA,EAAY,KAAM,KAAA,EAAO;AAC5C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,MAAM,CAAA,oDAAA;AAAA,KAC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AAA,GAAyB,EAAC,EAAoB;AAC5E,IAAA,MAAM,EAAE,IAAA,EAAM,MAAA,EAAO,GAAI,YAAY,MAAM,CAAA;AAC3C,IAAA,OAAO,mBAAA,CAAoB;AAAA,MACzB,MAAA,EAAQ,IAAA;AAAA,MACR,MAAA;AAAA,MACA,OAAO,IAAA,CAAK,KAAA;AAAA,MACZ,cAAc,IAAA,CAAK,YAAA;AAAA,MACnB,WAAW,IAAA,CAAK;AAAA,KACjB,CAAA;AAAA,EACH;AACF","file":"index.cjs","sourcesContent":["import type { Market } from \"./types.js\";\n\nexport interface ParsedSymbol {\n base: string;\n quote: string;\n market: Market;\n /** \"BASE/QUOTE\" — settlement suffix stripped. Pass this to per-exchange formatters. */\n pair: string;\n}\n\n/**\n * CCXT-style unified symbol:\n * \"BTC/USDT\" → spot\n * \"BTC/USDT:USDT\" → linear perpetual (USDT-margined)\n *\n * Inverse/coin-margined contracts (e.g. \"BTC/USD:BTC\") are intentionally\n * unsupported by this lib.\n */\nexport function parseSymbol(symbol: string): ParsedSymbol {\n const [pair, settle] = symbol.split(\":\");\n const parts = (pair ?? \"\").split(\"/\");\n const base = parts[0]?.toUpperCase();\n const quote = parts[1]?.toUpperCase();\n if (!base || !quote) {\n throw new Error(\n `invalid symbol \"${symbol}\" — expected \"BASE/QUOTE\" or \"BASE/QUOTE:SETTLE\"`\n );\n }\n if (settle && settle.toUpperCase() !== quote) {\n throw new Error(\n `unsupported settlement currency in \"${symbol}\" — only linear (settle === quote) is supported`\n );\n }\n return {\n base,\n quote,\n market: settle ? \"perpetual\" : \"spot\",\n pair: `${base}/${quote}`,\n };\n}\n","export interface HttpRequest {\n url: string;\n method?: \"GET\" | \"POST\";\n headers?: Record<string, string>;\n body?: string;\n timeoutMs?: number;\n /** Applied to `url` before the request fires. Use for CORS proxying. */\n transformUrl?: (url: string) => string;\n}\n\nexport async function httpJson<T>(req: HttpRequest): Promise<T> {\n const url = req.transformUrl ? req.transformUrl(req.url) : req.url;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), req.timeoutMs ?? 10_000);\n try {\n const res = await fetch(url, {\n method: req.method ?? \"GET\",\n headers: req.headers,\n body: req.body,\n signal: controller.signal,\n });\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n throw new Error(`HTTP ${res.status} ${res.statusText}: ${text.slice(0, 200)}`);\n }\n return (await res.json()) as T;\n } finally {\n clearTimeout(timer);\n }\n}\n","export class ExchangeError extends Error {\n constructor(\n public readonly exchange: string,\n message: string,\n cause?: unknown\n ) {\n super(\n `[${exchange}] ${message}`,\n cause === undefined ? undefined : { cause }\n );\n this.name = \"ExchangeError\";\n }\n}\n\nexport class RateLimitError extends ExchangeError {\n constructor(exchange: string, message = \"rate limited\") {\n super(exchange, message);\n this.name = \"RateLimitError\";\n }\n}\n\nexport class SequenceGapError extends Error {\n constructor(\n public readonly expected: number,\n public readonly received: number\n ) {\n super(`sequence gap: expected ${expected}, received ${received}`);\n this.name = \"SequenceGapError\";\n }\n}\n","import { ExchangeError } from \"../../core/errors.js\";\nimport { httpJson } from \"../../transport/http.js\";\nimport type { MexcContract, MexcFuturesResponse } from \"./types.js\";\n\nexport const MEXC_SPOT_REST = \"https://api.mexc.com\";\nexport const MEXC_FUTURES_REST = \"https://contract.mexc.com\";\n\nexport interface MexcContractOptions {\n timeoutMs?: number;\n transformUrl?: (url: string) => string;\n}\n\n/**\n * Futures depth is quoted in **contracts**, so every size has to be scaled by\n * the symbol's `contractSize` (BTC_USDT is 0.0001 BTC) to satisfy the lib's\n * base-coin rule. The registry is fetched once and cached module-wide; a\n * lookup miss refetches once so a newly listed contract resolves without\n * restarting the process.\n */\nlet cache: Map<string, MexcContract> | null = null;\nlet inflight: Promise<Map<string, MexcContract>> | null = null;\n\nasync function fetchContracts(\n opts: MexcContractOptions\n): Promise<Map<string, MexcContract>> {\n const res = await httpJson<MexcFuturesResponse<MexcContract[]>>({\n url: `${MEXC_FUTURES_REST}/api/v1/contract/detail`,\n timeoutMs: opts.timeoutMs,\n transformUrl: opts.transformUrl,\n });\n const rows = res.data ?? [];\n if (rows.length === 0) {\n throw new ExchangeError(\n \"mexc\",\n res.message ? `${res.code}: ${res.message}` : \"empty contract/detail response\"\n );\n }\n const map = new Map<string, MexcContract>();\n for (const row of rows) map.set(row.symbol.toUpperCase(), row);\n return map;\n}\n\nfunction loadContracts(\n opts: MexcContractOptions\n): Promise<Map<string, MexcContract>> {\n inflight ??= fetchContracts(opts).then(\n (m) => {\n cache = m;\n inflight = null;\n return m;\n },\n (err) => {\n inflight = null;\n throw err;\n }\n );\n return inflight;\n}\n\n/** Base-coin size for one contract of `symbol` (e.g. BTC_USDT → 0.0001). */\nexport async function resolveContractSize(\n symbol: string,\n opts: MexcContractOptions\n): Promise<number> {\n const k = symbol.toUpperCase();\n const hit = cache?.get(k);\n const contract = hit ?? (await loadContracts(opts)).get(k);\n if (!contract) {\n throw new ExchangeError(\n \"mexc\",\n `unknown futures contract \"${symbol}\" — not listed on mexc`\n );\n }\n const size = Number(contract.contractSize);\n if (!Number.isFinite(size) || size <= 0) {\n throw new ExchangeError(\n \"mexc\",\n `contract \"${symbol}\" has no usable contractSize (${contract.contractSize})`\n );\n }\n return size;\n}\n\n/** Test seam: drops the cached contract registry. */\nexport function resetMexcContractCache(): void {\n cache = null;\n inflight = null;\n}\n","import type { Market } from \"../../core/types.js\";\n\n/**\n * MEXC names the two markets differently: spot concatenates (`BTCUSDT`) while\n * futures uses an underscore (`BTC_USDT`). Quote assets are listed longest\n * first so `USDC` is matched before `USD` when splitting a spot symbol back.\n */\nconst QUOTES = [\"USDT\", \"USDC\", \"TUSD\", \"USD\", \"BTC\", \"ETH\"] as const;\n\nexport function toMexcSymbol(symbol: string, market: Market): string {\n const [base, quote] = symbol.split(\"/\");\n if (!base || !quote) {\n throw new Error(`invalid symbol \"${symbol}\" — expected \"BASE/QUOTE\"`);\n }\n return market === \"perpetual\"\n ? `${base.toUpperCase()}_${quote.toUpperCase()}`\n : `${base}${quote}`.toUpperCase();\n}\n\nexport function fromMexcSymbol(s: string, market: Market): string {\n const upper = s.toUpperCase();\n if (market === \"perpetual\") {\n const [base, quote] = upper.split(\"_\");\n return base && quote ? `${base}/${quote}` : upper;\n }\n for (const q of QUOTES) {\n if (upper.endsWith(q) && upper.length > q.length) {\n return `${upper.slice(0, -q.length)}/${q}`;\n }\n }\n return upper;\n}\n","import { httpJson } from \"../../transport/http.js\";\nimport { ExchangeError } from \"../../core/errors.js\";\nimport type { Market, Orderbook, OrderbookLevel } from \"../../core/types.js\";\nimport {\n MEXC_FUTURES_REST,\n MEXC_SPOT_REST,\n resolveContractSize,\n type MexcContractOptions,\n} from \"./contracts.js\";\nimport { fromMexcSymbol, toMexcSymbol } from \"./symbols.js\";\nimport type {\n MexcFuturesDepth,\n MexcFuturesLevel,\n MexcFuturesResponse,\n MexcSpotLevel,\n MexcSpotOrderbookResponse,\n} from \"./types.js\";\n\nexport interface FetchMexcOrderbookOptions extends MexcContractOptions {\n symbol: string;\n market: Market;\n depth?: number;\n}\n\nconst toSpotLevels = (rows: MexcSpotLevel[] | undefined): OrderbookLevel[] =>\n (rows ?? []).map(([p, s]) => ({ price: Number(p), size: Number(s) }));\n\n/** Futures `vol` is a contract count — scale it into base coin. */\nexport const toFuturesLevels = (\n rows: MexcFuturesLevel[] | undefined,\n contractSize: number\n): OrderbookLevel[] =>\n (rows ?? []).map(([price, vol]) => ({\n price: Number(price),\n size: Number(vol) * contractSize,\n }));\n\nexport async function fetchMexcOrderbook(\n opts: FetchMexcOrderbookOptions\n): Promise<Orderbook> {\n const symbol = toMexcSymbol(opts.symbol, opts.market);\n const depth = opts.depth ?? 50;\n\n if (opts.market === \"spot\") {\n const data = await httpJson<MexcSpotOrderbookResponse>({\n url: `${MEXC_SPOT_REST}/api/v3/depth?symbol=${symbol}&limit=${depth}`,\n timeoutMs: opts.timeoutMs,\n transformUrl: opts.transformUrl,\n });\n return {\n exchange: \"mexc\",\n symbol: fromMexcSymbol(symbol, opts.market),\n market: opts.market,\n bids: toSpotLevels(data.bids),\n asks: toSpotLevels(data.asks),\n // The spot depth endpoint returns no timestamp of its own.\n timestamp: Date.now(),\n sequence: data.lastUpdateId,\n };\n }\n\n const contractSize = await resolveContractSize(symbol, opts);\n const res = await httpJson<MexcFuturesResponse<MexcFuturesDepth>>({\n url: `${MEXC_FUTURES_REST}/api/v1/contract/depth/${symbol}?limit=${depth}`,\n timeoutMs: opts.timeoutMs,\n transformUrl: opts.transformUrl,\n });\n if (!res.data) {\n throw new ExchangeError(\n \"mexc\",\n res.message ? `${res.code}: ${res.message}` : \"empty orderbook response\"\n );\n }\n return {\n exchange: \"mexc\",\n symbol: fromMexcSymbol(symbol, opts.market),\n market: opts.market,\n bids: toFuturesLevels(res.data.bids, contractSize),\n asks: toFuturesLevels(res.data.asks, contractSize),\n timestamp: res.data.timestamp ?? Date.now(),\n sequence: Number(res.data.version ?? 0),\n };\n}\n","import type { BookEvent, OrderbookLevel } from \"./types.js\";\n\n/**\n * BookMerger maintains a sorted orderbook from a stream of snapshot and delta\n * events. It is exchange-agnostic — adapters translate raw WS frames into the\n * normalized BookEvent shape and feed them here.\n *\n * Gap detection:\n * - If the delta carries a `prevSequence`, we check it equals our current sequence.\n * - Otherwise we expect strictly consecutive sequence numbers.\n * - On gap, the caller is expected to re-fetch a REST snapshot, call reset(),\n * then apply the snapshot.\n */\n\nexport type MergeResult =\n | {\n ok: true;\n bids: OrderbookLevel[]; // descending\n asks: OrderbookLevel[]; // ascending\n sequence: number;\n timestamp: number;\n }\n | { ok: false; reason: \"gap\"; expected: number; received: number }\n | { ok: false; reason: \"no-snapshot\" };\n\nexport class BookMerger {\n private readonly bids = new Map<number, number>(); // price -> size\n private readonly asks = new Map<number, number>();\n private sequence = -1;\n private timestamp = 0;\n private hasSnapshot = false;\n\n apply(event: BookEvent): MergeResult {\n if (event.kind === \"snapshot\") {\n this.bids.clear();\n this.asks.clear();\n for (const { price, size } of event.bids) {\n if (size > 0) this.bids.set(price, size);\n }\n for (const { price, size } of event.asks) {\n if (size > 0) this.asks.set(price, size);\n }\n this.sequence = event.sequence;\n this.timestamp = event.timestamp;\n this.hasSnapshot = true;\n return this.emit();\n }\n\n if (!this.hasSnapshot) {\n return { ok: false, reason: \"no-snapshot\" };\n }\n\n // Stale or duplicate delta: silently ignore but emit current state.\n if (event.sequence <= this.sequence) {\n return this.emit();\n }\n\n // Gap detection\n if (event.prevSequence !== undefined) {\n if (event.prevSequence !== this.sequence) {\n return {\n ok: false,\n reason: \"gap\",\n expected: this.sequence,\n received: event.prevSequence,\n };\n }\n } else if (event.sequence !== this.sequence + 1) {\n return {\n ok: false,\n reason: \"gap\",\n expected: this.sequence + 1,\n received: event.sequence,\n };\n }\n\n for (const { price, size } of event.bids) {\n if (size === 0) this.bids.delete(price);\n else this.bids.set(price, size);\n }\n for (const { price, size } of event.asks) {\n if (size === 0) this.asks.delete(price);\n else this.asks.set(price, size);\n }\n this.sequence = event.sequence;\n this.timestamp = event.timestamp;\n return this.emit();\n }\n\n reset(): void {\n this.bids.clear();\n this.asks.clear();\n this.sequence = -1;\n this.timestamp = 0;\n this.hasSnapshot = false;\n }\n\n /** Returns true once the merger has a usable book. */\n isReady(): boolean {\n return this.hasSnapshot;\n }\n\n private emit(): Extract<MergeResult, { ok: true }> {\n const bids: OrderbookLevel[] = [];\n for (const [price, size] of this.bids) bids.push({ price, size });\n bids.sort((a, b) => b.price - a.price);\n\n const asks: OrderbookLevel[] = [];\n for (const [price, size] of this.asks) asks.push({ price, size });\n asks.sort((a, b) => a.price - b.price);\n\n return {\n ok: true,\n bids,\n asks,\n sequence: this.sequence,\n timestamp: this.timestamp,\n };\n }\n}\n","/**\n * Tiny typed event emitter — keeps the package dependency-free across runtimes\n * (Node's `events` doesn't work in browser bundles without polyfills).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype EventMap = Record<string, (...args: any[]) => void>;\n\nexport class TypedEmitter<E extends EventMap> {\n private readonly listeners = new Map<keyof E, Set<E[keyof E]>>();\n\n on<K extends keyof E>(event: K, fn: E[K]): this {\n let set = this.listeners.get(event);\n if (!set) {\n set = new Set();\n this.listeners.set(event, set as Set<E[keyof E]>);\n }\n (set as Set<E[K]>).add(fn);\n return this;\n }\n\n off<K extends keyof E>(event: K, fn: E[K]): this {\n (this.listeners.get(event) as Set<E[K]> | undefined)?.delete(fn);\n return this;\n }\n\n emit<K extends keyof E>(event: K, ...args: Parameters<E[K]>): boolean {\n const set = this.listeners.get(event) as Set<E[K]> | undefined;\n if (!set || set.size === 0) return false;\n for (const fn of set) fn(...args);\n return true;\n }\n\n removeAllListeners(): void {\n this.listeners.clear();\n }\n}\n","import { TypedEmitter } from \"./event-emitter.js\";\nimport type { Orderbook } from \"./types.js\";\n\nexport type StreamEvents = {\n update: (book: Orderbook) => void;\n error: (err: Error) => void;\n connected: () => void;\n disconnected: (reason?: string) => void;\n reconnecting: (attempt: number, waitMs: number) => void;\n};\n\n/**\n * OrderbookStream is the consumer-facing handle for a maintained orderbook.\n * It exposes both an EventEmitter API and an async-iterator (`for await`).\n */\nexport class OrderbookStream extends TypedEmitter<StreamEvents> {\n private closed = false;\n\n constructor(private readonly onClose: () => void) {\n super();\n }\n\n close(): void {\n if (this.closed) return;\n this.closed = true;\n this.onClose();\n this.removeAllListeners();\n }\n\n /** Yields each maintained book as it becomes available. */\n async *iter(): AsyncGenerator<Orderbook, void, undefined> {\n const queue: Orderbook[] = [];\n let resolveNext: (() => void) | null = null;\n let pendingError: Error | null = null;\n let ended = false;\n\n const onUpdate = (b: Orderbook) => {\n queue.push(b);\n resolveNext?.();\n };\n const onError = (e: Error) => {\n pendingError = e;\n resolveNext?.();\n };\n const onClose = () => {\n ended = true;\n resolveNext?.();\n };\n\n this.on(\"update\", onUpdate);\n this.on(\"error\", onError);\n this.on(\"disconnected\", onClose);\n\n try {\n while (true) {\n if (pendingError) throw pendingError;\n const next = queue.shift();\n if (next) {\n yield next;\n continue;\n }\n if (ended || this.closed) return;\n await new Promise<void>((r) => {\n resolveNext = r;\n });\n resolveNext = null;\n }\n } finally {\n this.off(\"update\", onUpdate);\n this.off(\"error\", onError);\n this.off(\"disconnected\", onClose);\n }\n }\n}\n","export interface BackoffOptions {\n initialMs?: number;\n maxMs?: number;\n factor?: number;\n /** 0..1 — random jitter as a fraction of the delay. */\n jitter?: number;\n /** 0 = infinite. */\n maxAttempts?: number;\n}\n\ninterface ResolvedBackoff {\n initialMs: number;\n maxMs: number;\n factor: number;\n jitter: number;\n maxAttempts: number;\n}\n\nexport class Backoff {\n private attempt = 0;\n private readonly opts: ResolvedBackoff;\n\n private constructor(opts: ResolvedBackoff) {\n this.opts = opts;\n }\n\n static withDefaults(opts: BackoffOptions = {}): Backoff {\n return new Backoff({\n initialMs: opts.initialMs ?? 500,\n maxMs: opts.maxMs ?? 30_000,\n factor: opts.factor ?? 2,\n jitter: opts.jitter ?? 0.3,\n maxAttempts: opts.maxAttempts ?? 0,\n });\n }\n\n next(): { wait: number; attempt: number } | null {\n if (this.opts.maxAttempts > 0 && this.attempt >= this.opts.maxAttempts) {\n return null;\n }\n this.attempt += 1;\n const base = Math.min(\n this.opts.initialMs * Math.pow(this.opts.factor, this.attempt - 1),\n this.opts.maxMs\n );\n const jitterRange = base * this.opts.jitter;\n const wait = Math.max(0, base + (Math.random() * 2 - 1) * jitterRange);\n return { wait, attempt: this.attempt };\n }\n\n reset(): void {\n this.attempt = 0;\n }\n}\n","declare const globalThis: typeof global & {\n window?: unknown;\n document?: unknown;\n WebSocket?: unknown;\n};\n\nexport const isBrowser =\n typeof globalThis.window !== \"undefined\" &&\n typeof globalThis.document !== \"undefined\";\n\nexport const hasNativeWebSocket = typeof globalThis.WebSocket !== \"undefined\";\n","import { TypedEmitter } from \"../core/event-emitter.js\";\nimport { Backoff, type BackoffOptions } from \"../core/reconnect.js\";\nimport { hasNativeWebSocket } from \"../utils/runtime.js\";\n\nexport interface WSConfig {\n /**\n * WebSocket URL, or a function resolved on every (re)connect. The function\n * form lets adapters that need a fresh handshake token (e.g. KuCoin's bullet\n * endpoint) hand out a new URL each time without ditching WSClient.\n */\n url: string | (() => string | Promise<string>);\n /** Called every time the socket opens (initial + after each reconnect). */\n onOpen?: (sock: SocketHandle) => void | Promise<void>;\n /** Called for every inbound frame. Adapter is responsible for JSON-parsing. */\n onMessage: (data: string | ArrayBuffer) => void | Promise<void>;\n /** Periodic ping; omit to disable. */\n pingIntervalMs?: number;\n pingPayload?: () => string;\n reconnect?: BackoffOptions;\n}\n\nexport interface SocketHandle {\n send(data: string): void;\n close(): void;\n}\n\ntype WSEvents = {\n open: () => void;\n close: (reason: string) => void;\n reconnecting: (attempt: number, waitMs: number) => void;\n error: (err: Error) => void;\n};\n\ninterface WebSocketLike {\n binaryType: string;\n send(data: string): void;\n close(): void;\n onopen: ((ev?: unknown) => void) | null;\n onclose: ((ev?: { reason?: string; code?: number }) => void) | null;\n onerror: ((ev?: WSErrorEventLike) => void) | null;\n onmessage: ((ev: { data: string | ArrayBuffer }) => void) | null;\n}\n\n/**\n * Shape of what lands in `onerror` across runtimes:\n * - browsers: a bare `Event` (no `message`), or an `ErrorEvent` whose\n * `message` defaults to the **empty string** — which is why the fallbacks\n * below test truthiness, not nullishness. `?? \"...\"` lets `\"\"` through and\n * the consumer ends up rendering a blank error.\n * - node (native/undici) + `ws`: `ErrorEvent` with `message` + `error`.\n */\ninterface WSErrorEventLike {\n message?: string;\n type?: string;\n error?: unknown;\n}\n\n/** Never returns an Error with an empty message. */\nexport function toError(value: unknown, fallback = \"unknown error\"): Error {\n if (value instanceof Error) {\n return value.message ? value : new Error(`${value.name}: ${fallback}`);\n }\n if (typeof value === \"string\" && value) return new Error(value);\n return new Error(fallback);\n}\n\n/** Turns a WebSocket `error` event into an Error that always says something. */\nexport function normalizeWsError(ev: WSErrorEventLike | undefined): Error {\n const detail =\n ev?.message ||\n (ev?.error instanceof Error ? ev.error.message : undefined) ||\n (typeof ev?.error === \"string\" ? ev.error : undefined);\n return new Error(detail ? `WebSocket error: ${detail}` : \"WebSocket error\");\n}\n\n/** Close events routinely carry `reason: \"\"` — surface the code instead. */\nexport function describeClose(ev: { reason?: string; code?: number } | undefined): string {\n if (ev?.reason) return ev.reason;\n return ev?.code === undefined ? \"closed\" : `closed (code ${ev.code})`;\n}\n\ntype WebSocketCtor = new (url: string) => WebSocketLike;\n\nlet cachedCtor: WebSocketCtor | null = null;\n\nasync function getWebSocketCtor(): Promise<WebSocketCtor> {\n if (cachedCtor) return cachedCtor;\n if (hasNativeWebSocket) {\n cachedCtor = (globalThis as unknown as { WebSocket: WebSocketCtor })\n .WebSocket;\n return cachedCtor;\n }\n try {\n const mod = (await import(\"ws\")) as unknown as {\n default?: WebSocketCtor;\n WebSocket?: WebSocketCtor;\n };\n const ctor = mod.default ?? mod.WebSocket;\n if (!ctor) throw new Error(\"missing default export\");\n cachedCtor = ctor;\n return cachedCtor;\n } catch (err) {\n throw new Error(\n \"WebSocket unavailable; install peer dep `ws` for Node <22. \" +\n (err instanceof Error ? err.message : String(err))\n );\n }\n}\n\nexport class WSClient extends TypedEmitter<WSEvents> {\n private ws: WebSocketLike | null = null;\n private readonly backoff: Backoff;\n private closed = false;\n private pingTimer: ReturnType<typeof setInterval> | null = null;\n\n constructor(private readonly cfg: WSConfig) {\n super();\n this.backoff = Backoff.withDefaults(cfg.reconnect);\n }\n\n async connect(): Promise<void> {\n if (this.closed) return;\n const WS = await getWebSocketCtor();\n const url =\n typeof this.cfg.url === \"function\" ? await this.cfg.url() : this.cfg.url;\n const ws = new WS(url);\n ws.binaryType = \"arraybuffer\";\n this.ws = ws;\n\n ws.onopen = async () => {\n this.backoff.reset();\n this.startPing();\n this.emit(\"open\");\n try {\n await this.cfg.onOpen?.({\n send: (d) => ws.send(d),\n close: () => this.close(),\n });\n } catch (err) {\n this.emit(\"error\", toError(err, \"onOpen handler failed\"));\n }\n };\n\n ws.onmessage = (e) => {\n let result: void | Promise<void>;\n try {\n result = this.cfg.onMessage(e.data);\n } catch (err) {\n this.emit(\"error\", toError(err, \"onMessage handler failed\"));\n return;\n }\n if (result && typeof (result as Promise<void>).catch === \"function\") {\n (result as Promise<void>).catch((err) =>\n this.emit(\"error\", toError(err, \"onMessage handler failed\"))\n );\n }\n };\n\n ws.onerror = (e) => {\n this.emit(\"error\", normalizeWsError(e));\n };\n\n ws.onclose = (e) => {\n this.stopPing();\n const reason = describeClose(e);\n this.emit(\"close\", reason);\n if (!this.closed) this.scheduleReconnect();\n };\n }\n\n send(data: string): void {\n this.ws?.send(data);\n }\n\n close(): void {\n this.closed = true;\n this.stopPing();\n try {\n this.ws?.close();\n } catch {\n /* ignore */\n }\n }\n\n private startPing(): void {\n if (!this.cfg.pingIntervalMs || !this.cfg.pingPayload) return;\n this.stopPing();\n this.pingTimer = setInterval(() => {\n try {\n this.ws?.send(this.cfg.pingPayload!());\n } catch {\n /* ignore — close handler will reconnect */\n }\n }, this.cfg.pingIntervalMs);\n }\n\n private stopPing(): void {\n if (this.pingTimer) {\n clearInterval(this.pingTimer);\n this.pingTimer = null;\n }\n }\n\n private scheduleReconnect(): void {\n const next = this.backoff.next();\n if (!next) {\n this.emit(\"error\", new Error(\"max reconnect attempts exceeded\"));\n return;\n }\n this.emit(\"reconnecting\", next.attempt, next.wait);\n setTimeout(() => {\n this.connect().catch((e) => this.emit(\"error\", toError(e, \"reconnect failed\")));\n }, next.wait);\n }\n}\n","import { BookMerger } from \"../../core/book-merger.js\";\nimport { ExchangeError } from \"../../core/errors.js\";\nimport { OrderbookStream } from \"../../core/stream.js\";\nimport type { Market, Orderbook } from \"../../core/types.js\";\nimport { WSClient } from \"../../transport/ws.js\";\nimport { resolveContractSize, type MexcContractOptions } from \"./contracts.js\";\nimport { fetchMexcOrderbook, toFuturesLevels } from \"./rest.js\";\nimport { fromMexcSymbol, toMexcSymbol } from \"./symbols.js\";\nimport type { MexcFuturesDepth, MexcWSMessage } from \"./types.js\";\n\nexport interface StreamMexcOrderbookOptions extends MexcContractOptions {\n symbol: string;\n market: Market;\n /** Depth used for the REST seed snapshot. Default 200. */\n depth?: number;\n}\n\nconst WS_FUTURES = \"wss://contract.mexc.com/edge\";\n/**\n * The gateway drops a client that sends nothing for ~60s — even one that is\n * actively receiving pushes (measured: closed at 65s after 296 frames). Only\n * client frames reset the timer, so this ping is mandatory, not decorative.\n */\nconst PING_INTERVAL_MS = 20_000;\n\n/**\n * MEXC futures `sub.depth` — incremental only, so the book is seeded from\n * `/api/v1/contract/depth` and deltas are chained on the version range:\n * each frame's `begin` equals the previous frame's `version` + 1, so we pass\n * `prevSequence = begin - 1` and `sequence = end`.\n *\n * Spot is not supported here: MEXC retired the JSON spot streams (they now\n * answer \"Blocked!\") in favour of protobuf-encoded ones, which this lib does\n * not decode. `fetchMexcOrderbook` still serves spot over REST.\n *\n * Sizes arrive as contract counts and are scaled by `contractSize`.\n */\nexport function streamMexcOrderbook(\n opts: StreamMexcOrderbookOptions\n): OrderbookStream {\n if (opts.market !== \"perpetual\") {\n throw new Error(\n `mexc spot streaming requires the protobuf WS feed, which this adapter ` +\n `does not decode — use fetchOrderbook(\"${opts.symbol}\") for a REST ` +\n `snapshot, or stream the perpetual (\"${opts.symbol}:${opts.symbol.split(\"/\")[1]}\")`\n );\n }\n\n const symbol = toMexcSymbol(opts.symbol, opts.market);\n const unified = fromMexcSymbol(symbol, opts.market);\n\n // Needed before any level can be scaled into base coin.\n const contractSize = resolveContractSize(symbol, opts);\n contractSize.catch(() => {}); // surfaced via the snapshot path below\n\n const merger = new BookMerger();\n let seedVersion = -1;\n let lastVersion = -1;\n let snapshotInFlight = false;\n let snapshotDone = false;\n let buffered: MexcFuturesDepth[] = [];\n let recovering = false;\n let scale = 0;\n let ws: WSClient | null = null;\n const stream = new OrderbookStream(() => ws?.close());\n\n const emit = (\n r: Extract<ReturnType<BookMerger[\"apply\"]>, { ok: true }>\n ) => {\n const book: Orderbook = {\n exchange: \"mexc\",\n symbol: unified,\n market: opts.market,\n bids: r.bids,\n asks: r.asks,\n timestamp: r.timestamp,\n sequence: r.sequence,\n };\n stream.emit(\"update\", book);\n };\n\n const triggerSnapshot = () => {\n if (snapshotInFlight) return;\n snapshotInFlight = true;\n contractSize\n .then(async (size) => {\n scale = size;\n return fetchMexcOrderbook({\n symbol: opts.symbol,\n market: opts.market,\n depth: opts.depth ?? 200,\n timeoutMs: opts.timeoutMs,\n transformUrl: opts.transformUrl,\n });\n })\n .then((snap) => {\n seedVersion = snap.sequence;\n const r = merger.apply({\n kind: \"snapshot\",\n bids: snap.bids,\n asks: snap.asks,\n sequence: snap.sequence,\n timestamp: snap.timestamp,\n });\n if (r.ok) emit(r);\n snapshotDone = true;\n lastVersion = -1;\n const pending = buffered;\n buffered = [];\n for (const d of pending) processDelta(d);\n })\n .catch((err) => stream.emit(\"error\", err as Error))\n .finally(() => {\n snapshotInFlight = false;\n });\n };\n\n const resync = () => {\n if (recovering) return;\n recovering = true;\n merger.reset();\n seedVersion = -1;\n snapshotDone = false;\n lastVersion = -1;\n buffered = [];\n setTimeout(() => {\n recovering = false;\n triggerSnapshot();\n }, 100);\n };\n\n const processDelta = (d: MexcFuturesDepth) => {\n const end = Number(d.end ?? d.version ?? 0);\n const begin = Number(d.begin ?? end);\n if (end <= seedVersion) return; // already covered by the seed\n\n let prevSequence: number;\n if (lastVersion < 0) {\n // First frame after the seed only has to span it.\n if (begin - 1 > seedVersion) {\n resync();\n return;\n }\n prevSequence = seedVersion;\n } else {\n prevSequence = begin - 1;\n }\n\n const r = merger.apply({\n kind: \"delta\",\n bids: toFuturesLevels(d.bids, scale),\n asks: toFuturesLevels(d.asks, scale),\n sequence: end,\n prevSequence,\n timestamp: d.timestamp ?? d.cts ?? Date.now(),\n });\n\n if (r.ok) {\n lastVersion = end;\n emit(r);\n } else if (r.reason === \"gap\" || r.reason === \"no-snapshot\") {\n resync();\n }\n };\n\n const onMessage = (raw: string | ArrayBuffer) => {\n if (typeof raw !== \"string\") return;\n let msg: MexcWSMessage;\n try {\n msg = JSON.parse(raw) as MexcWSMessage;\n } catch {\n return;\n }\n\n if (msg.channel === \"push.depth\") {\n if (msg.symbol && msg.symbol !== symbol) return;\n const d = msg.data as MexcFuturesDepth | undefined;\n if (!d) return;\n if (!snapshotDone) {\n buffered.push(d);\n if (!snapshotInFlight) triggerSnapshot();\n return;\n }\n processDelta(d);\n return;\n }\n\n // `rs.sub.depth` acks with data \"success\"; anything else on an rs./error\n // channel is a rejection worth surfacing.\n if (msg.channel === \"rs.error\" || msg.channel?.startsWith(\"rs.error\")) {\n stream.emit(\"error\", new ExchangeError(\"mexc\", String(msg.data)));\n return;\n }\n if (msg.channel === \"rs.sub.depth\" && msg.data !== \"success\") {\n stream.emit(\n \"error\",\n new ExchangeError(\"mexc\", `subscribe rejected: ${String(msg.data)}`)\n );\n }\n };\n\n ws = new WSClient({\n url: WS_FUTURES,\n onOpen: (handle) => {\n merger.reset();\n seedVersion = -1;\n snapshotDone = false;\n lastVersion = -1;\n buffered = [];\n handle.send(\n JSON.stringify({ method: \"sub.depth\", param: { symbol } })\n );\n },\n onMessage,\n pingIntervalMs: PING_INTERVAL_MS,\n pingPayload: () => JSON.stringify({ method: \"ping\" }),\n });\n\n ws.on(\"open\", () => stream.emit(\"connected\"));\n ws.on(\"close\", (r) => stream.emit(\"disconnected\", r));\n ws.on(\"reconnecting\", (a, w) => stream.emit(\"reconnecting\", a, w));\n ws.on(\"error\", (e) => stream.emit(\"error\", e));\n ws.connect().catch((e) => stream.emit(\"error\", e as Error));\n\n return stream;\n}\n","import type {\n ClientOptions,\n Orderbook,\n OrderbookOptions,\n} from \"../../core/types.js\";\nimport { OrderbookStream } from \"../../core/stream.js\";\nimport { parseSymbol } from \"../../core/symbol.js\";\nimport { fetchMexcOrderbook } from \"./rest.js\";\nimport { streamMexcOrderbook } from \"./ws.js\";\n\n/**\n * MEXC — USDT-M perpetuals over REST + WS, spot over REST only.\n *\n * MEXC retired its JSON spot streams in favour of protobuf-encoded ones, so\n * `streamOrderbook` on a spot symbol throws rather than returning a stream\n * that never ticks. Spot `fetchOrderbook` is unaffected.\n */\nexport class MexcClient {\n readonly exchange = \"mexc\" as const;\n private readonly transformUrl?: (url: string) => string;\n private readonly timeoutMs?: number;\n\n constructor(opts: ClientOptions = {}) {\n this.transformUrl = opts.transformUrl;\n this.timeoutMs = opts.timeoutMs;\n }\n\n fetchOrderbook(\n symbol: string,\n opts: OrderbookOptions = {}\n ): Promise<Orderbook> {\n const { pair, market } = parseSymbol(symbol);\n return fetchMexcOrderbook({\n symbol: pair,\n market,\n depth: opts.depth,\n timeoutMs: this.timeoutMs,\n transformUrl: this.transformUrl,\n });\n }\n\n /** Perpetuals only — see the class note on spot. */\n streamOrderbook(symbol: string, opts: OrderbookOptions = {}): OrderbookStream {\n const { pair, market } = parseSymbol(symbol);\n return streamMexcOrderbook({\n symbol: pair,\n market,\n depth: opts.depth,\n transformUrl: this.transformUrl,\n timeoutMs: this.timeoutMs,\n });\n }\n}\n\nexport { fetchMexcOrderbook } from \"./rest.js\";\nexport { streamMexcOrderbook } from \"./ws.js\";\nexport { toMexcSymbol, fromMexcSymbol } from \"./symbols.js\";\nexport { MEXC_SPOT_REST, MEXC_FUTURES_REST } from \"./contracts.js\";\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-Dyq24thx.cjs';
|
|
2
|
+
|
|
3
|
+
declare const MEXC_SPOT_REST = "https://api.mexc.com";
|
|
4
|
+
declare const MEXC_FUTURES_REST = "https://contract.mexc.com";
|
|
5
|
+
interface MexcContractOptions {
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
transformUrl?: (url: string) => string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface FetchMexcOrderbookOptions extends MexcContractOptions {
|
|
11
|
+
symbol: string;
|
|
12
|
+
market: Market;
|
|
13
|
+
depth?: number;
|
|
14
|
+
}
|
|
15
|
+
declare function fetchMexcOrderbook(opts: FetchMexcOrderbookOptions): Promise<Orderbook>;
|
|
16
|
+
|
|
17
|
+
interface StreamMexcOrderbookOptions extends MexcContractOptions {
|
|
18
|
+
symbol: string;
|
|
19
|
+
market: Market;
|
|
20
|
+
/** Depth used for the REST seed snapshot. Default 200. */
|
|
21
|
+
depth?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* MEXC futures `sub.depth` — incremental only, so the book is seeded from
|
|
25
|
+
* `/api/v1/contract/depth` and deltas are chained on the version range:
|
|
26
|
+
* each frame's `begin` equals the previous frame's `version` + 1, so we pass
|
|
27
|
+
* `prevSequence = begin - 1` and `sequence = end`.
|
|
28
|
+
*
|
|
29
|
+
* Spot is not supported here: MEXC retired the JSON spot streams (they now
|
|
30
|
+
* answer "Blocked!") in favour of protobuf-encoded ones, which this lib does
|
|
31
|
+
* not decode. `fetchMexcOrderbook` still serves spot over REST.
|
|
32
|
+
*
|
|
33
|
+
* Sizes arrive as contract counts and are scaled by `contractSize`.
|
|
34
|
+
*/
|
|
35
|
+
declare function streamMexcOrderbook(opts: StreamMexcOrderbookOptions): OrderbookStream;
|
|
36
|
+
|
|
37
|
+
declare function toMexcSymbol(symbol: string, market: Market): string;
|
|
38
|
+
declare function fromMexcSymbol(s: string, market: Market): string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* MEXC — USDT-M perpetuals over REST + WS, spot over REST only.
|
|
42
|
+
*
|
|
43
|
+
* MEXC retired its JSON spot streams in favour of protobuf-encoded ones, so
|
|
44
|
+
* `streamOrderbook` on a spot symbol throws rather than returning a stream
|
|
45
|
+
* that never ticks. Spot `fetchOrderbook` is unaffected.
|
|
46
|
+
*/
|
|
47
|
+
declare class MexcClient {
|
|
48
|
+
readonly exchange: "mexc";
|
|
49
|
+
private readonly transformUrl?;
|
|
50
|
+
private readonly timeoutMs?;
|
|
51
|
+
constructor(opts?: ClientOptions);
|
|
52
|
+
fetchOrderbook(symbol: string, opts?: OrderbookOptions): Promise<Orderbook>;
|
|
53
|
+
/** Perpetuals only — see the class note on spot. */
|
|
54
|
+
streamOrderbook(symbol: string, opts?: OrderbookOptions): OrderbookStream;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { MEXC_FUTURES_REST, MEXC_SPOT_REST, MexcClient, fetchMexcOrderbook, fromMexcSymbol, streamMexcOrderbook, toMexcSymbol };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { M as Market, a as Orderbook, c as OrderbookStream, C as ClientOptions, b as OrderbookOptions } from '../../stream-Dyq24thx.js';
|
|
2
|
+
|
|
3
|
+
declare const MEXC_SPOT_REST = "https://api.mexc.com";
|
|
4
|
+
declare const MEXC_FUTURES_REST = "https://contract.mexc.com";
|
|
5
|
+
interface MexcContractOptions {
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
transformUrl?: (url: string) => string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface FetchMexcOrderbookOptions extends MexcContractOptions {
|
|
11
|
+
symbol: string;
|
|
12
|
+
market: Market;
|
|
13
|
+
depth?: number;
|
|
14
|
+
}
|
|
15
|
+
declare function fetchMexcOrderbook(opts: FetchMexcOrderbookOptions): Promise<Orderbook>;
|
|
16
|
+
|
|
17
|
+
interface StreamMexcOrderbookOptions extends MexcContractOptions {
|
|
18
|
+
symbol: string;
|
|
19
|
+
market: Market;
|
|
20
|
+
/** Depth used for the REST seed snapshot. Default 200. */
|
|
21
|
+
depth?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* MEXC futures `sub.depth` — incremental only, so the book is seeded from
|
|
25
|
+
* `/api/v1/contract/depth` and deltas are chained on the version range:
|
|
26
|
+
* each frame's `begin` equals the previous frame's `version` + 1, so we pass
|
|
27
|
+
* `prevSequence = begin - 1` and `sequence = end`.
|
|
28
|
+
*
|
|
29
|
+
* Spot is not supported here: MEXC retired the JSON spot streams (they now
|
|
30
|
+
* answer "Blocked!") in favour of protobuf-encoded ones, which this lib does
|
|
31
|
+
* not decode. `fetchMexcOrderbook` still serves spot over REST.
|
|
32
|
+
*
|
|
33
|
+
* Sizes arrive as contract counts and are scaled by `contractSize`.
|
|
34
|
+
*/
|
|
35
|
+
declare function streamMexcOrderbook(opts: StreamMexcOrderbookOptions): OrderbookStream;
|
|
36
|
+
|
|
37
|
+
declare function toMexcSymbol(symbol: string, market: Market): string;
|
|
38
|
+
declare function fromMexcSymbol(s: string, market: Market): string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* MEXC — USDT-M perpetuals over REST + WS, spot over REST only.
|
|
42
|
+
*
|
|
43
|
+
* MEXC retired its JSON spot streams in favour of protobuf-encoded ones, so
|
|
44
|
+
* `streamOrderbook` on a spot symbol throws rather than returning a stream
|
|
45
|
+
* that never ticks. Spot `fetchOrderbook` is unaffected.
|
|
46
|
+
*/
|
|
47
|
+
declare class MexcClient {
|
|
48
|
+
readonly exchange: "mexc";
|
|
49
|
+
private readonly transformUrl?;
|
|
50
|
+
private readonly timeoutMs?;
|
|
51
|
+
constructor(opts?: ClientOptions);
|
|
52
|
+
fetchOrderbook(symbol: string, opts?: OrderbookOptions): Promise<Orderbook>;
|
|
53
|
+
/** Perpetuals only — see the class note on spot. */
|
|
54
|
+
streamOrderbook(symbol: string, opts?: OrderbookOptions): OrderbookStream;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { MEXC_FUTURES_REST, MEXC_SPOT_REST, MexcClient, fetchMexcOrderbook, fromMexcSymbol, streamMexcOrderbook, toMexcSymbol };
|