chore: add mark price to dlob response (#462)
This commit is contained in:
@@ -31,6 +31,7 @@ import {
|
|||||||
import { OffloadQueue } from '../utils/offload';
|
import { OffloadQueue } from '../utils/offload';
|
||||||
import { setHealthStatus, HEALTH_STATUS } from '../core/healthCheck';
|
import { setHealthStatus, HEALTH_STATUS } from '../core/healthCheck';
|
||||||
import { CounterValue } from '../core/metricsV2';
|
import { CounterValue } from '../core/metricsV2';
|
||||||
|
import { COMMON_MATH } from '@drift/common';
|
||||||
|
|
||||||
export type wsMarketArgs = {
|
export type wsMarketArgs = {
|
||||||
marketIndex: number;
|
marketIndex: number;
|
||||||
@@ -354,6 +355,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const l2 = this.getL2({ ...l2FuncArgs, includeVamm });
|
const l2 = this.getL2({ ...l2FuncArgs, includeVamm });
|
||||||
|
const { markPrice } = COMMON_MATH.calculateSpreadBidAskMark(l2);
|
||||||
const slot = l2.slot;
|
const slot = l2.slot;
|
||||||
|
|
||||||
if (slot) {
|
if (slot) {
|
||||||
@@ -379,6 +381,8 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
l2Formatted['marketIndex'] = marketArgs.marketIndex;
|
l2Formatted['marketIndex'] = marketArgs.marketIndex;
|
||||||
l2Formatted['ts'] = Date.now();
|
l2Formatted['ts'] = Date.now();
|
||||||
l2Formatted['slot'] = slot;
|
l2Formatted['slot'] = slot;
|
||||||
|
l2Formatted['markPrice'] = markPrice?.toString();
|
||||||
|
|
||||||
addOracletoResponse(
|
addOracletoResponse(
|
||||||
l2Formatted,
|
l2Formatted,
|
||||||
this.driftClient,
|
this.driftClient,
|
||||||
@@ -392,6 +396,10 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
marketArgs.marketIndex
|
marketArgs.marketIndex
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!markPrice) {
|
||||||
|
l2Formatted['markPrice'] = l2Formatted['oracle'];
|
||||||
|
}
|
||||||
|
|
||||||
// Check if slot diffs are too large for oracle
|
// Check if slot diffs are too large for oracle
|
||||||
const skipSlotCheck =
|
const skipSlotCheck =
|
||||||
(marketType === 'perp' &&
|
(marketType === 'perp' &&
|
||||||
|
|||||||
Reference in New Issue
Block a user