use std::time::Duration;
use hyperliquid_rust_sdk_toaster::{BaseUrl, InfoClient, Message, Subscription};
use log::info;
use tokio::{spawn, sync::mpsc::unbounded_channel, time::sleep};
#[tokio::main]
async fn main() {
env_logger::init();
let mut info_client = InfoClient::new(None, Some(BaseUrl::Mainnet)).await.unwrap();
let (sender, mut receiver) = unbounded_channel();
let subscription_id = info_client
.subscribe(
Subscription::ActiveAssetCtx {
coin: "@107".to_string(), },
sender,
)
.await
.unwrap();
spawn(async move {
sleep(Duration::from_secs(30)).await;
info!("Unsubscribing from order updates data");
info_client.unsubscribe(subscription_id).await.unwrap()
});
while let Some(Message::ActiveSpotAssetCtx(order_updates)) = receiver.recv().await {
info!("Received order update data: {order_updates:?}");
}
}