Expand description
Quote Provider (QP) WebSocket client for the /ws/quotes endpoint.
Connects to the Hypercall API server as a registered Quote Provider, authenticates via EIP-712 signature, and runs a bidirectional message loop with auto-reconnect.
§Usage
use std::sync::Arc;
use tokio::sync::mpsc;
use hypercall_client::{HypercallWallet, qp_client};
let wallet = Arc::new(HypercallWallet::from_private_key("0x...", 999)?);
let (outbound_tx, outbound_rx) = mpsc::channel(256);
let (inbound_tx, mut inbound_rx) = mpsc::channel(256);
// Spawn the auto-reconnecting QP client
let config = qp_client::QpClientConfig::new("https://api.hypercall.xyz".into());
tokio::spawn(qp_client::run_qp_client(
config,
wallet,
outbound_rx,
inbound_tx,
Arc::new(qp_client::NoopCallbacks),
));
// Handle inbound RFQ requests
while let Some(msg) = inbound_rx.recv().await {
match msg {
qp_client::ServerInbound::RfqRequest { rfq_id, legs, .. } => {
println!("RFQ {rfq_id}: {} legs", legs.len());
}
_ => {}
}
}Structs§
- Indicative
Quote - A single indicative quote for an instrument.
- Noop
Callbacks - QpClient
Config - Configuration for the QP WebSocket client.
- Response
Leg - A leg in a QP’s firm quote response.
- RfqLeg
- A leg in an RFQ request sent to QPs.
Enums§
- Client
Outbound - Messages sent by a QP client.
- QpDisconnect
Reason - High-level reason the QP client disconnected from the server.
- QpWrite
Failure - Reason a WebSocket write failed.
- QpWrite
Operation - WebSocket write operation that failed.
- RfqDrop
Reason - Why the scoped runtime dropped an RFQ response instead of sending it.
Surfaced through
QpClientCallbacks::on_rfq_response_droppedalongside the message itself, so the caller can attribute the loss to therfq_idit belongs to. - Server
Inbound - Messages sent to a QP client.
Traits§
- QpClient
Callbacks - Callbacks for observability hooks. Implement this to wire in your own
metrics framework (Prometheus, StatsD, etc.). The default
NoopCallbacksdoes nothing.
Functions§
- run_
qp_ client - Run the QP WebSocket client with auto-reconnect.