Skip to content

Commit

Permalink
fix: improve load_all_tokens arg names
Browse files Browse the repository at this point in the history
  • Loading branch information
louise-poole committed Feb 7, 2025
1 parent b1a76a8 commit cfc4f51
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,31 @@ pub fn hexstring_to_vec(hexstring: &str) -> Result<Vec<u8>, SimulationError> {
/// * `no_tls` - Whether to use HTTP instead of HTTPS.
/// * `auth_key` - The API key to use for authentication.
/// * `chain` - The chain to load tokens from.
/// * `quality_filter` - The minimum quality of tokens to load. Defaults to 100 if not provided.
/// * `activity_filter` - The max number of days since the token was last traded. Defaults are chain
/// specific and applied if not provided.
/// * `min_quality` - The minimum quality of tokens to load. Defaults to 100 if not provided.
/// * `max_days_since_last_trade` - The max number of days since the token was last traded. Defaults
/// are chain specific and applied if not provided.
pub async fn load_all_tokens(
tycho_url: &str,
no_tls: bool,
auth_key: Option<&str>,
chain: Chain,
quality_filter: Option<i32>,
activity_filter: Option<u64>,
min_quality: Option<i32>,
max_days_since_last_trade: Option<u64>,
) -> HashMap<Bytes, Token> {
info!("Loading tokens from Tycho...");
let rpc_url =
if no_tls { format!("http://{tycho_url}") } else { format!("https://{tycho_url}") };
let rpc_client = HttpRPCClient::new(rpc_url.as_str(), auth_key).unwrap();

// Chain specific defaults for special case chains. Otherwise defaults to 42 days.
let default_activity_filter = HashMap::from([(Chain::Base, 10_u64)]);
let default_min_days = HashMap::from([(Chain::Base, 10_u64)]);

#[allow(clippy::mutable_key_type)]
rpc_client
.get_all_tokens(
chain,
quality_filter.or(Some(100)),
activity_filter.or(default_activity_filter
min_quality.or(Some(100)),
max_days_since_last_trade.or(default_min_days
.get(&chain)
.or(Some(&42))
.copied()),
Expand Down

0 comments on commit cfc4f51

Please sign in to comment.