tardis-dev
Version:
Convenient access to tick-level historical and real-time cryptocurrency market data via Node.js
32 lines • 1.08 kB
JavaScript
import { RealTimeFeedBase } from "./realtimefeed.js";
export class HyperliquidRealTimeFeed extends RealTimeFeedBase {
wssURL = 'wss://api.hyperliquid.xyz/ws';
mapToSubscribeMessages(filters) {
return filters
.map((filter) => {
if (!filter.symbols || filter.symbols.length === 0) {
throw new Error('HyperliquidRealTimeFeed requires explicitly specified symbols when subscribing to live feed');
}
return filter.symbols.map((symbol) => {
return {
method: 'subscribe',
subscription: {
coin: symbol,
type: filter.channel
}
};
});
})
.flatMap((f) => f);
}
messageIsError(message) {
return message.channel === 'error';
}
messageIsHeartbeat(message) {
return message.channel === 'pong';
}
sendCustomPing = () => {
this.send({ method: 'ping' });
};
}
//# sourceMappingURL=hyperliquid.js.map