use std::{collections::HashSet, time::Duration};
use tycho_simulation::tycho_common::models::Chain;
pub(crate) mod events;
pub(crate) mod gas;
pub mod market_data;
pub mod protocol_registry;
pub mod tycho_feed;
#[derive(Debug, Clone)]
pub(crate) struct TychoFeedConfig {
pub(crate) tycho_url: String,
pub(crate) chain: Chain,
pub(crate) tycho_api_key: Option<String>,
pub(crate) use_tls: bool,
pub(crate) protocols: Vec<String>,
pub(crate) min_tvl: f64,
pub(crate) min_token_quality: i32,
pub(crate) tvl_buffer_ratio: f64,
pub(crate) gas_refresh_interval: Duration,
pub(crate) reconnect_delay: Duration,
pub(crate) traded_n_days_ago: Option<u64>,
pub(crate) blocklisted_components: HashSet<String>,
}
impl TychoFeedConfig {
pub(crate) fn new(
tycho_url: String,
chain: Chain,
tycho_api_key: Option<String>,
use_tls: bool,
protocols: Vec<String>,
min_tvl: f64,
) -> Self {
Self {
tycho_url,
chain,
tycho_api_key,
use_tls,
protocols,
min_tvl,
min_token_quality: 100,
traded_n_days_ago: None,
tvl_buffer_ratio: 1.1,
gas_refresh_interval: Duration::from_secs(30),
reconnect_delay: Duration::from_secs(5),
blocklisted_components: HashSet::new(),
}
}
pub(crate) fn tvl_buffer_ratio(mut self, tvl_buffer_ratio: f64) -> Self {
self.tvl_buffer_ratio = tvl_buffer_ratio;
self
}
pub(crate) fn gas_refresh_interval(mut self, gas_refresh_interval: Duration) -> Self {
self.gas_refresh_interval = gas_refresh_interval;
self
}
pub(crate) fn reconnect_delay(mut self, reconnect_delay: Duration) -> Self {
self.reconnect_delay = reconnect_delay;
self
}
pub(crate) fn min_token_quality(mut self, min_token_quality: i32) -> Self {
self.min_token_quality = min_token_quality;
self
}
pub(crate) fn traded_n_days_ago(mut self, days: u64) -> Self {
self.traded_n_days_ago = Some(days);
self
}
pub(crate) fn blocklisted_components(mut self, components: HashSet<String>) -> Self {
self.blocklisted_components = components;
self
}
}
#[derive(Debug, thiserror::Error)]
pub(crate) enum DataFeedError {
#[error("gas price fetcher error: {0}")]
GasPriceFetcherError(String),
#[error("configuration error: {0}")]
Config(String),
#[error("stream error: {0}")]
StreamError(String),
#[error("event send error: {0}")]
EventChannelError(String),
}