polyoxide_clob/lib.rs
1//! # polyoxide-clob
2//!
3//! Rust client library for Polymarket CLOB (Centralized Limit Order Book) API.
4//!
5//! ## Features
6//!
7//! - Order creation, signing, and posting with EIP-712
8//! - Market data and order book retrieval
9//! - Account balance and trade history
10//! - HMAC-based L2 authentication
11//! - Type-safe API with idiomatic Rust patterns
12//!
13//! ## Example
14//!
15//! ```no_run
16//! use polyoxide_clob::{Account, Chain, ClobBuilder, CreateOrderParams, OrderKind, OrderSide};
17//!
18//! #[tokio::main]
19//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
20//! // Load account from environment variables
21//! let account = Account::from_env()?;
22//!
23//! // Create CLOB client
24//! let clob = ClobBuilder::new()
25//! .with_account(account)
26//! .chain(Chain::PolygonMainnet)
27//! .build()?;
28//!
29//! // Place an order
30//! let params = CreateOrderParams {
31//! token_id: "token_id".to_string(),
32//! price: 0.52,
33//! size: 100.0,
34//! side: OrderSide::Buy,
35//! order_type: OrderKind::Gtc,
36//! post_only: false,
37//! expiration: None,
38//! funder: None,
39//! signature_type: None,
40//! };
41//!
42//! let response = clob.place_order(¶ms, None).await?;
43//! println!("Order ID: {:?}", response.order_id);
44//!
45//! Ok(())
46//! }
47//! ```
48
49pub mod account;
50pub mod api;
51pub mod client;
52pub mod core;
53pub mod error;
54pub mod request;
55pub mod types;
56pub mod utils;
57
58#[cfg(feature = "ws")]
59pub mod ws;
60
61pub use core::chain::{Chain, Contracts};
62
63pub use account::{Account, AccountConfig, Credentials, Signer, Wallet};
64pub use api::{
65 account::{BalanceAllowanceResponse, Trade},
66 health::Health,
67 markets::{
68 ListMarketsResponse, Market, MarketToken, MidpointResponse, OrderBook, OrderLevel,
69 PriceResponse,
70 },
71 orders::{CancelResponse, OpenOrder, OrderResponse},
72};
73pub use client::{Clob, ClobBuilder, CreateOrderParams};
74pub use error::ClobError;
75pub use types::{
76 Order, OrderKind, OrderSide, ParseTickSizeError, PartialCreateOrderOptions, SignatureType,
77 SignedOrder, TickSize,
78};