Skip to content

Commit 4a792de

Browse files
author
Edward (Mike's bot)
committed
refactor(defi): rename example clob → order-book for discoverability
Every other example in defi/ uses plain words (amm, escrow, token-swap). "clob" was the only opaque acronym. Renamed to "order-book" so the directory listing reads cleanly; "CLOB" stays as the term inside the README and code comments where the explanation makes it meaningful. Renames applied: - Directory defi/clob/ → defi/order-book/ - Directory programs/clob/ → programs/order-book/ - Cargo name = "clob" → name = "order_book" - Cargo lib name = "clob" → name = "order_book" - Anchor.toml [programs.localnet] clob = → order_book = - Rust mod pub mod clob {…} → pub mod order_book {…} - Test file tests/test_clob.rs → tests/test_order_book.rs - SBF .so target/deploy/clob.so → target/deploy/order_book.so - Keypair clob-keypair.json → order_book-keypair.json (same key bytes — program ID is unchanged) - Top-level repo README link to ./defi/clob/anchor → ./defi/order-book/anchor README first-mention pattern updated: now leads with "**order book** — specifically a **central limit order book (CLOB)**, …", subsequent uses of "CLOB" as a term are preserved. Path references and code-block commands in the README updated to the new layout. Program ID stays at C69UJ8irfmHq5ysyLek7FKApHR86FBeupiz4JnoyPzzx — only the names around it changed. Tests: 24/24 pass under cargo test (LiteSVM).
1 parent 2b788a4 commit 4a792de

28 files changed

Lines changed: 86 additions & 86 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Constant product AMM (x·y=k) — create liquidity pools, deposit and withdraw l
2727

2828
Order-book exchange — users post limit bids and asks at chosen prices, tokens are locked in program vaults, and orders cross against the opposing side using price-time priority. Fees route to a dedicated fee vault, maker/taker proceeds land in unsettled balances, and funds are withdrawn via `settle_funds`. A minimal teaching example of the mechanics behind Openbook and Phoenix.
2929

30-
[⚓ Anchor](./defi/clob/anchor)
30+
[⚓ Anchor](./defi/order-book/anchor)
3131

3232
### Escrow
3333

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ resolution = true
88
skip-lint = false
99

1010
[programs.localnet]
11-
clob = "C69UJ8irfmHq5ysyLek7FKApHR86FBeupiz4JnoyPzzx"
11+
order_book = "C69UJ8irfmHq5ysyLek7FKApHR86FBeupiz4JnoyPzzx"
1212

1313
[provider]
1414
cluster = "Localnet"
1515
wallet = "~/.config/solana/id.json"
1616

1717
[scripts]
18-
# LiteSVM Rust tests live under `programs/clob/tests/` and include the built
18+
# LiteSVM Rust tests live under `programs/order-book/tests/` and include the built
1919
# `.so` via `include_bytes!`, so a fresh `anchor build` must run first.
2020
test = "cargo test"
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# CLOB — Central Limit Order Book
2-
3-
An Anchor program that runs an **onchain central limit order book**
4-
(CLOB) for a single pair of token mints. Users post buy or sell offers
5-
at the prices they want, the program matches crossing offers in
6-
price-time priority, and settles the resulting token movements.
7-
8-
A CLOB is the standard piece of financial-market infrastructure: NYSE,
9-
NASDAQ, LSE, and CME all run on one, and every major crypto venue
10-
(Binance, Coinbase, Openbook, Phoenix) implements the same idea. This
11-
program is a simplified, onchain version of that mechanism. Two simple
12-
Solana CLOBs you can read alongside it:
1+
# Order Book — Central Limit Order Book (CLOB)
2+
3+
This is an **order book** — specifically, a **central limit order
4+
book (CLOB)**, the standard piece of market infrastructure used by
5+
NYSE, NASDAQ, LSE, CME, and every major crypto venue. An Anchor
6+
program that runs an onchain CLOB for a single pair of token mints:
7+
users post buy or sell offers at the prices they want, the program
8+
matches crossing offers in price-time priority, and settles the
9+
resulting token movements.
10+
11+
This program is a simplified, onchain version of that mechanism. Two
12+
production Solana CLOBs to read alongside it:
1313
[Openbook v2](https://github.com/openbook-dex/openbook-v2) and
1414
[Phoenix](https://github.com/Ellipsis-Labs/phoenix-v1). Both use
1515
zero-copy slabs for scale; this example uses plain `Vec`s so the
@@ -232,7 +232,7 @@ just needs enough to pick what to cross next and re-derive the PDA.
232232

233233
### `Order` state
234234

235-
From [`state/order.rs`](programs/clob/src/state/order.rs):
235+
From [`state/order.rs`](programs/order-book/src/state/order.rs):
236236

237237
```rust
238238
pub struct Order {
@@ -666,8 +666,8 @@ zero as a side effect of the transfer).
666666
667667
This is the heart of the program. Everything in `place_order` after
668668
the initial fund lock is matching-engine work. Follow along with
669-
[`place_order.rs`](programs/clob/src/instructions/place_order.rs) and
670-
[`state/matching.rs`](programs/clob/src/state/matching.rs) — it'll
669+
[`place_order.rs`](programs/order-book/src/instructions/place_order.rs) and
670+
[`state/matching.rs`](programs/order-book/src/state/matching.rs) — it'll
671671
read more easily once you've gone through this section.
672672
673673
### 4.1 The plan
@@ -1060,7 +1060,7 @@ imagine a future instruction handler to reclaim its rent — see §8).
10601060
10611061
### 6.1 What the program refuses to do
10621062
1063-
From [`errors.rs`](programs/clob/src/errors.rs):
1063+
From [`errors.rs`](programs/order-book/src/errors.rs):
10641064
10651065
| Error | When |
10661066
|---|---|
@@ -1178,9 +1178,9 @@ A production CLOB would add:
11781178
## 7. Running the tests
11791179
11801180
All tests are LiteSVM Rust integration tests under
1181-
[`programs/clob/tests/test_clob.rs`](programs/clob/tests/test_clob.rs).
1181+
[`programs/order-book/tests/test_order_book.rs`](programs/order-book/tests/test_order_book.rs).
11821182
They load the built `.so` via
1183-
`include_bytes!("../../../target/deploy/clob.so")`, so a build must
1183+
`include_bytes!("../../../target/deploy/order_book.so")`, so a build must
11841184
run first.
11851185
11861186
### Prerequisites
@@ -1191,14 +1191,14 @@ run first.
11911191
11921192
### Commands
11931193
1194-
From `defi/clob/anchor/`:
1194+
From `defi/order-book/anchor/`:
11951195
11961196
```bash
1197-
# 1. Build the .so — target/deploy/clob.so
1197+
# 1. Build the .so — target/deploy/order_book.so
11981198
anchor build
11991199
12001200
# 2. Run the LiteSVM tests
1201-
cargo test --manifest-path programs/clob/Cargo.toml
1201+
cargo test --manifest-path programs/order-book/Cargo.toml
12021202
12031203
# Or equivalently (Anchor.toml scripts.test = "cargo test"):
12041204
anchor test --skip-local-validator
@@ -1400,11 +1400,11 @@ in production.
14001400
## Code layout
14011401

14021402
```
1403-
defi/clob/anchor/
1403+
defi/order-book/anchor/
14041404
├── Anchor.toml
14051405
├── Cargo.toml
14061406
├── README.md (this file)
1407-
└── programs/clob/
1407+
└── programs/order-book/
14081408
├── Cargo.toml
14091409
├── src/
14101410
│ ├── errors.rs
@@ -1425,5 +1425,5 @@ defi/clob/anchor/
14251425
│ ├── market_user.rs
14261426
│ └── matching.rs (pure fill-planning logic)
14271427
└── tests/
1428-
└── test_clob.rs LiteSVM tests
1428+
└── test_order_book.rs LiteSVM tests
14291429
```
File renamed without changes.

defi/clob/anchor/programs/clob/Cargo.toml renamed to defi/order-book/anchor/programs/order-book/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
2-
name = "clob"
2+
name = "order_book"
33
version = "0.1.0"
4-
description = "Central limit order book on Solana"
4+
description = "Order book example (CLOB) on Solana"
55
edition = "2021"
66

77
[lib]
88
crate-type = ["cdylib", "lib"]
9-
name = "clob"
9+
name = "order_book"
1010

1111
[features]
1212
default = []
File renamed without changes.

defi/clob/anchor/programs/clob/src/instructions/cancel_order.rs renamed to defi/order-book/anchor/programs/order-book/src/instructions/cancel_order.rs

File renamed without changes.

defi/clob/anchor/programs/clob/src/instructions/create_market_user.rs renamed to defi/order-book/anchor/programs/order-book/src/instructions/create_market_user.rs

File renamed without changes.

0 commit comments

Comments
 (0)