A fully on-chain order book DEX on Solana that allows anyone to create trading pairs without permission. Built with Anchor framework featuring limit orders, order matching, and a modern Next.js frontend with one-click token creation.
π Try it now! No CLI required - create tokens and markets directly in the browser.
- Permissionless Market Creation - Create trading pairs in 2 clicks (no CLI required!)
- One-Click Token Creation - Auto-generate BASE and QUOTE tokens with mint authority
- Limit Order Book - Place limit buy/sell orders with custom prices
- Automated Order Matching - Permissionless cranking mechanism with economic incentives
- Fee System - Split fees between traders, crankers (10%), and market creators (90%)
- Token Balance Display - Real-time balance tracking in header
- One-Click Token Airdrop - Mint test tokens instantly (if you're mint authority)
- Step-by-Step Onboarding - Clear visual flow for new users
- Network Warnings - Prominent DEVNET badges to prevent confusion
- Professional UI - Tailwind CSS with dark mode, responsive design
- Full Documentation - Comprehensive guides for all features
- Helper Scripts - Automated token minting and setup scripts
- Social Integration - Links to developer Twitter and GitHub
- Solscan Integration - Direct links to view tokens and transactions
No CLI knowledge required! Try the DEX in 3 clicks:
- Connect Wallet β Use Phantom or Solflare
- Create Market β Click "Create Token Pair" β Auto-fills form β Create Market
- Trade β Click "Get Test Tokens" β Start trading!
Total time: ~2 minutes β±οΈ
- Blockchain: Solana (Anchor Framework 0.30+)
- Frontend: Next.js 15, React 18, TypeScript
- Styling: Tailwind CSS
- Wallet: Solana Wallet Adapter
- State Management: React Hooks
- Icons: Lucide React
Program ID (Devnet): Gvv7atyen9oY1TccNVDb76btjUKwXi6bgmhQZDnaryGg
View on Solscan: Program Explorer
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install Solana CLI
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
# Install Anchor (0.30+)
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
avm install latest
avm use latest
# Install Node.js (v18+)
# Use nvm or download from nodejs.org# Build the program
anchor build
# Run tests
anchor test
# Deploy to devnet
solana config set --url devnet
anchor deploycd app
# Install dependencies
npm install
# Start development server
npm run devVisit http://localhost:3000 to see the app!
# Use the helper script
./scripts/mint-to-wallet.sh YOUR_WALLET_ADDRESS 1000 10000
# Or manually
spl-token mint BASE_MINT 1000 YOUR_WALLET --fund-recipient
spl-token mint QUOTE_MINT 10000 YOUR_WALLET --fund-recipientorderbook-dex/
βββ programs/
β βββ orderbook-dex/
β βββ src/
β βββ lib.rs # Program entry point
β βββ states.rs # Account structures
β βββ errors.rs # Custom errors
β βββ instructions/
β βββ create_market.rs # Market creation
β βββ place_order.rs # Order placement
β βββ cancel_order.rs # Order cancellation
β βββ match_orders.rs # Matching engine
βββ tests/
β βββ orderbook-dex.ts # Integration tests
βββ app/ # Next.js frontend
β βββ app/
β β βββ page.tsx # Market list
β β βββ create/page.tsx # Create market (with token creation!)
β β βββ trade/[marketId]/page.tsx # Trading interface
β βββ components/
β β βββ TokenBalances.tsx # Balance display
β β βββ AirdropButton.tsx # One-click token minting
β β βββ TradePanel.tsx # Order placement
β β βββ OrderBook.tsx # Order book display
β β βββ Footer.tsx # Site footer
β β βββ NetworkBanner.tsx # Devnet warning
β βββ hooks/
β β βββ useProgram.ts # Anchor program hook
β β βββ useMarket.ts # Market data hook
β β βββ useOrderBook.ts # Order book hook
β βββ lib/
β βββ tokenCreation.ts # Token creation utilities
β βββ constants.ts # Config and helpers
β βββ idl.ts # Program IDL
βββ scripts/
β βββ mint-to-wallet.sh # Batch mint tokens
β βββ airdrop-tokens.ts # Airdrop helper
βββ Anchor.toml # Anchor configuration
βββ Cargo.toml # Rust workspace
Core Instructions:
create_market- Initialize a new trading pairplace_order- Place limit buy/sell orderscancel_order- Cancel pending orders with refundsmatch_orders- Permissionless crank to execute matching trades
Key Features:
- Price-priority matching (bids: highest first, asks: lowest first)
- Partial and full fill support
- Dynamic account resolution using remaining accounts pattern
- PDA-based vault system for secure asset custody
- Cranker incentives (10% of fees)
- Market creator revenue (90% of fees)
Pages:
- Market List - Browse all created markets
- Create Market - Two-step token + market creation
- Trading - Full order book with trade panel
Components:
- Token balance display (compact header mode)
- One-click token airdrop button
- Order book visualization
- Trade panel (buy/sell)
- My orders management
- Crank button for matching
- PDA Architecture - Program Derived Addresses for markets and order books
- Remaining Accounts Pattern - Dynamic account resolution for trader ATAs
- Token Program CPIs - Cross-program invocations for token transfers
- PDA Signing - Using PDAs as vault authority for secure transfers
- Partial Transaction Signing - Multi-signature transactions for token creation
- Order Book Data Structure - Efficient Vec-based order storage
- Price-Time Priority - Proper order sorting and matching
- Fee Distribution - Economic incentives for decentralized cranking
- Partial Fill Handling - Support for partial order execution
- Wallet Adapter Integration - Seamless wallet connection
- Real-time Balance Updates - Auto-refresh every 10 seconds
- Transaction State Management - Loading, success, error states
- Responsive Design - Mobile-friendly layout
Comprehensive test coverage including:
- Market creation and initialization
- Order placement (bid and ask)
- Stress testing (50 orders per side)
- Order cancellation with refund verification
- Order matching (full fills, partial fills, multiple matches)
- Fee calculation and distribution
Run tests:
anchor test- Signer Validation - All critical operations require proper signer accounts
- PDA Authority - Vaults controlled by PDAs to prevent unauthorized access
- Account Validation - Proper ATA and account ownership checks
- Integer Math - Careful handling of token decimals to prevent overflow
- Devnet Only - Clear warnings that this is a test environment
- AIRDROP_GUIDE.md - How to get test tokens
- HOW_TO_MINT_TOKENS.md - Token minting guide
- TOKEN_CREATION_COMPLETE.md - One-click token creation feature
- UX_IMPROVEMENTS.md - UI/UX enhancement details
- LAYOUT_IMPROVEMENTS.md - Layout fix documentation
- AIRDROP_BUTTON_GUIDE.md - Airdrop button usage
- Maximum 50 orders per side (configurable via
MAX_ORDERSconst) - Match orders must be called manually (permissionless but not automatic)
- No advanced order types (only limit orders currently)
- No order modification (must cancel and re-place)
- Devnet only (not production-ready for mainnet)
Trading Features:
- Automated cranking bot
- Stop-loss and take-profit orders
- Order modification without cancel
- Market orders (instant execution)
UI/UX Features:
- Historical price charts (TradingView integration)
- Trade history and analytics
- Order book depth visualization
- Mobile app (React Native)
Infrastructure:
- Backend faucet service
- WebSocket real-time updates
- Mainnet deployment
- Token metadata support
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
MIT License - see LICENSE file for details
Built by @HKsoldev
- Twitter/X: @HKsoldev
- GitHub: @MrBlackGhostt
- Repository: orderBook
Built as part of a 40-day Solana developer sprint, targeting roles at:
- Helius, Anza, Jito, Ellipsis Labs, Drift Protocol
Special thanks to:
- Solana Foundation for excellent documentation
- Anchor framework team for the amazing developer experience
- Solana community for support and resources
β‘ Built with Solana | π¦ Powered by Rust | βοΈ UI with React
For questions, feedback, or collaboration opportunities, reach out via GitHub Issues or Twitter.