Merge branch 'staging' into mainnet-beta
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.71.0-beta.3",
|
"@drift-labs/sdk": "2.72.0-beta.1",
|
||||||
"@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",
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
Map<number, { slot: number; ts: number }>
|
Map<number, { slot: number; ts: number }>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
public skipSlotStalenessCheckMarkets = new Set<number>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
config: DLOBSubscriptionConfig & {
|
config: DLOBSubscriptionConfig & {
|
||||||
redisClient: RedisClient;
|
redisClient: RedisClient;
|
||||||
@@ -73,6 +75,10 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
market.marketIndex
|
market.marketIndex
|
||||||
);
|
);
|
||||||
const includeVamm = !isVariant(perpMarket.status, 'ammPaused');
|
const includeVamm = !isVariant(perpMarket.status, 'ammPaused');
|
||||||
|
const oracleSource = perpMarket.amm.oracleSource;
|
||||||
|
if (isVariant(oracleSource, 'prelaunch')) {
|
||||||
|
this.skipSlotStalenessCheckMarkets.add(market.marketIndex);
|
||||||
|
}
|
||||||
|
|
||||||
this.marketArgs.push({
|
this.marketArgs.push({
|
||||||
marketIndex: market.marketIndex,
|
marketIndex: market.marketIndex,
|
||||||
@@ -175,9 +181,13 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Check if slot diffs are too large for oracle
|
// Check if slot diffs are too large for oracle
|
||||||
|
const skipSlotCheck =
|
||||||
|
marketType === 'perp' &&
|
||||||
|
this.skipSlotStalenessCheckMarkets.has(marketArgs.marketIndex);
|
||||||
if (
|
if (
|
||||||
Math.abs(slot - parseInt(l2Formatted['oracleData']['slot'])) >
|
Math.abs(slot - parseInt(l2Formatted['oracleData']['slot'])) >
|
||||||
this.killSwitchSlotDiffThreshold
|
this.killSwitchSlotDiffThreshold &&
|
||||||
|
!skipSlotCheck
|
||||||
) {
|
) {
|
||||||
console.log(`Killing process due to slot diffs for market ${marketName}:
|
console.log(`Killing process due to slot diffs for market ${marketName}:
|
||||||
dlobProvider slot: ${slot}
|
dlobProvider slot: ${slot}
|
||||||
@@ -194,7 +204,8 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
if (
|
if (
|
||||||
lastMarketSlotAndTime &&
|
lastMarketSlotAndTime &&
|
||||||
l2Formatted['marketSlot'] === lastMarketSlotAndTime.slot &&
|
l2Formatted['marketSlot'] === lastMarketSlotAndTime.slot &&
|
||||||
Date.now() - lastMarketSlotAndTime.ts > MAKRET_STALENESS_THRESHOLD
|
Date.now() - lastMarketSlotAndTime.ts > MAKRET_STALENESS_THRESHOLD &&
|
||||||
|
!skipSlotCheck
|
||||||
) {
|
) {
|
||||||
console.log(`Killing process due to same slot for market ${marketName} after > ${MAKRET_STALENESS_THRESHOLD}ms:
|
console.log(`Killing process due to same slot for market ${marketName} after > ${MAKRET_STALENESS_THRESHOLD}ms:
|
||||||
dlobProvider slot: ${slot}
|
dlobProvider slot: ${slot}
|
||||||
@@ -329,48 +340,6 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
marketArgs.marketIndex
|
marketArgs.marketIndex
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if slot diffs are too large for oracle
|
|
||||||
if (
|
|
||||||
Math.abs(slot - parseInt(l3['oracleData']['slot'])) >
|
|
||||||
this.killSwitchSlotDiffThreshold
|
|
||||||
) {
|
|
||||||
console.log(`Killing process due to slot diffs for market ${marketName}:
|
|
||||||
dlobProvider slot: ${slot}
|
|
||||||
oracle slot: ${l3['oracleData']['slot']}
|
|
||||||
`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 (
|
|
||||||
lastMarketSlotAndTime &&
|
|
||||||
l3['marketSlot'] === lastMarketSlotAndTime.slot &&
|
|
||||||
Date.now() - lastMarketSlotAndTime.ts > MAKRET_STALENESS_THRESHOLD
|
|
||||||
) {
|
|
||||||
console.log(`Killing process due to same slot for market ${marketName} after > ${MAKRET_STALENESS_THRESHOLD}ms:
|
|
||||||
dlobProvider slot: ${slot}
|
|
||||||
market slot: ${l3['marketSlot']}
|
|
||||||
`);
|
|
||||||
process.exit(1);
|
|
||||||
} else if (
|
|
||||||
lastMarketSlotAndTime &&
|
|
||||||
l3['marketSlot'] !== lastMarketSlotAndTime.slot
|
|
||||||
) {
|
|
||||||
console.log(
|
|
||||||
`Updating market slot for ${marketArgs.marketName} with slot ${l3['marketSlot']}`
|
|
||||||
);
|
|
||||||
this.lastMarketSlotMap
|
|
||||||
.get(marketArgs.marketType)
|
|
||||||
.set(marketArgs.marketIndex, {
|
|
||||||
slot: l3['marketSlot'],
|
|
||||||
ts: Date.now(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.redisClient.client.set(
|
this.redisClient.client.set(
|
||||||
`last_update_orderbook_l3_${marketType}_${marketArgs.marketIndex}`,
|
`last_update_orderbook_l3_${marketType}_${marketArgs.marketIndex}`,
|
||||||
JSON.stringify(l3)
|
JSON.stringify(l3)
|
||||||
|
|||||||
10
src/index.ts
10
src/index.ts
@@ -276,7 +276,7 @@ const main = async (): Promise<void> => {
|
|||||||
commitment: stateCommitment,
|
commitment: stateCommitment,
|
||||||
};
|
};
|
||||||
slotSubscriber = new SlotSubscriber(connection, {
|
slotSubscriber = new SlotSubscriber(connection, {
|
||||||
resubTimeoutMs: 5000
|
resubTimeoutMs: 5000,
|
||||||
});
|
});
|
||||||
await slotSubscriber.subscribe();
|
await slotSubscriber.subscribe();
|
||||||
}
|
}
|
||||||
@@ -785,6 +785,7 @@ const main = async (): Promise<void> => {
|
|||||||
if (topMakers) {
|
if (topMakers) {
|
||||||
cacheHitCounter.add(1, {
|
cacheHitCounter.add(1, {
|
||||||
miss: false,
|
miss: false,
|
||||||
|
path: req.baseUrl + req.path,
|
||||||
});
|
});
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(JSON.stringify(topMakers));
|
res.end(JSON.stringify(topMakers));
|
||||||
@@ -838,6 +839,7 @@ const main = async (): Promise<void> => {
|
|||||||
topMakers = [...topMakersSet];
|
topMakers = [...topMakersSet];
|
||||||
cacheHitCounter.add(1, {
|
cacheHitCounter.add(1, {
|
||||||
miss: true,
|
miss: true,
|
||||||
|
path: req.baseUrl + req.path,
|
||||||
});
|
});
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(JSON.stringify(topMakers));
|
res.end(JSON.stringify(topMakers));
|
||||||
@@ -950,6 +952,7 @@ const main = async (): Promise<void> => {
|
|||||||
if (l2Formatted) {
|
if (l2Formatted) {
|
||||||
cacheHitCounter.add(1, {
|
cacheHitCounter.add(1, {
|
||||||
miss: false,
|
miss: false,
|
||||||
|
path: req.baseUrl + req.path,
|
||||||
});
|
});
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(l2Formatted);
|
res.end(l2Formatted);
|
||||||
@@ -986,6 +989,7 @@ const main = async (): Promise<void> => {
|
|||||||
|
|
||||||
cacheHitCounter.add(1, {
|
cacheHitCounter.add(1, {
|
||||||
miss: true,
|
miss: true,
|
||||||
|
path: req.baseUrl + req.path,
|
||||||
});
|
});
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(JSON.stringify(l2Formatted));
|
res.end(JSON.stringify(l2Formatted));
|
||||||
@@ -1127,6 +1131,7 @@ const main = async (): Promise<void> => {
|
|||||||
if (l2Formatted) {
|
if (l2Formatted) {
|
||||||
cacheHitCounter.add(1, {
|
cacheHitCounter.add(1, {
|
||||||
miss: false,
|
miss: false,
|
||||||
|
path: req.baseUrl + req.path,
|
||||||
});
|
});
|
||||||
return l2Formatted;
|
return l2Formatted;
|
||||||
}
|
}
|
||||||
@@ -1161,6 +1166,7 @@ const main = async (): Promise<void> => {
|
|||||||
}
|
}
|
||||||
cacheHitCounter.add(1, {
|
cacheHitCounter.add(1, {
|
||||||
miss: true,
|
miss: true,
|
||||||
|
path: req.baseUrl + req.path,
|
||||||
});
|
});
|
||||||
return l2Formatted;
|
return l2Formatted;
|
||||||
})
|
})
|
||||||
@@ -1209,6 +1215,7 @@ const main = async (): Promise<void> => {
|
|||||||
) {
|
) {
|
||||||
cacheHitCounter.add(1, {
|
cacheHitCounter.add(1, {
|
||||||
miss: false,
|
miss: false,
|
||||||
|
path: req.baseUrl + req.path,
|
||||||
});
|
});
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(redisL3);
|
res.end(redisL3);
|
||||||
@@ -1216,6 +1223,7 @@ const main = async (): Promise<void> => {
|
|||||||
} else {
|
} else {
|
||||||
cacheHitCounter.add(1, {
|
cacheHitCounter.add(1, {
|
||||||
miss: true,
|
miss: true,
|
||||||
|
path: req.baseUrl + req.path,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,10 +115,10 @@
|
|||||||
enabled "2.0.x"
|
enabled "2.0.x"
|
||||||
kuler "^2.0.0"
|
kuler "^2.0.0"
|
||||||
|
|
||||||
"@drift-labs/sdk@2.71.0-beta.3":
|
"@drift-labs/sdk@2.72.0-beta.1":
|
||||||
version "2.71.0-beta.3"
|
version "2.72.0-beta.1"
|
||||||
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.71.0-beta.3.tgz#bddb4c5a2c3661dd12e533b4450f97d03d698a9a"
|
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.72.0-beta.1.tgz#bee1269f877970f10e53f651d19aced79e75a0bc"
|
||||||
integrity sha512-/MDv4678WGrgTKOMZlemvmCnT9Xs7gbQmY2wGQQN2umzXIa/ifCovD5kSNZcARlQuZltnLv8b8Hr98euzMt5aA==
|
integrity sha512-Fgz2WFoTxFetBNBEdzPSKi6IbGnUD6zo5EqUZqW3rICJcpjvjJazKNe9NnYy6q753wnMiYcCwhn29IxcIhAl0g==
|
||||||
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