On-chain cron-job service for DeFi protocols built on Arbitrum Stylus in Rust. Protocols register tasks (target + selector + trigger) and a decentralized keeper network executes them when due.
- Time-based tasks — fire every N seconds, with automatic reschedule
- Condition-based tasks — fire when an on-chain value crosses a threshold (e.g. vault profit > X)
- Min-heap priority queue — O(1) peek, O(log n) push/pop/remove for constant-cost keeper lookups
- Packed storage — 6 U256 slots per task, single-slot status/timestamp updates
- Access control — owner + keeper whitelist + per-task ownership
- Pausable — global pause + per-task pause/resume
- Reentrancy-safe — checks-effects-interactions + storage-based lock
- Keeper bot — Python script for continuous task monitoring and execution
# Build
cargo build --release --target wasm32-unknown-unknown
# Test
cargo test
# Run keeper
cd scripts && pip install -r requirements.txt
python keeper.py --rpc <RPC> --scheduler <ADDR> --private-key <KEY>src/
├── lib.rs Contract entrypoint, storage, public API, heap adapter
├── types.rs Task struct with pack/unpack, TriggerKind, TaskStatus
├── errors.rs Solidity custom-error types via sol! macro
├── access.rs Role-based access guards
├── queue.rs Generic min-heap with HeapStorage trait
└── executor.rs Trigger evaluation, external call dispatch, reschedule math
scripts/
├── keeper.py Keeper bot — poll, check, execute loop
└── requirements.txt
tests/
└── scheduler_test.rs 30+ integration tests
See ARCHITECTURE.md for the full technical deep-dive.
MIT