docs(orderbook): update Clearing section for the four-case clearing price - #231
Draft
claude[bot] wants to merge 1 commit into
Draft
docs(orderbook): update Clearing section for the four-case clearing price#231claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
…clamp Update the Clearing section to match the merged matching-engine behavior (podnetwork/pod#1083, #1132, #1086): the clearing range is bounded by the marginal matched limit orders and the best unmatched limit orders (limit orders only), with midpoint / single-bound / reference-price fallback cases; the final price is clamped so no matched order fills worse than its own price; and marginal fills at a price level are allocated deterministically by order ID. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A74BZVmHFAksnZWVaGBcgi
This was referenced Jul 6, 2026
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.
Requested by Shresth Agrawal · Slack thread
Before
The Clearing section of
doc/protocol/orderbook.mddescribed the old "average mechanism": the clearing price was simply the midpoint of the marginal matched buy and sell,p = (bk + sk) / 2, with a short note that a marginal market order defers to the other side's limit price and that the previous batch's clearing carries over when no limit orders matched.After
The section now describes the merged four-case k-double-auction rule and its safety clamp:
[max(ps, b'), min(pb, s')].How
One file touched:
doc/protocol/orderbook.md(Clearing section). The text reflects these merged matching-engine changes inpodnetwork/pod:The in-flight per-market
BatchInputrefactor is intentionally not documented here — it is unmerged and handled elsewhere.🤖 Generated with Claude Code
https://claude.ai/code/session_01A74BZVmHFAksnZWVaGBcgi
Generated by Claude Code