openbook-cli
v1.1.1
Published
A comprehensive CLI tool for interacting with OpenBook and Serum DEX markets on Solana
Maintainers
Readme
OpenBook CLI
A comprehensive command-line interface for interacting with OpenBook and Serum DEX markets on Solana.
🚀 Features
- Auto-detection: Automatically detects OpenBook vs Serum markets
- Real-time data: Fetches live order book data from the blockchain
- Market management: Add and list known markets
- Universal support: Works with any market address (known or unknown)
- Separate storage: Maintains separate files for OpenBook and Serum markets
📦 Installation
npm install -g openbook-cliOr install locally:
npm install openbook-cli🎯 Quick Start
# Fetch market data (auto-detects OpenBook/Serum)
openbook-cli Gc4tfUHRNnpVwvASfQD3q26G8GNmLYuz4KzB4QNkNuiQ
# Add market to known markets
openbook-cli 8nqjw5UVN65GyfdqiXnfJNbDVBgbk8RpFFd7uACXenbx --add
# List OpenBook markets
openbook-cli --list
# List Serum markets
openbook-cli --list --serum📋 Commands
Fetch Market Data
openbook-cli <market_address>Fetches real-time market information and order book data.
Add Market to Known Markets
openbook-cli <market_address> --addAdds a market to the persistent storage for future quick access.
List Known Markets
# List OpenBook markets
openbook-cli --list
# List Serum markets
openbook-cli --list --serum🔍 Auto-Detection
The CLI automatically detects whether a market belongs to OpenBook or Serum by checking the market account owner:
- OpenBook:
srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX - Serum:
9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin
📊 Data Storage
The CLI maintains separate files for different market types in the installation directory:
known_openbook_markets.json- OpenBook markets and token symbolsknown_serum_markets.json- Serum markets and token symbols
File Location: The market files are stored in the CLI's installation directory:
~/.nvm/versions/node/v24.2.0/lib/node_modules/openbook-cli/dist/You can find the exact location by running:
npm list -g openbook-cli📈 Order Book Data
The CLI fetches live order book data directly from the blockchain:
- Bids: Buy orders sorted by price (highest first)
- Asks: Sell orders sorted by price (lowest first)
- Depth: Configurable depth (default: 15 levels)
Market Statistics
- Total Bids/Asks: Number of orders on each side
- Best Bid/Ask: Highest bid and lowest ask prices
- Spread: Difference between best ask and best bid
- Spread %: Spread as a percentage of best bid
🛠️ Development
Prerequisites
- Node.js >= 16.0.0
- TypeScript
Setup
git clone https://github.com/belivenn/openbook-cli.git
cd openbook-cli
npm installBuild
npm run buildDevelopment
npm run dev📝 Examples
Basic Market Fetch
# Fetch any market (auto-detects type)
openbook-cli Gc4tfUHRNnpVwvASfQD3q26G8GNmLYuz4KzB4QNkNuiQAdd New Markets
# Add OpenBook market
openbook-cli EgnTFXgaQ8CzVSQJyTD2sT3Yx8esLgKf5e6YGvQfm2U7 --add
# Add Serum market
openbook-cli 8nqjw5UVN65GyfdqiXnfJNbDVBgbk8RpFFd7uACXenbx --addList Markets
# List OpenBook markets
openbook-cli --list
# List Serum markets
openbook-cli --list --serumCheck Market Files Location
# Find where market files are stored
npm list -g openbook-cli
ls -la $(npm list -g openbook-cli | grep openbook-cli | awk '{print $2}')/dist/*.json🔧 Configuration
The CLI uses the following configuration:
- RPC Endpoint: Default Solana RPC
- Market Files: Stored in the current directory
- Token Symbols: Cached for faster access
🚨 Error Handling
Common Issues
- Market not found: Invalid market address
- Network issues: Connection problems to Solana RPC
- Token metadata unavailable: Missing Metaplex data
- Program ownership mismatch: Market belongs to different program
Error Messages
❌ Market account not found- Invalid market address❌ Market verification failed- Program ownership issueNo Metaplex metadata found- Token symbol resolution failed
📊 Performance
Response Times
- Known markets: ~2-3 seconds
- Unknown markets: ~3-5 seconds (includes metadata fetch)
- Order book data: ~1-2 seconds
Network Usage
- Each market fetch requires multiple RPC calls
- Order book data is fetched in real-time
- Token metadata is cached after first fetch
🔒 Security
Data Sources
- All data comes directly from Solana blockchain
- No third-party API dependencies
- Real-time verification of market ownership
Market Validation
- Verifies market account exists
- Checks program ownership
- Validates token mint addresses
📄 License
MIT License - see LICENSE file for details.
🤝 Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
