predict_fun_sdk/lib.rs
1//! # predict-fun-sdk
2//!
3//! Rust SDK for the [Predict.fun](https://predict.fun) prediction market API on BNB Chain.
4//!
5//! ## Features
6//!
7//! - **Full REST API coverage**: all 30 endpoints from the [OpenAPI spec](https://api.predict.fun/docs)
8//! - **EIP-712 order signing** using [alloy](https://github.com/alloy-rs/alloy) (native Rust, no ethers)
9//! - **Execution pipeline**: auth → sign → submit with dry-run safety guard
10//! - **All 8 exchange contracts**: mainnet + testnet × normal/negRisk/yield/yieldNegRisk
11//!
12//! ## Quick Start
13//!
14//! ```rust,no_run
15//! use predict_fun_sdk::{PredictApiClient, PredictExecutionClient, PredictExecConfig};
16//! use predict_fun_sdk::order::{BNB_MAINNET_CHAIN_ID};
17//!
18//! # async fn example() -> anyhow::Result<()> {
19//! // Public data (no auth needed)
20//! let client = PredictApiClient::new_mainnet("your-api-key")?;
21//! let markets = client.list_markets(&[("limit", "10".to_string())]).await?;
22//! let orderbook = client.get_market_orderbook(12345).await?;
23//!
24//! // Authenticated execution
25//! let config = PredictExecConfig {
26//! api_key: "your-api-key".into(),
27//! private_key: "0x...".into(),
28//! chain_id: BNB_MAINNET_CHAIN_ID,
29//! live_execution: false, // dry-run by default
30//! fill_or_kill: true,
31//! };
32//! let exec = PredictExecutionClient::new(config).await?;
33//! # Ok(())
34//! # }
35//! ```
36//!
37//! ## Modules
38//!
39//! - [`api`] — REST client with typed methods for all 30 endpoints
40//! - [`order`] — EIP-712 order structs, signing, and amount calculation
41//! - [`execution`] — High-level auth → sign → submit pipeline
42
43pub mod api;
44pub mod execution;
45pub mod order;
46
47// Re-export primary types at crate root for convenience
48pub use api::{PredictApiClient, RawApiResponse, PREDICT_ENDPOINTS, PREDICT_MAINNET_BASE, PREDICT_TESTNET_BASE};
49pub use execution::{PredictExecConfig, PredictExecutionClient, PredictLimitOrderRequest, PredictSubmitResult};
50pub use order::{
51 PredictOrder, PredictOrderSigner, PredictOutcome, PredictSide, PredictStrategy,
52 SignedPredictOrder, predict_exchange_address, predict_limit_order_amounts,
53 BNB_MAINNET_CHAIN_ID, BNB_TESTNET_CHAIN_ID,
54};