feat: implement HyperliquidMonitor for position opening and migrate dependencies to git repository urls

This commit is contained in:
0xcathiefish
2026-05-30 09:00:53 +00:00
parent ffd98934e4
commit eadaa81438
15 changed files with 5397 additions and 224 deletions
+23 -8
View File
@@ -1,25 +1,40 @@
use alloy::primitives::address;
use anyhow::Result;
use nosync::{ModuleA, ModuleB};
use nosync::HyperliquidMonitor;
use tokio::sync::mpsc;
use tracing::info;
use tracing_subscriber::{EnvFilter, FmtSubscriber};
#[tokio::main]
async fn main() -> Result<()> {
// Configure simple standard output logging
let subscriber = FmtSubscriber::builder()
.with_env_filter(EnvFilter::new("info"))
.finish();
tracing::subscriber::set_global_default(subscriber)
.map_err(|e| anyhow::anyhow!("failed to set global tracing subscriber: {e}"))?;
info!("--- Running nosync library example ---");
info!("--- Starting Hyperliquid monitor demo ---");
// Construct the structs and execute the logic
let processor = ModuleA::new("example-processor".to_string())?;
let orchestrator = ModuleB::new(processor)?;
// Standard wallet address for demo
let wallet = address!("0xc64cc00b46101bd40aa1c3121195e85c0b0918d8");
let monitor = HyperliquidMonitor::new(wallet, true);
orchestrator.run().await?;
let (tx, mut rx) = mpsc::unbounded_channel();
// Spawn the monitor in a background task
tokio::spawn(async move {
if let Err(e) = monitor.run(tx).await {
tracing::error!("Monitor error: {:?}", e);
}
});
info!("Listening for position open events. Close with Ctrl+C...");
while let Some(event) = rx.recv().await {
info!(
"DEMO RECEIVED POSITION OPEN: coin={}, side={}, px={}, sz={}, time={}, tid={}",
event.coin, event.side, event.px, event.sz, event.time, event.tid
);
}
info!("--- Example execution completed successfully ---");
Ok(())
}