Skip to content

Commit

Permalink
Merge pull request #117 from propeller-heads/zz/uniswap_v4/implement-…
Browse files Browse the repository at this point in the history
…hook-filter

feat(uniswap_v4): add filter for pools with hooks
  • Loading branch information
zizou0x authored Dec 20, 2024
2 parents d97d174 + dd668e2 commit 24e5fd2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/evm/protocol/filters.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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
}

0 comments on commit 24e5fd2

Please sign in to comment.