mirror of
https://github.com/exchanges-lab/tradesync.git
synced 2026-08-05 05:06:07 +08:00
feat: implement HyperliquidMonitor for position opening and migrate dependencies to git repository urls
This commit is contained in:
+23
-8
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user