polymarket 0.1.0

Rust SDK for Polymarket prediction market - CLOB trading, on-chain operations, and WebSocket streaming
Documentation
#[derive(Debug, Clone, serde::Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Auth {
    pub api_key: String,
    pub secret: String,
    pub passphrase: String,
}

impl Auth {
    pub fn new(api_key: String, secret: String, passphrase: String) -> Self {
        Self {
            api_key,
            secret,
            passphrase,
        }
    }
}

impl From<&crate::clob::ApiCreds> for Auth {
    fn from(creds: &crate::clob::ApiCreds) -> Self {
        Self {
            api_key: creds.api_key.clone(),
            secret: creds.api_secret.clone(),
            passphrase: creds.api_passphrase.clone(),
        }
    }
}

impl From<crate::clob::ApiCreds> for Auth {
    fn from(creds: crate::clob::ApiCreds) -> Self {
        Self {
            api_key: creds.api_key,
            secret: creds.api_secret,
            passphrase: creds.api_passphrase,
        }
    }
}

#[derive(Debug, Clone, serde::Serialize)]
pub struct MarketSubscriptionRequest {
    pub r#type: String,
    pub assets_ids: Vec<String>,
}

impl MarketSubscriptionRequest {
    pub fn new(assets_ids: Vec<String>) -> Self {
        Self {
            r#type: "market".to_string(),
            assets_ids,
        }
    }
}

#[derive(Debug, Clone, serde::Serialize)]
pub struct UserSubscriptionRequest {
    pub r#type: String,
    pub auth: Auth,
    pub markets: Vec<String>,
}

impl UserSubscriptionRequest {
    pub fn new(auth: Auth, markets: Vec<String>) -> Self {
        Self {
            r#type: "user".to_string(),
            auth,
            markets,
        }
    }
}