diff --git a/Cargo.toml b/Cargo.toml index b71581a..c83c061 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ members = [ "crates/nexum-engine", "modules/example", + "modules/twap-monitor", ] resolver = "2" diff --git a/modules/twap-monitor/Cargo.toml b/modules/twap-monitor/Cargo.toml new file mode 100644 index 0000000..bafc696 --- /dev/null +++ b/modules/twap-monitor/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "twap-monitor" +version = "0.1.0" +edition.workspace = true +license.workspace = true +repository.workspace = true + +[lib] +crate-type = ["cdylib"] + +[dependencies] +cowprotocol = { version = "1.0.0-alpha.3", default-features = false } +alloy-sol-types = { version = "1.5", default-features = false } +wit-bindgen = { version = "0.57", default-features = false, features = ["macros", "realloc"] } diff --git a/modules/twap-monitor/src/lib.rs b/modules/twap-monitor/src/lib.rs new file mode 100644 index 0000000..72c0763 --- /dev/null +++ b/modules/twap-monitor/src/lib.rs @@ -0,0 +1,29 @@ +// wit_bindgen::generate! expands to host-import shims whose arity matches +// the WIT signatures, which can exceed clippy's too-many-arguments threshold. +#![allow(clippy::too_many_arguments)] + +wit_bindgen::generate!({ + path: ["../../wit/nexum-host", "../../wit/shepherd-cow"], + world: "shepherd:cow/shepherd", + generate_all, +}); + +use nexum::host::logging; +use nexum::host::types; + +struct TwapMonitor; + +impl Guest for TwapMonitor { + fn init(_config: Vec<(String, String)>) -> Result<(), HostError> { + logging::log(logging::Level::Info, "twap-monitor init"); + Ok(()) + } + + fn on_event(_event: types::Event) -> Result<(), HostError> { + // Dispatch on Event::Log (ConditionalOrderCreated) and Event::Block + // (TWAP poll tick) lands in BLEU-826 / BLEU-827. + Ok(()) + } +} + +export!(TwapMonitor);