From a7e4902ab79e28340f55e1db4444da3e7adbbc65 Mon Sep 17 00:00:00 2001 From: Thaddeus Date: Mon, 10 Jun 2024 10:12:59 +0200 Subject: [PATCH] improvement: handle dydx book change mapping more gracefully when no offsets are available --- src/mappers/dydx.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mappers/dydx.ts b/src/mappers/dydx.ts index 5040401..6873e1e 100644 --- a/src/mappers/dydx.ts +++ b/src/mappers/dydx.ts @@ -97,7 +97,7 @@ export class DydxBookChangeMapper implements Mapper<'dydx', BookChange> { bids: message.contents.bids .map((bid) => { - const lastPriceLevelOffset = this._bidsOffsets[message.id][bid[0]] + const lastPriceLevelOffset = this._bidsOffsets[message.id] && this._bidsOffsets[message.id][bid[0]] if (lastPriceLevelOffset !== undefined && lastPriceLevelOffset >= updateOffset) { return } @@ -111,7 +111,7 @@ export class DydxBookChangeMapper implements Mapper<'dydx', BookChange> { asks: message.contents.asks .map((ask) => { - const lastPriceLevelOffset = this._asksOffsets[message.id][ask[0]] + const lastPriceLevelOffset = this._asksOffsets[message.id] && this._asksOffsets[message.id][ask[0]] if (lastPriceLevelOffset !== undefined && lastPriceLevelOffset >= updateOffset) { return }