Files
tycho-protocol-sdk/substreams/ethereum-ambient/src/modules/2_store_pool_balances.rs
Louise Poole ad0a391f72 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
2025-01-27 10:36:13 +02:00

19 lines
602 B
Rust

use substreams::{
scalar::BigInt,
store::{StoreAdd, StoreAddBigInt, StoreNew},
};
use crate::pb::tycho::ambient::v1::BlockPoolChanges;
#[substreams::handlers::store]
pub fn store_pool_balances(changes: BlockPoolChanges, balance_store: StoreAddBigInt) {
for balance_delta in changes.balance_deltas {
let pool_hash_hex = hex::encode(&balance_delta.pool_hash);
balance_store.add(
balance_delta.ordinal,
format!("{}:{}", pool_hash_hex, balance_delta.token_type),
BigInt::from_signed_bytes_be(&balance_delta.token_delta),
);
}
}