From dd668e2c84248982d77770a2cb42413f27f6dab9 Mon Sep 17 00:00:00 2001 From: zizou <111426680+flopell@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:09:20 +0100 Subject: [PATCH] feat(uniswap_v4): add filter for pools with hooks --- src/evm/protocol/filters.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/evm/protocol/filters.rs b/src/evm/protocol/filters.rs index 947d97a9..7b751bf5 100644 --- a/src/evm/protocol/filters.rs +++ b/src/evm/protocol/filters.rs @@ -1,12 +1,14 @@ use std::collections::HashSet; use num_bigint::BigInt; -use tracing::info; +use tracing::{debug, info}; use tycho_client::feed::synchronizer::ComponentWithState; use crate::evm::protocol::vm::utils::json_deserialize_be_bigint_list; const ZERO_ADDRESS: &str = "0x0000000000000000000000000000000000000000"; +const ZERO_ADDRESS_ARR: [u8; 20] = [0u8; 20]; + pub fn balancer_pool_filter(component: &ComponentWithState) -> bool { // Check for rate_providers in static_attributes info!("Checking Balancer pool {}", component.component.id); @@ -123,3 +125,18 @@ pub fn curve_pool_filter(component: &ComponentWithState) -> bool { } true } + +/// Filters out pool that have hooks in Uniswap V4 +pub fn uniswap_v4_pool_with_hook_filter(component: &ComponentWithState) -> bool { + if let Some(hooks) = component + .component + .static_attributes + .get("hooks") + { + if hooks.to_vec() != ZERO_ADDRESS_ARR { + debug!("Filtering out UniswapV4 pool {} because it has hooks", component.component.id); + return false; + } + } + true +}