Commit 0410c68
Edward (MM bot)
docs(clob): apply Mike's feedback to README and code comments
Five consistent lessons from earlier reviews, applied to the CLOB program.
1. 'Token' not 'SPL Token' — tokens are the default on Solana, no qualifier
is needed unless specifically contrasting with native SOL. Replaced 'SPL
Token' / 'SPL token' throughout README, state/market.rs, and tests.
In tests, 'classic SPL Token vs Token-2022' becomes 'Classic Token
Program vs Token Extensions Program' — more precise and drops the SPL
prefix that's noise.
2. Glossary removed. The old section enumerated every Solana term (Account,
Lamport, Signer, PDA, Bump, CPI, ...) which duplicates what
https://solana.com/docs/terminology already covers. Replaced with a
one-line pointer there, plus a short inline 'Terms' block that defines
only genuinely CLOB-specific vocabulary (base/quote, tick size,
unsettled balance, fee vault, price improvement, remaining accounts).
3. No Ethereum references. Old README described an SPL token as 'Solana's
ERC-20 equivalent'. Removed — explain Solana on its own terms.
4. Accurate finance framing. Added a sentence at the top noting that a
CLOB is the same matching mechanism every major equity / futures / FX
/ crypto exchange (NYSE, NASDAQ, LSE, CME, Binance, Coinbase, Openbook,
Phoenix) uses. Previously the README framed the program as 'two users
who want to swap tokens' — accurate but understated. A CLOB is real
finance infrastructure and the README now says so. Renamed the
'Tradfi background' subsection to 'Finance background'.
5. 'Instruction handler' not 'instruction' when referring to the code.
An instruction is the call data submitted in a transaction; the
instruction handler is the Rust function that processes it. Updated
'the program has six instructions', 'later instructions can validate',
'no instruction flips this', 'close in the same instruction', etc.
Phrasing like 'a user calls the place_order instruction' is left
alone because it genuinely refers to the call.
Additional cleanups bundled in:
- 'on-chain' / 'off-chain' → 'onchain' / 'offchain' in README, matching
the repo-wide normalisation in commit fa93ce0.
- 'SPL Token program' → 'Token program' in CPI descriptions.
- 'SPL token accounts' → 'token accounts' in the vaults section.
- Code comment in place_order.rs describes basis points as 'the universal
rate convention on every major exchange' instead of the vague
'TradFi and CEXes'.
- Code comment in market.rs: 'program instructions can drain it' →
'program instruction handlers can drain it'.
- initialize_market.rs: 'Basis-points' → 'Basis points' (punctuation).
Section numbers in the README renumbered (2/3→2, 4→3, 5→4, ...) after
the Glossary removal; all cross-references updated.
Quasar port: NOT included in this change. Quasar's account macros
require fixed-layout structs (it does not support Vec<T> fields on
#[account] structs — see basics/favorites/quasar/src/state.rs for the
explicit call-out). The CLOB's OrderBook is a Vec<OrderEntry> pair and
UserAccount has a Vec<u64> open_orders, both of which rely on dynamic
insertion and removal. On top of that, place_order iterates through
remaining_accounts to deserialize and mutate multiple maker Order /
UserAccount PDAs per call — a pattern none of the existing Quasar
examples (escrow, token-swap, counter) demonstrate. Porting would need
a fresh fixed-capacity OrderBook design and a new cross-account
mutation pattern. Left as a follow-up so the terminology and finance
framing fixes ship first; a separate PR can tackle the Quasar port
once the architectural approach is agreed.
Tests: all 23 existing LiteSVM tests in programs/clob/tests/test_clob.rs
still pass locally after the sweep.1 parent 6053581 commit 0410c68
5 files changed
Lines changed: 164 additions & 243 deletions
File tree
- defi/clob/anchor
- programs/clob
- src
- instructions
- state
- tests
0 commit comments