Running Bots & Scripts

Vault operations require automation for optimal performance. This page covers why automation is needed, available scripts, and infrastructure recommendations.

Important: You must host your own automation. Ranger does not provide managed bot services. You are responsible for deploying, running, and monitoring your own scripts and bots.

Why Automation Is Needed

Task
Why It Needs Automation

Rebalancing

Yield rates change frequently; manual rebalancing misses optimal allocations

Reward claiming

Protocol rewards accrue continuously; manual claiming leaves value uncollected

Reward swapping

Claimed reward tokens need to be swapped to base asset to compound

Position monitoring

Raydium CLMM positions go out-of-range; Drift positions need risk monitoring

Fee harvesting

Accumulated fees should be harvested periodically

Script Repositories

The Ranger team provides reference scripts for common operations:

Repository
Use Case

Lending strategy init (Project0, Save)

Kamino strategy init, rewards claiming

Drift vaults/lend/perps strategy init, position management

Jupiter Swap/Lend strategy init

Trustful adaptor strategy init

Script Structure Example

A basic rebalancing script:

Key Considerations

  • Gas budget: Ensure your manager wallet has enough SOL for all automated transactions. Monitor and top up regularly.

  • Error handling: Scripts should handle transaction failures gracefully (retry logic, alerting).

  • Rate limiting: Respect RPC provider rate limits. Use exponential backoff on failures.

  • Idempotency: Design scripts to be safely re-runnable in case of partial failures.

Last updated