From ec6e16f4656a37f4af85320868c524d510442258 Mon Sep 17 00:00:00 2001 From: Florian Pellissier <111426680+flopell@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:42:55 +0200 Subject: [PATCH] refactor: Clean code and update cargo.lock --- substreams/Cargo.lock | 4 +++- substreams/crates/tycho-substreams/src/balances.rs | 7 +------ substreams/ethereum-curve/src/modules.rs | 6 +----- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/substreams/Cargo.lock b/substreams/Cargo.lock index 933179a..03514a5 100644 --- a/substreams/Cargo.lock +++ b/substreams/Cargo.lock @@ -1097,10 +1097,12 @@ dependencies = [ [[package]] name = "tycho-substreams" -version = "0.1.0" +version = "0.2.0" dependencies = [ + "ethabi 18.0.0", "hex", "itertools 0.12.1", + "num-bigint", "prost 0.11.9", "substreams", "substreams-ethereum", diff --git a/substreams/crates/tycho-substreams/src/balances.rs b/substreams/crates/tycho-substreams/src/balances.rs index ec14fde..afda1ff 100644 --- a/substreams/crates/tycho-substreams/src/balances.rs +++ b/substreams/crates/tycho-substreams/src/balances.rs @@ -212,12 +212,7 @@ pub fn extract_balance_deltas_from_tx bool>( let mut create_balance_delta = |transactor: &[u8], delta: BigInt| { balance_deltas.push(BalanceDelta { ord: log.ordinal, - tx: Some(Transaction { - to: tx.to.clone(), - from: tx.from.clone(), - hash: tx.hash.clone(), - index: tx.index.into(), - }), + tx: Some(tx.into()), token: log.address.clone(), delta: delta.to_signed_bytes_be(), component_id: hex::encode(transactor).into(), diff --git a/substreams/ethereum-curve/src/modules.rs b/substreams/ethereum-curve/src/modules.rs index 2f13e11..b8ef29f 100644 --- a/substreams/ethereum-curve/src/modules.rs +++ b/substreams/ethereum-curve/src/modules.rs @@ -117,11 +117,7 @@ pub fn map_relative_balances( let pool_key = format!("pool:{}", hex::encode(transactor)); if let Some(tokens) = tokens_store.get_last(pool_key) { let token_id = hex::encode(token); - tokens - .split(":") - .map(|token| token.to_owned()) - .collect::>() - .contains(&token_id) + tokens.split(':').any(|t| t == token_id) } else { false }