From 1bd5e39956a27a50b5d602dcd01c3c6991605915 Mon Sep 17 00:00:00 2001 From: Florian Pellissier <111426680+flopell@users.noreply.github.com> Date: Wed, 10 Jul 2024 14:46:11 +0200 Subject: [PATCH] feat: Add Balancer vault indexing --- substreams/ethereum-balancer/src/modules.rs | 3 ++- substreams/ethereum-balancer/src/pool_factories.rs | 7 +++++++ substreams/ethereum-balancer/substreams.yaml | 10 +++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/substreams/ethereum-balancer/src/modules.rs b/substreams/ethereum-balancer/src/modules.rs index c9b66a5..90297a1 100644 --- a/substreams/ethereum-balancer/src/modules.rs +++ b/substreams/ethereum-balancer/src/modules.rs @@ -202,7 +202,8 @@ pub fn map_protocol_changes( |addr| { components_store .get_last(format!("pool:0x{0}", hex::encode(addr))) - .is_some() + .is_some() || + addr.eq(VAULT_ADDRESS) }, &mut transaction_changes, ); diff --git a/substreams/ethereum-balancer/src/pool_factories.rs b/substreams/ethereum-balancer/src/pool_factories.rs index 8734a51..9cb4910 100644 --- a/substreams/ethereum-balancer/src/pool_factories.rs +++ b/substreams/ethereum-balancer/src/pool_factories.rs @@ -70,6 +70,7 @@ pub fn address_map( Some( ProtocolComponent::at_contract(&pool_created.pool, &(tx.into())) + .with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()]) .with_tokens(&create_call.tokens) .with_attributes(&[ ("pool_type", "WeightedPoolFactory".as_bytes()), @@ -96,6 +97,7 @@ pub fn address_map( Some( ProtocolComponent::at_contract(&pool_created.pool, &(tx.into())) + .with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()]) .with_tokens(&create_call.tokens) .with_attributes(&[ ("pool_type", "ComposableStablePoolFactory".as_bytes()), @@ -116,6 +118,7 @@ pub fn address_map( Some( ProtocolComponent::at_contract(&pool_created.pool, &(tx.into())) + .with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()]) .with_tokens(&[create_call.main_token, create_call.wrapped_token]) .with_attributes(&[ ("pool_type", "ERC4626LinearPoolFactory".as_bytes()), @@ -142,6 +145,7 @@ pub fn address_map( Some( ProtocolComponent::at_contract(&pool_created.pool, &(tx.into())) + .with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()]) .with_tokens(&[create_call.main_token, create_call.wrapped_token]) .with_attributes(&[ ("pool_type", "EulerLinearPoolFactory".as_bytes()), @@ -216,6 +220,7 @@ pub fn address_map( Some( ProtocolComponent::at_contract(&pool_created.pool, &(tx.into())) + .with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()]) .with_tokens(&[create_call.main_token, create_call.wrapped_token]) .with_attributes(&[ ("pool_type", "SiloLinearPoolFactory".as_bytes()), @@ -242,6 +247,7 @@ pub fn address_map( Some( ProtocolComponent::at_contract(&pool_created.pool, &(tx.into())) + .with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()]) .with_tokens(&[create_call.main_token, create_call.wrapped_token]) .with_attributes(&[ ("pool_type", "YearnLinearPoolFactory".as_bytes()), @@ -270,6 +276,7 @@ pub fn address_map( Some( ProtocolComponent::at_contract(&pool_created.pool, &(tx.into())) + .with_contracts(&[pool_created.pool, VAULT_ADDRESS.to_vec()]) .with_tokens(&create_call.tokens) .with_attributes(&[ ("pool_type", "WeightedPool2TokensFactory".as_bytes()), diff --git a/substreams/ethereum-balancer/substreams.yaml b/substreams/ethereum-balancer/substreams.yaml index 050e8fe..10c949c 100644 --- a/substreams/ethereum-balancer/substreams.yaml +++ b/substreams/ethereum-balancer/substreams.yaml @@ -19,7 +19,7 @@ binaries: modules: - name: map_components kind: map - initialBlock: 12369300 + initialBlock: 12272146 inputs: - source: sf.ethereum.type.v2.Block output: @@ -27,7 +27,7 @@ modules: - name: store_components kind: store - initialBlock: 12369300 + initialBlock: 12272146 updatePolicy: add valueType: int64 inputs: @@ -35,7 +35,7 @@ modules: - name: map_relative_balances kind: map - initialBlock: 12369300 # An arbitrary block that should change based on your requirements + initialBlock: 12272146 inputs: - source: sf.ethereum.type.v2.Block - store: store_components @@ -44,7 +44,7 @@ modules: - name: store_balances kind: store - initialBlock: 12369300 + initialBlock: 12272146 updatePolicy: add valueType: bigint inputs: @@ -52,7 +52,7 @@ modules: - name: map_protocol_changes kind: map - initialBlock: 12369300 + initialBlock: 12272146 inputs: - source: sf.ethereum.type.v2.Block - map: map_components