use nautilus_infrastructure::sql::pg::PostgresConnectOptions;
use nautilus_model::defi::{DexType, SharedChain};
#[derive(Debug, Clone)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.blockchain")
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.adapters.blockchain")
)]
pub struct DexPoolFilters {
pub remove_pools_with_empty_erc20fields: bool,
}
impl DexPoolFilters {
#[must_use]
pub fn new(remove_pools_with_empty_erc20fields: Option<bool>) -> Self {
Self {
remove_pools_with_empty_erc20fields: remove_pools_with_empty_erc20fields
.unwrap_or(true),
}
}
}
impl Default for DexPoolFilters {
fn default() -> Self {
Self {
remove_pools_with_empty_erc20fields: true,
}
}
}
#[derive(Debug, Clone)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.blockchain")
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.adapters.blockchain")
)]
pub struct BlockchainDataClientConfig {
pub chain: SharedChain,
pub dex_ids: Vec<DexType>,
pub use_hypersync_for_live_data: bool,
pub http_rpc_url: String,
pub rpc_requests_per_second: Option<u32>,
pub multicall_calls_per_rpc_request: u32,
pub wss_rpc_url: Option<String>,
pub from_block: Option<u64>,
pub pool_filters: DexPoolFilters,
pub postgres_cache_database_config: Option<PostgresConnectOptions>,
}
impl BlockchainDataClientConfig {
#[allow(clippy::too_many_arguments)]
#[must_use]
pub fn new(
chain: SharedChain,
dex_ids: Vec<DexType>,
http_rpc_url: String,
rpc_requests_per_second: Option<u32>,
multicall_calls_per_rpc_request: Option<u32>,
wss_rpc_url: Option<String>,
use_hypersync_for_live_data: bool,
from_block: Option<u64>,
pools_filters: Option<DexPoolFilters>,
postgres_cache_database_config: Option<PostgresConnectOptions>,
) -> Self {
Self {
chain,
dex_ids,
use_hypersync_for_live_data,
http_rpc_url,
rpc_requests_per_second,
multicall_calls_per_rpc_request: multicall_calls_per_rpc_request.unwrap_or(200),
wss_rpc_url,
from_block,
pool_filters: pools_filters.unwrap_or_default(),
postgres_cache_database_config,
}
}
}