polyte_clob/
lib.rs

1//! # polyte-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 polyte_clob::{Account, Chain, ClobBuilder, CreateOrderParams, 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(account)
25//!         .chain(Chain::PolygonMainnet)
26//!         .build()?;
27//!
28//!     // Place an order
29//!     let params = CreateOrderParams {
30//!         token_id: "token_id".to_string(),
31//!         price: 0.52,
32//!         size: 100.0,
33//!         side: OrderSide::Buy,
34//!         expiration: None,
35//!     };
36//!
37//!     let response = clob.place_order(&params).await?;
38//!     println!("Order ID: {:?}", response.order_id);
39//!
40//!     Ok(())
41//! }
42//! ```
43
44pub mod account;
45pub mod api;
46pub mod client;
47pub mod core;
48pub mod error;
49pub mod request;
50pub mod types;
51pub mod utils;
52
53#[cfg(feature = "ws")]
54pub mod ws;
55
56pub use account::{Account, AccountConfig, Credentials, Signer, Wallet};
57pub use api::account::{BalanceAllowanceResponse, Trade};
58pub use api::markets::{
59    ListMarketsResponse, Market, MarketToken, MidpointResponse, OrderBook, OrderLevel,
60    PriceResponse,
61};
62pub use api::orders::{CancelResponse, OpenOrder, OrderResponse};
63pub use client::{Clob, ClobBuilder, CreateOrderParams};
64pub use core::chain::{Chain, Contracts};
65pub use error::{ClobError, Result};
66pub use types::{Order, OrderKind, OrderSide, SignatureType, SignedOrder, TickSize};