polyte_clob/ws/
subscription.rs1use serde::{Deserialize, Serialize};
4
5use super::auth::ApiCredentials;
6
7pub const WS_MARKET_URL: &str = "wss://ws-subscriptions-clob.polymarket.com/ws/market";
9
10pub const WS_USER_URL: &str = "wss://ws-subscriptions-clob.polymarket.com/ws/user";
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
15#[serde(rename_all = "lowercase")]
16pub enum ChannelType {
17 Market,
19 User,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct MarketSubscription {
26 pub assets_ids: Vec<String>,
28 #[serde(rename = "type")]
30 pub channel_type: ChannelType,
31}
32
33impl MarketSubscription {
34 pub fn new(assets_ids: Vec<String>) -> Self {
36 Self {
37 assets_ids,
38 channel_type: ChannelType::Market,
39 }
40 }
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct UserSubscription {
46 pub markets: Vec<String>,
48 pub auth: ApiCredentials,
50 #[serde(rename = "type")]
52 pub channel_type: ChannelType,
53}
54
55impl UserSubscription {
56 pub fn new(markets: Vec<String>, credentials: ApiCredentials) -> Self {
58 Self {
59 markets,
60 auth: credentials,
61 channel_type: ChannelType::User,
62 }
63 }
64}