nautilus_blockchain/python/
config.rs1use std::sync::Arc;
19
20use nautilus_infrastructure::sql::pg::PostgresConnectOptions;
21use nautilus_model::defi::{Chain, DexType};
22use pyo3::prelude::*;
23
24use crate::config::{BlockchainDataClientConfig, DexPoolFilters};
25
26#[pymethods]
27impl DexPoolFilters {
28 #[new]
30 #[must_use]
31 pub fn py_new(remove_pools_with_empty_erc20_fields: Option<bool>) -> Self {
32 Self::new(remove_pools_with_empty_erc20_fields)
33 }
34}
35
36#[pymethods]
37impl BlockchainDataClientConfig {
38 #[new]
40 #[allow(clippy::too_many_arguments)]
41 #[pyo3(signature = (chain, dex_ids, http_rpc_url, rpc_requests_per_second=None, multicall_calls_per_rpc_request=None, wss_rpc_url=None, use_hypersync_for_live_data=true, from_block=None, pool_filters=None, postgres_cache_database_config=None))]
42 fn py_new(
43 chain: &Chain,
44 dex_ids: Vec<DexType>,
45 http_rpc_url: String,
46 rpc_requests_per_second: Option<u32>,
47 multicall_calls_per_rpc_request: Option<u32>,
48 wss_rpc_url: Option<String>,
49 use_hypersync_for_live_data: bool,
50 from_block: Option<u64>,
51 pool_filters: Option<DexPoolFilters>,
52 postgres_cache_database_config: Option<PostgresConnectOptions>,
53 ) -> Self {
54 Self::new(
55 Arc::new(chain.clone()),
56 dex_ids,
57 http_rpc_url,
58 rpc_requests_per_second,
59 multicall_calls_per_rpc_request,
60 wss_rpc_url,
61 use_hypersync_for_live_data,
62 from_block,
63 pool_filters,
64 postgres_cache_database_config,
65 )
66 }
67
68 #[getter]
70 fn chain(&self) -> Chain {
71 (*self.chain).clone()
72 }
73
74 #[getter]
76 fn http_rpc_url(&self) -> String {
77 self.http_rpc_url.clone()
78 }
79
80 #[getter]
82 fn wss_rpc_url(&self) -> Option<String> {
83 self.wss_rpc_url.clone()
84 }
85
86 #[getter]
88 const fn rpc_requests_per_second(&self) -> Option<u32> {
89 self.rpc_requests_per_second
90 }
91
92 #[getter]
94 const fn use_hypersync_for_live_data(&self) -> bool {
95 self.use_hypersync_for_live_data
96 }
97
98 #[getter]
100 #[allow(clippy::wrong_self_convention)]
101 const fn from_block(&self) -> Option<u64> {
102 self.from_block
103 }
104
105 fn __repr__(&self) -> String {
107 format!(
108 "BlockchainDataClientConfig(chain={:?}, http_rpc_url={}, wss_rpc_url={:?}, use_hypersync_for_live_data={}, from_block={:?})",
109 self.chain.name,
110 self.http_rpc_url,
111 self.wss_rpc_url,
112 self.use_hypersync_for_live_data,
113 self.from_block
114 )
115 }
116}