chore: clean up ambient (#136)
* fix: remove unnecessary tx field in ProtocolComponent * chore: move ambient protobuf files to ambient module * chore: remove dependency on common message types This allows us to isolate the ambient specific messages within the ambient module * feat: update ambient substream with new message structs * chore: update substream configs And remove use of deprecated BlockContractChanges. * feat: implement From for AmbientProtocolComponent to ProtocolComponent
This commit is contained in:
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use substreams_ethereum::pb::eth::v2::{self as sf, StorageChange};
|
||||
|
||||
// re-export the protobuf types here.
|
||||
pub use crate::pb::tycho::{ambient::v1::*, evm::v1::*};
|
||||
pub use crate::pb::tycho::evm::v1::*;
|
||||
|
||||
impl TransactionContractChanges {
|
||||
/// Creates a new empty `TransactionContractChanges` instance.
|
||||
@@ -213,7 +213,7 @@ impl ProtocolComponent {
|
||||
/// ## Parameters
|
||||
/// - `id`: Identifier for the component.
|
||||
/// - `tx`: Reference to the associated transaction.
|
||||
pub fn new(id: &str, tx: &Transaction) -> Self {
|
||||
pub fn new(id: &str) -> Self {
|
||||
Self {
|
||||
id: id.to_string(),
|
||||
tokens: Vec::new(),
|
||||
@@ -221,7 +221,6 @@ impl ProtocolComponent {
|
||||
static_att: Vec::new(),
|
||||
change: ChangeType::Creation.into(),
|
||||
protocol_type: None,
|
||||
tx: Some(tx.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +232,7 @@ impl ProtocolComponent {
|
||||
/// ## Parameters
|
||||
/// - `id`: Contract address to be encoded and set as the component's ID.
|
||||
/// - `tx`: Reference to the associated transaction.
|
||||
pub fn at_contract(id: &[u8], tx: &Transaction) -> Self {
|
||||
pub fn at_contract(id: &[u8]) -> Self {
|
||||
Self {
|
||||
id: format!("0x{}", hex::encode(id)),
|
||||
tokens: Vec::new(),
|
||||
@@ -241,7 +240,6 @@ impl ProtocolComponent {
|
||||
static_att: Vec::new(),
|
||||
change: ChangeType::Creation.into(),
|
||||
protocol_type: None,
|
||||
tx: Some(tx.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
// @generated
|
||||
pub mod tycho {
|
||||
pub mod ambient {
|
||||
// @@protoc_insertion_point(attribute:tycho.ambient.v1)
|
||||
pub mod v1 {
|
||||
include!("tycho.ambient.v1.rs");
|
||||
// @@protoc_insertion_point(tycho.ambient.v1)
|
||||
}
|
||||
}
|
||||
pub mod evm {
|
||||
// @@protoc_insertion_point(attribute:tycho.evm.v1)
|
||||
pub mod v1 {
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// @generated
|
||||
/// A change to a pool's balance. Ambient specific.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct AmbientBalanceDelta {
|
||||
/// The address of the ERC20 token whose balance changed.
|
||||
#[prost(bytes="vec", tag="1")]
|
||||
pub pool_hash: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The token type: it can be base or quote.
|
||||
#[prost(string, tag="2")]
|
||||
pub token_type: ::prost::alloc::string::String,
|
||||
/// The delta of the token.
|
||||
#[prost(bytes="vec", tag="3")]
|
||||
pub token_delta: ::prost::alloc::vec::Vec<u8>,
|
||||
/// Used to determine the order of the balance changes. Necessary for the balance store.
|
||||
#[prost(uint64, tag="4")]
|
||||
pub ordinal: u64,
|
||||
/// Transaction where the balance changed.
|
||||
#[prost(message, optional, tag="5")]
|
||||
pub tx: ::core::option::Option<super::super::evm::v1::Transaction>,
|
||||
}
|
||||
/// Ambient pool changes within a single block
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BlockPoolChanges {
|
||||
/// New protocol components added in this block
|
||||
#[prost(message, repeated, tag="1")]
|
||||
pub protocol_components: ::prost::alloc::vec::Vec<super::super::evm::v1::ProtocolComponent>,
|
||||
/// Balance changes to pools in this block
|
||||
#[prost(message, repeated, tag="2")]
|
||||
pub balance_deltas: ::prost::alloc::vec::Vec<AmbientBalanceDelta>,
|
||||
}
|
||||
// @@protoc_insertion_point(module)
|
||||
@@ -95,9 +95,6 @@ pub struct ProtocolComponent {
|
||||
/// / Represents the functionality of the component.
|
||||
#[prost(message, optional, tag="6")]
|
||||
pub protocol_type: ::core::option::Option<ProtocolType>,
|
||||
/// Transaction where this component was created
|
||||
#[prost(message, optional, tag = "7")]
|
||||
pub tx: ::core::option::Option<Transaction>,
|
||||
}
|
||||
/// A struct for following the changes of Total Value Locked (TVL) of a protocol component.
|
||||
/// Note that if a ProtocolComponent contains multiple contracts, the TVL is tracked for the component as a whole.
|
||||
|
||||
Reference in New Issue
Block a user