diff --git a/crates/orderbook/src/main.rs b/crates/orderbook/src/main.rs index 56e7f1488f..e1bdbad12c 100644 --- a/crates/orderbook/src/main.rs +++ b/crates/orderbook/src/main.rs @@ -31,7 +31,7 @@ use shared::{ instrumented::InstrumentedBadTokenDetectorExt, list_based::{ListBasedDetector, UnknownTokenStrategy}, trace_call::{ - BalancerVaultFinder, TokenOwnerFinding, TraceCallDetector, + BalancerVaultFinder, FeeValues, TokenOwnerFinding, TraceCallDetector, UniswapLikePairProviderFinder, UniswapV3Finder, }, }, @@ -244,6 +244,9 @@ struct Arguments { /// will not have any further effect. #[clap(long, env, default_value = "2")] fast_price_estimation_results_required: NonZeroUsize, + + #[clap(long, env, default_value = "static", arg_enum)] + token_detector_fee_values: FeeValues, } pub async fn database_metrics(metrics: Arc, database: Postgres) -> ! { @@ -410,6 +413,7 @@ async fn main() { contract, base_tokens.tokens().iter().copied().collect(), current_block, + args.token_detector_fee_values, ) .await .expect("create uniswapv3 finder"), diff --git a/crates/shared/src/bad_token/trace_call.rs b/crates/shared/src/bad_token/trace_call.rs index 481cdebb81..4528dc2922 100644 --- a/crates/shared/src/bad_token/trace_call.rs +++ b/crates/shared/src/bad_token/trace_call.rs @@ -59,15 +59,28 @@ pub struct UniswapV3Finder { fee_values: Vec, } +#[derive(Debug, Clone, Copy, clap::ArgEnum)] +pub enum FeeValues { + /// Use hardcoded list + Static, + /// Fetch on creation based on events queried from node. + /// Some nodes struggle with the request and take a long time to respond leading to timeouts. + Dynamic, +} + impl UniswapV3Finder { pub async fn new( factory: IUniswapV3Factory, base_tokens: Vec, current_block: u64, + fee_values: FeeValues, ) -> Result { - // We fetch these once at start up because we don't expect them to change often. - // Alternatively could use a time based cache. - let fee_values = Self::fee_values(&factory, current_block).await?; + let fee_values = match fee_values { + FeeValues::Static => vec![500, 3000, 10000, 100], + // We fetch these once at start up because we don't expect them to change often. + // Alternatively could use a time based cache. + FeeValues::Dynamic => Self::fee_values(&factory, current_block).await?, + }; tracing::debug!(?fee_values); Ok(Self { factory, @@ -679,7 +692,7 @@ mod tests { let settlement = contracts::GPv2Settlement::deployed(&web3).await.unwrap(); let factory = IUniswapV3Factory::deployed(&web3).await.unwrap(); let current_block = web3.eth().block_number().await.unwrap().as_u64(); - let univ3 = UniswapV3Finder::new(factory, base_tokens, current_block) + let univ3 = UniswapV3Finder::new(factory, base_tokens, current_block, FeeValues::Dynamic) .await .unwrap(); let token_cache = TraceCallDetector {