Expand description
§predict-fun-sdk
Rust SDK for the 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 feedsorder— EIP-712 order structs, signing, and amount calculationexecution— Auth → sign → submit pipeline with market metadata cache
§Quick Start
use predict_fun_sdk::{PredictApiClient, PredictExecutionClient, PredictExecConfig};
use predict_fun_sdk::ws::{PredictWsClient, PredictWsMessage, Topic};
use predict_fun_sdk::order::BNB_MAINNET_CHAIN_ID;
// 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?;Re-exports§
pub use api::PredictApiClient;pub use api::RawApiResponse;pub use api::PREDICT_MAINNET_BASE;pub use api::PREDICT_TESTNET_BASE;pub use execution::MarketMeta;pub use execution::PredictExecConfig;pub use execution::PredictExecutionClient;pub use execution::PredictLimitOrderRequest;pub use execution::PredictSubmitResult;pub use order::predict_exchange_address;pub use order::predict_limit_order_amounts;pub use order::PredictOrder;pub use order::PredictOrderSigner;pub use order::PredictOutcome;pub use order::PredictSide;pub use order::PredictStrategy;pub use order::SignedPredictOrder;pub use order::BNB_MAINNET_CHAIN_ID;pub use order::BNB_TESTNET_CHAIN_ID;pub use ws::AssetPriceUpdate;pub use ws::OrderbookSnapshot;pub use ws::PredictWsClient;pub use ws::PredictWsConfig;pub use ws::PredictWsMessage;pub use ws::Topic;pub use ws::PREDICT_WS_MAINNET;pub use ws::PREDICT_WS_TESTNET;