feat(substreams): add substreams for Uniswap v2 and v3
This commit is contained in:
25
substreams/ethereum-uniswap-v2/src/modules/2_store_pools.rs
Normal file
25
substreams/ethereum-uniswap-v2/src/modules/2_store_pools.rs
Normal 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user