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::{
66 BalanceAllowanceResponse, BuilderTrade, ListBuilderTrades, ListBuilderTradesResponse,
67 ListClobTrades, ListTradesResponse, MakerOrder, Trade,
68 },
69 auth::{
70 ApiKeyInfo, ApiKeyResponse, ClosedOnlyResponse, ReadonlyApiKeyResponse, ValidateKeyResponse,
71 },
72 health::{Health, ServerTimeResponse},
73 markets::{
74 BookParams, CalculatePriceResponse, LastTradePriceResponse, ListMarketsResponse,
75 LiveActivityEvent, Market, MarketToken, MidpointResponse, OrderBook, OrderLevel,
76 PriceResponse, SpreadResponse,
77 },
78 notifications::Notification,
79 orders::{
80 BatchCancelResponse, ListOrdersResponse, OpenOrder, OrderResponse, OrderScoringResponse,
81 },
82 rewards::{
83 RewardEarnings, RewardMarket, RewardMarketEarning, RewardPercentages, RewardTotalEarnings,
84 },
85 rfq::{
86 CreateRfqQuoteParams, CreateRfqRequestParams, RfqConfig, RfqPaginatedResponse, RfqQuote,
87 RfqQuoteResponse, RfqRequest, RfqRequestResponse,
88 },
89};
90pub use client::{Clob, ClobBuilder, CreateOrderParams, SignedOrderPayload};
91pub use error::ClobError;
92pub use types::{
93 Order, OrderKind, OrderSide, ParseTickSizeError, PartialCreateOrderOptions, SignatureType,
94 SignedOrder, TickSize,
95};