A modular service for monitoring staking deposits, executing profitable transactions, and claiming rewards.
This system is composed of four main components:
- Monitor: Tracks on-chain staking events and updates the database.
- Profitability Engine: Analyzes deposits for profitable actions and batches.
- Executor: Executes profitable transactions and manages the transaction queue.
- Database: Persists all state, events, and queue data (supports Supabase and JSON).
stateDiagram-v2
[*] --> Monitor
Monitor --> Database: Store events
Monitor --> ProfitabilityEngine: Notify new/updated deposits
ProfitabilityEngine --> Database: Update queue, analysis
ProfitabilityEngine --> Executor: Queue profitable actions
Executor --> Database: Update tx status
Executor --> [*]
sequenceDiagram
participant User
participant Monitor
participant Database
participant ProfitabilityEngine
participant Executor
participant Ethereum
Monitor->>Ethereum: Poll for events
Ethereum-->>Monitor: New deposit/withdrawal events
Monitor->>Database: Store events
Monitor->>ProfitabilityEngine: Notify deposit update
ProfitabilityEngine->>Database: Read deposits
ProfitabilityEngine->>ProfitabilityEngine: Analyze profitability
alt Profitable
ProfitabilityEngine->>Executor: Queue claim tx
Executor->>Database: Store tx
Executor->>Ethereum: Submit claim tx
Ethereum-->>Executor: Tx receipt
Executor->>Database: Update tx status
end
- Tracks on-chain events (deposits, withdrawals, delegatee changes)
- Groups events by transaction
- Maintains checkpoints for resilience
- Emits events to the profitability engine
- Analyzes deposits for claim profitability
- Optimizes batch size and timing
- Uses price feeds and gas estimates
- Queues profitable claims for execution
- Manages transaction queue (FIFO)
- Executes claim transactions (wallet or Defender relayer)
- Handles retries, confirmations, and tip management
- Stores deposits, events, checkpoints, queues, and claim history
- Supports Supabase (production) and JSON (testing)
Configuration is managed via environment variables and src/configuration/.
- See
.env.examplefor all options. - Key parameters: RPC_URL, STAKER_CONTRACT_ADDRESS, LST_ADDRESS, EXECUTOR_TYPE, DATABASE_TYPE, etc.
pnpm run build
pnpm run prodOr run specific components:
COMPONENTS=monitor,profitability pnpm run prod- Each component exposes health/status logs.
- Use
pnpm run health-checkfor status. - Logs:
output.log(info),errors.log(errors)
deposits: Tracks staking depositsprocessing_checkpoints: Tracks component stateprocessing_queue: Manages analysis queuetransaction_queue: Manages tx execution queue
- Prerequisites
- Installation
- Environment Setup
- Component Architecture
- Configuration Guide
- Running the Service
- Monitoring and Maintenance
- Troubleshooting
Before setting up the service, ensure you have:
- Node.js v18+ installed
- PNPM package manager installed (
npm install -g pnpm) - Access to an Ethereum RPC endpoint (e.g., Alchemy, Infura)
- A wallet with sufficient funds for gas fees
- (Optional) OpenZeppelin Defender account for production deployments
- Clone the repository:
git clone <repository-url>
cd staker-bots- Install dependencies:
pnpm install- Create environment configuration:
cp .env.example .envThe service requires careful configuration of environment variables. Here's a detailed guide for each section:
# Required: RPC endpoint URL
RPC_URL=https://eth-mainnet.g.alchemy.com/v2/your-api-key
# Required: Chain ID (1 for mainnet, 11155111 for sepolia)
CHAIN_ID=1
# Required: Network name
NETWORK_NAME=mainnet
# Optional: Starting block number (defaults to latest if not set)
START_BLOCK=0# Required: Staker contract address
STAKER_CONTRACT_ADDRESS=0x...