Skip to main content

hypercall_api/rfq/
qp_ws_state.rs

1use crate::boundary::market_inputs::InstrumentsCacheReader;
2use crate::rfq::indicative_quote_cache::IndicativeQuoteCache;
3use crate::rfq::qp_sessions::QpSessionManager;
4use crate::rfq::quote_provider_cache::QuoteProviderCache;
5use crate::rfq::rfq_manager::RfqManager;
6use hypercall_runtime_api::NonceCheckRequest;
7use hypercall_types::ws_protocol::{WsIndicativeMarketData, WsMessage, WsRfqQuotes};
8use std::sync::Arc;
9use tokio::sync::mpsc;
10
11/// Publishes RFQ WebSocket updates to taker-facing subscribers.
12pub trait RfqWebsocketPublisher: Send + Sync {
13    fn publish_indicative_market_data(&self, update: WsIndicativeMarketData);
14    fn publish_rfq_quotes(&self, quotes: WsRfqQuotes);
15    fn publish_to_channel(&self, channel: &str, message: WsMessage);
16}
17
18/// State shared with the QP WebSocket handler.
19#[derive(Clone)]
20pub struct QpWsState {
21    pub qp_cache: Arc<QuoteProviderCache>,
22    pub indicative_cache: Arc<IndicativeQuoteCache>,
23    pub instruments_cache: Arc<dyn InstrumentsCacheReader>,
24    pub session_manager: Arc<QpSessionManager>,
25    pub rfq_manager: Option<Arc<RfqManager>>,
26    /// Engine-level nonce check channel. QP handshakes dispatch NonceAdvance
27    /// commands through the engine to advance the per-wallet nonce watermark.
28    pub nonce_check_sender: mpsc::Sender<NonceCheckRequest>,
29    /// Push RFQ quotes to taker clients in real-time instead of relying on polling.
30    pub pubsub: Option<Arc<dyn RfqWebsocketPublisher>>,
31    pub signing_chain_id: u64,
32    /// Shared secret that allows the edge gateway to resume a previously
33    /// authenticated QP session without advancing the public nonce again.
34    pub gateway_resume_token: Option<String>,
35}