bybit-api 2.4.0-beta.1 → 2.4.0-beta.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.
package/README.md CHANGED
@@ -11,8 +11,8 @@
11
11
  Node.js connector for the Bybit APIs and WebSockets:
12
12
  - Complete integration with all bybit APIs.
13
13
  - TypeScript support (with type declarations for most API requests & responses).
14
- - Over 200 integration tests making real API calls, validating any changes before they reach npm.
15
- - Robust WebSocket integration with connection heartbeats & automatic reconnection.
14
+ - Over 300 integration tests making real API calls & WebSocket connections, validating any changes before they reach npm.
15
+ - Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
16
16
  - Browser support (via webpack bundle - see "Browser Usage" below).
17
17
 
18
18
  ## Installation
@@ -45,7 +45,7 @@ This connector is fully compatible with both TypeScript and pure JavaScript proj
45
45
 
46
46
  - [src](./src) - the whole connector written in TypeScript
47
47
  - [lib](./lib) - the JavaScript version of the project (built from TypeScript). This should not be edited directly, as it will be overwritten with each release.
48
- - [dist](./dist) - the packed bundle of the project for use in browser environments.
48
+ - [dist](./dist) - the web-packed bundle of the project for use in browser environments.
49
49
  - [examples](./examples) - some implementation examples & demonstrations. Contributions are welcome!
50
50
 
51
51
  ---
@@ -149,6 +149,19 @@ client.getOrderBook({ symbol: 'BTCUSD' })
149
149
  ## WebSockets
150
150
  All API groups can be used via a shared `WebsocketClient`. However, make sure to make one instance of the WebsocketClient per API group (spot vs inverse vs linear vs linearfutures etc):
151
151
 
152
+ The WebsocketClient can be configured to a specific API group using the market parameter. These are the currently available API groups:
153
+ | API Category | Market | Description |
154
+ |:----------------------------: |:-------------------: |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
155
+ | Unified Margin | TBC | The [derivatives v3](https://bybit-exchange.github.io/docs/derivativesV3/unified_margin/#t-websocket) category for unified margin. |
156
+ | Futures v2 - Inverse Perps | `market: 'inverse'` | The [inverse v2 perps](https://bybit-exchange.github.io/docs/futuresV2/inverse/#t-websocket) category. |
157
+ | Futures v2 - USDT Perps | `market: 'linear'` | The [USDT/linear v2 perps](https://bybit-exchange.github.io/docs/futuresV2/linear/#t-websocket) category. |
158
+ | Futures v2 - Inverse Futures | `market: 'inverse'` | The [inverse futures v2](https://bybit-exchange.github.io/docs/futuresV2/inverse_futures/#t-websocket) category uses the same market as inverse perps. |
159
+ | Spot v3 | `market: 'spotv3'` | The [spot v3](https://bybit-exchange.github.io/docs/spot/v3/#t-websocket) category. |
160
+ | Spot v1 | `market: 'spot'` | The older [spot v1](https://bybit-exchange.github.io/docs/spot/v1/#t-websocket) category. Use the `spotv3` market if possible, as the v1 category does not have automatic re-subscribe if reconnected. |
161
+ | Copy Trading | `market: 'linear'` | The [copy trading](https://bybit-exchange.github.io/docs/copy_trading/#t-websocket) category. Use the linear market to listen to all copy trading topics. |
162
+ | USDC Perps | TBC | The [USDC perps](https://bybit-exchange.github.io/docs/usdc/perpetual/#t-websocket) category. |
163
+ | USDC Options | TBC | The [USDC options](https://bybit-exchange.github.io/docs/usdc/option/#t-websocket) category. |
164
+
152
165
  ```javascript
153
166
  const { WebsocketClient } = require('bybit-api');
154
167
 
package/lib/index.d.ts CHANGED
@@ -10,6 +10,6 @@ export * from './usdc-perpetual-client';
10
10
  export * from './unified-margin-client';
11
11
  export * from './websocket-client';
12
12
  export * from './util/logger';
13
+ export * from './util';
13
14
  export * from './types';
14
- export * from './util/WsStore';
15
15
  export * from './constants/enum';
package/lib/index.js CHANGED
@@ -22,7 +22,7 @@ __exportStar(require("./usdc-perpetual-client"), exports);
22
22
  __exportStar(require("./unified-margin-client"), exports);
23
23
  __exportStar(require("./websocket-client"), exports);
24
24
  __exportStar(require("./util/logger"), exports);
25
+ __exportStar(require("./util"), exports);
25
26
  __exportStar(require("./types"), exports);
26
- __exportStar(require("./util/WsStore"), exports);
27
27
  __exportStar(require("./constants/enum"), exports);
28
28
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAuC;AACvC,wDAAsC;AACtC,mDAAiC;AACjC,2DAAyC;AACzC,kDAAgC;AAChC,gDAA8B;AAC9B,mDAAiC;AACjC,uDAAqC;AACrC,0DAAwC;AACxC,0DAAwC;AACxC,qDAAmC;AACnC,gDAA8B;AAC9B,0CAAwB;AACxB,iDAA+B;AAC/B,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAuC;AACvC,wDAAsC;AACtC,mDAAiC;AACjC,2DAAyC;AACzC,kDAAgC;AAChC,gDAA8B;AAC9B,mDAAiC;AACjC,uDAAqC;AACrC,0DAAwC;AACxC,0DAAwC;AACxC,qDAAmC;AACnC,gDAA8B;AAC9B,yCAAuB;AACvB,0CAAwB;AACxB,mDAAiC"}
@@ -2,7 +2,9 @@ import { InverseClient } from '../inverse-client';
2
2
  import { LinearClient } from '../linear-client';
3
3
  import { SpotClient } from '../spot-client';
4
4
  import { SpotClientV3 } from '../spot-client-v3';
5
- export declare type RESTClient = InverseClient | LinearClient | SpotClient | SpotClientV3;
5
+ import { USDCOptionClient } from '../usdc-option-client';
6
+ import { USDCPerpetualClient } from '../usdc-perpetual-client';
7
+ export declare type RESTClient = InverseClient | LinearClient | SpotClient | SpotClientV3 | USDCOptionClient | USDCPerpetualClient;
6
8
  export declare type numberInString = string;
7
9
  export declare type OrderSide = 'Buy' | 'Sell';
8
10
  export declare type KlineInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '6h' | '12h' | '1d' | '1w' | '1M';
@@ -1,5 +1,6 @@
1
- import { RestClientOptions } from '../util';
2
- export declare type APIMarket = 'inverse' | 'linear' | 'spot' | 'v3';
1
+ import { RestClientOptions, WS_KEY_MAP } from '../util';
2
+ /** For spot markets, spotV3 is recommended */
3
+ export declare type APIMarket = 'inverse' | 'linear' | 'spot' | 'spotv3' | 'usdcOption' | 'usdcPerp';
3
4
  export declare type WsPublicInverseTopic = 'orderBookL2_25' | 'orderBookL2_200' | 'trade' | 'insurance' | 'instrument_info' | 'klineV2';
4
5
  export declare type WsPublicUSDTPerpTopic = 'orderBookL2_25' | 'orderBookL2_200' | 'trade' | 'insurance' | 'instrument_info' | 'kline';
5
6
  export declare type WsPublicSpotV1Topic = 'trade' | 'realtimes' | 'kline' | 'depth' | 'mergedDepth' | 'diffDepth';
@@ -11,11 +12,11 @@ export declare type WsPrivateSpotTopic = 'outboundAccountInfo' | 'executionRepor
11
12
  export declare type WsPrivateTopic = WsPrivateInverseTopic | WsPrivateUSDTPerpTopic | WsPrivateSpotTopic | string;
12
13
  export declare type WsTopic = WsPublicTopics | WsPrivateTopic;
13
14
  /** This is used to differentiate between each of the available websocket streams (as bybit has multiple websockets) */
14
- export declare type WsKey = 'inverse' | 'linearPrivate' | 'linearPublic' | 'spotPrivate' | 'spotPublic';
15
+ export declare type WsKey = typeof WS_KEY_MAP[keyof typeof WS_KEY_MAP];
15
16
  export interface WSClientConfigurableOptions {
16
17
  key?: string;
17
18
  secret?: string;
18
- livenet?: boolean;
19
+ testnet?: boolean;
19
20
  /**
20
21
  * The API group this client should connect to.
21
22
  *
@@ -32,7 +33,7 @@ export interface WSClientConfigurableOptions {
32
33
  fetchTimeOffsetBeforeAuth?: boolean;
33
34
  }
34
35
  export interface WebsocketClientOptions extends WSClientConfigurableOptions {
35
- livenet: boolean;
36
+ testnet?: boolean;
36
37
  market: APIMarket;
37
38
  pongTimeout: number;
38
39
  pingInterval: number;
@@ -1,4 +1,5 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
+ import { WsKey } from '../types';
2
3
  import { DefaultLogger } from './logger';
3
4
  export declare enum WsConnectionStateEnum {
4
5
  INITIAL = 0,
@@ -23,6 +24,8 @@ interface WsStoredState {
23
24
  activePingTimer?: ReturnType<typeof setTimeout> | undefined;
24
25
  /** A timer tracking that an upstream heartbeat was sent, expecting a reply before it expires */
25
26
  activePongTimer?: ReturnType<typeof setTimeout> | undefined;
27
+ /** If a reconnection is in progress, this will have the timer for the delayed reconnect */
28
+ activeReconnectTimer?: ReturnType<typeof setTimeout> | undefined;
26
29
  /**
27
30
  * All the topics we are expected to be subscribed to (and we automatically resubscribe to if the connection drops)
28
31
  */
@@ -33,21 +36,21 @@ export default class WsStore {
33
36
  private logger;
34
37
  constructor(logger: typeof DefaultLogger);
35
38
  /** Get WS stored state for key, optionally create if missing */
36
- get(key: string, createIfMissing?: true): WsStoredState;
37
- get(key: string, createIfMissing?: false): WsStoredState | undefined;
38
- getKeys(): string[];
39
- create(key: string): WsStoredState | undefined;
40
- delete(key: string): void;
41
- hasExistingActiveConnection(key: string): boolean;
42
- getWs(key: string): WebSocket | undefined;
43
- setWs(key: string, wsConnection: WebSocket): WebSocket;
44
- isWsOpen(key: string): boolean;
45
- getConnectionState(key: string): WsConnectionStateEnum;
46
- setConnectionState(key: string, state: WsConnectionStateEnum): void;
47
- isConnectionState(key: string, state: WsConnectionStateEnum): boolean;
48
- getTopics(key: string): WsTopicList;
39
+ get(key: WsKey, createIfMissing?: true): WsStoredState;
40
+ get(key: WsKey, createIfMissing?: false): WsStoredState | undefined;
41
+ getKeys(): WsKey[];
42
+ create(key: WsKey): WsStoredState | undefined;
43
+ delete(key: WsKey): void;
44
+ hasExistingActiveConnection(key: WsKey): boolean;
45
+ getWs(key: WsKey): WebSocket | undefined;
46
+ setWs(key: WsKey, wsConnection: WebSocket): WebSocket;
47
+ isWsOpen(key: WsKey): boolean;
48
+ getConnectionState(key: WsKey): WsConnectionStateEnum;
49
+ setConnectionState(key: WsKey, state: WsConnectionStateEnum): void;
50
+ isConnectionState(key: WsKey, state: WsConnectionStateEnum): boolean;
51
+ getTopics(key: WsKey): WsTopicList;
49
52
  getTopicsByKey(): Record<string, WsTopicList>;
50
- addTopic(key: string, topic: WsTopic): WsTopicList;
51
- deleteTopic(key: string, topic: WsTopic): boolean;
53
+ addTopic(key: WsKey, topic: WsTopic): WsTopicList;
54
+ deleteTopic(key: WsKey, topic: WsTopic): boolean;
52
55
  }
53
56
  export {};
@@ -9,6 +9,7 @@ var WsConnectionStateEnum;
9
9
  WsConnectionStateEnum[WsConnectionStateEnum["CONNECTED"] = 2] = "CONNECTED";
10
10
  WsConnectionStateEnum[WsConnectionStateEnum["CLOSING"] = 3] = "CLOSING";
11
11
  WsConnectionStateEnum[WsConnectionStateEnum["RECONNECTING"] = 4] = "RECONNECTING";
12
+ // ERROR = 5,
12
13
  })(WsConnectionStateEnum = exports.WsConnectionStateEnum || (exports.WsConnectionStateEnum = {}));
13
14
  class WsStore {
14
15
  constructor(logger) {
@@ -1 +1 @@
1
- {"version":3,"file":"WsStore.js","sourceRoot":"","sources":["../../src/util/WsStore.ts"],"names":[],"mappings":";;;AAEA,qCAAyC;AAEzC,IAAY,qBAMX;AAND,WAAY,qBAAqB;IAC/B,uEAAW,CAAA;IACX,6EAAc,CAAA;IACd,2EAAa,CAAA;IACb,uEAAW,CAAA;IACX,iFAAgB,CAAA;AAClB,CAAC,EANW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAMhC;AAyBD,MAAqB,OAAO;IAI1B,YAAY,MAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,sBAAa,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAKD,GAAG,CAAC,GAAW,EAAE,eAAyB;QACxC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACrB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SAC1B;QAED,IAAI,eAAe,EAAE;YACnB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACzB;IACH,CAAC;IAED,OAAO;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;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AAC,GAAG,EAAE,IAAI,CAAE,CAAC,eAAgB,CAAC;IAC/C,CAAC;IAED,kBAAkB,CAAC,GAAU,EAAE,KAA4B;QACzD,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAE,CAAC,eAAe,GAAG,KAAK,CAAC;IAC/C,CAAC;IAED,iBAAiB,CAAC,GAAU,EAAE,KAA4B;QACxD,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC;IAChD,CAAC;IAED,uBAAuB;IAEvB,SAAS,CAAC,GAAU;QAClB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,gBAAgB,CAAC;IAC9C,CAAC;IAED,cAAc;QACZ,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;YACjC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAe,CAAC,CAAC;SAClD;QACD,OAAO,MAAM,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;AApHD,0BAoHC"}
@@ -1 +1,2 @@
1
+ /** This is async because the browser version uses a promise (browser-support) */
1
2
  export declare function signMessage(message: string, secret: string): Promise<string>;
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.signMessage = void 0;
13
13
  const crypto_1 = require("crypto");
14
+ /** This is async because the browser version uses a promise (browser-support) */
14
15
  function signMessage(message, secret) {
15
16
  return __awaiter(this, void 0, void 0, function* () {
16
17
  return crypto_1.createHmac('sha256', secret).update(message).digest('hex');
@@ -1 +1 @@
1
- {"version":3,"file":"node-support.js","sourceRoot":"","sources":["../../src/util/node-support.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAoC;AAEpC,SAAsB,WAAW,CAC/B,OAAe,EACf,MAAc;;QAEd,OAAO,mBAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;CAAA;AALD,kCAKC"}
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,mBAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;CAAA;AALD,kCAKC"}
@@ -19,7 +19,7 @@ export interface RestClientOptions {
19
19
  }
20
20
  export declare function serializeParams(params?: object, strict_validation?: boolean): string;
21
21
  export declare function getRestBaseUrl(useLivenet: boolean, restInverseOptions: RestClientOptions): string;
22
- export declare function isWsPong(response: any): any;
22
+ export declare function isWsPong(msg: any): boolean;
23
23
  export declare const agentSource = "bybitapinode";
24
24
  /**
25
25
  * Used to switch how authentication/requests work under the hood (primarily for SPOT since it's different there)
@@ -28,14 +28,20 @@ function getRestBaseUrl(useLivenet, restInverseOptions) {
28
28
  return exchangeBaseUrls.testnet;
29
29
  }
30
30
  exports.getRestBaseUrl = getRestBaseUrl;
31
- function isWsPong(response) {
32
- if (response.pong || response.ping) {
31
+ function isWsPong(msg) {
32
+ if (!msg) {
33
+ return false;
34
+ }
35
+ if (msg.pong || msg.ping) {
36
+ return true;
37
+ }
38
+ if (msg['op'] === 'pong') {
33
39
  return true;
34
40
  }
35
- return (response.request &&
36
- response.request.op === 'ping' &&
37
- response.ret_msg === 'pong' &&
38
- response.success === true);
41
+ return (msg.request &&
42
+ msg.request.op === 'ping' &&
43
+ msg.ret_msg === 'pong' &&
44
+ msg.success === true);
39
45
  }
40
46
  exports.isWsPong = isWsPong;
41
47
  exports.agentSource = 'bybitapinode';
@@ -1 +1 @@
1
- {"version":3,"file":"requestUtils.js","sourceRoot":"","sources":["../../src/util/requestUtils.ts"],"names":[],"mappings":";;;AA0BA,SAAgB,eAAe,CAC7B,SAAiB,EAAE,EACnB,iBAAiB,GAAG,KAAK;IAEzB,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SACvB,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,iBAAiB,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAC9D,MAAM,IAAI,KAAK,CACb,uDAAuD,CACxD,CAAC;SACH;QACD,OAAO,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;IAC3B,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAhBD,0CAgBC;AAED,SAAgB,cAAc,CAC5B,UAAmB,EACnB,kBAAqC;IAErC,MAAM,gBAAgB,GAAG;QACvB,OAAO,EAAE,uBAAuB;QAChC,OAAO,EAAE,+BAA+B;KACzC,CAAC;IAEF,IAAI,kBAAkB,CAAC,OAAO,EAAE;QAC9B,OAAO,kBAAkB,CAAC,OAAO,CAAC;KACnC;IAED,IAAI,UAAU,KAAK,IAAI,EAAE;QACvB,OAAO,gBAAgB,CAAC,OAAO,CAAC;KACjC;IACD,OAAO,gBAAgB,CAAC,OAAO,CAAC;AAClC,CAAC;AAjBD,wCAiBC;AAED,SAAgB,QAAQ,CAAC,QAAa;IACpC,IAAI,QAAQ,C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OAAO,EAAE;QAC9B,OAAO,kBAAkB,CAAC,OAAO,CAAC;KACnC;IAED,IAAI,UAAU,KAAK,IAAI,EAAE;QACvB,OAAO,gBAAgB,CAAC,OAAO,CAAC;KACjC;IACD,OAAO,gBAAgB,CAAC,OAAO,CAAC;AAClC,CAAC;AAjBD,wCAiBC;AAED,SAAgB,QAAQ,CAAC,GAAQ;IAC/B,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,KAAK,CAAC;KACd;IACD,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,MAAM,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,GAAG,CAAC,OAAO;QACX,GAAG,CAAC,OAAO,CAAC,EAAE,KAAK,MAAM;QACzB,GAAG,CAAC,OAAO,KAAK,MAAM;QACtB,GAAG,CAAC,OAAO,KAAK,IAAI,CACrB,CAAC;AACJ,CAAC;AAlBD,4BAkBC;AAEY,QAAA,WAAW,GAAG,cAAc,CAAC;AAE1C;;GAEG;AACU,QAAA,qBAAqB,GAAG;IACnC,YAAY,EAAE,cAAc;IAC5B,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,gBAAgB;IAChC,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,IAAI;CACA,CAAC"}
@@ -1,8 +1,34 @@
1
- import { WsKey } from '../types';
2
- export declare const wsKeyInverse = "inverse";
3
- export declare const wsKeyLinearPrivate = "linearPrivate";
4
- export declare const wsKeyLinearPublic = "linearPublic";
5
- export declare const wsKeySpotPrivate = "spotPrivate";
6
- export declare const wsKeySpotPublic = "spotPublic";
7
- export declare function getLinearWsKeyForTopic(topic: string): WsKey;
8
- export declare function getSpotWsKeyForTopic(topic: string): WsKey;
1
+ import { APIMarket, WsKey } from '../types';
2
+ interface NetworkMapV3 {
3
+ livenet: string;
4
+ livenet2?: string;
5
+ testnet: string;
6
+ testnet2?: string;
7
+ }
8
+ declare type PublicPrivateNetwork = 'public' | 'private';
9
+ export declare const WS_BASE_URL_MAP: Record<APIMarket, Record<PublicPrivateNetwork, NetworkMapV3>>;
10
+ export declare const WS_KEY_MAP: {
11
+ readonly inverse: "inverse";
12
+ readonly linearPrivate: "linearPrivate";
13
+ readonly linearPublic: "linearPublic";
14
+ readonly spotPrivate: "spotPrivate";
15
+ readonly spotPublic: "spotPublic";
16
+ readonly spotV3Private: "spotV3Private";
17
+ readonly spotV3Public: "spotV3Public";
18
+ readonly usdcOptionPrivate: "usdcOptionPrivate";
19
+ readonly usdcOptionPublic: "usdcOptionPublic";
20
+ readonly usdcPerpPrivate: "usdcPerpPrivate";
21
+ readonly usdcPerpPublic: "usdcPerpPublic";
22
+ };
23
+ export declare const WS_AUTH_ON_CONNECT_KEYS: WsKey[];
24
+ export declare const PUBLIC_WS_KEYS: string[];
25
+ export declare function getWsKeyForTopic(market: APIMarket, topic: string, isPrivate?: boolean): WsKey;
26
+ export declare function getUsdcWsKeyForTopic(topic: string, subGroup: 'option' | 'perp'): WsKey;
27
+ export declare const WS_ERROR_ENUM: {
28
+ NOT_AUTHENTICATED_SPOT_V3: string;
29
+ API_ERROR_GENERIC: string;
30
+ API_SIGN_AUTH_FAILED: string;
31
+ USDC_OPTION_AUTH_FAILED: string;
32
+ };
33
+ export declare function neverGuard(x: never, msg: string): Error;
34
+ export {};
@@ -1,39 +1,194 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSpotWsKeyForTopic = exports.getLinearWsKeyForTopic = exports.wsKeySpotPublic = exports.wsKeySpotPrivate = exports.wsKeyLinearPublic = exports.wsKeyLinearPrivate = exports.wsKeyInverse = void 0;
4
- exports.wsKeyInverse = 'inverse';
5
- exports.wsKeyLinearPrivate = 'linearPrivate';
6
- exports.wsKeyLinearPublic = 'linearPublic';
7
- exports.wsKeySpotPrivate = 'spotPrivate';
8
- exports.wsKeySpotPublic = 'spotPublic';
9
- function getLinearWsKeyForTopic(topic) {
10
- const privateLinearTopics = [
11
- 'position',
12
- 'execution',
13
- 'order',
14
- 'stop_order',
15
- 'wallet',
16
- ];
17
- if (privateLinearTopics.includes(topic)) {
18
- return exports.wsKeyLinearPrivate;
3
+ exports.neverGuard = exports.WS_ERROR_ENUM = exports.getUsdcWsKeyForTopic = exports.getWsKeyForTopic = exports.PUBLIC_WS_KEYS = exports.WS_AUTH_ON_CONNECT_KEYS = exports.WS_KEY_MAP = exports.WS_BASE_URL_MAP = void 0;
4
+ exports.WS_BASE_URL_MAP = {
5
+ inverse: {
6
+ public: {
7
+ livenet: 'wss://stream.bybit.com/realtime',
8
+ testnet: 'wss://stream-testnet.bybit.com/realtime',
9
+ },
10
+ private: {
11
+ livenet: 'wss://stream.bybit.com/realtime',
12
+ testnet: 'wss://stream-testnet.bybit.com/realtime',
13
+ },
14
+ },
15
+ linear: {
16
+ public: {
17
+ livenet: 'wss://stream.bybit.com/realtime_public',
18
+ livenet2: 'wss://stream.bytick.com/realtime_public',
19
+ testnet: 'wss://stream-testnet.bybit.com/realtime_public',
20
+ },
21
+ private: {
22
+ livenet: 'wss://stream.bybit.com/realtime_private',
23
+ livenet2: 'wss://stream.bytick.com/realtime_private',
24
+ testnet: 'wss://stream-testnet.bybit.com/realtime_private',
25
+ },
26
+ },
27
+ spot: {
28
+ public: {
29
+ livenet: 'wss://stream.bybit.com/spot/quote/ws/v1',
30
+ livenet2: 'wss://stream.bybit.com/spot/quote/ws/v2',
31
+ testnet: 'wss://stream-testnet.bybit.com/spot/quote/ws/v1',
32
+ testnet2: 'wss://stream-testnet.bybit.com/spot/quote/ws/v2',
33
+ },
34
+ private: {
35
+ livenet: 'wss://stream.bybit.com/spot/ws',
36
+ testnet: 'wss://stream-testnet.bybit.com/spot/ws',
37
+ },
38
+ },
39
+ spotv3: {
40
+ public: {
41
+ livenet: 'wss://stream.bybit.com/spot/public/v3',
42
+ testnet: 'wss://stream-testnet.bybit.com/spot/public/v3',
43
+ },
44
+ private: {
45
+ livenet: 'wss://stream.bybit.com/spot/private/v3',
46
+ testnet: 'wss://stream-testnet.bybit.com/spot/private/v3',
47
+ },
48
+ },
49
+ usdcOption: {
50
+ public: {
51
+ livenet: 'wss://stream.bybit.com/trade/option/usdc/public/v1',
52
+ livenet2: 'wss://stream.bytick.com/trade/option/usdc/public/v1',
53
+ testnet: 'wss://stream-testnet.bybit.com/trade/option/usdc/public/v1',
54
+ },
55
+ private: {
56
+ livenet: 'wss://stream.bybit.com/trade/option/usdc/private/v1',
57
+ livenet2: 'wss://stream.bytick.com/trade/option/usdc/private/v1',
58
+ testnet: 'wss://stream-testnet.bybit.com/trade/option/usdc/private/v1',
59
+ },
60
+ },
61
+ usdcPerp: {
62
+ public: {
63
+ livenet: 'wss://stream.bybit.com/perpetual/ws/v1/realtime_public',
64
+ livenet2: 'wss://stream.bytick.com/perpetual/ws/v1/realtime_public',
65
+ testnet: 'wss://stream-testnet.bybit.com/perpetual/ws/v1/realtime_public',
66
+ },
67
+ private: {
68
+ livenet: 'wss://stream.bybit.com/trade/option/usdc/private/v1',
69
+ livenet2: 'wss://stream.bytick.com/trade/option/usdc/private/v1',
70
+ testnet: 'wss://stream-testnet.bybit.com/trade/option/usdc/private/v1',
71
+ },
72
+ },
73
+ };
74
+ exports.WS_KEY_MAP = {
75
+ inverse: 'inverse',
76
+ linearPrivate: 'linearPrivate',
77
+ linearPublic: 'linearPublic',
78
+ spotPrivate: 'spotPrivate',
79
+ spotPublic: 'spotPublic',
80
+ spotV3Private: 'spotV3Private',
81
+ spotV3Public: 'spotV3Public',
82
+ usdcOptionPrivate: 'usdcOptionPrivate',
83
+ usdcOptionPublic: 'usdcOptionPublic',
84
+ usdcPerpPrivate: 'usdcPerpPrivate',
85
+ usdcPerpPublic: 'usdcPerpPublic',
86
+ };
87
+ exports.WS_AUTH_ON_CONNECT_KEYS = [
88
+ exports.WS_KEY_MAP.spotV3Private,
89
+ exports.WS_KEY_MAP.usdcOptionPrivate,
90
+ exports.WS_KEY_MAP.usdcPerpPrivate,
91
+ ];
92
+ exports.PUBLIC_WS_KEYS = [
93
+ exports.WS_KEY_MAP.linearPublic,
94
+ exports.WS_KEY_MAP.spotPublic,
95
+ exports.WS_KEY_MAP.spotV3Public,
96
+ exports.WS_KEY_MAP.usdcOptionPublic,
97
+ exports.WS_KEY_MAP.usdcPerpPublic,
98
+ ];
99
+ /** Used to automatically determine if a sub request should be to the public or private ws (when there's two) */
100
+ const PRIVATE_TOPICS = [
101
+ 'position',
102
+ 'execution',
103
+ 'order',
104
+ 'stop_order',
105
+ 'wallet',
106
+ 'outboundAccountInfo',
107
+ 'executionReport',
108
+ 'ticketInfo',
109
+ // copy trading apis
110
+ 'copyTradePosition',
111
+ 'copyTradeOrder',
112
+ 'copyTradeExecution',
113
+ 'copyTradeWallet',
114
+ // usdc options
115
+ 'user.openapi.option.position',
116
+ 'user.openapi.option.trade',
117
+ 'user.order',
118
+ 'user.openapi.option.order',
119
+ 'user.service',
120
+ 'user.openapi.greeks',
121
+ 'user.mmp.event',
122
+ // usdc perps
123
+ 'user.openapi.perp.position',
124
+ 'user.openapi.perp.trade',
125
+ 'user.openapi.perp.order',
126
+ 'user.service',
127
+ // unified margin
128
+ 'user.position.unifiedAccount',
129
+ 'user.execution.unifiedAccount',
130
+ 'user.order.unifiedAccount',
131
+ 'user.wallet.unifiedAccount',
132
+ 'user.greeks.unifiedAccount',
133
+ ];
134
+ function getWsKeyForTopic(market, topic, isPrivate) {
135
+ const isPrivateTopic = isPrivate === true || PRIVATE_TOPICS.includes(topic);
136
+ switch (market) {
137
+ case 'inverse': {
138
+ return exports.WS_KEY_MAP.inverse;
139
+ }
140
+ case 'linear': {
141
+ return isPrivateTopic
142
+ ? exports.WS_KEY_MAP.linearPrivate
143
+ : exports.WS_KEY_MAP.linearPublic;
144
+ }
145
+ case 'spot': {
146
+ return isPrivateTopic ? exports.WS_KEY_MAP.spotPrivate : exports.WS_KEY_MAP.spotPublic;
147
+ }
148
+ case 'spotv3': {
149
+ return isPrivateTopic
150
+ ? exports.WS_KEY_MAP.spotV3Private
151
+ : exports.WS_KEY_MAP.spotV3Public;
152
+ }
153
+ case 'usdcOption': {
154
+ return isPrivateTopic
155
+ ? exports.WS_KEY_MAP.usdcOptionPrivate
156
+ : exports.WS_KEY_MAP.usdcOptionPublic;
157
+ }
158
+ case 'usdcPerp': {
159
+ return isPrivateTopic
160
+ ? exports.WS_KEY_MAP.usdcPerpPrivate
161
+ : exports.WS_KEY_MAP.usdcPerpPublic;
162
+ }
163
+ default: {
164
+ throw neverGuard(market, `getWsKeyForTopic(): Unhandled market`);
165
+ }
19
166
  }
20
- return exports.wsKeyLinearPublic;
21
167
  }
22
- exports.getLinearWsKeyForTopic = getLinearWsKeyForTopic;
23
- function getSpotWsKeyForTopic(topic) {
24
- const privateLinearTopics = [
25
- 'position',
26
- 'execution',
27
- 'order',
28
- 'stop_order',
29
- 'outboundAccountInfo',
30
- 'executionReport',
31
- 'ticketInfo',
32
- ];
33
- if (privateLinearTopics.includes(topic)) {
34
- return exports.wsKeySpotPrivate;
168
+ exports.getWsKeyForTopic = getWsKeyForTopic;
169
+ function getUsdcWsKeyForTopic(topic, subGroup) {
170
+ const isPrivateTopic = PRIVATE_TOPICS.includes(topic);
171
+ if (subGroup === 'option') {
172
+ return isPrivateTopic
173
+ ? exports.WS_KEY_MAP.usdcOptionPrivate
174
+ : exports.WS_KEY_MAP.usdcOptionPublic;
35
175
  }
36
- return exports.wsKeySpotPublic;
176
+ return isPrivateTopic
177
+ ? exports.WS_KEY_MAP.usdcOptionPrivate
178
+ : exports.WS_KEY_MAP.usdcOptionPublic;
179
+ // return isPrivateTopic
180
+ // ? WS_KEY_MAP.usdcPerpPrivate
181
+ // : WS_KEY_MAP.usdcPerpPublic;
37
182
  }
38
- exports.getSpotWsKeyForTopic = getSpotWsKeyForTopic;
183
+ exports.getUsdcWsKeyForTopic = getUsdcWsKeyForTopic;
184
+ exports.WS_ERROR_ENUM = {
185
+ NOT_AUTHENTICATED_SPOT_V3: '-1004',
186
+ API_ERROR_GENERIC: '10001',
187
+ API_SIGN_AUTH_FAILED: '10003',
188
+ USDC_OPTION_AUTH_FAILED: '3303006',
189
+ };
190
+ function neverGuard(x, msg) {
191
+ return new Error(`Unhandled value exception "x", ${msg}`);
192
+ }
193
+ exports.neverGuard = neverGuard;
39
194
  //# sourceMappingURL=websocket-util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"websocket-util.js","sourceRoot":"","sources":["../../src/util/websocket-util.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAAG,SAAS,CAAC;AACzB,QAAA,kBAAkB,GAAG,eAAe,CAAC;AACrC,QAAA,iBAAiB,GAAG,cAAc,CAAC;AACnC,QAAA,gBAAgB,GAAG,aAAa,CAAC;AACjC,QAAA,eAAe,GAAG,YAAY,CAAC;AAE5C,SAAgB,sBAAsB,CAAC,KAAa;IAClD,MAAM,mBAAmB,GAAG;QAC1B,UAAU;QACV,WAAW;QACX,OAAO;QACP,YAAY;QACZ,QAAQ;KACT,CAAC;IACF,IAAI,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACvC,OAAO,0BAAkB,CAAC;KAC3B;IAED,OAAO,yBAAiB,CAAC;AAC3B,CAAC;AAbD,wDAaC;AAED,SAAgB,oBAAoB,CAAC,KAAa;IAChD,MAAM,mBAAmB,GAAG;QAC1B,UAAU;QACV,WAAW;QACX,OAAO;QACP,YAAY;QACZ,qBAAqB;QACrB,iBAAiB;QACjB,YAAY;KACb,CAAC;IAEF,IAAI,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACvC,OAAO,wBAAgB,CAAC;KACzB;IAED,OAAO,uBAAe,CAAC;AACzB,CAAC;AAhBD,oDAgBC"}
1
+ {"version":3,"file":"websocket-util.js","sourceRoot":"","sources":["../../src/util/websocket-util.ts"],"names":[],"mappings":";;;AAWa,QAA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