1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! REST API client module for Lightcone.
//!
//! This module provides a type-safe HTTP client for interacting with
//! the Lightcone REST API for market data, orderbooks, orders, and more.
//!
//! # Quick Start
//!
//! ```rust,ignore
//! use lightcone_sdk::api::LightconeApiClient;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create client with default settings
//! let client = LightconeApiClient::new("https://api.lightcone.xyz");
//!
//! // Get all markets
//! let markets = client.get_markets().await?;
//! println!("Found {} markets", markets.total);
//!
//! // Get a specific market
//! let market = client.get_market("market_pubkey").await?;
//! println!("Market: {}", market.market.market_name);
//!
//! // Get orderbook
//! let orderbook = client.get_orderbook("orderbook_id", Some(10)).await?;
//! println!("Best bid: {:?}, Best ask: {:?}", orderbook.best_bid, orderbook.best_ask);
//!
//! Ok(())
//! }
//! ```
//!
//! # Client Configuration
//!
//! Use the builder pattern for custom configuration:
//!
//! ```rust,ignore
//! use lightcone_sdk::api::LightconeApiClient;
//! use std::time::Duration;
//!
//! let client = LightconeApiClient::builder("https://api.lightcone.xyz")
//! .timeout(Duration::from_secs(60))
//! .header("X-Custom-Header", "value")
//! .build()?;
//! ```
//!
//! # Error Handling
//!
//! All methods return `ApiResult<T>` which is an alias for `Result<T, ApiError>`.
//! The [`ApiError`] enum covers all possible error cases:
//!
//! ```rust,ignore
//! use lightcone_sdk::api::{LightconeApiClient, ApiError};
//!
//! match client.get_market("invalid_pubkey").await {
//! Ok(market) => println!("Found market"),
//! Err(ApiError::NotFound(resp)) => println!("Market not found: {}", resp),
//! Err(ApiError::BadRequest(resp)) => println!("Invalid request: {}", resp),
//! Err(e) => println!("Other error: {}", e),
//! }
//! ```
//!
//! # Order Submission
//!
//! Orders must be pre-signed with Ed25519. Use the program module to create
//! and sign orders, then submit via the API:
//!
//! ```rust,ignore
//! use lightcone_sdk::api::{LightconeApiClient, SubmitOrderRequest};
//!
//! let request = SubmitOrderRequest {
//! maker: "maker_pubkey".to_string(),
//! nonce: 1,
//! market_pubkey: "market_pubkey".to_string(),
//! base_token: "base_token".to_string(),
//! quote_token: "quote_token".to_string(),
//! side: 0, // BID
//! maker_amount: 1000000,
//! taker_amount: 500000,
//! expiration: 0, // No expiration
//! signature: "hex_encoded_signature".to_string(),
//! orderbook_id: "orderbook_id".to_string(),
//! };
//!
//! let response = client.submit_order(request).await?;
//! println!("Order hash: {}", response.order_hash);
//! ```
// Re-export main types for convenience
pub use ;
pub use ;
pub use *;