nautilus_blockchain/
config.rs1use nautilus_infrastructure::sql::pg::PostgresConnectOptions;
17use nautilus_model::defi::{DexType, SharedChain};
18
19#[derive(Debug, Clone)]
21#[cfg_attr(
22 feature = "python",
23 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.blockchain")
24)]
25#[cfg_attr(
26 feature = "python",
27 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.adapters.blockchain")
28)]
29pub struct DexPoolFilters {
30 pub remove_pools_with_empty_erc20fields: bool,
32}
33
34impl DexPoolFilters {
35 #[must_use]
37 pub fn new(remove_pools_with_empty_erc20fields: Option<bool>) -> Self {
38 Self {
39 remove_pools_with_empty_erc20fields: remove_pools_with_empty_erc20fields
40 .unwrap_or(true),
41 }
42 }
43}
44
45impl Default for DexPoolFilters {
46 fn default() -> Self {
47 Self {
48 remove_pools_with_empty_erc20fields: true,
49 }
50 }
51}
52
53#[derive(Debug, Clone)]
55#[cfg_attr(
56 feature = "python",
57 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.blockchain")
58)]
59#[cfg_attr(
60 feature = "python",
61 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.adapters.blockchain")
62)]
63pub struct BlockchainDataClientConfig {
64 pub chain: SharedChain,
66 pub dex_ids: Vec<DexType>,
68 pub use_hypersync_for_live_data: bool,
70 pub http_rpc_url: String,
72 pub rpc_requests_per_second: Option<u32>,
74 pub multicall_calls_per_rpc_request: u32,
76 pub wss_rpc_url: Option<String>,
78 pub from_block: Option<u64>,
80 pub pool_filters: DexPoolFilters,
82 pub postgres_cache_database_config: Option<PostgresConnectOptions>,
84}
85
86impl BlockchainDataClientConfig {
87 #[allow(clippy::too_many_arguments)]
89 #[must_use]
90 pub fn new(
91 chain: SharedChain,
92 dex_ids: Vec<DexType>,
93 http_rpc_url: String,
94 rpc_requests_per_second: Option<u32>,
95 multicall_calls_per_rpc_request: Option<u32>,
96 wss_rpc_url: Option<String>,
97 use_hypersync_for_live_data: bool,
98 from_block: Option<u64>,
99 pools_filters: Option<DexPoolFilters>,
100 postgres_cache_database_config: Option<PostgresConnectOptions>,
101 ) -> Self {
102 Self {
103 chain,
104 dex_ids,
105 use_hypersync_for_live_data,
106 http_rpc_url,
107 rpc_requests_per_second,
108 multicall_calls_per_rpc_request: multicall_calls_per_rpc_request.unwrap_or(100),
109 wss_rpc_url,
110 from_block,
111 pool_filters: pools_filters.unwrap_or_default(),
112 postgres_cache_database_config,
113 }
114 }
115}