@zebpay_rajesh/zebpay-mcp-server 0.1.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.
Potentially problematic release.
This version of @zebpay_rajesh/zebpay-mcp-server might be problematic. Click here for more details.
- package/.env.example +14 -0
- package/README.md +223 -0
- package/dist/__tests__/errors.test.d.ts +5 -0
- package/dist/__tests__/errors.test.js +147 -0
- package/dist/__tests__/errors.test.js.map +1 -0
- package/dist/__tests__/prompts.test.d.ts +1 -0
- package/dist/__tests__/prompts.test.js +73 -0
- package/dist/__tests__/prompts.test.js.map +1 -0
- package/dist/__tests__/resources.test.d.ts +1 -0
- package/dist/__tests__/resources.test.js +79 -0
- package/dist/__tests__/resources.test.js.map +1 -0
- package/dist/__tests__/validation.test.d.ts +15 -0
- package/dist/__tests__/validation.test.js +64 -0
- package/dist/__tests__/validation.test.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +81 -0
- package/dist/config.js.map +1 -0
- package/dist/http/httpClient.d.ts +40 -0
- package/dist/http/httpClient.js +341 -0
- package/dist/http/httpClient.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/errors.d.ts +21 -0
- package/dist/mcp/errors.js +214 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/logging.d.ts +21 -0
- package/dist/mcp/logging.js +241 -0
- package/dist/mcp/logging.js.map +1 -0
- package/dist/mcp/prompts.d.ts +9 -0
- package/dist/mcp/prompts.js +165 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/resources.d.ts +9 -0
- package/dist/mcp/resources.js +125 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/tools_futures.d.ts +5 -0
- package/dist/mcp/tools_futures.js +694 -0
- package/dist/mcp/tools_futures.js.map +1 -0
- package/dist/mcp/tools_spot.d.ts +11 -0
- package/dist/mcp/tools_spot.js +2225 -0
- package/dist/mcp/tools_spot.js.map +1 -0
- package/dist/private/FuturesClient.d.ts +57 -0
- package/dist/private/FuturesClient.js +181 -0
- package/dist/private/FuturesClient.js.map +1 -0
- package/dist/private/SpotClient.d.ts +44 -0
- package/dist/private/SpotClient.js +201 -0
- package/dist/private/SpotClient.js.map +1 -0
- package/dist/private/ZebpayAPI.d.ts +19 -0
- package/dist/private/ZebpayAPI.js +172 -0
- package/dist/private/ZebpayAPI.js.map +1 -0
- package/dist/public/PublicClient.d.ts +79 -0
- package/dist/public/PublicClient.js +283 -0
- package/dist/public/PublicClient.js.map +1 -0
- package/dist/public/PublicFuturesClient.d.ts +27 -0
- package/dist/public/PublicFuturesClient.js +187 -0
- package/dist/public/PublicFuturesClient.js.map +1 -0
- package/dist/security/credentials.d.ts +42 -0
- package/dist/security/credentials.js +80 -0
- package/dist/security/credentials.js.map +1 -0
- package/dist/security/signing.d.ts +33 -0
- package/dist/security/signing.js +56 -0
- package/dist/security/signing.js.map +1 -0
- package/dist/types/responses.d.ts +130 -0
- package/dist/types/responses.js +6 -0
- package/dist/types/responses.js.map +1 -0
- package/dist/utils/cache.d.ts +29 -0
- package/dist/utils/cache.js +72 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/fileLogger.d.ts +10 -0
- package/dist/utils/fileLogger.js +81 -0
- package/dist/utils/fileLogger.js.map +1 -0
- package/dist/utils/metrics.d.ts +35 -0
- package/dist/utils/metrics.js +94 -0
- package/dist/utils/metrics.js.map +1 -0
- package/dist/utils/responseFormatter.d.ts +93 -0
- package/dist/utils/responseFormatter.js +268 -0
- package/dist/utils/responseFormatter.js.map +1 -0
- package/dist/validation/schemas.d.ts +70 -0
- package/dist/validation/schemas.js +48 -0
- package/dist/validation/schemas.js.map +1 -0
- package/dist/validation/validators.d.ts +28 -0
- package/dist/validation/validators.js +129 -0
- package/dist/validation/validators.js.map +1 -0
- package/docs/LOGGING.md +371 -0
- package/docs/zebpay-ai-trading-beginner.png +0 -0
- package/mcp-config.json.example +20 -0
- package/package.json +54 -0
- package/scripts/README.md +103 -0
- package/scripts/clear-logs.js +52 -0
- package/scripts/log-stats.js +264 -0
- package/scripts/log-viewer.js +288 -0
- package/server.json +31 -0
- package/src/__tests__/errors.test.ts +180 -0
- package/src/__tests__/prompts.test.ts +89 -0
- package/src/__tests__/resources.test.ts +95 -0
- package/src/__tests__/validation.test.ts +88 -0
- package/src/config.ts +108 -0
- package/src/http/httpClient.ts +398 -0
- package/src/index.ts +71 -0
- package/src/mcp/errors.ts +262 -0
- package/src/mcp/logging.ts +284 -0
- package/src/mcp/prompts.ts +206 -0
- package/src/mcp/resources.ts +163 -0
- package/src/mcp/tools_futures.ts +874 -0
- package/src/mcp/tools_spot.ts +2702 -0
- package/src/private/FuturesClient.ts +189 -0
- package/src/private/SpotClient.ts +250 -0
- package/src/private/ZebpayAPI.ts +205 -0
- package/src/public/PublicClient.ts +381 -0
- package/src/public/PublicFuturesClient.ts +228 -0
- package/src/security/credentials.ts +114 -0
- package/src/security/signing.ts +98 -0
- package/src/types/responses.ts +146 -0
- package/src/utils/cache.ts +90 -0
- package/src/utils/fileLogger.ts +88 -0
- package/src/utils/metrics.ts +135 -0
- package/src/utils/responseFormatter.ts +361 -0
- package/src/validation/schemas.ts +66 -0
- package/src/validation/validators.ts +189 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Futures public tools
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { withLogging } from "./logging.js";
|
|
6
|
+
import { createInvalidParamsError } from "./errors.js";
|
|
7
|
+
import { formatResponse, formatOrderBookResponse, formatTickerResponse, generateCorrelationId } from "../utils/responseFormatter.js";
|
|
8
|
+
import { metricsCollector } from "../utils/metrics.js";
|
|
9
|
+
export function registerFuturesTools(server, futuresPublicClient, futuresPrivateClient, config) {
|
|
10
|
+
console.error("Registering futures public tools (markets, depth, tickers)...");
|
|
11
|
+
const futuresSymbolSchema = z.string().min(1).regex(/^[A-Z0-9]+$/, {
|
|
12
|
+
message: 'Invalid futures symbol. Expected uppercase alphanumeric like "BTCUSDT".',
|
|
13
|
+
});
|
|
14
|
+
// Health check (no params)
|
|
15
|
+
try {
|
|
16
|
+
server.tool("zebpay_futures_public_healthCheckStatus", `Get current health status of the Zebpay Futures public API (no auth).
|
|
17
|
+
|
|
18
|
+
When to use:
|
|
19
|
+
- Before making other futures requests to confirm API availability
|
|
20
|
+
- To troubleshoot connectivity or rate limit issues
|
|
21
|
+
|
|
22
|
+
Response:
|
|
23
|
+
- Returns a status payload indicating whether services are operational.
|
|
24
|
+
`, {}, withLogging("futures_public_healthCheckStatus", config.logLevel, async () => {
|
|
25
|
+
const correlationId = generateCorrelationId();
|
|
26
|
+
const startTime = Date.now();
|
|
27
|
+
try {
|
|
28
|
+
const result = await futuresPublicClient.getHealthCheckStatus();
|
|
29
|
+
const durationMs = Date.now() - startTime;
|
|
30
|
+
metricsCollector.record("zebpay_futures_public_healthCheckStatus", durationMs, true);
|
|
31
|
+
return formatResponse(result, { toolName: "zebpay_futures_public_healthCheckStatus", correlationId, executionTimeMs: durationMs });
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
const durationMs = Date.now() - startTime;
|
|
35
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
36
|
+
metricsCollector.record("zebpay_futures_public_healthCheckStatus", durationMs, false, errorType);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
console.error("Registered tool: zebpay_futures_public_healthCheckStatus");
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error("Error registering zebpay_futures_public_healthCheckStatus:", error);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
server.tool("zebpay_futures_public_getMarkets", `Get list of all futures markets and tradable symbols (no auth).
|
|
47
|
+
|
|
48
|
+
When to use:
|
|
49
|
+
- To discover available futures symbols and market metadata
|
|
50
|
+
- Prior to validating a user-provided symbol
|
|
51
|
+
|
|
52
|
+
Notes:
|
|
53
|
+
- Symbols are typically uppercase without hyphens, e.g., "BTCUSDT".
|
|
54
|
+
`, {}, withLogging("futures_public_getMarkets", config.logLevel, async () => {
|
|
55
|
+
const correlationId = generateCorrelationId();
|
|
56
|
+
const startTime = Date.now();
|
|
57
|
+
try {
|
|
58
|
+
const result = await futuresPublicClient.getMarkets();
|
|
59
|
+
const durationMs = Date.now() - startTime;
|
|
60
|
+
metricsCollector.record("zebpay_futures_public_getMarkets", durationMs, true);
|
|
61
|
+
return formatResponse(result, { toolName: "zebpay_futures_public_getMarkets", correlationId, executionTimeMs: durationMs });
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
const durationMs = Date.now() - startTime;
|
|
65
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
66
|
+
metricsCollector.record("zebpay_futures_public_getMarkets", durationMs, false, errorType);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
console.error("Registered tool: zebpay_futures_public_getMarkets");
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.error("Error registering zebpay_futures_public_getMarkets:", error);
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
server.tool("zebpay_futures_public_getMarketInfo", `Get futures market info (fees, limits, min qty/price, filters) (no auth).
|
|
77
|
+
|
|
78
|
+
When to use:
|
|
79
|
+
- Before placing orders to understand precision, minimum quantity, and price tick size
|
|
80
|
+
- To validate user inputs against exchange rules
|
|
81
|
+
`, {}, withLogging("futures_public_getMarketInfo", config.logLevel, async () => {
|
|
82
|
+
const correlationId = generateCorrelationId();
|
|
83
|
+
const startTime = Date.now();
|
|
84
|
+
try {
|
|
85
|
+
const result = await futuresPublicClient.getMarketInfo();
|
|
86
|
+
const durationMs = Date.now() - startTime;
|
|
87
|
+
metricsCollector.record("zebpay_futures_public_getMarketInfo", durationMs, true);
|
|
88
|
+
return formatResponse(result, { toolName: "zebpay_futures_public_getMarketInfo", correlationId, executionTimeMs: durationMs });
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
const durationMs = Date.now() - startTime;
|
|
92
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
93
|
+
metricsCollector.record("zebpay_futures_public_getMarketInfo", durationMs, false, errorType);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
97
|
+
console.error("Registered tool: zebpay_futures_public_getMarketInfo");
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error("Error registering zebpay_futures_public_getMarketInfo:", error);
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
server.tool("zebpay_futures_public_getOrderBook", `Get futures order book (market depth) for a symbol (no auth).
|
|
104
|
+
|
|
105
|
+
When to use:
|
|
106
|
+
- To analyze bid/ask depth, spread, and liquidity for a symbol
|
|
107
|
+
- Before placing a limit order to choose price levels
|
|
108
|
+
|
|
109
|
+
Example:
|
|
110
|
+
{ "symbol": "BTCUSDT", "limit": 50 }
|
|
111
|
+
`, {
|
|
112
|
+
symbol: futuresSymbolSchema.describe(`Futures symbol like "BTCUSDT" (uppercase, no hyphen).`),
|
|
113
|
+
limit: z.string().optional().describe(`Optional number of price levels to return per side as string (e.g., "5", "10", "50").`),
|
|
114
|
+
}, withLogging("futures_public_getOrderBook", config.logLevel, async ({ symbol, limit }) => {
|
|
115
|
+
const correlationId = generateCorrelationId();
|
|
116
|
+
const startTime = Date.now();
|
|
117
|
+
try {
|
|
118
|
+
const result = await futuresPublicClient.getOrderBook({ symbol: String(symbol).trim().toUpperCase(), limit: limit ? parseInt(limit, 10) : undefined });
|
|
119
|
+
const durationMs = Date.now() - startTime;
|
|
120
|
+
metricsCollector.record("zebpay_futures_public_getOrderBook", durationMs, true);
|
|
121
|
+
return formatOrderBookResponse(result, { toolName: "zebpay_futures_public_getOrderBook", correlationId, executionTimeMs: durationMs });
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
const durationMs = Date.now() - startTime;
|
|
125
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
126
|
+
metricsCollector.record("zebpay_futures_public_getOrderBook", durationMs, false, errorType);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
console.error("Registered tool: zebpay_futures_public_getOrderBook");
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
console.error("Error registering zebpay_futures_public_getOrderBook:", error);
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
server.tool("zebpay_futures_public_getTicker24Hr", `Get 24h ticker statistics for a futures symbol (no auth).
|
|
137
|
+
|
|
138
|
+
Includes:
|
|
139
|
+
- Last price, 24h high/low, volume, price change absolute and percentage.
|
|
140
|
+
|
|
141
|
+
Example:
|
|
142
|
+
{ "symbol": "BTCUSDT" }
|
|
143
|
+
`, {
|
|
144
|
+
symbol: futuresSymbolSchema.describe(`Futures symbol like "BTCUSDT" (uppercase, no hyphen).`),
|
|
145
|
+
}, withLogging("futures_public_getTicker24Hr", config.logLevel, async ({ symbol }) => {
|
|
146
|
+
const correlationId = generateCorrelationId();
|
|
147
|
+
const startTime = Date.now();
|
|
148
|
+
try {
|
|
149
|
+
const result = await futuresPublicClient.getTicker24Hr({ symbol: String(symbol).trim().toUpperCase() });
|
|
150
|
+
const durationMs = Date.now() - startTime;
|
|
151
|
+
metricsCollector.record("zebpay_futures_public_getTicker24Hr", durationMs, true);
|
|
152
|
+
return formatTickerResponse(result, { correlationId, executionTimeMs: durationMs });
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
const durationMs = Date.now() - startTime;
|
|
156
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
157
|
+
metricsCollector.record("zebpay_futures_public_getTicker24Hr", durationMs, false, errorType);
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}));
|
|
161
|
+
console.error("Registered tool: zebpay_futures_public_getTicker24Hr");
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
console.error("Error registering zebpay_futures_public_getTicker24Hr:", error);
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
server.tool("zebpay_futures_public_getAggregateTrades", `Get aggregate trades (compressed recent trades) for a futures symbol (no auth).
|
|
168
|
+
|
|
169
|
+
When to use:
|
|
170
|
+
- To inspect recent trading activity and momentum
|
|
171
|
+
- For lightweight trade history without full raw trades
|
|
172
|
+
`, {
|
|
173
|
+
symbol: futuresSymbolSchema.describe(`Futures symbol like "BTCUSDT" (uppercase, no hyphen).`),
|
|
174
|
+
limit: z.string().optional().describe(`Optional number of trades to fetch as string (e.g., "50", "100").`),
|
|
175
|
+
}, withLogging("futures_public_getAggregateTrades", config.logLevel, async ({ symbol, limit }) => {
|
|
176
|
+
const correlationId = generateCorrelationId();
|
|
177
|
+
const startTime = Date.now();
|
|
178
|
+
try {
|
|
179
|
+
const result = await futuresPublicClient.getAggregateTrades({ symbol: String(symbol).trim().toUpperCase(), limit: limit ? parseInt(limit, 10) : undefined });
|
|
180
|
+
const durationMs = Date.now() - startTime;
|
|
181
|
+
metricsCollector.record("zebpay_futures_public_getAggregateTrades", durationMs, true);
|
|
182
|
+
return formatResponse(result, { toolName: "zebpay_futures_public_getAggregateTrades", correlationId, executionTimeMs: durationMs });
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
const durationMs = Date.now() - startTime;
|
|
186
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
187
|
+
metricsCollector.record("zebpay_futures_public_getAggregateTrades", durationMs, false, errorType);
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
}));
|
|
191
|
+
console.error("Registered tool: zebpay_futures_public_getAggregateTrades");
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
console.error("Error registering zebpay_futures_public_getAggregateTrades:", error);
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
server.tool("zebpay_futures_public_getExchangeInfo", `Get futures exchange info (no auth).
|
|
198
|
+
|
|
199
|
+
Includes:
|
|
200
|
+
- Exchange-wide settings, available symbols, filters, and rule sets.
|
|
201
|
+
|
|
202
|
+
Use with:
|
|
203
|
+
- zebpay_futures_public_getMarketInfo for detailed per-symbol limits.
|
|
204
|
+
`, {}, withLogging("futures_public_getExchangeInfo", config.logLevel, async () => {
|
|
205
|
+
const correlationId = generateCorrelationId();
|
|
206
|
+
const startTime = Date.now();
|
|
207
|
+
try {
|
|
208
|
+
const result = await futuresPublicClient.getExchangeInfo();
|
|
209
|
+
const durationMs = Date.now() - startTime;
|
|
210
|
+
metricsCollector.record("zebpay_futures_public_getExchangeInfo", durationMs, true);
|
|
211
|
+
return formatResponse(result, { toolName: "zebpay_futures_public_getExchangeInfo", correlationId, executionTimeMs: durationMs });
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
const durationMs = Date.now() - startTime;
|
|
215
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
216
|
+
metricsCollector.record("zebpay_futures_public_getExchangeInfo", durationMs, false, errorType);
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
}));
|
|
220
|
+
console.error("Registered tool: zebpay_futures_public_getExchangeInfo");
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
console.error("Error registering zebpay_futures_public_getExchangeInfo:", error);
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
server.tool("zebpay_futures_public_getExchangePairs", `Get futures exchange pairs (no auth).
|
|
227
|
+
|
|
228
|
+
Returns:
|
|
229
|
+
- List of pairs/symbols that are enabled for trading.
|
|
230
|
+
`, {}, withLogging("futures_public_getExchangePairs", config.logLevel, async () => {
|
|
231
|
+
const correlationId = generateCorrelationId();
|
|
232
|
+
const startTime = Date.now();
|
|
233
|
+
try {
|
|
234
|
+
const result = await futuresPublicClient.getExchangePairs();
|
|
235
|
+
const durationMs = Date.now() - startTime;
|
|
236
|
+
metricsCollector.record("zebpay_futures_public_getExchangePairs", durationMs, true);
|
|
237
|
+
return formatResponse(result, { toolName: "zebpay_futures_public_getExchangePairs", correlationId, executionTimeMs: durationMs });
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
const durationMs = Date.now() - startTime;
|
|
241
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
242
|
+
metricsCollector.record("zebpay_futures_public_getExchangePairs", durationMs, false, errorType);
|
|
243
|
+
throw error;
|
|
244
|
+
}
|
|
245
|
+
}));
|
|
246
|
+
console.error("Registered tool: zebpay_futures_public_getExchangePairs");
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
console.error("Error registering zebpay_futures_public_getExchangePairs:", error);
|
|
250
|
+
}
|
|
251
|
+
// =========================
|
|
252
|
+
// Authenticated futures tools
|
|
253
|
+
// =========================
|
|
254
|
+
console.error("Registering futures AUTHENTICATED tools...");
|
|
255
|
+
// Wallet Balance (GET)
|
|
256
|
+
try {
|
|
257
|
+
server.tool("zebpay_futures_getWalletBalance", `Get futures wallet balance (authentication required).
|
|
258
|
+
|
|
259
|
+
When to use:
|
|
260
|
+
- Before placing orders to verify available margin asset balances
|
|
261
|
+
- To display user account balances in a dashboard
|
|
262
|
+
`, {}, withLogging("futures_getWalletBalance", config.logLevel, async () => {
|
|
263
|
+
const correlationId = generateCorrelationId();
|
|
264
|
+
const startTime = Date.now();
|
|
265
|
+
if (!futuresPrivateClient) {
|
|
266
|
+
metricsCollector.record("zebpay_futures_getWalletBalance", Date.now() - startTime, false, "missing_credentials");
|
|
267
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
268
|
+
}
|
|
269
|
+
try {
|
|
270
|
+
const result = await futuresPrivateClient.getWalletBalance();
|
|
271
|
+
const durationMs = Date.now() - startTime;
|
|
272
|
+
metricsCollector.record("zebpay_futures_getWalletBalance", durationMs, true);
|
|
273
|
+
return formatResponse(result, { toolName: "zebpay_futures_getWalletBalance", correlationId, executionTimeMs: durationMs });
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
const durationMs = Date.now() - startTime;
|
|
277
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
278
|
+
metricsCollector.record("zebpay_futures_getWalletBalance", durationMs, false, errorType);
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
281
|
+
}));
|
|
282
|
+
console.error("Registered tool: zebpay_futures_getWalletBalance");
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
console.error("Error registering zebpay_futures_getWalletBalance:", error);
|
|
286
|
+
}
|
|
287
|
+
// Place Order (POST)
|
|
288
|
+
try {
|
|
289
|
+
server.tool("zebpay_futures_placeOrder", `Place a new futures trade order (authentication required).
|
|
290
|
+
|
|
291
|
+
Order types supported: MARKET, LIMIT
|
|
292
|
+
Sides: BUY, SELL
|
|
293
|
+
|
|
294
|
+
Notes:
|
|
295
|
+
- Provide price for LIMIT orders; omit price for MARKET orders.
|
|
296
|
+
- amount and price can be strings to preserve precision.
|
|
297
|
+
`, {
|
|
298
|
+
symbol: z.string().min(1).describe(`Futures symbol, e.g., "BTCUSDT" (uppercase, no hyphen).`),
|
|
299
|
+
amount: z.string().describe(`Order amount (base asset quantity) as string for precision, e.g., "0.01".`),
|
|
300
|
+
side: z.enum(["BUY", "SELL"]).describe(`Order side.`),
|
|
301
|
+
type: z.enum(["MARKET", "LIMIT"]).describe(`Order type.`),
|
|
302
|
+
marginAsset: z.string().min(1).describe(`Margin asset used for the position, e.g., "USDT".`),
|
|
303
|
+
price: z.string().optional().describe(`Price for LIMIT orders in quote asset as string. Omit for MARKET.`),
|
|
304
|
+
clientOrderId: z.string().optional().describe(`Optional client-defined identifier for idempotency and tracking.`),
|
|
305
|
+
}, withLogging("futures_placeOrder", config.logLevel, async ({ symbol, amount, side, type, marginAsset, price, clientOrderId }) => {
|
|
306
|
+
const correlationId = generateCorrelationId();
|
|
307
|
+
const startTime = Date.now();
|
|
308
|
+
if (!futuresPrivateClient) {
|
|
309
|
+
metricsCollector.record("zebpay_futures_placeOrder", Date.now() - startTime, false, "missing_credentials");
|
|
310
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
311
|
+
}
|
|
312
|
+
try {
|
|
313
|
+
const result = await futuresPrivateClient.placeOrder({ symbol, amount, side, type, marginAsset, price, clientOrderId });
|
|
314
|
+
const durationMs = Date.now() - startTime;
|
|
315
|
+
metricsCollector.record("zebpay_futures_placeOrder", durationMs, true);
|
|
316
|
+
return formatResponse(result, { toolName: "zebpay_futures_placeOrder", correlationId, executionTimeMs: durationMs });
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
const durationMs = Date.now() - startTime;
|
|
320
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
321
|
+
metricsCollector.record("zebpay_futures_placeOrder", durationMs, false, errorType);
|
|
322
|
+
throw error;
|
|
323
|
+
}
|
|
324
|
+
}));
|
|
325
|
+
console.error("Registered tool: zebpay_futures_placeOrder");
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
console.error("Error registering zebpay_futures_placeOrder:", error);
|
|
329
|
+
}
|
|
330
|
+
// Add Margin (POST)
|
|
331
|
+
try {
|
|
332
|
+
server.tool("zebpay_futures_addMargin", `Add margin to a futures position (authentication required).
|
|
333
|
+
|
|
334
|
+
Use to:
|
|
335
|
+
- Increase margin to reduce liquidation risk or increase position buffer.
|
|
336
|
+
`, {
|
|
337
|
+
symbol: z.string().min(1).describe(`Futures symbol, e.g., "BTCUSDT".`),
|
|
338
|
+
amount: z.string().describe(`Amount of margin to add as string, in marginAsset.`),
|
|
339
|
+
marginAsset: z.string().min(1).describe(`Margin asset, e.g., "USDT".`),
|
|
340
|
+
}, withLogging("futures_addMargin", config.logLevel, async ({ symbol, amount, marginAsset }) => {
|
|
341
|
+
const correlationId = generateCorrelationId();
|
|
342
|
+
const startTime = Date.now();
|
|
343
|
+
if (!futuresPrivateClient) {
|
|
344
|
+
metricsCollector.record("zebpay_futures_addMargin", Date.now() - startTime, false, "missing_credentials");
|
|
345
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
346
|
+
}
|
|
347
|
+
try {
|
|
348
|
+
const result = await futuresPrivateClient.addMargin({ symbol, amount, marginAsset });
|
|
349
|
+
const durationMs = Date.now() - startTime;
|
|
350
|
+
metricsCollector.record("zebpay_futures_addMargin", durationMs, true);
|
|
351
|
+
return formatResponse(result, { toolName: "zebpay_futures_addMargin", correlationId, executionTimeMs: durationMs });
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
const durationMs = Date.now() - startTime;
|
|
355
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
356
|
+
metricsCollector.record("zebpay_futures_addMargin", durationMs, false, errorType);
|
|
357
|
+
throw error;
|
|
358
|
+
}
|
|
359
|
+
}));
|
|
360
|
+
console.error("Registered tool: zebpay_futures_addMargin");
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
console.error("Error registering zebpay_futures_addMargin:", error);
|
|
364
|
+
}
|
|
365
|
+
// Reduce Margin (POST)
|
|
366
|
+
try {
|
|
367
|
+
server.tool("zebpay_futures_reduceMargin", `Reduce margin from a futures position (authentication required).
|
|
368
|
+
|
|
369
|
+
Use to:
|
|
370
|
+
- Withdraw excess margin from a position, within risk limits.
|
|
371
|
+
`, {
|
|
372
|
+
symbol: z.string().min(1).describe(`Futures symbol, e.g., "BTCUSDT".`),
|
|
373
|
+
amount: z.string().describe(`Amount of margin to remove as string, in marginAsset.`),
|
|
374
|
+
marginAsset: z.string().min(1).describe(`Margin asset, e.g., "USDT".`),
|
|
375
|
+
}, withLogging("futures_reduceMargin", config.logLevel, async ({ symbol, amount, marginAsset }) => {
|
|
376
|
+
const correlationId = generateCorrelationId();
|
|
377
|
+
const startTime = Date.now();
|
|
378
|
+
if (!futuresPrivateClient) {
|
|
379
|
+
metricsCollector.record("zebpay_futures_reduceMargin", Date.now() - startTime, false, "missing_credentials");
|
|
380
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
381
|
+
}
|
|
382
|
+
try {
|
|
383
|
+
const result = await futuresPrivateClient.reduceMargin({ symbol, amount, marginAsset });
|
|
384
|
+
const durationMs = Date.now() - startTime;
|
|
385
|
+
metricsCollector.record("zebpay_futures_reduceMargin", durationMs, true);
|
|
386
|
+
return formatResponse(result, { toolName: "zebpay_futures_reduceMargin", correlationId, executionTimeMs: durationMs });
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
const durationMs = Date.now() - startTime;
|
|
390
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
391
|
+
metricsCollector.record("zebpay_futures_reduceMargin", durationMs, false, errorType);
|
|
392
|
+
throw error;
|
|
393
|
+
}
|
|
394
|
+
}));
|
|
395
|
+
console.error("Registered tool: zebpay_futures_reduceMargin");
|
|
396
|
+
}
|
|
397
|
+
catch (error) {
|
|
398
|
+
console.error("Error registering zebpay_futures_reduceMargin:", error);
|
|
399
|
+
}
|
|
400
|
+
// Open Orders (GET)
|
|
401
|
+
try {
|
|
402
|
+
server.tool("zebpay_futures_getOpenOrders", `Get open futures orders (authentication required).
|
|
403
|
+
|
|
404
|
+
Filters:
|
|
405
|
+
- Optional symbol filter
|
|
406
|
+
- Optional limit and since cursor/pagination
|
|
407
|
+
`, {
|
|
408
|
+
symbol: z.string().optional().describe(`Optional futures symbol to filter, e.g., "BTCUSDT".`),
|
|
409
|
+
limit: z.string().optional().describe(`Optional maximum number of records to return as string.`),
|
|
410
|
+
since: z.string().optional().describe(`Optional cursor or timestamp as string to fetch orders since.`),
|
|
411
|
+
}, withLogging("futures_getOpenOrders", config.logLevel, async ({ symbol, limit, since }) => {
|
|
412
|
+
const correlationId = generateCorrelationId();
|
|
413
|
+
const startTime = Date.now();
|
|
414
|
+
if (!futuresPrivateClient) {
|
|
415
|
+
metricsCollector.record("zebpay_futures_getOpenOrders", Date.now() - startTime, false, "missing_credentials");
|
|
416
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
417
|
+
}
|
|
418
|
+
try {
|
|
419
|
+
const result = await futuresPrivateClient.getOpenOrders({ symbol, limit: limit ? parseInt(limit, 10) : undefined, since });
|
|
420
|
+
const durationMs = Date.now() - startTime;
|
|
421
|
+
metricsCollector.record("zebpay_futures_getOpenOrders", durationMs, true);
|
|
422
|
+
return formatResponse(result, { toolName: "zebpay_futures_getOpenOrders", correlationId, executionTimeMs: durationMs });
|
|
423
|
+
}
|
|
424
|
+
catch (error) {
|
|
425
|
+
const durationMs = Date.now() - startTime;
|
|
426
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
427
|
+
metricsCollector.record("zebpay_futures_getOpenOrders", durationMs, false, errorType);
|
|
428
|
+
throw error;
|
|
429
|
+
}
|
|
430
|
+
}));
|
|
431
|
+
console.error("Registered tool: zebpay_futures_getOpenOrders");
|
|
432
|
+
}
|
|
433
|
+
catch (error) {
|
|
434
|
+
console.error("Error registering zebpay_futures_getOpenOrders:", error);
|
|
435
|
+
}
|
|
436
|
+
// Order History (GET)
|
|
437
|
+
try {
|
|
438
|
+
server.tool("zebpay_futures_getOrderHistory", `Get futures order history (authentication required).
|
|
439
|
+
|
|
440
|
+
Pagination:
|
|
441
|
+
- page (1-based) and pageSize (e.g., 50, 100)
|
|
442
|
+
`, {
|
|
443
|
+
page: z.string().optional().describe(`Optional 1-based page number as string.`),
|
|
444
|
+
pageSize: z.string().optional().describe(`Optional page size as string, e.g., "50" or "100".`),
|
|
445
|
+
}, withLogging("futures_getOrderHistory", config.logLevel, async ({ page, pageSize }) => {
|
|
446
|
+
const correlationId = generateCorrelationId();
|
|
447
|
+
const startTime = Date.now();
|
|
448
|
+
if (!futuresPrivateClient) {
|
|
449
|
+
metricsCollector.record("zebpay_futures_getOrderHistory", Date.now() - startTime, false, "missing_credentials");
|
|
450
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
451
|
+
}
|
|
452
|
+
try {
|
|
453
|
+
const result = await futuresPrivateClient.getOrderHistory({ page: page ? parseInt(page, 10) : undefined, pageSize: pageSize ? parseInt(pageSize, 10) : undefined });
|
|
454
|
+
const durationMs = Date.now() - startTime;
|
|
455
|
+
metricsCollector.record("zebpay_futures_getOrderHistory", durationMs, true);
|
|
456
|
+
return formatResponse(result, { toolName: "zebpay_futures_getOrderHistory", correlationId, executionTimeMs: durationMs });
|
|
457
|
+
}
|
|
458
|
+
catch (error) {
|
|
459
|
+
const durationMs = Date.now() - startTime;
|
|
460
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
461
|
+
metricsCollector.record("zebpay_futures_getOrderHistory", durationMs, false, errorType);
|
|
462
|
+
throw error;
|
|
463
|
+
}
|
|
464
|
+
}));
|
|
465
|
+
console.error("Registered tool: zebpay_futures_getOrderHistory");
|
|
466
|
+
}
|
|
467
|
+
catch (error) {
|
|
468
|
+
console.error("Error registering zebpay_futures_getOrderHistory:", error);
|
|
469
|
+
}
|
|
470
|
+
// Linked Orders (GET)
|
|
471
|
+
try {
|
|
472
|
+
server.tool("zebpay_futures_getLinkedOrders", `Get linked orders by clientOrderId (authentication required).
|
|
473
|
+
|
|
474
|
+
Use to:
|
|
475
|
+
- Retrieve chain of related orders created with the same clientOrderId.
|
|
476
|
+
`, { clientOrderId: z.string().min(1).describe(`Client-defined identifier used when placing orders.`) }, withLogging("futures_getLinkedOrders", config.logLevel, async ({ clientOrderId }) => {
|
|
477
|
+
const correlationId = generateCorrelationId();
|
|
478
|
+
const startTime = Date.now();
|
|
479
|
+
if (!futuresPrivateClient) {
|
|
480
|
+
metricsCollector.record("zebpay_futures_getLinkedOrders", Date.now() - startTime, false, "missing_credentials");
|
|
481
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
482
|
+
}
|
|
483
|
+
try {
|
|
484
|
+
const result = await futuresPrivateClient.getLinkedOrders(clientOrderId);
|
|
485
|
+
const durationMs = Date.now() - startTime;
|
|
486
|
+
metricsCollector.record("zebpay_futures_getLinkedOrders", durationMs, true);
|
|
487
|
+
return formatResponse(result, { toolName: "zebpay_futures_getLinkedOrders", correlationId, executionTimeMs: durationMs });
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
const durationMs = Date.now() - startTime;
|
|
491
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
492
|
+
metricsCollector.record("zebpay_futures_getLinkedOrders", durationMs, false, errorType);
|
|
493
|
+
throw error;
|
|
494
|
+
}
|
|
495
|
+
}));
|
|
496
|
+
console.error("Registered tool: zebpay_futures_getLinkedOrders");
|
|
497
|
+
}
|
|
498
|
+
catch (error) {
|
|
499
|
+
console.error("Error registering zebpay_futures_getLinkedOrders:", error);
|
|
500
|
+
}
|
|
501
|
+
// Positions (GET)
|
|
502
|
+
try {
|
|
503
|
+
server.tool("zebpay_futures_getPositions", `Get futures positions (authentication required).
|
|
504
|
+
|
|
505
|
+
Filter:
|
|
506
|
+
- Optional status filter (e.g., "OPEN", "CLOSED") if supported by API.
|
|
507
|
+
`, { status: z.string().optional().describe(`Optional position status filter.`) }, withLogging("futures_getPositions", config.logLevel, async ({ status }) => {
|
|
508
|
+
const correlationId = generateCorrelationId();
|
|
509
|
+
const startTime = Date.now();
|
|
510
|
+
if (!futuresPrivateClient) {
|
|
511
|
+
metricsCollector.record("zebpay_futures_getPositions", Date.now() - startTime, false, "missing_credentials");
|
|
512
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
513
|
+
}
|
|
514
|
+
try {
|
|
515
|
+
const result = await futuresPrivateClient.getPositions({ status });
|
|
516
|
+
const durationMs = Date.now() - startTime;
|
|
517
|
+
metricsCollector.record("zebpay_futures_getPositions", durationMs, true);
|
|
518
|
+
return formatResponse(result, { toolName: "zebpay_futures_getPositions", correlationId, executionTimeMs: durationMs });
|
|
519
|
+
}
|
|
520
|
+
catch (error) {
|
|
521
|
+
const durationMs = Date.now() - startTime;
|
|
522
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
523
|
+
metricsCollector.record("zebpay_futures_getPositions", durationMs, false, errorType);
|
|
524
|
+
throw error;
|
|
525
|
+
}
|
|
526
|
+
}));
|
|
527
|
+
console.error("Registered tool: zebpay_futures_getPositions");
|
|
528
|
+
}
|
|
529
|
+
catch (error) {
|
|
530
|
+
console.error("Error registering zebpay_futures_getPositions:", error);
|
|
531
|
+
}
|
|
532
|
+
// Trade History (GET)
|
|
533
|
+
try {
|
|
534
|
+
server.tool("zebpay_futures_getTradeHistory", `Get futures trade history (authentication required).
|
|
535
|
+
|
|
536
|
+
Pagination:
|
|
537
|
+
- page (1-based) and pageSize (e.g., 50, 100)
|
|
538
|
+
`, {
|
|
539
|
+
page: z.string().optional().describe(`Optional 1-based page number as string.`),
|
|
540
|
+
pageSize: z.string().optional().describe(`Optional page size as string, e.g., "50" or "100".`),
|
|
541
|
+
}, withLogging("futures_getTradeHistory", config.logLevel, async ({ page, pageSize }) => {
|
|
542
|
+
const correlationId = generateCorrelationId();
|
|
543
|
+
const startTime = Date.now();
|
|
544
|
+
if (!futuresPrivateClient) {
|
|
545
|
+
metricsCollector.record("zebpay_futures_getTradeHistory", Date.now() - startTime, false, "missing_credentials");
|
|
546
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
547
|
+
}
|
|
548
|
+
try {
|
|
549
|
+
const result = await futuresPrivateClient.getTradeHistory({ page: page ? parseInt(page, 10) : undefined, pageSize: pageSize ? parseInt(pageSize, 10) : undefined });
|
|
550
|
+
const durationMs = Date.now() - startTime;
|
|
551
|
+
metricsCollector.record("zebpay_futures_getTradeHistory", durationMs, true);
|
|
552
|
+
return formatResponse(result, { toolName: "zebpay_futures_getTradeHistory", correlationId, executionTimeMs: durationMs });
|
|
553
|
+
}
|
|
554
|
+
catch (error) {
|
|
555
|
+
const durationMs = Date.now() - startTime;
|
|
556
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
557
|
+
metricsCollector.record("zebpay_futures_getTradeHistory", durationMs, false, errorType);
|
|
558
|
+
throw error;
|
|
559
|
+
}
|
|
560
|
+
}));
|
|
561
|
+
console.error("Registered tool: zebpay_futures_getTradeHistory");
|
|
562
|
+
}
|
|
563
|
+
catch (error) {
|
|
564
|
+
console.error("Error registering zebpay_futures_getTradeHistory:", error);
|
|
565
|
+
}
|
|
566
|
+
// Transaction History (GET)
|
|
567
|
+
try {
|
|
568
|
+
server.tool("zebpay_futures_getTransactionHistory", `Get futures transaction history (authentication required).
|
|
569
|
+
|
|
570
|
+
Pagination:
|
|
571
|
+
- page (1-based) and pageSize (e.g., 50, 100)
|
|
572
|
+
`, {
|
|
573
|
+
page: z.string().optional().describe(`Optional 1-based page number as string.`),
|
|
574
|
+
pageSize: z.string().optional().describe(`Optional page size as string, e.g., "50" or "100".`),
|
|
575
|
+
}, withLogging("futures_getTransactionHistory", config.logLevel, async ({ page, pageSize }) => {
|
|
576
|
+
const correlationId = generateCorrelationId();
|
|
577
|
+
const startTime = Date.now();
|
|
578
|
+
if (!futuresPrivateClient) {
|
|
579
|
+
metricsCollector.record("zebpay_futures_getTransactionHistory", Date.now() - startTime, false, "missing_credentials");
|
|
580
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
581
|
+
}
|
|
582
|
+
try {
|
|
583
|
+
const result = await futuresPrivateClient.getTransactionHistory({ page: page ? parseInt(page, 10) : undefined, pageSize: pageSize ? parseInt(pageSize, 10) : undefined });
|
|
584
|
+
const durationMs = Date.now() - startTime;
|
|
585
|
+
metricsCollector.record("zebpay_futures_getTransactionHistory", durationMs, true);
|
|
586
|
+
return formatResponse(result, { toolName: "zebpay_futures_getTransactionHistory", correlationId, executionTimeMs: durationMs });
|
|
587
|
+
}
|
|
588
|
+
catch (error) {
|
|
589
|
+
const durationMs = Date.now() - startTime;
|
|
590
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
591
|
+
metricsCollector.record("zebpay_futures_getTransactionHistory", durationMs, false, errorType);
|
|
592
|
+
throw error;
|
|
593
|
+
}
|
|
594
|
+
}));
|
|
595
|
+
console.error("Registered tool: zebpay_futures_getTransactionHistory");
|
|
596
|
+
}
|
|
597
|
+
catch (error) {
|
|
598
|
+
console.error("Error registering zebpay_futures_getTransactionHistory:", error);
|
|
599
|
+
}
|
|
600
|
+
// Delete Order (DELETE)
|
|
601
|
+
try {
|
|
602
|
+
server.tool("zebpay_futures_deleteOrder", `Cancel a futures order (authentication required).
|
|
603
|
+
|
|
604
|
+
Provide either orderId or clientOrderId.
|
|
605
|
+
`, {
|
|
606
|
+
orderId: z.string().optional().describe(`Order ID as string assigned by exchange.`),
|
|
607
|
+
clientOrderId: z.string().optional().describe(`Client-defined identifier used when placing the order.`),
|
|
608
|
+
}, withLogging("futures_deleteOrder", config.logLevel, async ({ orderId, clientOrderId }) => {
|
|
609
|
+
const correlationId = generateCorrelationId();
|
|
610
|
+
const startTime = Date.now();
|
|
611
|
+
if (!futuresPrivateClient) {
|
|
612
|
+
metricsCollector.record("zebpay_futures_deleteOrder", Date.now() - startTime, false, "missing_credentials");
|
|
613
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
614
|
+
}
|
|
615
|
+
if (!orderId && !clientOrderId) {
|
|
616
|
+
throw createInvalidParamsError("Provide either orderId or clientOrderId.", {});
|
|
617
|
+
}
|
|
618
|
+
try {
|
|
619
|
+
const result = await futuresPrivateClient.deleteOrder({ orderId, clientOrderId });
|
|
620
|
+
const durationMs = Date.now() - startTime;
|
|
621
|
+
metricsCollector.record("zebpay_futures_deleteOrder", durationMs, true);
|
|
622
|
+
return formatResponse(result, { toolName: "zebpay_futures_deleteOrder", correlationId, executionTimeMs: durationMs });
|
|
623
|
+
}
|
|
624
|
+
catch (error) {
|
|
625
|
+
const durationMs = Date.now() - startTime;
|
|
626
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
627
|
+
metricsCollector.record("zebpay_futures_deleteOrder", durationMs, false, errorType);
|
|
628
|
+
throw error;
|
|
629
|
+
}
|
|
630
|
+
}));
|
|
631
|
+
console.error("Registered tool: zebpay_futures_deleteOrder");
|
|
632
|
+
}
|
|
633
|
+
catch (error) {
|
|
634
|
+
console.error("Error registering zebpay_futures_deleteOrder:", error);
|
|
635
|
+
}
|
|
636
|
+
// Get Leverage (GET)
|
|
637
|
+
try {
|
|
638
|
+
server.tool("zebpay_futures_getUserLeverage", `Get user leverage for a symbol (authentication required).`, { symbol: z.string().min(1).describe(`Futures symbol, e.g., "BTCUSDT".`) }, withLogging("futures_getUserLeverage", config.logLevel, async ({ symbol }) => {
|
|
639
|
+
const correlationId = generateCorrelationId();
|
|
640
|
+
const startTime = Date.now();
|
|
641
|
+
if (!futuresPrivateClient) {
|
|
642
|
+
metricsCollector.record("zebpay_futures_getUserLeverage", Date.now() - startTime, false, "missing_credentials");
|
|
643
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
644
|
+
}
|
|
645
|
+
try {
|
|
646
|
+
const result = await futuresPrivateClient.getUserLeverage({ symbol });
|
|
647
|
+
const durationMs = Date.now() - startTime;
|
|
648
|
+
metricsCollector.record("zebpay_futures_getUserLeverage", durationMs, true);
|
|
649
|
+
return formatResponse(result, { toolName: "zebpay_futures_getUserLeverage", correlationId, executionTimeMs: durationMs });
|
|
650
|
+
}
|
|
651
|
+
catch (error) {
|
|
652
|
+
const durationMs = Date.now() - startTime;
|
|
653
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
654
|
+
metricsCollector.record("zebpay_futures_getUserLeverage", durationMs, false, errorType);
|
|
655
|
+
throw error;
|
|
656
|
+
}
|
|
657
|
+
}));
|
|
658
|
+
console.error("Registered tool: zebpay_futures_getUserLeverage");
|
|
659
|
+
}
|
|
660
|
+
catch (error) {
|
|
661
|
+
console.error("Error registering zebpay_futures_getUserLeverage:", error);
|
|
662
|
+
}
|
|
663
|
+
// Update User Leverage (POST)
|
|
664
|
+
try {
|
|
665
|
+
server.tool("zebpay_futures_updateUserLeverage", `Update user leverage for a symbol (authentication required).`, {
|
|
666
|
+
symbol: z.string().min(1).describe(`Futures symbol, e.g., "BTCUSDT".`),
|
|
667
|
+
leverage: z.string().describe(`Target leverage value as string, e.g., "5" or "10".`),
|
|
668
|
+
}, withLogging("futures_updateUserLeverage", config.logLevel, async ({ symbol, leverage }) => {
|
|
669
|
+
const correlationId = generateCorrelationId();
|
|
670
|
+
const startTime = Date.now();
|
|
671
|
+
if (!futuresPrivateClient) {
|
|
672
|
+
metricsCollector.record("zebpay_futures_updateUserLeverage", Date.now() - startTime, false, "missing_credentials");
|
|
673
|
+
throw createInvalidParamsError("API credentials are required for this operation.", {});
|
|
674
|
+
}
|
|
675
|
+
try {
|
|
676
|
+
const result = await futuresPrivateClient.updateUserLeverage({ symbol, leverage });
|
|
677
|
+
const durationMs = Date.now() - startTime;
|
|
678
|
+
metricsCollector.record("zebpay_futures_updateUserLeverage", durationMs, true);
|
|
679
|
+
return formatResponse(result, { toolName: "zebpay_futures_updateUserLeverage", correlationId, executionTimeMs: durationMs });
|
|
680
|
+
}
|
|
681
|
+
catch (error) {
|
|
682
|
+
const durationMs = Date.now() - startTime;
|
|
683
|
+
const errorType = error && typeof error === "object" && "code" in error ? String(error.code) : "unknown";
|
|
684
|
+
metricsCollector.record("zebpay_futures_updateUserLeverage", durationMs, false, errorType);
|
|
685
|
+
throw error;
|
|
686
|
+
}
|
|
687
|
+
}));
|
|
688
|
+
console.error("Registered tool: zebpay_futures_updateUserLeverage");
|
|
689
|
+
}
|
|
690
|
+
catch (error) {
|
|
691
|
+
console.error("Error registering zebpay_futures_updateUserLeverage:", error);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
//# sourceMappingURL=tools_futures.js.map
|