From 9df366b29df15fcaf072389cd54a41bd8ad072cf Mon Sep 17 00:00:00 2001 From: kayibal Date: Wed, 7 Aug 2024 13:30:44 +0200 Subject: [PATCH] fix(balancer): Change pool_id encoding to utf-8. Since it is used to replace component_id, it should be a string as well. --- substreams/ethereum-balancer/Readme.md | 2 +- .../ethereum-balancer/src/pool_factories.rs | 35 +++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/substreams/ethereum-balancer/Readme.md b/substreams/ethereum-balancer/Readme.md index 566d94a..b918fde 100644 --- a/substreams/ethereum-balancer/Readme.md +++ b/substreams/ethereum-balancer/Readme.md @@ -16,7 +16,7 @@ This is planned to be resolved with the dynamic contract indexing module. |--------------------|-------|---------------------------------------------------------------------------------------------------------| | pool_type | str | A unique identifier per pool type. Set depending on the factory | | normalized weights | json | The normalised weights of a weighted pool. | -| pool_id | bytes | The balancer pool id. | +| pool_id | str | A hex encoded balancer pool id. | | rate_providers | json | A list of rate provider addresses. | | bpt | bytes | The balancer lp token, set if the pool support entering and exiting lp postions via the swap interface. | | main_token | bytes | The main token address for a linear pool | diff --git a/substreams/ethereum-balancer/src/pool_factories.rs b/substreams/ethereum-balancer/src/pool_factories.rs index 8e280f8..890e0a9 100644 --- a/substreams/ethereum-balancer/src/pool_factories.rs +++ b/substreams/ethereum-balancer/src/pool_factories.rs @@ -70,7 +70,10 @@ pub fn address_map( "normalized_weights", &json_serialize_bigint_list(&create_call.normalized_weights), ), - ("pool_id", &pool_registered.pool_id), + ( + "pool_id", + format!("0x{}", hex::encode(pool_registered.pool_id)).as_bytes(), + ), ( "rate_providers", &json_serialize_address_list(&create_call.rate_providers), @@ -100,7 +103,10 @@ pub fn address_map( .with_tokens(&tokens_registered.tokens) .with_attributes(&[ ("pool_type", "ComposableStablePoolFactory".as_bytes()), - ("pool_id", &pool_registered.pool_id), + ( + "pool_id", + format!("0x{}", hex::encode(pool_registered.pool_id)).as_bytes(), + ), ("bpt", &pool_created.pool), ( "fee", @@ -137,7 +143,10 @@ pub fn address_map( .upper_target .to_signed_bytes_be(), ), - ("pool_id", &pool_registered.pool_id), + ( + "pool_id", + format!("0x{}", hex::encode(pool_registered.pool_id)).as_bytes(), + ), ("manual_updates", &[1u8]), ("bpt", &pool_created.pool), ("main_token", &create_call.main_token), @@ -172,7 +181,10 @@ pub fn address_map( .upper_target .to_signed_bytes_be(), ), - ("pool_id", &pool_registered.pool_id), + ( + "pool_id", + format!("0x{}", hex::encode(pool_registered.pool_id)).as_bytes(), + ), ("manual_updates", &[1u8]), ("bpt", &pool_created.pool), ("main_token", &create_call.main_token), @@ -255,7 +267,10 @@ pub fn address_map( .upper_target .to_signed_bytes_be(), ), - ("pool_id", &pool_registered.pool_id), + ( + "pool_id", + format!("0x{}", hex::encode(pool_registered.pool_id)).as_bytes(), + ), ("manual_updates", &[1u8]), ("bpt", &pool_created.pool), ("main_token", &create_call.main_token), @@ -290,7 +305,10 @@ pub fn address_map( .upper_target .to_signed_bytes_be(), ), - ("pool_id", &pool_registered.pool_id), + ( + "pool_id", + format!("0x{}", hex::encode(pool_registered.pool_id)).as_bytes(), + ), ("manual_updates", &[1u8]), ("bpt", &pool_created.pool), ("main_token", &create_call.main_token), @@ -321,7 +339,10 @@ pub fn address_map( .with_attributes(&[ ("pool_type", "WeightedPool2TokensFactory".as_bytes()), ("weights", &json_serialize_bigint_list(&create_call.weights)), - ("pool_id", &pool_registered.pool_id), + ( + "pool_id", + format!("0x{}", hex::encode(pool_registered.pool_id)).as_bytes(), + ), ( "fee", &create_call