fix: curve substream issues

This commit is contained in:
0xMochan
2024-03-07 17:00:32 -05:00
parent 249fe6eb4c
commit ef098f8238
8 changed files with 13 additions and 101 deletions

View File

@@ -885,7 +885,7 @@ dependencies = [
] ]
[[package]] [[package]]
name = "substreams-balancer" name = "substreams-curve"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",

View File

@@ -1,10 +1,10 @@
[package] [package]
name = "substreams-balancer" name = "substreams-curve"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
[lib] [lib]
name = "substreams_balancer" name = "substreams_curve"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]

View File

@@ -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 /// Simply stores the `ProtocolComponent`s with the pool id as the key
#[substreams::handlers::store] #[substreams::handlers::store]
pub fn store_pool_tokens(map: tycho::GroupedTransactionProtocolComponents, store: StoreSetString) { pub fn store_pools_tokens(map: tycho::GroupedTransactionProtocolComponents, store: StoreSetString) {
&map.tx_components map.tx_components
.iter() .iter()
.flat_map(|tx_components| &tx_components.components) .flat_map(|tx_components| &tx_components.components)
.for_each(|component| { .for_each(|component| {
@@ -120,7 +120,7 @@ pub fn store_pool_tokens(map: tycho::GroupedTransactionProtocolComponents, store
#[substreams::handlers::map] #[substreams::handlers::map]
pub fn map_balance_deltas( pub fn map_balance_deltas(
block: eth::v2::Block, block: eth::v2::Block,
store: StoreGetInt64, pools_store: StoreGetInt64,
tokens_store: StoreGetString, tokens_store: StoreGetString,
) -> Result<tycho::BalanceDeltas, anyhow::Error> { ) -> Result<tycho::BalanceDeltas, anyhow::Error> {
let mut deltas = block let mut deltas = block
@@ -130,7 +130,7 @@ pub fn map_balance_deltas(
Some((log, event)) Some((log, event))
}) })
.filter(|(log, _)| { .filter(|(log, _)| {
store pools_store
.get_last(format!("pool:{0}", hex::encode(&log.address()))) .get_last(format!("pool:{0}", hex::encode(&log.address())))
.is_some() .is_some()
}) })
@@ -163,7 +163,7 @@ pub fn map_balance_deltas(
Some((log, event)) Some((log, event))
}) })
.filter(|(log, _)| { .filter(|(log, _)| {
store pools_store
.get_last(format!("pool:{0}", hex::encode(&log.address()))) .get_last(format!("pool:{0}", hex::encode(&log.address())))
.is_none() .is_none()
}) })
@@ -198,7 +198,7 @@ pub fn map_balance_deltas(
Some((log, event)) Some((log, event))
}) })
.filter(|(log, _)| { .filter(|(log, _)| {
store pools_store
.get_last(format!("pool:{0}", hex::encode(&log.address()))) .get_last(format!("pool:{0}", hex::encode(&log.address())))
.is_none() .is_none()
}) })

View File

@@ -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<Pool>,
}
#[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<u8>,
#[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<u8>,
#[prost(bytes="vec", tag="2")]
pub to: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag="3")]
pub token: ::prost::alloc::string::String,
#[prost(string, tag="4")]
pub amount: ::prost::alloc::string::String,
}
// @@protoc_insertion_point(module)

View File

@@ -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<Pool>,
}
#[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<u8>,
#[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<u8>,
#[prost(bytes="vec", tag="2")]
pub to: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag="3")]
pub token: ::prost::alloc::string::String,
#[prost(string, tag="4")]
pub amount: ::prost::alloc::string::String,
}
// @@protoc_insertion_point(module)

View File

@@ -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<Transfer>,
}
#[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)

View File

@@ -4,7 +4,7 @@ use substreams_ethereum::{Event, Function};
use crate::abi; use crate::abi;
use crate::pb; use crate::pb;
use pb::tycho::evm::v1::{self as tycho}; use pb::tycho::evm::v1::{self as tycho};
use substreams::{hex, log}; use substreams::hex;
use substreams::scalar::BigInt; use substreams::scalar::BigInt;
@@ -38,17 +38,6 @@ impl SerializableVecBigInt for Vec<BigInt> {
} }
} }
/// 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( pub fn address_map(
call_address: &[u8; 20], call_address: &[u8; 20],
log: &Log, log: &Log,

View File

@@ -14,7 +14,7 @@ protobuf:
binaries: binaries:
default: default:
type: wasm/rust-v1 type: wasm/rust-v1
file: target/wasm32-unknown-unknown/release/substreams_balancer.wasm file: target/wasm32-unknown-unknown/release/substreams_curve.wasm
modules: modules:
- name: map_pools_created - name: map_pools_created
@@ -36,7 +36,7 @@ modules:
- name: store_pools_tokens - name: store_pools_tokens
kind: store kind: store
initialBlock: 19128828 initialBlock: 19128828
updatePolicy: add updatePolicy: set
valueType: string valueType: string
inputs: inputs:
- map: map_pools_created - map: map_pools_created
@@ -47,6 +47,7 @@ modules:
inputs: inputs:
- source: sf.ethereum.type.v2.Block - source: sf.ethereum.type.v2.Block
- store: store_pools_created - store: store_pools_created
- store: store_pools_tokens
output: output:
type: proto:tycho.evm.v1.BalanceDeltas type: proto:tycho.evm.v1.BalanceDeltas