Merge branch 'master' into mainnet-beta

This commit is contained in:
wphan
2025-07-16 08:53:25 -07:00

View File

@@ -21,6 +21,7 @@ import {
MarketType, MarketType,
OraclePriceData, OraclePriceData,
ONE, ONE,
decodeName,
} from '@drift-labs/sdk'; } from '@drift-labs/sdk';
import { RedisClient, RedisClientPrefix } from '@drift/common/clients'; import { RedisClient, RedisClientPrefix } from '@drift/common/clients';
@@ -381,6 +382,7 @@ const main = async () => {
type: 'websocket', type: 'websocket',
commitment: stateCommitment, commitment: stateCommitment,
resubTimeoutMs: 30_000, resubTimeoutMs: 30_000,
logResubMessages: true,
}; };
slotSubscriber = new SlotSubscriber(connection, { slotSubscriber = new SlotSubscriber(connection, {
resubTimeoutMs: 10_000, resubTimeoutMs: 10_000,
@@ -394,6 +396,7 @@ const main = async () => {
const { perpMarketInfos, spotMarketInfos, oracleInfos } = const { perpMarketInfos, spotMarketInfos, oracleInfos } =
getMarketsAndOraclesToLoad(sdkConfig); getMarketsAndOraclesToLoad(sdkConfig);
driftClient = new DriftClient({ driftClient = new DriftClient({
connection, connection,
wallet, wallet,
@@ -602,46 +605,38 @@ const main = async () => {
}; };
const handleDebug = async (req: Request, res: Response) => { const handleDebug = async (req: Request, res: Response) => {
const marketIndex = +req.query.marketIndex; const slot = slotSource.getSlot();
let marketType: MarketType = MarketType.PERP; const slotInfos = [];
let oraclePriceData: OraclePriceData; for (const market of driftClient.getPerpMarketAccounts()) {
if (req.query.marketType === 'spot') { const oracleDataAndSlot = driftClient.getOracleDataForPerpMarket(
marketType = MarketType.SPOT; market.marketIndex
oraclePriceData = driftClient.getOracleDataForSpotMarket(marketIndex); );
} else { const marketSlot = market.amm.lastUpdateSlot.toNumber();
oraclePriceData = driftClient.getOracleDataForPerpMarket(marketIndex); const oracleSlot = oracleDataAndSlot.slot.toNumber();
slotInfos.push({
marketName: decodeName(market.name),
slot,
marketSlot,
oracleSlot,
marketSlotDiff: marketSlot - slot,
oracleSlotDiff: oracleSlot - slot,
});
} }
try {
const slot = slotSource.getSlot();
const dlob = await dlobProvider.getDLOB(slot);
const l2 = dlob.getL2({
marketIndex,
marketType,
depth: 5,
slot,
oraclePriceData,
});
const l3 = dlob.getL3({
marketIndex,
marketType,
slot,
oraclePriceData,
});
const state = {
dlobSize: dlobProvider.size(),
slot,
markets: {
perp: perpMarketInfos,
spot: spotMarketInfos,
},
l2: l2WithBNToStrings(l2),
l3,
};
res.json(state); for (const market of driftClient.getSpotMarketAccounts()) {
} catch (e) { const oracleDataAndSlot = driftClient.getOracleDataForSpotMarket(
res.status(500).json({ error: e.message }); market.marketIndex
);
const oracleSlot = oracleDataAndSlot.slot.toNumber();
slotInfos.push({
marketName: decodeName(market.name),
slot,
oracleSlot,
oracleSlotDiff: oracleSlot - slot,
});
} }
res.json(slotInfos);
}; };
app.get('/debug', handleDebug); app.get('/debug', handleDebug);
app.get('/health', handleHealthCheck(slotSource, healthStatusGauge)); app.get('/health', handleHealthCheck(slotSource, healthStatusGauge));