diff --git a/substreams/Cargo.lock b/substreams/Cargo.lock index 0cce934..0b3e18b 100644 --- a/substreams/Cargo.lock +++ b/substreams/Cargo.lock @@ -261,7 +261,7 @@ dependencies = [ ] [[package]] -name = "ethereum-ekubo" +name = "ethereum-ekubo-v2" version = "0.1.0" dependencies = [ "anyhow", @@ -274,7 +274,7 @@ dependencies = [ "serde_qs", "substreams", "substreams-ethereum", - "substreams-helper 0.0.2", + "substreams-helper 0.0.2 (git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=e4609be)", "tycho-substreams 0.2.0 (git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=3c08359)", ] @@ -1470,6 +1470,29 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "substreams-helper" +version = "0.0.2" +source = "git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=e4609be#e4609bed0bb3c73a13864a951b8cb64c523bc148" +dependencies = [ + "anyhow", + "base64", + "bigdecimal", + "downcast-rs", + "ethabi 18.0.0", + "hex", + "hex-literal 0.4.1", + "num-bigint", + "pad", + "prost 0.11.9", + "prost-types 0.12.6", + "substreams", + "substreams-entity-change", + "substreams-ethereum", + "thiserror 1.0.69", + "tiny-keccak", +] + [[package]] name = "substreams-macro" version = "0.5.22" diff --git a/substreams/Cargo.toml b/substreams/Cargo.toml index 39918e5..f7771ce 100644 --- a/substreams/Cargo.toml +++ b/substreams/Cargo.toml @@ -14,7 +14,7 @@ members = [ "ethereum-template-factory", "ethereum-template-singleton", "ethereum-uniswap-v4", - "ethereum-ekubo", + "ethereum-ekubo-v2", ] resolver = "2" diff --git a/substreams/ethereum-ekubo/.cargo/config.toml b/substreams/ethereum-ekubo-v2/.cargo/config.toml similarity index 100% rename from substreams/ethereum-ekubo/.cargo/config.toml rename to substreams/ethereum-ekubo-v2/.cargo/config.toml diff --git a/substreams/ethereum-ekubo/Cargo.toml b/substreams/ethereum-ekubo-v2/Cargo.toml similarity index 75% rename from substreams/ethereum-ekubo/Cargo.toml rename to substreams/ethereum-ekubo-v2/Cargo.toml index c5a917f..3d50afc 100644 --- a/substreams/ethereum-ekubo/Cargo.toml +++ b/substreams/ethereum-ekubo-v2/Cargo.toml @@ -1,18 +1,18 @@ [package] -name = "ethereum-ekubo" +name = "ethereum-ekubo-v2" version = "0.1.0" edition = "2021" [lib] -name = "ethereum_ekubo" +name = "ethereum_ekubo_v2" crate-type = ["cdylib"] [dependencies] substreams = "0.5.22" substreams-ethereum = "0.9.9" -substreams-helper = { path = "../crates/substreams-helper" } # TODO Update to git once pushed -prost = "0.11" +substreams-helper = { git = "https://github.com/propeller-heads/tycho-protocol-sdk.git", rev = "e4609be" } tycho-substreams = { git = "https://github.com/propeller-heads/tycho-protocol-sdk.git", rev = "3c08359" } +prost = "0.11" anyhow = "1.0.95" ethabi = "18.0.0" num-bigint = "0.4.6" diff --git a/substreams/ethereum-ekubo/abi/core.json b/substreams/ethereum-ekubo-v2/abi/core.json similarity index 100% rename from substreams/ethereum-ekubo/abi/core.json rename to substreams/ethereum-ekubo-v2/abi/core.json diff --git a/substreams/ethereum-ekubo/buf.gen.yaml b/substreams/ethereum-ekubo-v2/buf.gen.yaml similarity index 100% rename from substreams/ethereum-ekubo/buf.gen.yaml rename to substreams/ethereum-ekubo-v2/buf.gen.yaml diff --git a/substreams/ethereum-ekubo/build.rs b/substreams/ethereum-ekubo-v2/build.rs similarity index 100% rename from substreams/ethereum-ekubo/build.rs rename to substreams/ethereum-ekubo-v2/build.rs diff --git a/substreams/ethereum-ekubo-v2/integration_test.tycho.yaml b/substreams/ethereum-ekubo-v2/integration_test.tycho.yaml new file mode 100644 index 0000000..91a9126 --- /dev/null +++ b/substreams/ethereum-ekubo-v2/integration_test.tycho.yaml @@ -0,0 +1,24 @@ +adapter_contract: "EkuboSwapAdapter" +adapter_build_signature: "constructor(address)" +adapter_build_args: "0x16e186ecdc94083fff53ef2a41d46b92a54f61e2" +skip_balance_check: true # Fails because the pool id is not the owner of the tokens. Needs to be address in the testing framework. +protocol_type_names: + - "ekubo_v2_pool" +tests: + - name: test_pool_creation + start_block: 22048334 + stop_block: 22048335 + expected_components: + - id: "0x3565d037d3f435ba5dc6381a9f4dc03d3db8d96c0100f7271b4bbeba3b6b2c14" + tokens: + - "0x0000000000000000000000000000000000000000" + - "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" + static_attributes: + token0: "0x0000000000000000000000000000000000000000" + token1: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" + fee: "0x0000000000000000" + tick_spacing: "0x00000000" + extension_id: "0x00000000" + extension: "0x514d5de68852628af2f1236f780866989660ada6" + creation_tx: "0x7c2e697e73dc1f114a5473d1015c411f10585b2b671bee0bd6d5706895e16b27" + skip_simulation: true # Native implementation diff --git a/substreams/ethereum-ekubo/proto/ekubo.proto b/substreams/ethereum-ekubo-v2/proto/ekubo.proto similarity index 100% rename from substreams/ethereum-ekubo/proto/ekubo.proto rename to substreams/ethereum-ekubo-v2/proto/ekubo.proto diff --git a/substreams/ethereum-ekubo/src/abi/core.rs b/substreams/ethereum-ekubo-v2/src/abi/core.rs similarity index 100% rename from substreams/ethereum-ekubo/src/abi/core.rs rename to substreams/ethereum-ekubo-v2/src/abi/core.rs diff --git a/substreams/ethereum-ekubo/src/abi/mod.rs b/substreams/ethereum-ekubo-v2/src/abi/mod.rs similarity index 100% rename from substreams/ethereum-ekubo/src/abi/mod.rs rename to substreams/ethereum-ekubo-v2/src/abi/mod.rs diff --git a/substreams/ethereum-ekubo/src/deployment_config.rs b/substreams/ethereum-ekubo-v2/src/deployment_config.rs similarity index 100% rename from substreams/ethereum-ekubo/src/deployment_config.rs rename to substreams/ethereum-ekubo-v2/src/deployment_config.rs diff --git a/substreams/ethereum-ekubo/src/lib.rs b/substreams/ethereum-ekubo-v2/src/lib.rs similarity index 100% rename from substreams/ethereum-ekubo/src/lib.rs rename to substreams/ethereum-ekubo-v2/src/lib.rs diff --git a/substreams/ethereum-ekubo/src/modules/1_map_events.rs b/substreams/ethereum-ekubo-v2/src/modules/1_map_events.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/1_map_events.rs rename to substreams/ethereum-ekubo-v2/src/modules/1_map_events.rs diff --git a/substreams/ethereum-ekubo/src/modules/2_map_components.rs b/substreams/ethereum-ekubo-v2/src/modules/2_map_components.rs similarity index 91% rename from substreams/ethereum-ekubo/src/modules/2_map_components.rs rename to substreams/ethereum-ekubo-v2/src/modules/2_map_components.rs index 37a7d9a..41ed9ee 100644 --- a/substreams/ethereum-ekubo/src/modules/2_map_components.rs +++ b/substreams/ethereum-ekubo-v2/src/modules/2_map_components.rs @@ -1,5 +1,5 @@ use itertools::Itertools; -use substreams::scalar::BigInt; +use substreams::{hex, scalar::BigInt}; use substreams_helper::hex::Hexable; use tycho_substreams::models::{ Attribute, BalanceChange, BlockChanges, ChangeType, EntityChanges, FinancialType, @@ -57,7 +57,7 @@ fn maybe_create_component( contracts: vec![], change: ChangeType::Creation.into(), protocol_type: Some(ProtocolType { - name: "ekubo".to_string(), + name: "ekubo_v2_pool".to_string(), financial_type: FinancialType::Swap.into(), implementation_type: ImplementationType::Custom.into(), attribute_schema: vec![], @@ -114,6 +114,12 @@ fn maybe_create_component( name: "sqrt_ratio".to_string(), value: pi.sqrt_ratio, }, + Attribute { + change: ChangeType::Creation.into(), + name: "balance_owner".to_string(), /* TODO: We should use AccountBalances + * instead */ + value: hex!("e0e0e08A6A4b9Dc7bD67BCB7aadE5cF48157d444").to_vec(), + }, ], }, vec![ diff --git a/substreams/ethereum-ekubo/src/modules/2_map_tick_changes.rs b/substreams/ethereum-ekubo-v2/src/modules/2_map_tick_changes.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/2_map_tick_changes.rs rename to substreams/ethereum-ekubo-v2/src/modules/2_map_tick_changes.rs diff --git a/substreams/ethereum-ekubo/src/modules/2_store_active_ticks.rs b/substreams/ethereum-ekubo-v2/src/modules/2_store_active_ticks.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/2_store_active_ticks.rs rename to substreams/ethereum-ekubo-v2/src/modules/2_store_active_ticks.rs diff --git a/substreams/ethereum-ekubo/src/modules/3_map_liquidity_changes.rs b/substreams/ethereum-ekubo-v2/src/modules/3_map_liquidity_changes.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/3_map_liquidity_changes.rs rename to substreams/ethereum-ekubo-v2/src/modules/3_map_liquidity_changes.rs diff --git a/substreams/ethereum-ekubo/src/modules/3_store_pool_details.rs b/substreams/ethereum-ekubo-v2/src/modules/3_store_pool_details.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/3_store_pool_details.rs rename to substreams/ethereum-ekubo-v2/src/modules/3_store_pool_details.rs diff --git a/substreams/ethereum-ekubo/src/modules/3_store_tick_liquidities.rs b/substreams/ethereum-ekubo-v2/src/modules/3_store_tick_liquidities.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/3_store_tick_liquidities.rs rename to substreams/ethereum-ekubo-v2/src/modules/3_store_tick_liquidities.rs diff --git a/substreams/ethereum-ekubo/src/modules/4_map_balance_changes.rs b/substreams/ethereum-ekubo-v2/src/modules/4_map_balance_changes.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/4_map_balance_changes.rs rename to substreams/ethereum-ekubo-v2/src/modules/4_map_balance_changes.rs diff --git a/substreams/ethereum-ekubo/src/modules/4_store_liquidities.rs b/substreams/ethereum-ekubo-v2/src/modules/4_store_liquidities.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/4_store_liquidities.rs rename to substreams/ethereum-ekubo-v2/src/modules/4_store_liquidities.rs diff --git a/substreams/ethereum-ekubo/src/modules/5_store_balance_changes.rs b/substreams/ethereum-ekubo-v2/src/modules/5_store_balance_changes.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/5_store_balance_changes.rs rename to substreams/ethereum-ekubo-v2/src/modules/5_store_balance_changes.rs diff --git a/substreams/ethereum-ekubo/src/modules/6_map_protocol_changes.rs b/substreams/ethereum-ekubo-v2/src/modules/6_map_protocol_changes.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/6_map_protocol_changes.rs rename to substreams/ethereum-ekubo-v2/src/modules/6_map_protocol_changes.rs diff --git a/substreams/ethereum-ekubo/src/modules/mod.rs b/substreams/ethereum-ekubo-v2/src/modules/mod.rs similarity index 100% rename from substreams/ethereum-ekubo/src/modules/mod.rs rename to substreams/ethereum-ekubo-v2/src/modules/mod.rs diff --git a/substreams/ethereum-ekubo/src/pb/ekubo.rs b/substreams/ethereum-ekubo-v2/src/pb/ekubo.rs similarity index 100% rename from substreams/ethereum-ekubo/src/pb/ekubo.rs rename to substreams/ethereum-ekubo-v2/src/pb/ekubo.rs diff --git a/substreams/ethereum-ekubo/src/pb/mod.rs b/substreams/ethereum-ekubo-v2/src/pb/mod.rs similarity index 100% rename from substreams/ethereum-ekubo/src/pb/mod.rs rename to substreams/ethereum-ekubo-v2/src/pb/mod.rs diff --git a/substreams/ethereum-ekubo/src/pool_config.rs b/substreams/ethereum-ekubo-v2/src/pool_config.rs similarity index 100% rename from substreams/ethereum-ekubo/src/pool_config.rs rename to substreams/ethereum-ekubo-v2/src/pool_config.rs diff --git a/substreams/ethereum-ekubo/src/sqrt_ratio.rs b/substreams/ethereum-ekubo-v2/src/sqrt_ratio.rs similarity index 100% rename from substreams/ethereum-ekubo/src/sqrt_ratio.rs rename to substreams/ethereum-ekubo-v2/src/sqrt_ratio.rs diff --git a/substreams/ethereum-ekubo/substreams.yaml b/substreams/ethereum-ekubo-v2/substreams.yaml similarity index 94% rename from substreams/ethereum-ekubo/substreams.yaml rename to substreams/ethereum-ekubo-v2/substreams.yaml index 99aa0c3..c1995b8 100644 --- a/substreams/ethereum-ekubo/substreams.yaml +++ b/substreams/ethereum-ekubo-v2/substreams.yaml @@ -1,7 +1,8 @@ specVersion: v0.1.0 package: - name: "ethereum_ekubo" + name: "ethereum_ekubo_v2" version: v0.1.0 + url: "https://github.com/propeller-heads/tycho-protocol-sdk/tree/main/substreams/ethereum-ekubo-v2" protobuf: files: @@ -12,14 +13,13 @@ protobuf: - ../../proto - ./proto excludePaths: - - sf/substreams - google - tycho binaries: default: type: wasm/rust-v1 - file: ../target/wasm32-unknown-unknown/release/ethereum_ekubo.wasm + file: ../target/wasm32-unknown-unknown/release/ethereum_ekubo_v2.wasm network: ethereum networks: diff --git a/substreams/ethereum-ekubo/integration_test.tycho.yaml b/substreams/ethereum-ekubo/integration_test.tycho.yaml deleted file mode 100644 index 76187be..0000000 --- a/substreams/ethereum-ekubo/integration_test.tycho.yaml +++ /dev/null @@ -1,23 +0,0 @@ -adapter_contract: "EkuboSwapAdapter" -adapter_build_signature: "constructor(address)" -adapter_build_args: "0x16e186ecdc94083fff53ef2a41d46b92a54f61e2" -skip_balance_check: true # This seems to fail because testing/src/runner:TestRunner.validate_state tries to interpret the component id as an Ethereum address? -protocol_type_names: - - "ekubo" -tests: - - name: test_pool_creation - start_block: 7811236 - stop_block: 7811283 - expected_components: - - id: "0xae76f216ce250b7b9a388d59cbbf92407d7ccee71a99b27ad521508b1c74681f" - tokens: - - "0x0000000000000000000000000000000000000000" - - "0xb1b388f2ef1bb1f7979f009381f797f94b90c094" - static_attributes: - token0: "0x0000000000000000000000000000000000000000" - token1: "0xb1b388f2ef1bb1f7979f009381f797f94b90c094" - fee: "0x00c49ba5e353f7ce" - tick_spacing: "0x0000175e" - extension: "0x0000000000000000000000000000000000000000" - creation_tx: "0x4b39d41ae3b823409ba6a92e2937f52f545acfd9cb7ecf7fb8eb7ea2e3b9985e" - skip_simulation: false