Skip to content

Commit

Permalink
improvement: handle dydx book change mapping more gracefully when no …
Browse files Browse the repository at this point in the history
…offsets are available
  • Loading branch information
thaaddeus committed Jun 10, 2024
1 parent 04b602f commit 97558aa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/mappers/dydx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,16 @@ export class DydxBookChangeMapper implements Mapper<'dydx', BookChange> {
localTimestamp
}

if (!this._bidsOffsets[message.id]) {
this._bidsOffsets[message.id] = {}
}
for (const bid of message.contents.bids) {
this._bidsOffsets[message.id][bid[0]] = updateOffset
}

if (!this._asksOffsets[message.id]) {
this._asksOffsets[message.id] = {}
}
for (const ask of message.contents.asks) {
this._asksOffsets[message.id][ask[0]] = updateOffset
}
Expand Down

0 comments on commit 97558aa

Please sign in to comment.