Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"crates/shepherd-sdk-test",
"modules/ethflow-watcher",
"modules/example",
"modules/examples/price-alert",
"modules/twap-monitor",
]
resolver = "2"
Expand Down
16 changes: 16 additions & 0 deletions modules/examples/price-alert/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "price-alert"
version = "0.1.0"
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "Shepherd example module: polls a Chainlink price oracle every block and emits a Warn log when the price crosses a config-supplied threshold."

[lib]
crate-type = ["cdylib"]

[dependencies]
shepherd-sdk = { path = "../../../crates/shepherd-sdk" }
alloy-primitives = { version = "1.5", default-features = false, features = ["std"] }
alloy-sol-types = { version = "1.5", default-features = false, features = ["std"] }
wit-bindgen = { version = "0.57", default-features = false, features = ["macros", "realloc"] }
43 changes: 43 additions & 0 deletions modules/examples/price-alert/module.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# price-alert example module: polls a Chainlink price oracle on every
# block and emits a Warn log when the price crosses a config-supplied
# threshold. Demonstrates `chain::request` + ABI decode via
# `alloy_sol_types` + config-driven module behaviour.

[module]
name = "price-alert"
version = "0.1.0"
# Placeholder content hash. 0.2 parses but does not verify this; 0.3
# will compare against the sha256 of the loaded component bytes.
component = "sha256:0000000000000000000000000000000000000000000000000000000000000000"

[capabilities]
required = ["logging", "chain"]
optional = []

[capabilities.http]
# All chain traffic flows through the `chain` capability (host's
# pinned alloy provider). No direct `http` calls.
allow = []

# --- subscriptions ----------------------------------------------------

# New blocks on Sepolia drive the polling cadence.
[[subscription]]
kind = "block"
chain_id = 11155111

# --- config -----------------------------------------------------------

[config]
# Chainlink AggregatorV3Interface address. Default points at the
# canonical ETH/USD feed on Sepolia.
oracle_address = "0x694AA1769357215DE4FAC081bf1f309aDC325306"
# Decimals the oracle reports (Chainlink USD pairs are 8).
decimals = "8"
# Threshold in the oracle's native decimal units.
threshold = "2500.00"
# "above" -> fires when answer >= threshold
# "below" -> fires when answer <= threshold
direction = "below"
# Throttle: only poll every Nth block. Default 1.
every_n_blocks = "1"
Loading