Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stylus Task Scheduler

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.

Features

  • 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

Quick Start

# 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>

Project Structure

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.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages