honor grouping and depth in get l2
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@drift-labs/sdk": "2.31.0-beta.4",
|
"@drift-labs/sdk": "2.31.0-beta.5",
|
||||||
"@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",
|
||||||
|
|||||||
14
src/index.ts
14
src/index.ts
@@ -906,10 +906,17 @@ const main = async () => {
|
|||||||
|
|
||||||
const isSpot = isVariant(normedMarketType, 'spot');
|
const isSpot = isVariant(normedMarketType, 'spot');
|
||||||
|
|
||||||
|
let adjustedDepth = depth ?? '10';
|
||||||
|
if (grouping !== undefined) {
|
||||||
|
// If grouping is also supplied, we want the entire book depth.
|
||||||
|
// we will apply depth after grouping
|
||||||
|
adjustedDepth = '-1';
|
||||||
|
}
|
||||||
|
|
||||||
const l2 = dlobSubscriber.getL2({
|
const l2 = dlobSubscriber.getL2({
|
||||||
marketIndex: normedMarketIndex,
|
marketIndex: normedMarketIndex,
|
||||||
marketType: normedMarketType,
|
marketType: normedMarketType,
|
||||||
depth: depth ? parseInt(depth as string) : 10,
|
depth: parseInt(adjustedDepth as string),
|
||||||
includeVamm: `${includeVamm}`.toLowerCase() === 'true',
|
includeVamm: `${includeVamm}`.toLowerCase() === 'true',
|
||||||
fallbackL2Generators: isSpot
|
fallbackL2Generators: isSpot
|
||||||
? [
|
? [
|
||||||
@@ -922,6 +929,7 @@ const main = async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (grouping) {
|
if (grouping) {
|
||||||
|
const finalDepth = depth ? parseInt(depth as string) : 10;
|
||||||
if (isNaN(parseInt(grouping as string))) {
|
if (isNaN(parseInt(grouping as string))) {
|
||||||
res
|
res
|
||||||
.status(400)
|
.status(400)
|
||||||
@@ -930,7 +938,9 @@ const main = async () => {
|
|||||||
}
|
}
|
||||||
const groupingBN = new BN(parseInt(grouping as string));
|
const groupingBN = new BN(parseInt(grouping as string));
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(JSON.stringify(l2WithBNToStrings(groupL2(l2, groupingBN))));
|
res.end(
|
||||||
|
JSON.stringify(l2WithBNToStrings(groupL2(l2, groupingBN, finalDepth)))
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// make the BNs into strings
|
// make the BNs into strings
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
|
|||||||
@@ -80,10 +80,10 @@
|
|||||||
enabled "2.0.x"
|
enabled "2.0.x"
|
||||||
kuler "^2.0.0"
|
kuler "^2.0.0"
|
||||||
|
|
||||||
"@drift-labs/sdk@2.31.0-beta.4":
|
"@drift-labs/sdk@2.31.0-beta.5":
|
||||||
version "2.31.0-beta.4"
|
version "2.31.0-beta.5"
|
||||||
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.31.0-beta.4.tgz#e03d7dc40078f9ccf63cb3899ea07994ef7a2b74"
|
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.31.0-beta.5.tgz#d95092a5e3e689c2a05e95012cc93b86892f8285"
|
||||||
integrity sha512-3tiNn6LTyUENNu+7TjLJvbPlWXDohRsONYAQOC4DVljXk8jUVFo0tLTyKXkZe9EJsMS+TE3WikIgf9jYJIGHjg==
|
integrity sha512-WP1DAgo4gb03tMBUl3ApyeUxmctcLQuzGMjDhER5fPR+HbEi01P7s6bAwdrGlqINdlnqNm2uutxh3Re5VAkCqg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@coral-xyz/anchor" "0.26.0"
|
"@coral-xyz/anchor" "0.26.0"
|
||||||
"@ellipsis-labs/phoenix-sdk" "^1.4.2"
|
"@ellipsis-labs/phoenix-sdk" "^1.4.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user