From ef098f8238ee20343863aeff1cb9f62c1e41b845 Mon Sep 17 00:00:00 2001 From: 0xMochan Date: Thu, 7 Mar 2024 17:00:32 -0500 Subject: [PATCH] fix: curve substream issues --- substreams/ethereum-curve/Cargo.lock | 2 +- substreams/ethereum-curve/Cargo.toml | 4 +-- substreams/ethereum-curve/src/modules.rs | 12 ++++---- .../ethereum-curve/src/pb/eth.balancer.v1.rs | 28 ------------------- .../ethereum-curve/src/pb/eth.factory.v1.rs | 28 ------------------- .../ethereum-curve/src/pb/eth.pool.v1.rs | 22 --------------- .../ethereum-curve/src/pool_factories.rs | 13 +-------- substreams/ethereum-curve/substreams.yaml | 5 ++-- 8 files changed, 13 insertions(+), 101 deletions(-) delete mode 100644 substreams/ethereum-curve/src/pb/eth.balancer.v1.rs delete mode 100644 substreams/ethereum-curve/src/pb/eth.factory.v1.rs delete mode 100644 substreams/ethereum-curve/src/pb/eth.pool.v1.rs diff --git a/substreams/ethereum-curve/Cargo.lock b/substreams/ethereum-curve/Cargo.lock index c96455e..0cb60cc 100644 --- a/substreams/ethereum-curve/Cargo.lock +++ b/substreams/ethereum-curve/Cargo.lock @@ -885,7 +885,7 @@ dependencies = [ ] [[package]] -name = "substreams-balancer" +name = "substreams-curve" version = "0.1.0" dependencies = [ "anyhow", diff --git a/substreams/ethereum-curve/Cargo.toml b/substreams/ethereum-curve/Cargo.toml index 795c565..c601e7b 100644 --- a/substreams/ethereum-curve/Cargo.toml +++ b/substreams/ethereum-curve/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "substreams-balancer" +name = "substreams-curve" version = "0.1.0" edition = "2021" [lib] -name = "substreams_balancer" +name = "substreams_curve" crate-type = ["cdylib"] [dependencies] diff --git a/substreams/ethereum-curve/src/modules.rs b/substreams/ethereum-curve/src/modules.rs index 2a47f46..6ceb2ee 100644 --- a/substreams/ethereum-curve/src/modules.rs +++ b/substreams/ethereum-curve/src/modules.rs @@ -98,8 +98,8 @@ pub fn store_pools_created(map: tycho::GroupedTransactionProtocolComponents, sto /// Simply stores the `ProtocolComponent`s with the pool id as the key #[substreams::handlers::store] -pub fn store_pool_tokens(map: tycho::GroupedTransactionProtocolComponents, store: StoreSetString) { - &map.tx_components +pub fn store_pools_tokens(map: tycho::GroupedTransactionProtocolComponents, store: StoreSetString) { + map.tx_components .iter() .flat_map(|tx_components| &tx_components.components) .for_each(|component| { @@ -120,7 +120,7 @@ pub fn store_pool_tokens(map: tycho::GroupedTransactionProtocolComponents, store #[substreams::handlers::map] pub fn map_balance_deltas( block: eth::v2::Block, - store: StoreGetInt64, + pools_store: StoreGetInt64, tokens_store: StoreGetString, ) -> Result { let mut deltas = block @@ -130,7 +130,7 @@ pub fn map_balance_deltas( Some((log, event)) }) .filter(|(log, _)| { - store + pools_store .get_last(format!("pool:{0}", hex::encode(&log.address()))) .is_some() }) @@ -163,7 +163,7 @@ pub fn map_balance_deltas( Some((log, event)) }) .filter(|(log, _)| { - store + pools_store .get_last(format!("pool:{0}", hex::encode(&log.address()))) .is_none() }) @@ -198,7 +198,7 @@ pub fn map_balance_deltas( Some((log, event)) }) .filter(|(log, _)| { - store + pools_store .get_last(format!("pool:{0}", hex::encode(&log.address()))) .is_none() }) diff --git a/substreams/ethereum-curve/src/pb/eth.balancer.v1.rs b/substreams/ethereum-curve/src/pb/eth.balancer.v1.rs deleted file mode 100644 index 47065d4..0000000 --- a/substreams/ethereum-curve/src/pb/eth.balancer.v1.rs +++ /dev/null @@ -1,28 +0,0 @@ -// @generated -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Pools { - #[prost(message, repeated, tag="1")] - pub pools: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Pool { - #[prost(bytes="vec", tag="1")] - pub pool_id: ::prost::alloc::vec::Vec, - #[prost(fixed64, tag="2")] - pub log_ordinal: u64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Transfer { - #[prost(bytes="vec", tag="1")] - pub from: ::prost::alloc::vec::Vec, - #[prost(bytes="vec", tag="2")] - pub to: ::prost::alloc::vec::Vec, - #[prost(string, tag="3")] - pub token: ::prost::alloc::string::String, - #[prost(string, tag="4")] - pub amount: ::prost::alloc::string::String, -} -// @@protoc_insertion_point(module) diff --git a/substreams/ethereum-curve/src/pb/eth.factory.v1.rs b/substreams/ethereum-curve/src/pb/eth.factory.v1.rs deleted file mode 100644 index 47065d4..0000000 --- a/substreams/ethereum-curve/src/pb/eth.factory.v1.rs +++ /dev/null @@ -1,28 +0,0 @@ -// @generated -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Pools { - #[prost(message, repeated, tag="1")] - pub pools: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Pool { - #[prost(bytes="vec", tag="1")] - pub pool_id: ::prost::alloc::vec::Vec, - #[prost(fixed64, tag="2")] - pub log_ordinal: u64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Transfer { - #[prost(bytes="vec", tag="1")] - pub from: ::prost::alloc::vec::Vec, - #[prost(bytes="vec", tag="2")] - pub to: ::prost::alloc::vec::Vec, - #[prost(string, tag="3")] - pub token: ::prost::alloc::string::String, - #[prost(string, tag="4")] - pub amount: ::prost::alloc::string::String, -} -// @@protoc_insertion_point(module) diff --git a/substreams/ethereum-curve/src/pb/eth.pool.v1.rs b/substreams/ethereum-curve/src/pb/eth.pool.v1.rs deleted file mode 100644 index 16ad6e5..0000000 --- a/substreams/ethereum-curve/src/pb/eth.pool.v1.rs +++ /dev/null @@ -1,22 +0,0 @@ -// @generated -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Transfers { - #[prost(message, repeated, tag="1")] - pub transfers: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Transfer { - #[prost(string, tag="1")] - pub from: ::prost::alloc::string::String, - #[prost(string, tag="2")] - pub to: ::prost::alloc::string::String, - #[prost(uint64, tag="3")] - pub token_id: u64, - #[prost(string, tag="4")] - pub trx_hash: ::prost::alloc::string::String, - #[prost(uint64, tag="5")] - pub ordinal: u64, -} -// @@protoc_insertion_point(module) diff --git a/substreams/ethereum-curve/src/pool_factories.rs b/substreams/ethereum-curve/src/pool_factories.rs index 7d02558..e797873 100644 --- a/substreams/ethereum-curve/src/pool_factories.rs +++ b/substreams/ethereum-curve/src/pool_factories.rs @@ -4,7 +4,7 @@ use substreams_ethereum::{Event, Function}; use crate::abi; use crate::pb; use pb::tycho::evm::v1::{self as tycho}; -use substreams::{hex, log}; +use substreams::hex; use substreams::scalar::BigInt; @@ -38,17 +38,6 @@ impl SerializableVecBigInt for Vec { } } -/// This is the main function that handles the creation of `ProtocolComponent`s with `Attribute`s -/// based on the specific factory address. There's 3 factory groups that are represented here: -/// - Weighted Pool Factories -/// - Linear Pool Factories -/// - Stable Pool Factories -/// (Balancer does have a bit more (esp. in the deprecated section) that could be implemented as -/// desired.) -/// We use the specific ABIs to decode both the log event and cooresponding call to gather -/// `PoolCreated` event information alongside the `Create` calldata that provide us details to -/// fufill both the required details + any extra `Attributes` -/// Ref: https://docs.balancer.fi/reference/contracts/deployment-addresses/mainnet.html pub fn address_map( call_address: &[u8; 20], log: &Log, diff --git a/substreams/ethereum-curve/substreams.yaml b/substreams/ethereum-curve/substreams.yaml index 306d089..9daab92 100644 --- a/substreams/ethereum-curve/substreams.yaml +++ b/substreams/ethereum-curve/substreams.yaml @@ -14,7 +14,7 @@ protobuf: binaries: default: type: wasm/rust-v1 - file: target/wasm32-unknown-unknown/release/substreams_balancer.wasm + file: target/wasm32-unknown-unknown/release/substreams_curve.wasm modules: - name: map_pools_created @@ -36,7 +36,7 @@ modules: - name: store_pools_tokens kind: store initialBlock: 19128828 - updatePolicy: add + updatePolicy: set valueType: string inputs: - map: map_pools_created @@ -47,6 +47,7 @@ modules: inputs: - source: sf.ethereum.type.v2.Block - store: store_pools_created + - store: store_pools_tokens output: type: proto:tycho.evm.v1.BalanceDeltas