bybit-api 3.6.1 → 3.7.1-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 (93) hide show
  1. package/lib/contract-client.d.ts +17 -3
  2. package/lib/contract-client.js +17 -3
  3. package/lib/contract-client.js.map +1 -1
  4. package/lib/rest-client-v5.d.ts +259 -10
  5. package/lib/rest-client-v5.js +196 -7
  6. package/lib/rest-client-v5.js.map +1 -1
  7. package/lib/types/request/contract.d.ts +21 -11
  8. package/lib/types/request/index.d.ts +1 -0
  9. package/lib/types/request/index.js +1 -0
  10. package/lib/types/request/index.js.map +1 -1
  11. package/lib/types/request/v5-account.d.ts +5 -0
  12. package/lib/types/request/v5-market.d.ts +10 -2
  13. package/lib/types/request/v5-position.d.ts +13 -2
  14. package/lib/types/request/v5-pre-upgrade.d.ts +34 -0
  15. package/lib/types/request/v5-pre-upgrade.js +3 -0
  16. package/lib/types/request/v5-pre-upgrade.js.map +1 -0
  17. package/lib/types/request/v5-trade.d.ts +24 -1
  18. package/lib/types/response/contract.d.ts +22 -12
  19. package/lib/types/response/v5-account.d.ts +1 -0
  20. package/lib/types/response/v5-market.d.ts +6 -0
  21. package/lib/types/response/v5-position.d.ts +26 -0
  22. package/lib/types/response/v5-trade.d.ts +7 -0
  23. package/lib/types/v5-shared.d.ts +4 -1
  24. package/lib/util/websocket-util.d.ts +2 -1
  25. package/lib/util/websocket-util.js +2 -2
  26. package/lib/util/websocket-util.js.map +1 -1
  27. package/lib/websocket-client.js +1 -1
  28. package/lib/websocket-client.js.map +1 -1
  29. package/package.json +13 -1
  30. package/src/account-asset-client-v3.ts +310 -0
  31. package/src/account-asset-client.ts +149 -0
  32. package/src/constants/enum.ts +105 -0
  33. package/src/contract-client.ts +360 -0
  34. package/src/copy-trading-client.ts +159 -0
  35. package/src/index.ts +18 -0
  36. package/src/inverse-client.ts +337 -0
  37. package/src/inverse-futures-client.ts +403 -0
  38. package/src/linear-client.ts +387 -0
  39. package/src/rest-client-v5.ts +1638 -0
  40. package/src/spot-client-v3.ts +303 -0
  41. package/src/spot-client.ts +180 -0
  42. package/src/types/index.ts +5 -0
  43. package/src/types/request/account-asset.ts +258 -0
  44. package/src/types/request/contract.ts +139 -0
  45. package/src/types/request/copy-trading.ts +53 -0
  46. package/src/types/request/index.ts +18 -0
  47. package/src/types/request/inverse.ts +135 -0
  48. package/src/types/request/linear.ts +201 -0
  49. package/src/types/request/spot.ts +89 -0
  50. package/src/types/request/unified-margin.ts +247 -0
  51. package/src/types/request/usdc-options.ts +134 -0
  52. package/src/types/request/usdc-perp.ts +100 -0
  53. package/src/types/request/usdc-shared.ts +39 -0
  54. package/src/types/request/v5-account.ts +40 -0
  55. package/src/types/request/v5-asset.ts +133 -0
  56. package/src/types/request/v5-market.ts +127 -0
  57. package/src/types/request/v5-position.ts +107 -0
  58. package/src/types/request/v5-pre-upgrade.ts +37 -0
  59. package/src/types/request/v5-spot-leverage-token.ts +23 -0
  60. package/src/types/request/v5-trade.ts +133 -0
  61. package/src/types/request/v5-user.ts +21 -0
  62. package/src/types/response/account-asset.ts +236 -0
  63. package/src/types/response/contract.ts +74 -0
  64. package/src/types/response/index.ts +13 -0
  65. package/src/types/response/shared.ts +19 -0
  66. package/src/types/response/spot.ts +17 -0
  67. package/src/types/response/unified-margin.ts +71 -0
  68. package/src/types/response/usdt-perp.ts +58 -0
  69. package/src/types/response/v5-account.ts +122 -0
  70. package/src/types/response/v5-asset.ts +170 -0
  71. package/src/types/response/v5-market.ts +271 -0
  72. package/src/types/response/v5-position.ts +118 -0
  73. package/src/types/response/v5-spot-leverage-token.ts +70 -0
  74. package/src/types/response/v5-trade.ts +103 -0
  75. package/src/types/response/v5-user.ts +58 -0
  76. package/src/types/shared.ts +175 -0
  77. package/src/types/v5-shared.ts +213 -0
  78. package/src/types/websockets.ts +115 -0
  79. package/src/types/ws-events/failed-topic-subscription-confirmation.ts +6 -0
  80. package/src/types/ws-events/succeeded-topic-subscription-confirmation.ts +6 -0
  81. package/src/types/ws-events/topic-subscription-confirmation.ts +7 -0
  82. package/src/unified-margin-client.ts +400 -0
  83. package/src/usdc-option-client.ts +333 -0
  84. package/src/usdc-perpetual-client.ts +312 -0
  85. package/src/util/BaseRestClient.ts +502 -0
  86. package/src/util/WsStore.ts +160 -0
  87. package/src/util/browser-support.ts +29 -0
  88. package/src/util/index.ts +5 -0
  89. package/src/util/logger.ts +26 -0
  90. package/src/util/node-support.ts +9 -0
  91. package/src/util/requestUtils.ts +171 -0
  92. package/src/util/websocket-util.ts +550 -0
  93. package/src/websocket-client.ts +1262 -0
@@ -0,0 +1,115 @@
1
+ import { RestClientOptions, WS_KEY_MAP } from '../util';
2
+
3
+ /** For spot markets, spotV3 is recommended */
4
+ export type APIMarket =
5
+ | 'inverse'
6
+ | 'linear'
7
+ | 'spot'
8
+ | 'spotv3'
9
+ | 'usdcOption'
10
+ | 'usdcPerp'
11
+ | 'unifiedPerp'
12
+ | 'unifiedOption'
13
+ | 'contractUSDT'
14
+ | 'contractInverse'
15
+ | 'v5';
16
+
17
+ // Same as inverse futures
18
+ export type WsPublicInverseTopic =
19
+ | 'orderBookL2_25'
20
+ | 'orderBookL2_200'
21
+ | 'trade'
22
+ | 'insurance'
23
+ | 'instrument_info'
24
+ | 'klineV2';
25
+
26
+ export type WsPublicUSDTPerpTopic =
27
+ | 'orderBookL2_25'
28
+ | 'orderBookL2_200'
29
+ | 'trade'
30
+ | 'insurance'
31
+ | 'instrument_info'
32
+ | 'kline';
33
+
34
+ export type WsPublicSpotV1Topic =
35
+ | 'trade'
36
+ | 'realtimes'
37
+ | 'kline'
38
+ | 'depth'
39
+ | 'mergedDepth'
40
+ | 'diffDepth';
41
+
42
+ export type WsPublicSpotV2Topic =
43
+ | 'depth'
44
+ | 'kline'
45
+ | 'trade'
46
+ | 'bookTicker'
47
+ | 'realtimes';
48
+
49
+ export type WsPublicTopics =
50
+ | WsPublicInverseTopic
51
+ | WsPublicUSDTPerpTopic
52
+ | WsPublicSpotV1Topic
53
+ | WsPublicSpotV2Topic
54
+ | string;
55
+
56
+ // Same as inverse futures
57
+ export type WsPrivateInverseTopic =
58
+ | 'position'
59
+ | 'execution'
60
+ | 'order'
61
+ | 'stop_order';
62
+
63
+ export type WsPrivateUSDTPerpTopic =
64
+ | 'position'
65
+ | 'execution'
66
+ | 'order'
67
+ | 'stop_order'
68
+ | 'wallet';
69
+
70
+ export type WsPrivateSpotTopic =
71
+ | 'outboundAccountInfo'
72
+ | 'executionReport'
73
+ | 'ticketInfo';
74
+
75
+ export type WsPrivateTopic =
76
+ | WsPrivateInverseTopic
77
+ | WsPrivateUSDTPerpTopic
78
+ | WsPrivateSpotTopic
79
+ | string;
80
+
81
+ export type WsTopic = WsPublicTopics | WsPrivateTopic;
82
+
83
+ /** This is used to differentiate between each of the available websocket streams (as bybit has multiple websockets) */
84
+ export type WsKey = typeof WS_KEY_MAP[keyof typeof WS_KEY_MAP];
85
+
86
+ export interface WSClientConfigurableOptions {
87
+ key?: string;
88
+ secret?: string;
89
+ testnet?: boolean;
90
+
91
+ /**
92
+ * The API group this client should connect to.
93
+ *
94
+ * For the V3 APIs use `v3` as the market (spot/unified margin/usdc/account asset/copy trading)
95
+ */
96
+ market: APIMarket;
97
+
98
+ pongTimeout?: number;
99
+ pingInterval?: number;
100
+ reconnectTimeout?: number;
101
+ restOptions?: RestClientOptions;
102
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
+ requestOptions?: any;
104
+ wsUrl?: string;
105
+ /** If true, fetch server time before trying to authenticate (disabled by default) */
106
+ fetchTimeOffsetBeforeAuth?: boolean;
107
+ }
108
+
109
+ export interface WebsocketClientOptions extends WSClientConfigurableOptions {
110
+ testnet?: boolean;
111
+ market: APIMarket;
112
+ pongTimeout: number;
113
+ pingInterval: number;
114
+ reconnectTimeout: number;
115
+ }
@@ -0,0 +1,6 @@
1
+ import { WebsocketTopicSubscriptionConfirmationEvent } from './topic-subscription-confirmation';
2
+
3
+ export interface WebsocketFailedTopicSubscriptionConfirmationEvent
4
+ extends WebsocketTopicSubscriptionConfirmationEvent {
5
+ success: false;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { WebsocketTopicSubscriptionConfirmationEvent } from './topic-subscription-confirmation';
2
+
3
+ export interface WebsocketSucceededTopicSubscriptionConfirmationEvent
4
+ extends WebsocketTopicSubscriptionConfirmationEvent {
5
+ success: true;
6
+ }
@@ -0,0 +1,7 @@
1
+ export interface WebsocketTopicSubscriptionConfirmationEvent {
2
+ op: 'subscribe';
3
+ req_id: string;
4
+ conn_id: string;
5
+ ret_msg: string;
6
+ success: boolean;
7
+ }
@@ -0,0 +1,400 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import {
3
+ APIResponseV3,
4
+ APIResponseWithTime,
5
+ InternalTransferRequest,
6
+ UM7DayTradingHistoryRequest,
7
+ UMActiveOrdersRequest,
8
+ UMBatchOrder,
9
+ UMBatchOrderCancel,
10
+ UMBatchOrderReplace,
11
+ UMBorrowHistoryRequest,
12
+ UMCancelAllOrdersRequest,
13
+ UMCancelOrderRequest,
14
+ UMCandlesRequest,
15
+ UMCategory,
16
+ UMExchangeCoinsRequest,
17
+ UMFundingRateHistoryRequest,
18
+ UMHistoricOrder,
19
+ UMHistoricOrdersRequest,
20
+ UMInstrumentInfo,
21
+ UMInstrumentInfoRequest,
22
+ UMModifyOrderRequest,
23
+ UMOpenInterestRequest,
24
+ UMOptionDeliveryPriceRequest,
25
+ UMOptionsSettlementHistoryRequest,
26
+ UMOrderRequest,
27
+ UMPaginatedResult,
28
+ UMPerpSettlementHistoryRequest,
29
+ UMPositionsRequest,
30
+ UMPublicTradesRequest,
31
+ UMSetTPSLRequest,
32
+ UMTransactionLogRequest,
33
+ } from './types';
34
+ import { REST_CLIENT_TYPE_ENUM } from './util';
35
+ import BaseRestClient from './util/BaseRestClient';
36
+
37
+ /**
38
+ * REST API client for Derivatives V3 unified margin APIs
39
+ */
40
+ export class UnifiedMarginClient extends BaseRestClient {
41
+ getClientType() {
42
+ return REST_CLIENT_TYPE_ENUM.v3;
43
+ }
44
+
45
+ async fetchServerTime(): Promise<number> {
46
+ const res = await this.getServerTime();
47
+ return Number(res.time_now);
48
+ }
49
+
50
+ /**
51
+ *
52
+ * Market Data Endpoints
53
+ *
54
+ */
55
+
56
+ /** Query order book info. Each side has a depth of 25 orders. */
57
+ getOrderBook(
58
+ symbol: string,
59
+ category: string,
60
+ limit?: number
61
+ ): Promise<APIResponseV3<any>> {
62
+ return this.get('/derivatives/v3/public/order-book/L2', {
63
+ category,
64
+ symbol,
65
+ limit,
66
+ });
67
+ }
68
+
69
+ /** Get candles/klines */
70
+ getCandles(params: UMCandlesRequest): Promise<APIResponseV3<any>> {
71
+ return this.get('/derivatives/v3/public/kline', params);
72
+ }
73
+
74
+ /** Get a symbol price/statistics ticker */
75
+ getSymbolTicker(
76
+ category: UMCategory,
77
+ symbol?: string
78
+ ): Promise<APIResponseV3<any>> {
79
+ return this.get('/derivatives/v3/public/tickers', { category, symbol });
80
+ }
81
+
82
+ /** Get trading rules per symbol/contract, incl price/amount/value/leverage filters */
83
+ getInstrumentInfo(
84
+ params: UMInstrumentInfoRequest
85
+ ): Promise<APIResponseV3<UMPaginatedResult<UMInstrumentInfo>>> {
86
+ return this.get('/derivatives/v3/public/instruments-info', params);
87
+ }
88
+
89
+ /** Query mark price kline (like getCandles() but for mark price). */
90
+ getMarkPriceCandles(params: UMCandlesRequest): Promise<APIResponseV3<any>> {
91
+ return this.get('/derivatives/v3/public/mark-price-kline', params);
92
+ }
93
+
94
+ /** Query Index Price Kline */
95
+ getIndexPriceCandles(params: UMCandlesRequest): Promise<APIResponseV3<any>> {
96
+ return this.get('/derivatives/v3/public/index-price-kline', params);
97
+ }
98
+
99
+ /**
100
+ * The funding rate is generated every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC.
101
+ * For example, if a request is sent at 12:00 UTC, the funding rate generated earlier that day at 08:00 UTC will be sent.
102
+ */
103
+ getFundingRateHistory(
104
+ params: UMFundingRateHistoryRequest
105
+ ): Promise<APIResponseV3<any>> {
106
+ return this.get(
107
+ '/derivatives/v3/public/funding/history-funding-rate',
108
+ params
109
+ );
110
+ }
111
+
112
+ /** Get Risk Limit */
113
+ getRiskLimit(
114
+ category: UMCategory,
115
+ symbol: string
116
+ ): Promise<APIResponseV3<any>> {
117
+ return this.get('/derivatives/v3/public/risk-limit/list', {
118
+ category,
119
+ symbol,
120
+ });
121
+ }
122
+
123
+ /** Get option delivery price */
124
+ getOptionDeliveryPrice(
125
+ params: UMOptionDeliveryPriceRequest
126
+ ): Promise<APIResponseV3<any>> {
127
+ return this.get('/derivatives/v3/public/delivery-price', params);
128
+ }
129
+
130
+ /** Get recent trades */
131
+ getTrades(params: UMPublicTradesRequest): Promise<APIResponseV3<any>> {
132
+ return this.get('/derivatives/v3/public/recent-trade', params);
133
+ }
134
+
135
+ /**
136
+ * Gets the total amount of unsettled contracts.
137
+ * In other words, the total number of contracts held in open positions.
138
+ */
139
+ getOpenInterest(params: UMOpenInterestRequest): Promise<APIResponseV3<any>> {
140
+ return this.get('/derivatives/v3/public/open-interest', params);
141
+ }
142
+
143
+ /**
144
+ *
145
+ * Unified Margin Account Endpoints
146
+ *
147
+ */
148
+
149
+ /** -> Order API */
150
+
151
+ /** Place an order */
152
+ submitOrder(params: UMOrderRequest): Promise<APIResponseV3<any>> {
153
+ return this.postPrivate('/unified/v3/private/order/create', params);
154
+ }
155
+
156
+ /** Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time. Please request modification separately. */
157
+ modifyOrder(params: UMModifyOrderRequest): Promise<APIResponseV3<any>> {
158
+ return this.postPrivate('/unified/v3/private/order/replace', params);
159
+ }
160
+
161
+ /** Cancel order */
162
+ cancelOrder(params: UMCancelOrderRequest): Promise<APIResponseV3<any>> {
163
+ return this.postPrivate('/unified/v3/private/order/cancel', params);
164
+ }
165
+
166
+ /** Query Open Orders */
167
+ getActiveOrders(params: UMActiveOrdersRequest): Promise<APIResponseV3<any>> {
168
+ return this.getPrivate('/unified/v3/private/order/unfilled-orders', params);
169
+ }
170
+
171
+ /** Query order history. As order creation/cancellation is asynchronous, the data returned from the interface may be delayed. To access order information in real-time, call getActiveOrders() */
172
+ getHistoricOrders(
173
+ params: UMHistoricOrdersRequest
174
+ ): Promise<APIResponseV3<UMPaginatedResult<UMHistoricOrder>>> {
175
+ return this.getPrivate('/unified/v3/private/order/list', params);
176
+ }
177
+
178
+ /**
179
+ * This API provides the batch order mode under the unified margin account.
180
+ * Max 10 per request
181
+ */
182
+ batchSubmitOrders(
183
+ category: UMCategory,
184
+ orders: UMBatchOrder[]
185
+ ): Promise<APIResponseV3<any>> {
186
+ return this.postPrivate('/unified/v3/private/order/create-batch', {
187
+ category,
188
+ request: orders,
189
+ });
190
+ }
191
+
192
+ /**
193
+ * This interface can modify the open order information in batches.
194
+ * Currently, it is not supported to modify the conditional order information.
195
+ * Please note that only unfilled or partial filled orders can be modified.
196
+ * If both futures and options orders are in one request, only the orders matching the category will be operated according to the category type
197
+ */
198
+ batchReplaceOrders(
199
+ category: UMCategory,
200
+ orders: UMBatchOrderReplace[]
201
+ ): Promise<APIResponseV3<any>> {
202
+ return this.postPrivate('/unified/v3/private/order/replace-batch', {
203
+ category,
204
+ request: orders,
205
+ });
206
+ }
207
+
208
+ /**
209
+ * This API provides batch cancellation under the unified margin account.
210
+ * Order cancellation of futures and options cannot be canceled in one request at the same time.
211
+ * If both futures and options orders are in one request, only the orders matching the category will be operated according to the category type.
212
+ */
213
+ batchCancelOrders(
214
+ category: UMCategory,
215
+ orders: UMBatchOrderCancel[]
216
+ ): Promise<APIResponseV3<any>> {
217
+ return this.postPrivate('/unified/v3/private/order/cancel-batch', {
218
+ category,
219
+ request: orders,
220
+ });
221
+ }
222
+
223
+ /**
224
+ * This API provides the cancellation of all open orders under the unified margin account.
225
+ * Order cancellation of futures and options cannot be canceled in one request at the same time.
226
+ * If both futures and options orders are in one request, only the orders matching the category will be operated according to the category type.
227
+ */
228
+ cancelAllOrders(
229
+ params: UMCancelAllOrdersRequest
230
+ ): Promise<APIResponseV3<any>> {
231
+ return this.postPrivate('/unified/v3/private/order/cancel-all', params);
232
+ }
233
+
234
+ /** -> Positions API */
235
+
236
+ /**
237
+ * Query my positions real-time. Accessing personal list of positions.
238
+ * Users can access their position holding information through this interface, such as the number of position holdings and wallet balance.
239
+ */
240
+ getPositions(params: UMPositionsRequest): Promise<APIResponseV3<any>> {
241
+ return this.getPrivate('/unified/v3/private/position/list', params);
242
+ }
243
+
244
+ /** Leverage setting. */
245
+ setLeverage(
246
+ category: UMCategory,
247
+ symbol: string,
248
+ buyLeverage: number,
249
+ sellLeverage: number
250
+ ): Promise<APIResponseV3<any>> {
251
+ return this.postPrivate('/unified/v3/private/position/set-leverage', {
252
+ category,
253
+ symbol,
254
+ buyLeverage,
255
+ sellLeverage,
256
+ });
257
+ }
258
+
259
+ /**
260
+ * Switching the TP/SL mode to the cross margin mode or selected positions.
261
+ * When you set the TP/SL mode on the selected positions, the quantity of take-profit or stop-loss orders can be smaller than the position size. Please use Trading-Stop endpoint.
262
+ */
263
+ setTPSLMode(
264
+ category: UMCategory,
265
+ symbol: string,
266
+ tpSlMode: 1 | 0
267
+ ): Promise<APIResponseV3<any>> {
268
+ return this.postPrivate('/unified/v3/private/position/tpsl/switch-mode', {
269
+ category,
270
+ symbol,
271
+ tpSlMode,
272
+ });
273
+ }
274
+
275
+ /** Set risk limit */
276
+ setRiskLimit(
277
+ category: UMCategory,
278
+ symbol: string,
279
+ riskId: number,
280
+ positionIdx: number
281
+ ): Promise<APIResponseV3<any>> {
282
+ return this.postPrivate('/unified/v3/private/position/set-risk-limit', {
283
+ category,
284
+ symbol,
285
+ riskId,
286
+ positionIdx,
287
+ });
288
+ }
289
+
290
+ /**
291
+ * Set position TP/SL and trailing stop.
292
+ * Pass the following parameters, then the system will create conditional orders.
293
+ * If the position is closed, the system will cancel these orders, and adjust the position size.
294
+ */
295
+ setTPSL(params: UMSetTPSLRequest): Promise<APIResponseV3<any>> {
296
+ return this.postPrivate(
297
+ '/unified/v3/private/position/trading-stop',
298
+ params
299
+ );
300
+ }
301
+
302
+ /**
303
+ * Access the user's filled history, ranked by time in descending order.
304
+ * There might be multiple filled histories for an order.
305
+ */
306
+ get7DayTradingHistory(
307
+ params: UM7DayTradingHistoryRequest
308
+ ): Promise<APIResponseV3<any>> {
309
+ return this.getPrivate('/unified/v3/private/execution/list', params);
310
+ }
311
+
312
+ /** Query the settlement history, ranked by time in descending order. */
313
+ getOptionsSettlementHistory(
314
+ params: UMOptionsSettlementHistoryRequest
315
+ ): Promise<APIResponseV3<any>> {
316
+ return this.getPrivate('/unified/v3/private/delivery-record', params);
317
+ }
318
+
319
+ /** Query session settlement records, only for USDC perpetual */
320
+ getUSDCPerpetualSettlementHistory(
321
+ params: UMPerpSettlementHistoryRequest
322
+ ): Promise<APIResponseV3<any>> {
323
+ return this.getPrivate('/unified/v3/private/settlement-record', params);
324
+ }
325
+
326
+ /** -> Account API */
327
+
328
+ /** Query wallet balance */
329
+ getBalances(coin?: string): Promise<APIResponseV3<any>> {
330
+ return this.getPrivate('/unified/v3/private/account/wallet/balance', {
331
+ coin,
332
+ });
333
+ }
334
+
335
+ /**
336
+ * Upgrade to unified margin account.
337
+ * WARNING: This is currently not reversable!
338
+ */
339
+ upgradeToUnifiedMargin(): Promise<APIResponseV3<any>> {
340
+ return this.postPrivate(
341
+ '/unified/v3/private/account/upgrade-unified-account'
342
+ );
343
+ }
344
+
345
+ /** Query trading history */
346
+ getTransactionLog(
347
+ params: UMTransactionLogRequest
348
+ ): Promise<APIResponseV3<any>> {
349
+ return this.getPrivate(
350
+ '/unified/v3/private/account/transaction-log',
351
+ params
352
+ );
353
+ }
354
+
355
+ /** Fund transfer between accounts (v2) */
356
+ transferFunds(params: InternalTransferRequest): Promise<APIResponseV3<any>> {
357
+ return this.postPrivate('/asset/v1/private/transfer', params);
358
+ }
359
+
360
+ /** Exchange Coins */
361
+ getCoinExchangeHistory(
362
+ params?: UMExchangeCoinsRequest
363
+ ): Promise<APIResponseV3<any>> {
364
+ return this.getPrivate(
365
+ '/asset/v2/private/exchange/exchange-order-all',
366
+ params
367
+ );
368
+ }
369
+
370
+ /** Get Borrow History */
371
+ getBorrowHistory(
372
+ params?: UMBorrowHistoryRequest
373
+ ): Promise<APIResponseV3<any>> {
374
+ return this.getPrivate(
375
+ '/unified/v3/private/account/borrow-history',
376
+ params
377
+ );
378
+ }
379
+
380
+ /** Get Borrow Rate */
381
+ getBorrowRate(currency?: string): Promise<APIResponseV3<any>> {
382
+ return this.getPrivate('/unified/v3/private/account/borrow-rate', {
383
+ currency,
384
+ });
385
+ }
386
+
387
+ /**
388
+ *
389
+ * API Data Endpoints
390
+ *
391
+ */
392
+
393
+ getServerTime(): Promise<APIResponseWithTime> {
394
+ return this.get('/v2/public/time');
395
+ }
396
+
397
+ getAnnouncements(): Promise<APIResponseV3<any>> {
398
+ return this.get('/v2/public/announcement');
399
+ }
400
+ }