polymarket 0.1.0

Rust SDK for Polymarket prediction market - CLOB trading, on-chain operations, and WebSocket streaming
Documentation
use rand::{rng, Rng};
use std::time::{SystemTime, UNIX_EPOCH};

/// Generate a unique salt value combining timestamp and randomness
///
/// Format: [timestamp_secs (upper 48 bits)] + [16-bit random (lower 16 bits)]
/// This ensures uniqueness while keeping values small and safe for JavaScript
pub(crate) fn generate_salt() -> u64 {
    let mut rng = rng();
    let timestamp_secs = SystemTime::now()
        .duration_since(UNIX_EPOCH)
        .unwrap()
        .as_secs();

    // Generate 16-bit random number (0-65535)
    let random: u16 = rng.random();

    // Combine: shift timestamp left by 16 bits, OR with random
    (timestamp_secs << 16) | (random as u64)
}