From 78fffc02d9445b2d069e1a4a206f7d1dba8a8f77 Mon Sep 17 00:00:00 2001 From: 0xMochan Date: Thu, 9 May 2024 11:52:29 -0500 Subject: [PATCH] clean up maverick stuff and implement changes from feedback --- substreams/Cargo.lock | 19 ------------- substreams/Cargo.toml | 7 +---- substreams/ethereum-curve/src/modules.rs | 27 +++++++++++++------ .../ethereum-curve/src/pool_factories.rs | 7 +++-- substreams/ethereum-curve/substreams.yaml | 3 ++- 5 files changed, 25 insertions(+), 38 deletions(-) diff --git a/substreams/Cargo.lock b/substreams/Cargo.lock index 55336e5..ab4e68f 100644 --- a/substreams/Cargo.lock +++ b/substreams/Cargo.lock @@ -1000,25 +1000,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "substreams-maverick" -version = "0.1.0" -dependencies = [ - "anyhow", - "bytes", - "ethabi 18.0.0", - "getrandom", - "hex", - "hex-literal 0.4.1", - "itertools 0.12.1", - "num-bigint", - "prost 0.11.9", - "prost-types 0.12.3", - "substreams", - "substreams-ethereum", - "tycho-substreams", -] - [[package]] name = "syn" version = "1.0.109" diff --git a/substreams/Cargo.toml b/substreams/Cargo.toml index 9bf71d5..4a69dfc 100644 --- a/substreams/Cargo.toml +++ b/substreams/Cargo.toml @@ -1,10 +1,5 @@ [workspace] -members = [ - "ethereum-balancer", - "ethereum-curve", - "ethereum-maverick", - "crates/tycho-substreams", -] +members = ["ethereum-balancer", "ethereum-curve", "crates/tycho-substreams"] resolver = "2" diff --git a/substreams/ethereum-curve/src/modules.rs b/substreams/ethereum-curve/src/modules.rs index f557320..cd05755 100644 --- a/substreams/ethereum-curve/src/modules.rs +++ b/substreams/ethereum-curve/src/modules.rs @@ -11,8 +11,6 @@ use substreams::{ }, }; -use substreams::key; - use substreams_ethereum::pb::eth; use crate::{pool_changes::emit_deltas, pool_factories, pools::emit_specific_pools}; @@ -164,10 +162,9 @@ pub fn map_protocol_changes( // convert into `TransactionContractChanges` grouped_components .tx_components - .iter() + .into_iter() .for_each(|tx_component| { let tx = tx_component.tx.as_ref().unwrap(); - transaction_contract_changes .entry(tx.index) .or_insert_with(|| TransactionContractChanges { @@ -177,7 +174,16 @@ pub fn map_protocol_changes( balance_changes: vec![], }) .component_changes - .extend_from_slice(&tx_component.components); + .extend_from_slice( + &(tx_component + .components + .into_iter() + .map(|mut component| { + component.id = format!("0x{}", component.id); + component + }) + .collect::>()), + ); }); // Balance changes are gathered by the `StoreDelta` based on `TokenExchange`, etc. creating @@ -189,7 +195,9 @@ pub fn map_protocol_changes( .into_iter() .zip(deltas.balance_deltas) .map(|(store_delta, balance_delta)| { - let new_value_string = String::from_utf8_lossy(&store_delta.new_value).to_string(); + let new_value_string = String::from_utf8(store_delta.new_value) + .unwrap() + .to_string(); ( balance_delta.tx.unwrap(), BalanceChange { @@ -197,8 +205,11 @@ pub fn map_protocol_changes( balance: BigInt::try_from(new_value_string) .unwrap() .to_signed_bytes_be(), - component_id: hex::decode(balance_delta.component_id) - .expect("Pool ID not valid hex"), + component_id: format!( + "0x{}", + String::from_utf8(balance_delta.component_id).unwrap() + ) + .into(), }, ) }) diff --git a/substreams/ethereum-curve/src/pool_factories.rs b/substreams/ethereum-curve/src/pool_factories.rs index 70c7dd7..361bceb 100644 --- a/substreams/ethereum-curve/src/pool_factories.rs +++ b/substreams/ethereum-curve/src/pool_factories.rs @@ -12,7 +12,7 @@ use substreams::scalar::BigInt; const EMPTY_BYTES32: [u8; 32] = [0; 32]; const EMPTY_ADDRESS: [u8; 20] = hex!("0000000000000000000000000000000000000000"); -const CRYPTO_SWAP_REGISTRY: [u8; 20] = hex!("897888115Ada5773E02aA29F775430BFB5F34c51"); +const CRYPTO_SWAP_REGISTRY: [u8; 20] = hex!("9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0"); const MAIN_REGISTRY: [u8; 20] = hex!("90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5"); const CRYPTO_POOL_FACTORY: [u8; 20] = hex!("F18056Bbd320E96A48e3Fbf8bC061322531aac99"); const META_POOL_FACTORY: [u8; 20] = hex!("B9fC157394Af804a3578134A6585C0dc9cc990d4"); @@ -88,7 +88,7 @@ pub fn address_map( let coins = coins_function.call(CRYPTO_SWAP_REGISTRY.to_vec())?; let trimmed_coins: Vec<_> = coins .get(0..add_pool.n_coins.to_i32() as usize) - .unwrap_or(&[]) + .unwrap() .to_vec(); Some(ProtocolComponent { @@ -175,8 +175,7 @@ pub fn address_map( .or_else(|| abi::main_registry::functions::AddPool::match_and_decode(call))?; // We need to perform an eth_call in order to actually get the pool's tokens - let coins_function = - abi::main_registry::functions::GetCoins { pool: add_pool.pool }; + let coins_function = abi::main_registry::functions::GetCoins { pool: add_pool.pool }; let coins = coins_function.call(MAIN_REGISTRY.to_vec())?; let trimmed_coins: Vec<_> = coins diff --git a/substreams/ethereum-curve/substreams.yaml b/substreams/ethereum-curve/substreams.yaml index e0224a9..99f600c 100644 --- a/substreams/ethereum-curve/substreams.yaml +++ b/substreams/ethereum-curve/substreams.yaml @@ -7,6 +7,7 @@ protobuf: files: - tycho/evm/v1/vm.proto - tycho/evm/v1/common.proto + - tycho/evm/v1/utils.proto importPaths: - ../../proto - ./proto @@ -50,7 +51,7 @@ modules: - store: store_components - store: store_component_tokens output: - type: proto:tycho.evm.v1.BalanceDeltas + type: proto:tycho.evm.v1.BlockBalanceDeltas - name: store_balances kind: store