From 20165c271ef11df84f6dbb33a46430fe37d86b01 Mon Sep 17 00:00:00 2001 From: Louise Poole Date: Tue, 18 Feb 2025 15:01:38 +0200 Subject: [PATCH] feat: move initial lp fee to static attributes (#161) This initial lp fee value is used for generating the PoolKey. It is static and should be part of the ProtocolComponent static attributes. --- substreams/Cargo.lock | 2 +- substreams/ethereum-uniswap-v4/Cargo.toml | 2 +- .../ethereum-uniswap-v4/base-uniswap-v4.yaml | 2 +- .../ethereum-uniswap-v4.yaml | 2 +- .../src/modules/1_map_pool_created.rs | 23 ++++++++++--------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/substreams/Cargo.lock b/substreams/Cargo.lock index 5ff1bbe..e87fdc4 100644 --- a/substreams/Cargo.lock +++ b/substreams/Cargo.lock @@ -404,7 +404,7 @@ dependencies = [ [[package]] name = "ethereum-uniswap-v4" -version = "0.1.1" +version = "0.2.0" dependencies = [ "anyhow", "ethabi 18.0.0", diff --git a/substreams/ethereum-uniswap-v4/Cargo.toml b/substreams/ethereum-uniswap-v4/Cargo.toml index 8dba988..219c3bb 100644 --- a/substreams/ethereum-uniswap-v4/Cargo.toml +++ b/substreams/ethereum-uniswap-v4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethereum-uniswap-v4" -version = "0.1.1" +version = "0.2.0" edition = "2021" [lib] diff --git a/substreams/ethereum-uniswap-v4/base-uniswap-v4.yaml b/substreams/ethereum-uniswap-v4/base-uniswap-v4.yaml index 838a925..00436c8 100644 --- a/substreams/ethereum-uniswap-v4/base-uniswap-v4.yaml +++ b/substreams/ethereum-uniswap-v4/base-uniswap-v4.yaml @@ -1,7 +1,7 @@ specVersion: v0.1.0 package: name: "base_uniswap_v4" - version: v0.1.1 + version: v0.2.0 protobuf: files: diff --git a/substreams/ethereum-uniswap-v4/ethereum-uniswap-v4.yaml b/substreams/ethereum-uniswap-v4/ethereum-uniswap-v4.yaml index 69633bf..b13982e 100644 --- a/substreams/ethereum-uniswap-v4/ethereum-uniswap-v4.yaml +++ b/substreams/ethereum-uniswap-v4/ethereum-uniswap-v4.yaml @@ -1,7 +1,7 @@ specVersion: v0.1.0 package: name: "ethereum_uniswap_v4" - version: v0.1.1 + version: v0.2.0 protobuf: files: diff --git a/substreams/ethereum-uniswap-v4/src/modules/1_map_pool_created.rs b/substreams/ethereum-uniswap-v4/src/modules/1_map_pool_created.rs index eb1904a..498d42f 100644 --- a/substreams/ethereum-uniswap-v4/src/modules/1_map_pool_created.rs +++ b/substreams/ethereum-uniswap-v4/src/modules/1_map_pool_created.rs @@ -37,22 +37,11 @@ fn get_new_pools( entity_changes: vec![EntityChanges { component_id: event.id.to_vec().to_hex(), attributes: vec![ - // Represents the pool's LP Fee. The fee is either static or dynamic. - // Static fees are represented in hundredths of a bip, and can be set to a - // value between 0 and 1000000 (100%) and are immutable. If - // the value is set to 0x800000 (1 in the most significant bit of uint24) then - // the pool has a dynamic fee. This pool is initialized - // with 0 fee which can be changed later via hooks (dynamic fee). Attribute { name: "balance_owner".to_string(), value: hex::decode(pool_manager_address).unwrap(), change: ChangeType::Creation.into(), }, - Attribute { - name: "fee".to_string(), - value: event.fee.to_signed_bytes_be(), - change: ChangeType::Creation.into(), - }, Attribute { name: "liquidity".to_string(), value: BigInt::from(0).to_signed_bytes_be(), @@ -102,6 +91,18 @@ fn get_new_pools( value: event.hooks.to_vec(), change: ChangeType::Creation.into(), }, + // Represents the pool's LP Fee. The fee is either static or dynamic. Static + // fees are represented in hundredths of a bip, can be set to a value between 0 + // and 1000000 (100%) and are immutable. If the value is set to 0x800000 then + // the pool is flagged as using dynamic fees. The dynamic fees changes should + // be tracked in state attributes and the flag value set + // here should remain untouched (it is needed for + // generating the PoolKey for contract interactions). + Attribute { + name: "key_lp_fee".to_string(), + value: event.fee.to_signed_bytes_be(), + change: ChangeType::Creation.into(), + }, ], change: i32::from(ChangeType::Creation), protocol_type: Some(ProtocolType {