Skip to content

ind liq metrics and mock scripts for dashboard#597

Merged
jonthia-drift merged 3 commits intomasterfrom
jonthia/be-247-indicative-liquidity-dashboard
Mar 30, 2026
Merged

ind liq metrics and mock scripts for dashboard#597
jonthia-drift merged 3 commits intomasterfrom
jonthia/be-247-indicative-liquidity-dashboard

Conversation

@jonthia-drift
Copy link
Copy Markdown
Contributor

@jonthia-drift jonthia-drift commented Mar 27, 2026

Tracy and Kevin want a dashboard that monitors metrics around how much ind liq / quotes that whitelisted MM's are adding, and what there actual fills are like in relation to those quotes.

Open to feedback on some of these are measured but I'm starting with:

Indicative presence rate
% of fills the MM had any ind quote
indicative_presence_total / market_fill_count

Competitive presence rate
% of fills where at least one quote level would have crossed or matched the observed fill price.
indicative_competitive_opportunity_total / market_fill_count

Indicative size on book
notional value of quotes - regardless of spread
indicative_total_size_on_book

Competitive size on book
notional value of quotes which would have crossed or matched the observed fill price.
indicative_competitive_size_on_book

Quote-to-Fill Conversion Rate
% of fills where the maker had a competitive presence and actually filled. Note that there are many reasons why they didn't fill - and this doesn't really break that down so at best we can just observe trends.
indicative_competitive_fill_total / indicative_competitive_opportunity_total

Notional Capture Rate
Same definition as above but in terms of notional value.
indicative_competitive_captured_notional_total / indicative_competitive_opportunity_notional_total

Fill Price vs Indicative Quote
Distribution of fills based on bps between the fill and best quoted price, for fills the maker captured. This is broken into 5 spread buckets from very tight to very wide.
indicative_fill_vs_quote_bucket_total

I'm testing the listener by:

# Start redis
bash redisCluster.sh start
bash redisCluster.sh create
## when done testing run bash redisCluster.sh stop

# Run the publisher - copy and paste .env.trades.local
yarn trades-publish:local

# Submit a mock fill & quote event - change the MOCK_QUOTES_JSON and MOCK_FILLS_JSON to simulate different quotes and fills
yarn mock-jit:submit

Example of the metrics

# HELP market_fill_count_total Total market fills considered for JIT competitive opportunity metrics
# TYPE market_fill_count_total counter
market_fill_count_total{market_index="0",market_type="perp",side="long"} 1 1774577783272
# HELP indicative_presence_total Count of fills where a maker had any fresh indicative quote on the relevant side
# TYPE indicative_presence_total counter
indicative_presence_total{market_index="0",market_type="perp",maker="good-maker",side="long"} 1 1774577783272
indicative_presence_total{market_index="0",market_type="perp",maker="bad-maker",side="long"} 1 1774577783272
# HELP indicative_competitive_opportunity_total Count of market fills where a maker had a fresh competitive indicative quote
# TYPE indicative_competitive_opportunity_total counter
indicative_competitive_opportunity_total{market_index="0",market_type="perp",maker="good-maker",side="long"} 1 1774577783272
indicative_competitive_opportunity_total{market_index="0",market_type="perp",maker="bad-maker",side="long"} 1 1774577783272
# HELP indicative_competitive_fill_total Count of competitive opportunities where the maker captured the fill
# TYPE indicative_competitive_fill_total counter
indicative_competitive_fill_total{market_index="0",market_type="perp",maker="good-maker",side="long"} 1 1774577783272
# HELP indicative_competitive_opportunity_notional_total Total competitive opportunity notional in quote units for each maker
# TYPE indicative_competitive_opportunity_notional_total counter
indicative_competitive_opportunity_notional_total{market_index="0",market_type="perp",maker="good-maker",side="long"} 99.9 1774577783272
indicative_competitive_opportunity_notional_total{market_index="0",market_type="perp",maker="bad-maker",side="long"} 99.9 1774577783272
# HELP indicative_competitive_captured_notional_total Total captured notional in quote units on competitive opportunities for each maker
# TYPE indicative_competitive_captured_notional_total counter
indicative_competitive_captured_notional_total{market_index="0",market_type="perp",maker="good-maker",side="long"} 99.9 1774577783272
# HELP indicative_fill_vs_quote_bucket_total Count of maker fills bucketed by absolute bps distance from the best competitive indicative quote
# TYPE indicative_fill_vs_quote_bucket_total counter
indicative_fill_vs_quote_bucket_total{market_index="0",market_type="perp",maker="good-maker",side="long",bucket="very_tight"} 1 1774577783272
# HELP indicative_quote_evaluation_total Count of quote evaluation outcomes by maker and market
# TYPE indicative_quote_evaluation_total counter
indicative_quote_evaluation_total{market_index="0",market_type="perp",maker="good-maker",side="long",result="competitive"} 1 1774577783272
indicative_quote_evaluation_total{market_index="0",market_type="perp",maker="bad-maker",side="long",result="competitive"} 1 1774577783272
# HELP indicative_total_size_on_book Latest fresh total quoted value on book by maker, market, and side
# TYPE indicative_total_size_on_book gauge
indicative_total_size_on_book{market_index="0",market_type="perp",maker="good-maker",side="long"} 1197.8 1774577783272
indicative_total_size_on_book{market_index="0",market_type="perp",maker="bad-maker",side="long"} 101 1774577783272
# HELP indicative_competitive_size_on_book Latest fresh competitive quoted value on book by maker, market, and side
# TYPE indicative_competitive_size_on_book gauge
indicative_competitive_size_on_book{market_index="0",market_type="perp",maker="good-maker",side="long"} 199.8 1774577783272
indicative_competitive_size_on_book{market_index="0",market_type="perp",maker="bad-maker",side="long"} 101 1774577783272

@@ -0,0 +1,16 @@
ENDPOINT=https://api.devnet.solana.com
Copy link
Copy Markdown
Contributor

@jackwaller jackwaller Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't end up using this one so will remove

@@ -0,0 +1,22 @@
ENDPOINT=https://api.devnet.solana.com
Copy link
Copy Markdown
Contributor

@jackwaller jackwaller Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is just for the mock=true and mock value mode.

const stateCommitment: Commitment = 'confirmed';
let driftClient: DriftClient;

type FillEvent = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OrderAction record in the drift sdk

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yea I did try to use this at first but there's actually a lot of existing conversion done before it's passed through, like the precisions and maker/taker pub keys to strings. So this type represents the payload that redis was already taking (typed any) but to avoid breaking changes I locked it down.

@jackwaller
Copy link
Copy Markdown
Contributor

jackwaller commented Mar 27, 2026

As discussed I would merge this into staging so we can start to visualise in grafana better

@jonthia-drift jonthia-drift merged commit f4e62f2 into master Mar 30, 2026
1 check passed
@jonthia-drift jonthia-drift deleted the jonthia/be-247-indicative-liquidity-dashboard branch March 30, 2026 00:19
@jonthia-drift jonthia-drift restored the jonthia/be-247-indicative-liquidity-dashboard branch March 30, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants