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::{Chain, Clob, CreateOrderParams, OrderSide, Wallet, Credentials};
17//!
18//! #[tokio::main]
19//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
20//!     let private_key = "0x..."; // Load this from environment variables
21//!
22//!     // Set up credentials (from API)
23//!     let credentials = Credentials {
24//!         key: "<api_key>".to_string(),
25//!         secret: "<secret>".to_string(),
26//!         passphrase: "<passphrase>".to_string(),
27//!     };
28//!
29//!     // Create CLOB client
30//!     let clob = Clob::builder(private_key, credentials)?
31//!         .chain(Chain::PolygonMainnet)
32//!         .build()?;
33//!
34//!     // Place an order
35//!     let params = CreateOrderParams {
36//!         token_id: "token_id".to_string(),
37//!         price: 0.52,
38//!         size: 100.0,
39//!         side: OrderSide::Buy,
40//!         expiration: None,
41//!     };
42//!
43//!     let response = clob.place_order(&params).await?;
44//!     println!("Order ID: {:?}", response.order_id);
45//!
46//!     Ok(())
47//! }
48//! ```
49
50pub mod api;
51pub mod client;
52pub mod core;
53pub mod error;
54pub mod request;
55pub mod signer;
56pub mod types;
57pub mod utils;
58pub mod wallet;
59
60pub use api::account::{BalanceAllowanceResponse, Trade};
61pub use api::markets::{
62    ListMarketsResponse, Market, MarketToken, MidpointResponse, OrderBook, OrderLevel,
63    PriceResponse,
64};
65pub use api::orders::{CancelResponse, OpenOrder, OrderResponse};
66pub use client::{Clob, ClobBuilder, CreateOrderParams};
67pub use core::chain::{Chain, Contracts};
68pub use error::{ClobError, Result};
69pub use types::{Credentials, Order, OrderSide, SignatureType, SignedOrder, TickSize};
70pub use wallet::Wallet;