Skip to content

Conversation

@didobagi
Copy link

@didobagi didobagi commented Oct 17, 2025

Summary

Adds a native Rust WebSocket client for Switchboard Surge real-time price feeds as an optional feature.

Changes

New surge feature providing:

  • WebSocket client with builder pattern API
  • Real-time price streaming via bundle-based subscriptions
  • Automatic reconnection with exponential backoff
  • Support for oracle and crossbar subscription modes
  • Proper bundle ID tracking for unsubscribe operations

Implementation details:

  • New src/surge/ module with client, protocol, connection handling, and configuration
  • Three usage examples: quickstart, subscription management, error handling
  • 49 unit tests covering protocol and connection logic

Testing

All tests pass with and without the surge feature enabled:

  • cargo test --features surge - 49 tests
  • cargo test - 9 base SDK tests
  • cargo test --all-features - 58 total tests

Verified against production Surge gateway.

Dependencies

Added thiserror to base dependencies and tokio-tungstenite as optional dependency. The surge feature reuses existing optional dependencies (tokio, futures, reqwest, serde_json).

Compatibility

Fully backward compatible. The surge feature is opt-in and doesn't modify existing SDK functionality. Integrates with the 0.10.0 Cargo.toml structure supporting both Solana v2 and v3.

- Real-time price feeds with auto-reconnection
- Bundle-based subscriptions with oracle response data
- Configurable timeouts and exponential backoff
- Opt-in surge feature flag
- Examples: quickstart, reconnection, unsubscribe
- 40+ unit tests with protocol parsing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant