pmm dlob server
This commit is contained in:
@@ -263,11 +263,15 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
});
|
||||
|
||||
this.redisClient.publish(
|
||||
`${clientPrefix}orderbook_${marketType}_${marketArgs.marketIndex}`,
|
||||
`${clientPrefix}orderbook_${marketType}_${marketArgs.marketIndex}${
|
||||
this.protectedMakerView ? '_pmm' : ''
|
||||
}`,
|
||||
l2Formatted
|
||||
);
|
||||
this.redisClient.set(
|
||||
`last_update_orderbook_${marketType}_${marketArgs.marketIndex}`,
|
||||
`last_update_orderbook_${marketType}_${marketArgs.marketIndex}${
|
||||
this.protectedMakerView ? '_pmm' : ''
|
||||
}`,
|
||||
l2Formatted_depth100
|
||||
);
|
||||
const oraclePriceData =
|
||||
@@ -350,7 +354,9 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
);
|
||||
|
||||
this.redisClient.set(
|
||||
`last_update_orderbook_l3_${marketType}_${marketArgs.marketIndex}`,
|
||||
`last_update_orderbook_l3_${marketType}_${marketArgs.marketIndex}${
|
||||
this.protectedMakerView ? '_pmm' : ''
|
||||
}`,
|
||||
l3
|
||||
);
|
||||
}
|
||||
|
||||
19
src/index.ts
19
src/index.ts
@@ -520,7 +520,8 @@ const main = async (): Promise<void> => {
|
||||
|
||||
app.get('/l2', async (req, res, next) => {
|
||||
try {
|
||||
const { marketName, marketIndex, marketType, depth } = req.query;
|
||||
const { marketName, marketIndex, marketType, depth, includePmm } =
|
||||
req.query;
|
||||
|
||||
const { normedMarketType, normedMarketIndex, error } = validateDlobQuery(
|
||||
driftClient,
|
||||
@@ -535,14 +536,14 @@ const main = async (): Promise<void> => {
|
||||
}
|
||||
|
||||
const isSpot = isVariant(normedMarketType, 'spot');
|
||||
|
||||
const includePmmStr = (includePmm as string)?.toLowerCase() === 'true';
|
||||
const adjustedDepth = depth ?? '100';
|
||||
|
||||
let l2Formatted: any;
|
||||
const redisL2 = await fetchFromRedis(
|
||||
`last_update_orderbook_${
|
||||
isSpot ? 'spot' : 'perp'
|
||||
}_${normedMarketIndex}`,
|
||||
}_${normedMarketIndex}${includePmmStr ? '_pmm' : ''}`,
|
||||
selectMostRecentBySlot
|
||||
);
|
||||
const depthToUse = Math.min(parseInt(adjustedDepth as string) ?? 1, 100);
|
||||
@@ -604,6 +605,7 @@ const main = async (): Promise<void> => {
|
||||
includePhoenix,
|
||||
includeOpenbook,
|
||||
includeOracle,
|
||||
includePmm,
|
||||
} = req.query;
|
||||
|
||||
const normedParams = normalizeBatchQueryParams({
|
||||
@@ -615,6 +617,7 @@ const main = async (): Promise<void> => {
|
||||
includePhoenix: includePhoenix as string | undefined,
|
||||
includeOpenbook: includeOpenbook as string | undefined,
|
||||
includeOracle: includeOracle as string | undefined,
|
||||
includePmm: includePmm as string | undefined,
|
||||
});
|
||||
|
||||
if (normedParams === undefined) {
|
||||
@@ -645,13 +648,14 @@ const main = async (): Promise<void> => {
|
||||
}
|
||||
|
||||
const isSpot = isVariant(normedMarketType, 'spot');
|
||||
const normedIncludePmm = normedParam['includePmm'] == 'true';
|
||||
|
||||
const adjustedDepth = normedParam['depth'] ?? '100';
|
||||
let l2Formatted: any;
|
||||
const redisL2 = await fetchFromRedis(
|
||||
`last_update_orderbook_${
|
||||
isSpot ? 'spot' : 'perp'
|
||||
}_${normedMarketIndex}`,
|
||||
}_${normedMarketIndex}${normedIncludePmm ? '_pmm' : ''}`,
|
||||
selectMostRecentBySlot
|
||||
);
|
||||
const depth = Math.min(parseInt(adjustedDepth as string) ?? 1, 100);
|
||||
@@ -721,7 +725,7 @@ const main = async (): Promise<void> => {
|
||||
|
||||
app.get('/l3', async (req, res, next) => {
|
||||
try {
|
||||
const { marketName, marketIndex, marketType } = req.query;
|
||||
const { marketName, marketIndex, marketType, includePmm } = req.query;
|
||||
|
||||
const { normedMarketType, normedMarketIndex, error } = validateDlobQuery(
|
||||
driftClient,
|
||||
@@ -736,9 +740,12 @@ const main = async (): Promise<void> => {
|
||||
}
|
||||
|
||||
const marketTypeStr = getVariant(normedMarketType);
|
||||
const normedIncludePmm = (includePmm as string)?.toLowerCase() === 'true';
|
||||
|
||||
const redisL3 = await fetchFromRedis(
|
||||
`last_update_orderbook_l3_${marketTypeStr}_${normedMarketIndex}`,
|
||||
`last_update_orderbook_l3_${marketTypeStr}_${normedMarketIndex}${
|
||||
normedIncludePmm ? '_pmm' : ''
|
||||
}`,
|
||||
selectMostRecentBySlot
|
||||
);
|
||||
if (redisL3) {
|
||||
|
||||
@@ -497,8 +497,25 @@ const main = async () => {
|
||||
perpMarketInfos,
|
||||
spotMarketInfos,
|
||||
killSwitchSlotDiffThreshold: KILLSWITCH_SLOT_DIFF_THRESHOLD,
|
||||
protectedMakerView: false,
|
||||
});
|
||||
await dlobSubscriber.subscribe();
|
||||
|
||||
const dlobSubscriberPmm = new DLOBSubscriberIO({
|
||||
driftClient,
|
||||
env: driftEnv,
|
||||
dlobSource: dlobProvider,
|
||||
slotSource,
|
||||
updateFrequency: ORDERBOOK_UPDATE_INTERVAL,
|
||||
redisClient,
|
||||
spotMarketSubscribers: MARKET_SUBSCRIBERS,
|
||||
perpMarketInfos,
|
||||
spotMarketInfos,
|
||||
killSwitchSlotDiffThreshold: KILLSWITCH_SLOT_DIFF_THRESHOLD,
|
||||
protectedMakerView: true,
|
||||
});
|
||||
await dlobSubscriberPmm.subscribe();
|
||||
|
||||
if (useWebsocket && !FEATURE_FLAGS.DISABLE_GPA_REFRESH) {
|
||||
const recursiveFetch = (delay = WS_FALLBACK_FETCH_INTERVAL) => {
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user