Skip to main content

Keeper Deployment

The keeper is an off-chain bot that processes deposits, executes rebalances, runs DCA schedules, and collects fees.

What the Keeper Does​

OperationTrigger
Process depositsEscrow has funds
Execute DCASchedule next_execution reached
Trigger rebalanceCadence elapsed + drift detected
Collect feesFees accrued since last collection
Refund unsupported mintsUnwhitelisted token deposited
Swap-assisted depositsWhitelisted non-USDC deposit

Running​

# Development
bun run --cwd packages/keeper dev

# Production
bun run --cwd packages/keeper start

Configuration​

All configuration is via environment variables:

Required​

VariableDescription
RPC_URLS or SOLANA_RPC_URLSolana RPC endpoint(s), comma-separated
KEEPER_KEYPAIRPath to keeper keypair JSON (default: ./keeper-keypair.json)

Polling and Retry​

VariableDefaultDescription
KEEPER_INTERVAL_MS15000Main loop interval
KEEPER_MAX_RETRIES3Max retries per transaction
KEEPER_RETRY_BASE_DELAY_MS400Base delay between retries

Transaction Fees​

VariableDefaultDescription
KEEPER_PRIORITY_FEE_MICROLAMPORTSautoFixed priority fee override
KEEPER_PRIORITY_FEE_PERCENTILE0.75Priority fee percentile (when auto)
KEEPER_COMPUTE_UNIT_MARGIN_BPS1500CU margin over simulation (15%)

Route Provider​

The keeper needs swap routes for cross-mint rebalancing:

VariableDefaultDescription
KEEPER_ROUTE_PROVIDER_MODEfilefile, http, or hybrid
KEEPER_REBALANCE_ROUTES_FILE—Path to routes JSON file
KEEPER_REBALANCE_ROUTES_URL—URL for route generation service
KEEPER_ROUTE_GENERATOR_URL—On-demand route generator URL
KEEPER_ROUTES_REFRESH_MS30000Route cache refresh interval
KEEPER_ROUTE_REQUEST_TIMEOUT_MS2500Route request timeout
KEEPER_ROUTE_FAILURE_THRESHOLD3Failures before circuit-breaker opens
KEEPER_ROUTE_FAILURE_COOLDOWN_MS30000Circuit-breaker cooldown

Mint Whitelist​

VariableDescription
KEEPER_WHITELIST_MINTSComma-separated mints for swap-deposit processing
KEEPER_SWAP_ROUTES_FILERoute config for whitelisted non-USDC deposits

Telemetry​

VariableDefaultDescription
KEEPER_TELEMETRY_WEBHOOK_URL—Webhook endpoint for telemetry events
KEEPER_TELEMETRY_TIMEOUT_MS2500Webhook timeout
KEEPER_TELEMETRY_AUTH_HEADER—Auth header name
KEEPER_TELEMETRY_AUTH_TOKEN—Auth token value

Alerting​

VariableDefaultDescription
KEEPER_ALERT_FAILURE_RATE_THRESHOLD0.25Failure rate to trigger alert
KEEPER_ALERT_MIN_ATTEMPTS5Min attempts before alerting
KEEPER_ALERT_COOLDOWN_MS300000Alert cooldown (5 min)

RPC Pool​

The keeper uses RpcPool for multi-endpoint failover. Provide multiple URLs comma-separated:

RPC_URLS=https://rpc1.example.com,https://rpc2.example.com,https://rpc3.example.com

The pool randomly selects endpoints and retries on alternates when one fails.

Production Checklist​

  1. Use a dedicated keypair with sufficient SOL for transaction fees
  2. Fund the keeper's USDC token account (for receiving keeper incentives)
  3. Set up multiple RPC endpoints for reliability
  4. Configure telemetry webhook for monitoring
  5. Set appropriate alerting thresholds
  6. Run as a persistent process (systemd, Docker, Fly.io)