Skip to main content

Installation

This guide will walk you through installing Keep-rs and configuring it to run keeper bots on Drift Protocol.

Prerequisites

Before installing Keep-rs, ensure you have the following:

Required Software

1

Rust Toolchain

Install Rust 1.87.0 or later using rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup component add rustfmt
Verify installation:
rustc --version
cargo --version
2

Solana CLI (Optional)

If you need to create a new wallet or manage keys:
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
Generate a new keypair:
solana-keygen new --outfile ~/bot-keypair.json
3

Git

Ensure Git is installed for cloning the repository:
git --version

Required Access & Credentials

You will need the following credentials before running the bots. Some require paid subscriptions.
  • Bot Wallet: A Solana wallet with SOL for transaction fees (base58 encoded private key)
  • RPC Endpoint: A Solana RPC provider (e.g., Helius, QuickNode, Triton)
  • gRPC Access: Drift Protocol gRPC endpoint and authentication token
  • Pyth Lazer Token: For real-time price feeds (optional but recommended)

Clone and Build

1

Clone the Repository

Clone the Keep-rs repository from GitHub:
git clone https://github.com/drift-labs/keep-rs.git
cd keep-rs
2

Build the Project

Build the release binary with optimizations:
cargo build --release
This will compile the keeprs binary to target/release/keeprs.
The first build may take several minutes as Cargo downloads and compiles all dependencies. Subsequent builds will be faster due to caching.
3

Verify the Build

Check that the binary was created successfully:
./target/release/keeprs --help
You should see the help output with available command-line options.

Configure Environment Variables

1

Copy Environment Template

Create your environment configuration from the example file:
cp .env.example .env
2

Edit Required Variables

Open .env in your editor and configure the required variables:
# Required: Bot wallet private key (base58 encoded)
BOT_PRIVATE_KEY="your_base58_private_key_here"

# Required: Solana RPC endpoint
RPC_URL="https://api.mainnet-beta.solana.com"

# Required: Drift gRPC configuration
GRPC_ENDPOINT="https://api.rpcpool.com"
GRPC_X_TOKEN="your_grpc_token_here"

# Optional: Pyth price feed access token
PYTH_LAZER_TOKEN="your_pyth_token_here"
Never commit your .env file to version control. It contains sensitive credentials.
3

Configure Optional Variables

Customize additional settings as needed:
# Metrics server port (default: 9898)
METRICS_PORT=9898

# Market IDs to operate on (comma-separated, default: "0,1,2")
# Market 0 = SOL-PERP, 1 = BTC-PERP, 2 = ETH-PERP
MARKET_IDS="0,1,2"

# Network selection (default: true)
MAINNET=true

# Dry run mode - simulate without sending transactions (default: false)
DRY_RUN=false

Environment Variable Reference

Required Variables

VariableDescriptionExample
BOT_PRIVATE_KEYBase58 encoded Solana private key for your bot wallet5J7W...
RPC_URLSolana RPC endpoint URLhttps://api.mainnet-beta.solana.com
GRPC_ENDPOINTDrift Protocol gRPC endpointhttps://api.rpcpool.com
GRPC_X_TOKENAuthentication token for gRPC accessyour_token

Optional Variables

VariableDescriptionDefault
PYTH_LAZER_TOKENPyth Lazer price feed tokenNone
METRICS_PORTPort for Prometheus metrics server9898
MARKET_IDSComma-separated perp market indices"0,1,2"
MAINNETUse mainnet (true) or devnet (false)true
DRY_RUNSimulate transactions without sendingfalse

Getting Access Credentials

Bot Wallet Setup

Your bot needs a funded Solana wallet:
  1. Create a new keypair (if you don’t have one):
    solana-keygen new --outfile ~/bot-keypair.json
    
  2. Export as base58:
    cat ~/bot-keypair.json | jq -r 'map(tostring) | join(",")' | base58
    
  3. Fund the wallet: Transfer SOL to your bot’s address for transaction fees
    • Minimum recommended: 0.5 SOL for fillers, 1-5 SOL for liquidators

RPC Provider

The public RPC endpoint (https://api.mainnet-beta.solana.com) has rate limits. For production use, sign up for a dedicated RPC provider:

gRPC Access

Contact the Drift Protocol team to get gRPC access:
  • Join the Drift Discord
  • Request keeper bot access in the developer channels
  • Receive your GRPC_ENDPOINT and GRPC_X_TOKEN

Pyth Lazer (Optional)

For the fastest price feeds:
  • Visit Pyth Network
  • Sign up for Pyth Lazer access
  • Generate an API token

Docker Installation (Alternative)

If you prefer to run Keep-rs in Docker:
1

Build the Docker Image

docker build -t keeprs .
This creates an optimized multi-stage build with all dependencies.
2

Run with Environment File

docker run --env-file .env -p 9898:9898 keeprs --mainnet --filler
The Docker image exposes port 9898 for metrics. Map it to your host with -p 9898:9898 to access the metrics and health endpoints.

Verify Installation

Test that everything is configured correctly:
# Run in dry-run mode to verify configuration without sending transactions
RUST_LOG=info cargo run --release -- --mainnet --filler --dry
You should see log output indicating:
  • Bot wallet loaded successfully
  • Connected to RPC endpoint
  • gRPC subscriptions established
  • Metrics server running on port 9898
Check the metrics endpoint:
curl http://localhost:9898/health
If you see a success response, your installation is complete!

Next Steps

Quick Start Guide

Get your first bot running with step-by-step instructions

Configuration Reference

Learn about all available configuration options

Build docs developers (and LLMs) love