UNPKG

tardis-dev

Version:

Convenient access to tick-level historical and real-time cryptocurrency market data via Node.js

40 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DydxV4RealTimeFeed = void 0; const realtimefeed_1 = require("./realtimefeed"); class DydxV4RealTimeFeed extends realtimefeed_1.RealTimeFeedBase { constructor() { super(...arguments); this.wssURL = 'wss://indexer.dydx.trade/v4/ws'; } mapToSubscribeMessages(filters) { const subs = filters .map((filter) => { if (filter.channel === 'v4_markets') { return [ { type: 'subscribe', channel: 'v4_markets' } ]; } if (!filter.symbols || filter.symbols.length === 0) { throw new Error('DydxV4RealTimeFeed requires explicitly specified symbols when subscribing to live feed'); } return filter.symbols.map((symbol) => { return { type: 'subscribe', channel: filter.channel, id: symbol }; }); }) .flatMap((f) => f); return subs; } messageIsError(message) { return message.type === 'error'; } } exports.DydxV4RealTimeFeed = DydxV4RealTimeFeed; //# sourceMappingURL=dydx_v4.js.map