bybit-api 3.4.2 → 3.5.0-beta.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.
Files changed (105) hide show
  1. package/README.md +5 -4
  2. package/lib/account-asset-client-v3.d.ts +1 -1
  3. package/lib/account-asset-client-v3.js.map +1 -1
  4. package/lib/account-asset-client.d.ts +1 -1
  5. package/lib/account-asset-client.js.map +1 -1
  6. package/lib/constants/enum.d.ts +1 -0
  7. package/lib/constants/enum.js +1 -0
  8. package/lib/constants/enum.js.map +1 -1
  9. package/lib/contract-client.d.ts +1 -1
  10. package/lib/contract-client.js.map +1 -1
  11. package/lib/copy-trading-client.d.ts +1 -1
  12. package/lib/copy-trading-client.js.map +1 -1
  13. package/lib/index.d.ts +1 -0
  14. package/lib/index.js +1 -0
  15. package/lib/index.js.map +1 -1
  16. package/lib/inverse-client.js +1 -0
  17. package/lib/inverse-client.js.map +1 -1
  18. package/lib/inverse-futures-client.js +1 -0
  19. package/lib/inverse-futures-client.js.map +1 -1
  20. package/lib/linear-client.js +1 -0
  21. package/lib/linear-client.js.map +1 -1
  22. package/lib/rest-client-v5.d.ts +626 -0
  23. package/lib/rest-client-v5.js +801 -0
  24. package/lib/rest-client-v5.js.map +1 -0
  25. package/lib/spot-client-v3.d.ts +1 -1
  26. package/lib/spot-client-v3.js +1 -0
  27. package/lib/spot-client-v3.js.map +1 -1
  28. package/lib/spot-client.d.ts +1 -1
  29. package/lib/spot-client.js.map +1 -1
  30. package/lib/types/index.d.ts +1 -0
  31. package/lib/types/index.js +1 -0
  32. package/lib/types/index.js.map +1 -1
  33. package/lib/types/request/index.d.ts +8 -1
  34. package/lib/types/request/index.js +8 -1
  35. package/lib/types/request/index.js.map +1 -1
  36. package/lib/types/request/spot.d.ts +1 -1
  37. package/lib/types/request/v5-account.d.ts +30 -0
  38. package/lib/types/request/v5-account.js +3 -0
  39. package/lib/types/request/v5-account.js.map +1 -0
  40. package/lib/types/request/v5-asset.d.ts +120 -0
  41. package/lib/types/request/v5-asset.js +3 -0
  42. package/lib/types/request/v5-asset.js.map +1 -0
  43. package/lib/types/request/v5-market.d.ts +97 -0
  44. package/lib/types/request/v5-market.js +3 -0
  45. package/lib/types/request/v5-market.js.map +1 -0
  46. package/lib/types/request/v5-position.d.ts +78 -0
  47. package/lib/types/request/v5-position.js +3 -0
  48. package/lib/types/request/v5-position.js.map +1 -0
  49. package/lib/types/request/v5-spot-leverage-token.d.ts +20 -0
  50. package/lib/types/request/v5-spot-leverage-token.js +3 -0
  51. package/lib/types/request/v5-spot-leverage-token.js.map +1 -0
  52. package/lib/types/request/v5-trade.d.ts +91 -0
  53. package/lib/types/request/v5-trade.js +3 -0
  54. package/lib/types/request/v5-trade.js.map +1 -0
  55. package/lib/types/request/v5-user.d.ts +18 -0
  56. package/lib/types/request/v5-user.js +3 -0
  57. package/lib/types/request/v5-user.js.map +1 -0
  58. package/lib/types/response/index.d.ts +7 -0
  59. package/lib/types/response/index.js +7 -0
  60. package/lib/types/response/index.js.map +1 -1
  61. package/lib/types/response/v5-account.d.ts +101 -0
  62. package/lib/types/response/v5-account.js +3 -0
  63. package/lib/types/response/v5-account.js.map +1 -0
  64. package/lib/types/response/v5-asset.d.ts +133 -0
  65. package/lib/types/response/v5-asset.js +3 -0
  66. package/lib/types/response/v5-asset.js.map +1 -0
  67. package/lib/types/response/v5-market.d.ts +234 -0
  68. package/lib/types/response/v5-market.js +3 -0
  69. package/lib/types/response/v5-market.js.map +1 -0
  70. package/lib/types/response/v5-position.d.ts +78 -0
  71. package/lib/types/response/v5-position.js +3 -0
  72. package/lib/types/response/v5-position.js.map +1 -0
  73. package/lib/types/response/v5-spot-leverage-token.d.ts +62 -0
  74. package/lib/types/response/v5-spot-leverage-token.js +3 -0
  75. package/lib/types/response/v5-spot-leverage-token.js.map +1 -0
  76. package/lib/types/response/v5-trade.d.ts +78 -0
  77. package/lib/types/response/v5-trade.js +3 -0
  78. package/lib/types/response/v5-trade.js.map +1 -0
  79. package/lib/types/response/v5-user.d.ts +53 -0
  80. package/lib/types/response/v5-user.js +3 -0
  81. package/lib/types/response/v5-user.js.map +1 -0
  82. package/lib/types/v5-shared.d.ts +87 -0
  83. package/lib/types/v5-shared.js +3 -0
  84. package/lib/types/v5-shared.js.map +1 -0
  85. package/lib/unified-margin-client.d.ts +1 -1
  86. package/lib/unified-margin-client.js.map +1 -1
  87. package/lib/usdc-option-client.d.ts +9 -3
  88. package/lib/usdc-option-client.js +8 -2
  89. package/lib/usdc-option-client.js.map +1 -1
  90. package/lib/usdc-perpetual-client.d.ts +4 -2
  91. package/lib/usdc-perpetual-client.js +3 -1
  92. package/lib/usdc-perpetual-client.js.map +1 -1
  93. package/lib/util/BaseRestClient.js +4 -2
  94. package/lib/util/BaseRestClient.js.map +1 -1
  95. package/lib/util/WsStore.d.ts +2 -1
  96. package/lib/util/WsStore.js.map +1 -1
  97. package/lib/util/browser-support.js +2 -0
  98. package/lib/util/browser-support.js.map +1 -1
  99. package/lib/util/logger.js.map +1 -1
  100. package/lib/util/requestUtils.js +1 -0
  101. package/lib/util/requestUtils.js.map +1 -1
  102. package/lib/util/websocket-util.js +2 -2
  103. package/lib/websocket-client.js +16 -12
  104. package/lib/websocket-client.js.map +1 -1
  105. package/package.json +6 -4
@@ -0,0 +1,801 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.RestClientV5 = void 0;
16
+ const util_1 = require("./util");
17
+ const BaseRestClient_1 = __importDefault(require("./util/BaseRestClient"));
18
+ /**
19
+ * REST API client for V5 REST APIs
20
+ *
21
+ * https://bybit-exchange.github.io/docs/v5/intro
22
+ */
23
+ class RestClientV5 extends BaseRestClient_1.default {
24
+ getClientType() {
25
+ return util_1.REST_CLIENT_TYPE_ENUM.v3;
26
+ }
27
+ fetchServerTime() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const res = yield this.getServerTime();
30
+ return Number(res.time);
31
+ });
32
+ }
33
+ getServerTime() {
34
+ return this.get('/v3/public/time');
35
+ }
36
+ /**
37
+ *
38
+ ****** Market APIs
39
+ *
40
+ */
41
+ /**
42
+ * Query the kline data. Charts are returned in groups based on the requested interval.
43
+ *
44
+ * Covers: Spot / Linear contract / Inverse contract
45
+ */
46
+ getKline(params) {
47
+ return this.get('/v5/market/kline', params);
48
+ }
49
+ /**
50
+ * Query the mark price kline data. Charts are returned in groups based on the requested interval.
51
+ *
52
+ * Covers: Linear contract / Inverse contract
53
+ */
54
+ getMarkPriceKline(params) {
55
+ return this.get('/v5/market/mark-price-kline', params);
56
+ }
57
+ /**
58
+ * Query the index price kline data. Charts are returned in groups based on the requested interval.
59
+ *
60
+ * Covers: Linear contract / Inverse contract
61
+ */
62
+ getIndexPriceKline(params) {
63
+ return this.get('/v5/market/index-price-kline', params);
64
+ }
65
+ /**
66
+ * Retrieve the premium index price kline data. Charts are returned in groups based on the requested interval.
67
+ *
68
+ * Covers: Linear contract
69
+ */
70
+ getPremiumIndexPriceKline(params) {
71
+ return this.get('/v5/market/premium-index-price-kline', params);
72
+ }
73
+ /**
74
+ * Query a list of instruments of online trading pair.
75
+ *
76
+ * Covers: Spot / Linear contract / Inverse contract / Option
77
+ *
78
+ * Note: Spot does not support pagination, so limit & cursor are invalid.
79
+ */
80
+ getInstrumentsInfo(params) {
81
+ return this.get('/v5/market/instruments-info', params);
82
+ }
83
+ /**
84
+ * Query orderbook data
85
+ *
86
+ * Covers: Spot / Linear contract / Inverse contract / Option
87
+ */
88
+ getOrderbook(params) {
89
+ return this.get('/v5/market/orderbook', params);
90
+ }
91
+ /**
92
+ * Query the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.
93
+ *
94
+ * Covers: Spot / Linear contract / Inverse contract / Option
95
+ */
96
+ getTickers(params) {
97
+ return this.get('/v5/market/tickers', params);
98
+ }
99
+ /**
100
+ * Query historical funding rate. Each symbol has a different funding interval.
101
+ *
102
+ * Covers: Linear contract / Inverse perpetual
103
+ */
104
+ getFundingRateHistory(params) {
105
+ return this.get('/v5/market/funding/history', params);
106
+ }
107
+ /**
108
+ * Query recent public trading data in Bybit.
109
+ *
110
+ * Covers: Spot / Linear contract / Inverse contract / Option
111
+ */
112
+ getPublicTradingHistory(params) {
113
+ return this.get('/v5/market/recent-trade', params);
114
+ }
115
+ /**
116
+ * Get open interest of each symbol.
117
+ *
118
+ * Covers: Linear contract / Inverse contract
119
+ */
120
+ getOpenInterest(params) {
121
+ return this.get('/v5/market/open-interest', params);
122
+ }
123
+ /**
124
+ * Query option historical volatility
125
+ * Covers: Option
126
+ */
127
+ getHistoricalVolatility(params) {
128
+ return this.get('/v5/market/historical-volatility', params);
129
+ }
130
+ /**
131
+ * Query Bybit insurance pool data (BTC/USDT/USDC etc). The data is updated every 24 hours.
132
+ */
133
+ getInsurance(params) {
134
+ return this.get('/v5/market/insurance', params);
135
+ }
136
+ /**
137
+ * Query risk limit of futures
138
+ *
139
+ * Covers: Linear contract / Inverse contract
140
+ */
141
+ getRiskLimit(params) {
142
+ return this.get('/v5/market/risk-limit', params);
143
+ }
144
+ /**
145
+ * Get the delivery price for option
146
+ *
147
+ * Covers: Option
148
+ */
149
+ getOptionDeliveryPrice(params) {
150
+ return this.get('/v5/market/delivery-price', params);
151
+ }
152
+ /**
153
+ *
154
+ ****** Trade APIs
155
+ *
156
+ */
157
+ submitOrder(params) {
158
+ return this.postPrivate('/v5/order/create', params);
159
+ }
160
+ amendOrder(params) {
161
+ return this.postPrivate('/v5/order/amend', params);
162
+ }
163
+ cancelOrder(params) {
164
+ return this.postPrivate('/v5/order/cancel', params);
165
+ }
166
+ /**
167
+ * Query unfilled or partially filled orders in real-time. To query older order records, please use the order history interface.
168
+ */
169
+ getActiveOrders(params) {
170
+ return this.getPrivate('/v5/order/realtime', params);
171
+ }
172
+ cancelAllOrders(params) {
173
+ return this.postPrivate('/v5/order/cancel-all', params);
174
+ }
175
+ /**
176
+ * Query order history. As order creation/cancellation is asynchronous, the data returned from this endpoint may delay.
177
+ *
178
+ * If you want to get real-time order information, you could query this endpoint or rely on the websocket stream (recommended).
179
+ */
180
+ getHistoricOrders(params) {
181
+ return this.getPrivate('/v5/order/history', params);
182
+ }
183
+ /**
184
+ * This endpoint allows you to place more than one order in a single request. Covers: option (unified account).
185
+ *
186
+ * Make sure you have sufficient funds in your account when placing an order.
187
+ * Once an order is placed, according to the funds required by the order,
188
+ * the funds in your account will be frozen by the corresponding amount during the life cycle of the order.
189
+ *
190
+ * A maximum of 20 orders can be placed per request. The returned data list is divided into two lists.
191
+ * The first list indicates whether or not the order creation was successful and the second list details the created order information.
192
+ * The structure of the two lists are completely consistent.
193
+ */
194
+ batchSubmitOrders(category, orders) {
195
+ return this.postPrivate('/v5/order/create-batch', {
196
+ category,
197
+ request: orders,
198
+ });
199
+ }
200
+ /**
201
+ * This endpoint allows you to amend more than one open order in a single request. Covers: option (unified account).
202
+ *
203
+ * You can modify unfilled or partially filled orders. Conditional orders are not supported.
204
+ *
205
+ * A maximum of 20 orders can be amended per request.
206
+ */
207
+ batchAmendOrders(category, orders) {
208
+ return this.postPrivate('/v5/order/amend-batch', {
209
+ category,
210
+ request: orders,
211
+ });
212
+ }
213
+ /**
214
+ * This endpoint allows you to cancel more than one open order in a single request. Covers: option (unified account).
215
+ *
216
+ * You must specify orderId or orderLinkId. If orderId and orderLinkId is not matched, the system will process orderId first.
217
+ *
218
+ * You can cancel unfilled or partially filled orders. A maximum of 20 orders can be cancelled per request.
219
+ */
220
+ batchCancelOrders(category, orders) {
221
+ return this.postPrivate('/v5/order/cancel-batch', {
222
+ category,
223
+ request: orders,
224
+ });
225
+ }
226
+ /**
227
+ * Query the qty and amount of borrowable coins in spot account.
228
+ *
229
+ * Covers: Spot (Unified Account)
230
+ */
231
+ getSpotBorrowCheck(symbol, side) {
232
+ return this.getPrivate('/v5/order/spot-borrow-check', {
233
+ category: 'spot',
234
+ symbol,
235
+ side,
236
+ });
237
+ }
238
+ /**
239
+ * This endpoint allows you to set the disconnection protect time window. Covers: option (unified account).
240
+ *
241
+ * If you need to turn it on/off, you can contact your client manager for consultation and application.
242
+ * The default time window is 10 seconds.
243
+ */
244
+ setDisconnectCancelAllWindow(category, timeWindow) {
245
+ return this.postPrivate('/v5/order/disconnected-cancel-all', {
246
+ category,
247
+ timeWindow,
248
+ });
249
+ }
250
+ /**
251
+ *
252
+ ****** Position APIs
253
+ *
254
+ */
255
+ /**
256
+ * Query real-time position data, such as position size, cumulative realizedPNL.
257
+ *
258
+ * Unified account covers: Linear contract / Options
259
+ *
260
+ * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures
261
+ *
262
+ * Note: this will give a 404 error if you query the `option` category if your account is not unified
263
+ */
264
+ getPositionInfo(params) {
265
+ return this.getPrivate('/v5/position/list', params);
266
+ }
267
+ /**
268
+ * Set the leverage
269
+ *
270
+ * Unified account covers: Linear contract
271
+ *
272
+ * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures
273
+ *
274
+ * Note: Under one-way mode, buyLeverage must be the same as sellLeverage
275
+ */
276
+ setLeverage(params) {
277
+ return this.postPrivate('/v5/position/set-leverage', params);
278
+ }
279
+ /**
280
+ * Select cross margin mode or isolated margin mode.
281
+ *
282
+ * Covers: USDT perpetual (Normal account) / Inverse contract (Normal account).
283
+ *
284
+ * Switching margin modes will cause orders in progress to be cancelled.
285
+ * Please make sure that there are no open orders before you switch margin modes.
286
+ */
287
+ switchIsolatedMargin(params) {
288
+ return this.postPrivate('/v5/position/switch-isolated', params);
289
+ }
290
+ /**
291
+ * This endpoint sets the take profit/stop loss (TP/SL) mode to full or partial.
292
+ *
293
+ * Unified account covers: Linear contract; normal account covers: USDT perpetual, inverse perpetual, inverse futures.
294
+ *
295
+ * For partial TP/SL mode, you can set the TP/SL size smaller than position size.
296
+ */
297
+ setTPSLMode(params) {
298
+ return this.postPrivate('/v5/position/set-tpsl-mode', params);
299
+ }
300
+ /**
301
+ * Switches the position mode for USDT perpetual and Inverse futures.
302
+ *
303
+ * If you are in one-way Mode, you can only open one position on Buy or Sell side.
304
+ *
305
+ * If you are in hedge mode, you can open both Buy and Sell side positions simultaneously.
306
+ *
307
+ * Position mode. 0: Merged Single. 3: Both Sides.
308
+ */
309
+ switchPositionMode(params) {
310
+ return this.postPrivate('/v5/position/switch-mode', params);
311
+ }
312
+ /**
313
+ * The risk limit will limit the maximum position value you can hold under different margin requirements.
314
+ * If you want to hold a bigger position size, you need more margin.
315
+ *
316
+ * This interface can set the risk limit of a single position.
317
+ * If the order exceeds the current risk limit when placing an order, it will be rejected.
318
+ */
319
+ setRiskLimit(params) {
320
+ return this.postPrivate('/v5/position/set-risk-limit', params);
321
+ }
322
+ /**
323
+ * This endpoint allows you to set the take profit, stop loss or trailing stop for a position.
324
+ * Passing these parameters will create conditional orders by the system internally.
325
+ *
326
+ * The system will cancel these orders if the position is closed, and adjust the qty according to the size of the open position.
327
+ *
328
+ * Unified account covers: Linear contract.
329
+ * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures.
330
+ */
331
+ setTradingStop(params) {
332
+ return this.postPrivate('/v5/position/trading-stop', params);
333
+ }
334
+ /**
335
+ * This endpoint allows you to turn on/off auto-add-margin for an isolated margin position.
336
+ *
337
+ * Covers: USDT perpetual (Normal Account).
338
+ */
339
+ setAutoAddMargin(params) {
340
+ return this.postPrivate('/v5/position/set-auto-add-margin', params);
341
+ }
342
+ /**
343
+ * Query users' execution records, sorted by execTime in descending order
344
+ *
345
+ * Unified account covers: Spot / Linear contract / Options
346
+ * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures
347
+ */
348
+ getExecutionList(params) {
349
+ return this.getPrivate('/v5/execution/list', params);
350
+ }
351
+ /**
352
+ * Query user's closed profit and loss records. The results are sorted by createdTime in descending order.
353
+ *
354
+ * Unified account covers: Linear contract
355
+ * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures
356
+ */
357
+ getClosedPnL(params) {
358
+ return this.getPrivate('/v5/position/closed-pnl', params);
359
+ }
360
+ /**
361
+ *
362
+ ****** Account APIs
363
+ *
364
+ */
365
+ /**
366
+ * Obtain wallet balance, query asset information of each currency, and account risk rate information under unified margin mode.
367
+ *
368
+ * By default, currency information with assets or liabilities of 0 is not returned.
369
+ */
370
+ getWalletBalance(params) {
371
+ return this.getPrivate('/v5/account/wallet-balance', params);
372
+ }
373
+ /**
374
+ * Upgrade to unified account.
375
+ *
376
+ * Banned/OTC loan/Net asset unsatisfying/Express path users cannot upgrade the account to Unified Account for now.
377
+ */
378
+ upgradeToUnifiedAccount() {
379
+ return this.postPrivate('/v5/account/upgrade-to-uta');
380
+ }
381
+ /**
382
+ * Get interest records, sorted in reverse order of creation time.
383
+ *
384
+ * Unified account
385
+ */
386
+ getBorrowHistory(params) {
387
+ return this.getPrivate('/v5/account/borrow-history', params);
388
+ }
389
+ /**
390
+ * Get the collateral information of the current unified margin account, including loan interest rate,
391
+ * loanable amount, collateral conversion rate, whether it can be mortgaged as margin, etc.
392
+ */
393
+ getCollateralInfo(currency) {
394
+ return this.getPrivate('/v5/account/collateral-info', { currency });
395
+ }
396
+ /**
397
+ * Get current account Greeks information
398
+ */
399
+ getCoinGreeks(baseCoin) {
400
+ return this.getPrivate('/v5/asset/coin-greeks', baseCoin ? { baseCoin } : undefined);
401
+ }
402
+ /**
403
+ * Get the trading fee rate of derivatives.
404
+ * Covers: USDT perpetual / Inverse perpetual / Inverse futures
405
+ */
406
+ getFeeRate(symbol) {
407
+ return this.getPrivate('/v5/account/fee-rate', symbol ? { symbol } : undefined);
408
+ }
409
+ /**
410
+ * Query the margin mode and the upgraded status of account
411
+ */
412
+ getAccountInfo() {
413
+ return this.getPrivate('/v5/account/info');
414
+ }
415
+ /**
416
+ * Query transaction logs in Unified account.
417
+ */
418
+ getTransactionLog(params) {
419
+ return this.getPrivate('/v5/account/transaction-log', params);
420
+ }
421
+ /**
422
+ * Default is regular margin mode.
423
+ *
424
+ * This mode is valid for USDT Perp, USDC Perp and USDC Option.
425
+ */
426
+ setMarginMode(marginMode) {
427
+ return this.postPrivate('/v5/account/set-margin-mode', {
428
+ setMarginMode: marginMode,
429
+ });
430
+ }
431
+ /**
432
+ * Configure Market Maker Protection (MMP)
433
+ */
434
+ setMMP(params) {
435
+ return this.postPrivate('/v5/account/mmp-modify', params);
436
+ }
437
+ /**
438
+ * Once the mmp triggered, you can unfreeze the account via this endpoint
439
+ */
440
+ resetMMP(baseCoin) {
441
+ return this.postPrivate('/v5/account/mmp-modify', { baseCoin });
442
+ }
443
+ /**
444
+ * Get MMP State
445
+ */
446
+ getMMPState(baseCoin) {
447
+ return this.getPrivate('/v5/account/mmp-state', { baseCoin });
448
+ }
449
+ /**
450
+ *
451
+ ****** Asset APIs
452
+ *
453
+ */
454
+ /**
455
+ * Query the coin exchange records.
456
+ *
457
+ * CAUTION: You may experience long delays with this endpoint.
458
+ */
459
+ getCoinExchangeRecords(params) {
460
+ return this.getPrivate('/v5/asset/exchange/order-record', params);
461
+ }
462
+ /**
463
+ * Query option delivery records, sorted by deliveryTime in descending order.
464
+ *
465
+ * Covers: Option
466
+ */
467
+ getDeliveryRecord(params) {
468
+ return this.getPrivate('/v5/asset/delivery-record', params);
469
+ }
470
+ /**
471
+ * Query session settlement records of USDC perpetual
472
+ *
473
+ * Covers: Linear contract (USDC Perpetual only, Unified Account)
474
+ */
475
+ getSettlementRecords(params) {
476
+ return this.getPrivate('/v5/asset/settlement-record', params);
477
+ }
478
+ /**
479
+ * Query asset information.
480
+ *
481
+ * INFO
482
+ * For now, it can query SPOT only.
483
+ */
484
+ getAssetInfo(params) {
485
+ return this.getPrivate('/v5/asset/transfer/query-asset-info', params);
486
+ }
487
+ /**
488
+ * Query all coin balances of all account types under the master account and sub accounts.
489
+ *
490
+ * It is not allowed to get the master account coin balance via sub account API key.
491
+ */
492
+ getAllCoinsBalance(params) {
493
+ return this.getPrivate('/v5/asset/transfer/query-account-coins-balance', params);
494
+ }
495
+ /**
496
+ * Query the balance of a specific coin in a specific account type. Supports querying sub UID's balance.
497
+ *
498
+ * CAUTION: Can query by the master UID's api key only.
499
+ */
500
+ getCoinBalance(params) {
501
+ return this.getPrivate('/v5/asset/transfer/query-account-coin-balance', params);
502
+ }
503
+ /**
504
+ * Query the transferable coin list between each account type.
505
+ */
506
+ getTransferableCoinList(fromAccountType, toAccountType) {
507
+ return this.getPrivate('/v5/asset/transfer/query-transfer-coin-list', {
508
+ fromAccountType,
509
+ toAccountType,
510
+ });
511
+ }
512
+ /**
513
+ * Create the internal transfer between different account types under the same UID.
514
+ * Each account type has its own acceptable coins, e.g, you cannot transfer USDC from SPOT to CONTRACT.
515
+ *
516
+ * Please refer to the getTransferableCoinList() API to find out more.
517
+ */
518
+ createInternalTransfer(transferId, coin, amount, fromAccountType, toAccountType) {
519
+ return this.postPrivate('/v5/asset/transfer/inter-transfer', {
520
+ transferId,
521
+ coin,
522
+ amount,
523
+ fromAccountType,
524
+ toAccountType,
525
+ });
526
+ }
527
+ /**
528
+ * Query the internal transfer records between different account types under the same UID.
529
+ */
530
+ getInternalTransferRecords(params) {
531
+ return this.getPrivate('/v5/asset/transfer/query-inter-transfer-list', params);
532
+ }
533
+ /**
534
+ * Query the sub UIDs under a main UID
535
+ *
536
+ * CAUTION: Can query by the master UID's api key only
537
+ */
538
+ getSubUID() {
539
+ return this.getPrivate('/v5/asset/transfer/query-sub-member-list');
540
+ }
541
+ /**
542
+ * Enable Universal Transfer for Sub UID
543
+ *
544
+ * Use this endpoint to enable a subaccount to take part in a universal transfer.
545
+ * It is a one-time switch which, once thrown, enables a subaccount permanently.
546
+ * If not set, your subaccount cannot use universal transfers.
547
+ */
548
+ enableUniversalTransferForSubUIDs(subMemberIds) {
549
+ return this.postPrivate('/v5/asset/transfer/save-transfer-sub-member', {
550
+ subMemberIds,
551
+ });
552
+ }
553
+ /**
554
+ * Transfer between sub-sub or main-sub. Please make sure you have enabled universal transfer on your sub UID in advance.
555
+ */
556
+ createUniversalTransfer(params) {
557
+ return this.postPrivate('/v5/asset/transfer/universal-transfer', params);
558
+ }
559
+ /**
560
+ * Query universal transfer records
561
+ *
562
+ * CAUTION
563
+ * Can query by the master UID's API key only
564
+ */
565
+ getUniversalTransferRecords(params) {
566
+ return this.getPrivate('/v5/asset/transfer/query-universal-transfer-list', params);
567
+ }
568
+ /**
569
+ * Query allowed deposit coin information.
570
+ * To find out paired chain of coin, please refer to the coin info api.
571
+ */
572
+ getAllowedDepositCoinInfo(params) {
573
+ return this.get('/v5/asset/deposit/query-allowed-list', params);
574
+ }
575
+ /**
576
+ * Query deposit records.
577
+ *
578
+ * TIP
579
+ * endTime - startTime should be less than 30 days. Query last 30 days records by default.
580
+ *
581
+ * Can use main or sub UID api key to query deposit records respectively.
582
+ */
583
+ getDepositRecords(params) {
584
+ return this.getPrivate('/v5/asset/deposit/query-record', params);
585
+ }
586
+ /**
587
+ * Query subaccount's deposit records by MAIN UID's API key.
588
+ *
589
+ * TIP: Query deposit records of SPOT only
590
+ * endTime - startTime should be less than 30 days.
591
+ * Queries for the last 30 days worth of records by default.
592
+ */
593
+ getSubAccountDepositRecords(params) {
594
+ return this.getPrivate('/v5/asset/deposit/query-sub-member-record', params);
595
+ }
596
+ /**
597
+ * Query the deposit address information of MASTER account.
598
+ */
599
+ getMasterDepositAddress(coin, chainType) {
600
+ return this.getPrivate('/v5/asset/deposit/query-address', {
601
+ coin,
602
+ chainType,
603
+ });
604
+ }
605
+ /**
606
+ * Query the deposit address information of SUB account.
607
+ *
608
+ * CAUTION
609
+ * Can use master UID's api key only
610
+ */
611
+ querySubMemberAddress(coin, chainType, subMemberId) {
612
+ return this.getPrivate('/v5/asset/deposit/query-sub-member-address', {
613
+ coin,
614
+ chainType,
615
+ subMemberId,
616
+ });
617
+ }
618
+ /**
619
+ * Query coin information, including chain information, withdraw and deposit status.
620
+ */
621
+ getCoinInfo(coin) {
622
+ return this.getPrivate('/v5/asset/coin/query-info', coin ? { coin } : undefined);
623
+ }
624
+ /**
625
+ * Query withdrawal records.
626
+ */
627
+ getWithdrawalRecords(params) {
628
+ return this.getPrivate('/v5/asset/withdraw/query-record', params);
629
+ }
630
+ /**
631
+ * Withdraw assets from the SPOT account.
632
+ *
633
+ * CAUTION: Make sure you have whitelisted your wallet address before calling this endpoint.
634
+ *
635
+ * You can make an off-chain transfer if the target wallet address is from Bybit. This means that no blockchain fee will be charged.
636
+ */
637
+ submitWithdrawal(params) {
638
+ return this.postPrivate('/v5/asset/withdraw/create', params);
639
+ }
640
+ /**
641
+ * Cancel the withdrawal
642
+ *
643
+ * CAUTION: Can query by the master UID's api key only
644
+ */
645
+ cancelWithdrawal(id) {
646
+ return this.postPrivate('/v5/asset/withdraw/cancel', { id });
647
+ }
648
+ /**
649
+ *
650
+ ****** User APIs
651
+ *
652
+ */
653
+ /**
654
+ * Create a new sub user id. Use master user's api key only.
655
+ *
656
+ * The API key must own one of permissions will be allowed to call the following API endpoint.
657
+ *
658
+ * master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
659
+ */
660
+ createSubMember(params) {
661
+ return this.postPrivate('/v5/user/create-sub-member', params);
662
+ }
663
+ /**
664
+ * To create new API key for those newly created sub UID. Use master user's api key only.
665
+ *
666
+ * TIP
667
+ * The API key must own one of permissions will be allowed to call the following API endpoint.
668
+ * master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
669
+ */
670
+ createSubUIDAPIKey(params) {
671
+ return this.postPrivate('/v5/user/create-sub-api', params);
672
+ }
673
+ /**
674
+ * This endpoint allows you to get a list of all sub UID of master account.
675
+ */
676
+ getSubUIDList() {
677
+ return this.getPrivate('/v5/user/query-sub-members');
678
+ }
679
+ /**
680
+ * Froze sub uid. Use master user's api key only.
681
+ *
682
+ * TIP: The API key must own one of the following permissions will be allowed to call the following API endpoint.
683
+ *
684
+ * master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
685
+ */
686
+ setSubUIDFrozenState(subuid, frozen) {
687
+ return this.postPrivate('/v5/user/frozen-sub-member', { subuid, frozen });
688
+ }
689
+ /**
690
+ * Get the information of the api key. Use the api key pending to be checked to call the endpoint.
691
+ * Both master and sub user's api key are applicable.
692
+ *
693
+ * TIP: Any permission can access this endpoint.
694
+ */
695
+ getQueryApiKey() {
696
+ return this.getPrivate('/v5/user/query-api');
697
+ }
698
+ /**
699
+ * Modify the settings of a master API key. Use the API key pending to be modified to call the endpoint. Use master user's API key only.
700
+ *
701
+ * TIP: The API key must own one of the permissions to call the following API endpoint.
702
+ *
703
+ * Master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
704
+ */
705
+ updateMasterApiKey(params) {
706
+ return this.postPrivate('/v5/user/update-api', params);
707
+ }
708
+ /**
709
+ * This endpoint modifies the settings of a sub API key.
710
+ * Use the API key pending to be modified to call the endpoint.
711
+ * Only the API key that calls this interface can be modified.
712
+ *
713
+ * The API key must own "Account Transfer" permission to be allowed to call this API endpoint.
714
+ */
715
+ updateSubApiKey(params) {
716
+ return this.postPrivate('/v5/user/update-sub-api', params);
717
+ }
718
+ /**
719
+ * Delete the api key of master account. Use the api key pending to be delete to call the endpoint. Use master user's api key only.
720
+ *
721
+ * TIP: The API key must own one of permissions will be allowed to call the following API endpoint.
722
+ * master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
723
+ *
724
+ * DANGER: BE CAREFUL! The API key used to call this interface will be invalid immediately.
725
+ */
726
+ deleteMasterApiKey() {
727
+ return this.postPrivate('/v5/user/delete-api');
728
+ }
729
+ /**
730
+ * Delete the api key of sub account. Use the api key pending to be delete to call the endpoint. Use sub user's api key only.
731
+ *
732
+ * TIP
733
+ * The API key must own one of permissions will be allowed to call the following API endpoint.
734
+ * sub API key: "Account Transfer"
735
+ *
736
+ * DANGER: BE CAREFUL! The API key used to call this interface will be invalid immediately.
737
+ */
738
+ deleteSubApiKey() {
739
+ return this.postPrivate('/v5/user/delete-sub-api');
740
+ }
741
+ /**
742
+ *
743
+ ****** Spot Leverage Token APIs
744
+ *
745
+ */
746
+ /**
747
+ * Query leverage token information
748
+ */
749
+ getLeveragedTokenInfo(ltCoin) {
750
+ return this.get('/v5/spot-lever-token/info', { ltCoin });
751
+ }
752
+ /**
753
+ * Get leverage token market information.
754
+ */
755
+ getLeveragedTokenMarket(ltCoin) {
756
+ return this.get('/v5/spot-lever-token/reference', { ltCoin });
757
+ }
758
+ /**
759
+ * This endpoint allows you to purchase a leveraged token with a specified amount.
760
+ */
761
+ purchaseSpotLeveragedToken(params) {
762
+ return this.postPrivate('/v5/spot-lever-token/purchase', params);
763
+ }
764
+ /**
765
+ * Redeem leveraged token.
766
+ */
767
+ redeemSpotLeveragedToken(params) {
768
+ return this.postPrivate('/v5/spot-lever-token/redeem', params);
769
+ }
770
+ /**
771
+ * Get purchase or redemption history
772
+ */
773
+ getSpotLeveragedTokenOrderHistory(params) {
774
+ return this.getPrivate('/v5/spot-lever-token/order-record', params);
775
+ }
776
+ /**
777
+ *
778
+ ****** Spot Margin Trade APIs
779
+ *
780
+ */
781
+ /**
782
+ * Turn spot margin trade on / off.
783
+ *
784
+ * CAUTION
785
+ * Your account needs to turn on spot margin first
786
+ */
787
+ toggleSpotMarginTrade(spotMarginMode) {
788
+ return this.postPrivate('/v5/spot-margin-trade/switch-mode', {
789
+ spotMarginMode,
790
+ });
791
+ }
792
+ /**
793
+ * Set the user's maximum leverage in spot cross margin.
794
+ * CAUTION: Your account needs to enable spot margin first; i.e., you must have finished the quiz on web / app.
795
+ */
796
+ setSpotMarginLeverage(leverage) {
797
+ return this.postPrivate('/v5/spot-margin-trade/set-leverage', { leverage });
798
+ }
799
+ }
800
+ exports.RestClientV5 = RestClientV5;
801
+ //# sourceMappingURL=rest-client-v5.js.map