Merge pull request #66 from drift-labs/master
more data with dlob response
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coral-xyz/anchor": "^0.29.0",
|
"@coral-xyz/anchor": "^0.29.0",
|
||||||
"@drift-labs/sdk": "2.54.0-beta.6",
|
"@drift-labs/sdk": "2.56.0-beta.0",
|
||||||
"@opentelemetry/api": "^1.1.0",
|
"@opentelemetry/api": "^1.1.0",
|
||||||
"@opentelemetry/auto-instrumentations-node": "^0.31.1",
|
"@opentelemetry/auto-instrumentations-node": "^0.31.1",
|
||||||
"@opentelemetry/exporter-prometheus": "^0.31.0",
|
"@opentelemetry/exporter-prometheus": "^0.31.0",
|
||||||
|
|||||||
@@ -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';
|
||||||
@@ -96,6 +97,10 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
const grouping = l2Args.grouping;
|
const grouping = l2Args.grouping;
|
||||||
const { marketName, ...l2FuncArgs } = l2Args;
|
const { marketName, ...l2FuncArgs } = l2Args;
|
||||||
const l2 = this.getL2(l2FuncArgs);
|
const l2 = this.getL2(l2FuncArgs);
|
||||||
|
const slot = l2.slot;
|
||||||
|
if (slot) {
|
||||||
|
delete l2.slot;
|
||||||
|
}
|
||||||
const marketType = isVariant(l2Args.marketType, 'perp') ? 'perp' : 'spot';
|
const marketType = isVariant(l2Args.marketType, 'perp') ? 'perp' : 'spot';
|
||||||
let l2Formatted: any;
|
let l2Formatted: any;
|
||||||
if (grouping) {
|
if (grouping) {
|
||||||
@@ -119,13 +124,20 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
l2Formatted['marketName'] = marketName?.toUpperCase();
|
l2Formatted['marketName'] = marketName?.toUpperCase();
|
||||||
l2Formatted['marketType'] = marketType?.toLowerCase();
|
l2Formatted['marketType'] = marketType?.toLowerCase();
|
||||||
l2Formatted['marketIndex'] = l2Args.marketIndex;
|
l2Formatted['marketIndex'] = l2Args.marketIndex;
|
||||||
|
l2Formatted['slot'] = slot;
|
||||||
addOracletoResponse(
|
addOracletoResponse(
|
||||||
l2Formatted,
|
l2Formatted,
|
||||||
this.driftClient,
|
this.driftClient,
|
||||||
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),
|
||||||
asks: l2Formatted.asks.slice(0, 100),
|
asks: l2Formatted.asks.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',
|
||||||
|
|||||||
@@ -115,10 +115,10 @@
|
|||||||
enabled "2.0.x"
|
enabled "2.0.x"
|
||||||
kuler "^2.0.0"
|
kuler "^2.0.0"
|
||||||
|
|
||||||
"@drift-labs/sdk@2.54.0-beta.6":
|
"@drift-labs/sdk@2.56.0-beta.0":
|
||||||
version "2.54.0-beta.6"
|
version "2.56.0-beta.0"
|
||||||
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.54.0-beta.6.tgz#917bcd6d32aa9c3d545ffb552f36f48ac324f44a"
|
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.56.0-beta.0.tgz#2ed7b5f2cc9f1597dd6a16512b6f42716d11b624"
|
||||||
integrity sha512-GXR/F0rjoEGwuY+tkQRZsY9obr9vWBHVBnfytmCXHpzsppEoPmXRwB2TKXQNb7Co7nyVj4fXt/yOO426ob0+0w==
|
integrity sha512-64byprjkruQNmhIxJ/hNTfzFQCf28ls4zHDSw6Wx5Bc+9nj1g4ZwGy+22nfzdHCwres/KSXnkATIwE8BqTgAKg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@coral-xyz/anchor" "0.28.1-beta.2"
|
"@coral-xyz/anchor" "0.28.1-beta.2"
|
||||||
"@ellipsis-labs/phoenix-sdk" "^1.4.2"
|
"@ellipsis-labs/phoenix-sdk" "^1.4.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user