Initial pools.rs function for handling custom parameters

This commit is contained in:
0xMochan
2024-04-11 19:41:56 -05:00
parent 8dcae829b5
commit 7c75c8d3d6
9 changed files with 1525 additions and 28 deletions

View File

@@ -16,7 +16,7 @@ use substreams_ethereum::{block_view::LogView, pb::eth};
use substreams_ethereum::Event;
use crate::{abi, pool_factories};
use crate::{abi, pool_factories, pools::emit_specific_pools};
use tycho_substreams::{
balances::store_balance_changes, contract::extract_contract_changes, prelude::*,
};
@@ -42,14 +42,17 @@ fn tx_from_log(log: &LogView) -> Transaction {
}
#[substreams::handlers::map]
pub fn map_components(block: eth::v2::Block) -> Result<BlockTransactionProtocolComponents> {
pub fn map_components(
params: String,
block: eth::v2::Block,
) -> Result<BlockTransactionProtocolComponents> {
// 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(BlockTransactionProtocolComponents {
tx_components: block
.transactions()
.filter_map(|tx| {
let components = tx
let mut components = tx
.logs_with_calls()
.filter(|(_, call)| !call.call.state_reverted)
.filter_map(|(log, call)| {
@@ -66,6 +69,8 @@ pub fn map_components(block: eth::v2::Block) -> Result<BlockTransactionProtocolC
})
.collect::<Vec<_>>();
components.extend(emit_specific_pools(&params, &block).expect("yur"));
if !components.is_empty() {
Some(TransactionProtocolComponents {
tx: Some(Transaction {