Repository navigation
feat(dex): add fill probability estimator for limit orders - #1134
Merged
Nanle-code merged 1 commit intoOct 5, 2026
Merged
Conversation
Estimate the likelihood a proposed limit order fills using two signals
from current order book depth and recent trade cadence:
- Depth score: walks book levels from best price toward the limit;
aggressive prices (inside spread) score ~1, deep passive limits ~0.
Formula: exp(-3 * depthFraction)
- Cadence score: trades-per-minute at-or-better-than limit price in a
5-min window. Formula: 1 - exp(-0.5 * tpm)
Both combine via weighted geometric mean (depth 60%, cadence 40%) into
a [0,1] probability with tier labels (very_high/high/medium/low/very_low).
New files:
src/lib/fillProbability.ts - pure estimation engine, no React deps
src/hooks/useFillProbability.ts - useMemo reactive wrapper, returns null
when book data is absent
src/lib/tests/fillProbability.test.ts - 12 tests covering primary flow,
boundary cases, and failure paths
Modified files:
src/components/dashboard/SlippageTradePanel.tsx - add optional trades prop,
expand metrics grid 4->5 cols with color-coded Fill Probability stat
src/components/dashboard/DEXExplorer.tsx - thread fetched trades into
SlippageTradePanel
Invalid inputs (bad side, non-positive price/qty, NaN) return probability 0
without throwing. Existing SlippageTradePanel tests are unaffected since
the trades prop is optional.
|
@Manuelshub is attempting to deploy a commit to the nanle-code's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Estimate the likelihood a proposed limit order fills using two signals from current order book depth and recent trade cadence:
Both combine via weighted geometric mean (depth 60%, cadence 40%) into a [0,1] probability with tier labels (very_high/high/medium/low/very_low).
New files:
src/lib/fillProbability.ts - pure estimation engine, no React deps
src/hooks/useFillProbability.ts - useMemo reactive wrapper, returns null
when book data is absent
src/lib/tests/fillProbability.test.ts - 12 tests covering primary flow,
boundary cases, and failure paths
Modified files:
src/components/dashboard/SlippageTradePanel.tsx - add optional trades prop,
expand metrics grid 4->5 cols with color-coded Fill Probability stat
src/components/dashboard/DEXExplorer.tsx - thread fetched trades into
SlippageTradePanel
Invalid inputs (bad side, non-positive price/qty, NaN) return probability 0 without throwing. Existing SlippageTradePanel tests are unaffected since the trades prop is optional.
Summary
Closes #860
How was this tested?
Merge requirements
A PR is merged only when every box below is true. See
Merge requirements for the full policy.
masterif GitHub shows "This branch has conflicts").Security-sensitive changes
.github/CODEOWNERS(wallet, auth, cryptography, CI) and a code owner has been requested for review.