Skip to content

Commit

Permalink
patch trades and move last update
Browse files Browse the repository at this point in the history
  • Loading branch information
NourAlharithi committed Nov 20, 2023
1 parent 613f4cc commit 6ce59a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/dlob-subscriber/DLOBSubscriberIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,9 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
`orderbook_${marketType}_${l2Args.marketIndex}`,
JSON.stringify(l2Formatted)
);
this.redisClient.client.set(
`last_update_orderbook_${marketType}_${l2Args.marketIndex}`,
JSON.stringify(l2Formatted)
);
}
}
6 changes: 5 additions & 1 deletion src/publishers/tradesPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
QUOTE_PRECISION,
PRICE_PRECISION,
getVariant,
ZERO,
} from '@drift-labs/sdk';

import { logger, setLogLevel } from '../utils/logger';
Expand Down Expand Up @@ -181,7 +182,10 @@ const main = async () => {
slot: fill.slot,
action: 'fill',
actionExplanation: getVariant(fill.actionExplanation),
referrerReward: convertToNumber(fill.referrerReward, QUOTE_PRECISION),
referrerReward: convertToNumber(
fill.referrerReward ?? ZERO,
QUOTE_PRECISION
),
};
})
)
Expand Down
6 changes: 0 additions & 6 deletions src/wsConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ async function main() {
subscribers.forEach((ws) => {
ws.send(JSON.stringify({ channel: subscribedChannel, data: message }));
});

// Save and persist last message
lastMessageRetriever.client.set(
`last_update_${subscribedChannel}`,
message
);
});

redisClient.client.on('error', (error) => {
Expand Down

0 comments on commit 6ce59a1

Please sign in to comment.