From cfbfeaabde77283eea83e95f11c6ef47bd9dce8d Mon Sep 17 00:00:00 2001 From: Louise Poole Date: Tue, 4 Feb 2025 18:21:46 +0200 Subject: [PATCH 1/4] feat: update tycho version to a Base supported version --- Cargo.lock | 8 ++++---- Cargo.toml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5b74e17..dd18dadd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7071,8 +7071,8 @@ dependencies = [ [[package]] name = "tycho-client" -version = "0.46.0" -source = "git+https://github.com/propeller-heads/tycho-indexer.git?tag=0.46.0#481b2f252eddb98442eab78069fa427068b5050d" +version = "0.55.1" +source = "git+https://github.com/propeller-heads/tycho-indexer.git?tag=0.55.1#d59ff21403f2e628e3ec59882c1be3ca287d0303" dependencies = [ "anyhow", "async-trait", @@ -7097,8 +7097,8 @@ dependencies = [ [[package]] name = "tycho-core" -version = "0.46.0" -source = "git+https://github.com/propeller-heads/tycho-indexer.git?tag=0.46.0#481b2f252eddb98442eab78069fa427068b5050d" +version = "0.55.1" +source = "git+https://github.com/propeller-heads/tycho-indexer.git?tag=0.55.1#d59ff21403f2e628e3ec59882c1be3ca287d0303" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 1c4f9751..7065763b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,8 +38,8 @@ mini-moka = "0.10" lazy_static = "1.4.0" # Tycho dependencies -tycho-core = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-core", tag = "0.46.0" } -tycho-client = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-client", tag = "0.46.0" } +tycho-core = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-core", tag = "0.55.1" } +tycho-client = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-client", tag = "0.55.1" } # EVM dependencies foundry-config = { git = "https://github.com/foundry-rs/foundry", rev = "57bb12e", optional = true } From 1cae4404dc5383e42cad68dbffac37baf85c2a28 Mon Sep 17 00:00:00 2001 From: Louise Poole Date: Tue, 4 Feb 2025 18:23:03 +0200 Subject: [PATCH 2/4] feat: re-export shallow reimplementions of tycho core models Removes the need to update these from maps whenever tycho updates their enums. --- src/evm/tycho_models.rs | 52 ++++------------------------------------- 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/src/evm/tycho_models.rs b/src/evm/tycho_models.rs index 4939ce2a..c53620b1 100644 --- a/src/evm/tycho_models.rs +++ b/src/evm/tycho_models.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, fmt::Display}; use alloy_primitives::{Address, B256, U256}; use chrono::{NaiveDateTime, Utc}; use serde::{Deserialize, Serialize}; -use strum_macros::{Display, EnumString}; +pub use tycho_core::dto::{Chain, ChangeType}; use uuid::Uuid; use super::engine_db::simulation_db::BlockHeader; @@ -110,50 +110,6 @@ impl BlockAccountChanges { } } -#[derive( - Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, EnumString, Display, Default, -)] -#[serde(rename_all = "lowercase")] -#[strum(serialize_all = "lowercase")] -pub enum Chain { - #[default] - Ethereum, - ZkSync, - Starknet, - Arbitrum, -} - -impl From for Chain { - fn from(value: tycho_core::dto::Chain) -> Self { - match value { - tycho_core::dto::Chain::Ethereum => Chain::Ethereum, - tycho_core::dto::Chain::ZkSync => Chain::ZkSync, - tycho_core::dto::Chain::Starknet => Chain::Starknet, - tycho_core::dto::Chain::Arbitrum => Chain::Arbitrum, - } - } -} - -#[derive(Debug, PartialEq, Default, Copy, Clone, Deserialize, Serialize, Display, EnumString)] -pub enum ChangeType { - #[default] - Update, - Deletion, - Creation, - Unspecified, -} - -impl From for ChangeType { - fn from(value: tycho_core::dto::ChangeType) -> Self { - match value { - tycho_core::dto::ChangeType::Update => ChangeType::Update, - tycho_core::dto::ChangeType::Deletion => ChangeType::Deletion, - tycho_core::dto::ChangeType::Creation => ChangeType::Creation, - tycho_core::dto::ChangeType::Unspecified => ChangeType::Unspecified, - } - } -} - #[derive(PartialEq, Serialize, Deserialize, Clone, Debug)] pub struct AccountUpdate { pub address: Address, @@ -182,14 +138,14 @@ impl AccountUpdate { impl From for AccountUpdate { fn from(value: tycho_core::dto::AccountUpdate) -> Self { Self { - chain: value.chain.into(), + chain: value.chain, address: Address::from_slice(&value.address[..20]), // Convert address field to Address slots: u256_num::map_slots_to_u256(value.slots), balance: value .balance .map(|balance| u256_num::bytes_to_u256(balance.into())), code: value.code.map(|code| code.to_vec()), - change: value.change.into(), + change: value.change, } } } @@ -304,7 +260,7 @@ impl std::fmt::Debug for ResponseAccount { impl From for ResponseAccount { fn from(value: tycho_core::dto::ResponseAccount) -> Self { Self { - chain: value.chain.into(), + chain: value.chain, address: Address::from_slice(&value.address[..20]), // Convert address field to Address title: value.title.clone(), slots: u256_num::map_slots_to_u256(value.slots), From 185391671ca3a4885c1390a6a409e6d759bc9921 Mon Sep 17 00:00:00 2001 From: Louise Poole Date: Tue, 4 Feb 2025 18:23:27 +0200 Subject: [PATCH 3/4] feat: add chain ver to load_all_tokens --- examples/price_printer/main.rs | 9 +++++++-- examples/quickstart/main.rs | 4 +++- src/utils.rs | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/price_printer/main.rs b/examples/price_printer/main.rs index 3c38d174..6d75f649 100644 --- a/examples/price_printer/main.rs +++ b/examples/price_printer/main.rs @@ -53,8 +53,13 @@ async fn main() { let (tick_tx, tick_rx) = mpsc::channel::(12); let tycho_message_processor: JoinHandle> = tokio::spawn(async move { - let all_tokens = - load_all_tokens(tycho_url.as_str(), false, Some(tycho_api_key.as_str())).await; + let all_tokens = load_all_tokens( + tycho_url.as_str(), + false, + Some(tycho_api_key.as_str()), + Chain::Ethereum, + ) + .await; let tvl_filter = ComponentFilter::with_tvl_range(cli.tvl_threshold, cli.tvl_threshold); let mut protocol_stream = ProtocolStreamBuilder::new(&tycho_url, Chain::Ethereum) .exchange::("uniswap_v2", tvl_filter.clone(), None) diff --git a/examples/quickstart/main.rs b/examples/quickstart/main.rs index f2d50a74..d63bb598 100644 --- a/examples/quickstart/main.rs +++ b/examples/quickstart/main.rs @@ -36,7 +36,9 @@ async fn main() { let tvl_threshold = 10_000.0; let tvl_filter = ComponentFilter::with_tvl_range(tvl_threshold, tvl_threshold); - let all_tokens = load_all_tokens(tycho_url.as_str(), false, Some(tycho_api_key.as_str())).await; + let all_tokens = + load_all_tokens(tycho_url.as_str(), false, Some(tycho_api_key.as_str()), Chain::Ethereum) + .await; let mut pairs: HashMap> = HashMap::new(); let mut protocol_stream = ProtocolStreamBuilder::new(&tycho_url, Chain::Ethereum) diff --git a/src/utils.rs b/src/utils.rs index fbb93c01..1e8782fb 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -40,6 +40,7 @@ pub async fn load_all_tokens( tycho_url: &str, no_tls: bool, auth_key: Option<&str>, + chain: Chain, ) -> HashMap { let rpc_url = if no_tls { format!("http://{tycho_url}") } else { format!("https://{tycho_url}") }; @@ -47,7 +48,7 @@ pub async fn load_all_tokens( #[allow(clippy::mutable_key_type)] rpc_client - .get_all_tokens(Chain::Ethereum, Some(100), Some(42), 3_000) + .get_all_tokens(chain, Some(100), Some(42), 3_000) .await .expect("Unable to load tokens") .into_iter() From 87e4e273703bbe2e4f5effa2f7725615255f1c47 Mon Sep 17 00:00:00 2001 From: Louise Poole Date: Wed, 5 Feb 2025 11:39:09 +0200 Subject: [PATCH 4/4] chore: update tycho version to 0.55.2 This includes conversion support on all dto enums --- Cargo.lock | 8 ++++---- Cargo.toml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd18dadd..a739ac8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7071,8 +7071,8 @@ dependencies = [ [[package]] name = "tycho-client" -version = "0.55.1" -source = "git+https://github.com/propeller-heads/tycho-indexer.git?tag=0.55.1#d59ff21403f2e628e3ec59882c1be3ca287d0303" +version = "0.55.2" +source = "git+https://github.com/propeller-heads/tycho-indexer.git?tag=0.55.2#dfa50d5e318253001938655a49aa3e05f958d89e" dependencies = [ "anyhow", "async-trait", @@ -7097,8 +7097,8 @@ dependencies = [ [[package]] name = "tycho-core" -version = "0.55.1" -source = "git+https://github.com/propeller-heads/tycho-indexer.git?tag=0.55.1#d59ff21403f2e628e3ec59882c1be3ca287d0303" +version = "0.55.2" +source = "git+https://github.com/propeller-heads/tycho-indexer.git?tag=0.55.2#dfa50d5e318253001938655a49aa3e05f958d89e" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 7065763b..a5f232fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,8 +38,8 @@ mini-moka = "0.10" lazy_static = "1.4.0" # Tycho dependencies -tycho-core = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-core", tag = "0.55.1" } -tycho-client = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-client", tag = "0.55.1" } +tycho-core = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-core", tag = "0.55.2" } +tycho-client = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-client", tag = "0.55.2" } # EVM dependencies foundry-config = { git = "https://github.com/foundry-rs/foundry", rev = "57bb12e", optional = true }