polymarket_client/
environment.rs1use polymarket_types::EvmAddress;
2
3#[derive(Clone, Debug)]
5pub struct Environment {
6 pub name: &'static str,
7 pub chain_id: u64,
8 pub rpc: &'static str,
9 pub clob: &'static str,
10 pub gamma: &'static str,
11 pub data: &'static str,
12 pub relayer: &'static str,
13 pub rfq: &'static str,
14 pub clob_ws: &'static str,
15 pub rtds_ws: &'static str,
16 pub sports_ws: &'static str,
17 pub collateral_token: EvmAddress,
18}
19
20impl Environment {
21 #[must_use]
23 pub fn production() -> Self {
24 Self {
25 name: "production",
26 chain_id: 137,
27 rpc: "https://polygon.drpc.org",
28 clob: "https://clob.polymarket.com",
29 gamma: "https://gamma-api.polymarket.com",
30 data: "https://data-api.polymarket.com",
31 relayer: "https://relayer-v2.polymarket.com",
32 rfq: "https://combos-rfq-api.polymarket.com",
33 clob_ws: "wss://ws-subscriptions-clob.polymarket.com",
34 rtds_ws: "wss://ws-live-data.polymarket.com",
35 sports_ws: "wss://sports-api.polymarket.com/ws",
36 collateral_token: EvmAddress::from_str("0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB")
37 .expect("valid production collateral token address"),
38 }
39 }
40
41 #[must_use]
43 pub fn preproduction() -> Self {
44 Self {
45 name: "preproduction",
46 clob: "https://clob-staging.polymarket.com",
47 gamma: "https://gamma-staging.polymarket.com",
48 data: "https://data-staging.polymarket.com",
49 relayer: "https://relayer-staging.polymarket.com",
50 ..Self::production()
51 }
52 }
53}
54
55use std::str::FromStr;
56
57#[cfg(test)]
58mod tests {
59 use super::*;
60
61 #[test]
62 fn production_urls_are_https() {
63 let env = Environment::production();
64 assert!(env.gamma.starts_with("https://"));
65 assert!(env.clob.starts_with("https://"));
66 }
67}