nautilus_blockchain/
config.rs1use std::any::Any;
17
18use nautilus_infrastructure::sql::pg::PostgresConnectOptions;
19use nautilus_model::{
20 defi::{Chain, DexType, SharedChain},
21 identifiers::{AccountId, TraderId},
22};
23use nautilus_system::ClientConfig;
24
25#[derive(Debug, Clone)]
27#[cfg_attr(
28 feature = "python",
29 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.blockchain")
30)]
31#[cfg_attr(
32 feature = "python",
33 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.adapters.blockchain")
34)]
35pub struct DexPoolFilters {
36 pub remove_pools_with_empty_erc20fields: bool,
38}
39
40impl DexPoolFilters {
41 #[must_use]
43 pub fn new(remove_pools_with_empty_erc20fields: Option<bool>) -> Self {
44 Self {
45 remove_pools_with_empty_erc20fields: remove_pools_with_empty_erc20fields
46 .unwrap_or(true),
47 }
48 }
49}
50
51impl Default for DexPoolFilters {
52 fn default() -> Self {
53 Self {
54 remove_pools_with_empty_erc20fields: true,
55 }
56 }
57}
58
59#[derive(Debug, Clone)]
61#[cfg_attr(
62 feature = "python",
63 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.blockchain")
64)]
65#[cfg_attr(
66 feature = "python",
67 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.adapters.blockchain")
68)]
69pub struct BlockchainDataClientConfig {
70 pub chain: SharedChain,
72 pub dex_ids: Vec<DexType>,
74 pub use_hypersync_for_live_data: bool,
76 pub http_rpc_url: String,
78 pub rpc_requests_per_second: Option<u32>,
80 pub multicall_calls_per_rpc_request: u32,
82 pub wss_rpc_url: Option<String>,
84 pub http_proxy_url: Option<String>,
86 pub ws_proxy_url: Option<String>,
91 pub from_block: Option<u64>,
93 pub pool_filters: DexPoolFilters,
95 pub postgres_cache_database_config: Option<PostgresConnectOptions>,
97}
98
99impl BlockchainDataClientConfig {
100 #[allow(clippy::too_many_arguments)]
102 #[must_use]
103 pub fn new(
104 chain: SharedChain,
105 dex_ids: Vec<DexType>,
106 http_rpc_url: String,
107 rpc_requests_per_second: Option<u32>,
108 multicall_calls_per_rpc_request: Option<u32>,
109 wss_rpc_url: Option<String>,
110 use_hypersync_for_live_data: bool,
111 from_block: Option<u64>,
112 pools_filters: Option<DexPoolFilters>,
113 postgres_cache_database_config: Option<PostgresConnectOptions>,
114 ) -> Self {
115 Self {
116 chain,
117 dex_ids,
118 use_hypersync_for_live_data,
119 http_rpc_url,
120 rpc_requests_per_second,
121 multicall_calls_per_rpc_request: multicall_calls_per_rpc_request.unwrap_or(200),
122 wss_rpc_url,
123 http_proxy_url: None,
124 ws_proxy_url: None,
125 from_block,
126 pool_filters: pools_filters.unwrap_or_default(),
127 postgres_cache_database_config,
128 }
129 }
130}
131
132#[derive(Debug, Clone)]
133pub struct BlockchainExecutionClientConfig {
134 pub trader_id: TraderId,
136 pub client_id: AccountId,
138 pub chain: Chain,
140 pub wallet_address: String,
142 pub tokens: Option<Vec<String>>,
144 pub http_rpc_url: String,
146 pub rpc_requests_per_second: Option<u32>,
148}
149
150impl BlockchainExecutionClientConfig {
151 pub fn new(
152 trader_id: TraderId,
153 client_id: AccountId,
154 chain: Chain,
155 wallet_address: String,
156 tokens: Option<Vec<String>>,
157 http_rpc_url: String,
158 rpc_requests_per_second: Option<u32>,
159 ) -> Self {
160 Self {
161 trader_id,
162 client_id,
163 chain,
164 wallet_address,
165 tokens,
166 http_rpc_url,
167 rpc_requests_per_second,
168 }
169 }
170}
171
172impl ClientConfig for BlockchainExecutionClientConfig {
173 fn as_any(&self) -> &dyn Any {
174 self
175 }
176}