Repository navigation
finance/order-book: make the base, quote, and fee vaults market PDAs - #148
Conversation
initialize_market created the three vaults at public keys the client generated, so opening a market meant generating and signing with three extra keys, and nothing but the market's record said where its tokens were. The vaults are now PDAs of the market, at ["base_vault", market], ["quote_vault", market] and ["fee_vault", market], with the market as their authority: the shape the options and prop AMM vaults already have. The market still records each vault address, and every other handler still checks the vaults it is passed against that record, so the fee-vault-for-quote-vault substitution stays rejected. The order book itself stays client-allocated, since at about 180 KB it is too large for the program to create. Applied to the Anchor v2 and Quasar ports, with the tests deriving the vaults instead of generating keys for them, and the READMEs and changelogs following. The Anchor v1 port is a frozen snapshot and does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011VUvZT5384GaSBhhgJwFp3
…side its dot The first fix named the order book's and the vaults' dots on the curve and left their boxes up to 300 units below, so a reader had to match a label to a box half a page away. The companion program now makes the three vaults PDAs of the market (quicknode/solana-program-examples#148), so they draw like every other program-owned account: an offcurve dot beside a seed caption, "BASE_VAULT" + MARKET ADDRESS and its siblings, in the column where their boxes and arrows already were on main. The order book is the one account the client must create, so its dot stays on the curve, and its box moves above the curve at the top right, beside its dot, where the USDC mint box was. The NVDAx and USDC mint boxes go: these figures name the mints only in seeds and fields, and a not-drawn note says so. The token-account Venn figure's base vault gets its seed caption too, and the order-book chapter says the vaults are market PDAs. The geometry checker now measures address dots after transforms and gains check 12: every address dot sits within 20 of an account box, legend keys aside. It fails the named-dot figures this replaces. The named-dot wording leaves WRITING-PLAN.md and the lint message. Claude-Session: https://claude.ai/code/session_011VUvZT5384GaSBhhgJwFp3
…side its dot The first fix named the order book's and the vaults' dots on the curve and left their boxes up to 300 units below, so a reader had to match a label to a box half a page away. The companion program now makes the three vaults PDAs of the market (quicknode/solana-program-examples#148), so they draw like every other program-owned account: an offcurve dot beside a seed caption, "BASE_VAULT" + MARKET ADDRESS and its siblings, in the column where their boxes and arrows already were on main. The order book is the one account the client must create, so its dot stays on the curve, and its box moves above the curve at the top right, beside its dot, where the USDC mint box was. The NVDAx and USDC mint boxes go: these figures name the mints only in seeds and fields, and a not-drawn note says so. The token-account Venn figure's base vault gets its seed caption too, and the order-book chapter says the vaults are market PDAs. The geometry checker now measures address dots after transforms and gains check 12: every address dot sits within 20 of an account box, legend keys aside. It fails the named-dot figures this replaces. The named-dot wording leaves WRITING-PLAN.md and the lint message. Claude-Session: https://claude.ai/code/session_011VUvZT5384GaSBhhgJwFp3
|
Anchor v2 / Cause. The workflow installs surfpool from Proposed fix. All nine echo "::notice::skipping IDL generation for $project (anchor#4947)"
- idl_flag="--no-idl"
+ # These run LiteSVM tests (`test = "cargo test"`), so they need no validator,
+ # and surfpool >= 1.6 will not start without the IDL this skips.
+ idl_flag="--no-idl"
+ test_flag="--skip-local-validator"
;;
*)
idl_flag=""
+ test_flag=""
;;
...
- if ! anchor test $idl_flag; then
+ if ! anchor test $idl_flag $test_flag; thenWith that change, Generated by Claude Code |
…without an IDL Ported from #149, which fixes the same failure on main: surfpool 1.6 will not start without target/idl/<program>.json, and order-book is one of the nine projects built with --no-idl, so `anchor test` died before any test ran. Those projects test with LiteSVM via `cargo test`, so `anchor test` now passes --skip-local-validator for them. This is a no-op once #149 merges; its CHANGELOG entry stays there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011VUvZT5384GaSBhhgJwFp3
Brings in #149's Anchor v2 CI fix, which this branch had already ported, so the workflow is now identical to main. The only conflict was CHANGELOG.md, where both branches added a 2026-09-22 entry at the top; both are kept, the order-book entry first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011VUvZT5384GaSBhhgJwFp3
initialize_marketcreated the three vaults at public keys the client generated, so opening a market meant generating and signing with three extra keys, and nothing but the market's record said where its tokens were. The vaults are now PDAs of the market, with the market as their authority. That is the shape the options and prop AMM vaults already have.["base_vault", market]["quote_vault", market]["fee_vault", market]What stays the same
Scope
MARKET_SEED(Quasar gets a#[derive(Seeds)]type per vault), and a seeds constraint on each vault'sinit.CONTRIBUTING.mdand the most recent changelog entry.CI
Main's Anchor v2 runs were red because surfpool 1.6 won't start without an IDL, and order-book is built with
--no-idl. #149 fixed that on main, and main is merged in here, so this PR no longer touches the workflow.Verified locally
cargo build-sbf, thencargo test. All 27 tests pass. They can only pass against the new program, because the old one required the three vault keys to sign.anchor test --no-idl --skip-local-validatoralso passes, 27/27, which is what CI runs.quasar build, thencargo test. All 6 tests pass.cargo fmt --checkis clean in both ports.cargo clippy --all-targets -D warningsfails with two lints (div_ceil,is_multiple_of) in the Anchor test file, in code this change doesn't touch. They fail identically onmain.This is the companion change for the book's order-book figures in quicknode/solana-book#149, which will draw the vaults as derived addresses beside their seeds.
🤖 Generated with Claude Code
https://claude.ai/code/session_011VUvZT5384GaSBhhgJwFp3