fix isSpot check

This commit is contained in:
wphan
2023-05-31 17:18:59 -07:00
parent e80ec8bcdd
commit 0b50e4894a

View File

@@ -28,7 +28,8 @@ import {
PhoenixSubscriber, PhoenixSubscriber,
SerumSubscriber, SerumSubscriber,
DLOBNode, DLOBNode,
} from "@drift-labs/sdk"; isVariant,
} from '@drift-labs/sdk';
import { Mutex } from 'async-mutex'; import { Mutex } from 'async-mutex';
@@ -498,7 +499,7 @@ const main = async () => {
const userAccount = user.getUserAccount(); const userAccount = user.getUserAccount();
for (const order of userAccount.orders) { for (const order of userAccount.orders) {
if (getVariant(order.status) === 'init') { if (isVariant(order.status, 'init')) {
continue; continue;
} }
@@ -553,7 +554,7 @@ const main = async () => {
const userAccount = user.getUserAccount(); const userAccount = user.getUserAccount();
for (const order of userAccount.orders) { for (const order of userAccount.orders) {
if (getVariant(order.status) === 'init') { if (isVariant(order.status, 'init')) {
continue; continue;
} }
@@ -617,7 +618,7 @@ const main = async () => {
const userAccount = user.getUserAccount(); const userAccount = user.getUserAccount();
for (const order of userAccount.orders) { for (const order of userAccount.orders) {
if (getVariant(order.status) === 'init') { if (isVariant(order.status, 'init')) {
continue; continue;
} }
@@ -665,7 +666,7 @@ const main = async () => {
const userAccount = user.getUserAccount(); const userAccount = user.getUserAccount();
for (const order of userAccount.orders) { for (const order of userAccount.orders) {
if (getVariant(order.status) === 'init') { if (isVariant(order.status, 'init')) {
continue; continue;
} }
@@ -769,7 +770,7 @@ const main = async () => {
}; };
}; };
app.get("/topMakers", handleResponseTime, async (req, res, next) => { app.get('/topMakers', handleResponseTime, async (req, res, next) => {
try { try {
const { const {
marketName, marketName,
@@ -789,8 +790,8 @@ const main = async () => {
return; return;
} }
if (side !== "bid" && side !== "ask") { if (side !== 'bid' && side !== 'ask') {
res.status(400).send("Bad Request: side must be either bid or ask"); res.status(400).send('Bad Request: side must be either bid or ask');
return; return;
} }
const normedSide = (side as string).toLowerCase(); const normedSide = (side as string).toLowerCase();
@@ -801,7 +802,7 @@ const main = async () => {
if (isNaN(parseInt(limit as string))) { if (isNaN(parseInt(limit as string))) {
res res
.status(400) .status(400)
.send("Bad Request: limit must be a number if supplied"); .send('Bad Request: limit must be a number if supplied');
return; return;
} }
normedLimit = parseInt(limit as string); normedLimit = parseInt(limit as string);
@@ -828,7 +829,7 @@ const main = async () => {
} }
}; };
if (normedSide === "bid") { if (normedSide === 'bid') {
findMakers( findMakers(
dlobSubscriber dlobSubscriber
.getDLOB() .getDLOB()
@@ -859,7 +860,7 @@ const main = async () => {
} }
}); });
app.get("/l2", handleResponseTime, async (req, res, next) => { app.get('/l2', handleResponseTime, async (req, res, next) => {
try { try {
const { const {
marketName, marketName,
@@ -881,7 +882,7 @@ const main = async () => {
return; return;
} }
const isSpot = getVariant(normedMarketType); const isSpot = isVariant(normedMarketType, 'spot');
const l2 = await dlobSubscriber.getL2({ const l2 = await dlobSubscriber.getL2({
marketIndex: normedMarketIndex, marketIndex: normedMarketIndex,