# Transaction Bot - CLAUDE.md Automated service for triggering protocol maintenance transactions. ## Purpose This bot monitors the KRAIKEN protocol and automatically: - Triggers liquidity position recentering when needed - Processes tax liquidations for defaulting positions - Maintains protocol health through timely interventions ## Architecture ### Core Components **service.js** - Main bot loop - Queries subgraph for protocol state - Evaluates recentering conditions - Submits transactions when profitable **generateKey.js** - Utility for creating bot wallets - Generates secure private keys - Provides addresses for funding ### Configuration Environment variables (`.env`): ``` PRIVATE_KEY=0x... RPC_URL=https://... SUBGRAPH_URL=https://... ``` ## Recentering Logic The bot evaluates: 1. Current price vs liquidity position centers 2. Gas costs vs expected rewards 3. MEV protection considerations Triggers recentering when: - Price has moved significantly from position centers - Expected rewards exceed gas costs by threshold - No recent recentering has occurred ## Tax Liquidation Monitors staking positions for: - Tax payment defaults - Insufficient balances - Expired grace periods ## Development Commands ```bash # Install dependencies npm install # Generate new bot wallet node generateKey.js # Run the bot node service.js # Run with debug logging DEBUG=* node service.js ``` ## Deployment Considerations - Fund bot wallet with ETH for gas - Set appropriate gas price limits - Monitor for stuck transactions - Implement proper error handling and retries ## Security Notes - Private key must be kept secure - Use dedicated bot wallet (not personal) - Limit wallet balance to operational needs - Monitor for unusual activity ## Performance Optimization - Cache subgraph queries - Batch similar operations - Use flashbots for MEV protection - Implement exponential backoff for retries