Expand description
§polyte
Unified Rust client for Polymarket APIs, combining CLOB (trading), Gamma (market data), and Data APIs.
§Features
- Unified access to CLOB, Gamma, and Data APIs
- Type-safe API with idiomatic Rust patterns
- EIP-712 order signing and HMAC authentication
- Comprehensive market data and trading operations
§Example
use polyte::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load account from environment variables
let account = Account::from_env()?;
// Create unified client
let polymarket = Polymarket::builder(account)
.chain(Chain::PolygonMainnet)
.build()?;
// Use Gamma API to list markets
let markets = polymarket.gamma.markets()
.list()
.active(true)
.limit(10)
.send()
.await?;
// Use CLOB API to place an order
if let Some(first_market) = markets.first() {
if let Some(token) = first_market.tokens.first() {
let order_params = CreateOrderParams {
token_id: token.token_id.clone(),
price: 0.52,
size: 100.0,
side: OrderSide::Buy,
expiration: None,
};
let response = polymarket.clob.place_order(&order_params).await?;
println!("Order placed: {:?}", response.order_id);
}
}
Ok(())
}Re-exports§
pub use polyte_clob;pub use polyte_data;pub use polyte_gamma;
Modules§
- prelude
- Prelude module for convenient imports
Structs§
- Polymarket
- Unified Polymarket client
- Polymarket
Builder - Builder for Polymarket client
Enums§
- Polymarket
Error - Error types for Polymarket operations