Skip to main content

strike_sdk/
config.rs

1//! Chain configuration and contract addresses.
2
3use alloy::primitives::Address;
4
5/// Contract addresses for a Strike deployment.
6#[derive(Debug, Clone)]
7pub struct ContractAddresses {
8    pub usdt: Address,
9    pub fee_model: Address,
10    pub outcome_token: Address,
11    pub vault: Address,
12    pub order_book: Address,
13    pub batch_auction: Address,
14    pub market_factory: Address,
15    pub pyth_resolver: Address,
16    pub redemption: Address,
17}
18
19/// Configuration for connecting to a Strike deployment.
20#[derive(Debug, Clone)]
21pub struct StrikeConfig {
22    /// Contract addresses.
23    pub addresses: ContractAddresses,
24    /// Chain ID.
25    pub chain_id: u64,
26    /// Default HTTP RPC URL.
27    pub rpc_url: String,
28    /// Default WebSocket URL for event subscriptions.
29    pub wss_url: String,
30    /// Indexer base URL.
31    pub indexer_url: String,
32}
33
34impl StrikeConfig {
35    /// BSC Testnet deployment (chain ID 97).
36    pub fn bsc_testnet() -> Self {
37        Self {
38            addresses: ContractAddresses {
39                usdt: "0xb242dc031998b06772C63596Bfce091c80D4c3fA"
40                    .parse()
41                    .unwrap(),
42                fee_model: "0xa044FF6E4385c3d671E47aa9E31cb91a50a3F276"
43                    .parse()
44                    .unwrap(),
45                outcome_token: "0x427CFce18cC5278f2546F88ab02c6a0749228A45"
46                    .parse()
47                    .unwrap(),
48                vault: "0xc9aA051e0BB2E0Fbb8Bfe4e4BB9ffa5Bf690023b"
49                    .parse()
50                    .unwrap(),
51                order_book: "0xB59e3d709Bd8Df10418D47E7d2CF045B02D06E32"
52                    .parse()
53                    .unwrap(),
54                batch_auction: "0x414D9da55d61835fD7Bb127978a2c49B8F09BdD5"
55                    .parse()
56                    .unwrap(),
57                market_factory: "0x6415619262033090EA0C2De913a3a6d9FC1d9DE9"
58                    .parse()
59                    .unwrap(),
60                pyth_resolver: "0xDcb807de5Ba5F3af04286a9dC1F6f3eb33066b92"
61                    .parse()
62                    .unwrap(),
63                redemption: "0x4b55f917Ab45028d4C75f3dA400B50D81209593b"
64                    .parse()
65                    .unwrap(),
66            },
67            chain_id: 97,
68            rpc_url: "https://data-seed-prebsc-1-s1.binance.org:8545".to_string(),
69            wss_url: "wss://bsc-testnet.core.chainstack.com/e602061228197d446d43e62320004d74"
70                .to_string(),
71            indexer_url: "https://strike-indexer.fly.dev".to_string(),
72        }
73    }
74
75    /// BSC Mainnet deployment (chain ID 56).
76    ///
77    /// Note: Mainnet contracts are not yet deployed. Update addresses when available.
78    pub fn bsc_mainnet() -> Self {
79        Self {
80            addresses: ContractAddresses {
81                usdt: "0x55d398326f99059fF775485246999027B3197955"
82                    .parse()
83                    .unwrap(),
84                // Placeholder addresses — update when mainnet contracts are deployed
85                fee_model: Address::ZERO,
86                outcome_token: Address::ZERO,
87                vault: Address::ZERO,
88                order_book: Address::ZERO,
89                batch_auction: Address::ZERO,
90                market_factory: Address::ZERO,
91                pyth_resolver: Address::ZERO,
92                redemption: Address::ZERO,
93            },
94            chain_id: 56,
95            rpc_url: "https://bsc-dataseed1.binance.org".to_string(),
96            wss_url: "wss://bsc-ws-node.nariox.org:443".to_string(),
97            indexer_url: String::new(),
98        }
99    }
100
101    /// Custom deployment with user-provided addresses and chain ID.
102    pub fn custom(addresses: ContractAddresses, chain_id: u64) -> Self {
103        Self {
104            addresses,
105            chain_id,
106            rpc_url: String::new(),
107            wss_url: String::new(),
108            indexer_url: String::new(),
109        }
110    }
111}