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,51 @@
use ethabi::ethereum_types::Address;
use substreams::store::{StoreGet, StoreGetProto};
use substreams_ethereum::pb::eth::v2::{self as eth};
use substreams_helper::{common::HasAddresser, hex::Hexable};
use crate::{
pb::tycho::evm::v1::{Block, ProtocolComponent, Transaction},
store_key::StoreKey,
};
pub struct PoolAddresser<'a> {
pub store: &'a StoreGetProto<ProtocolComponent>,
}
impl<'a> HasAddresser for PoolAddresser<'a> {
fn has_address(&self, key: Address) -> bool {
let pool = self
.store
.get_last(StoreKey::Pool.get_unique_pool_key(&key.to_hex()));
pool.is_some()
}
}
impl From<eth::Block> for Block {
fn from(block: eth::Block) -> Self {
Self {
hash: block.hash.clone(),
parent_hash: block
.header
.as_ref()
.expect("Block header not present")
.parent_hash
.clone(),
number: block.number,
ts: block.timestamp_seconds(),
}
}
}
impl From<&eth::TransactionTrace> for Transaction {
fn from(tx: &eth::TransactionTrace) -> Self {
Self {
hash: tx.hash.clone(),
from: tx.from.clone(),
to: tx.to.clone(),
index: tx.index.into(),
}
}
}