@barista-dex/cli-dlp
v0.1.29
Published
CLI for Barista DEX Liquidity Providers (DLPs)
Downloads
87
Maintainers
Readme
Barista DLP CLI
Command-line interface for Decentralized Liquidity Providers (DLPs) on Barista DEX.
Note: This CLI is for DLPs only. If you're a trader, use the
cli-clientCLI instead.
Features
- 🏦 Portfolio Management - Initialize, deposit, withdraw, and view DLP capital
- 📊 Slab Operations - Create and view order book slabs
- 🔒 Safety Checks - Automatic validation to prevent unsafe operations
- 🎨 Beautiful Output - Color-coded displays with real-time spinners
- 💬 Interactive Prompts - Guided parameter collection and confirmations
Oracle Management: For oracle operations (init, update, crank), use the
percolator-keeperbinary instead.
Installation
From npm (Recommended)
# Global installation
npm install -g @barista-dex/cli-dlp
# Or use npx (no installation required)
npx @barista-dex/cli-dlp --helpFrom Source
# Clone repository
git clone https://github.com/barista-dex/barista-dex.git
cd barista-dex/cli-dlp
# Install dependencies
npm install
# Build
npm run build
# Link globally (optional)
npm linkQuick Start
1. Initialize Portfolio
# Initialize a new DLP portfolio
barista-dlp portfolio:init \
--keypair ~/.config/solana/dlp-wallet.json \
--network localnet2. Deposit Capital
# Deposit 100 SOL (100000000000 lamports)
barista-dlp deposit \
--amount 100000000000 \
--keypair ~/.config/solana/dlp-wallet.json \
--network localnet3. View Portfolio
# View basic portfolio summary
barista-dlp portfolio \
--keypair ~/.config/solana/dlp-wallet.json \
--network localnet
# View detailed breakdown with per-slab exposure
barista-dlp portfolio --detailed4. Withdraw Capital
# Withdraw 10 SOL
barista-dlp withdraw \
--amount 10000000000 \
--keypair ~/.config/solana/dlp-wallet.json \
--network localnet
# Force withdrawal (skip safety checks - dangerous!)
barista-dlp withdraw --amount 10000000000 --forceEnvironment Variables
Set these to avoid passing options every time:
export BARISTA_DLP_KEYPAIR=~/.config/solana/dlp-wallet.json
export BARISTA_DLP_NETWORK=localnet
export BARISTA_DLP_RPC_URL=http://127.0.0.1:8899 # Optional custom RPC
# Now you can omit --keypair and --network flags
barista-dlp portfolio
barista-dlp deposit --amount 50000000000Commands
Portfolio Commands
portfolio:init
Initialize a new DLP portfolio account.
barista-dlp portfolio:init --keypair <path>Options:
--keypair <path>- Path to DLP wallet keypair--network <network>- Network: localnet/devnet/mainnet-beta (default: localnet)--url <url>- Custom RPC URL
portfolio
View DLP portfolio details and capital summary.
barista-dlp portfolio [options]Options:
--detailed- Show detailed per-slab exposure breakdown--keypair <path>- Path to DLP wallet keypair--network <network>- Network to use
Example Output:
═══════════════════════════════════════
DLP Portfolio Summary
═══════════════════════════════════════
┌──────────────────────────────┬──────────────────────────────┐
│ Metric │ Value │
├──────────────────────────────┼──────────────────────────────┤
│ Principal (Deposited) │ 100.0 SOL │
│ Realized PnL │ +2.5 SOL │
│ ─────────────────────────── │ ─────────────────────────── │
│ Total Equity │ 102.5 SOL │
└──────────────────────────────┴──────────────────────────────┘
💡 Tips:
• Use --detailed for more information
• Create slabs with: barista-dlp slab create
• View analytics with: barista-dlp analytics statsdeposit
Deposit SOL capital to your portfolio.
barista-dlp deposit --amount <lamports>Options:
--amount <lamports>- Amount in lamports (1 SOL = 1,000,000,000 lamports)--keypair <path>- Path to DLP wallet keypair--network <network>- Network to use
Safety Checks:
- Validates amount > 0
- Warns if deposit is unusually large
- Auto-creates portfolio if it doesn't exist
Examples:
# Deposit 1 SOL
barista-dlp deposit --amount 1000000000
# Deposit 100 SOL
barista-dlp deposit --amount 100000000000
# Deposit with custom RPC
barista-dlp deposit --amount 50000000000 --url http://localhost:8899withdraw
Withdraw SOL from your portfolio.
barista-dlp withdraw --amount <lamports> [--force]Options:
--amount <lamports>- Amount in lamports to withdraw--force- Skip safety checks (dangerous!)--keypair <path>- Path to DLP wallet keypair--network <network>- Network to use
Safety Checks:
- ✅ Ensures sufficient balance
- ✅ Blocks withdrawals with open positions
- ✅ Warns about unrealized PnL
- ✅ Prevents capital undercollateralization
- ✅ Enforces minimum balance thresholds
Examples:
# Withdraw 10 SOL (with safety checks)
barista-dlp withdraw --amount 10000000000
# Force withdrawal (skip safety checks)
barista-dlp withdraw --amount 5000000000 --forceSafety Check Example:
⚠ Safety Warnings:
• Withdrawal reduces free capital by 50% - monitor your exposure
• Recommended minimum: Keep at least 10 SOL as buffer
✓ Proceed with withdrawal despite warnings? No
❯ Withdrawal cancelledSlab Commands
slab:create
Create a new order book slab.
barista-dlp slab:create \
--instrument <instrument-address> \
--mark-price 100.50 \
--taker-fee 10 \
--contract-size 1.0Options:
--instrument <address>- Instrument (perp market) public key--mark-price <price>- Initial mark price in USD (e.g., 100.50)--taker-fee <bps>- Taker fee in basis points (e.g., 10 = 0.1%)--contract-size <size>- Contract size (e.g., 1.0)--yes- Skip confirmation prompts--keypair <path>- Path to DLP wallet keypair--network <network>- Network to use
Interactive Mode: If options are not provided, the CLI will prompt for each parameter:
barista-dlp slab:create
? Instrument address (perp market): <paste-address>
? Mark price (USD, e.g., 100.50): 100.00
? Taker fee (bps, e.g., 10 = 0.1%): 10
? Contract size (e.g., 1.0): 1.0
? Create slab with these settings? Yes
✓ Slab created successfully!
Slab Address: 7EqQdEU...vcMwJeK
Signature: 5j8dqXJ...rYjk9Z
⚠ Save this slab address! You'll need it to manage this slabNotes:
- Slab PDA is derived from:
['slab', lpOwner, instrument] - Only one slab per LP Owner + Instrument combination
- Requires portfolio to exist first
slab:view
View slab details and current state.
# Basic view
barista-dlp slab:view --address <slab-pubkey>
# Detailed view with prices and instruments
barista-dlp slab:view --address <slab-pubkey> --detailedOptions:
--address <pubkey>- Slab address (required)--detailed- Show best prices and instruments--keypair <path>- Path to DLP wallet (to check ownership)--network <network>- Network to use
Example Output:
═══════════════════════════════════════
Slab Information
═══════════════════════════════════════
┌──────────────────────┬────────────────────────────────┐
│ Field │ Value │
├──────────────────────┼────────────────────────────────┤
│ Slab Address │ 7EqQdEU...vcMwJeK │
│ LP Owner (DLP) │ 9aE2FN...Lp4k2 │
│ Router ID │ Router1...2r3t │
│ Instrument │ SOLPER...P1 │
│ │ ✓ You own this slab │
└──────────────────────┴────────────────────────────────┘
┌──────────────────────┬────────────────────────────────┐
│ Parameter │ Value │
├──────────────────────┼────────────────────────────────┤
│ Mark Price │ $100.00 │
│ Contract Size │ 1.000000 │
│ Taker Fee │ 10.00 bps │
│ Sequence Number │ 0 │
│ Bump │ 255 │
└──────────────────────┴────────────────────────────────┘Future Commands
slab:update (Coming Soon)
Update slab parameters (fees, limits, etc.).
barista-dlp slab:update --address <slab-pubkey> --fee-bps 10slab:pause (Coming Soon)
Pause trading on a slab (emergency stop).
barista-dlp slab:pause --address <slab-pubkey>slab:resume (Coming Soon)
Resume trading on a paused slab.
barista-dlp slab:resume --address <slab-pubkey>Analytics Commands (Coming Soon)
analytics:exposure
View current exposure across all slabs.
barista-dlp analytics:exposureanalytics:stats
View performance statistics and metrics.
barista-dlp analytics:stats --period 7danalytics:trades
View recent trades and settlements.
barista-dlp analytics:trades --limit 50Configuration
Network Configuration
The CLI automatically configures program IDs based on the network:
- localnet: Uses localhost programs
- devnet: Uses Solana devnet programs
- mainnet-beta: Uses production programs
Wallet Setup
# Generate a new DLP wallet
solana-keygen new -o ~/.config/solana/dlp-wallet.json
# Check balance
solana balance ~/.config/solana/dlp-wallet.json
# Airdrop SOL on localnet/devnet
solana airdrop 100 ~/.config/solana/dlp-wallet.json --url http://127.0.0.1:8899Safety Features
Deposit Safety
- Validates deposit amount is positive
- Warns if amount is unusually large (>1000 SOL)
- Auto-initializes portfolio if needed
Withdrawal Safety
The CLI performs comprehensive safety checks before withdrawals:
- Balance Check - Ensures sufficient balance exists
- Position Check - Blocks withdrawals with open positions
- PnL Check - Warns about unrealized losses
- Utilization Check - Prevents capital undercollateralization
- Minimum Balance - Enforces safety buffers
Override with --force (not recommended):
barista-dlp withdraw --amount 100000000000 --forceDevelopment
Build
cd cli-dlp
npm run buildTest
npm testLocal Development
# Watch mode for development
npm run dev
# Link for testing
npm link
barista-dlp --helpTroubleshooting
"Portfolio not found"
You need to initialize a portfolio first:
barista-dlp portfolio:init --keypair <path>Or deposit capital (auto-creates portfolio):
barista-dlp deposit --amount 100000000000 --keypair <path>"Insufficient balance"
Check your wallet balance:
solana balance ~/.config/solana/dlp-wallet.jsonAirdrop SOL on localnet/devnet:
solana airdrop 100 ~/.config/solana/dlp-wallet.json --url http://127.0.0.1:8899"Cannot withdraw with open positions"
Close all positions before withdrawing. View open positions:
barista-dlp portfolio --detailedConnection errors
Verify your RPC URL is correct:
# Test connection
curl http://127.0.0.1:8899 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"getVersion"}'Architecture
cli-dlp/
├── src/
│ ├── index.ts # CLI entry point with Commander.js
│ ├── commands/
│ │ ├── portfolio/
│ │ │ ├── init.ts # Initialize portfolio
│ │ │ ├── view.ts # View portfolio details
│ │ │ ├── deposit.ts # Deposit capital
│ │ │ └── withdraw.ts # Withdraw capital
│ │ ├── slab/ # Slab management (coming soon)
│ │ └── analytics/ # Analytics commands (coming soon)
│ └── utils/
│ ├── wallet.ts # Keypair loading
│ ├── network.ts # RPC and program ID config
│ ├── display.ts # Formatting and display
│ └── safety.ts # Safety checks and validations
├── package.json
├── tsconfig.json
└── README.mdRelated
- SDK:
@barista-dex/sdk- TypeScript SDK for building applications - Trader CLI:
cli-client- CLI for traders - Keeper CLI:
cli- Rust-based keeper operations (alternative)
Publishing
This package is published to npm as @barista-dex/cli-dlp.
For Maintainers
# Run tests and build
npm run prepublishOnly
# Publish to npm (requires npm credentials)
npm publish
# Or publish with tag
npm publish --tag betaPre-publish Checklist:
- [ ] Update version in
package.json - [ ] Update
CHANGELOG.mdwith changes - [ ] Run all tests:
npm test - [ ] Build successfully:
npm run build - [ ] Test locally:
npm link && barista-dlp --help - [ ] Create git tag:
git tag cli-dlp-v0.2.0
Contributing
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
Development Workflow
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run tests:
npm test - Run linter:
npm run lint:fix - Commit changes:
git commit -m "feat: my feature" - Push to your fork:
git push origin feature/my-feature - Open a Pull Request
Support
- Documentation: Barista DEX Docs
- Issues: GitHub Issues
- Discord: Join our community
- NPM: @barista-dex/cli-dlp
License
Apache-2.0
Copyright 2025 Barista DEX Contributors
See LICENSE for full details.
