Don't include balancer specific pb in tycho pbs.
This commit is contained in:
32
substreams/ethereum-balancer/proto/balancer.proto
Normal file
32
substreams/ethereum-balancer/proto/balancer.proto
Normal file
@@ -0,0 +1,32 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package balancer;
|
||||
|
||||
import "tycho/evm/v1/common.proto";
|
||||
|
||||
// A struct for following the changes of Total Value Locked (TVL).
|
||||
message BalanceDelta {
|
||||
uint64 ord = 1;
|
||||
// The tx hash of the transaction that caused the balance change.
|
||||
tycho.evm.v1.Transaction tx = 2;
|
||||
// The address of the ERC20 token whose balance changed.
|
||||
bytes token = 3;
|
||||
// The delta balance of the token.
|
||||
bytes delta = 4;
|
||||
// The id of the component whose TVL is tracked.
|
||||
// If the protocol component includes multiple contracts, the balance change must be aggregated to reflect how much tokens can be traded.
|
||||
bytes component_id = 5;
|
||||
}
|
||||
|
||||
message BalanceDeltas {
|
||||
repeated BalanceDelta balance_deltas = 1;
|
||||
}
|
||||
|
||||
message TransactionProtocolComponents {
|
||||
tycho.evm.v1.Transaction tx = 1;
|
||||
repeated tycho.evm.v1.ProtocolComponent components = 2;
|
||||
}
|
||||
|
||||
message GroupedTransactionProtocolComponents {
|
||||
repeated TransactionProtocolComponents tx_components = 1;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ use pb::tycho::evm::v1::{self as tycho};
|
||||
|
||||
use contract_changes::extract_contract_changes;
|
||||
|
||||
use crate::pb::tycho::evm::v1::{BalanceDeltas, GroupedTransactionProtocolComponents};
|
||||
use crate::pb::balancer::{BalanceDelta, BalanceDeltas, GroupedTransactionProtocolComponents, TransactionProtocolComponents};
|
||||
use crate::{abi, contract_changes, pb, pool_factories};
|
||||
|
||||
const VAULT_ADDRESS: &[u8] = &hex!("BA12222222228d8Ba445958a75a0704d566BF2C8");
|
||||
@@ -36,10 +36,10 @@ impl PartialEq for TransactionWrapper {
|
||||
#[substreams::handlers::map]
|
||||
pub fn map_pools_created(
|
||||
block: eth::v2::Block,
|
||||
) -> Result<tycho::GroupedTransactionProtocolComponents> {
|
||||
) -> Result<GroupedTransactionProtocolComponents> {
|
||||
// Gather contract changes by indexing `PoolCreated` events and analysing the `Create` call
|
||||
// We store these as a hashmap by tx hash since we need to agg by tx hash later
|
||||
Ok(tycho::GroupedTransactionProtocolComponents {
|
||||
Ok(GroupedTransactionProtocolComponents {
|
||||
tx_components: block
|
||||
.transactions()
|
||||
.filter_map(|tx| {
|
||||
@@ -62,7 +62,7 @@ pub fn map_pools_created(
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !components.is_empty() {
|
||||
Some(tycho::TransactionProtocolComponents {
|
||||
Some(TransactionProtocolComponents {
|
||||
tx: Some(tycho::Transaction {
|
||||
hash: tx.hash.clone(),
|
||||
from: tx.from.clone(),
|
||||
@@ -81,7 +81,7 @@ pub fn map_pools_created(
|
||||
|
||||
/// Simply stores the `ProtocolComponent`s with the pool id as the key
|
||||
#[substreams::handlers::store]
|
||||
pub fn store_pools_created(map: tycho::GroupedTransactionProtocolComponents, store: StoreAddInt64) {
|
||||
pub fn store_pools_created(map: GroupedTransactionProtocolComponents, store: StoreAddInt64) {
|
||||
store.add_many(
|
||||
0,
|
||||
&map.tx_components
|
||||
@@ -99,8 +99,8 @@ pub fn store_pools_created(map: tycho::GroupedTransactionProtocolComponents, sto
|
||||
pub fn map_balance_deltas(
|
||||
block: eth::v2::Block,
|
||||
store: StoreGetInt64,
|
||||
) -> Result<tycho::BalanceDeltas, anyhow::Error> {
|
||||
Ok(tycho::BalanceDeltas {
|
||||
) -> Result<BalanceDeltas, anyhow::Error> {
|
||||
Ok(BalanceDeltas {
|
||||
balance_deltas: block
|
||||
.events::<abi::vault::events::PoolBalanceChanged>(&[VAULT_ADDRESS])
|
||||
.flat_map(|(event, log)| {
|
||||
@@ -113,7 +113,7 @@ pub fn map_balance_deltas(
|
||||
|
||||
store.get_last(format!("pool:{0}", hex::encode(&component_id)))?;
|
||||
|
||||
Some(tycho::BalanceDelta {
|
||||
Some(BalanceDelta {
|
||||
ord: log.log.ordinal,
|
||||
tx: Some(tycho::Transaction {
|
||||
hash: log.receipt.transaction.hash.clone(),
|
||||
@@ -135,7 +135,7 @@ pub fn map_balance_deltas(
|
||||
/// It's significant to include both the `pool_id` and the `token_id` for each balance delta as the
|
||||
/// store key to ensure that there's a unique balance being tallied for each.
|
||||
#[substreams::handlers::store]
|
||||
pub fn store_balance_changes(deltas: tycho::BalanceDeltas, store: StoreAddBigInt) {
|
||||
pub fn store_balance_changes(deltas: BalanceDeltas, store: StoreAddBigInt) {
|
||||
deltas.balance_deltas.iter().for_each(|delta| {
|
||||
store.add(
|
||||
delta.ord,
|
||||
|
||||
42
substreams/ethereum-balancer/src/pb/balancer.rs
Normal file
42
substreams/ethereum-balancer/src/pb/balancer.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
// @generated
|
||||
/// A struct for following the changes of Total Value Locked (TVL).
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BalanceDelta {
|
||||
#[prost(uint64, tag="1")]
|
||||
pub ord: u64,
|
||||
/// The tx hash of the transaction that caused the balance change.
|
||||
#[prost(message, optional, tag="2")]
|
||||
pub tx: ::core::option::Option<super::tycho::evm::v1::Transaction>,
|
||||
/// The address of the ERC20 token whose balance changed.
|
||||
#[prost(bytes="vec", tag="3")]
|
||||
pub token: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The delta balance of the token.
|
||||
#[prost(bytes="vec", tag="4")]
|
||||
pub delta: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The id of the component whose TVL is tracked.
|
||||
/// If the protocol component includes multiple contracts, the balance change must be aggregated to reflect how much tokens can be traded.
|
||||
#[prost(bytes="vec", tag="5")]
|
||||
pub component_id: ::prost::alloc::vec::Vec<u8>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BalanceDeltas {
|
||||
#[prost(message, repeated, tag="1")]
|
||||
pub balance_deltas: ::prost::alloc::vec::Vec<BalanceDelta>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct TransactionProtocolComponents {
|
||||
#[prost(message, optional, tag="1")]
|
||||
pub tx: ::core::option::Option<super::tycho::evm::v1::Transaction>,
|
||||
#[prost(message, repeated, tag="2")]
|
||||
pub components: ::prost::alloc::vec::Vec<super::tycho::evm::v1::ProtocolComponent>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct GroupedTransactionProtocolComponents {
|
||||
#[prost(message, repeated, tag="1")]
|
||||
pub tx_components: ::prost::alloc::vec::Vec<TransactionProtocolComponents>,
|
||||
}
|
||||
// @@protoc_insertion_point(module)
|
||||
@@ -1,4 +1,9 @@
|
||||
// @generated
|
||||
// @@protoc_insertion_point(attribute:balancer)
|
||||
pub mod balancer {
|
||||
include!("balancer.rs");
|
||||
// @@protoc_insertion_point(balancer)
|
||||
}
|
||||
pub mod tycho {
|
||||
pub mod evm {
|
||||
// @@protoc_insertion_point(attribute:tycho.evm.v1)
|
||||
|
||||
@@ -267,44 +267,4 @@ pub struct BlockContractChanges {
|
||||
#[prost(message, repeated, tag="2")]
|
||||
pub changes: ::prost::alloc::vec::Vec<TransactionContractChanges>,
|
||||
}
|
||||
/// A struct for following the changes of Total Value Locked (TVL).
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BalanceDelta {
|
||||
#[prost(uint64, tag="1")]
|
||||
pub ord: u64,
|
||||
/// The tx hash of the transaction that caused the balance change.
|
||||
#[prost(message, optional, tag="2")]
|
||||
pub tx: ::core::option::Option<Transaction>,
|
||||
/// The address of the ERC20 token whose balance changed.
|
||||
#[prost(bytes="vec", tag="3")]
|
||||
pub token: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The delta balance of the token.
|
||||
#[prost(bytes="vec", tag="4")]
|
||||
pub delta: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The id of the component whose TVL is tracked.
|
||||
/// If the protocol component includes multiple contracts, the balance change must be aggregated to reflect how much tokens can be traded.
|
||||
#[prost(bytes="vec", tag="5")]
|
||||
pub component_id: ::prost::alloc::vec::Vec<u8>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BalanceDeltas {
|
||||
#[prost(message, repeated, tag="1")]
|
||||
pub balance_deltas: ::prost::alloc::vec::Vec<BalanceDelta>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct TransactionProtocolComponents {
|
||||
#[prost(message, optional, tag="1")]
|
||||
pub tx: ::core::option::Option<Transaction>,
|
||||
#[prost(message, repeated, tag="2")]
|
||||
pub components: ::prost::alloc::vec::Vec<ProtocolComponent>,
|
||||
}
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct GroupedTransactionProtocolComponents {
|
||||
#[prost(message, repeated, tag="1")]
|
||||
pub tx_components: ::prost::alloc::vec::Vec<TransactionProtocolComponents>,
|
||||
}
|
||||
// @@protoc_insertion_point(module)
|
||||
|
||||
@@ -7,9 +7,10 @@ protobuf:
|
||||
files:
|
||||
- tycho/evm/v1/vm.proto
|
||||
- tycho/evm/v1/common.proto
|
||||
- tycho/evm/v1/balancer.proto
|
||||
- balancer.proto
|
||||
importPaths:
|
||||
- ../../proto
|
||||
- ./proto
|
||||
|
||||
binaries:
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user