Keeper Service
The Keeper Service is an automated background process that maintains system liveness by accruing yields, recording performance snapshots, and triggering automated rebalancing.
Overview
Without user interaction, DeFi strategies continue to accrue yields on-chain. The Keeper Service ensures Obsqra.fi remains "live" by periodically updating balances, recording historical snapshots, and executing automated strategies.
Yield Accrual
Updates strategy balances every 30 seconds
Snapshots
Records historical data to PostgreSQL
Auto-Rebalance
Triggers portfolio adjustments when needed
Testing vs Production
Testing Environment
For local development and demo purposes, the keeper runs as a simple Node.js script with aggressive intervals to showcase live updates.
- •Technology: Node.js script with viem
- •Database: Optional (works without PostgreSQL)
- •Intervals: 30 seconds (aggressive for demos)
- •Purpose: Local testing, rapid iteration
Production Environment
For mainnet deployment, Obsqra.fi uses Chainlink Automation for decentralized, reliable keeper operations with optimized gas usage.
- •Technology: Chainlink Automation Network
- •Database: PostgreSQL (Supabase or RDS)
- •Intervals: 5+ minutes (gas-optimized)
- •Purpose: Decentralized, reliable automation
Note: The contracts are already Chainlink-compatible with checkUpkeep() and performUpkeep() functions. No code changes needed for production deployment.
How It Works
Yield Accrual
Keeper calls StrategyRouter.accrueAllYields() which updates balances for all active strategies (Aave, Lido, Compound).
→ Balances update to reflect current value
→
YieldAccrued events emittedSnapshot Recording
After accrual, keeper reads updated balances and records them to PostgreSQL for historical tracking.
→ Inserts records into
balance_snapshots table→ Powers performance charts and analytics
Rebalance Check
Keeper queries AutoRebalancer.checkUpkeep() to determine if portfolio rebalancing is needed.
→ Evaluates time since last rebalance
→ Triggers
performUpkeep() if conditions metQuick Start
1. Environment Setup
Create keeper/.env:
2. Start Keeper
3. Monitor
Tip: The keeper runs alongside your Next.js dev server. Start both in separate terminals to see yields accrue live in the UI.
Architecture
viem → Ethereum clientaccrueAllYields()Database (Optional)
The keeper works without PostgreSQL for testing. For production with historical data persistence, set up a database:
Quick Docker Setup
Initialize Schema
Seed Historical Data
Production: Use managed PostgreSQL services like Supabase, AWS RDS, or Heroku Postgres for reliability and automated backups.
Resources
- 📄QUICK_START_KEEPER.md - Simplified quick reference
- 📄DEPLOYMENT_GUIDE.md - Complete production deployment guide
- 📄keeper/README.md - Detailed keeper service documentation
- 🔗Chainlink Automation Docs - Production keeper solution