Merge pull request #87 from drift-labs/master
market staleness for perp or spot
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.60.0-beta.10",
|
"@drift-labs/sdk": "2.60.0-beta.13",
|
||||||
"@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",
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ type wsMarketL2Args = {
|
|||||||
updateOnChange?: boolean;
|
updateOnChange?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const MAKRET_STALENESS_THRESHOLD = 10 * 60 * 1000;
|
const PERP_MAKRET_STALENESS_THRESHOLD = 10 * 60 * 1000;
|
||||||
|
const SPOT_MAKRET_STALENESS_THRESHOLD = 20 * 60 * 1000;
|
||||||
|
|
||||||
export type wsMarketInfo = {
|
export type wsMarketInfo = {
|
||||||
marketIndex: number;
|
marketIndex: number;
|
||||||
@@ -180,6 +181,10 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if times and slots are too different for market
|
// Check if times and slots are too different for market
|
||||||
|
const MAKRET_STALENESS_THRESHOLD =
|
||||||
|
marketType === 'perp'
|
||||||
|
? PERP_MAKRET_STALENESS_THRESHOLD
|
||||||
|
: SPOT_MAKRET_STALENESS_THRESHOLD;
|
||||||
if (
|
if (
|
||||||
lastMarketSlotAndTime &&
|
lastMarketSlotAndTime &&
|
||||||
l2Formatted['marketSlot'] === lastMarketSlotAndTime.slot &&
|
l2Formatted['marketSlot'] === lastMarketSlotAndTime.slot &&
|
||||||
@@ -197,12 +202,10 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
console.log(
|
console.log(
|
||||||
`Updating market slot for ${l2Args.marketName} with slot ${l2Formatted['marketSlot']}`
|
`Updating market slot for ${l2Args.marketName} with slot ${l2Formatted['marketSlot']}`
|
||||||
);
|
);
|
||||||
this.lastMarketSlotMap
|
this.lastMarketSlotMap.get(l2Args.marketType).set(l2Args.marketIndex, {
|
||||||
.get(l2Args.marketType)
|
slot: l2Formatted['marketSlot'],
|
||||||
.set(l2Args.marketIndex, {
|
ts: Date.now(),
|
||||||
slot: l2Formatted['marketSlot'],
|
});
|
||||||
ts: Date.now(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const l2Formatted_depth100 = Object.assign({}, l2Formatted, {
|
const l2Formatted_depth100 = Object.assign({}, l2Formatted, {
|
||||||
|
|||||||
@@ -115,10 +115,10 @@
|
|||||||
enabled "2.0.x"
|
enabled "2.0.x"
|
||||||
kuler "^2.0.0"
|
kuler "^2.0.0"
|
||||||
|
|
||||||
"@drift-labs/sdk@2.60.0-beta.10":
|
"@drift-labs/sdk@2.60.0-beta.13":
|
||||||
version "2.60.0-beta.10"
|
version "2.60.0-beta.13"
|
||||||
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.60.0-beta.10.tgz#7aae00ed374493c06033bbb51679af77c70611ab"
|
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.60.0-beta.13.tgz#8abb3b0f6bc0341b071f3b769067c9d7e286444f"
|
||||||
integrity sha512-BBfYpA6MTCohDN6t1EqiJtZiGRCBn5pFhXmQcTZ8t3Qd3kXj8kutV5k//Ps14IdlaWcnyxL8lfB33JCtzudsSQ==
|
integrity sha512-UJuZ72nSN8IUl7t1X/hQmnRtz2x86yTrNEY6lQtYXjCsovgOWGune4TlvF+BNBZ/L83uY4wwWETSWqwEJ5C0iA==
|
||||||
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