diff --git a/examples/ws-public.ts b/examples/ws-public.ts index 71362ad..e358919 100644 --- a/examples/ws-public.ts +++ b/examples/ws-public.ts @@ -16,10 +16,10 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src'; // market: 'linear', // market: 'inverse', // market: 'spot', - market: 'spotv3', + // market: 'spotv3', // market: 'usdcOption', // market: 'usdcPerp', - // market: 'unifiedPerp', + market: 'unifiedPerp', // market: 'unifiedOption', }, logger @@ -62,7 +62,7 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src'; // wsClient.subscribe('trade.BTCUSDT'); // Spot V3 - wsClient.subscribe('trade.BTCUSDT'); + // wsClient.subscribe('trade.BTCUSDT'); // Or an array of topics // wsClient.subscribe([ // 'orderbook.40.BTCUSDT', @@ -137,11 +137,12 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src'; // `recenttrades.SOL`, // ]); - // usdc perps - // wsClient.subscribe('trade.BTCPERP'); + // usdc perps (note: the syntax is different for the unified perp market) + // wsClient.subscribe('trade.BTCUSDC'); // unified perps // wsClient.subscribe('publicTrade.BTCUSDT'); + wsClient.subscribe('publicTrade.BTCPERP'); // For spot v1 (the old, deprecated client), request public connection first then send required topics on 'open' // Not necessary for spot v3 diff --git a/package.json b/package.json index 32db6b1..3e9a6d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "3.3.9", + "version": "3.3.10", "description": "Complete & robust node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & integration tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/util/websocket-util.ts b/src/util/websocket-util.ts index c15d385..6b437bf 100644 --- a/src/util/websocket-util.ts +++ b/src/util/websocket-util.ts @@ -276,7 +276,10 @@ export function getWsKeyForTopic( return WS_KEY_MAP.unifiedPerpUSDTPublic; } - if (upperTopic.indexOf('USDC') !== -1) { + if ( + upperTopic.indexOf('USDC') !== -1 || + upperTopic.indexOf('PERP') !== -1 + ) { return WS_KEY_MAP.unifiedPerpUSDCPublic; }