use ostium_rust_sdk::{Network, OstiumClient, Result};
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
println!("đ Ostium Rust SDK - Basic Usage Example");
println!("=========================================");
println!("\nđĄ Connecting to Ostium testnet...");
let client = OstiumClient::new(Network::Testnet).await?;
println!("â
Connected to network: {:?}", client.config().network);
println!("đ RPC URL: {}", client.config().rpc_url);
println!("đ GraphQL URL: {}", client.config().graphql_url);
println!("\nđ Fetching available trading pairs...");
match client.get_pairs().await {
Ok(pairs) => {
println!("â
Found {} trading pairs:", pairs.len());
for pair in pairs.iter().take(5) {
println!(
" âĸ {} ({})",
pair.symbol,
if pair.is_active { "Active" } else { "Inactive" }
);
}
if pairs.len() > 5 {
println!(" ... and {} more", pairs.len() - 5);
}
}
Err(e) => {
println!("â ī¸ Failed to fetch pairs: {}", e);
}
}
println!("\nđ° Fetching BTC/USD price...");
match client.get_price("BTC/USD").await {
Ok(price) => {
println!("â
BTC/USD Price:");
println!(" âĸ Mark Price: ${}", price.mark_price);
println!(" âĸ Index Price: ${}", price.index_price);
println!(" âĸ 24h High: ${}", price.high_24h);
println!(" âĸ 24h Low: ${}", price.low_24h);
println!(" âĸ 24h Volume: ${}", price.volume_24h);
}
Err(e) => {
println!("â ī¸ Failed to fetch price: {}", e);
}
}
println!("\nđ Checking trading hours for BTC/USD...");
match client.get_trading_hours("BTC/USD").await {
Ok(hours) => {
println!("â
Trading Hours:");
println!(
" âĸ Market Open: {}",
if hours.is_open { "Yes" } else { "No" }
);
if let Some(next_open) = hours.next_open {
println!(" âĸ Next Open: {}", next_open);
}
if let Some(next_close) = hours.next_close {
println!(" âĸ Next Close: {}", next_close);
}
}
Err(e) => {
println!("â ī¸ Failed to fetch trading hours: {}", e);
}
}
println!("\nđŗ Balance check example:");
println!("âšī¸ To check balance, you need to provide an address or configure a signer");
println!(" Example: client.get_balance(Some(address)).await");
println!("\n⨠Basic usage example completed!");
println!("\nđ Next steps:");
println!(" âĸ Check examples/trading.rs for trading operations");
println!(" âĸ Configure a private key to enable trading");
println!(" âĸ Explore the full API documentation");
Ok(())
}