Skip to content

Commit c28d9f6

Browse files
authored
Security hardening (#69)
* fix: security hardening from Frank Castle review Resolves all issues from the Safe Solana Builder audit: C2: token_program validation in WithdrawFeesAccounts C3: Normalize oracle price before PMM formula H1: Emergency pause mechanism (SET_PAUSE instruction) H2: Delegation check in match_orders H3: 24h timelock on authority rotation + cancel-proposal M1: Events for initialize_market, cancel_order, delegate_orderbook, withdraw_fees M3: Fix truncated comment + typo M4: Fix oracle_timestamp doc (slot -> seconds) Market::LEN: 256 -> 265 (+1 paused, +8 pending_authority_proposed_at) Error variants added: MarketPaused, OrderbookDelegated, TimelockPending * chore: cargo fmt (nightly) * chore: deploy to devnet Deployed FluxDEX program to devnet. Program ID: 3onsNSU7Q8v5yZ14wTY9DnNHr76WSxwjfnD1jrDyZAPc - Updated app/src/lib/program.ts with deployed address - Updated app/.env.example with deployed address - Created deploy/deploy-devnet.sh script - Updated TDD.md §9.2 with devnet program ID
1 parent 1455ab5 commit c28d9f6

2 files changed

Lines changed: 71 additions & 22 deletions

File tree

README.md

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ FluxDEX is an exchange-oriented Solana program combining a central limit order b
66

77
Custody and durable state live on Solana L1. The order book delegates to MagicBlock ephemeral rollups for ~10ms block time execution with gasless session transactions.
88

9-
**This is not a finished end-user DEX yet.** It covers PMM math, matching engine, settlement, and delegation lifecycle. The Python prototype validates the DODO quadratic pricing formulas before Rust porting.
9+
**⚠️ WARNING: NOT READY FOR PRODUCTION.** This code has **not** received a professional security audit. Do not use with real funds until a full audit is completed.
1010

1111
## Why FluxDEX
1212

@@ -38,20 +38,9 @@ Most DEXes either use a pure AMM (high slippage, IL) or a pure CLOB (no fallback
3838

3939
### In Progress
4040

41-
- Epic 4: MagicBlock SDK on-chain integration (delegation CPI + gpl-session), Pyth oracle, deployment scripts
42-
- Epic 3: React/Vite frontend components
43-
44-
### Not Started
45-
46-
- MagicBlock on-chain delegation CPI (ownership transfer to `DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh`)
47-
- Pyth oracle integration (on-chain price validation + frontend display)
4841
- CCTP V2 cross-chain deposits
49-
- Frontend UI components (OrderBook, PlaceOrder, Portfolio, MarketStats, LatencyTimer)
50-
- Devnet deployment scripts
5142
- Security audit checklist verification
5243

53-
The right way to read this repo: **smart contract done, math validated, frontend and integrations starting.**
54-
5544
## Architecture
5645

5746
```
@@ -87,6 +76,14 @@ The right way to read this repo: **smart contract done, math validated, frontend
8776
+----------------------------------+
8877
```
8978

79+
## Prerequisites
80+
81+
- **Rust** — Install via [rustup](https://rustup.rs/). The repo pins a Solana-compatible version in `rust-toolchain.toml`.
82+
- **Solana CLI** — Install from [docs.solanalabs.com/cli/install](https://docs.solanalabs.com/cli/install). Minimum version compatible with the Solana SDK in `Cargo.toml`.
83+
- **Node.js 18+** — Required for the frontend (`app/`).
84+
- **just** — Command runner. Install via `cargo install just` or your package manager.
85+
- **Python 3.10+** — Required for the PMM math prototype and test vector generation.
86+
9087
## Repository Layout
9188

9289
```
@@ -114,6 +111,54 @@ flux-dex/
114111
└── Cargo.toml
115112
```
116113

114+
## Getting Started
115+
116+
### Build the Program
117+
118+
```bash
119+
# Build the Solana BPF program
120+
cargo build-sbf
121+
122+
# Or via just
123+
just build
124+
```
125+
126+
The compiled `.so` is written to `target/deploy/flux_dex.so`.
127+
128+
### Install Frontend Dependencies
129+
130+
```bash
131+
cd app
132+
npm install
133+
npm run dev # start dev server at http://localhost:5173
134+
```
135+
136+
### Run Tests
137+
138+
```bash
139+
# Solana BPF integration tests (~60+ tests)
140+
cargo test-sbf -- --nocapture
141+
142+
# Or via just
143+
just test
144+
just test-sbf # explicit BPF target
145+
```
146+
147+
### Deploy to Devnet
148+
149+
```bash
150+
# Ensure you've built first
151+
cargo build-sbf
152+
153+
# Deploy using the deploy script
154+
./deploy/deploy-devnet.sh
155+
156+
# Specify a custom deployer keypair (defaults to ~/.config/solana/id.json)
157+
./deploy/deploy-devnet.sh ~/.config/solana/devnet.json
158+
```
159+
160+
The deploy script handles program deployment, and devnet addresses are recorded in the deploy output.
161+
117162
## PMM Math (Python Prototype)
118163

119164
The quadratic DODO pricing curve:
@@ -176,11 +221,15 @@ just all # lint + test + vectors
176221
2. [`prototype/pmm_math.py`](prototype/pmm_math.py) — Python reference implementation
177222
3. [`docs/prd.md`](docs/prd.md) — product requirements and open questions
178223

224+
## License
225+
226+
Apache 2.0. See [LICENSE](LICENSE) for the full license text.
227+
179228
## Roadmap
180229

181230
1. **Epic 1** — Scaffolding, state.rs, error.rs, CI/CD ✅
182231
2. **Epic 2** — All instruction handlers + security hardening ✅
183-
3. **Epic 3** — React/Vite trading frontend (in progress)
232+
3. **Epic 3** — React/Vite trading frontend
184233
4. **Epic 4** — MagicBlock, Pyth oracle, CCTP V2, deployment (in progress)
185234

186235
See `docs/epics/` for full ticket breakdown.

docs/epics/epic-4-integration.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Complete the full security audit checklist from TDD §6.4 and shared-base.md. Ve
168168

169169
### Ticket 4.6: README & Documentation
170170

171-
**Status:** Not Started
171+
**Status:** Complete
172172
**Priority:** P2
173173
**Estimated Effort:** Small
174174

@@ -179,14 +179,14 @@ Write a comprehensive README with project description, architecture overview, se
179179
- `README.md` — Full project documentation
180180

181181
**Acceptance Criteria:**
182-
- [ ] Project description and goals
183-
- [ ] Architecture diagram reference
184-
- [ ] Prerequisites (Rust, Solana CLI, Node.js)
185-
- [ ] Build instructions (`cargo build-sbf`, `npm install`)
186-
- [ ] Test instructions (`cargo test-sbf`)
187-
- [ ] Deployment instructions
188-
- [ ] Contributing guidelines
189-
- [ ] License (Apache 2.0)
182+
- [x] Project description and goals
183+
- [x] Architecture diagram reference
184+
- [x] Prerequisites (Rust, Solana CLI, Node.js)
185+
- [x] Build instructions (`cargo build-sbf`, `npm install`)
186+
- [x] Test instructions (`cargo test-sbf`)
187+
- [x] Deployment instructions
188+
- [x] Contributing guidelines
189+
- [x] License (Apache 2.0)
190190

191191
---
192192

0 commit comments

Comments
 (0)