npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@barista-dex/cli

v0.1.35

Published

Command-line interface for Barista DEX

Readme

Barista CLI (Traders)

Command-line interface for traders on Barista DEX.

Note: This CLI is for traders only. If you're a DLP (Decentralized Liquidity Provider), use the cli-dlp CLI for slab management and portfolio operations.

Installation

npm install -g @barista-dex/cli

Or use directly with npx:

npx @barista-dex/cli --help

Configuration

The CLI comes pre-configured with program addresses for devnet, mainnet-beta, and localnet. Configuration is handled through environment variables (similar to binance-cli).

Environment Variables

Set these once in your shell profile (~/.bashrc, ~/.zshrc, etc.):

# Network: mainnet-beta (default), devnet, or localnet
export BARISTA_NETWORK=mainnet-beta

# Custom RPC endpoint (optional)
export BARISTA_RPC_URL=https://my-custom-rpc.com

# Keypair path (optional, defaults to ~/.config/solana/id.json)
export BARISTA_KEYPAIR=/path/to/keypair.json

Priority: CLI flags > Environment variables > Defaults

Network Selection

You can override environment variables with CLI flags:

# Use environment variable (if set) or default to mainnet
barista portfolio

# Override with CLI flag
barista portfolio --network devnet

# Use environment variable for network, override RPC
barista portfolio --url https://my-custom-rpc.com

Quick Setup

For mainnet trading with default settings (no configuration needed):

# Uses mainnet-beta by default
barista portfolio

For devnet testing:

# Option 1: Set environment variable (persistent)
export BARISTA_NETWORK=devnet
barista portfolio

# Option 2: Use CLI flag (one-time)
barista portfolio --network devnet

v0.5 Limitations

Important: This CLI interfaces with v0.5 (counterparty settlement model):

  • Market orders only - Executes instantly at oracle price (±0.5% slippage tolerance)
  • Limit orders execute instantly (NOT resting orders) - Price validation only, fills immediately
  • Single slab execution - Must specify --slab (cross-slab smart routing disabled in v0.5)
  • Single instrument per slab - v1+ will support up to 32 instruments per slab
  • Atomic fills - No partial fills or order book
  • SOL collateral only - v1+ will support multi-collateral (USDC, etc.)
  • PnL settles against DLP vault - Each slab has an LP/DLP providing liquidity as counterparty
    • User profit = DLP loss (SOL transferred from DLP Portfolio → User Portfolio)
    • User loss = DLP profit (SOL transferred from User Portfolio → DLP Portfolio)
  • v1 order book - Migration will enable resting orders, cross-slab routing, trader-to-trader matching

For more details on v0.5 → v1 migration, see V1_ROADMAP.md.


Commands

Portfolio Management

View Portfolio

New in v0.1.32: Clean, boxed layout with color-coded PnL, actual leverage display, and asset-agnostic "units" labels.

barista portfolio

# Example output:
# ╭─💰 Balance────────────────────────────────────────╮
# │  Equity: 49.000000000 units                       │
# │  Free: 48.000 units  |  IM: 1.0 units  |  PnL: 0.00 units  │
# ╰───────────────────────────────────────────────────╯
#
# ╭─📍 Positions──────────────────────────────────────╮
# │  1 active position                                │
# ╰───────────────────────────────────────────────────╯
#
# ┌──────────┬──────────┬──────────┬────────────┬────────────┬──────┐
# │ Size     │ Entry    │ Mark     │ PnL        │ Notional   │ Lev  │
# ├──────────┼──────────┼──────────┼────────────┼────────────┼──────┤
# │ 5.000000 │ $199.00  │ $199.50  │ +0.002500  │ $997.50    │ 5x   │
# └──────────┴──────────┴──────────┴────────────┴──────────┴──────┘

# View another trader's portfolio
barista portfolio --address <trader-address>

Deposit Collateral (SOL Only in v0)

barista deposit --amount <lamports>

# Example: Deposit 1 SOL (1000000000 lamports)
barista deposit --amount 1000000000

# Example: Deposit 0.5 SOL
barista deposit --amount 500000000

Note:

  • Amounts are in lamports (1 SOL = 1,000,000,000 lamports)
  • v0 supports SOL deposits only
  • Portfolio is automatically created on first deposit
  • USDC and other SPL tokens coming in v1+

Withdraw Collateral (SOL Only in v0)

barista withdraw --amount <lamports>

# Example: Withdraw 0.5 SOL
barista withdraw --amount 500000000

Trading

Execute Orders (v0.5: Single Slab Required)

v0.5: Must specify --slab for all trades. Cross-slab smart routing is disabled.

# Market buy (executes at oracle price)
barista buy --slab <SLAB_ADDRESS> -q 1000

# Market sell
barista sell --slab <SLAB_ADDRESS> -q 500

# Limit buy (sanity-checked, executes instantly)
barista buy --slab <SLAB_ADDRESS> -q 1000 -p 50000000

# With leverage (5x)
barista buy --slab <SLAB_ADDRESS> -q 1000 -l 5x

v0.5 Behavior:

  • --slab is required (single-slab execution only)
  • --instrument is optional (for future multi-instrument slabs in v1+)
  • Orders execute instantly (no order book)
  • Market orders: Filled at oracle price ± 0.5% slippage
  • Limit orders: Price validated within ±20% of oracle, then filled instantly
  • Settlement: Real SOL transfer between User Portfolio ↔ DLP Portfolio

Closing Positions:

  • Leverage is ignored when closing - you can close a 5x position with a 1x order
  • Example: Opened long 5 contracts @ 5x, close with sell -q 5 at any leverage
  • Margin is fully returned regardless of the leverage used on the close order

Position Reversals:

  • Selling more than your long position automatically reverses to short
  • Example: Long 5 contracts, sell 10 contracts:
    1. Closes the 5-contract long (returns margin)
    2. Opens a 5-contract short (requires new margin based on sell order leverage)

v1 (Future):

  • --slab will be optional (cross-slab smart routing re-enabled)
  • --instrument will enable best price discovery across slabs
  • Resting limit orders will wait for price
  • Trader-to-trader matching via order book

Market Data

Get Price

barista price --slab <market>

View Order Book

barista book --slab <market>

# Show 20 levels
barista book --slab <market> --levels 20

Options

All commands support the following options:

  • -n, --network <network> - Network to use: mainnet-beta, devnet, or localnet (default: BARISTA_NETWORK env var or mainnet-beta)
  • -u, --url <url> - Custom RPC URL (default: BARISTA_RPC_URL env var or network default)
  • -k, --keypair <path> - Path to keypair file (default: BARISTA_KEYPAIR env var or ~/.config/solana/id.json)
  • -h, --help - Display help for command

Examples

Complete Trading Workflow

# 1. Deposit SOL collateral (10 SOL = 10000000000 lamports)
barista deposit --amount 10000000000

# 2. Check your portfolio
barista portfolio

# 3. View market prices
barista price --slab SLaBZ6Ps...

# 4. View order book depth
barista book --slab SLaBZ6Ps... --levels 10

# 5. Place a buy order
barista buy --slab SLaBZ6Ps... --quantity 1000000

# 6. Place a sell order
barista sell --slab SLaBZ6Ps... --quantity 500000

# 7. Withdraw funds (5 SOL)
barista withdraw --amount 5000000000

Example Output

Portfolio:

📊 Portfolio Summary

┌─────────────────────────┬──────────────────────────────┐
│ Metric                  │ Value                        │
├─────────────────────────┼──────────────────────────────┤
│ Owner                   │ 5Z6sRxvL...                  │
│ Equity                  │ 1000.000000                  │
│ Collateral Value        │ 1000.000000                  │
│ Maint Margin            │ 0.000000                     │
│ Unrealized PnL          │ 0.000000                     │
│ Health                  │ 100.000000                   │
│ Last Update             │ 1234567890                   │
└─────────────────────────┴──────────────────────────────┘

Order Book:

📖 Order Book (SLaBZ6Ps...)

┌────────────────────┬────────────────────┬─────┬────────────────────┬────────────────────┐
│ Bid Size           │ Bid Price          │     │ Ask Price          │ Ask Size           │
├────────────────────┼────────────────────┼─────┼────────────────────┼────────────────────┤
│ 10.500000          │ 50000.000000       │     │ 50010.000000       │ 8.250000           │
│ 5.250000           │ 49990.000000       │     │ 50020.000000       │ 12.000000          │
└────────────────────┴────────────────────┴─────┴────────────────────┴────────────────────┘

Spread: 10.000000 (0.02%)
Total Bid Depth: 15 levels
Total Ask Depth: 12 levels

Development

# Install dependencies
npm install

# Build
npm run build

# Link locally
npm link

# Test
barista --help

Architecture

The CLI is built on top of the @barista-dex/sdk package, which handles all Solana interactions and instruction building.

CLI (@barista-dex/cli)
  └── SDK (@barista-dex/sdk)
        └── Solana Web3.js

License

MIT