Skip to main content

Module qp_client

Module qp_client 

Source
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§

IndicativeQuote
A single indicative quote for an instrument.
NoopCallbacks
QpClientConfig
Configuration for the QP WebSocket client.
ResponseLeg
A leg in a QP’s firm quote response.
RfqLeg
A leg in an RFQ request sent to QPs.

Enums§

ClientOutbound
Messages sent by a QP client.
QpDisconnectReason
High-level reason the QP client disconnected from the server.
QpWriteFailure
Reason a WebSocket write failed.
QpWriteOperation
WebSocket write operation that failed.
RfqDropReason
Why the scoped runtime dropped an RFQ response instead of sending it. Surfaced through QpClientCallbacks::on_rfq_response_dropped alongside the message itself, so the caller can attribute the loss to the rfq_id it belongs to.
ServerInbound
Messages sent to a QP client.

Traits§

QpClientCallbacks
Callbacks for observability hooks. Implement this to wire in your own metrics framework (Prometheus, StatsD, etc.). The default NoopCallbacks does nothing.

Functions§

run_qp_client
Run the QP WebSocket client with auto-reconnect.