@nemesis-oss/binance-sdk 2.0.0 → 3.0.0

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.
@@ -25,6 +25,7 @@ __export(tools_exports, {
25
25
  createFuturesToolkit: () => createFuturesToolkit,
26
26
  createPaperContext: () => createPaperContext,
27
27
  derivedTools: () => derivedTools,
28
+ executionTools: () => executionTools,
28
29
  getBufferedWsEvents: () => getBufferedWsEvents,
29
30
  marketDataTools: () => marketDataTools,
30
31
  paperTools: () => paperTools,
@@ -333,12 +334,331 @@ function derivedTools(client) {
333
334
  ];
334
335
  }
335
336
 
336
- // src/tools/market-data.tools.ts
337
+ // src/tools/execution.tools.ts
337
338
  var import_zod5 = require("zod");
338
339
 
339
- // src/types/market.types.ts
340
+ // src/tools/trading.tools.ts
340
341
  var import_zod4 = require("zod");
341
- var KlineIntervalSchema = import_zod4.z.enum([
342
+ var symbol2 = import_zod4.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT");
343
+ var optionalSymbol2 = import_zod4.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT").optional();
344
+ var limit2 = import_zod4.z.number().int().positive().max(1e3).default(100);
345
+ var startTime2 = import_zod4.z.number().int().positive().optional();
346
+ var endTime2 = import_zod4.z.number().int().positive().optional();
347
+ var side = import_zod4.z.enum(["BUY", "SELL"]);
348
+ var positionSide = import_zod4.z.enum(["BOTH", "LONG", "SHORT"]).optional();
349
+ var orderParamsSchema = import_zod4.z.object({
350
+ symbol: symbol2,
351
+ side,
352
+ type: import_zod4.z.enum(["LIMIT", "MARKET", "STOP", "STOP_MARKET", "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET"]),
353
+ quantity: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]).describe("Order quantity in base asset"),
354
+ price: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]).optional().describe("Required for LIMIT and STOP/TAKE_PROFIT (limit-triggered) types"),
355
+ timeInForce: import_zod4.z.enum(["GTC", "IOC", "FOK", "GTX"]).optional(),
356
+ stopPrice: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]).optional().describe("Trigger price for STOP/STOP_MARKET/TAKE_PROFIT/TAKE_PROFIT_MARKET"),
357
+ reduceOnly: import_zod4.z.boolean().optional().describe("true = only reduces the position, never opens"),
358
+ positionSide,
359
+ newClientOrderId: import_zod4.z.string().optional(),
360
+ closePosition: import_zod4.z.boolean().optional().describe("Close the full position on trigger (mutually exclusive with quantity)"),
361
+ newOrderRespType: import_zod4.z.enum(["ACK", "RESULT"]).optional(),
362
+ priceProtect: import_zod4.z.boolean().optional(),
363
+ workingType: import_zod4.z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional().describe("Trigger price basis; default CONTRACT_PRICE"),
364
+ callbackRate: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]).optional().describe("Percent callback for TRAILING_STOP_MARKET, e.g. 0.5"),
365
+ activationPrice: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]).optional().describe("Activation price for TRAILING_STOP_MARKET"),
366
+ selfTradePreventionMode: import_zod4.z.enum(["NONE", "EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH"]).optional(),
367
+ goodTillDate: import_zod4.z.number().int().optional().describe("Timestamp when a GTD order expires")
368
+ });
369
+ function tradingTools(client) {
370
+ const t = client.futures.trading;
371
+ return [
372
+ {
373
+ name: "futures_new_order",
374
+ description: "Place a new futures order. Types: LIMIT, MARKET, STOP, STOP_MARKET, TAKE_PROFIT, TAKE_PROFIT_MARKET, TRAILING_STOP_MARKET. Use STOP_MARKET as the take-profit/stop-loss trigger and LIMIT for the actual fill. Signed.",
375
+ inputSchema: orderParamsSchema,
376
+ handler: async (args) => textResult(await t.createOrder({ ...args, symbol: normalizeSymbol(args.symbol) }))
377
+ },
378
+ {
379
+ name: "futures_test_order",
380
+ description: "Validate a new order without submitting it. Returns 200 on success; use to validate fields and margin before real orders. Signed.",
381
+ inputSchema: orderParamsSchema,
382
+ handler: async (args) => textResult(await t.createTestOrder({ ...args, symbol: normalizeSymbol(args.symbol) }))
383
+ },
384
+ {
385
+ name: "futures_get_order",
386
+ description: "Query a specific order by orderId or client order id. Signed.",
387
+ inputSchema: import_zod4.z.object({ symbol: symbol2, orderId: import_zod4.z.number().int().positive().optional(), origClientOrderId: import_zod4.z.string().optional() }),
388
+ handler: async ({ symbol: symbol3, orderId, origClientOrderId }) => textResult(await t.getOrder(normalizeSymbol(symbol3), { orderId, origClientOrderId }))
389
+ },
390
+ {
391
+ name: "futures_cancel_order",
392
+ description: "Cancel a specific open order by orderId or client order id. Signed.",
393
+ inputSchema: import_zod4.z.object({ symbol: symbol2, orderId: import_zod4.z.number().int().positive().optional(), origClientOrderId: import_zod4.z.string().optional() }),
394
+ handler: async ({ symbol: symbol3, orderId, origClientOrderId }) => textResult(await t.cancelOrder(normalizeSymbol(symbol3), { orderId, origClientOrderId }))
395
+ },
396
+ {
397
+ name: "futures_get_open_order",
398
+ description: "Query a current open order (must exist in the open order book). Signed.",
399
+ inputSchema: import_zod4.z.object({ symbol: symbol2, orderId: import_zod4.z.number().int().positive().optional(), origClientOrderId: import_zod4.z.string().optional() }),
400
+ handler: async ({ symbol: symbol3, orderId, origClientOrderId }) => textResult(await t.getCurrentOrder(normalizeSymbol(symbol3), { orderId, origClientOrderId }))
401
+ },
402
+ {
403
+ name: "futures_open_orders",
404
+ description: "Get all current open orders, for one symbol or all symbols. Signed.",
405
+ inputSchema: import_zod4.z.object({ symbol: optionalSymbol2 }),
406
+ handler: async ({ symbol: symbol3 }) => textResult(await t.getOpenOrders(symbol3 ? normalizeSymbol(symbol3) : void 0))
407
+ },
408
+ {
409
+ name: "futures_all_orders",
410
+ description: "Get historical orders for a symbol with optional time range (last 7 days by default). Signed.",
411
+ inputSchema: import_zod4.z.object({ symbol: symbol2, orderId: import_zod4.z.number().int().positive().optional(), startTime: startTime2, endTime: endTime2, limit: limit2 }),
412
+ handler: async ({ symbol: symbol3, orderId, startTime: startTime5, endTime: endTime5, limit: limit4 }) => textResult(await t.getAllOrders(normalizeSymbol(symbol3), { orderId, startTime: startTime5, endTime: endTime5, limit: limit4 }))
413
+ },
414
+ {
415
+ name: "futures_cancel_all_orders",
416
+ description: "Cancel all open orders for a symbol. Signed.",
417
+ inputSchema: import_zod4.z.object({ symbol: symbol2 }),
418
+ handler: async ({ symbol: symbol3 }) => textResult(await t.cancelAllOpenOrders(normalizeSymbol(symbol3)))
419
+ },
420
+ {
421
+ name: "futures_modify_order",
422
+ description: "Modify an open order (price/quantity/stopPrice). Cannot modify when position side is BOTH and closePosition is true. Signed.",
423
+ inputSchema: import_zod4.z.object({
424
+ symbol: symbol2,
425
+ side,
426
+ quantity: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]),
427
+ price: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]).optional(),
428
+ orderId: import_zod4.z.number().int().positive().optional(),
429
+ origClientOrderId: import_zod4.z.string().optional(),
430
+ stopPrice: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]).optional(),
431
+ timeInForce: import_zod4.z.enum(["GTC", "IOC", "FOK", "GTX"]).optional(),
432
+ positionSide,
433
+ newClientOrderId: import_zod4.z.string().optional()
434
+ }),
435
+ handler: async (args) => textResult(await t.modifyOrder({ ...args, symbol: normalizeSymbol(args.symbol) }))
436
+ },
437
+ {
438
+ name: "futures_order_modify_history",
439
+ description: "Get order modification history for a symbol. Signed.",
440
+ inputSchema: import_zod4.z.object({ symbol: symbol2, startTime: startTime2, endTime: endTime2, limit: limit2 }),
441
+ handler: async ({ symbol: symbol3, startTime: startTime5, endTime: endTime5, limit: limit4 }) => textResult(await t.getOrderModifyHistory(normalizeSymbol(symbol3), { startTime: startTime5, endTime: endTime5, limit: limit4 }))
442
+ },
443
+ {
444
+ name: "futures_batch_orders",
445
+ description: "Place up to 5 orders in one request (array of order objects, max 30 per minute per symbol). Signed.",
446
+ inputSchema: import_zod4.z.object({ orders: import_zod4.z.array(orderParamsSchema).min(1).max(5) }),
447
+ handler: async (args) => {
448
+ const mapped = args.orders.map((o) => ({ ...o, symbol: normalizeSymbol(o.symbol) }));
449
+ return textResult(await t.createBatchOrders(mapped));
450
+ }
451
+ },
452
+ {
453
+ name: "futures_cancel_batch_orders",
454
+ description: "Cancel multiple orders at once (up to 10 by orderId list or client order id list). Signed.",
455
+ inputSchema: import_zod4.z.object({
456
+ symbol: symbol2,
457
+ orderIdList: import_zod4.z.array(import_zod4.z.number().int().positive()).max(10).optional(),
458
+ origClientOrderIdList: import_zod4.z.array(import_zod4.z.string()).max(10).optional()
459
+ }),
460
+ handler: async ({ symbol: symbol3, orderIdList, origClientOrderIdList }) => textResult(await t.cancelBatchOrders(normalizeSymbol(symbol3), { orderIdList, origClientOrderIdList }))
461
+ },
462
+ {
463
+ name: "futures_set_leverage",
464
+ description: "Change initial leverage for a symbol (1-125, within bracket). Signed.",
465
+ inputSchema: import_zod4.z.object({ symbol: symbol2, leverage: import_zod4.z.number().int().min(1).max(125) }),
466
+ handler: async ({ symbol: symbol3, leverage }) => textResult(await t.setLeverage(normalizeSymbol(symbol3), leverage))
467
+ },
468
+ {
469
+ name: "futures_set_margin_type",
470
+ description: "Change margin type for a symbol: isolated or cross. Only allowed when no open position for the symbol. Signed.",
471
+ inputSchema: import_zod4.z.object({ symbol: symbol2, marginType: import_zod4.z.enum(["isolated", "cross"]) }),
472
+ handler: async ({ symbol: symbol3, marginType }) => textResult(await t.setMarginType(normalizeSymbol(symbol3), marginType))
473
+ },
474
+ {
475
+ name: "futures_modify_position_margin",
476
+ description: "Add or reduce isolated position margin. marginType: 1 = add margin, 2 = reduce margin. Signed.",
477
+ inputSchema: import_zod4.z.object({ symbol: symbol2, amount: import_zod4.z.number().positive(), marginType: import_zod4.z.enum(["1", "2"]).describe("1 = add margin, 2 = reduce margin") }),
478
+ handler: async ({ symbol: symbol3, amount, marginType }) => textResult(await t.modifyPositionMargin(normalizeSymbol(symbol3), amount, Number(marginType)))
479
+ },
480
+ {
481
+ name: "futures_countdown_cancel_all",
482
+ description: "Auto-cancel all open orders for a symbol after countdownTime ms (0 = cancel the countdown). Emergency circuit breaker. Signed.",
483
+ inputSchema: import_zod4.z.object({ symbol: symbol2, countdownTime: import_zod4.z.number().int().min(100).max(6e4) }),
484
+ handler: async ({ symbol: symbol3, countdownTime }) => textResult(await t.setCountdownCancelAll(normalizeSymbol(symbol3), countdownTime))
485
+ },
486
+ {
487
+ name: "futures_new_algo_order",
488
+ description: "Place a conditional algo order (CONDITIONAL or VP). CONDITIONAL supports STOP_MARKET/TAKE_PROFIT_MARKET types with triggerPrice; VP is a volume-participation order with urgency and quantity. Signed.",
489
+ inputSchema: import_zod4.z.object({
490
+ algoType: import_zod4.z.enum(["CONDITIONAL", "VP"]),
491
+ symbol: symbol2,
492
+ side,
493
+ positionSide,
494
+ type: import_zod4.z.enum(["STOP_MARKET", "TAKE_PROFIT_MARKET", "LIMIT"]).describe("For CONDITIONAL: STOP_MARKET/TAKE_PROFIT_MARKET. For VP: LIMIT"),
495
+ quantity: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]),
496
+ triggerPrice: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]).optional().describe("Required for CONDITIONAL"),
497
+ price: import_zod4.z.union([import_zod4.z.string(), import_zod4.z.number()]).optional(),
498
+ timeInForce: import_zod4.z.enum(["GTC", "IOC", "FOK", "GTX"]).optional(),
499
+ workingType: import_zod4.z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional(),
500
+ priceProtect: import_zod4.z.boolean().optional(),
501
+ reduceOnly: import_zod4.z.boolean().optional(),
502
+ closePosition: import_zod4.z.boolean().optional(),
503
+ urgency: import_zod4.z.enum(["LOW", "MEDIUM", "HIGH"]).optional().describe("Required for VP"),
504
+ clientAlgoId: import_zod4.z.string().optional()
505
+ }),
506
+ handler: async (args) => textResult(await t.createAlgoOrder({ ...args, symbol: normalizeSymbol(args.symbol) }))
507
+ },
508
+ {
509
+ name: "futures_cancel_algo_order",
510
+ description: "Cancel an open algo order by algoId or clientAlgoId. Signed.",
511
+ inputSchema: import_zod4.z.object({ symbol: symbol2, algoId: import_zod4.z.number().int().positive().optional(), clientAlgoId: import_zod4.z.string().optional() }),
512
+ handler: async ({ symbol: symbol3, algoId, clientAlgoId }) => textResult(await t.cancelAlgoOrder(normalizeSymbol(symbol3), { algoId, clientAlgoId }))
513
+ },
514
+ {
515
+ name: "futures_cancel_all_algo_orders",
516
+ description: "Cancel all open algo orders for a symbol. Signed.",
517
+ inputSchema: import_zod4.z.object({ symbol: symbol2 }),
518
+ handler: async ({ symbol: symbol3 }) => textResult(await t.cancelAllOpenAlgoOrders(normalizeSymbol(symbol3)))
519
+ },
520
+ {
521
+ name: "futures_get_algo_order",
522
+ description: "Query an algo order by algoId or clientAlgoId. Signed.",
523
+ inputSchema: import_zod4.z.object({ symbol: symbol2, algoId: import_zod4.z.number().int().positive().optional(), clientAlgoId: import_zod4.z.string().optional() }),
524
+ handler: async ({ symbol: symbol3, algoId, clientAlgoId }) => textResult(await t.getAlgoOrder(normalizeSymbol(symbol3), { algoId, clientAlgoId }))
525
+ },
526
+ {
527
+ name: "futures_open_algo_orders",
528
+ description: "Get all current open algo orders, optionally filtered by symbol. Signed.",
529
+ inputSchema: import_zod4.z.object({ symbol: optionalSymbol2 }),
530
+ handler: async ({ symbol: symbol3 }) => textResult(await t.getOpenAlgoOrders(symbol3 ? normalizeSymbol(symbol3) : void 0))
531
+ },
532
+ {
533
+ name: "futures_all_algo_orders",
534
+ description: "Get historical algo orders for a symbol with optional time range. Signed.",
535
+ inputSchema: import_zod4.z.object({ symbol: symbol2, startTime: startTime2, endTime: endTime2, limit: limit2 }),
536
+ handler: async ({ symbol: symbol3, startTime: startTime5, endTime: endTime5, limit: limit4 }) => textResult(await t.getAllAlgoOrders(normalizeSymbol(symbol3), { startTime: startTime5, endTime: endTime5, limit: limit4 }))
537
+ },
538
+ {
539
+ name: "futures_convert_exchange_info",
540
+ description: "List asset pairs eligible for futures Convert, optionally filtered by fromAsset/toAsset.",
541
+ inputSchema: import_zod4.z.object({ fromAsset: import_zod4.z.string().optional(), toAsset: import_zod4.z.string().optional() }),
542
+ handler: async ({ fromAsset, toAsset }) => textResult(await t.convertExchangeInfo({ fromAsset, toAsset }))
543
+ },
544
+ {
545
+ name: "futures_convert_get_quote",
546
+ description: "Request a Convert quote between two assets (quote expires quickly; accept with futures_convert_accept_quote). Signed.",
547
+ inputSchema: import_zod4.z.object({
548
+ fromAsset: import_zod4.z.string().min(1),
549
+ toAsset: import_zod4.z.string().min(1),
550
+ fromAmount: import_zod4.z.number().positive().optional(),
551
+ toAmount: import_zod4.z.number().positive().optional(),
552
+ validTime: import_zod4.z.enum(["10s", "30s", "1m", "2m"]).optional()
553
+ }),
554
+ handler: async (args) => textResult(await t.convertGetQuote(args))
555
+ },
556
+ {
557
+ name: "futures_convert_accept_quote",
558
+ description: "Accept a previously requested Convert quote by quoteId. Signed.",
559
+ inputSchema: import_zod4.z.object({ quoteId: import_zod4.z.string().min(1) }),
560
+ handler: async ({ quoteId }) => textResult(await t.convertAcceptQuote(quoteId))
561
+ },
562
+ {
563
+ name: "futures_convert_order_status",
564
+ description: "Query the status of a Convert order by orderId or quoteId. Signed.",
565
+ inputSchema: import_zod4.z.object({ orderId: import_zod4.z.string().optional(), quoteId: import_zod4.z.string().optional() }),
566
+ handler: async ({ orderId, quoteId }) => textResult(await t.convertOrderStatus({ orderId, quoteId }))
567
+ }
568
+ ];
569
+ }
570
+
571
+ // src/tools/execution.tools.ts
572
+ var backend = import_zod5.z.enum(["live", "paper"]).optional().describe("Execution backend for this call; default is the gateway's default backend");
573
+ var intentId = import_zod5.z.string().min(1).optional().describe(
574
+ "Idempotency key. Re-submitting the same intentId returns the original execution instead of placing a second order. Recommended for any retry loop."
575
+ );
576
+ function executionTools(gateway, client) {
577
+ return [
578
+ {
579
+ name: "execution_place_order",
580
+ description: "Place an order through the execution gateway: idempotent (retry with the same intentId returns the original execution), reconciled on ambiguous failures, and routable to the live exchange or the paper simulator via `backend`. Paper orders need no API keys. MARKET and LIMIT types supported on paper.",
581
+ inputSchema: orderParamsSchema.extend({ intentId, backend }),
582
+ handler: async (args) => {
583
+ const { intentId: intent, backend: route } = args;
584
+ return textResult(
585
+ await gateway.placeOrder(
586
+ { ...args, intentId: intent, symbol: normalizeSymbol(args.symbol) },
587
+ { backend: route }
588
+ )
589
+ );
590
+ }
591
+ },
592
+ {
593
+ name: "execution_cancel_order",
594
+ description: "Cancel an order idempotently by exchange orderId, clientOrderId, or the intentId from execution_place_order. Cancels of already-gone orders resolve to a terminal CANCELED execution (never a thrown -2011).",
595
+ inputSchema: import_zod5.z.object({
596
+ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
597
+ orderId: import_zod5.z.number().int().positive().optional().describe("Exchange order id"),
598
+ origClientOrderId: import_zod5.z.string().optional().describe("Client order id (the reconciliation key)"),
599
+ intentId,
600
+ backend
601
+ }),
602
+ handler: async ({ symbol: symbol3, orderId, origClientOrderId, intentId: intent, backend: route }) => textResult(
603
+ await gateway.cancelOrder(
604
+ normalizeSymbol(symbol3),
605
+ { orderId, origClientOrderId, intentId: intent, backend: route }
606
+ )
607
+ )
608
+ },
609
+ {
610
+ name: "execution_get_order",
611
+ description: "Fetch an execution from the ledger by its intentId. When `backend` is omitted both ledgers are searched (paper first), so callers do not need to remember where an intent ran.",
612
+ inputSchema: import_zod5.z.object({ intentId: import_zod5.z.string().min(1), backend }),
613
+ handler: async ({ intentId: intent, backend: route }) => {
614
+ const execution = route ? gateway.getExecution(intent, route) : gateway.getExecution(intent, "paper") ?? gateway.getExecution(intent, "live");
615
+ if (!execution) throw new Error(`No execution for intentId ${intent}`);
616
+ return textResult(execution);
617
+ }
618
+ },
619
+ {
620
+ name: "execution_list_orders",
621
+ description: "List the execution ledger (most recent first) for a backend. Each entry carries status, fills, and reconciliation state. Paper and live ledgers are independent.",
622
+ inputSchema: import_zod5.z.object({ backend }),
623
+ handler: async ({ backend: route }) => textResult(gateway.listExecutions(route))
624
+ },
625
+ {
626
+ name: "execution_reconcile_order",
627
+ description: "Force a reconciliation pass for an intent whose outcome is unknown (e.g. after a timeout). Recovers the true state from the exchange (live) or simulator (paper) instead of guessing.",
628
+ inputSchema: import_zod5.z.object({ intentId: import_zod5.z.string().min(1), backend }),
629
+ handler: async ({ intentId: intent, backend: route }) => textResult(await gateway.reconcile(intent, route))
630
+ },
631
+ {
632
+ name: "execution_status",
633
+ description: "Snapshot of the execution environment: default backend, risk-gateway state (when a trading policy is configured), and the paper simulator account (balance, positions, unrealized PnL). Read-only, never places orders.",
634
+ inputSchema: import_zod5.z.object({}),
635
+ handler: async () => {
636
+ const risk = client?.getRiskStatus?.();
637
+ const paper = gateway.paperEngine.getAccountInfo();
638
+ return textResult({
639
+ defaultBackend: gateway.backend,
640
+ risk: risk ?? null,
641
+ paper: {
642
+ balance: paper.balance,
643
+ availableBalance: paper.availableBalance,
644
+ totalWalletBalance: paper.totalWalletBalance,
645
+ unrealizedPnl: paper.unrealizedPnl,
646
+ realizedPnl: paper.realizedPnl,
647
+ positions: Object.values(paper.positions).filter((p) => p.quantity > 0),
648
+ orderCount: paper.orders.length
649
+ }
650
+ });
651
+ }
652
+ }
653
+ ];
654
+ }
655
+
656
+ // src/tools/market-data.tools.ts
657
+ var import_zod7 = require("zod");
658
+
659
+ // src/types/market.types.ts
660
+ var import_zod6 = require("zod");
661
+ var KlineIntervalSchema = import_zod6.z.enum([
342
662
  "1m",
343
663
  "3m",
344
664
  "5m",
@@ -355,19 +675,19 @@ var KlineIntervalSchema = import_zod4.z.enum([
355
675
  "1w",
356
676
  "1M"
357
677
  ]);
358
- var RawKlineSchema = import_zod4.z.tuple([
359
- import_zod4.z.number(),
360
- import_zod4.z.string(),
361
- import_zod4.z.string(),
362
- import_zod4.z.string(),
363
- import_zod4.z.string(),
364
- import_zod4.z.string(),
365
- import_zod4.z.number(),
366
- import_zod4.z.string(),
367
- import_zod4.z.number(),
368
- import_zod4.z.string(),
369
- import_zod4.z.string(),
370
- import_zod4.z.string()
678
+ var RawKlineSchema = import_zod6.z.tuple([
679
+ import_zod6.z.number(),
680
+ import_zod6.z.string(),
681
+ import_zod6.z.string(),
682
+ import_zod6.z.string(),
683
+ import_zod6.z.string(),
684
+ import_zod6.z.string(),
685
+ import_zod6.z.number(),
686
+ import_zod6.z.string(),
687
+ import_zod6.z.number(),
688
+ import_zod6.z.string(),
689
+ import_zod6.z.string(),
690
+ import_zod6.z.string()
371
691
  ]);
372
692
  var KlineSchema = RawKlineSchema.transform(
373
693
  ([openTime, open, high, low, close, volume, closeTime, quoteAssetVolume, trades, takerBuyBaseVolume, takerBuyQuoteVolume]) => ({
@@ -384,87 +704,87 @@ var KlineSchema = RawKlineSchema.transform(
384
704
  takerBuyQuoteVolume: Number(takerBuyQuoteVolume)
385
705
  })
386
706
  );
387
- var KlinesResponseSchema = import_zod4.z.array(KlineSchema);
388
- var TickerPriceSchema = import_zod4.z.object({
389
- symbol: import_zod4.z.string(),
390
- price: import_zod4.z.string().transform(Number),
391
- time: import_zod4.z.number().optional()
707
+ var KlinesResponseSchema = import_zod6.z.array(KlineSchema);
708
+ var TickerPriceSchema = import_zod6.z.object({
709
+ symbol: import_zod6.z.string(),
710
+ price: import_zod6.z.string().transform(Number),
711
+ time: import_zod6.z.number().optional()
392
712
  });
393
- var Ticker24hrSchema = import_zod4.z.object({
394
- symbol: import_zod4.z.string(),
395
- priceChange: import_zod4.z.string().transform(Number),
396
- priceChangePercent: import_zod4.z.string().transform(Number),
397
- weightedAvgPrice: import_zod4.z.string().transform(Number),
398
- lastPrice: import_zod4.z.string().transform(Number),
399
- lastQty: import_zod4.z.string().transform(Number),
400
- openPrice: import_zod4.z.string().transform(Number),
401
- highPrice: import_zod4.z.string().transform(Number),
402
- lowPrice: import_zod4.z.string().transform(Number),
403
- volume: import_zod4.z.string().transform(Number),
404
- quoteVolume: import_zod4.z.string().transform(Number),
405
- openTime: import_zod4.z.number(),
406
- closeTime: import_zod4.z.number(),
407
- firstId: import_zod4.z.number(),
408
- lastId: import_zod4.z.number(),
409
- count: import_zod4.z.number()
713
+ var Ticker24hrSchema = import_zod6.z.object({
714
+ symbol: import_zod6.z.string(),
715
+ priceChange: import_zod6.z.string().transform(Number),
716
+ priceChangePercent: import_zod6.z.string().transform(Number),
717
+ weightedAvgPrice: import_zod6.z.string().transform(Number),
718
+ lastPrice: import_zod6.z.string().transform(Number),
719
+ lastQty: import_zod6.z.string().transform(Number),
720
+ openPrice: import_zod6.z.string().transform(Number),
721
+ highPrice: import_zod6.z.string().transform(Number),
722
+ lowPrice: import_zod6.z.string().transform(Number),
723
+ volume: import_zod6.z.string().transform(Number),
724
+ quoteVolume: import_zod6.z.string().transform(Number),
725
+ openTime: import_zod6.z.number(),
726
+ closeTime: import_zod6.z.number(),
727
+ firstId: import_zod6.z.number(),
728
+ lastId: import_zod6.z.number(),
729
+ count: import_zod6.z.number()
410
730
  });
411
- var BookTickerSchema = import_zod4.z.object({
412
- symbol: import_zod4.z.string(),
413
- bidPrice: import_zod4.z.string().transform(Number),
414
- bidQty: import_zod4.z.string().transform(Number),
415
- askPrice: import_zod4.z.string().transform(Number),
416
- askQty: import_zod4.z.string().transform(Number),
417
- time: import_zod4.z.number().optional()
731
+ var BookTickerSchema = import_zod6.z.object({
732
+ symbol: import_zod6.z.string(),
733
+ bidPrice: import_zod6.z.string().transform(Number),
734
+ bidQty: import_zod6.z.string().transform(Number),
735
+ askPrice: import_zod6.z.string().transform(Number),
736
+ askQty: import_zod6.z.string().transform(Number),
737
+ time: import_zod6.z.number().optional()
418
738
  });
419
- var DepthLevelSchema = import_zod4.z.tuple([import_zod4.z.string(), import_zod4.z.string()]).transform(([price, qty]) => ({ price: Number(price), qty: Number(qty) }));
420
- var DepthSnapshotSchema = import_zod4.z.object({
421
- lastUpdateId: import_zod4.z.number(),
422
- bids: import_zod4.z.array(DepthLevelSchema),
423
- asks: import_zod4.z.array(DepthLevelSchema)
739
+ var DepthLevelSchema = import_zod6.z.tuple([import_zod6.z.string(), import_zod6.z.string()]).transform(([price, qty]) => ({ price: Number(price), qty: Number(qty) }));
740
+ var DepthSnapshotSchema = import_zod6.z.object({
741
+ lastUpdateId: import_zod6.z.number(),
742
+ bids: import_zod6.z.array(DepthLevelSchema),
743
+ asks: import_zod6.z.array(DepthLevelSchema)
424
744
  });
425
- var TradeSchema = import_zod4.z.object({
426
- id: import_zod4.z.number(),
427
- price: import_zod4.z.string().transform(Number),
428
- qty: import_zod4.z.string().transform(Number),
429
- quoteQty: import_zod4.z.string().transform(Number),
430
- time: import_zod4.z.number(),
431
- isBuyerMaker: import_zod4.z.boolean()
745
+ var TradeSchema = import_zod6.z.object({
746
+ id: import_zod6.z.number(),
747
+ price: import_zod6.z.string().transform(Number),
748
+ qty: import_zod6.z.string().transform(Number),
749
+ quoteQty: import_zod6.z.string().transform(Number),
750
+ time: import_zod6.z.number(),
751
+ isBuyerMaker: import_zod6.z.boolean()
432
752
  });
433
- var TradesResponseSchema = import_zod4.z.array(TradeSchema);
434
- var AggTradeSchema = import_zod4.z.object({
435
- a: import_zod4.z.number(),
436
- p: import_zod4.z.string().transform(Number),
437
- q: import_zod4.z.string().transform(Number),
438
- f: import_zod4.z.number(),
439
- l: import_zod4.z.number(),
440
- T: import_zod4.z.number(),
441
- m: import_zod4.z.boolean()
753
+ var TradesResponseSchema = import_zod6.z.array(TradeSchema);
754
+ var AggTradeSchema = import_zod6.z.object({
755
+ a: import_zod6.z.number(),
756
+ p: import_zod6.z.string().transform(Number),
757
+ q: import_zod6.z.string().transform(Number),
758
+ f: import_zod6.z.number(),
759
+ l: import_zod6.z.number(),
760
+ T: import_zod6.z.number(),
761
+ m: import_zod6.z.boolean()
442
762
  });
443
- var AggTradesResponseSchema = import_zod4.z.array(AggTradeSchema);
444
- var AvgPriceSchema = import_zod4.z.object({
445
- mins: import_zod4.z.number(),
446
- price: import_zod4.z.string().transform(Number)
763
+ var AggTradesResponseSchema = import_zod6.z.array(AggTradeSchema);
764
+ var AvgPriceSchema = import_zod6.z.object({
765
+ mins: import_zod6.z.number(),
766
+ price: import_zod6.z.string().transform(Number)
447
767
  });
448
- var ExchangeSymbolSchema = import_zod4.z.object({
449
- symbol: import_zod4.z.string(),
450
- status: import_zod4.z.string(),
451
- baseAsset: import_zod4.z.string(),
452
- quoteAsset: import_zod4.z.string()
768
+ var ExchangeSymbolSchema = import_zod6.z.object({
769
+ symbol: import_zod6.z.string(),
770
+ status: import_zod6.z.string(),
771
+ baseAsset: import_zod6.z.string(),
772
+ quoteAsset: import_zod6.z.string()
453
773
  }).loose();
454
- var ExchangeInfoSchema = import_zod4.z.object({
455
- timezone: import_zod4.z.string(),
456
- serverTime: import_zod4.z.number(),
457
- symbols: import_zod4.z.array(ExchangeSymbolSchema)
774
+ var ExchangeInfoSchema = import_zod6.z.object({
775
+ timezone: import_zod6.z.string(),
776
+ serverTime: import_zod6.z.number(),
777
+ symbols: import_zod6.z.array(ExchangeSymbolSchema)
458
778
  }).loose();
459
779
 
460
780
  // src/tools/market-data.tools.ts
461
781
  var u = (s) => s.optional();
462
- var optSymbol = u(import_zod5.z.string().min(1)).describe("USD-M pair, e.g. BTCUSDT");
463
- var limitDefault = import_zod5.z.number().int().positive().max(1500).default(100);
464
- var startTime2 = import_zod5.z.number().int().positive().optional();
465
- var endTime2 = import_zod5.z.number().int().positive().optional();
466
- var period = import_zod5.z.enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]).default("1h");
467
- var contractType = import_zod5.z.enum(["perpetual", "current_quarter", "next_quarter"]).default("perpetual");
782
+ var optSymbol = u(import_zod7.z.string().min(1)).describe("USD-M pair, e.g. BTCUSDT");
783
+ var limitDefault = import_zod7.z.number().int().positive().max(1500).default(100);
784
+ var startTime3 = import_zod7.z.number().int().positive().optional();
785
+ var endTime3 = import_zod7.z.number().int().positive().optional();
786
+ var period = import_zod7.z.enum(["5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d"]).default("1h");
787
+ var contractType = import_zod7.z.enum(["perpetual", "current_quarter", "next_quarter"]).default("perpetual");
468
788
  function marketDataTools(client) {
469
789
  const m = client.futures.market;
470
790
  const d = client.futures.data;
@@ -472,65 +792,65 @@ function marketDataTools(client) {
472
792
  {
473
793
  name: "futures_ping",
474
794
  description: "Test connectivity to the Binance USD-M futures REST API. Returns empty object {} on success.",
475
- inputSchema: import_zod5.z.object({}),
795
+ inputSchema: import_zod7.z.object({}),
476
796
  handler: async () => textResult(await m.ping())
477
797
  },
478
798
  {
479
799
  name: "futures_server_time",
480
800
  description: "Get the current Binance USD-M futures server time in milliseconds since epoch.",
481
- inputSchema: import_zod5.z.object({}),
801
+ inputSchema: import_zod7.z.object({}),
482
802
  handler: async () => textResult(await m.serverTime())
483
803
  },
484
804
  {
485
805
  name: "futures_exchange_info",
486
806
  description: "Get exchange trading rules and symbol metadata: contract type, status, base/quote assets, price/quantity filters, tick size, step size, notional and leverage brackets, delivery dates.",
487
- inputSchema: import_zod5.z.object({}),
807
+ inputSchema: import_zod7.z.object({}),
488
808
  handler: async () => textResult(await m.exchangeInfo())
489
809
  },
490
810
  {
491
811
  name: "futures_ticker_price",
492
812
  description: "Get latest price for one symbol (v1).",
493
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
813
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
494
814
  handler: async ({ symbol: symbol3 }) => textResult(await m.tickerPrice(normalizeSymbol(symbol3)))
495
815
  },
496
816
  {
497
817
  name: "futures_ticker_price_v2",
498
818
  description: "Get latest price for one symbol, or for all symbols when symbol is omitted (v2 endpoint). Use all-symbols mode for market overviews.",
499
- inputSchema: import_zod5.z.object({ symbol: optSymbol }),
819
+ inputSchema: import_zod7.z.object({ symbol: optSymbol }),
500
820
  handler: async ({ symbol: symbol3 }) => textResult(await m.tickerPriceV2(symbol3 ? normalizeSymbol(symbol3) : void 0))
501
821
  },
502
822
  {
503
823
  name: "futures_ticker_24hr",
504
824
  description: "Get 24-hour rolling price change statistics for a symbol: price change %, high, low, volume, quote volume, open interest.",
505
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
825
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
506
826
  handler: async ({ symbol: symbol3 }) => textResult(await m.ticker24hr(normalizeSymbol(symbol3)))
507
827
  },
508
828
  {
509
829
  name: "futures_book_ticker",
510
830
  description: "Get best bid/ask (top of book) for a single symbol (v1).",
511
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
831
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
512
832
  handler: async ({ symbol: symbol3 }) => textResult(await m.bookTicker(normalizeSymbol(symbol3)))
513
833
  },
514
834
  {
515
835
  name: "futures_book_ticker_v2",
516
836
  description: "Get best bid/ask (top of book) for one symbol, or all symbols when omitted (v2 endpoint).",
517
- inputSchema: import_zod5.z.object({ symbol: optSymbol }),
837
+ inputSchema: import_zod7.z.object({ symbol: optSymbol }),
518
838
  handler: async ({ symbol: symbol3 }) => textResult(await m.bookTickerV2(symbol3 ? normalizeSymbol(symbol3) : void 0))
519
839
  },
520
840
  {
521
841
  name: "futures_order_book",
522
842
  description: "Get order book depth for a symbol. Limits: 5, 10, 20, 50, 100, 500, 1000.",
523
- inputSchema: import_zod5.z.object({
524
- symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
525
- limit: import_zod5.z.enum(["5", "10", "20", "50", "100", "500", "1000"]).default("100")
843
+ inputSchema: import_zod7.z.object({
844
+ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
845
+ limit: import_zod7.z.enum(["5", "10", "20", "50", "100", "500", "1000"]).default("100")
526
846
  }),
527
847
  handler: async ({ symbol: symbol3, limit: limit4 }) => textResult(await m.depth(normalizeSymbol(symbol3), Number(limit4)))
528
848
  },
529
849
  {
530
850
  name: "futures_recent_trades",
531
851
  description: "Get the most recent executed trades for a symbol (public endpoint).",
532
- inputSchema: import_zod5.z.object({
533
- symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
852
+ inputSchema: import_zod7.z.object({
853
+ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
534
854
  limit: limitDefault.default(500)
535
855
  }),
536
856
  handler: async ({ symbol: symbol3, limit: limit4 }) => textResult(await m.trades(normalizeSymbol(symbol3), Number(limit4)))
@@ -538,184 +858,184 @@ function marketDataTools(client) {
538
858
  {
539
859
  name: "futures_historical_trades",
540
860
  description: "Get older trades for a symbol by fromId (older than recent).",
541
- inputSchema: import_zod5.z.object({
542
- symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
861
+ inputSchema: import_zod7.z.object({
862
+ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
543
863
  limit: limitDefault.default(500),
544
- fromId: import_zod5.z.number().int().positive().optional()
864
+ fromId: import_zod7.z.number().int().positive().optional()
545
865
  }),
546
866
  handler: async ({ symbol: symbol3, limit: limit4, fromId }) => textResult(await m.historicalTrades(normalizeSymbol(symbol3), { limit: Number(limit4), fromId }))
547
867
  },
548
868
  {
549
869
  name: "futures_agg_trades",
550
870
  description: "Get compressed/aggregate trades for a symbol within an optional time window. Each entry aggregates trades with the same price and side.",
551
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), limit: limitDefault.default(500), startTime: startTime2, endTime: endTime2 }),
871
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), limit: limitDefault.default(500), startTime: startTime3, endTime: endTime3 }),
552
872
  handler: async ({ symbol: symbol3, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await m.aggTrades(normalizeSymbol(symbol3), { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
553
873
  },
554
874
  {
555
875
  name: "futures_klines",
556
876
  description: "Get candlestick (OHLCV) data for a symbol. Intervals: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M. Max 1500 per request.",
557
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), interval: KlineIntervalSchema, limit: limitDefault.default(500), startTime: startTime2, endTime: endTime2 }),
877
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), interval: KlineIntervalSchema, limit: limitDefault.default(500), startTime: startTime3, endTime: endTime3 }),
558
878
  handler: async ({ symbol: symbol3, interval, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await m.klines(normalizeSymbol(symbol3), interval, { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
559
879
  },
560
880
  {
561
881
  name: "futures_continuous_klines",
562
882
  description: "Get klines for a continuous contract (perpetual, current_quarter, next_quarter) identified by base pair (e.g. BTCUSDT).",
563
- inputSchema: import_zod5.z.object({
564
- symbol: import_zod5.z.string().min(1).describe("Base pair, e.g. BTCUSDT"),
883
+ inputSchema: import_zod7.z.object({
884
+ symbol: import_zod7.z.string().min(1).describe("Base pair, e.g. BTCUSDT"),
565
885
  contractType,
566
886
  interval: KlineIntervalSchema,
567
887
  limit: limitDefault.default(500),
568
- startTime: startTime2,
569
- endTime: endTime2
888
+ startTime: startTime3,
889
+ endTime: endTime3
570
890
  }),
571
891
  handler: async ({ symbol: symbol3, contractType: contractType2, interval, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await m.continuousKlines(normalizeSymbol(symbol3), contractType2, interval, { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
572
892
  },
573
893
  {
574
894
  name: "futures_index_price_klines",
575
895
  description: "Get index price candlesticks for a pair (e.g. BTCUSDT index).",
576
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("Base pair, e.g. BTCUSDT"), interval: KlineIntervalSchema, limit: limitDefault.default(500), startTime: startTime2, endTime: endTime2 }),
896
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("Base pair, e.g. BTCUSDT"), interval: KlineIntervalSchema, limit: limitDefault.default(500), startTime: startTime3, endTime: endTime3 }),
577
897
  handler: async ({ symbol: symbol3, interval, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await m.indexPriceKlines(normalizeSymbol(symbol3), interval, { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
578
898
  },
579
899
  {
580
900
  name: "futures_mark_price_klines",
581
901
  description: "Get mark price candlesticks for a symbol.",
582
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), interval: KlineIntervalSchema, limit: limitDefault.default(500), startTime: startTime2, endTime: endTime2 }),
902
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), interval: KlineIntervalSchema, limit: limitDefault.default(500), startTime: startTime3, endTime: endTime3 }),
583
903
  handler: async ({ symbol: symbol3, interval, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await m.markPriceKlines(normalizeSymbol(symbol3), interval, { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
584
904
  },
585
905
  {
586
906
  name: "futures_trading_day_ticker",
587
907
  description: "Get the trading-day ticker (v1: rolling window stats by symbol, including open, close, high, low, volume, closeTime).",
588
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
908
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
589
909
  handler: async ({ symbol: symbol3 }) => textResult(await m.tradingDayTicker(normalizeSymbol(symbol3)))
590
910
  },
591
911
  {
592
912
  name: "futures_mark_price",
593
913
  description: "Get mark price, index price, estimated settle price, last funding rate, next funding time and interest rate for a symbol.",
594
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
914
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
595
915
  handler: async ({ symbol: symbol3 }) => textResult(await d.premiumIndex(normalizeSymbol(symbol3)))
596
916
  },
597
917
  {
598
918
  name: "futures_funding_rate_history",
599
919
  description: "Get historical funding rates for a symbol.",
600
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), limit: limitDefault.default(100), startTime: startTime2, endTime: endTime2 }),
920
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), limit: limitDefault.default(100), startTime: startTime3, endTime: endTime3 }),
601
921
  handler: async ({ symbol: symbol3, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await d.fundingRateHistory(normalizeSymbol(symbol3), { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
602
922
  },
603
923
  {
604
924
  name: "futures_funding_info",
605
925
  description: "Get funding rate configuration for all symbols with adjusted funding cap/floor or interval (e.g. under extreme volatility).",
606
- inputSchema: import_zod5.z.object({}),
926
+ inputSchema: import_zod7.z.object({}),
607
927
  handler: async () => textResult(await d.fundingInfo())
608
928
  },
609
929
  {
610
930
  name: "futures_open_interest",
611
931
  description: "Get the current total open interest for a symbol.",
612
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
932
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
613
933
  handler: async ({ symbol: symbol3 }) => textResult(await d.openInterest(normalizeSymbol(symbol3)))
614
934
  },
615
935
  {
616
936
  name: "futures_open_interest_hist",
617
937
  description: "Get historical open interest statistics per period.",
618
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), period, limit: limitDefault.default(30) }),
938
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), period, limit: limitDefault.default(30) }),
619
939
  handler: async ({ symbol: symbol3, period: period2, limit: limit4 }) => textResult(await d.openInterestHist(normalizeSymbol(symbol3), period2, Number(limit4)))
620
940
  },
621
941
  {
622
942
  name: "futures_top_long_short_account_ratio",
623
943
  description: "Get top trader long/short account ratio (number of accounts) for a symbol.",
624
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), period, limit: limitDefault.default(30) }),
944
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), period, limit: limitDefault.default(30) }),
625
945
  handler: async ({ symbol: symbol3, period: period2, limit: limit4 }) => textResult(await d.topLongShortAccountRatio(normalizeSymbol(symbol3), period2, Number(limit4)))
626
946
  },
627
947
  {
628
948
  name: "futures_top_long_short_position_ratio",
629
949
  description: "Get top trader long/short position ratio (accounts with net positions) for a symbol.",
630
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), period, limit: limitDefault.default(30) }),
950
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), period, limit: limitDefault.default(30) }),
631
951
  handler: async ({ symbol: symbol3, period: period2, limit: limit4 }) => textResult(await d.topLongShortPositionRatio(normalizeSymbol(symbol3), period2, Number(limit4)))
632
952
  },
633
953
  {
634
954
  name: "futures_global_long_short_ratio",
635
955
  description: "Get global long/short account ratio for a symbol (all accounts).",
636
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), period, limit: limitDefault.default(30) }),
956
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), period, limit: limitDefault.default(30) }),
637
957
  handler: async ({ symbol: symbol3, period: period2, limit: limit4 }) => textResult(await d.globalLongShortAccountRatio(normalizeSymbol(symbol3), period2, Number(limit4)))
638
958
  },
639
959
  {
640
960
  name: "futures_taker_long_short_ratio",
641
961
  description: "Get taker buy/sell volume ratio for a symbol.",
642
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), period, limit: limitDefault.default(30) }),
962
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), period, limit: limitDefault.default(30) }),
643
963
  handler: async ({ symbol: symbol3, period: period2, limit: limit4 }) => textResult(await d.takerLongShortRatio(normalizeSymbol(symbol3), period2, Number(limit4)))
644
964
  },
645
965
  {
646
966
  name: "futures_basis",
647
967
  description: "Get basis data (spot-futures spread, mark price - index price) for a pair and contract type.",
648
- inputSchema: import_zod5.z.object({
649
- symbol: import_zod5.z.string().min(1).describe("Base pair, e.g. BTCUSDT"),
968
+ inputSchema: import_zod7.z.object({
969
+ symbol: import_zod7.z.string().min(1).describe("Base pair, e.g. BTCUSDT"),
650
970
  period,
651
971
  limit: limitDefault.default(30),
652
- startTime: startTime2,
653
- endTime: endTime2
972
+ startTime: startTime3,
973
+ endTime: endTime3
654
974
  }),
655
975
  handler: async ({ symbol: symbol3, period: period2, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await d.basis(normalizeSymbol(symbol3), period2, { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
656
976
  },
657
977
  {
658
978
  name: "futures_asset_index",
659
979
  description: "Get multi-assets mode asset index (collateral price) for one asset or all assets.",
660
- inputSchema: import_zod5.z.object({ symbol: optSymbol.describe("Asset index symbol, e.g. ADAUSD") }),
980
+ inputSchema: import_zod7.z.object({ symbol: optSymbol.describe("Asset index symbol, e.g. ADAUSD") }),
661
981
  handler: async ({ symbol: symbol3 }) => textResult(await d.assetIndex(symbol3 ? normalizeSymbol(symbol3) : void 0))
662
982
  },
663
983
  {
664
984
  name: "futures_composite_index_info",
665
985
  description: "Get composite index symbol information (e.g. DEFIUSDT) with constituent weights.",
666
- inputSchema: import_zod5.z.object({ symbol: optSymbol }),
986
+ inputSchema: import_zod7.z.object({ symbol: optSymbol }),
667
987
  handler: async ({ symbol: symbol3 }) => textResult(await d.compositeIndexInfo(symbol3 ? normalizeSymbol(symbol3) : void 0))
668
988
  },
669
989
  {
670
990
  name: "futures_insurance_balance",
671
991
  description: "Get insurance fund balance snapshots for a symbol.",
672
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BNBUSDT"), limit: limitDefault.default(100), startTime: startTime2, endTime: endTime2 }),
992
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BNBUSDT"), limit: limitDefault.default(100), startTime: startTime3, endTime: endTime3 }),
673
993
  handler: async ({ symbol: symbol3, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await d.insuranceFundBalance({ symbol: normalizeSymbol(symbol3), limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
674
994
  },
675
995
  {
676
996
  name: "futures_index_price_constituents",
677
997
  description: "Get the index price constituents (exchange weights) for a symbol.",
678
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
998
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT") }),
679
999
  handler: async ({ symbol: symbol3 }) => textResult(await d.indexPriceConstituents(normalizeSymbol(symbol3)))
680
1000
  },
681
1001
  {
682
1002
  name: "futures_premium_index_klines",
683
1003
  description: "Get premium index candlesticks for a symbol (mark price premium over index price).",
684
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), interval: KlineIntervalSchema, limit: limitDefault.default(500), startTime: startTime2, endTime: endTime2 }),
1004
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), interval: KlineIntervalSchema, limit: limitDefault.default(500), startTime: startTime3, endTime: endTime3 }),
685
1005
  handler: async ({ symbol: symbol3, interval, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await m.premiumIndexKlines(normalizeSymbol(symbol3), interval, { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
686
1006
  },
687
1007
  {
688
1008
  name: "futures_rpi_depth",
689
1009
  description: "Get the RPI (Retail Price Improvement) order book depth for a symbol.",
690
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), limit: import_zod5.z.number().int().positive().default(1e3) }),
1010
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"), limit: import_zod7.z.number().int().positive().default(1e3) }),
691
1011
  handler: async ({ symbol: symbol3, limit: limit4 }) => textResult(await m.rpiDepth(normalizeSymbol(symbol3), Number(limit4)))
692
1012
  },
693
1013
  {
694
1014
  name: "futures_delivery_price",
695
1015
  description: "Get historical quarterly contract settlement/delivery prices for a pair.",
696
- inputSchema: import_zod5.z.object({ symbol: import_zod5.z.string().min(1).describe("Base pair, e.g. BTCUSDT") }),
1016
+ inputSchema: import_zod7.z.object({ symbol: import_zod7.z.string().min(1).describe("Base pair, e.g. BTCUSDT") }),
697
1017
  handler: async ({ symbol: symbol3 }) => textResult(await d.deliveryPrice(normalizeSymbol(symbol3)))
698
1018
  },
699
1019
  {
700
1020
  name: "futures_symbol_adl_risk",
701
1021
  description: "Get the auto-deleveraging (ADL) risk level for one symbol or all symbols on the account (signed).",
702
- inputSchema: import_zod5.z.object({ symbol: optSymbol }),
1022
+ inputSchema: import_zod7.z.object({ symbol: optSymbol }),
703
1023
  handler: async ({ symbol: symbol3 }) => textResult(await d.symbolAdlRisk(symbol3 ? normalizeSymbol(symbol3) : void 0))
704
1024
  },
705
1025
  {
706
1026
  name: "futures_adl_quantile",
707
1027
  description: "Get the position ADL (auto-deleveraging) quantile estimation for one symbol or all symbols (signed).",
708
- inputSchema: import_zod5.z.object({ symbol: optSymbol }),
1028
+ inputSchema: import_zod7.z.object({ symbol: optSymbol }),
709
1029
  handler: async ({ symbol: symbol3 }) => textResult(await d.adlQuantile(symbol3 ? normalizeSymbol(symbol3) : void 0))
710
1030
  },
711
1031
  {
712
1032
  name: "futures_force_orders",
713
1033
  description: "Get the user's force-liquidation orders (LIQUIDATION) and ADL orders for a symbol or all symbols (signed).",
714
- inputSchema: import_zod5.z.object({
1034
+ inputSchema: import_zod7.z.object({
715
1035
  symbol: optSymbol,
716
- autoCloseType: import_zod5.z.enum(["LIQUIDATION", "ADL"]).optional(),
717
- startTime: startTime2,
718
- endTime: endTime2,
1036
+ autoCloseType: import_zod7.z.enum(["LIQUIDATION", "ADL"]).optional(),
1037
+ startTime: startTime3,
1038
+ endTime: endTime3,
719
1039
  limit: limitDefault.default(50)
720
1040
  }),
721
1041
  handler: async ({ symbol: symbol3, autoCloseType, startTime: startTime5, endTime: endTime5, limit: limit4 }) => textResult(
@@ -733,7 +1053,7 @@ function marketDataTools(client) {
733
1053
  }
734
1054
 
735
1055
  // src/tools/paper.tools.ts
736
- var import_zod6 = require("zod");
1056
+ var import_zod8 = require("zod");
737
1057
  function createPaperContext(client, initialState = {}) {
738
1058
  return {
739
1059
  client,
@@ -751,7 +1071,7 @@ function paperTools(ctx) {
751
1071
  {
752
1072
  name: "paper_init",
753
1073
  description: "Initialize paper-trading state (reset balances, positions, history). No API keys required.",
754
- inputSchema: import_zod6.z.object({ balance: import_zod6.z.number().positive().default(1e4).describe("Starting USDT balance") }),
1074
+ inputSchema: import_zod8.z.object({ balance: import_zod8.z.number().positive().default(1e4).describe("Starting USDT balance") }),
755
1075
  handler: async ({ balance }) => {
756
1076
  s.balance = balance;
757
1077
  s.positions = [];
@@ -762,17 +1082,17 @@ function paperTools(ctx) {
762
1082
  {
763
1083
  name: "paper_balance",
764
1084
  description: "Get current paper-trading balance and open-position equity (uses live market prices if an open position exists). No API keys required.",
765
- inputSchema: import_zod6.z.object({}),
1085
+ inputSchema: import_zod8.z.object({}),
766
1086
  handler: async () => textResult(s)
767
1087
  },
768
1088
  {
769
1089
  name: "paper_open_position",
770
1090
  description: "Open an in-memory paper position at the live ticker price (or a fixed price). No API keys required.",
771
- inputSchema: import_zod6.z.object({
772
- symbol: import_zod6.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
773
- side: import_zod6.z.enum(["LONG", "SHORT"]),
774
- quantity: import_zod6.z.number().positive(),
775
- price: import_zod6.z.number().positive().optional().describe("If omitted, uses live ticker price")
1091
+ inputSchema: import_zod8.z.object({
1092
+ symbol: import_zod8.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
1093
+ side: import_zod8.z.enum(["LONG", "SHORT"]),
1094
+ quantity: import_zod8.z.number().positive(),
1095
+ price: import_zod8.z.number().positive().optional().describe("If omitted, uses live ticker price")
776
1096
  }),
777
1097
  handler: async ({ symbol: symbol3, side: side3, quantity, price }) => {
778
1098
  const sym = normalizeSymbol(symbol3);
@@ -786,10 +1106,10 @@ function paperTools(ctx) {
786
1106
  {
787
1107
  name: "paper_close_position",
788
1108
  description: "Close a paper position by id (or symbol) and realize PnL at the live/last price.",
789
- inputSchema: import_zod6.z.object({
790
- id: import_zod6.z.string().optional().describe("Position id from paper_open_position"),
791
- symbol: import_zod6.z.string().min(1).optional().describe("Close the position for this symbol"),
792
- price: import_zod6.z.number().positive().optional().describe("If omitted, uses live ticker price")
1109
+ inputSchema: import_zod8.z.object({
1110
+ id: import_zod8.z.string().optional().describe("Position id from paper_open_position"),
1111
+ symbol: import_zod8.z.string().min(1).optional().describe("Close the position for this symbol"),
1112
+ price: import_zod8.z.number().positive().optional().describe("If omitted, uses live ticker price")
793
1113
  }),
794
1114
  handler: async ({ id, symbol: symbol3, price }) => {
795
1115
  const idx = s.positions.findIndex((p) => id ? p.id === id : normalizeSymbol(p.symbol) === normalizeSymbol(symbol3 ?? ""));
@@ -807,7 +1127,7 @@ function paperTools(ctx) {
807
1127
  {
808
1128
  name: "paper_positions",
809
1129
  description: "List open paper positions with live unrealized PnL (marked to market).",
810
- inputSchema: import_zod6.z.object({}),
1130
+ inputSchema: import_zod8.z.object({}),
811
1131
  handler: async () => {
812
1132
  const out = await Promise.all(
813
1133
  s.positions.map(async (p) => {
@@ -821,39 +1141,39 @@ function paperTools(ctx) {
821
1141
  {
822
1142
  name: "paper_history",
823
1143
  description: "List paper-trading history of open/close events with realized PnL.",
824
- inputSchema: import_zod6.z.object({}),
1144
+ inputSchema: import_zod8.z.object({}),
825
1145
  handler: async () => textResult(s.history)
826
1146
  },
827
1147
  {
828
1148
  name: "paper_summary",
829
1149
  description: "Summarize paper-trading state: balance, open positions, trade count.",
830
- inputSchema: import_zod6.z.object({}),
1150
+ inputSchema: import_zod8.z.object({}),
831
1151
  handler: async () => textResult({ balance: s.balance, openPositions: s.positions.length, trades: s.history.length })
832
1152
  }
833
1153
  ];
834
1154
  }
835
1155
 
836
1156
  // src/tools/spot.tools.ts
837
- var import_zod7 = require("zod");
838
- var spotSymbol = import_zod7.z.string().min(1).describe("Spot pair, e.g. BTCUSDT");
839
- var optionalSymbol2 = import_zod7.z.string().min(1).describe("Spot pair, e.g. BTCUSDT").optional();
840
- var limit2 = import_zod7.z.number().int().positive().max(1e3).default(100);
841
- var startTime3 = import_zod7.z.number().int().positive().optional();
842
- var endTime3 = import_zod7.z.number().int().positive().optional();
843
- var side = import_zod7.z.enum(["BUY", "SELL"]);
844
- var spotOrderParamsSchema = import_zod7.z.object({
1157
+ var import_zod9 = require("zod");
1158
+ var spotSymbol = import_zod9.z.string().min(1).describe("Spot pair, e.g. BTCUSDT");
1159
+ var optionalSymbol3 = import_zod9.z.string().min(1).describe("Spot pair, e.g. BTCUSDT").optional();
1160
+ var limit3 = import_zod9.z.number().int().positive().max(1e3).default(100);
1161
+ var startTime4 = import_zod9.z.number().int().positive().optional();
1162
+ var endTime4 = import_zod9.z.number().int().positive().optional();
1163
+ var side2 = import_zod9.z.enum(["BUY", "SELL"]);
1164
+ var spotOrderParamsSchema = import_zod9.z.object({
845
1165
  symbol: spotSymbol,
846
- side,
847
- type: import_zod7.z.enum(["LIMIT", "MARKET", "LIMIT_MAKER", "STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT"]),
848
- quantity: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).optional().describe("Base-asset quantity; omit if using quoteOrderQty"),
849
- quoteOrderQty: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).optional().describe("Quote-asset quantity (e.g. spend 100 USDT on a MARKET order)"),
850
- price: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).optional().describe("Required for LIMIT / STOP_LOSS_LIMIT / TAKE_PROFIT_LIMIT"),
851
- stopPrice: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).optional().describe("Trigger price for STOP_LOSS / TAKE_PROFIT variants"),
852
- timeInForce: import_zod7.z.enum(["GTC", "IOC", "FOK"]).optional().describe("Required for LIMIT"),
853
- newClientOrderId: import_zod7.z.string().optional(),
854
- newOrderRespType: import_zod7.z.enum(["ACK", "RESULT", "FULL"]).optional(),
855
- icebergQty: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).optional(),
856
- selfTradePreventionMode: import_zod7.z.enum(["NONE", "EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH"]).optional()
1166
+ side: side2,
1167
+ type: import_zod9.z.enum(["LIMIT", "MARKET", "LIMIT_MAKER", "STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT"]),
1168
+ quantity: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).optional().describe("Base-asset quantity; omit if using quoteOrderQty"),
1169
+ quoteOrderQty: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).optional().describe("Quote-asset quantity (e.g. spend 100 USDT on a MARKET order)"),
1170
+ price: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).optional().describe("Required for LIMIT / STOP_LOSS_LIMIT / TAKE_PROFIT_LIMIT"),
1171
+ stopPrice: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).optional().describe("Trigger price for STOP_LOSS / TAKE_PROFIT variants"),
1172
+ timeInForce: import_zod9.z.enum(["GTC", "IOC", "FOK"]).optional().describe("Required for LIMIT"),
1173
+ newClientOrderId: import_zod9.z.string().optional(),
1174
+ newOrderRespType: import_zod9.z.enum(["ACK", "RESULT", "FULL"]).optional(),
1175
+ icebergQty: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).optional(),
1176
+ selfTradePreventionMode: import_zod9.z.enum(["NONE", "EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH"]).optional()
857
1177
  });
858
1178
  function spotTools(client) {
859
1179
  const m = client.spot.market;
@@ -864,128 +1184,128 @@ function spotTools(client) {
864
1184
  {
865
1185
  name: "spot_ping",
866
1186
  description: "Test connectivity to the Binance Spot REST API.",
867
- inputSchema: import_zod7.z.object({}),
1187
+ inputSchema: import_zod9.z.object({}),
868
1188
  handler: async () => textResult(await m.ping())
869
1189
  },
870
1190
  {
871
1191
  name: "spot_server_time",
872
1192
  description: "Get the current Binance Spot server time in ms since epoch.",
873
- inputSchema: import_zod7.z.object({}),
1193
+ inputSchema: import_zod9.z.object({}),
874
1194
  handler: async () => textResult(await m.serverTime())
875
1195
  },
876
1196
  {
877
1197
  name: "spot_exchange_info",
878
1198
  description: "Get Spot exchange trading rules and symbol metadata (status, base/quote assets, filters, permissions).",
879
- inputSchema: import_zod7.z.object({}),
1199
+ inputSchema: import_zod9.z.object({}),
880
1200
  handler: async () => textResult(await m.exchangeInfo())
881
1201
  },
882
1202
  {
883
1203
  name: "spot_ticker_price",
884
1204
  description: "Get the latest price for a Spot symbol.",
885
- inputSchema: import_zod7.z.object({ symbol: spotSymbol }),
1205
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol }),
886
1206
  handler: async ({ symbol: symbol3 }) => textResult(await m.tickerPrice(normalizeSymbol(symbol3)))
887
1207
  },
888
1208
  {
889
1209
  name: "spot_ticker_24hr",
890
1210
  description: "Get 24-hour rolling price change statistics for a Spot symbol.",
891
- inputSchema: import_zod7.z.object({ symbol: spotSymbol }),
1211
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol }),
892
1212
  handler: async ({ symbol: symbol3 }) => textResult(await m.ticker24hr(normalizeSymbol(symbol3)))
893
1213
  },
894
1214
  {
895
1215
  name: "spot_book_ticker",
896
1216
  description: "Get the best bid/ask (top of book) for a Spot symbol.",
897
- inputSchema: import_zod7.z.object({ symbol: spotSymbol }),
1217
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol }),
898
1218
  handler: async ({ symbol: symbol3 }) => textResult(await m.bookTicker(normalizeSymbol(symbol3)))
899
1219
  },
900
1220
  {
901
1221
  name: "spot_order_book",
902
1222
  description: "Get the Spot order book depth for a symbol (limits 5/10/20/50/100/500/1000/5000).",
903
- inputSchema: import_zod7.z.object({
1223
+ inputSchema: import_zod9.z.object({
904
1224
  symbol: spotSymbol,
905
- limit: import_zod7.z.enum(["5", "10", "20", "50", "100", "500", "1000", "5000"]).default("100")
1225
+ limit: import_zod9.z.enum(["5", "10", "20", "50", "100", "500", "1000", "5000"]).default("100")
906
1226
  }),
907
1227
  handler: async ({ symbol: symbol3, limit: limit4 }) => textResult(await m.depth(normalizeSymbol(symbol3), Number(limit4)))
908
1228
  },
909
1229
  {
910
1230
  name: "spot_recent_trades",
911
1231
  description: "Get the most recent executed trades for a Spot symbol.",
912
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, limit: limit2.default(500) }),
1232
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, limit: limit3.default(500) }),
913
1233
  handler: async ({ symbol: symbol3, limit: limit4 }) => textResult(await m.trades(normalizeSymbol(symbol3), Number(limit4)))
914
1234
  },
915
1235
  {
916
1236
  name: "spot_historical_trades",
917
1237
  description: "Get older Spot trades for a symbol by fromId.",
918
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, limit: limit2.default(500), fromId: import_zod7.z.number().int().positive().optional() }),
1238
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, limit: limit3.default(500), fromId: import_zod9.z.number().int().positive().optional() }),
919
1239
  handler: async ({ symbol: symbol3, limit: limit4, fromId }) => textResult(await m.historicalTrades(normalizeSymbol(symbol3), { limit: Number(limit4), fromId }))
920
1240
  },
921
1241
  {
922
1242
  name: "spot_agg_trades",
923
1243
  description: "Get compressed/aggregate Spot trades for a symbol within an optional time window.",
924
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, limit: limit2.default(500), startTime: startTime3, endTime: endTime3 }),
1244
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, limit: limit3.default(500), startTime: startTime4, endTime: endTime4 }),
925
1245
  handler: async ({ symbol: symbol3, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await m.aggTrades(normalizeSymbol(symbol3), { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
926
1246
  },
927
1247
  {
928
1248
  name: "spot_klines",
929
1249
  description: "Get Spot candlesticks (OHLCV). Intervals 1m\u20261M; max 1000 per request.",
930
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, interval: KlineIntervalSchema, limit: limit2.default(500), startTime: startTime3, endTime: endTime3 }),
1250
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, interval: KlineIntervalSchema, limit: limit3.default(500), startTime: startTime4, endTime: endTime4 }),
931
1251
  handler: async ({ symbol: symbol3, interval, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await m.klines(normalizeSymbol(symbol3), interval, { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
932
1252
  },
933
1253
  {
934
1254
  name: "spot_ui_klines",
935
1255
  description: "Get Spot candlesticks via the optimized uiKlines endpoint (same shape as spot_klines).",
936
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, interval: KlineIntervalSchema, limit: limit2.default(500), startTime: startTime3, endTime: endTime3 }),
1256
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, interval: KlineIntervalSchema, limit: limit3.default(500), startTime: startTime4, endTime: endTime4 }),
937
1257
  handler: async ({ symbol: symbol3, interval, limit: limit4, startTime: startTime5, endTime: endTime5 }) => textResult(await m.uiKlines(normalizeSymbol(symbol3), interval, { limit: Number(limit4), startTime: startTime5, endTime: endTime5 }))
938
1258
  },
939
1259
  {
940
1260
  name: "spot_avg_price",
941
1261
  description: "Get the current average price (5-minute rolling average) for a Spot symbol.",
942
- inputSchema: import_zod7.z.object({ symbol: spotSymbol }),
1262
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol }),
943
1263
  handler: async ({ symbol: symbol3 }) => textResult(await m.avgPrice(normalizeSymbol(symbol3)))
944
1264
  },
945
1265
  {
946
1266
  name: "spot_rolling_window_ticker",
947
1267
  description: "Get rolling-window price change statistics (1d/7d/30d). Omit symbol for all symbols.",
948
- inputSchema: import_zod7.z.object({
949
- symbol: optionalSymbol2,
950
- windowSize: import_zod7.z.enum(["1d", "7d", "30d"]).optional()
1268
+ inputSchema: import_zod9.z.object({
1269
+ symbol: optionalSymbol3,
1270
+ windowSize: import_zod9.z.enum(["1d", "7d", "30d"]).optional()
951
1271
  }),
952
1272
  handler: async ({ symbol: symbol3, windowSize }) => textResult(await m.rollingWindowTicker(symbol3 ? normalizeSymbol(symbol3) : void 0, windowSize))
953
1273
  },
954
1274
  {
955
1275
  name: "spot_trading_day_ticker",
956
1276
  description: "Get the Spot trading-day ticker (open/close/high/low/volume by UTC day). Omit symbol for all symbols.",
957
- inputSchema: import_zod7.z.object({ symbol: optionalSymbol2, timeZone: import_zod7.z.string().optional(), type: import_zod7.z.enum(["FULL", "MINI"]).optional() }),
1277
+ inputSchema: import_zod9.z.object({ symbol: optionalSymbol3, timeZone: import_zod9.z.string().optional(), type: import_zod9.z.enum(["FULL", "MINI"]).optional() }),
958
1278
  handler: async ({ symbol: symbol3, timeZone, type }) => textResult(await m.tradingDayTicker(symbol3 ? normalizeSymbol(symbol3) : void 0, { timeZone, type }))
959
1279
  },
960
1280
  // ---- Account (signed) ----
961
1281
  {
962
1282
  name: "spot_account",
963
1283
  description: "Get the Spot account: balances (free/locked), commissions, permissions (signed).",
964
- inputSchema: import_zod7.z.object({}),
1284
+ inputSchema: import_zod9.z.object({}),
965
1285
  handler: async () => textResult(await a.account())
966
1286
  },
967
1287
  {
968
1288
  name: "spot_my_trades",
969
1289
  description: "Get the Spot account trade list (filled trades) for a symbol with optional time range (signed).",
970
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, orderId: import_zod7.z.number().int().positive().optional(), startTime: startTime3, endTime: endTime3, fromId: import_zod7.z.number().int().positive().optional(), limit: limit2.default(500) }),
1290
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, orderId: import_zod9.z.number().int().positive().optional(), startTime: startTime4, endTime: endTime4, fromId: import_zod9.z.number().int().positive().optional(), limit: limit3.default(500) }),
971
1291
  handler: async ({ symbol: symbol3, orderId, startTime: startTime5, endTime: endTime5, fromId, limit: limit4 }) => textResult(await a.myTrades(normalizeSymbol(symbol3), { orderId, startTime: startTime5, endTime: endTime5, fromId, limit: Number(limit4) }))
972
1292
  },
973
1293
  {
974
1294
  name: "spot_my_prevented_matches",
975
1295
  description: "Get Spot orders that were expired by the self-trade-prevention (STP) mechanism (signed).",
976
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, preventedMatchId: import_zod7.z.number().int().positive().optional(), orderId: import_zod7.z.number().int().positive().optional(), limit: limit2.default(500) }),
1296
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, preventedMatchId: import_zod9.z.number().int().positive().optional(), orderId: import_zod9.z.number().int().positive().optional(), limit: limit3.default(500) }),
977
1297
  handler: async ({ symbol: symbol3, preventedMatchId, orderId, limit: limit4 }) => textResult(await a.myPreventedMatches(normalizeSymbol(symbol3), { preventedMatchId, orderId, limit: Number(limit4) }))
978
1298
  },
979
1299
  {
980
1300
  name: "spot_account_commission",
981
1301
  description: "Get the Spot account commission rates for a symbol (signed).",
982
- inputSchema: import_zod7.z.object({ symbol: spotSymbol }),
1302
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol }),
983
1303
  handler: async ({ symbol: symbol3 }) => textResult(await a.accountCommission(normalizeSymbol(symbol3)))
984
1304
  },
985
1305
  {
986
1306
  name: "spot_rate_limit_order",
987
1307
  description: "Query the current Spot order rate limit usage (signed).",
988
- inputSchema: import_zod7.z.object({}),
1308
+ inputSchema: import_zod9.z.object({}),
989
1309
  handler: async () => textResult(await a.rateLimitOrder())
990
1310
  },
991
1311
  // ---- Trading (signed) ----
@@ -1004,109 +1324,109 @@ function spotTools(client) {
1004
1324
  {
1005
1325
  name: "spot_get_order",
1006
1326
  description: "Query a specific Spot order by orderId or client order id. Signed.",
1007
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, orderId: import_zod7.z.number().int().positive().optional(), origClientOrderId: import_zod7.z.string().optional() }),
1327
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, orderId: import_zod9.z.number().int().positive().optional(), origClientOrderId: import_zod9.z.string().optional() }),
1008
1328
  handler: async ({ symbol: symbol3, orderId, origClientOrderId }) => textResult(await t.getOrder(normalizeSymbol(symbol3), { orderId, origClientOrderId }))
1009
1329
  },
1010
1330
  {
1011
1331
  name: "spot_cancel_order",
1012
1332
  description: "Cancel a specific open Spot order by orderId or client order id. Signed.",
1013
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, orderId: import_zod7.z.number().int().positive().optional(), origClientOrderId: import_zod7.z.string().optional(), newClientOrderId: import_zod7.z.string().optional() }),
1333
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, orderId: import_zod9.z.number().int().positive().optional(), origClientOrderId: import_zod9.z.string().optional(), newClientOrderId: import_zod9.z.string().optional() }),
1014
1334
  handler: async ({ symbol: symbol3, orderId, origClientOrderId, newClientOrderId }) => textResult(await t.cancelOrder(normalizeSymbol(symbol3), { orderId, origClientOrderId, newClientOrderId }))
1015
1335
  },
1016
1336
  {
1017
1337
  name: "spot_open_orders",
1018
1338
  description: "Get all current open Spot orders, for one symbol or all symbols. Signed.",
1019
- inputSchema: import_zod7.z.object({ symbol: optionalSymbol2 }),
1339
+ inputSchema: import_zod9.z.object({ symbol: optionalSymbol3 }),
1020
1340
  handler: async ({ symbol: symbol3 }) => textResult(await t.getOpenOrders(symbol3 ? normalizeSymbol(symbol3) : void 0))
1021
1341
  },
1022
1342
  {
1023
1343
  name: "spot_all_orders",
1024
1344
  description: "Get historical Spot orders for a symbol with optional time range. Signed.",
1025
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, orderId: import_zod7.z.number().int().positive().optional(), startTime: startTime3, endTime: endTime3, limit: limit2 }),
1345
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, orderId: import_zod9.z.number().int().positive().optional(), startTime: startTime4, endTime: endTime4, limit: limit3 }),
1026
1346
  handler: async ({ symbol: symbol3, orderId, startTime: startTime5, endTime: endTime5, limit: limit4 }) => textResult(await t.getAllOrders(normalizeSymbol(symbol3), { orderId, startTime: startTime5, endTime: endTime5, limit: limit4 }))
1027
1347
  },
1028
1348
  {
1029
1349
  name: "spot_cancel_open_orders",
1030
1350
  description: "Cancel all open Spot orders for a symbol. Signed.",
1031
- inputSchema: import_zod7.z.object({ symbol: spotSymbol }),
1351
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol }),
1032
1352
  handler: async ({ symbol: symbol3 }) => textResult(await t.cancelOpenOrders(normalizeSymbol(symbol3)))
1033
1353
  },
1034
1354
  {
1035
1355
  name: "spot_cancel_replace_order",
1036
1356
  description: "Cancel an existing Spot order and place a new one on the same symbol (cancel-replace). Signed.",
1037
- inputSchema: import_zod7.z.object({
1357
+ inputSchema: import_zod9.z.object({
1038
1358
  symbol: spotSymbol,
1039
- side,
1040
- type: import_zod7.z.enum(["LIMIT", "MARKET", "STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT"]),
1041
- cancelReplaceMode: import_zod7.z.enum(["STOP_ON_FAILURE", "ALLOW_FAILURE"]).default("STOP_ON_FAILURE"),
1042
- cancelOrderId: import_zod7.z.number().int().positive().optional(),
1043
- cancelOrigClientOrderId: import_zod7.z.string().optional(),
1044
- cancelNewClientOrderId: import_zod7.z.string().optional(),
1045
- quantity: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).optional(),
1046
- price: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).optional(),
1047
- timeInForce: import_zod7.z.enum(["GTC", "IOC", "FOK"]).optional(),
1048
- newClientOrderId: import_zod7.z.string().optional()
1359
+ side: side2,
1360
+ type: import_zod9.z.enum(["LIMIT", "MARKET", "STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT"]),
1361
+ cancelReplaceMode: import_zod9.z.enum(["STOP_ON_FAILURE", "ALLOW_FAILURE"]).default("STOP_ON_FAILURE"),
1362
+ cancelOrderId: import_zod9.z.number().int().positive().optional(),
1363
+ cancelOrigClientOrderId: import_zod9.z.string().optional(),
1364
+ cancelNewClientOrderId: import_zod9.z.string().optional(),
1365
+ quantity: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).optional(),
1366
+ price: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).optional(),
1367
+ timeInForce: import_zod9.z.enum(["GTC", "IOC", "FOK"]).optional(),
1368
+ newClientOrderId: import_zod9.z.string().optional()
1049
1369
  }),
1050
1370
  handler: async (args) => textResult(await t.cancelReplaceOrder({ ...args, symbol: normalizeSymbol(args.symbol) }))
1051
1371
  },
1052
1372
  {
1053
1373
  name: "spot_new_oco_order",
1054
1374
  description: "Place a new Spot OCO (one-cancels-other) order: a stop-loss limit + a limit-maker take-profit. Signed.",
1055
- inputSchema: import_zod7.z.object({
1375
+ inputSchema: import_zod9.z.object({
1056
1376
  symbol: spotSymbol,
1057
- side,
1058
- quantity: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).describe("Total base-asset quantity for both legs"),
1059
- price: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).describe("Limit (take-profit) price"),
1060
- stopPrice: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).describe("Stop-loss trigger price"),
1061
- stopLimitPrice: import_zod7.z.union([import_zod7.z.string(), import_zod7.z.number()]).optional().describe("Stop-loss limit price (defaults to stopPrice)"),
1062
- stopLimitTimeInForce: import_zod7.z.enum(["GTC", "IOC", "FOK"]).optional(),
1063
- listClientOrderId: import_zod7.z.string().optional(),
1064
- limitClientOrderId: import_zod7.z.string().optional(),
1065
- stopClientOrderId: import_zod7.z.string().optional()
1377
+ side: side2,
1378
+ quantity: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).describe("Total base-asset quantity for both legs"),
1379
+ price: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).describe("Limit (take-profit) price"),
1380
+ stopPrice: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).describe("Stop-loss trigger price"),
1381
+ stopLimitPrice: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).optional().describe("Stop-loss limit price (defaults to stopPrice)"),
1382
+ stopLimitTimeInForce: import_zod9.z.enum(["GTC", "IOC", "FOK"]).optional(),
1383
+ listClientOrderId: import_zod9.z.string().optional(),
1384
+ limitClientOrderId: import_zod9.z.string().optional(),
1385
+ stopClientOrderId: import_zod9.z.string().optional()
1066
1386
  }),
1067
1387
  handler: async (args) => textResult(await t.createOCOOrder({ ...args, symbol: normalizeSymbol(args.symbol) }))
1068
1388
  },
1069
1389
  {
1070
1390
  name: "spot_cancel_oco_order",
1071
1391
  description: "Cancel an entire Spot OCO order list by orderListId or listClientOrderId. Signed.",
1072
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, orderListId: import_zod7.z.number().int().positive().optional(), listClientOrderId: import_zod7.z.string().optional(), newClientOrderId: import_zod7.z.string().optional() }),
1392
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, orderListId: import_zod9.z.number().int().positive().optional(), listClientOrderId: import_zod9.z.string().optional(), newClientOrderId: import_zod9.z.string().optional() }),
1073
1393
  handler: async ({ symbol: symbol3, orderListId, listClientOrderId, newClientOrderId }) => textResult(await t.cancelOCOOrder(normalizeSymbol(symbol3), { orderListId, listClientOrderId, newClientOrderId }))
1074
1394
  },
1075
1395
  {
1076
1396
  name: "spot_get_oco_order",
1077
1397
  description: "Query a Spot OCO order list by orderListId or listClientOrderId. Signed.",
1078
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, orderListId: import_zod7.z.number().int().positive().optional(), origClientOrderId: import_zod7.z.string().optional() }),
1398
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, orderListId: import_zod9.z.number().int().positive().optional(), origClientOrderId: import_zod9.z.string().optional() }),
1079
1399
  handler: async ({ symbol: symbol3, orderListId, origClientOrderId }) => textResult(await t.getOCOOrder(normalizeSymbol(symbol3), { orderListId, origClientOrderId }))
1080
1400
  },
1081
1401
  {
1082
1402
  name: "spot_open_oco_orders",
1083
1403
  description: "Get all current open Spot OCO order lists. Signed.",
1084
- inputSchema: import_zod7.z.object({}),
1404
+ inputSchema: import_zod9.z.object({}),
1085
1405
  handler: async () => textResult(await t.getOpenOCOOrders())
1086
1406
  },
1087
1407
  {
1088
1408
  name: "spot_all_oco_orders",
1089
1409
  description: "Get historical Spot OCO order lists for a symbol with optional time range. Signed.",
1090
- inputSchema: import_zod7.z.object({ symbol: spotSymbol, fromId: import_zod7.z.number().int().positive().optional(), startTime: startTime3, endTime: endTime3, limit: limit2 }),
1410
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol, fromId: import_zod9.z.number().int().positive().optional(), startTime: startTime4, endTime: endTime4, limit: limit3 }),
1091
1411
  handler: async ({ symbol: symbol3, fromId, startTime: startTime5, endTime: endTime5, limit: limit4 }) => textResult(await t.getAllOCOOrders(normalizeSymbol(symbol3), { fromId, startTime: startTime5, endTime: endTime5, limit: limit4 }))
1092
1412
  },
1093
1413
  {
1094
1414
  name: "spot_cancel_open_oco_orders",
1095
1415
  description: "Cancel all open Spot OCO order lists for a symbol. Signed.",
1096
- inputSchema: import_zod7.z.object({ symbol: spotSymbol }),
1416
+ inputSchema: import_zod9.z.object({ symbol: spotSymbol }),
1097
1417
  handler: async ({ symbol: symbol3 }) => textResult(await t.cancelOpenOCOOrders(normalizeSymbol(symbol3)))
1098
1418
  },
1099
1419
  // ---- User data stream (signed) ----
1100
1420
  {
1101
1421
  name: "spot_ws_start_user_stream",
1102
1422
  description: "Start the Spot user data stream: creates a listenKey, connects the private WebSocket, and begins keep-alive. Emits executionReport, outboundAccountPosition, balanceUpdate, listStatus.",
1103
- inputSchema: import_zod7.z.object({}),
1423
+ inputSchema: import_zod9.z.object({}),
1104
1424
  handler: async () => textResult({ listenKey: await client.startSpotUserStream() })
1105
1425
  },
1106
1426
  {
1107
1427
  name: "spot_ws_stop_user_stream",
1108
1428
  description: "Stop the Spot user data stream: closes the private WebSocket and invalidates the listenKey.",
1109
- inputSchema: import_zod7.z.object({}),
1429
+ inputSchema: import_zod9.z.object({}),
1110
1430
  handler: async () => {
1111
1431
  client.closeSpotUserStream();
1112
1432
  return textResult({ stopped: true });
@@ -1116,239 +1436,8 @@ function spotTools(client) {
1116
1436
  return tools;
1117
1437
  }
1118
1438
 
1119
- // src/tools/trading.tools.ts
1120
- var import_zod8 = require("zod");
1121
- var symbol2 = import_zod8.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT");
1122
- var optionalSymbol3 = import_zod8.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT").optional();
1123
- var limit3 = import_zod8.z.number().int().positive().max(1e3).default(100);
1124
- var startTime4 = import_zod8.z.number().int().positive().optional();
1125
- var endTime4 = import_zod8.z.number().int().positive().optional();
1126
- var side2 = import_zod8.z.enum(["BUY", "SELL"]);
1127
- var positionSide = import_zod8.z.enum(["BOTH", "LONG", "SHORT"]).optional();
1128
- var orderParamsSchema = import_zod8.z.object({
1129
- symbol: symbol2,
1130
- side: side2,
1131
- type: import_zod8.z.enum(["LIMIT", "MARKET", "STOP", "STOP_MARKET", "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET"]),
1132
- quantity: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]).describe("Order quantity in base asset"),
1133
- price: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]).optional().describe("Required for LIMIT and STOP/TAKE_PROFIT (limit-triggered) types"),
1134
- timeInForce: import_zod8.z.enum(["GTC", "IOC", "FOK", "GTX"]).optional(),
1135
- stopPrice: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]).optional().describe("Trigger price for STOP/STOP_MARKET/TAKE_PROFIT/TAKE_PROFIT_MARKET"),
1136
- reduceOnly: import_zod8.z.boolean().optional().describe("true = only reduces the position, never opens"),
1137
- positionSide,
1138
- newClientOrderId: import_zod8.z.string().optional(),
1139
- closePosition: import_zod8.z.boolean().optional().describe("Close the full position on trigger (mutually exclusive with quantity)"),
1140
- newOrderRespType: import_zod8.z.enum(["ACK", "RESULT"]).optional(),
1141
- priceProtect: import_zod8.z.boolean().optional(),
1142
- workingType: import_zod8.z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional().describe("Trigger price basis; default CONTRACT_PRICE"),
1143
- callbackRate: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]).optional().describe("Percent callback for TRAILING_STOP_MARKET, e.g. 0.5"),
1144
- activationPrice: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]).optional().describe("Activation price for TRAILING_STOP_MARKET"),
1145
- selfTradePreventionMode: import_zod8.z.enum(["NONE", "EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH"]).optional(),
1146
- goodTillDate: import_zod8.z.number().int().optional().describe("Timestamp when a GTD order expires")
1147
- });
1148
- function tradingTools(client) {
1149
- const t = client.futures.trading;
1150
- return [
1151
- {
1152
- name: "futures_new_order",
1153
- description: "Place a new futures order. Types: LIMIT, MARKET, STOP, STOP_MARKET, TAKE_PROFIT, TAKE_PROFIT_MARKET, TRAILING_STOP_MARKET. Use STOP_MARKET as the take-profit/stop-loss trigger and LIMIT for the actual fill. Signed.",
1154
- inputSchema: orderParamsSchema,
1155
- handler: async (args) => textResult(await t.createOrder({ ...args, symbol: normalizeSymbol(args.symbol) }))
1156
- },
1157
- {
1158
- name: "futures_test_order",
1159
- description: "Validate a new order without submitting it. Returns 200 on success; use to validate fields and margin before real orders. Signed.",
1160
- inputSchema: orderParamsSchema,
1161
- handler: async (args) => textResult(await t.createTestOrder({ ...args, symbol: normalizeSymbol(args.symbol) }))
1162
- },
1163
- {
1164
- name: "futures_get_order",
1165
- description: "Query a specific order by orderId or client order id. Signed.",
1166
- inputSchema: import_zod8.z.object({ symbol: symbol2, orderId: import_zod8.z.number().int().positive().optional(), origClientOrderId: import_zod8.z.string().optional() }),
1167
- handler: async ({ symbol: symbol3, orderId, origClientOrderId }) => textResult(await t.getOrder(normalizeSymbol(symbol3), { orderId, origClientOrderId }))
1168
- },
1169
- {
1170
- name: "futures_cancel_order",
1171
- description: "Cancel a specific open order by orderId or client order id. Signed.",
1172
- inputSchema: import_zod8.z.object({ symbol: symbol2, orderId: import_zod8.z.number().int().positive().optional(), origClientOrderId: import_zod8.z.string().optional() }),
1173
- handler: async ({ symbol: symbol3, orderId, origClientOrderId }) => textResult(await t.cancelOrder(normalizeSymbol(symbol3), { orderId, origClientOrderId }))
1174
- },
1175
- {
1176
- name: "futures_get_open_order",
1177
- description: "Query a current open order (must exist in the open order book). Signed.",
1178
- inputSchema: import_zod8.z.object({ symbol: symbol2, orderId: import_zod8.z.number().int().positive().optional(), origClientOrderId: import_zod8.z.string().optional() }),
1179
- handler: async ({ symbol: symbol3, orderId, origClientOrderId }) => textResult(await t.getCurrentOrder(normalizeSymbol(symbol3), { orderId, origClientOrderId }))
1180
- },
1181
- {
1182
- name: "futures_open_orders",
1183
- description: "Get all current open orders, for one symbol or all symbols. Signed.",
1184
- inputSchema: import_zod8.z.object({ symbol: optionalSymbol3 }),
1185
- handler: async ({ symbol: symbol3 }) => textResult(await t.getOpenOrders(symbol3 ? normalizeSymbol(symbol3) : void 0))
1186
- },
1187
- {
1188
- name: "futures_all_orders",
1189
- description: "Get historical orders for a symbol with optional time range (last 7 days by default). Signed.",
1190
- inputSchema: import_zod8.z.object({ symbol: symbol2, orderId: import_zod8.z.number().int().positive().optional(), startTime: startTime4, endTime: endTime4, limit: limit3 }),
1191
- handler: async ({ symbol: symbol3, orderId, startTime: startTime5, endTime: endTime5, limit: limit4 }) => textResult(await t.getAllOrders(normalizeSymbol(symbol3), { orderId, startTime: startTime5, endTime: endTime5, limit: limit4 }))
1192
- },
1193
- {
1194
- name: "futures_cancel_all_orders",
1195
- description: "Cancel all open orders for a symbol. Signed.",
1196
- inputSchema: import_zod8.z.object({ symbol: symbol2 }),
1197
- handler: async ({ symbol: symbol3 }) => textResult(await t.cancelAllOpenOrders(normalizeSymbol(symbol3)))
1198
- },
1199
- {
1200
- name: "futures_modify_order",
1201
- description: "Modify an open order (price/quantity/stopPrice). Cannot modify when position side is BOTH and closePosition is true. Signed.",
1202
- inputSchema: import_zod8.z.object({
1203
- symbol: symbol2,
1204
- side: side2,
1205
- quantity: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]),
1206
- price: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]).optional(),
1207
- orderId: import_zod8.z.number().int().positive().optional(),
1208
- origClientOrderId: import_zod8.z.string().optional(),
1209
- stopPrice: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]).optional(),
1210
- timeInForce: import_zod8.z.enum(["GTC", "IOC", "FOK", "GTX"]).optional(),
1211
- positionSide,
1212
- newClientOrderId: import_zod8.z.string().optional()
1213
- }),
1214
- handler: async (args) => textResult(await t.modifyOrder({ ...args, symbol: normalizeSymbol(args.symbol) }))
1215
- },
1216
- {
1217
- name: "futures_order_modify_history",
1218
- description: "Get order modification history for a symbol. Signed.",
1219
- inputSchema: import_zod8.z.object({ symbol: symbol2, startTime: startTime4, endTime: endTime4, limit: limit3 }),
1220
- handler: async ({ symbol: symbol3, startTime: startTime5, endTime: endTime5, limit: limit4 }) => textResult(await t.getOrderModifyHistory(normalizeSymbol(symbol3), { startTime: startTime5, endTime: endTime5, limit: limit4 }))
1221
- },
1222
- {
1223
- name: "futures_batch_orders",
1224
- description: "Place up to 5 orders in one request (array of order objects, max 30 per minute per symbol). Signed.",
1225
- inputSchema: import_zod8.z.object({ orders: import_zod8.z.array(orderParamsSchema).min(1).max(5) }),
1226
- handler: async (args) => {
1227
- const mapped = args.orders.map((o) => ({ ...o, symbol: normalizeSymbol(o.symbol) }));
1228
- return textResult(await t.createBatchOrders(mapped));
1229
- }
1230
- },
1231
- {
1232
- name: "futures_cancel_batch_orders",
1233
- description: "Cancel multiple orders at once (up to 10 by orderId list or client order id list). Signed.",
1234
- inputSchema: import_zod8.z.object({
1235
- symbol: symbol2,
1236
- orderIdList: import_zod8.z.array(import_zod8.z.number().int().positive()).max(10).optional(),
1237
- origClientOrderIdList: import_zod8.z.array(import_zod8.z.string()).max(10).optional()
1238
- }),
1239
- handler: async ({ symbol: symbol3, orderIdList, origClientOrderIdList }) => textResult(await t.cancelBatchOrders(normalizeSymbol(symbol3), { orderIdList, origClientOrderIdList }))
1240
- },
1241
- {
1242
- name: "futures_set_leverage",
1243
- description: "Change initial leverage for a symbol (1-125, within bracket). Signed.",
1244
- inputSchema: import_zod8.z.object({ symbol: symbol2, leverage: import_zod8.z.number().int().min(1).max(125) }),
1245
- handler: async ({ symbol: symbol3, leverage }) => textResult(await t.setLeverage(normalizeSymbol(symbol3), leverage))
1246
- },
1247
- {
1248
- name: "futures_set_margin_type",
1249
- description: "Change margin type for a symbol: isolated or cross. Only allowed when no open position for the symbol. Signed.",
1250
- inputSchema: import_zod8.z.object({ symbol: symbol2, marginType: import_zod8.z.enum(["isolated", "cross"]) }),
1251
- handler: async ({ symbol: symbol3, marginType }) => textResult(await t.setMarginType(normalizeSymbol(symbol3), marginType))
1252
- },
1253
- {
1254
- name: "futures_modify_position_margin",
1255
- description: "Add or reduce isolated position margin. marginType: 1 = add margin, 2 = reduce margin. Signed.",
1256
- inputSchema: import_zod8.z.object({ symbol: symbol2, amount: import_zod8.z.number().positive(), marginType: import_zod8.z.enum(["1", "2"]).describe("1 = add margin, 2 = reduce margin") }),
1257
- handler: async ({ symbol: symbol3, amount, marginType }) => textResult(await t.modifyPositionMargin(normalizeSymbol(symbol3), amount, Number(marginType)))
1258
- },
1259
- {
1260
- name: "futures_countdown_cancel_all",
1261
- description: "Auto-cancel all open orders for a symbol after countdownTime ms (0 = cancel the countdown). Emergency circuit breaker. Signed.",
1262
- inputSchema: import_zod8.z.object({ symbol: symbol2, countdownTime: import_zod8.z.number().int().min(100).max(6e4) }),
1263
- handler: async ({ symbol: symbol3, countdownTime }) => textResult(await t.setCountdownCancelAll(normalizeSymbol(symbol3), countdownTime))
1264
- },
1265
- {
1266
- name: "futures_new_algo_order",
1267
- description: "Place a conditional algo order (CONDITIONAL or VP). CONDITIONAL supports STOP_MARKET/TAKE_PROFIT_MARKET types with triggerPrice; VP is a volume-participation order with urgency and quantity. Signed.",
1268
- inputSchema: import_zod8.z.object({
1269
- algoType: import_zod8.z.enum(["CONDITIONAL", "VP"]),
1270
- symbol: symbol2,
1271
- side: side2,
1272
- positionSide,
1273
- type: import_zod8.z.enum(["STOP_MARKET", "TAKE_PROFIT_MARKET", "LIMIT"]).describe("For CONDITIONAL: STOP_MARKET/TAKE_PROFIT_MARKET. For VP: LIMIT"),
1274
- quantity: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]),
1275
- triggerPrice: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]).optional().describe("Required for CONDITIONAL"),
1276
- price: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number()]).optional(),
1277
- timeInForce: import_zod8.z.enum(["GTC", "IOC", "FOK", "GTX"]).optional(),
1278
- workingType: import_zod8.z.enum(["MARK_PRICE", "CONTRACT_PRICE"]).optional(),
1279
- priceProtect: import_zod8.z.boolean().optional(),
1280
- reduceOnly: import_zod8.z.boolean().optional(),
1281
- closePosition: import_zod8.z.boolean().optional(),
1282
- urgency: import_zod8.z.enum(["LOW", "MEDIUM", "HIGH"]).optional().describe("Required for VP"),
1283
- clientAlgoId: import_zod8.z.string().optional()
1284
- }),
1285
- handler: async (args) => textResult(await t.createAlgoOrder({ ...args, symbol: normalizeSymbol(args.symbol) }))
1286
- },
1287
- {
1288
- name: "futures_cancel_algo_order",
1289
- description: "Cancel an open algo order by algoId or clientAlgoId. Signed.",
1290
- inputSchema: import_zod8.z.object({ symbol: symbol2, algoId: import_zod8.z.number().int().positive().optional(), clientAlgoId: import_zod8.z.string().optional() }),
1291
- handler: async ({ symbol: symbol3, algoId, clientAlgoId }) => textResult(await t.cancelAlgoOrder(normalizeSymbol(symbol3), { algoId, clientAlgoId }))
1292
- },
1293
- {
1294
- name: "futures_cancel_all_algo_orders",
1295
- description: "Cancel all open algo orders for a symbol. Signed.",
1296
- inputSchema: import_zod8.z.object({ symbol: symbol2 }),
1297
- handler: async ({ symbol: symbol3 }) => textResult(await t.cancelAllOpenAlgoOrders(normalizeSymbol(symbol3)))
1298
- },
1299
- {
1300
- name: "futures_get_algo_order",
1301
- description: "Query an algo order by algoId or clientAlgoId. Signed.",
1302
- inputSchema: import_zod8.z.object({ symbol: symbol2, algoId: import_zod8.z.number().int().positive().optional(), clientAlgoId: import_zod8.z.string().optional() }),
1303
- handler: async ({ symbol: symbol3, algoId, clientAlgoId }) => textResult(await t.getAlgoOrder(normalizeSymbol(symbol3), { algoId, clientAlgoId }))
1304
- },
1305
- {
1306
- name: "futures_open_algo_orders",
1307
- description: "Get all current open algo orders, optionally filtered by symbol. Signed.",
1308
- inputSchema: import_zod8.z.object({ symbol: optionalSymbol3 }),
1309
- handler: async ({ symbol: symbol3 }) => textResult(await t.getOpenAlgoOrders(symbol3 ? normalizeSymbol(symbol3) : void 0))
1310
- },
1311
- {
1312
- name: "futures_all_algo_orders",
1313
- description: "Get historical algo orders for a symbol with optional time range. Signed.",
1314
- inputSchema: import_zod8.z.object({ symbol: symbol2, startTime: startTime4, endTime: endTime4, limit: limit3 }),
1315
- handler: async ({ symbol: symbol3, startTime: startTime5, endTime: endTime5, limit: limit4 }) => textResult(await t.getAllAlgoOrders(normalizeSymbol(symbol3), { startTime: startTime5, endTime: endTime5, limit: limit4 }))
1316
- },
1317
- {
1318
- name: "futures_convert_exchange_info",
1319
- description: "List asset pairs eligible for futures Convert, optionally filtered by fromAsset/toAsset.",
1320
- inputSchema: import_zod8.z.object({ fromAsset: import_zod8.z.string().optional(), toAsset: import_zod8.z.string().optional() }),
1321
- handler: async ({ fromAsset, toAsset }) => textResult(await t.convertExchangeInfo({ fromAsset, toAsset }))
1322
- },
1323
- {
1324
- name: "futures_convert_get_quote",
1325
- description: "Request a Convert quote between two assets (quote expires quickly; accept with futures_convert_accept_quote). Signed.",
1326
- inputSchema: import_zod8.z.object({
1327
- fromAsset: import_zod8.z.string().min(1),
1328
- toAsset: import_zod8.z.string().min(1),
1329
- fromAmount: import_zod8.z.number().positive().optional(),
1330
- toAmount: import_zod8.z.number().positive().optional(),
1331
- validTime: import_zod8.z.enum(["10s", "30s", "1m", "2m"]).optional()
1332
- }),
1333
- handler: async (args) => textResult(await t.convertGetQuote(args))
1334
- },
1335
- {
1336
- name: "futures_convert_accept_quote",
1337
- description: "Accept a previously requested Convert quote by quoteId. Signed.",
1338
- inputSchema: import_zod8.z.object({ quoteId: import_zod8.z.string().min(1) }),
1339
- handler: async ({ quoteId }) => textResult(await t.convertAcceptQuote(quoteId))
1340
- },
1341
- {
1342
- name: "futures_convert_order_status",
1343
- description: "Query the status of a Convert order by orderId or quoteId. Signed.",
1344
- inputSchema: import_zod8.z.object({ orderId: import_zod8.z.string().optional(), quoteId: import_zod8.z.string().optional() }),
1345
- handler: async ({ orderId, quoteId }) => textResult(await t.convertOrderStatus({ orderId, quoteId }))
1346
- }
1347
- ];
1348
- }
1349
-
1350
1439
  // src/tools/ws.tools.ts
1351
- var import_zod9 = require("zod");
1440
+ var import_zod10 = require("zod");
1352
1441
  var buffers = /* @__PURE__ */ new Map();
1353
1442
  var MAX_BUFFER = 500;
1354
1443
  function bufferFor(client) {
@@ -1375,8 +1464,8 @@ function wsTools(client) {
1375
1464
  {
1376
1465
  name: "futures_ws_subscribe",
1377
1466
  description: "Subscribe to real-time market data streams. Topic format: <symbol>@<stream>, e.g. btcusdt@aggTrade, btcusdt@kline_1m, btcusdt@depth20, btcusdt@markPrice@1s, btcusdt@bookTicker, btcusdt@ticker, btcusdt@miniTicker, btcusdt@forceOrder, or all-market topics !ticker@arr, !bookTicker, !markPrice@arr, !forceOrder@arr, !miniTicker@arr. Multiple topics can be passed at once.",
1378
- inputSchema: import_zod9.z.object({
1379
- topics: import_zod9.z.array(import_zod9.z.string().min(1)).min(1).describe('Stream topics, e.g. ["btcusdt@aggTrade", "btcusdt@kline_1m"]')
1467
+ inputSchema: import_zod10.z.object({
1468
+ topics: import_zod10.z.array(import_zod10.z.string().min(1)).min(1).describe('Stream topics, e.g. ["btcusdt@aggTrade", "btcusdt@kline_1m"]')
1380
1469
  }),
1381
1470
  handler: async ({ topics }) => {
1382
1471
  const normalized = topics.map((t) => t.trim().toLowerCase());
@@ -1388,7 +1477,7 @@ function wsTools(client) {
1388
1477
  {
1389
1478
  name: "futures_ws_unsubscribe",
1390
1479
  description: "Unsubscribe from previously subscribed market data streams.",
1391
- inputSchema: import_zod9.z.object({ topics: import_zod9.z.array(import_zod9.z.string().min(1)).min(1) }),
1480
+ inputSchema: import_zod10.z.object({ topics: import_zod10.z.array(import_zod10.z.string().min(1)).min(1) }),
1392
1481
  handler: async ({ topics }) => {
1393
1482
  const normalized = topics.map((t) => t.trim().toLowerCase());
1394
1483
  client.futures.ws.unsubscribe(normalized);
@@ -1399,19 +1488,19 @@ function wsTools(client) {
1399
1488
  {
1400
1489
  name: "futures_ws_subscriptions",
1401
1490
  description: "List the currently subscribed WebSocket market streams for this client.",
1402
- inputSchema: import_zod9.z.object({}),
1491
+ inputSchema: import_zod10.z.object({}),
1403
1492
  handler: async () => textResult({ active: [...buffer.subscriptions] })
1404
1493
  },
1405
1494
  {
1406
1495
  name: "futures_ws_events",
1407
1496
  description: "Read the buffered real-time payloads received since the last read for the subscribed streams (aggregate trades, klines, depth deltas, mark price, book tickers, tickers, force orders). Payloads are parsed; depth deltas must be applied to a snapshot from futures_order_book.",
1408
- inputSchema: import_zod9.z.object({ limit: import_zod9.z.number().int().min(1).max(200).default(50) }),
1497
+ inputSchema: import_zod10.z.object({ limit: import_zod10.z.number().int().min(1).max(200).default(50) }),
1409
1498
  handler: async ({ limit: limit4 }) => textResult(getBufferedWsEvents(client, limit4))
1410
1499
  },
1411
1500
  {
1412
1501
  name: "futures_ws_clear_events",
1413
1502
  description: "Clear the buffered WebSocket events so the next read only returns new payloads.",
1414
- inputSchema: import_zod9.z.object({}),
1503
+ inputSchema: import_zod10.z.object({}),
1415
1504
  handler: async () => {
1416
1505
  clearBufferedWsEvents(client);
1417
1506
  return textResult({ cleared: true });
@@ -1420,13 +1509,13 @@ function wsTools(client) {
1420
1509
  {
1421
1510
  name: "futures_ws_start_user_stream",
1422
1511
  description: "Start the user data stream: creates a listenKey, connects the private WebSocket, and begins a 30-minute keep-alive. Emits private events (ACCOUNT_UPDATE, ORDER_TRADE_UPDATE, MARGIN_CALL, ACCOUNT_CONFIG_UPDATE, listenKeyExpired) that the application can consume from the client.",
1423
- inputSchema: import_zod9.z.object({}),
1512
+ inputSchema: import_zod10.z.object({}),
1424
1513
  handler: async () => textResult({ listenKey: await client.startUserStream() })
1425
1514
  },
1426
1515
  {
1427
1516
  name: "futures_ws_stop_user_stream",
1428
1517
  description: "Stop the user data stream: closes the private WebSocket and invalidates the listenKey.",
1429
- inputSchema: import_zod9.z.object({}),
1518
+ inputSchema: import_zod10.z.object({}),
1430
1519
  handler: async () => {
1431
1520
  client.closeUserStream();
1432
1521
  return textResult({ stopped: true });
@@ -1435,49 +1524,49 @@ function wsTools(client) {
1435
1524
  {
1436
1525
  name: "futures_ws_api_order_status",
1437
1526
  description: "Query an order via the signed WebSocket API (order.status) \u2014 lower-latency alternative to futures_get_order.",
1438
- inputSchema: import_zod9.z.object({
1439
- symbol: import_zod9.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
1440
- orderId: import_zod9.z.number().int().positive().optional(),
1441
- origClientOrderId: import_zod9.z.string().optional()
1527
+ inputSchema: import_zod10.z.object({
1528
+ symbol: import_zod10.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
1529
+ orderId: import_zod10.z.number().int().positive().optional(),
1530
+ origClientOrderId: import_zod10.z.string().optional()
1442
1531
  }),
1443
1532
  handler: async ({ symbol: symbol3, orderId, origClientOrderId }) => textResult(await client.futures.wsApi.orderStatus({ symbol: normalizeSymbol(symbol3), orderId, origClientOrderId }))
1444
1533
  },
1445
1534
  {
1446
1535
  name: "futures_ws_api_account_status",
1447
1536
  description: "Get account info via the signed WebSocket API (account.status).",
1448
- inputSchema: import_zod9.z.object({}),
1537
+ inputSchema: import_zod10.z.object({}),
1449
1538
  handler: async () => textResult(await client.futures.wsApi.accountStatus())
1450
1539
  },
1451
1540
  {
1452
1541
  name: "futures_ws_api_account_position",
1453
1542
  description: "Get current positions via the signed WebSocket API (account.position).",
1454
- inputSchema: import_zod9.z.object({ symbol: import_zod9.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT").optional() }),
1543
+ inputSchema: import_zod10.z.object({ symbol: import_zod10.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT").optional() }),
1455
1544
  handler: async ({ symbol: symbol3 }) => textResult(await client.futures.wsApi.accountPosition(symbol3 ? { symbol: normalizeSymbol(symbol3) } : {}))
1456
1545
  },
1457
1546
  {
1458
1547
  name: "futures_ws_api_user_data_stream_start",
1459
1548
  description: "Create a listenKey via the signed WebSocket API (userDataStream.start) \u2014 no REST call required.",
1460
- inputSchema: import_zod9.z.object({}),
1549
+ inputSchema: import_zod10.z.object({}),
1461
1550
  handler: async () => textResult(await client.futures.wsApi.userDataStreamStart())
1462
1551
  },
1463
1552
  {
1464
1553
  name: "futures_ws_api_user_data_stream_stop",
1465
1554
  description: "Invalidate a listenKey via the signed WebSocket API (userDataStream.stop).",
1466
- inputSchema: import_zod9.z.object({ listenKey: import_zod9.z.string().min(1) }),
1555
+ inputSchema: import_zod10.z.object({ listenKey: import_zod10.z.string().min(1) }),
1467
1556
  handler: async ({ listenKey }) => textResult(await client.futures.wsApi.userDataStreamStop(listenKey))
1468
1557
  },
1469
1558
  {
1470
1559
  name: "futures_ws_api_ticker_price",
1471
1560
  description: "Get latest price via the unsigned WebSocket API (ticker.price); omit symbol for all symbols.",
1472
- inputSchema: import_zod9.z.object({ symbol: import_zod9.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT").optional() }),
1561
+ inputSchema: import_zod10.z.object({ symbol: import_zod10.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT").optional() }),
1473
1562
  handler: async ({ symbol: symbol3 }) => textResult(await client.futures.wsApi.tickerPrice(symbol3 ? { symbol: normalizeSymbol(symbol3) } : {}))
1474
1563
  },
1475
1564
  {
1476
1565
  name: "futures_ws_api_order_book",
1477
1566
  description: "Get order-book depth via the unsigned WebSocket API (depth).",
1478
- inputSchema: import_zod9.z.object({
1479
- symbol: import_zod9.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
1480
- limit: import_zod9.z.enum(["5", "10", "20", "50", "100", "500", "1000"]).optional()
1567
+ inputSchema: import_zod10.z.object({
1568
+ symbol: import_zod10.z.string().min(1).describe("USD-M pair, e.g. BTCUSDT"),
1569
+ limit: import_zod10.z.enum(["5", "10", "20", "50", "100", "500", "1000"]).optional()
1481
1570
  }),
1482
1571
  handler: async ({ symbol: symbol3, limit: limit4 }) => textResult(await client.futures.wsApi.depth({ symbol: normalizeSymbol(symbol3), limit: limit4 }))
1483
1572
  }
@@ -1485,7 +1574,7 @@ function wsTools(client) {
1485
1574
  }
1486
1575
 
1487
1576
  // src/tools/index.ts
1488
- function createFuturesToolkit(client) {
1577
+ function createFuturesToolkit(client, options = {}) {
1489
1578
  const market = marketDataTools(client);
1490
1579
  const account = accountTools(client);
1491
1580
  const trading = tradingTools(client);
@@ -1494,9 +1583,14 @@ function createFuturesToolkit(client) {
1494
1583
  const derived = derivedTools(client);
1495
1584
  const paperContext = createPaperContext(client);
1496
1585
  const paper = paperTools(paperContext);
1586
+ const gateway = client.createExecutionGateway({
1587
+ paper: options.paper,
1588
+ defaultBackend: options.executionBackend
1589
+ });
1590
+ const execution = executionTools(gateway, client);
1497
1591
  return {
1498
1592
  client,
1499
- tools: [...market, ...account, ...trading, ...spot, ...ws, ...derived, ...paper],
1593
+ tools: [...market, ...account, ...trading, ...spot, ...ws, ...derived, ...paper, ...execution],
1500
1594
  market,
1501
1595
  account,
1502
1596
  trading,
@@ -1504,7 +1598,9 @@ function createFuturesToolkit(client) {
1504
1598
  ws,
1505
1599
  derived,
1506
1600
  paper,
1507
- paperContext
1601
+ paperContext,
1602
+ execution,
1603
+ gateway
1508
1604
  };
1509
1605
  }
1510
1606
  function toolkitToFormats(toolkit) {
@@ -1521,6 +1617,7 @@ function toolkitToFormats(toolkit) {
1521
1617
  createFuturesToolkit,
1522
1618
  createPaperContext,
1523
1619
  derivedTools,
1620
+ executionTools,
1524
1621
  getBufferedWsEvents,
1525
1622
  marketDataTools,
1526
1623
  paperTools,