crypto_ws_client/clients/gate/
gate_swap.rs1use async_trait::async_trait;
2
3use super::utils::{GateCommandTranslator, GateMessageHandler, EXCHANGE_NAME};
4use crate::{
5 clients::common_traits::{
6 Candlestick, Level3OrderBook, OrderBook, OrderBookTopK, Ticker, Trade, BBO,
7 },
8 common::{command_translator::CommandTranslator, ws_client_internal::WSClientInternal},
9 WSClient,
10};
11
12const INVERSE_SWAP_WEBSOCKET_URL: &str = "wss://fx-ws.gateio.ws/v4/ws/btc";
13const LINEAR_SWAP_WEBSOCKET_URL: &str = "wss://fx-ws.gateio.ws/v4/ws/usdt";
14
15pub struct GateInverseSwapWSClient {
20 client: WSClientInternal<GateMessageHandler<'F'>>,
21 translator: GateCommandTranslator<'F'>,
22}
23
24pub struct GateLinearSwapWSClient {
29 client: WSClientInternal<GateMessageHandler<'F'>>,
30 translator: GateCommandTranslator<'F'>,
31}
32
33impl_new_constructor!(
34 GateInverseSwapWSClient,
35 EXCHANGE_NAME,
36 INVERSE_SWAP_WEBSOCKET_URL,
37 GateMessageHandler::<'F'> {},
38 GateCommandTranslator::<'F'> {}
39);
40
41impl_new_constructor!(
42 GateLinearSwapWSClient,
43 EXCHANGE_NAME,
44 LINEAR_SWAP_WEBSOCKET_URL,
45 GateMessageHandler::<'F'> {},
46 GateCommandTranslator::<'F'> {}
47);
48
49impl_trait!(Trade, GateInverseSwapWSClient, subscribe_trade, "trades");
50#[rustfmt::skip]
51impl_trait!(OrderBook, GateInverseSwapWSClient, subscribe_orderbook, "order_book_update");
52#[rustfmt::skip]
53impl_trait!(OrderBookTopK, GateInverseSwapWSClient, subscribe_orderbook_topk, "order_book");
54impl_trait!(BBO, GateInverseSwapWSClient, subscribe_bbo, "book_ticker");
55impl_trait!(Ticker, GateInverseSwapWSClient, subscribe_ticker, "tickers");
56
57impl_trait!(Trade, GateLinearSwapWSClient, subscribe_trade, "trades");
58#[rustfmt::skip]
59impl_trait!(OrderBook, GateLinearSwapWSClient, subscribe_orderbook, "order_book_update");
60#[rustfmt::skip]
61impl_trait!(OrderBookTopK, GateLinearSwapWSClient, subscribe_orderbook_topk, "order_book");
62impl_trait!(BBO, GateLinearSwapWSClient, subscribe_bbo, "book_ticker");
63impl_trait!(Ticker, GateLinearSwapWSClient, subscribe_ticker, "tickers");
64
65impl_candlestick!(GateInverseSwapWSClient);
66impl_candlestick!(GateLinearSwapWSClient);
67
68panic_l3_orderbook!(GateInverseSwapWSClient);
69panic_l3_orderbook!(GateLinearSwapWSClient);
70
71impl_ws_client_trait!(GateInverseSwapWSClient);
72impl_ws_client_trait!(GateLinearSwapWSClient);