bybit-api 3.10.30 → 4.0.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 (146) hide show
  1. package/README.md +301 -178
  2. package/lib/index.d.ts +0 -11
  3. package/lib/index.js +0 -11
  4. package/lib/index.js.map +1 -1
  5. package/lib/rest-client-v5.d.ts +1 -1
  6. package/lib/rest-client-v5.js +1 -1
  7. package/lib/spot-client-v3.d.ts +8 -81
  8. package/lib/spot-client-v3.js +7 -172
  9. package/lib/spot-client-v3.js.map +1 -1
  10. package/lib/types/index.d.ts +1 -2
  11. package/lib/types/index.js +1 -2
  12. package/lib/types/index.js.map +1 -1
  13. package/lib/types/request/index.d.ts +0 -1
  14. package/lib/types/request/index.js +0 -1
  15. package/lib/types/request/index.js.map +1 -1
  16. package/lib/types/request/v5-account.d.ts +1 -1
  17. package/lib/types/request/v5-asset.d.ts +1 -1
  18. package/lib/types/request/v5-market.d.ts +1 -1
  19. package/lib/types/request/v5-position.d.ts +1 -1
  20. package/lib/types/request/v5-pre-upgrade.d.ts +1 -1
  21. package/lib/types/request/v5-spot-leverage-token.d.ts +1 -1
  22. package/lib/types/request/v5-trade.d.ts +1 -1
  23. package/lib/types/request/v5-user.d.ts +1 -1
  24. package/lib/types/response/v5-account.d.ts +1 -1
  25. package/lib/types/response/v5-asset.d.ts +1 -1
  26. package/lib/types/response/v5-market.d.ts +1 -1
  27. package/lib/types/response/v5-position.d.ts +1 -1
  28. package/lib/types/response/v5-spot-leverage-token.d.ts +1 -1
  29. package/lib/types/response/v5-trade.d.ts +1 -1
  30. package/lib/types/response/v5-user.d.ts +1 -1
  31. package/lib/types/{request/spot.js → shared-v5.js} +1 -1
  32. package/lib/types/shared-v5.js.map +1 -0
  33. package/lib/types/shared.d.ts +1 -19
  34. package/lib/types/websockets/index.d.ts +3 -0
  35. package/lib/types/websockets/index.js +20 -0
  36. package/lib/types/websockets/index.js.map +1 -0
  37. package/lib/types/websockets/ws-api.d.ts +73 -0
  38. package/lib/types/websockets/ws-api.js +10 -0
  39. package/lib/types/websockets/ws-api.js.map +1 -0
  40. package/lib/types/websockets/ws-confirmations.d.ts +13 -0
  41. package/lib/types/{websocket.events.js → websockets/ws-confirmations.js} +1 -1
  42. package/lib/types/websockets/ws-confirmations.js.map +1 -0
  43. package/lib/types/{websocket.events.d.ts → websockets/ws-events.d.ts} +9 -3
  44. package/lib/types/websockets/ws-events.js +11 -0
  45. package/lib/types/websockets/ws-events.js.map +1 -0
  46. package/lib/types/{websockets.d.ts → websockets/ws-general.d.ts} +35 -10
  47. package/lib/types/{v5-shared.js → websockets/ws-general.js} +1 -1
  48. package/lib/types/websockets/ws-general.js.map +1 -0
  49. package/lib/util/BaseRestClient.d.ts +1 -1
  50. package/lib/util/BaseRestClient.js +15 -39
  51. package/lib/util/BaseRestClient.js.map +1 -1
  52. package/lib/util/BaseWSClient.d.ts +221 -0
  53. package/lib/util/BaseWSClient.js +733 -0
  54. package/lib/util/BaseWSClient.js.map +1 -0
  55. package/lib/util/index.d.ts +1 -2
  56. package/lib/util/index.js +1 -2
  57. package/lib/util/index.js.map +1 -1
  58. package/lib/util/logger.d.ts +2 -5
  59. package/lib/util/logger.js +3 -12
  60. package/lib/util/logger.js.map +1 -1
  61. package/lib/util/requestUtils.d.ts +7 -10
  62. package/lib/util/requestUtils.js +6 -33
  63. package/lib/util/requestUtils.js.map +1 -1
  64. package/lib/util/typeGuards.d.ts +7 -1
  65. package/lib/util/typeGuards.js +41 -5
  66. package/lib/util/typeGuards.js.map +1 -1
  67. package/lib/util/webCryptoAPI.d.ts +10 -0
  68. package/lib/util/webCryptoAPI.js +69 -0
  69. package/lib/util/webCryptoAPI.js.map +1 -0
  70. package/lib/util/websockets/WsStore.d.ts +71 -0
  71. package/lib/util/websockets/WsStore.js +269 -0
  72. package/lib/util/websockets/WsStore.js.map +1 -0
  73. package/lib/util/websockets/WsStore.types.d.ts +50 -0
  74. package/lib/util/websockets/WsStore.types.js +14 -0
  75. package/lib/util/websockets/WsStore.types.js.map +1 -0
  76. package/lib/util/websockets/index.d.ts +3 -0
  77. package/lib/util/websockets/index.js +20 -0
  78. package/lib/util/websockets/index.js.map +1 -0
  79. package/lib/util/websockets/websocket-util.d.ts +92 -0
  80. package/lib/util/websockets/websocket-util.js +280 -0
  81. package/lib/util/websockets/websocket-util.js.map +1 -0
  82. package/lib/websocket-client.d.ts +107 -114
  83. package/lib/websocket-client.js +422 -716
  84. package/lib/websocket-client.js.map +1 -1
  85. package/package.json +4 -4
  86. package/lib/account-asset-client-v3.d.ts +0 -87
  87. package/lib/account-asset-client-v3.js +0 -154
  88. package/lib/account-asset-client-v3.js.map +0 -1
  89. package/lib/account-asset-client.d.ts +0 -46
  90. package/lib/account-asset-client.js +0 -108
  91. package/lib/account-asset-client.js.map +0 -1
  92. package/lib/contract-client.d.ts +0 -136
  93. package/lib/contract-client.js +0 -251
  94. package/lib/contract-client.js.map +0 -1
  95. package/lib/copy-trading-client.d.ts +0 -60
  96. package/lib/copy-trading-client.js +0 -114
  97. package/lib/copy-trading-client.js.map +0 -1
  98. package/lib/inverse-client.d.ts +0 -104
  99. package/lib/inverse-client.js +0 -213
  100. package/lib/inverse-client.js.map +0 -1
  101. package/lib/inverse-futures-client.d.ts +0 -217
  102. package/lib/inverse-futures-client.js +0 -224
  103. package/lib/inverse-futures-client.js.map +0 -1
  104. package/lib/linear-client.d.ts +0 -112
  105. package/lib/linear-client.js +0 -225
  106. package/lib/linear-client.js.map +0 -1
  107. package/lib/spot-client.d.ts +0 -46
  108. package/lib/spot-client.js +0 -131
  109. package/lib/spot-client.js.map +0 -1
  110. package/lib/types/request/spot.d.ts +0 -79
  111. package/lib/types/request/spot.js.map +0 -1
  112. package/lib/types/v5-shared.js.map +0 -1
  113. package/lib/types/websocket.events.js.map +0 -1
  114. package/lib/types/websockets.js +0 -3
  115. package/lib/types/websockets.js.map +0 -1
  116. package/lib/types/ws-events/failed-topic-subscription-confirmation.d.ts +0 -4
  117. package/lib/types/ws-events/failed-topic-subscription-confirmation.js +0 -3
  118. package/lib/types/ws-events/failed-topic-subscription-confirmation.js.map +0 -1
  119. package/lib/types/ws-events/succeeded-topic-subscription-confirmation.d.ts +0 -4
  120. package/lib/types/ws-events/succeeded-topic-subscription-confirmation.js +0 -3
  121. package/lib/types/ws-events/succeeded-topic-subscription-confirmation.js.map +0 -1
  122. package/lib/types/ws-events/topic-subscription-confirmation.d.ts +0 -7
  123. package/lib/types/ws-events/topic-subscription-confirmation.js +0 -3
  124. package/lib/types/ws-events/topic-subscription-confirmation.js.map +0 -1
  125. package/lib/unified-margin-client.d.ts +0 -140
  126. package/lib/unified-margin-client.js +0 -270
  127. package/lib/unified-margin-client.js.map +0 -1
  128. package/lib/usdc-option-client.d.ts +0 -110
  129. package/lib/usdc-option-client.js +0 -196
  130. package/lib/usdc-option-client.js.map +0 -1
  131. package/lib/usdc-perpetual-client.d.ts +0 -97
  132. package/lib/usdc-perpetual-client.js +0 -191
  133. package/lib/usdc-perpetual-client.js.map +0 -1
  134. package/lib/util/WsStore.d.ts +0 -57
  135. package/lib/util/WsStore.js +0 -97
  136. package/lib/util/WsStore.js.map +0 -1
  137. package/lib/util/browser-support.d.ts +0 -1
  138. package/lib/util/browser-support.js +0 -26
  139. package/lib/util/browser-support.js.map +0 -1
  140. package/lib/util/node-support.d.ts +0 -2
  141. package/lib/util/node-support.js +0 -21
  142. package/lib/util/node-support.js.map +0 -1
  143. package/lib/util/websocket-util.d.ts +0 -68
  144. package/lib/util/websocket-util.js +0 -506
  145. package/lib/util/websocket-util.js.map +0 -1
  146. /package/lib/types/{v5-shared.d.ts → shared-v5.d.ts} +0 -0
@@ -1,97 +0,0 @@
1
- import { APIResponseV3, APIResponseWithTime, SymbolLimitParam, SymbolPeriodLimitParam, USDCKlineRequest, USDCLast500TradesRequest, USDCOpenInterestRequest, USDCOrderFilter, USDCPerpActiveOrdersRequest, USDCPerpCancelOrderRequest, USDCPerpHistoricOrdersRequest, USDCPerpModifyOrderRequest, USDCPerpOrderRequest, USDCPositionsRequest, USDCSymbolDirectionLimit, USDCSymbolDirectionLimitCursor, USDCTransactionLogRequest } from './types';
2
- import BaseRestClient from './util/BaseRestClient';
3
- /**
4
- * REST API client for USDC Perpetual APIs
5
- *
6
- * @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
7
- * will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
8
- * Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
9
- */
10
- export declare class USDCPerpetualClient extends BaseRestClient {
11
- getClientType(): "v3";
12
- fetchServerTime(): Promise<number>;
13
- /**
14
- *
15
- * Market Data Endpoints
16
- *
17
- */
18
- getOrderBook(symbol: string): Promise<APIResponseV3<any>>;
19
- /** Fetch trading rules (such as min/max qty). Query for all if blank. */
20
- getContractInfo(params?: USDCSymbolDirectionLimit): Promise<APIResponseV3<any>>;
21
- /** Get a symbol price/statistics ticker */
22
- getSymbolTicker(symbol: string): Promise<APIResponseV3<any>>;
23
- getCandles(params: USDCKlineRequest): Promise<APIResponseV3<any>>;
24
- getMarkPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>>;
25
- getIndexPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>>;
26
- getIndexPremium(params: USDCKlineRequest): Promise<APIResponseV3<any>>;
27
- getOpenInterest(params: USDCOpenInterestRequest): Promise<APIResponseV3<any>>;
28
- getLargeOrders(params: SymbolLimitParam<string>): Promise<APIResponseV3<any>>;
29
- getLongShortRatio(params: SymbolPeriodLimitParam<string>): Promise<APIResponseV3<any>>;
30
- getLast500Trades(params: USDCLast500TradesRequest): Promise<APIResponseV3<any>>;
31
- /**
32
- *
33
- * Account Data Endpoints
34
- *
35
- */
36
- /** -> Order API */
37
- /**
38
- * Place an order using the USDC Derivatives Account.
39
- * The request status can be queried in real-time.
40
- * The response parameters must be queried through a query or a WebSocket response.
41
- */
42
- submitOrder(params: USDCPerpOrderRequest): Promise<APIResponseV3<any>>;
43
- /**
44
- * Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time.
45
- * Please request modification separately.
46
- */
47
- modifyOrder(params: USDCPerpModifyOrderRequest): Promise<APIResponseV3<any>>;
48
- /** Cancel order */
49
- cancelOrder(params: USDCPerpCancelOrderRequest): Promise<APIResponseV3<any>>;
50
- /** Cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
51
- cancelActiveOrders(symbol: string, orderFilter: USDCOrderFilter): Promise<APIResponseV3<any>>;
52
- /** Query Unfilled/Partially Filled Orders */
53
- getActiveOrders(params: USDCPerpActiveOrdersRequest): Promise<APIResponseV3<any>>;
54
- /** Query order history. The endpoint only supports up to 30 days of queried records */
55
- getHistoricOrders(params: USDCPerpHistoricOrdersRequest): Promise<APIResponseV3<any>>;
56
- /** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
57
- getOrderExecutionHistory(params: USDCPerpActiveOrdersRequest): Promise<APIResponseV3<any>>;
58
- /** -> Account API */
59
- /** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
60
- getTransactionLog(params: USDCTransactionLogRequest): Promise<APIResponseV3<any>>;
61
- /** Wallet info for USDC account. */
62
- getBalances(): Promise<APIResponseV3<any>>;
63
- /** Asset Info */
64
- getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>>;
65
- /**
66
- * If USDC derivatives account balance is greater than X, you can open PORTFOLIO_MARGIN,
67
- * and if it is less than Y, it will automatically close PORTFOLIO_MARGIN and change back to REGULAR_MARGIN.
68
- * X and Y will be adjusted according to operational requirements.
69
- * Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode.
70
- */
71
- setMarginMode(newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN'): Promise<APIResponseV3<any>>;
72
- /** Query margin mode for USDC account. */
73
- getMarginMode(): Promise<APIResponseV3<any>>;
74
- /** -> Positions API */
75
- /** Query my positions */
76
- getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>>;
77
- /** Only for REGULAR_MARGIN */
78
- setLeverage(symbol: string, leverage: string): Promise<APIResponseV3<any>>;
79
- /** Query Settlement History */
80
- getSettlementHistory(params?: USDCSymbolDirectionLimitCursor): Promise<APIResponseV3<any>>;
81
- /** -> Risk Limit API */
82
- /** Query risk limit */
83
- getRiskLimit(symbol: string): Promise<APIResponseV3<any>>;
84
- /** Set risk limit */
85
- setRiskLimit(symbol: string, riskId: number): Promise<APIResponseV3<any>>;
86
- /** -> Funding API */
87
- /** Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC. The current interval's fund fee settlement is based on the previous interval's fund rate. For example, at 16:00, the settlement is based on the fund rate generated at 8:00. The fund rate generated at 16:00 will be used at 0:00 the next day. */
88
- getLastFundingRate(symbol: string): Promise<APIResponseV3<any>>;
89
- /** Get predicted funding rate and my predicted funding fee */
90
- getPredictedFundingRate(symbol: string): Promise<APIResponseV3<any>>;
91
- /**
92
- *
93
- * API Data Endpoints
94
- *
95
- */
96
- getServerTime(): Promise<APIResponseWithTime>;
97
- }
@@ -1,191 +0,0 @@
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.USDCPerpetualClient = void 0;
16
- const util_1 = require("./util");
17
- const BaseRestClient_1 = __importDefault(require("./util/BaseRestClient"));
18
- /**
19
- * REST API client for USDC Perpetual APIs
20
- *
21
- * @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
22
- * will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
23
- * Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
24
- */
25
- class USDCPerpetualClient extends BaseRestClient_1.default {
26
- getClientType() {
27
- // Follows the same authentication mechanism as other v3 APIs (e.g. USDC)
28
- return util_1.REST_CLIENT_TYPE_ENUM.v3;
29
- }
30
- fetchServerTime() {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const res = yield this.getServerTime();
33
- return Number(res.time_now);
34
- });
35
- }
36
- /**
37
- *
38
- * Market Data Endpoints
39
- *
40
- */
41
- getOrderBook(symbol) {
42
- return this.get('/perpetual/usdc/openapi/public/v1/order-book', { symbol });
43
- }
44
- /** Fetch trading rules (such as min/max qty). Query for all if blank. */
45
- getContractInfo(params) {
46
- return this.get('/perpetual/usdc/openapi/public/v1/symbols', params);
47
- }
48
- /** Get a symbol price/statistics ticker */
49
- getSymbolTicker(symbol) {
50
- return this.get('/perpetual/usdc/openapi/public/v1/tick', { symbol });
51
- }
52
- getCandles(params) {
53
- return this.get('/perpetual/usdc/openapi/public/v1/kline/list', params);
54
- }
55
- getMarkPrice(params) {
56
- return this.get('/perpetual/usdc/openapi/public/v1/mark-price-kline', params);
57
- }
58
- getIndexPrice(params) {
59
- return this.get('/perpetual/usdc/openapi/public/v1/index-price-kline', params);
60
- }
61
- getIndexPremium(params) {
62
- return this.get('/perpetual/usdc/openapi/public/v1/premium-index-kline', params);
63
- }
64
- getOpenInterest(params) {
65
- return this.get('/perpetual/usdc/openapi/public/v1/open-interest', params);
66
- }
67
- getLargeOrders(params) {
68
- return this.get('/perpetual/usdc/openapi/public/v1/big-deal', params);
69
- }
70
- getLongShortRatio(params) {
71
- return this.get('/perpetual/usdc/openapi/public/v1/account-ratio', params);
72
- }
73
- getLast500Trades(params) {
74
- return this.get('/option/usdc/openapi/public/v1/query-trade-latest', params);
75
- }
76
- /**
77
- *
78
- * Account Data Endpoints
79
- *
80
- */
81
- /** -> Order API */
82
- /**
83
- * Place an order using the USDC Derivatives Account.
84
- * The request status can be queried in real-time.
85
- * The response parameters must be queried through a query or a WebSocket response.
86
- */
87
- submitOrder(params) {
88
- return this.postPrivate('/perpetual/usdc/openapi/private/v1/place-order', params);
89
- }
90
- /**
91
- * Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time.
92
- * Please request modification separately.
93
- */
94
- modifyOrder(params) {
95
- return this.postPrivate('/perpetual/usdc/openapi/private/v1/replace-order', params);
96
- }
97
- /** Cancel order */
98
- cancelOrder(params) {
99
- return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-order', params);
100
- }
101
- /** Cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
102
- cancelActiveOrders(symbol, orderFilter) {
103
- return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-all', {
104
- symbol,
105
- orderFilter,
106
- });
107
- }
108
- /** Query Unfilled/Partially Filled Orders */
109
- getActiveOrders(params) {
110
- return this.postPrivate('/option/usdc/openapi/private/v1/query-active-orders', params);
111
- }
112
- /** Query order history. The endpoint only supports up to 30 days of queried records */
113
- getHistoricOrders(params) {
114
- return this.postPrivate('/option/usdc/openapi/private/v1/query-order-history', params);
115
- }
116
- /** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
117
- getOrderExecutionHistory(params) {
118
- return this.postPrivate('/option/usdc/openapi/private/v1/execution-list', params);
119
- }
120
- /** -> Account API */
121
- /** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
122
- getTransactionLog(params) {
123
- return this.postPrivate('/option/usdc/openapi/private/v1/query-transaction-log', params);
124
- }
125
- /** Wallet info for USDC account. */
126
- getBalances() {
127
- return this.postPrivate('/option/usdc/openapi/private/v1/query-wallet-balance');
128
- }
129
- /** Asset Info */
130
- getAssetInfo(baseCoin) {
131
- return this.postPrivate('/option/usdc/openapi/private/v1/query-asset-info', { baseCoin });
132
- }
133
- /**
134
- * If USDC derivatives account balance is greater than X, you can open PORTFOLIO_MARGIN,
135
- * and if it is less than Y, it will automatically close PORTFOLIO_MARGIN and change back to REGULAR_MARGIN.
136
- * X and Y will be adjusted according to operational requirements.
137
- * Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode.
138
- */
139
- setMarginMode(newMarginMode) {
140
- return this.postPrivate('/option/usdc/private/asset/account/setMarginMode', { setMarginMode: newMarginMode });
141
- }
142
- /** Query margin mode for USDC account. */
143
- getMarginMode() {
144
- return this.postPrivate('/option/usdc/openapi/private/v1/query-margin-info');
145
- }
146
- /** -> Positions API */
147
- /** Query my positions */
148
- getPositions(params) {
149
- return this.postPrivate('/option/usdc/openapi/private/v1/query-position', params);
150
- }
151
- /** Only for REGULAR_MARGIN */
152
- setLeverage(symbol, leverage) {
153
- return this.postPrivate('/perpetual/usdc/openapi/private/v1/position/leverage/save', { symbol, leverage });
154
- }
155
- /** Query Settlement History */
156
- getSettlementHistory(params) {
157
- return this.postPrivate('/option/usdc/openapi/private/v1/session-settlement', params);
158
- }
159
- /** -> Risk Limit API */
160
- /** Query risk limit */
161
- getRiskLimit(symbol) {
162
- return this.getPrivate('/perpetual/usdc/openapi/public/v1/risk-limit/list', {
163
- symbol,
164
- });
165
- }
166
- /** Set risk limit */
167
- setRiskLimit(symbol, riskId) {
168
- return this.postPrivate('/perpetual/usdc/openapi/private/v1/position/set-risk-limit', { symbol, riskId });
169
- }
170
- /** -> Funding API */
171
- /** Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC. The current interval's fund fee settlement is based on the previous interval's fund rate. For example, at 16:00, the settlement is based on the fund rate generated at 8:00. The fund rate generated at 16:00 will be used at 0:00 the next day. */
172
- getLastFundingRate(symbol) {
173
- return this.get('/perpetual/usdc/openapi/public/v1/prev-funding-rate', {
174
- symbol,
175
- });
176
- }
177
- /** Get predicted funding rate and my predicted funding fee */
178
- getPredictedFundingRate(symbol) {
179
- return this.postPrivate('/perpetual/usdc/openapi/private/v1/predicted-funding', { symbol });
180
- }
181
- /**
182
- *
183
- * API Data Endpoints
184
- *
185
- */
186
- getServerTime() {
187
- return this.get('/v2/public/time');
188
- }
189
- }
190
- exports.USDCPerpetualClient = USDCPerpetualClient;
191
- //# sourceMappingURL=usdc-perpetual-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usdc-perpetual-client.js","sourceRoot":"","sources":["../src/usdc-perpetual-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAqBA,iCAA+C;AAC/C,2EAAmD;AAEnD;;;;;;GAMG;AACH,MAAa,mBAAoB,SAAQ,wBAAc;IACrD,aAAa;QACX,yEAAyE;QACzE,OAAO,4BAAqB,CAAC,EAAE,CAAC;IAClC,CAAC;IAEK,eAAe;;YACnB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YACvC,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;KAAA;IAED;;;;OAIG;IAEH,YAAY,CAAC,MAAc;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,8CAA8C,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,yEAAyE;IACzE,eAAe,CACb,MAAiC;QAEjC,OAAO,IAAI,CAAC,GAAG,CAAC,2CAA2C,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;IAED,2CAA2C;IAC3C,eAAe,CAAC,MAAc;QAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,wCAAwC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,UAAU,CAAC,MAAwB;QACjC,OAAO,IAAI,CAAC,GAAG,CAAC,8CAA8C,EAAE,MAAM,CAAC,CAAC;IAC1E,CAAC;IAED,YAAY,CAAC,MAAwB;QACnC,O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,EAAE,CACrB,CAAC;IACJ,CAAC;IAED,+BAA+B;IAC/B,oBAAoB,CAClB,MAAuC;QAEvC,OAAO,IAAI,CAAC,WAAW,CACrB,oDAAoD,EACpD,MAAM,CACP,CAAC;IACJ,CAAC;IAED,wBAAwB;IAExB,uBAAuB;IACvB,YAAY,CAAC,MAAc;QACzB,OAAO,IAAI,CAAC,UAAU,CACpB,mDAAmD,EACnD;YACE,MAAM;SACP,CACF,CAAC;IACJ,CAAC;IAED,qBAAqB;IACrB,YAAY,CAAC,MAAc,EAAE,MAAc;QACzC,OAAO,IAAI,CAAC,WAAW,CACrB,4DAA4D,EAC5D,EAAE,MAAM,EAAE,MAAM,EAAE,CACnB,CAAC;IACJ,CAAC;IAED,qBAAqB;IAErB,sUAAsU;IACtU,kBAAkB,CAAC,MAAc;QAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,qDAAqD,EAAE;YACrE,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,8DAA8D;IAC9D,uBAAuB,CAAC,MAAc;QACpC,OAAO,IAAI,CAAC,WAAW,CACrB,sDAAsD,EACtD,EAAE,MAAM,EAAE,CACX,CAAC;IACJ,CAAC;IAED;;;;OAIG;IAEH,aAAa;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF;AAhSD,kDAgSC"}
@@ -1,57 +0,0 @@
1
- import WebSocket from 'isomorphic-ws';
2
- import { WsKey } from '../types';
3
- import { DefaultLogger } from './logger';
4
- export declare enum WsConnectionStateEnum {
5
- INITIAL = 0,
6
- CONNECTING = 1,
7
- CONNECTED = 2,
8
- CLOSING = 3,
9
- RECONNECTING = 4
10
- }
11
- /** A "topic" is always a string */
12
- type WsTopic = string;
13
- /**
14
- * A "Set" is used to ensure we only subscribe to a topic once (tracking a list of unique topics we're expected to be connected to)
15
- * Note: Accurate duplicate tracking only works for plaintext topics.
16
- * E.g. JSON objects may not be seen as duplicates if keys are in different orders. If that's needed, check the FTX implementation.
17
- */
18
- type WsTopicList = Set<WsTopic>;
19
- interface WsStoredState {
20
- /** The currently active websocket connection */
21
- ws?: WebSocket;
22
- /** The current lifecycle state of the connection (enum) */
23
- connectionState?: WsConnectionStateEnum;
24
- /** A timer that will send an upstream heartbeat (ping) when it expires */
25
- activePingTimer?: ReturnType<typeof setTimeout> | undefined;
26
- /** A timer tracking that an upstream heartbeat was sent, expecting a reply before it expires */
27
- activePongTimer?: ReturnType<typeof setTimeout> | undefined;
28
- /** If a reconnection is in progress, this will have the timer for the delayed reconnect */
29
- activeReconnectTimer?: ReturnType<typeof setTimeout> | undefined;
30
- /**
31
- * All the topics we are expected to be subscribed to (and we automatically resubscribe to if the connection drops)
32
- */
33
- subscribedTopics: WsTopicList;
34
- }
35
- export default class WsStore {
36
- private wsState;
37
- private logger;
38
- constructor(logger: typeof DefaultLogger);
39
- /** Get WS stored state for key, optionally create if missing */
40
- get(key: WsKey, createIfMissing?: true): WsStoredState;
41
- get(key: WsKey, createIfMissing?: false): WsStoredState | undefined;
42
- getKeys(): WsKey[];
43
- create(key: WsKey): WsStoredState | undefined;
44
- delete(key: WsKey): void;
45
- hasExistingActiveConnection(key: WsKey): boolean;
46
- getWs(key: WsKey): WebSocket | undefined;
47
- setWs(key: WsKey, wsConnection: WebSocket): WebSocket;
48
- isWsOpen(key: WsKey): boolean;
49
- getConnectionState(key: WsKey): WsConnectionStateEnum;
50
- setConnectionState(key: WsKey, state: WsConnectionStateEnum): void;
51
- isConnectionState(key: WsKey, state: WsConnectionStateEnum): boolean;
52
- getTopics(key: WsKey): WsTopicList;
53
- getTopicsByKey(): Record<string, WsTopicList>;
54
- addTopic(key: WsKey, topic: WsTopic): WsTopicList;
55
- deleteTopic(key: WsKey, topic: WsTopic): boolean;
56
- }
57
- export {};
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WsConnectionStateEnum = void 0;
4
- const logger_1 = require("./logger");
5
- var WsConnectionStateEnum;
6
- (function (WsConnectionStateEnum) {
7
- WsConnectionStateEnum[WsConnectionStateEnum["INITIAL"] = 0] = "INITIAL";
8
- WsConnectionStateEnum[WsConnectionStateEnum["CONNECTING"] = 1] = "CONNECTING";
9
- WsConnectionStateEnum[WsConnectionStateEnum["CONNECTED"] = 2] = "CONNECTED";
10
- WsConnectionStateEnum[WsConnectionStateEnum["CLOSING"] = 3] = "CLOSING";
11
- WsConnectionStateEnum[WsConnectionStateEnum["RECONNECTING"] = 4] = "RECONNECTING";
12
- // ERROR = 5,
13
- })(WsConnectionStateEnum || (exports.WsConnectionStateEnum = WsConnectionStateEnum = {}));
14
- class WsStore {
15
- constructor(logger) {
16
- this.logger = logger || logger_1.DefaultLogger;
17
- this.wsState = {};
18
- }
19
- get(key, createIfMissing) {
20
- if (this.wsState[key]) {
21
- return this.wsState[key];
22
- }
23
- if (createIfMissing) {
24
- return this.create(key);
25
- }
26
- }
27
- getKeys() {
28
- return Object.keys(this.wsState);
29
- }
30
- create(key) {
31
- if (this.hasExistingActiveConnection(key)) {
32
- this.logger.warning('WsStore setConnection() overwriting existing open connection: ', this.getWs(key));
33
- }
34
- this.wsState[key] = {
35
- subscribedTopics: new Set(),
36
- connectionState: WsConnectionStateEnum.INITIAL,
37
- };
38
- return this.get(key);
39
- }
40
- delete(key) {
41
- if (this.hasExistingActiveConnection(key)) {
42
- const ws = this.getWs(key);
43
- this.logger.warning('WsStore deleting state for connection still open: ', ws);
44
- ws === null || ws === void 0 ? void 0 : ws.close();
45
- }
46
- delete this.wsState[key];
47
- }
48
- /* connection websocket */
49
- hasExistingActiveConnection(key) {
50
- return this.get(key) && this.isWsOpen(key);
51
- }
52
- getWs(key) {
53
- var _a;
54
- return (_a = this.get(key)) === null || _a === void 0 ? void 0 : _a.ws;
55
- }
56
- setWs(key, wsConnection) {
57
- if (this.isWsOpen(key)) {
58
- this.logger.warning('WsStore setConnection() overwriting existing open connection: ', this.getWs(key));
59
- }
60
- this.get(key, true).ws = wsConnection;
61
- return wsConnection;
62
- }
63
- /* connection state */
64
- isWsOpen(key) {
65
- const existingConnection = this.getWs(key);
66
- return (!!existingConnection &&
67
- existingConnection.readyState === existingConnection.OPEN);
68
- }
69
- getConnectionState(key) {
70
- return this.get(key, true).connectionState;
71
- }
72
- setConnectionState(key, state) {
73
- this.get(key, true).connectionState = state;
74
- }
75
- isConnectionState(key, state) {
76
- return this.getConnectionState(key) === state;
77
- }
78
- /* subscribed topics */
79
- getTopics(key) {
80
- return this.get(key, true).subscribedTopics;
81
- }
82
- getTopicsByKey() {
83
- const result = {};
84
- for (const refKey in this.wsState) {
85
- result[refKey] = this.getTopics(refKey);
86
- }
87
- return result;
88
- }
89
- addTopic(key, topic) {
90
- return this.getTopics(key).add(topic);
91
- }
92
- deleteTopic(key, topic) {
93
- return this.getTopics(key).delete(topic);
94
- }
95
- }
96
- exports.default = WsStore;
97
- //# sourceMappingURL=WsStore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WsStore.js","sourceRoot":"","sources":["../../src/util/WsStore.ts"],"names":[],"mappings":";;;AAGA,qCAAyC;AAEzC,IAAY,qBAOX;AAPD,WAAY,qBAAqB;IAC/B,uEAAW,CAAA;IACX,6EAAc,CAAA;IACd,2EAAa,CAAA;IACb,uEAAW,CAAA;IACX,iFAAgB,CAAA;IAChB,aAAa;AACf,CAAC,EAPW,qBAAqB,qCAArB,qBAAqB,QAOhC;AA4BD,MAAqB,OAAO;IAK1B,YAAY,MAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,sBAAa,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAOD,GAAG,CAAC,GAAU,EAAE,eAAyB;QACvC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAED,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,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CAAC;IAChB,CAAC;IAED,QAAQ,CAAC,GAAU,EAAE,KAAc;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,WAAW,CAAC,GAAU,EAAE,KAAc;QACpC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAvHD,0BAuHC"}
@@ -1 +0,0 @@
1
- export declare function signMessage(message: string, secret: string): Promise<string>;
@@ -1,26 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.signMessage = void 0;
13
- function signMessage(message, secret) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- const encoder = new TextEncoder();
16
- // eslint-disable-next-line no-undef
17
- const key = yield window.crypto.subtle.importKey('raw', encoder.encode(secret), { name: 'HMAC', hash: { name: 'SHA-256' } }, false, ['sign']);
18
- // eslint-disable-next-line no-undef
19
- const signature = yield window.crypto.subtle.sign('HMAC', key, encoder.encode(message));
20
- return Array.prototype.map
21
- .call(new Uint8Array(signature), (x) => ('00' + x.toString(16)).slice(-2))
22
- .join('');
23
- });
24
- }
25
- exports.signMessage = signMessage;
26
- //# sourceMappingURL=browser-support.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser-support.js","sourceRoot":"","sources":["../../src/util/browser-support.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,SAAsB,WAAW,CAC/B,OAAe,EACf,MAAc;;QAEd,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,oCAAoC;QACpC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAC9C,KAAK,EACL,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EACtB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAC3C,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,oCAAoC;QACpC,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAC/C,MAAM,EACN,GAAG,EACH,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CACxB,CAAC;QAEF,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG;aACvB,IAAI,CACH,IAAI,UAAU,CAAC,SAAS,CAAC,EACzB,CAAC,CAAyC,EAAE,EAAE,CAC5C,CAAC,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACpC;aACA,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;CAAA;AA5BD,kCA4BC"}
@@ -1,2 +0,0 @@
1
- /** This is async because the browser version uses a promise (browser-support) */
2
- export declare function signMessage(message: string, secret: string): Promise<string>;
@@ -1,21 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.signMessage = void 0;
13
- const crypto_1 = require("crypto");
14
- /** This is async because the browser version uses a promise (browser-support) */
15
- function signMessage(message, secret) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- return (0, crypto_1.createHmac)('sha256', secret).update(message).digest('hex');
18
- });
19
- }
20
- exports.signMessage = signMessage;
21
- //# sourceMappingURL=node-support.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-support.js","sourceRoot":"","sources":["../../src/util/node-support.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAoC;AAEpC,iFAAiF;AACjF,SAAsB,WAAW,CAC/B,OAAe,EACf,MAAc;;QAEd,OAAO,IAAA,mBAAU,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;CAAA;AALD,kCAKC"}
@@ -1,68 +0,0 @@
1
- import WebSocket from 'isomorphic-ws';
2
- import { APIMarket, CategoryV5, WebsocketClientOptions, WsKey } from '../types';
3
- import { DefaultLogger } from './logger';
4
- interface NetworkMapV3 {
5
- livenet: string;
6
- livenet2?: string;
7
- testnet: string;
8
- testnet2?: string;
9
- }
10
- type PublicPrivateNetwork = 'public' | 'private';
11
- /**
12
- * The following WS keys are logical.
13
- *
14
- * They're not directly used as a market. They usually have one private endpoint but many public ones,
15
- * so they need a bit of extra handling for seamless messaging between endpoints.
16
- *
17
- * For the unified keys, the "split" happens using the symbol. Symbols suffixed with USDT are obviously USDT topics.
18
- * For the v5 endpoints, the subscribe/unsubscribe call must specify the category the subscription should route to.
19
- */
20
- type PublicOnlyWsKeys = 'unifiedPerpUSDT' | 'unifiedPerpUSDC' | 'v5SpotPublic' | 'v5LinearPublic' | 'v5InversePublic' | 'v5OptionPublic';
21
- export declare const WS_BASE_URL_MAP: Record<APIMarket, Record<PublicPrivateNetwork, NetworkMapV3>> & Record<PublicOnlyWsKeys, Record<'public', NetworkMapV3>>;
22
- export declare const WS_KEY_MAP: {
23
- readonly inverse: "inverse";
24
- readonly linearPrivate: "linearPrivate";
25
- readonly linearPublic: "linearPublic";
26
- readonly spotPrivate: "spotPrivate";
27
- readonly spotPublic: "spotPublic";
28
- readonly spotV3Private: "spotV3Private";
29
- readonly spotV3Public: "spotV3Public";
30
- readonly usdcOptionPrivate: "usdcOptionPrivate";
31
- readonly usdcOptionPublic: "usdcOptionPublic";
32
- readonly usdcPerpPrivate: "usdcPerpPrivate";
33
- readonly usdcPerpPublic: "usdcPerpPublic";
34
- readonly unifiedPrivate: "unifiedPrivate";
35
- readonly unifiedOptionPublic: "unifiedOptionPublic";
36
- readonly unifiedPerpUSDTPublic: "unifiedPerpUSDTPublic";
37
- readonly unifiedPerpUSDCPublic: "unifiedPerpUSDCPublic";
38
- readonly contractUSDTPublic: "contractUSDTPublic";
39
- readonly contractUSDTPrivate: "contractUSDTPrivate";
40
- readonly contractInversePublic: "contractInversePublic";
41
- readonly contractInversePrivate: "contractInversePrivate";
42
- readonly v5SpotPublic: "v5SpotPublic";
43
- readonly v5LinearPublic: "v5LinearPublic";
44
- readonly v5InversePublic: "v5InversePublic";
45
- readonly v5OptionPublic: "v5OptionPublic";
46
- readonly v5Private: "v5Private";
47
- };
48
- export declare const WS_AUTH_ON_CONNECT_KEYS: WsKey[];
49
- export declare const PUBLIC_WS_KEYS: string[];
50
- export declare function isPrivateWsTopic(topic: string): boolean;
51
- export declare function getWsKeyForTopic(market: APIMarket, topic: string, isPrivate?: boolean, category?: CategoryV5): WsKey;
52
- export declare function getWsUrl(wsKey: WsKey, wsClientOptions: WebsocketClientOptions, logger: typeof DefaultLogger): string;
53
- export declare function getMaxTopicsPerSubscribeEvent(market: APIMarket, wsKey: WsKey): number | null;
54
- export declare function getUsdcWsKeyForTopic(topic: string, subGroup: 'option' | 'perp'): WsKey;
55
- export declare const WS_ERROR_ENUM: {
56
- NOT_AUTHENTICATED_SPOT_V3: string;
57
- API_ERROR_GENERIC: string;
58
- API_SIGN_AUTH_FAILED: string;
59
- USDC_OPTION_AUTH_FAILED: string;
60
- };
61
- export declare function neverGuard(x: never, msg: string): Error;
62
- /**
63
- * #305: ws.terminate() is undefined in browsers.
64
- * This only works in node.js, not in browsers.
65
- * Does nothing if `ws` is undefined.
66
- */
67
- export declare function safeTerminateWs(ws?: WebSocket | unknown): void;
68
- export {};