Overview
The Keep-rs bots can be configured through a combination of environment variables (via.env file) and command-line flags. CLI flags take precedence over environment variables when both are specified.
Environment Variables
Environment variables are loaded from a.env file in the project root. Copy .env.example to .env and configure with your credentials.
Required Variables
Base58-encoded Solana private key for the bot’s wallet.This wallet is used to sign and send all transactions. It should have:
- Sufficient SOL for transaction fees (recommend 0.5+ SOL)
- USDC collateral in Drift for settling trades and liquidations
- Proper permissions on your Drift account
Solana RPC endpoint for submitting transactions and querying blockchain state.For best performance, use a dedicated RPC provider with high rate limits and low latency.Examples:
Drift gRPC endpoint for real-time account updates, slot updates, and transaction confirmations.The gRPC connection provides:
- Real-time user account updates
- Market and oracle account updates
- Slot updates for orderbook state
- Transaction confirmation notifications
Authentication token for the gRPC endpoint.Contact your gRPC provider for access credentials.Example:
Pyth Lazer access token for real-time price feeds.Pyth Lazer provides high-frequency oracle price updates that are critical for:
- Accurate fill pricing (filler bot)
- Margin calculations (liquidator bot)
- Auction price calculations
Optional Variables
HTTP port for the Prometheus metrics server and dashboard.The metrics server exposes:
/metrics- Prometheus-format metrics/health- Health check endpoint/dashboard- Human-readable status page/api/dashboard- JSON dashboard data (liquidator only)
Comma-separated list of perpetual market indices for the filler bot to monitor.Market indices:
0= SOL-PERP1= BTC-PERP2= ETH-PERP- (Additional markets vary by deployment)
--market-ids CLI flag.Examples:Network selection:
true for mainnet-beta, false for devnet.Can be overridden by --mainnet CLI flag.Examples:Dry-run mode: When
true, transactions are simulated but not sent to the network.Useful for:- Testing configuration
- Validating strategy logic
- Estimating profitability without risk
--dry CLI flag.Example:Compute unit limit for liquidation transactions (liquidator bot only).This environment variable can override the
--fill-cu-limit CLI flag for the liquidator bot. The liquidator uses this to set compute unit limits for liquidation transactions.Example:CLI Flags
Command-line flags configure bot behavior and override environment variables.Bot Mode Selection
Run the Filler Bot to match orders against resting liquidity.Usage:
This is the default mode when neither
--filler nor --liquidator is specified.Run the Liquidator Bot to liquidate undercollateralized positions.Usage:
Network Configuration
Connect to Solana mainnet-beta. When Overrides
false, connects to devnet.Usage:MAINNET environment variable.Enable dry-run mode. Transactions are simulated but not sent.Usage:Overrides
DRY_RUN environment variable.Filler-Specific Flags
Monitor and fill orders for all available perpetual markets.When enabled, this overrides
--market-ids and automatically discovers all active perp markets (excluding bet markets and uninitialized markets).Usage:Comma-separated list of perpetual market indices to monitor.Usage:Can also be set via
MARKET_IDS environment variable.Compute unit limit for swift order fill transactions.Swift fills require more compute due to off-chain signature verification. Increase this if transactions fail with “Compute Unit Exceeded” errors.Usage:
Compute unit limit for regular auction and limit order fill transactions.Standard fills typically require fewer compute units than swift fills.Usage:
Liquidator-Specific Flags
Minimum collateral threshold (in USDC micro-units) for liquidation.Accounts with total collateral below this value are skipped. This prevents wasting gas on dust liquidations.Units: USDC micro-units (6 decimals)
1000000= 1 USDC5000000= 5 USDC10000000= 10 USDC
Enable spot liquidation using Jupiter swaps.When enabled, the bot will liquidate spot borrow positions using atomic swaps. When disabled, only perpetual positions are liquidated.Usage:
Transaction Configuration
Base priority fee in microlamports per compute unit.The actual priority fee may be dynamically adjusted based on:
- Recent successful transactions (priority fee subscriber)
- Network congestion levels
- Bot mode (liquidator uses 60th percentile)
Drift sub-account ID to use for the bot.Allows running multiple bots from the same wallet using different Drift sub-accounts.Usage:
Configuration Examples
Filler Bot - Mainnet Production
Liquidator Bot - Devnet Testing
Filler Bot - High-Volume Markets Only
Liquidator Bot - Conservative Settings
Troubleshooting
Missing Environment Variables
.env file exists and contains all required variables. Copy from .env.example:
Invalid Private Key Format
BOT_PRIVATE_KEY is base58-encoded. Export from Phantom/Solflare in base58 format.
RPC Connection Issues
- Verify
RPC_URLis correct and accessible - Check your RPC provider rate limits
- Test connection manually:
gRPC Subscription Failures
- Verify
GRPC_ENDPOINTandGRPC_X_TOKENare correct - Check your gRPC provider status
- Ensure your IP is allowlisted (if required)
Source Reference
- Config struct:
src/main.rs:27-59 - Environment loading:
src/main.rs:85-86(dotenv) - Config parsing:
src/main.rs:87(clap parser)