Skip to content

feat(house): house vault module — capital, policy caps, modes, clearing API#122

Draft
JaeLeex wants to merge 1 commit into
jae/hybrid-amm-designfrom
jae/house-module
Draft

feat(house): house vault module — capital, policy caps, modes, clearing API#122
JaeLeex wants to merge 1 commit into
jae/hybrid-amm-designfrom
jae/house-module

Conversation

@JaeLeex

@JaeLeex JaeLeex commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add nunchi-house: the house vault module of the hybrid AMM stack (PRD in PRD: Hybrid AMM design — house + CBC + off-chain bin manager #119). Owns vault capital accounting (free balance + per-market clearing reservations), per-vault risk policy (market allowlist, allocation cap, net-inventory cap, leverage ceiling), live/frozen/halt operating modes, and the authorized-submitter registry.
  • Exposes the checked clearing API the CBC module composes: authorized_submitter, reserve_clearing_quote / release_clearing_quote, pure validate_clearing_fill, and settle_clearing_fill. Exposure caps bind only on exposure-increasing fills, so vaults can always trade back toward flat; the leverage ceiling L_max check runs against the keeper-posted oracle price at settlement.
  • Signed net inventory uses an explicit sign+magnitude codec (NetInventory) rather than relying on platform signed-integer codec behavior.
  • Follows the clob/perpetuals module pattern: transaction ops + ledger + db + genesis + optional rpc + deterministic tests, stability_scope!(ALPHA).

Deliberate v1 boundaries

  • Balances are internal accounting units until chain wiring connects deposits/withdrawals to coins (same seam feat(clob): add spot order book module #117 took for fills).
  • Withdrawals require a live vault with a flat book; margin-coverage-based partial withdrawal needs oracle wiring.
  • "House" is an HLP analogue in the house-liquidity sense only — no liquidation-vault/backstop/ADL semantics (those stay in perpetuals).
  • README flags the reserved vaults taxonomy entry — fold-in vs standalone is PRD open question 1.

Test plan

  • cargo test -p nunchi-house (13 tests: codec, genesis, owner gates, mode gates, flat-book withdrawal, reservation caps, settlement round trip, frozen reduce-only, halt, net-inventory + leverage caps)
  • cargo check --workspace --all-targets
  • cargo check -p nunchi-house --no-default-features
  • cargo clippy -p nunchi-house --all-targets -- -D warnings

Stacking

Base is jae/hybrid-amm-design (#119) → jae/spot-clob-module (#117). Landing order per the PRD: #117#119 → this → CBC. No chain wire tags allocated yet (coordinated against the final module set, perpetuals/ROADMAP.md §1).

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

@JaeLeex
JaeLeex marked this pull request as draft July 8, 2026 12:34
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.

1 participant