predict-fun-sdk 0.4.0

Rust SDK for the Predict.fun prediction market API — EIP-712 order signing, REST client, WebSocket feeds, and execution pipeline
Documentation
//! # predict-fun-sdk
//!
//! Rust SDK for the [Predict.fun](https://predict.fun) prediction market API on BNB Chain.
//!
//! ## Modules
//!
//! - [`api`] — REST client for all 30 endpoints (BNB Chain mainnet + testnet)
//! - [`ws`] — WebSocket client for real-time orderbook, price, and cross-venue feeds
//! - [`order`] — EIP-712 order structs, signing, and amount calculation
//! - [`execution`] — Auth → sign → submit pipeline with market metadata cache
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use predict_fun_sdk::{PredictApiClient, PredictExecutionClient, PredictExecConfig};
//! use predict_fun_sdk::ws::{PredictWsClient, PredictWsMessage, Topic};
//! use predict_fun_sdk::order::BNB_MAINNET_CHAIN_ID;
//!
//! # async fn example() -> anyhow::Result<()> {
//! // REST
//! let client = PredictApiClient::new_mainnet("your-api-key")?;
//! let markets = client.list_markets(&[("limit", "10".to_string())]).await?;
//!
//! // WebSocket
//! let (ws, mut rx) = PredictWsClient::connect_mainnet().await?;
//! ws.subscribe(Topic::Orderbook { market_id: 12345 }).await?;
//!
//! // Execution (with market metadata cache)
//! let exec = PredictExecutionClient::new(PredictExecConfig {
//!     api_key: "key".into(),
//!     private_key: "0x...".into(),
//!     chain_id: BNB_MAINNET_CHAIN_ID,
//!     live_execution: false,
//!     fill_or_kill: true,
//! }).await?;
//!
//! // Pre-warm cache for markets you'll trade
//! exec.preload_markets(&[12345, 67890]).await?;
//! # Ok(())
//! # }
//! ```

pub mod api;
pub mod execution;
pub mod order;
pub mod ws;

pub use api::{PredictApiClient, RawApiResponse, PREDICT_MAINNET_BASE, PREDICT_TESTNET_BASE};
pub use execution::{
    MarketMeta, PredictExecConfig, PredictExecutionClient, PredictLimitOrderRequest,
    PredictSubmitResult,
};
pub use order::{
    predict_exchange_address, predict_limit_order_amounts, PredictOrder, PredictOrderSigner,
    PredictOutcome, PredictSide, PredictStrategy, SignedPredictOrder, BNB_MAINNET_CHAIN_ID,
    BNB_TESTNET_CHAIN_ID,
};
pub use ws::{
    AssetPriceUpdate, OrderbookSnapshot, PredictWsClient, PredictWsConfig, PredictWsMessage,
    Topic, PREDICT_WS_MAINNET, PREDICT_WS_TESTNET,
};