Drift for changes to DlobSubscriber

This commit is contained in:
Luke Steyn
2023-05-30 22:25:35 +09:00
parent 3589467d17
commit 413f6f1898

View File

@@ -24,7 +24,6 @@ import {
PerpMarkets, PerpMarkets,
DLOBSubscriber, DLOBSubscriber,
MarketType, MarketType,
isVariant,
} from "@drift-labs/sdk"; } from "@drift-labs/sdk";
import { Mutex } from "async-mutex"; import { Mutex } from "async-mutex";
@@ -686,8 +685,15 @@ const main = async () => {
app.get("/l2", handleResponseTime, async (req, res, next) => { app.get("/l2", handleResponseTime, async (req, res, next) => {
try { try {
const { marketName, marketIndex, marketType, depth, includeVamm } = const {
req.query; marketName,
marketIndex,
marketType,
depth,
includeVamm,
includePhoenix,
includeSerum,
} = req.query;
const { normedMarketType, normedMarketIndex, error } = validateDlobQuery( const { normedMarketType, normedMarketIndex, error } = validateDlobQuery(
marketType as string, marketType as string,
@@ -699,13 +705,21 @@ const main = async () => {
return; return;
} }
const l2 = dlobSubscriber.getL2({ const l2 = await dlobSubscriber.getL2({
marketIndex: normedMarketIndex, marketIndex: normedMarketIndex,
marketType: normedMarketType, marketType: normedMarketType,
depth: depth ? parseInt(depth as string) : 10, depth: depth ? parseInt(depth as string) : 10,
includeVamm: includeVamm opts: {
? (includeVamm as string).toLowerCase() === "true" includeVammL2: includeVamm
: false, ? `${includeVamm}`.toLowerCase() === "true"
: false,
includePhoenixL2: includeSerum
? `${includeSerum}`.toLowerCase() === "true"
: false,
includeSerumL2: includePhoenix
? `${includePhoenix}`.toLowerCase() === "true"
: false,
},
}); });
for (const key of Object.keys(l2)) { for (const key of Object.keys(l2)) {