Expand description
§predict-fun-sdk
Rust SDK for the Predict.fun prediction market API on BNB Chain.
§Features
- Full REST API coverage: all 30 endpoints from the OpenAPI spec
- Real-time WebSocket feeds: orderbook snapshots, oracle prices, cross-venue data
- EIP-712 order signing using alloy (native Rust, no ethers)
- Execution pipeline: auth → sign → submit with dry-run safety guard
- All 8 exchange contracts: mainnet + testnet × normal/negRisk/yield/yieldNegRisk
§Quick Start
use predict_fun_sdk::{PredictApiClient, PredictExecutionClient, PredictExecConfig};
use predict_fun_sdk::order::BNB_MAINNET_CHAIN_ID;
// Public data (no auth needed)
let client = PredictApiClient::new_mainnet("your-api-key")?;
let markets = client.list_markets(&[("limit", "10".to_string())]).await?;
let orderbook = client.get_market_orderbook(12345).await?;
// Real-time WebSocket feeds
use predict_fun_sdk::ws::{PredictWsClient, PredictWsMessage, Topic};
let (ws, mut rx) = PredictWsClient::connect_mainnet().await?;
ws.subscribe(Topic::Orderbook { market_id: 12345 }).await?;
ws.subscribe(Topic::AssetPrice { feed_id: 1 }).await?; // BTC
// Authenticated execution
let config = PredictExecConfig {
api_key: "your-api-key".into(),
private_key: "0x...".into(),
chain_id: BNB_MAINNET_CHAIN_ID,
live_execution: false, // dry-run by default
fill_or_kill: true,
};
let exec = PredictExecutionClient::new(config).await?;§Modules
Re-exports§
pub use api::PredictApiClient;pub use api::RawApiResponse;pub use api::PREDICT_ENDPOINTS;pub use api::PREDICT_MAINNET_BASE;pub use api::PREDICT_TESTNET_BASE;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;