v3.3.10: fix(#220): correctly detecting usdc pairs for unified perp ws market

This commit is contained in:
tiagosiebler
2023-01-24 11:04:50 +00:00
parent ee90cc07e7
commit 8010b2cebf
3 changed files with 11 additions and 7 deletions

View File

@@ -16,10 +16,10 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src';
// market: 'linear', // market: 'linear',
// market: 'inverse', // market: 'inverse',
// market: 'spot', // market: 'spot',
market: 'spotv3', // market: 'spotv3',
// market: 'usdcOption', // market: 'usdcOption',
// market: 'usdcPerp', // market: 'usdcPerp',
// market: 'unifiedPerp', market: 'unifiedPerp',
// market: 'unifiedOption', // market: 'unifiedOption',
}, },
logger logger
@@ -62,7 +62,7 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src';
// wsClient.subscribe('trade.BTCUSDT'); // wsClient.subscribe('trade.BTCUSDT');
// Spot V3 // Spot V3
wsClient.subscribe('trade.BTCUSDT'); // wsClient.subscribe('trade.BTCUSDT');
// Or an array of topics // Or an array of topics
// wsClient.subscribe([ // wsClient.subscribe([
// 'orderbook.40.BTCUSDT', // 'orderbook.40.BTCUSDT',
@@ -137,11 +137,12 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src';
// `recenttrades.SOL`, // `recenttrades.SOL`,
// ]); // ]);
// usdc perps // usdc perps (note: the syntax is different for the unified perp market)
// wsClient.subscribe('trade.BTCPERP'); // wsClient.subscribe('trade.BTCUSDC');
// unified perps // unified perps
// wsClient.subscribe('publicTrade.BTCUSDT'); // 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' // For spot v1 (the old, deprecated client), request public connection first then send required topics on 'open'
// Not necessary for spot v3 // Not necessary for spot v3

View File

@@ -1,6 +1,6 @@
{ {
"name": "bybit-api", "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.", "description": "Complete & robust node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & integration tests.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@@ -276,7 +276,10 @@ export function getWsKeyForTopic(
return WS_KEY_MAP.unifiedPerpUSDTPublic; return WS_KEY_MAP.unifiedPerpUSDTPublic;
} }
if (upperTopic.indexOf('USDC') !== -1) { if (
upperTopic.indexOf('USDC') !== -1 ||
upperTopic.indexOf('PERP') !== -1
) {
return WS_KEY_MAP.unifiedPerpUSDCPublic; return WS_KEY_MAP.unifiedPerpUSDCPublic;
} }