add market slot to response'
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
import { RedisClient } from '../utils/redisClient';
|
import { RedisClient } from '../utils/redisClient';
|
||||||
import {
|
import {
|
||||||
SubscriberLookup,
|
SubscriberLookup,
|
||||||
|
addMarketSlotToResponse,
|
||||||
addOracletoResponse,
|
addOracletoResponse,
|
||||||
l2WithBNToStrings,
|
l2WithBNToStrings,
|
||||||
} from '../utils/utils';
|
} from '../utils/utils';
|
||||||
@@ -130,6 +131,12 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
l2Args.marketType,
|
l2Args.marketType,
|
||||||
l2Args.marketIndex
|
l2Args.marketIndex
|
||||||
);
|
);
|
||||||
|
addMarketSlotToResponse(
|
||||||
|
l2Formatted,
|
||||||
|
this.driftClient,
|
||||||
|
l2Args.marketType,
|
||||||
|
l2Args.marketIndex
|
||||||
|
);
|
||||||
|
|
||||||
const l2Formatted_depth100 = Object.assign({}, l2Formatted, {
|
const l2Formatted_depth100 = Object.assign({}, l2Formatted, {
|
||||||
bids: l2Formatted.bids.slice(0, 100),
|
bids: l2Formatted.bids.slice(0, 100),
|
||||||
|
|||||||
@@ -132,6 +132,21 @@ export const addOracletoResponse = (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const addMarketSlotToResponse = (
|
||||||
|
response: L2OrderBook | L3OrderBook,
|
||||||
|
driftClient: DriftClient,
|
||||||
|
marketType: MarketType,
|
||||||
|
marketIndex: number
|
||||||
|
): void => {
|
||||||
|
let marketSlot: number;
|
||||||
|
if (isVariant(marketType, 'perp')) {
|
||||||
|
marketSlot = driftClient.accountSubscriber.getMarketAccountAndSlot(marketIndex).slot;
|
||||||
|
} else {
|
||||||
|
marketSlot = driftClient.accountSubscriber.getSpotMarketAccountAndSlot(marketIndex).slot;
|
||||||
|
}
|
||||||
|
response['marketSlot'] = marketSlot;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes in a req.query like: `{
|
* Takes in a req.query like: `{
|
||||||
* marketName: 'SOL-PERP,BTC-PERP,ETH-PERP',
|
* marketName: 'SOL-PERP,BTC-PERP,ETH-PERP',
|
||||||
|
|||||||
Reference in New Issue
Block a user