feat(cbc): cooperative batch clearing module over house vaults#123
Draft
JaeLeex wants to merge 1 commit into
Draft
feat(cbc): cooperative batch clearing module over house vaults#123JaeLeex wants to merge 1 commit into
JaeLeex wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
JaeLeex
marked this pull request as draft
July 8, 2026 12:34
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.
Summary
nunchi-cbc: uniform-price cooperative batch clearing (PRD in PRD: Hybrid AMM design — house + CBC + off-chain bin manager #119). Signed intents from house vaults and allowlisted MMs rest in per-market queues; the keeper closes batches; all executable fills clear at one deterministic price and settle throughnunchi-house's checked clearing API.OutsideBandand leave the queue untouched.limit × qty) in the house module at submission — a vault can never distort the batch price with intents it cannot settle. Allocation walks submission order; each matched chunk validates both sides against live house state (mode gates, reducing capacity, caps, leverage) and settles immediately, so settlement is conservation-preserving by construction.Trust seams (documented in README)
CloseAndClearBatchis keeper-gated, not permissionless.gamma/c) is the v1.1 price-rule upgrade.Test plan
cargo test -p nunchi-cbc(11 tests, including the PRD worked example end-to-end: house +1,200 long sells vs two MM bids → clears 1,000 @ oracle 10,000, house left +200PartiallyFilled, quote conserved across free+reserved balances)cargo check --workspace --all-targetscargo check -p nunchi-cbc --no-default-featurescargo clippy -p nunchi-cbc --all-targets -- -D warningsStacking
Base is
jae/house-module→ #119 → #117. This completes the on-chain half of the hybrid AMM stack; the ABM stays off-chain per the PRD.