A decentralized Central Limit Order Book (CLOB) built on Solana using Anchor framework. Part of the Q4 Turbin3 Capstone Project.
RapidFlow is a decentralized exchange (DEX) protocol that implements a traditional order book matching engine on-chain. Unlike Automated Market Makers (AMMs), our CLOB provides:
- Price Discovery: True market-driven pricing through order matching
- Zero Slippage: For limit orders within the book
- Capital Efficiency: No need for large liquidity pools
- Professional Trading: Familiar interface for traditional traders
Program ID: 7ssJMQw9tFamJcsdxuaEwM6iKF7LS3e2ypNNFKRcLHjA
- 📖 On-chain Order Book - Fully decentralized bid/ask management
- 🎯 Order Types - Limit orders and market orders support
- ⚡ Price-Time Priority - Fair matching engine following traditional exchange rules
- ✍️ Order Management - Place, modify, and cancel orders seamlessly
- 🔄 Flexible Fill Logic - Support for partial and full order fills
- 💰 Fee Structure - Built-in maker/taker fees with rebate system
- 🔒 Secure - Audited smart contracts with comprehensive test coverage
- Built with Anchor framework for type safety
- Optimized for Solana's high throughput
- Efficient state management and rent optimization
- Comprehensive error handling
The protocol consists of several key components:
- Market: Main market state storing authority, token mints (base/quote), vaults, and references to bid/ask order books
- OrderBook: Stores all orders for one side of the market (bids or asks) with price-time priority
- Order: Individual order data containing order ID, owner, price, size, and timestamp
- OpenOrders: Tracks user's locked and free balances for both base and quote tokens in a specific market
- Initialize Market - Create a new trading pair
- Place Order - Add limit or market orders to the book
- Cancel Order - Remove unfilled orders
- Settle Funds - Withdraw filled order proceeds
📄 View Detailed Architecture Design
Ensure you have the following installed:
- Rust (stable toolchain)
- Solana CLI (v1.17+)
- Anchor CLI (v0.29+)
- Node.js (v18+) & npm/yarn
- Clone the repository
git clone https://github.com/bytehash69/rapid-flow.git
cd rapid-flow- Install dependencies
yarn install- Build the program
anchor build- Run tests
anchor testTo deploy to devnet:
anchor deploy --provider.cluster devnetTo deploy to mainnet-beta:
anchor deploy --provider.cluster mainnet-betarapid-flow/
├── programs/
│ └── rapid-flow/
│ ├── src/
│ │ ├── instructions/ # Instruction handlers
│ │ │ ├── initialize.rs
│ │ │ ├── place_order.rs
│ │ │ ├── cancel_order.rs
│ │ │ └── settle_funds.rs
│ │ ├── state/ # State structs and logic
│ │ │ ├── order_book.rs
│ │ │ ├── order.rs
│ │ │ └── error.rs
│ │ └── lib.rs # Program entrypoint
│ └── Cargo.toml
├── tests/
│ └── rapid-flow.ts # Integration tests
├── Anchor.toml # Anchor configuration
└── package.json
The project includes comprehensive test coverage:
# Run all tests
anchor test
# Run specific test file
anchor test tests/rapid-flow.ts- ✅ Market initialization
- ✅ Order placement (limit & market)
- ✅ Order matching logic
- ✅ Partial fills
- ✅ Order cancellation
- ✅ Fee calculation
- ✅ Fund settlement
- ✅ Edge cases and error conditions
- @bytehash69 - Core Developer
- @Vdkk07 - Core Developer
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ on Solana