feat(substreams): add substreams for Uniswap v2 and v3

This commit is contained in:
zizou
2024-10-11 12:57:34 +02:00
parent 58455a1188
commit 73d48236ba
70 changed files with 16697 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
use substreams::store::{StoreNew, StoreSetIfNotExists, StoreSetIfNotExistsProto};
use crate::{
pb::tycho::evm::v1::{BlockChanges, ProtocolComponent},
store_key::StoreKey,
};
#[substreams::handlers::store]
pub fn store_pools(
pools_created: BlockChanges,
store: StoreSetIfNotExistsProto<ProtocolComponent>,
) {
// Store pools. Required so the next steps can match any event to a known pool by their address
for change in pools_created.changes {
for new_protocol_component in change.component_changes {
// Use ordinal 0 because the address should be unique, so ordering doesn't matter.
store.set_if_not_exists(
0,
StoreKey::Pool.get_unique_pool_key(&new_protocol_component.id),
&new_protocol_component,
);
}
}
}