Skip to content

Commit

Permalink
Use notional in depth probes (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
brittcyr authored Nov 12, 2024
1 parent e7b6172 commit cd96a73
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions debug-ui/scripts/stats-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const lastPrice: promClient.Gauge<'market'> = new promClient.Gauge({
const depth: promClient.Gauge<'depth_bps' | 'market' | 'trader'> =
new promClient.Gauge({
name: 'depth',
help: 'Number of tokens in orders at a given depth by trader',
help: 'Notional in orders at a given depth by trader',
labelNames: ['depth_bps', 'market', 'trader'] as const,
});

Expand Down Expand Up @@ -280,20 +280,20 @@ export class ManifestStatsServer {
return;
}

const mid: number =
const midTokens: number =
(bids[bids.length - 1].tokenPrice +
asks[asks.length - 1].tokenPrice) /
2;

DEPTHS_BPS.forEach((depthBps: number) => {
const bidsAtDepth: RestingOrder[] = bids.filter(
(bid: RestingOrder) => {
return bid.tokenPrice > mid * (1 - depthBps * 0.0001);
return bid.tokenPrice > midTokens * (1 - depthBps * 0.0001);
},
);
const asksAtDepth: RestingOrder[] = asks.filter(
(ask: RestingOrder) => {
return ask.tokenPrice < mid * (1 + depthBps * 0.0001);
return ask.tokenPrice < midTokens * (1 + depthBps * 0.0001);
},
);

Expand Down Expand Up @@ -326,7 +326,7 @@ export class ManifestStatsServer {
market: marketPk.toBase58(),
trader: trader,
},
Math.min(bidTokensAtDepth, askTokensAtDepth),
Math.min(bidTokensAtDepth, askTokensAtDepth) * midTokens,
);
}
});
Expand Down

0 comments on commit cd96a73

Please sign in to comment.