Real-Time Events

Event Stream

Subscribe to on-chain events via WebSocket:

use strike_sdk::prelude::*;

let client = StrikeClient::new(StrikeConfig::bsc_testnet()).build()?;

let mut events = client.events().await?;

while let Some(event) = events.next().await {
    match event {
        StrikeEvent::MarketCreated { market_id, strike_price, expiry_time, .. } => {
            println!("new market {market_id} | strike: {strike_price} | expiry: {expiry_time}");
        }
        StrikeEvent::BatchCleared { market_id, batch_id, clearing_tick, matched_lots } => {
            println!("batch cleared | market: {market_id} | tick: {clearing_tick} | matched: {matched_lots}");
        }
        StrikeEvent::OrderSettled { order_id, filled_lots, .. } => {
            println!("order settled | {order_id} | filled: {filled_lots}");
        }
        StrikeEvent::GtcAutoCancelled { order_id, .. } => {
            println!("GTC auto-cancelled | {order_id}");
        }
        _ => {}
    }
}

No wallet required — event streaming is read-only.

Event Types

StrikeEvent is an enum with the following variants:

MarketCreated

Emitted when a new market is created via MarketFactory.

BatchCleared

Emitted when a batch auction clears. clearing_tick is the uniform price all fills settle at. matched_lots is the total volume matched.

OrderSettled

Emitted per order during batch settlement. Tells you how many lots were filled.

GtcAutoCancelled

Emitted when a GTC order is auto-cancelled (e.g., market halted or deactivated).

OrderPlaced / OrderCancelled

Emitted on order placement and cancellation. Available via historical scanning (see below), not via the live WSS stream.

Auto-Reconnect

EventStream handles WSS disconnections automatically. On connection loss, it waits 5 seconds and reconnects. Events emitted during the reconnection gap are missed — use historical scanning to recover them.

Historical Scanning

For startup recovery (e.g., a bot restarting and needing to know its open orders), use scan_orders():

This scans OrderPlaced and OrderCancelled events from from_block to the latest block, returning only orders that haven't been cancelled.

Typical Bot Pattern

A common pattern combines the event stream with historical recovery:

Last updated