1use std::sync::Arc;
2
3use ethers::{
4 signers::{LocalWallet, Signer},
5 types::Address,
6};
7use hyperliquid::{types::Chain, Hyperliquid, Info};
8
9const SEP: &str = "\n---";
10
11#[tokio::main]
12pub async fn main() {
13 let wallet: Arc<LocalWallet> = Arc::new(
15 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
16 .parse()
17 .unwrap(),
18 );
19
20 let user = wallet.address();
21
22 let info = Hyperliquid::new(Chain::Dev);
23
24 println!("Info Spot API Examples");
25
26 spot_meta(&info).await;
27 spot_meta_and_asset_ctxs(&info).await;
28 spot_clearinghouse_state(&info, user).await;
29}
30
31async fn spot_meta(info: &Info) {
32 let spot_meta = info.spot_meta().await.unwrap();
33 println!("{SEP}\nSpot Metadata \n{:?}{SEP}", spot_meta);
34}
35
36async fn spot_meta_and_asset_ctxs(info: &Info) {
37 let spot_asset_ctxs = info.spot_meta_and_asset_ctxs().await.unwrap();
38 println!("Spot Asset Contexts \n{:?}{SEP}", spot_asset_ctxs);
39}
40
41async fn spot_clearinghouse_state(info: &Info, user: Address) {
42 let states = info.spot_clearinghouse_state(user).await.unwrap();
43 println!("User spot state for {user} \n{:?}{SEP}", states);
44}