bybit-api 3.7.1-beta.0 → 3.7.2

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 (73) hide show
  1. package/README.md +34 -6
  2. package/lib/constants/enum.d.ts +4 -1
  3. package/lib/constants/enum.js +4 -1
  4. package/lib/constants/enum.js.map +1 -1
  5. package/lib/rest-client-v5.d.ts +3 -3
  6. package/lib/rest-client-v5.js.map +1 -1
  7. package/lib/types/request/v5-trade.d.ts +2 -2
  8. package/lib/types/response/v5-market.d.ts +4 -1
  9. package/package.json +1 -13
  10. package/src/account-asset-client-v3.ts +0 -310
  11. package/src/account-asset-client.ts +0 -149
  12. package/src/constants/enum.ts +0 -105
  13. package/src/contract-client.ts +0 -360
  14. package/src/copy-trading-client.ts +0 -159
  15. package/src/index.ts +0 -18
  16. package/src/inverse-client.ts +0 -337
  17. package/src/inverse-futures-client.ts +0 -403
  18. package/src/linear-client.ts +0 -387
  19. package/src/rest-client-v5.ts +0 -1638
  20. package/src/spot-client-v3.ts +0 -303
  21. package/src/spot-client.ts +0 -180
  22. package/src/types/index.ts +0 -5
  23. package/src/types/request/account-asset.ts +0 -258
  24. package/src/types/request/contract.ts +0 -139
  25. package/src/types/request/copy-trading.ts +0 -53
  26. package/src/types/request/index.ts +0 -18
  27. package/src/types/request/inverse.ts +0 -135
  28. package/src/types/request/linear.ts +0 -201
  29. package/src/types/request/spot.ts +0 -89
  30. package/src/types/request/unified-margin.ts +0 -247
  31. package/src/types/request/usdc-options.ts +0 -134
  32. package/src/types/request/usdc-perp.ts +0 -100
  33. package/src/types/request/usdc-shared.ts +0 -39
  34. package/src/types/request/v5-account.ts +0 -40
  35. package/src/types/request/v5-asset.ts +0 -133
  36. package/src/types/request/v5-market.ts +0 -127
  37. package/src/types/request/v5-position.ts +0 -107
  38. package/src/types/request/v5-pre-upgrade.ts +0 -37
  39. package/src/types/request/v5-spot-leverage-token.ts +0 -23
  40. package/src/types/request/v5-trade.ts +0 -133
  41. package/src/types/request/v5-user.ts +0 -21
  42. package/src/types/response/account-asset.ts +0 -236
  43. package/src/types/response/contract.ts +0 -74
  44. package/src/types/response/index.ts +0 -13
  45. package/src/types/response/shared.ts +0 -19
  46. package/src/types/response/spot.ts +0 -17
  47. package/src/types/response/unified-margin.ts +0 -71
  48. package/src/types/response/usdt-perp.ts +0 -58
  49. package/src/types/response/v5-account.ts +0 -122
  50. package/src/types/response/v5-asset.ts +0 -170
  51. package/src/types/response/v5-market.ts +0 -271
  52. package/src/types/response/v5-position.ts +0 -118
  53. package/src/types/response/v5-spot-leverage-token.ts +0 -70
  54. package/src/types/response/v5-trade.ts +0 -103
  55. package/src/types/response/v5-user.ts +0 -58
  56. package/src/types/shared.ts +0 -175
  57. package/src/types/v5-shared.ts +0 -213
  58. package/src/types/websockets.ts +0 -115
  59. package/src/types/ws-events/failed-topic-subscription-confirmation.ts +0 -6
  60. package/src/types/ws-events/succeeded-topic-subscription-confirmation.ts +0 -6
  61. package/src/types/ws-events/topic-subscription-confirmation.ts +0 -7
  62. package/src/unified-margin-client.ts +0 -400
  63. package/src/usdc-option-client.ts +0 -333
  64. package/src/usdc-perpetual-client.ts +0 -312
  65. package/src/util/BaseRestClient.ts +0 -502
  66. package/src/util/WsStore.ts +0 -160
  67. package/src/util/browser-support.ts +0 -29
  68. package/src/util/index.ts +0 -5
  69. package/src/util/logger.ts +0 -26
  70. package/src/util/node-support.ts +0 -9
  71. package/src/util/requestUtils.ts +0 -171
  72. package/src/util/websocket-util.ts +0 -550
  73. package/src/websocket-client.ts +0 -1262
@@ -1,1638 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import {
3
- APIResponseV3,
4
- APIResponseV3WithTime,
5
- AccountCoinBalanceV5,
6
- AccountInfoV5,
7
- AccountMarginModeV5,
8
- AccountOrderV5,
9
- AccountTypeV5,
10
- AddOrReduceMarginParamsV5,
11
- AddOrReduceMarginResultV5,
12
- AllCoinsBalanceV5,
13
- AllowedDepositCoinInfoV5,
14
- AmendOrderParamsV5,
15
- ApiKeyInfoV5,
16
- AssetInfoV5,
17
- BatchAmendOrderParamsV5,
18
- BatchAmendOrderResultV5,
19
- BatchCancelOrderParamsV5,
20
- BatchCancelOrderResultV5,
21
- BatchCreateOrderResultV5,
22
- BatchOrderParamsV5,
23
- BatchOrdersResponseV5,
24
- BorrowHistoryRecordV5,
25
- CancelAllOrdersParamsV5,
26
- CancelOrderParamsV5,
27
- CategoryCursorListV5,
28
- CategoryListV5,
29
- CategorySymbolListV5,
30
- CategoryV5,
31
- ClosedPnLV5,
32
- CoinExchangeRecordV5,
33
- CoinGreeksV5,
34
- CoinInfoV5,
35
- CollateralInfoV5,
36
- CreateSubApiKeyParamsV5,
37
- CreateSubApiKeyResultV5,
38
- CreateSubMemberParamsV5,
39
- CreateSubMemberResultV5,
40
- CursorListV5,
41
- DeliveryPriceV5,
42
- DeliveryRecordV5,
43
- DepositAddressResultV5,
44
- DepositRecordV5,
45
- ExecutionV5,
46
- FeeRateV5,
47
- FundingRateHistoryResponseV5,
48
- GetAccountCoinBalanceParamsV5,
49
- GetAccountHistoricOrdersPArams,
50
- GetAccountOrdersParams,
51
- GetAllCoinsBalanceParamsV5,
52
- GetAllowedDepositCoinInfoParamsV5,
53
- GetAssetInfoParamsV5,
54
- GetBorrowHistoryParamsV5,
55
- GetClosedPnLParamsV5,
56
- GetCoinExchangeRecordParamsV5,
57
- GetDeliveryPriceParamsV5,
58
- GetDeliveryRecordParamsV5,
59
- GetDepositRecordParamsV5,
60
- GetExecutionListParamsV5,
61
- GetFeeRateParamsV5,
62
- GetFundingRateHistoryParamsV5,
63
- GetHistoricalVolatilityParamsV5,
64
- GetIndexPriceKlineParamsV5,
65
- GetInstrumentsInfoParamsV5,
66
- GetInsuranceParamsV5,
67
- GetInternalDepositRecordParamsV5,
68
- GetInternalTransferParamsV5,
69
- GetKlineParamsV5,
70
- GetMarkPriceKlineParamsV5,
71
- GetOpenInterestParamsV5,
72
- GetOptionDeliveryPriceParamsV5,
73
- GetOrderbookParamsV5,
74
- GetPreUpgradeClosedPnlParamsV5,
75
- GetPreUpgradeOrderHistoryParamsV5,
76
- GetPreUpgradeTradeHistoryParamsV5,
77
- GetPremiumIndexPriceKlineParamsV5,
78
- GetPublicTradingHistoryParamsV5,
79
- GetRiskLimitParamsV5,
80
- GetSettlementRecordParamsV5,
81
- GetSpotLeveragedTokenOrderHistoryParamsV5,
82
- GetSubAccountDepositRecordParamsV5,
83
- GetTickersParamsV5,
84
- GetTransactionLogParamsV5,
85
- GetUniversalTransferRecordsParamsV5,
86
- GetWalletBalanceParamsV5,
87
- GetWithdrawalRecordsParamsV5,
88
- HistoricalVolatilityV5,
89
- InstrumentInfoResponseV5,
90
- InsuranceResponseV5,
91
- InternalDepositRecordV5,
92
- InternalTransferRecordV5,
93
- LeverageTokenInfoV5,
94
- LeveragedTokenMarketResultV5,
95
- MMPModifyParamsV5,
96
- MMPStateV5,
97
- OHLCKlineV5,
98
- OHLCVKlineV5,
99
- OpenInterestResponseV5,
100
- OptionDeliveryPriceV5,
101
- OrderParamsV5,
102
- OrderResultV5,
103
- OrderSideV5,
104
- OrderbookResponseV5,
105
- PositionInfoParamsV5,
106
- PositionV5,
107
- PublicTradeV5,
108
- PurchaseSpotLeveragedTokenParamsV5,
109
- PurchaseSpotLeveragedTokenResultV5,
110
- RedeemSpotLeveragedTokenParamsV5,
111
- RedeemSpotLeveragedTokenResultV5,
112
- RiskLimitV5,
113
- SetAutoAddMarginParamsV5,
114
- SetLeverageParamsV5,
115
- SetRiskLimitParamsV5,
116
- SetRiskLimitResultV5,
117
- SetTPSLModeParamsV5,
118
- SetTradingStopParamsV5,
119
- SettlementRecordV5,
120
- SpotBorrowCheckResultV5,
121
- SpotLeveragedTokenOrderHistoryV5,
122
- SubMemberV5,
123
- SwitchIsolatedMarginParamsV5,
124
- SwitchPositionModeParamsV5,
125
- TPSLModeV5,
126
- TickerLinearInverseV5,
127
- TickerOptionV5,
128
- TickerSpotV5,
129
- TransactionLogV5,
130
- UnifiedAccountUpgradeResultV5,
131
- UniversalTransferParamsV5,
132
- UniversalTransferRecordV5,
133
- UpdateApiKeyParamsV5,
134
- UpdateApiKeyResultV5,
135
- WalletBalanceV5,
136
- WithdrawParamsV5,
137
- WithdrawalRecordV5,
138
- } from './types';
139
- import { REST_CLIENT_TYPE_ENUM } from './util';
140
- import BaseRestClient from './util/BaseRestClient';
141
-
142
- /**
143
- * REST API client for V5 REST APIs
144
- *
145
- * https://bybit-exchange.github.io/docs/v5/intro
146
- */
147
- export class RestClientV5 extends BaseRestClient {
148
- getClientType() {
149
- return REST_CLIENT_TYPE_ENUM.v3;
150
- }
151
-
152
- async fetchServerTime(): Promise<number> {
153
- const res = await this.getServerTime();
154
- return Number(res.time) / 1000;
155
- }
156
-
157
- getServerTime(): Promise<
158
- APIResponseV3WithTime<{ timeSecond: string; timeNano: string }>
159
- > {
160
- return this.get('/v3/public/time');
161
- }
162
-
163
- /**
164
- *
165
- ****** Market APIs
166
- *
167
- */
168
-
169
- /**
170
- * Query the kline data. Charts are returned in groups based on the requested interval.
171
- *
172
- * Covers: Spot / Linear contract / Inverse contract
173
- */
174
- getKline(
175
- params: GetKlineParamsV5,
176
- ): Promise<
177
- APIResponseV3WithTime<
178
- CategorySymbolListV5<OHLCVKlineV5[], 'spot' | 'linear' | 'inverse'>
179
- >
180
- > {
181
- return this.get('/v5/market/kline', params);
182
- }
183
-
184
- /**
185
- * Query the mark price kline data. Charts are returned in groups based on the requested interval.
186
- *
187
- * Covers: Linear contract / Inverse contract
188
- */
189
- getMarkPriceKline(
190
- params: GetMarkPriceKlineParamsV5,
191
- ): Promise<
192
- APIResponseV3WithTime<
193
- CategorySymbolListV5<OHLCKlineV5[], 'linear' | 'inverse'>
194
- >
195
- > {
196
- return this.get('/v5/market/mark-price-kline', params);
197
- }
198
-
199
- /**
200
- * Query the index price kline data. Charts are returned in groups based on the requested interval.
201
- *
202
- * Covers: Linear contract / Inverse contract
203
- */
204
- getIndexPriceKline(
205
- params: GetIndexPriceKlineParamsV5,
206
- ): Promise<
207
- APIResponseV3WithTime<
208
- CategorySymbolListV5<OHLCKlineV5[], 'linear' | 'inverse'>
209
- >
210
- > {
211
- return this.get('/v5/market/index-price-kline', params);
212
- }
213
-
214
- /**
215
- * Retrieve the premium index price kline data. Charts are returned in groups based on the requested interval.
216
- *
217
- * Covers: Linear contract
218
- */
219
- getPremiumIndexPriceKline(
220
- params: GetPremiumIndexPriceKlineParamsV5,
221
- ): Promise<
222
- APIResponseV3WithTime<CategorySymbolListV5<OHLCKlineV5[], 'linear'>>
223
- > {
224
- return this.get('/v5/market/premium-index-price-kline', params);
225
- }
226
-
227
- /**
228
- * Query a list of instruments of online trading pair.
229
- *
230
- * Covers: Spot / Linear contract / Inverse contract / Option
231
- *
232
- * Note: Spot does not support pagination, so limit & cursor are invalid.
233
- */
234
- getInstrumentsInfo(
235
- params: GetInstrumentsInfoParamsV5,
236
- ): Promise<APIResponseV3WithTime<InstrumentInfoResponseV5>> {
237
- return this.get('/v5/market/instruments-info', params);
238
- }
239
-
240
- /**
241
- * Query orderbook data
242
- *
243
- * Covers: Spot / Linear contract / Inverse contract / Option
244
- */
245
- getOrderbook(
246
- params: GetOrderbookParamsV5,
247
- ): Promise<APIResponseV3WithTime<OrderbookResponseV5>> {
248
- return this.get('/v5/market/orderbook', params);
249
- }
250
-
251
- /**
252
- * Query the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.
253
- *
254
- * Covers: Spot / Linear contract / Inverse contract / Option
255
- */
256
- getTickers(
257
- params: GetTickersParamsV5,
258
- ): Promise<
259
- APIResponseV3WithTime<
260
- | CategoryListV5<TickerLinearInverseV5[], 'linear' | 'inverse'>
261
- | CategoryListV5<TickerOptionV5[], 'option'>
262
- | CategoryListV5<TickerSpotV5[], 'spot'>
263
- >
264
- > {
265
- return this.get('/v5/market/tickers', params);
266
- }
267
-
268
- /**
269
- * Query historical funding rate. Each symbol has a different funding interval.
270
- *
271
- * Covers: Linear contract / Inverse perpetual
272
- */
273
- getFundingRateHistory(
274
- params: GetFundingRateHistoryParamsV5,
275
- ): Promise<
276
- APIResponseV3WithTime<
277
- CategoryListV5<FundingRateHistoryResponseV5[], 'linear' | 'inverse'>
278
- >
279
- > {
280
- return this.get('/v5/market/funding/history', params);
281
- }
282
-
283
- /**
284
- * Query recent public trading data in Bybit.
285
- *
286
- * Covers: Spot / Linear contract / Inverse contract / Option
287
- */
288
- getPublicTradingHistory(
289
- params: GetPublicTradingHistoryParamsV5,
290
- ): Promise<
291
- APIResponseV3WithTime<CategoryListV5<PublicTradeV5[], CategoryV5>>
292
- > {
293
- return this.get('/v5/market/recent-trade', params);
294
- }
295
-
296
- /**
297
- * Get open interest of each symbol.
298
- *
299
- * Covers: Linear contract / Inverse contract
300
- */
301
- getOpenInterest(
302
- params: GetOpenInterestParamsV5,
303
- ): Promise<APIResponseV3WithTime<OpenInterestResponseV5>> {
304
- return this.get('/v5/market/open-interest', params);
305
- }
306
-
307
- /**
308
- * Query option historical volatility
309
- * Covers: Option
310
- */
311
- getHistoricalVolatility(
312
- params: GetHistoricalVolatilityParamsV5,
313
- ): Promise<
314
- APIResponseV3WithTime<CategoryListV5<HistoricalVolatilityV5[], 'option'>>
315
- > {
316
- return this.get('/v5/market/historical-volatility', params);
317
- }
318
-
319
- /**
320
- * Query Bybit insurance pool data (BTC/USDT/USDC etc). The data is updated every 24 hours.
321
- */
322
- getInsurance(
323
- params?: GetInsuranceParamsV5,
324
- ): Promise<APIResponseV3WithTime<InsuranceResponseV5>> {
325
- return this.get('/v5/market/insurance', params);
326
- }
327
-
328
- /**
329
- * Query risk limit of futures
330
- *
331
- * Covers: Linear contract / Inverse contract
332
- */
333
- getRiskLimit(
334
- params?: GetRiskLimitParamsV5,
335
- ): Promise<
336
- APIResponseV3WithTime<CategoryListV5<RiskLimitV5[], 'inverse' | 'linear'>>
337
- > {
338
- return this.get('/v5/market/risk-limit', params);
339
- }
340
-
341
- /**
342
- * Get the delivery price for option
343
- *
344
- * Covers: Option
345
- *
346
- * @deprecated use getDeliveryPrice() instead
347
- */
348
- getOptionDeliveryPrice(
349
- params: GetOptionDeliveryPriceParamsV5,
350
- ): Promise<
351
- APIResponseV3WithTime<CategoryCursorListV5<OptionDeliveryPriceV5[]>>
352
- > {
353
- return this.get('/v5/market/delivery-price', params);
354
- }
355
-
356
- /**
357
- * Get the delivery price of Inverse futures, USDC futures and Options
358
- *
359
- * Covers: USDC futures / Inverse futures / Option
360
- */
361
- getDeliveryPrice(
362
- params: GetDeliveryPriceParamsV5,
363
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<DeliveryPriceV5[]>>> {
364
- return this.get('/v5/market/delivery-price', params);
365
- }
366
-
367
- /**
368
- *
369
- ****** Trade APIs
370
- *
371
- */
372
-
373
- submitOrder(
374
- params: OrderParamsV5,
375
- ): Promise<APIResponseV3WithTime<OrderResultV5>> {
376
- return this.postPrivate('/v5/order/create', params);
377
- }
378
-
379
- amendOrder(
380
- params: AmendOrderParamsV5,
381
- ): Promise<APIResponseV3WithTime<OrderResultV5>> {
382
- return this.postPrivate('/v5/order/amend', params);
383
- }
384
-
385
- cancelOrder(
386
- params: CancelOrderParamsV5,
387
- ): Promise<APIResponseV3WithTime<OrderResultV5>> {
388
- return this.postPrivate('/v5/order/cancel', params);
389
- }
390
-
391
- /**
392
- * Query unfilled or partially filled orders in real-time. To query older order records, please use the order history interface.
393
- */
394
- getActiveOrders(
395
- params: GetAccountOrdersParams,
396
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<AccountOrderV5[]>>> {
397
- return this.getPrivate('/v5/order/realtime', params);
398
- }
399
-
400
- cancelAllOrders(
401
- params: CancelAllOrdersParamsV5,
402
- ): Promise<APIResponseV3WithTime<{ list: OrderResultV5[] }>> {
403
- return this.postPrivate('/v5/order/cancel-all', params);
404
- }
405
-
406
- /**
407
- * Query order history. As order creation/cancellation is asynchronous, the data returned from this endpoint may delay.
408
- *
409
- * If you want to get real-time order information, you could query this endpoint or rely on the websocket stream (recommended).
410
- */
411
- getHistoricOrders(
412
- params: GetAccountHistoricOrdersPArams,
413
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<AccountOrderV5[]>>> {
414
- return this.getPrivate('/v5/order/history', params);
415
- }
416
-
417
- /**
418
- * This endpoint allows you to place more than one order in a single request. Covers: option (unified account).
419
- *
420
- * Make sure you have sufficient funds in your account when placing an order.
421
- * Once an order is placed, according to the funds required by the order,
422
- * the funds in your account will be frozen by the corresponding amount during the life cycle of the order.
423
- *
424
- * A maximum of 20 orders can be placed per request. The returned data list is divided into two lists.
425
- * The first list indicates whether or not the order creation was successful and the second list details the created order information.
426
- * The structure of the two lists are completely consistent.
427
- */
428
- batchSubmitOrders(
429
- category: 'option',
430
- orders: BatchOrderParamsV5[],
431
- ): Promise<
432
- APIResponseV3WithTime<BatchOrdersResponseV5<BatchCreateOrderResultV5[]>>
433
- > {
434
- return this.postPrivate('/v5/order/create-batch', {
435
- category,
436
- request: orders,
437
- });
438
- }
439
-
440
- /**
441
- * This endpoint allows you to amend more than one open order in a single request. Covers: option (unified account).
442
- *
443
- * You can modify unfilled or partially filled orders. Conditional orders are not supported.
444
- *
445
- * A maximum of 20 orders can be amended per request.
446
- */
447
- batchAmendOrders(
448
- category: 'option',
449
- orders: BatchAmendOrderParamsV5[],
450
- ): Promise<
451
- APIResponseV3WithTime<BatchOrdersResponseV5<BatchAmendOrderResultV5[]>>
452
- > {
453
- return this.postPrivate('/v5/order/amend-batch', {
454
- category,
455
- request: orders,
456
- });
457
- }
458
-
459
- /**
460
- * This endpoint allows you to cancel more than one open order in a single request. Covers: option (unified account).
461
- *
462
- * You must specify orderId or orderLinkId. If orderId and orderLinkId is not matched, the system will process orderId first.
463
- *
464
- * You can cancel unfilled or partially filled orders. A maximum of 20 orders can be cancelled per request.
465
- */
466
- batchCancelOrders(
467
- category: 'option',
468
- orders: BatchCancelOrderParamsV5[],
469
- ): Promise<
470
- APIResponseV3WithTime<BatchOrdersResponseV5<BatchCancelOrderResultV5[]>>
471
- > {
472
- return this.postPrivate('/v5/order/cancel-batch', {
473
- category,
474
- request: orders,
475
- });
476
- }
477
-
478
- /**
479
- * Query the qty and amount of borrowable coins in spot account.
480
- *
481
- * Covers: Spot (Unified Account)
482
- */
483
- getSpotBorrowCheck(
484
- symbol: string,
485
- side: OrderSideV5,
486
- ): Promise<APIResponseV3WithTime<SpotBorrowCheckResultV5>> {
487
- return this.getPrivate('/v5/order/spot-borrow-check', {
488
- category: 'spot',
489
- symbol,
490
- side,
491
- });
492
- }
493
-
494
- /**
495
- * This endpoint allows you to set the disconnection protect time window. Covers: option (unified account).
496
- *
497
- * If you need to turn it on/off, you can contact your client manager for consultation and application.
498
- * The default time window is 10 seconds.
499
- */
500
- setDisconnectCancelAllWindow(
501
- category: 'option',
502
- timeWindow: number,
503
- ): Promise<APIResponseV3<undefined>> {
504
- return this.postPrivate('/v5/order/disconnected-cancel-all', {
505
- category,
506
- timeWindow,
507
- });
508
- }
509
-
510
- /**
511
- *
512
- ****** Position APIs
513
- *
514
- */
515
-
516
- /**
517
- * Query real-time position data, such as position size, cumulative realizedPNL.
518
- *
519
- * 0: cross margin. 1: isolated margin
520
- *
521
- * Unified account covers: Linear contract / Options
522
- *
523
- * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures
524
- *
525
- * Note: this will give a 404 error if you query the `option` category if your account is not unified
526
- */
527
- getPositionInfo(
528
- params: PositionInfoParamsV5,
529
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<PositionV5[]>>> {
530
- return this.getPrivate('/v5/position/list', params);
531
- }
532
-
533
- /**
534
- * Set the leverage
535
- *
536
- * Unified account covers: Linear contract
537
- *
538
- * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures
539
- *
540
- * Note: Under one-way mode, buyLeverage must be the same as sellLeverage
541
- */
542
- setLeverage(params: SetLeverageParamsV5): Promise<APIResponseV3WithTime<{}>> {
543
- return this.postPrivate('/v5/position/set-leverage', params);
544
- }
545
-
546
- /**
547
- * Select cross margin mode or isolated margin mode.
548
- * 0: cross margin. 1: isolated margin
549
- *
550
- * Covers: USDT perpetual (Normal account) / Inverse contract (Normal account).
551
- *
552
- * Switching margin modes will cause orders in progress to be cancelled.
553
- * Please make sure that there are no open orders before you switch margin modes.
554
- */
555
- switchIsolatedMargin(
556
- params: SwitchIsolatedMarginParamsV5,
557
- ): Promise<APIResponseV3WithTime<{}>> {
558
- return this.postPrivate('/v5/position/switch-isolated', params);
559
- }
560
-
561
- /**
562
- * This endpoint sets the take profit/stop loss (TP/SL) mode to full or partial.
563
- *
564
- * Unified account covers: Linear contract; normal account covers: USDT perpetual, inverse perpetual, inverse futures.
565
- *
566
- * For partial TP/SL mode, you can set the TP/SL size smaller than position size.
567
- */
568
- setTPSLMode(
569
- params: SetTPSLModeParamsV5,
570
- ): Promise<APIResponseV3WithTime<{ tpSlMode: TPSLModeV5 }>> {
571
- return this.postPrivate('/v5/position/set-tpsl-mode', params);
572
- }
573
-
574
- /**
575
- * Switches the position mode for USDT perpetual and Inverse futures.
576
- *
577
- * If you are in one-way Mode, you can only open one position on Buy or Sell side.
578
- *
579
- * If you are in hedge mode, you can open both Buy and Sell side positions simultaneously.
580
- *
581
- * Position mode. 0: Merged Single. 3: Both Sides.
582
- */
583
- switchPositionMode(
584
- params: SwitchPositionModeParamsV5,
585
- ): Promise<APIResponseV3WithTime<{}>> {
586
- return this.postPrivate('/v5/position/switch-mode', params);
587
- }
588
-
589
- /**
590
- * The risk limit will limit the maximum position value you can hold under different margin requirements.
591
- * If you want to hold a bigger position size, you need more margin.
592
- *
593
- * This interface can set the risk limit of a single position.
594
- * If the order exceeds the current risk limit when placing an order, it will be rejected.
595
- */
596
- setRiskLimit(
597
- params: SetRiskLimitParamsV5,
598
- ): Promise<APIResponseV3WithTime<SetRiskLimitResultV5>> {
599
- return this.postPrivate('/v5/position/set-risk-limit', params);
600
- }
601
-
602
- /**
603
- * This endpoint allows you to set the take profit, stop loss or trailing stop for a position.
604
- * Passing these parameters will create conditional orders by the system internally.
605
- *
606
- * The system will cancel these orders if the position is closed, and adjust the qty according to the size of the open position.
607
- *
608
- * Unified account covers: Linear contract.
609
- * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures.
610
- */
611
- setTradingStop(
612
- params: SetTradingStopParamsV5,
613
- ): Promise<APIResponseV3WithTime<{}>> {
614
- return this.postPrivate('/v5/position/trading-stop', params);
615
- }
616
-
617
- /**
618
- * This endpoint allows you to turn on/off auto-add-margin for an isolated margin position.
619
- *
620
- * Covers: USDT perpetual (Normal Account).
621
- */
622
- setAutoAddMargin(
623
- params: SetAutoAddMarginParamsV5,
624
- ): Promise<APIResponseV3WithTime<{}>> {
625
- return this.postPrivate('/v5/position/set-auto-add-margin', params);
626
- }
627
-
628
- /**
629
- * Manually add or reduce margin for isolated margin position
630
- *
631
- * Unified account covers: USDT perpetual / USDC perpetual / USDC futures / Inverse contract
632
- * Normal account covers: USDT perpetual / Inverse contract
633
- */
634
- addOrReduceMargin(
635
- params: AddOrReduceMarginParamsV5,
636
- ): Promise<APIResponseV3WithTime<AddOrReduceMarginResultV5>> {
637
- return this.postPrivate('/v5/position/add-margin', params);
638
- }
639
-
640
- /**
641
- * Query users' execution records, sorted by execTime in descending order
642
- *
643
- * Unified account covers: Spot / Linear contract / Options
644
- * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures
645
- */
646
- getExecutionList(
647
- params: GetExecutionListParamsV5,
648
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<ExecutionV5[]>>> {
649
- return this.getPrivate('/v5/execution/list', params);
650
- }
651
-
652
- /**
653
- * Query user's closed profit and loss records. The results are sorted by createdTime in descending order.
654
- *
655
- * Unified account covers: Linear contract
656
- * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures
657
- */
658
- getClosedPnL(
659
- params: GetClosedPnLParamsV5,
660
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<ClosedPnLV5[]>>> {
661
- return this.getPrivate('/v5/position/closed-pnl', params);
662
- }
663
-
664
- /**
665
- *
666
- ****** Pre-upgrade APIs
667
- *
668
- */
669
-
670
- /**
671
- * Get those orders which occurred before you upgrade the account to Unified account.
672
- *
673
- * For now, it only supports to query USDT perpetual, USDC perpetual, Inverse perpetual and futures.
674
- *
675
- * - can get all status in 7 days
676
- * - can only get filled orders beyond 7 days
677
- */
678
- getPreUpgradeOrderHistory(
679
- params: GetPreUpgradeOrderHistoryParamsV5,
680
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<AccountOrderV5[]>>> {
681
- return this.getPrivate('/v5/pre-upgrade/order/history', params);
682
- }
683
-
684
- /**
685
- * Get users' execution records which occurred before you upgrade the account to Unified account, sorted by execTime in descending order
686
- *
687
- * For now, it only supports to query USDT perpetual, Inverse perpetual and futures.
688
- *
689
- * - You may have multiple executions in a single order.
690
- * - You can query by symbol, baseCoin, orderId and orderLinkId, and if you pass multiple params,
691
- * the system will process them according to this priority: orderId > orderLinkId > symbol > baseCoin.
692
- */
693
- getPreUpgradeTradeHistory(
694
- params: GetPreUpgradeTradeHistoryParamsV5,
695
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<ExecutionV5[]>>> {
696
- return this.getPrivate('/v5/pre-upgrade/execution/list', params);
697
- }
698
-
699
- /**
700
- * Query user's closed profit and loss records. The results are sorted by createdTime in descending order.
701
- *
702
- * For now, it only supports to query USDT perpetual, Inverse perpetual and futures.
703
- */
704
- getPreUpgradeClosedPnl(
705
- params: GetPreUpgradeClosedPnlParamsV5,
706
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<ClosedPnLV5[]>>> {
707
- return this.getPrivate('/v5/pre-upgrade/position/closed-pnl', params);
708
- }
709
-
710
- /**
711
- *
712
- ****** Account APIs
713
- *
714
- */
715
-
716
- /**
717
- * Obtain wallet balance, query asset information of each currency, and account risk rate information under unified margin mode.
718
- *
719
- * By default, currency information with assets or liabilities of 0 is not returned.
720
- */
721
- getWalletBalance(
722
- params: GetWalletBalanceParamsV5,
723
- ): Promise<APIResponseV3WithTime<{ list: WalletBalanceV5[] }>> {
724
- return this.getPrivate('/v5/account/wallet-balance', params);
725
- }
726
-
727
- /**
728
- * Upgrade to unified account.
729
- *
730
- * Banned/OTC loan/Net asset unsatisfying/Express path users cannot upgrade the account to Unified Account for now.
731
- */
732
- upgradeToUnifiedAccount(): Promise<
733
- APIResponseV3WithTime<UnifiedAccountUpgradeResultV5>
734
- > {
735
- return this.postPrivate('/v5/account/upgrade-to-uta');
736
- }
737
-
738
- /**
739
- * Get interest records, sorted in reverse order of creation time.
740
- *
741
- * Unified account
742
- */
743
- getBorrowHistory(
744
- params?: GetBorrowHistoryParamsV5,
745
- ): Promise<APIResponseV3WithTime<CursorListV5<BorrowHistoryRecordV5[]>>> {
746
- return this.getPrivate('/v5/account/borrow-history', params);
747
- }
748
-
749
- /**
750
- * Get the collateral information of the current unified margin account, including loan interest rate,
751
- * loanable amount, collateral conversion rate, whether it can be mortgaged as margin, etc.
752
- */
753
- getCollateralInfo(
754
- currency?: string,
755
- ): Promise<APIResponseV3WithTime<{ list: CollateralInfoV5[] }>> {
756
- return this.getPrivate('/v5/account/collateral-info', { currency });
757
- }
758
-
759
- /**
760
- * Get current account Greeks information
761
- */
762
- getCoinGreeks(
763
- baseCoin?: string,
764
- ): Promise<APIResponseV3WithTime<{ list: CoinGreeksV5[] }>> {
765
- return this.getPrivate(
766
- '/v5/asset/coin-greeks',
767
- baseCoin ? { baseCoin } : undefined,
768
- );
769
- }
770
-
771
- /**
772
- * Get the trading fee rate.
773
- * Covers: Spot / USDT perpetual / Inverse perpetual / Inverse futures / Options
774
- */
775
- getFeeRate(
776
- params: GetFeeRateParamsV5,
777
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<FeeRateV5[]>>> {
778
- return this.getPrivate('/v5/account/fee-rate', params);
779
- }
780
-
781
- /**
782
- * Query the margin mode and the upgraded status of account
783
- */
784
- getAccountInfo(): Promise<APIResponseV3<AccountInfoV5>> {
785
- return this.getPrivate('/v5/account/info');
786
- }
787
-
788
- /**
789
- * Query transaction logs in Unified account.
790
- */
791
- getTransactionLog(
792
- params?: GetTransactionLogParamsV5,
793
- ): Promise<APIResponseV3WithTime<CursorListV5<TransactionLogV5[]>>> {
794
- return this.getPrivate('/v5/account/transaction-log', params);
795
- }
796
-
797
- /**
798
- * Default is regular margin mode.
799
- *
800
- * This mode is valid for USDT Perp, USDC Perp and USDC Option.
801
- */
802
- setMarginMode(
803
- marginMode: AccountMarginModeV5,
804
- ): Promise<
805
- APIResponseV3<{ reasons: { reasonCode: string; reasonMsg: string }[] }>
806
- > {
807
- return this.postPrivate('/v5/account/set-margin-mode', {
808
- setMarginMode: marginMode,
809
- });
810
- }
811
-
812
- /**
813
- * Configure Market Maker Protection (MMP)
814
- */
815
- setMMP(params: MMPModifyParamsV5): Promise<APIResponseV3<undefined>> {
816
- return this.postPrivate('/v5/account/mmp-modify', params);
817
- }
818
-
819
- /**
820
- * Once the mmp triggered, you can unfreeze the account via this endpoint
821
- */
822
- resetMMP(baseCoin: string): Promise<APIResponseV3<undefined>> {
823
- return this.postPrivate('/v5/account/mmp-reset', { baseCoin });
824
- }
825
-
826
- /**
827
- * Get MMP State
828
- */
829
- getMMPState(
830
- baseCoin: string,
831
- ): Promise<APIResponseV3WithTime<{ result: MMPStateV5[] }>> {
832
- return this.getPrivate('/v5/account/mmp-state', { baseCoin });
833
- }
834
-
835
- /**
836
- *
837
- ****** Asset APIs
838
- *
839
- */
840
-
841
- /**
842
- * Query the coin exchange records.
843
- *
844
- * CAUTION: You may experience long delays with this endpoint.
845
- */
846
- getCoinExchangeRecords(params?: GetCoinExchangeRecordParamsV5): Promise<
847
- APIResponseV3WithTime<{
848
- orderBody: CoinExchangeRecordV5[];
849
- nextPageCursor?: string;
850
- }>
851
- > {
852
- return this.getPrivate('/v5/asset/exchange/order-record', params);
853
- }
854
-
855
- /**
856
- * Query option delivery records, sorted by deliveryTime in descending order.
857
- *
858
- * Covers: Option
859
- */
860
- getDeliveryRecord(
861
- params: GetDeliveryRecordParamsV5,
862
- ): Promise<APIResponseV3WithTime<CategoryCursorListV5<DeliveryRecordV5[]>>> {
863
- return this.getPrivate('/v5/asset/delivery-record', params);
864
- }
865
-
866
- /**
867
- * Query session settlement records of USDC perpetual
868
- *
869
- * Covers: Linear contract (USDC Perpetual only, Unified Account)
870
- */
871
- getSettlementRecords(
872
- params: GetSettlementRecordParamsV5,
873
- ): Promise<
874
- APIResponseV3WithTime<CategoryCursorListV5<SettlementRecordV5[]>>
875
- > {
876
- return this.getPrivate('/v5/asset/settlement-record', params);
877
- }
878
-
879
- /**
880
- * Query asset information.
881
- *
882
- * INFO
883
- * For now, it can query SPOT only.
884
- */
885
- getAssetInfo(
886
- params: GetAssetInfoParamsV5,
887
- ): Promise<APIResponseV3WithTime<{ spot: AssetInfoV5 }>> {
888
- return this.getPrivate('/v5/asset/transfer/query-asset-info', params);
889
- }
890
-
891
- /**
892
- * Query all coin balances of all account types under the master account and sub accounts.
893
- *
894
- * It is not allowed to get the master account coin balance via sub account API key.
895
- */
896
- getAllCoinsBalance(
897
- params: GetAllCoinsBalanceParamsV5,
898
- ): Promise<APIResponseV3WithTime<AllCoinsBalanceV5>> {
899
- return this.getPrivate(
900
- '/v5/asset/transfer/query-account-coins-balance',
901
- params,
902
- );
903
- }
904
-
905
- /**
906
- * Query the balance of a specific coin in a specific account type. Supports querying sub UID's balance.
907
- *
908
- * CAUTION: Can query by the master UID's api key only.
909
- */
910
- getCoinBalance(
911
- params: GetAccountCoinBalanceParamsV5,
912
- ): Promise<APIResponseV3<AccountCoinBalanceV5>> {
913
- return this.getPrivate(
914
- '/v5/asset/transfer/query-account-coin-balance',
915
- params,
916
- );
917
- }
918
-
919
- /**
920
- * Query the transferable coin list between each account type.
921
- */
922
- getTransferableCoinList(
923
- fromAccountType: AccountTypeV5,
924
- toAccountType: AccountTypeV5,
925
- ): Promise<APIResponseV3WithTime<{ list: string[] }>> {
926
- return this.getPrivate('/v5/asset/transfer/query-transfer-coin-list', {
927
- fromAccountType,
928
- toAccountType,
929
- });
930
- }
931
-
932
- /**
933
- * Create the internal transfer between different account types under the same UID.
934
- * Each account type has its own acceptable coins, e.g, you cannot transfer USDC from SPOT to CONTRACT.
935
- *
936
- * Please refer to the getTransferableCoinList() API to find out more.
937
- */
938
- createInternalTransfer(
939
- transferId: string,
940
- coin: string,
941
- amount: string,
942
- fromAccountType: AccountTypeV5,
943
- toAccountType: AccountTypeV5,
944
- ): Promise<APIResponseV3WithTime<{ transferId: string }>> {
945
- return this.postPrivate('/v5/asset/transfer/inter-transfer', {
946
- transferId,
947
- coin,
948
- amount,
949
- fromAccountType,
950
- toAccountType,
951
- });
952
- }
953
-
954
- /**
955
- * Query the internal transfer records between different account types under the same UID.
956
- */
957
- getInternalTransferRecords(
958
- params?: GetInternalTransferParamsV5,
959
- ): Promise<APIResponseV3WithTime<CursorListV5<InternalTransferRecordV5[]>>> {
960
- return this.getPrivate(
961
- '/v5/asset/transfer/query-inter-transfer-list',
962
- params,
963
- );
964
- }
965
-
966
- /**
967
- * Query the sub UIDs under a main UID
968
- *
969
- * CAUTION: Can query by the master UID's api key only
970
- */
971
- getSubUID(): Promise<
972
- APIResponseV3WithTime<{
973
- subMemberIds: string[];
974
- transferableSubMemberIds: string[];
975
- }>
976
- > {
977
- return this.getPrivate('/v5/asset/transfer/query-sub-member-list');
978
- }
979
-
980
- /**
981
- * Enable Universal Transfer for Sub UID
982
- *
983
- * Use this endpoint to enable a subaccount to take part in a universal transfer.
984
- * It is a one-time switch which, once thrown, enables a subaccount permanently.
985
- * If not set, your subaccount cannot use universal transfers.
986
- */
987
- enableUniversalTransferForSubUIDs(
988
- subMemberIds: string[],
989
- ): Promise<APIResponseV3WithTime<{}>> {
990
- return this.postPrivate('/v5/asset/transfer/save-transfer-sub-member', {
991
- subMemberIds,
992
- });
993
- }
994
-
995
- /**
996
- * Transfer between sub-sub or main-sub. Please make sure you have enabled universal transfer on your sub UID in advance.
997
- */
998
- createUniversalTransfer(
999
- params: UniversalTransferParamsV5,
1000
- ): Promise<APIResponseV3WithTime<{ transferId: string }>> {
1001
- return this.postPrivate('/v5/asset/transfer/universal-transfer', params);
1002
- }
1003
-
1004
- /**
1005
- * Query universal transfer records
1006
- *
1007
- * CAUTION
1008
- * Can query by the master UID's API key only
1009
- */
1010
- getUniversalTransferRecords(
1011
- params?: GetUniversalTransferRecordsParamsV5,
1012
- ): Promise<APIResponseV3WithTime<CursorListV5<UniversalTransferRecordV5[]>>> {
1013
- return this.getPrivate(
1014
- '/v5/asset/transfer/query-universal-transfer-list',
1015
- params,
1016
- );
1017
- }
1018
-
1019
- /**
1020
- * Query allowed deposit coin information.
1021
- * To find out paired chain of coin, please refer to the coin info api.
1022
- */
1023
- getAllowedDepositCoinInfo(
1024
- params?: GetAllowedDepositCoinInfoParamsV5,
1025
- ): Promise<
1026
- APIResponseV3WithTime<{
1027
- configList: AllowedDepositCoinInfoV5[];
1028
- nextPageCursor: string;
1029
- }>
1030
- > {
1031
- return this.get('/v5/asset/deposit/query-allowed-list', params);
1032
- }
1033
-
1034
- /**
1035
- * Set auto transfer account after deposit. The same function as the setting for Deposit on web GUI
1036
- */
1037
- setDepositAccount(params: { accountType: AccountTypeV5 }): Promise<
1038
- APIResponseV3WithTime<{
1039
- status: 0 | 1;
1040
- }>
1041
- > {
1042
- return this.postPrivate('/v5/asset/deposit/deposit-to-account', params);
1043
- }
1044
-
1045
- /**
1046
- * Query deposit records.
1047
- *
1048
- * TIP
1049
- * endTime - startTime should be less than 30 days. Query last 30 days records by default.
1050
- *
1051
- * Can use main or sub UID api key to query deposit records respectively.
1052
- */
1053
- getDepositRecords(
1054
- params?: GetDepositRecordParamsV5,
1055
- ): Promise<
1056
- APIResponseV3WithTime<{ rows: DepositRecordV5[]; nextPageCursor: string }>
1057
- > {
1058
- return this.getPrivate('/v5/asset/deposit/query-record', params);
1059
- }
1060
-
1061
- /**
1062
- * Query subaccount's deposit records by MAIN UID's API key.
1063
- *
1064
- * TIP: Query deposit records of SPOT only
1065
- * endTime - startTime should be less than 30 days.
1066
- * Queries for the last 30 days worth of records by default.
1067
- */
1068
- getSubAccountDepositRecords(
1069
- params: GetSubAccountDepositRecordParamsV5,
1070
- ): Promise<
1071
- APIResponseV3WithTime<{ rows: DepositRecordV5[]; nextPageCursor: string }>
1072
- > {
1073
- return this.getPrivate('/v5/asset/deposit/query-sub-member-record', params);
1074
- }
1075
-
1076
- /**
1077
- * Get Internal Deposit Records (across Bybit)
1078
- * Query deposit records through Bybit platform
1079
- *
1080
- * RULES
1081
- * The maximum difference between the start time and the end time is 30 days.
1082
- * Support to get deposit records by Master or Sub Member Api Key
1083
- */
1084
- getInternalDepositRecords(params?: GetInternalDepositRecordParamsV5): Promise<
1085
- APIResponseV3WithTime<{
1086
- rows: InternalDepositRecordV5[];
1087
- nextPageCursor: string;
1088
- }>
1089
- > {
1090
- return this.getPrivate('/v5/asset/deposit/query-internal-record', params);
1091
- }
1092
-
1093
- /**
1094
- * Query the deposit address information of MASTER account.
1095
- */
1096
- getMasterDepositAddress(
1097
- coin: string,
1098
- chainType?: string,
1099
- ): Promise<APIResponseV3WithTime<DepositAddressResultV5>> {
1100
- return this.getPrivate('/v5/asset/deposit/query-address', {
1101
- coin,
1102
- chainType,
1103
- });
1104
- }
1105
-
1106
- /**
1107
- * Query the deposit address information of SUB account.
1108
- */
1109
- getSubDepositAddress(
1110
- coin: string,
1111
- chainType: string,
1112
- subMemberId: string,
1113
- ): Promise<APIResponseV3WithTime<DepositAddressResultV5>> {
1114
- return this.getPrivate('/v5/asset/deposit/query-sub-member-address', {
1115
- coin,
1116
- chainType,
1117
- subMemberId,
1118
- });
1119
- }
1120
-
1121
- /**
1122
- * Query the deposit address information of SUB account.
1123
- *
1124
- * CAUTION
1125
- * Can use master UID's api key only
1126
- */
1127
- querySubMemberAddress(
1128
- coin: string,
1129
- chainType: string,
1130
- subMemberId: string,
1131
- ): Promise<APIResponseV3<DepositAddressResultV5>> {
1132
- return this.getPrivate('/v5/asset/deposit/query-sub-member-address', {
1133
- coin,
1134
- chainType,
1135
- subMemberId,
1136
- });
1137
- }
1138
-
1139
- /**
1140
- * Query coin information, including chain information, withdraw and deposit status.
1141
- */
1142
- getCoinInfo(
1143
- coin?: string,
1144
- ): Promise<APIResponseV3WithTime<{ rows: CoinInfoV5[] }>> {
1145
- return this.getPrivate(
1146
- '/v5/asset/coin/query-info',
1147
- coin ? { coin } : undefined,
1148
- );
1149
- }
1150
-
1151
- /**
1152
- * Query withdrawal records.
1153
- */
1154
- getWithdrawalRecords(
1155
- params?: GetWithdrawalRecordsParamsV5,
1156
- ): Promise<APIResponseV3<{ rows: WithdrawalRecordV5[] }>> {
1157
- return this.getPrivate('/v5/asset/withdraw/query-record', params);
1158
- }
1159
-
1160
- /**
1161
- * Query withdrawable amount.
1162
- */
1163
- getWithdrawableAmount(params: {
1164
- coin: string;
1165
- }): Promise<APIResponseV3<{ rows: WithdrawalRecordV5[] }>> {
1166
- return this.getPrivate('/v5/asset/withdraw/withdrawable-amount', params);
1167
- }
1168
-
1169
- /**
1170
- * Withdraw assets from the SPOT account.
1171
- *
1172
- * CAUTION: Make sure you have whitelisted your wallet address before calling this endpoint.
1173
- *
1174
- * You can make an off-chain transfer if the target wallet address is from Bybit. This means that no blockchain fee will be charged.
1175
- */
1176
- submitWithdrawal(
1177
- params: WithdrawParamsV5,
1178
- ): Promise<APIResponseV3WithTime<{ id: string }>> {
1179
- return this.postPrivate('/v5/asset/withdraw/create', params);
1180
- }
1181
-
1182
- /**
1183
- * Cancel the withdrawal
1184
- *
1185
- * CAUTION: Can query by the master UID's api key only
1186
- */
1187
- cancelWithdrawal(
1188
- id: string,
1189
- ): Promise<APIResponseV3WithTime<{ status: 0 | 1 }>> {
1190
- return this.postPrivate('/v5/asset/withdraw/cancel', { id });
1191
- }
1192
-
1193
- /**
1194
- *
1195
- ****** User APIs
1196
- *
1197
- */
1198
-
1199
- /**
1200
- * Create a new sub user id. Use master user's api key only.
1201
- *
1202
- * The API key must own one of permissions will be allowed to call the following API endpoint.
1203
- *
1204
- * master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
1205
- */
1206
- createSubMember(
1207
- params: CreateSubMemberParamsV5,
1208
- ): Promise<APIResponseV3WithTime<CreateSubMemberResultV5>> {
1209
- return this.postPrivate('/v5/user/create-sub-member', params);
1210
- }
1211
-
1212
- /**
1213
- * To create new API key for those newly created sub UID. Use master user's api key only.
1214
- *
1215
- * TIP
1216
- * The API key must own one of permissions will be allowed to call the following API endpoint.
1217
- * master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
1218
- */
1219
- createSubUIDAPIKey(
1220
- params: CreateSubApiKeyParamsV5,
1221
- ): Promise<APIResponseV3WithTime<CreateSubApiKeyResultV5>> {
1222
- return this.postPrivate('/v5/user/create-sub-api', params);
1223
- }
1224
-
1225
- /**
1226
- * This endpoint allows you to get a list of all sub UID of master account.
1227
- */
1228
- getSubUIDList(): Promise<
1229
- APIResponseV3WithTime<{ subMembers: SubMemberV5[] }>
1230
- > {
1231
- return this.getPrivate('/v5/user/query-sub-members');
1232
- }
1233
-
1234
- /**
1235
- * Froze sub uid. Use master user's api key only.
1236
- *
1237
- * TIP: The API key must own one of the following permissions will be allowed to call the following API endpoint.
1238
- *
1239
- * master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
1240
- */
1241
- setSubUIDFrozenState(
1242
- subuid: number,
1243
- frozen: 0 | 1,
1244
- ): Promise<APIResponseV3WithTime<{}>> {
1245
- return this.postPrivate('/v5/user/frozen-sub-member', { subuid, frozen });
1246
- }
1247
-
1248
- /**
1249
- * Get the information of the api key. Use the api key pending to be checked to call the endpoint.
1250
- * Both master and sub user's api key are applicable.
1251
- *
1252
- * TIP: Any permission can access this endpoint.
1253
- */
1254
- getQueryApiKey(): Promise<APIResponseV3WithTime<ApiKeyInfoV5>> {
1255
- return this.getPrivate('/v5/user/query-api');
1256
- }
1257
-
1258
- /**
1259
- * 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.
1260
- *
1261
- * TIP: The API key must own one of the permissions to call the following API endpoint.
1262
- *
1263
- * Master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
1264
- */
1265
- updateMasterApiKey(
1266
- params: UpdateApiKeyParamsV5,
1267
- ): Promise<APIResponseV3WithTime<UpdateApiKeyResultV5>> {
1268
- return this.postPrivate('/v5/user/update-api', params);
1269
- }
1270
-
1271
- /**
1272
- * This endpoint modifies the settings of a sub API key.
1273
- * Use the API key pending to be modified to call the endpoint.
1274
- * Only the API key that calls this interface can be modified.
1275
- *
1276
- * The API key must own "Account Transfer" permission to be allowed to call this API endpoint.
1277
- */
1278
- updateSubApiKey(
1279
- params: UpdateApiKeyParamsV5,
1280
- ): Promise<APIResponseV3<UpdateApiKeyResultV5>> {
1281
- return this.postPrivate('/v5/user/update-sub-api', params);
1282
- }
1283
-
1284
- /**
1285
- * 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.
1286
- *
1287
- * TIP: The API key must own one of permissions will be allowed to call the following API endpoint.
1288
- * master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
1289
- *
1290
- * DANGER: BE CAREFUL! The API key used to call this interface will be invalid immediately.
1291
- */
1292
- deleteMasterApiKey(): Promise<APIResponseV3WithTime<{}>> {
1293
- return this.postPrivate('/v5/user/delete-api');
1294
- }
1295
-
1296
- /**
1297
- * 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.
1298
- *
1299
- * TIP
1300
- * The API key must own one of permissions will be allowed to call the following API endpoint.
1301
- * sub API key: "Account Transfer"
1302
- *
1303
- * DANGER: BE CAREFUL! The API key used to call this interface will be invalid immediately.
1304
- */
1305
- deleteSubApiKey(): Promise<APIResponseV3WithTime<{}>> {
1306
- return this.postPrivate('/v5/user/delete-sub-api');
1307
- }
1308
-
1309
- /**
1310
- *
1311
- ****** Spot Leverage Token APIs
1312
- *
1313
- */
1314
-
1315
- /**
1316
- * Query leverage token information
1317
- */
1318
- getLeveragedTokenInfo(
1319
- ltCoin?: string,
1320
- ): Promise<APIResponseV3WithTime<{ list: LeverageTokenInfoV5[] }>> {
1321
- return this.get('/v5/spot-lever-token/info', { ltCoin });
1322
- }
1323
-
1324
- /**
1325
- * Get leverage token market information.
1326
- */
1327
- getLeveragedTokenMarket(
1328
- ltCoin: string,
1329
- ): Promise<APIResponseV3WithTime<LeveragedTokenMarketResultV5>> {
1330
- return this.get('/v5/spot-lever-token/reference', { ltCoin });
1331
- }
1332
-
1333
- /**
1334
- * This endpoint allows you to purchase a leveraged token with a specified amount.
1335
- */
1336
- purchaseSpotLeveragedToken(
1337
- params: PurchaseSpotLeveragedTokenParamsV5,
1338
- ): Promise<APIResponseV3WithTime<PurchaseSpotLeveragedTokenResultV5>> {
1339
- return this.postPrivate('/v5/spot-lever-token/purchase', params);
1340
- }
1341
-
1342
- /**
1343
- * Redeem leveraged token.
1344
- */
1345
- redeemSpotLeveragedToken(
1346
- params: RedeemSpotLeveragedTokenParamsV5,
1347
- ): Promise<APIResponseV3WithTime<RedeemSpotLeveragedTokenResultV5>> {
1348
- return this.postPrivate('/v5/spot-lever-token/redeem', params);
1349
- }
1350
-
1351
- /**
1352
- * Get purchase or redemption history
1353
- */
1354
- getSpotLeveragedTokenOrderHistory(
1355
- params?: GetSpotLeveragedTokenOrderHistoryParamsV5,
1356
- ): Promise<
1357
- APIResponseV3WithTime<{ list: SpotLeveragedTokenOrderHistoryV5[] }>
1358
- > {
1359
- return this.getPrivate('/v5/spot-lever-token/order-record', params);
1360
- }
1361
-
1362
- /**
1363
- *
1364
- ****** Spot Margin Trade APIs (UTA)
1365
- *
1366
- */
1367
-
1368
- /**
1369
- * Turn spot margin trade on / off in your UTA account.
1370
- *
1371
- * CAUTION
1372
- * Your account needs to turn on spot margin first.
1373
- */
1374
- toggleSpotMarginTrade(
1375
- spotMarginMode: '1' | '0',
1376
- ): Promise<APIResponseV3WithTime<{ spotMarginMode: '1' | '0' }>> {
1377
- return this.postPrivate('/v5/spot-margin-trade/switch-mode', {
1378
- spotMarginMode,
1379
- });
1380
- }
1381
-
1382
- /**
1383
- * Set the user's maximum leverage in spot cross margin.
1384
- * CAUTION: Your account needs to enable spot margin first; i.e., you must have finished the quiz on web / app.
1385
- */
1386
- setSpotMarginLeverage(leverage: string): Promise<APIResponseV3WithTime<{}>> {
1387
- return this.postPrivate('/v5/spot-margin-trade/set-leverage', { leverage });
1388
- }
1389
-
1390
- /**
1391
- *
1392
- ****** Spot Margin Trade APIs (Normal)
1393
- *
1394
- */
1395
-
1396
- /**
1397
- * Get Margin Coin Info
1398
- */
1399
- getSpotMarginCoinInfo(coin?: string): Promise<
1400
- APIResponseV3WithTime<{
1401
- list: {
1402
- coin: string;
1403
- conversionRate: string;
1404
- liquidationOrder: number;
1405
- }[];
1406
- }>
1407
- > {
1408
- return this.getPrivate('/v5/spot-cross-margin-trade/pledge-token', {
1409
- coin,
1410
- });
1411
- }
1412
-
1413
- /**
1414
- * Get Borrowable Coin Info
1415
- */
1416
- getSpotMarginBorrowableCoinInfo(coin?: string): Promise<
1417
- APIResponseV3WithTime<{
1418
- list: {
1419
- coin: string;
1420
- borrowingPrecision: number;
1421
- repaymentPrecision: number;
1422
- }[];
1423
- }>
1424
- > {
1425
- return this.getPrivate('/v5/spot-cross-margin-trade/borrow-token', {
1426
- coin,
1427
- });
1428
- }
1429
-
1430
- /**
1431
- * Get Interest & Quota
1432
- */
1433
- getSpotMarginInterestAndQuota(coin: string): Promise<
1434
- APIResponseV3WithTime<{
1435
- list: {
1436
- coin: string;
1437
- interestRate: string;
1438
- loanAbleAmount: string;
1439
- maxLoanAmount: string;
1440
- }[];
1441
- }>
1442
- > {
1443
- return this.getPrivate('/v5/spot-cross-margin-trade/loan-info', {
1444
- coin,
1445
- });
1446
- }
1447
-
1448
- /**
1449
- * Get Loan Account Info
1450
- */
1451
- getSpotMarginLoanAccountInfo(): Promise<
1452
- APIResponseV3WithTime<{
1453
- acctBalanceSum: string;
1454
- debtBalanceSum: string;
1455
- loanAccountList: {
1456
- free: string;
1457
- interest: string;
1458
- loan: string;
1459
- remainAmount: string;
1460
- locked: string;
1461
- tokenId: string;
1462
- total: string;
1463
- }[];
1464
- riskRate: string;
1465
- status: number;
1466
- switchStatus: number;
1467
- }>
1468
- > {
1469
- return this.getPrivate('/v5/spot-cross-margin-trade/account');
1470
- }
1471
-
1472
- /**
1473
- * Borrow
1474
- */
1475
- spotMarginBorrow(params: { coin: string; qty: string }): Promise<
1476
- APIResponseV3WithTime<{
1477
- transactId: string;
1478
- }>
1479
- > {
1480
- return this.postPrivate('/v5/spot-cross-margin-trade/loan', params);
1481
- }
1482
-
1483
- /**
1484
- * Repay
1485
- */
1486
- spotMarginRepay(params: {
1487
- coin: string;
1488
- qty?: string;
1489
- completeRepayment: 0 | 1;
1490
- }): Promise<
1491
- APIResponseV3WithTime<{
1492
- repayId: string;
1493
- }>
1494
- > {
1495
- return this.postPrivate('/v5/spot-cross-margin-trade/repay', params);
1496
- }
1497
-
1498
- /**
1499
- * Get Borrow Order Detail
1500
- */
1501
- getSpotMarginBorrowOrderDetail(params?: {
1502
- startTime?: number;
1503
- endTime?: number;
1504
- coin?: string;
1505
- status?: 0 | 1 | 2;
1506
- limit?: number;
1507
- }): Promise<
1508
- APIResponseV3WithTime<{
1509
- list: {
1510
- accountId: string;
1511
- coin: string;
1512
- createdTime: number;
1513
- id: string;
1514
- interestAmount: string;
1515
- interestBalance: string;
1516
- loanAmount: string;
1517
- loanBalance: string;
1518
- remainAmount: string;
1519
- status: string;
1520
- type: string;
1521
- }[];
1522
- }>
1523
- > {
1524
- return this.getPrivate('/v5/spot-cross-margin-trade/orders', params);
1525
- }
1526
-
1527
- /**
1528
- * Get Repayment Order Detail
1529
- */
1530
- getSpotMarginRepaymentOrderDetail(params?: {
1531
- startTime?: number;
1532
- endTime?: number;
1533
- coin?: string;
1534
- limit?: number;
1535
- }): Promise<
1536
- APIResponseV3WithTime<{
1537
- list: {
1538
- accountId: string;
1539
- coin: string;
1540
- repaidAmount: string;
1541
- repayId: string;
1542
- repayMarginOrderId: string;
1543
- repayTime: string;
1544
- transactIds: {
1545
- repaidInterest: string;
1546
- repaidPrincipal: string;
1547
- repaidSerialNumber: string;
1548
- transactId: string;
1549
- }[];
1550
- }[];
1551
- }>
1552
- > {
1553
- return this.getPrivate('/v5/spot-cross-margin-trade/repay-history', params);
1554
- }
1555
-
1556
- /**
1557
- * Turn spot margin trade on / off in your NORMAL account.
1558
- */
1559
- toggleSpotCrossMarginTrade(params: {
1560
- switch: 1 | 0;
1561
- }): Promise<APIResponseV3WithTime<{ switchStatus: '1' | '0' }>> {
1562
- return this.postPrivate('/v5/spot-cross-margin-trade/switch', params);
1563
- }
1564
-
1565
- /**
1566
- *
1567
- ****** Institutional Lending
1568
- *
1569
- */
1570
-
1571
- /**
1572
- * Get Product Info
1573
- */
1574
- getInstitutionalLendingProductInfo(
1575
- productId?: string,
1576
- ): Promise<APIResponseV3WithTime<{ marginProductInfo: any[] }>> {
1577
- return this.get('/v5/ins-loan/product-infos', { productId });
1578
- }
1579
-
1580
- /**
1581
- * Get Margin Coin Info
1582
- */
1583
- getInstitutionalLendingMarginCoinInfo(
1584
- productId?: string,
1585
- ): Promise<APIResponseV3WithTime<{ marginToken: any[] }>> {
1586
- return this.get('/v5/ins-loan/ensure-tokens', { productId });
1587
- }
1588
-
1589
- /**
1590
- * Get Margin Coin Info With Conversion Rate
1591
- */
1592
- getInstitutionalLendingMarginCoinInfoWithConversionRate(
1593
- productId?: string,
1594
- ): Promise<APIResponseV3WithTime<{ marginToken: any[] }>> {
1595
- return this.get('/v5/ins-loan/ensure-tokens-convert', { productId });
1596
- }
1597
-
1598
- /**
1599
- * Get Loan Orders
1600
- */
1601
- getInstitutionalLendingLoanOrders(params?: {
1602
- orderId?: string;
1603
- startTime?: number;
1604
- endTime?: number;
1605
- limit?: number;
1606
- }): Promise<APIResponseV3WithTime<{ marginToken: any[] }>> {
1607
- return this.getPrivate('/v5/ins-loan/loan-order', params);
1608
- }
1609
-
1610
- /**
1611
- * Get Repay Orders
1612
- */
1613
- getInstitutionalLendingRepayOrders(params?: {
1614
- startTime?: number;
1615
- endTime?: number;
1616
- limit?: number;
1617
- }): Promise<APIResponseV3WithTime<{ repayInfo: any[] }>> {
1618
- return this.getPrivate('/v5/ins-loan/repaid-history', params);
1619
- }
1620
-
1621
- /**
1622
- * Get LTV
1623
- */
1624
- getInstitutionalLendingLTV(): Promise<
1625
- APIResponseV3WithTime<{ ltvInfo: any[] }>
1626
- > {
1627
- return this.getPrivate('/v5/ins-loan/ltv');
1628
- }
1629
-
1630
- /**
1631
- * Get LTV with Ladder Conversion Rate
1632
- */
1633
- getInstitutionalLendingLTVWithLadderConversionRate(): Promise<
1634
- APIResponseV3WithTime<{ ltvInfo: any[] }>
1635
- > {
1636
- return this.getPrivate('/v5/ins-loan/ltv-convert');
1637
- }
1638
- }