use dex_connector::{create_lighter_connector, DexConnector, OrderSide};
use rust_decimal::Decimal;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
let api_key = env::var("LIGHTER_API_KEY").expect("LIGHTER_API_KEY must be set");
let private_key = env::var("LIGHTER_PRIVATE_KEY").expect("LIGHTER_PRIVATE_KEY must be set");
let is_testnet = env::var("LIGHTER_TESTNET").unwrap_or_default() == "true";
let base_url = if is_testnet {
"https://testnet.zklighter.elliot.ai".to_string()
} else {
"https://mainnet.zklighter.elliot.ai".to_string()
};
let websocket_url = if is_testnet {
"wss://testnet.zklighter.elliot.ai/ws".to_string()
} else {
"wss://mainnet.zklighter.elliot.ai/ws".to_string()
};
let connector = create_lighter_connector(api_key, private_key, base_url, websocket_url)?;
connector.start().await?;
let ticker = connector.get_ticker("ETH", None).await?;
println!("ETH Price: {}", ticker.price);
let balance = connector.get_balance(None).await?;
println!(
"Account Equity: {}, Available Balance: {}",
balance.equity, balance.balance
);
let filled_orders = connector.get_filled_orders("ETH").await?;
println!("Number of filled orders: {}", filled_orders.orders.len());
connector.stop().await?;
Ok(())
}