Don't include balancer specific pb in tycho pbs.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package tycho.evm.v1;
|
package balancer;
|
||||||
|
|
||||||
import "tycho/evm/v1/common.proto";
|
import "tycho/evm/v1/common.proto";
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ import "tycho/evm/v1/common.proto";
|
|||||||
message BalanceDelta {
|
message BalanceDelta {
|
||||||
uint64 ord = 1;
|
uint64 ord = 1;
|
||||||
// The tx hash of the transaction that caused the balance change.
|
// The tx hash of the transaction that caused the balance change.
|
||||||
Transaction tx = 2;
|
tycho.evm.v1.Transaction tx = 2;
|
||||||
// The address of the ERC20 token whose balance changed.
|
// The address of the ERC20 token whose balance changed.
|
||||||
bytes token = 3;
|
bytes token = 3;
|
||||||
// The delta balance of the token.
|
// The delta balance of the token.
|
||||||
@@ -23,8 +23,8 @@ message BalanceDeltas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message TransactionProtocolComponents {
|
message TransactionProtocolComponents {
|
||||||
Transaction tx = 1;
|
tycho.evm.v1.Transaction tx = 1;
|
||||||
repeated ProtocolComponent components = 2;
|
repeated tycho.evm.v1.ProtocolComponent components = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GroupedTransactionProtocolComponents {
|
message GroupedTransactionProtocolComponents {
|
||||||
@@ -17,7 +17,7 @@ use pb::tycho::evm::v1::{self as tycho};
|
|||||||
|
|
||||||
use contract_changes::extract_contract_changes;
|
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};
|
use crate::{abi, contract_changes, pb, pool_factories};
|
||||||
|
|
||||||
const VAULT_ADDRESS: &[u8] = &hex!("BA12222222228d8Ba445958a75a0704d566BF2C8");
|
const VAULT_ADDRESS: &[u8] = &hex!("BA12222222228d8Ba445958a75a0704d566BF2C8");
|
||||||
@@ -36,10 +36,10 @@ impl PartialEq for TransactionWrapper {
|
|||||||
#[substreams::handlers::map]
|
#[substreams::handlers::map]
|
||||||
pub fn map_pools_created(
|
pub fn map_pools_created(
|
||||||
block: eth::v2::Block,
|
block: eth::v2::Block,
|
||||||
) -> Result<tycho::GroupedTransactionProtocolComponents> {
|
) -> Result<GroupedTransactionProtocolComponents> {
|
||||||
// Gather contract changes by indexing `PoolCreated` events and analysing the `Create` call
|
// 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
|
// 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
|
tx_components: block
|
||||||
.transactions()
|
.transactions()
|
||||||
.filter_map(|tx| {
|
.filter_map(|tx| {
|
||||||
@@ -62,7 +62,7 @@ pub fn map_pools_created(
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
if !components.is_empty() {
|
if !components.is_empty() {
|
||||||
Some(tycho::TransactionProtocolComponents {
|
Some(TransactionProtocolComponents {
|
||||||
tx: Some(tycho::Transaction {
|
tx: Some(tycho::Transaction {
|
||||||
hash: tx.hash.clone(),
|
hash: tx.hash.clone(),
|
||||||
from: tx.from.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
|
/// Simply stores the `ProtocolComponent`s with the pool id as the key
|
||||||
#[substreams::handlers::store]
|
#[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(
|
store.add_many(
|
||||||
0,
|
0,
|
||||||
&map.tx_components
|
&map.tx_components
|
||||||
@@ -99,8 +99,8 @@ pub fn store_pools_created(map: tycho::GroupedTransactionProtocolComponents, sto
|
|||||||
pub fn map_balance_deltas(
|
pub fn map_balance_deltas(
|
||||||
block: eth::v2::Block,
|
block: eth::v2::Block,
|
||||||
store: StoreGetInt64,
|
store: StoreGetInt64,
|
||||||
) -> Result<tycho::BalanceDeltas, anyhow::Error> {
|
) -> Result<BalanceDeltas, anyhow::Error> {
|
||||||
Ok(tycho::BalanceDeltas {
|
Ok(BalanceDeltas {
|
||||||
balance_deltas: block
|
balance_deltas: block
|
||||||
.events::<abi::vault::events::PoolBalanceChanged>(&[VAULT_ADDRESS])
|
.events::<abi::vault::events::PoolBalanceChanged>(&[VAULT_ADDRESS])
|
||||||
.flat_map(|(event, log)| {
|
.flat_map(|(event, log)| {
|
||||||
@@ -113,7 +113,7 @@ pub fn map_balance_deltas(
|
|||||||
|
|
||||||
store.get_last(format!("pool:{0}", hex::encode(&component_id)))?;
|
store.get_last(format!("pool:{0}", hex::encode(&component_id)))?;
|
||||||
|
|
||||||
Some(tycho::BalanceDelta {
|
Some(BalanceDelta {
|
||||||
ord: log.log.ordinal,
|
ord: log.log.ordinal,
|
||||||
tx: Some(tycho::Transaction {
|
tx: Some(tycho::Transaction {
|
||||||
hash: log.receipt.transaction.hash.clone(),
|
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
|
/// 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.
|
/// store key to ensure that there's a unique balance being tallied for each.
|
||||||
#[substreams::handlers::store]
|
#[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| {
|
deltas.balance_deltas.iter().for_each(|delta| {
|
||||||
store.add(
|
store.add(
|
||||||
delta.ord,
|
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
|
// @generated
|
||||||
|
// @@protoc_insertion_point(attribute:balancer)
|
||||||
|
pub mod balancer {
|
||||||
|
include!("balancer.rs");
|
||||||
|
// @@protoc_insertion_point(balancer)
|
||||||
|
}
|
||||||
pub mod tycho {
|
pub mod tycho {
|
||||||
pub mod evm {
|
pub mod evm {
|
||||||
// @@protoc_insertion_point(attribute:tycho.evm.v1)
|
// @@protoc_insertion_point(attribute:tycho.evm.v1)
|
||||||
|
|||||||
@@ -267,44 +267,4 @@ pub struct BlockContractChanges {
|
|||||||
#[prost(message, repeated, tag="2")]
|
#[prost(message, repeated, tag="2")]
|
||||||
pub changes: ::prost::alloc::vec::Vec<TransactionContractChanges>,
|
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)
|
// @@protoc_insertion_point(module)
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ protobuf:
|
|||||||
files:
|
files:
|
||||||
- tycho/evm/v1/vm.proto
|
- tycho/evm/v1/vm.proto
|
||||||
- tycho/evm/v1/common.proto
|
- tycho/evm/v1/common.proto
|
||||||
- tycho/evm/v1/balancer.proto
|
- balancer.proto
|
||||||
importPaths:
|
importPaths:
|
||||||
- ../../proto
|
- ../../proto
|
||||||
|
- ./proto
|
||||||
|
|
||||||
binaries:
|
binaries:
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user