fix(balancer): miscellaneous improvements before resync (#104)

* fix(balancer): ignore self balance change

Euler pool emit a balance change for the pool itself. We don't want to have it because it's an unknown token from Tycho's perspective.

example: https://etherscan.io/tx/0x4a9ea683052afefdae3d189862868c3a7dc8f431d1d9828b6bfd9451a8816426#eventlog#338

* refactor(balancer): rename balancer module to balancer-v2

* ci: make clippy happy

---------

Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
This commit is contained in:
Zizou
2024-10-31 20:12:37 +07:00
committed by GitHub
parent 64ca72cfa9
commit eea8b27112
44 changed files with 31 additions and 26 deletions

4
substreams/Cargo.lock generated
View File

@@ -221,8 +221,8 @@ dependencies = [
] ]
[[package]] [[package]]
name = "ethereum-balancer" name = "ethereum-balancer-v2"
version = "0.2.2" version = "0.2.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",

View File

@@ -1,6 +1,6 @@
[workspace] [workspace]
members = [ members = [
"ethereum-balancer", "ethereum-balancer-v2",
"ethereum-curve", "ethereum-curve",
"crates/tycho-substreams", "crates/tycho-substreams",
"crates/substreams-helper", "crates/substreams-helper",
@@ -8,7 +8,7 @@ members = [
"ethereum-uniswap-v2", "ethereum-uniswap-v2",
"ethereum-uniswap-v3", "ethereum-uniswap-v3",
"ethereum-sfrax", "ethereum-sfrax",
"ethereum-sfraxeth" "ethereum-sfraxeth",
] ]
resolver = "2" resolver = "2"

View File

@@ -1,10 +1,10 @@
[package] [package]
name = "ethereum-balancer" name = "ethereum-balancer-v2"
version = "0.2.2" version = "0.2.3"
edition = "2021" edition = "2021"
[lib] [lib]
name = "ethereum_balancer" name = "ethereum_balancer_v2"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]

View File

@@ -1,6 +1,6 @@
substreams_yaml_path: ./substreams.yaml substreams_yaml_path: ./substreams.yaml
protocol_type_names: protocol_type_names:
- "balancer_pool" - "balancer_v2_pool"
adapter_contract: "BalancerV2SwapAdapter" adapter_contract: "BalancerV2SwapAdapter"
adapter_build_signature: "constructor(address)" adapter_build_signature: "constructor(address)"
adapter_build_args: "0xBA12222222228d8Ba445958a75a0704d566BF2C8" adapter_build_args: "0xBA12222222228d8Ba445958a75a0704d566BF2C8"

View File

@@ -79,7 +79,12 @@ pub fn map_relative_balances(
.get_last(format!("pool:{}", &component_id[..42])) .get_last(format!("pool:{}", &component_id[..42]))
.is_some() .is_some()
{ {
for (token, delta) in ev.tokens.iter().zip(ev.deltas.iter()) { for (token, delta) in ev
.tokens
.iter()
.zip(ev.deltas.iter())
.filter(|(token, _)| **token != hex::decode(&component_id[2..42]).unwrap())
{
deltas.push(BalanceDelta { deltas.push(BalanceDelta {
ord: vault_log.ordinal(), ord: vault_log.ordinal(),
tx: Some(vault_log.receipt.transaction.into()), tx: Some(vault_log.receipt.transaction.into()),

View File

@@ -77,7 +77,7 @@ pub fn address_map(
), ),
("manual_updates", &[1u8]), ("manual_updates", &[1u8]),
]) ])
.as_swap_type("balancer_pool", ImplementationType::Vm), .as_swap_type("balancer_v2_pool", ImplementationType::Vm),
) )
} }
hex!("cC508a455F5b0073973107Db6a878DdBDab957bC") => { hex!("cC508a455F5b0073973107Db6a878DdBDab957bC") => {
@@ -109,7 +109,7 @@ pub fn address_map(
), ),
("manual_updates", &[1u8]), ("manual_updates", &[1u8]),
]) ])
.as_swap_type("balancer_pool", ImplementationType::Vm), .as_swap_type("balancer_v2_pool", ImplementationType::Vm),
) )
} }
hex!("5Dd94Da3644DDD055fcf6B3E1aa310Bb7801EB8b") => { hex!("5Dd94Da3644DDD055fcf6B3E1aa310Bb7801EB8b") => {
@@ -141,7 +141,7 @@ pub fn address_map(
), ),
("manual_updates", &[1u8]), ("manual_updates", &[1u8]),
]) ])
.as_swap_type("balancer_pool", ImplementationType::Vm), .as_swap_type("balancer_v2_pool", ImplementationType::Vm),
) )
} }
hex!("897888115Ada5773E02aA29F775430BFB5F34c51") => { hex!("897888115Ada5773E02aA29F775430BFB5F34c51") => {
@@ -173,7 +173,7 @@ pub fn address_map(
), ),
("manual_updates", &[1u8]), ("manual_updates", &[1u8]),
]) ])
.as_swap_type("balancer_pool", ImplementationType::Vm), .as_swap_type("balancer_v2_pool", ImplementationType::Vm),
) )
} }
hex!("DB8d758BCb971e482B2C45f7F8a7740283A1bd3A") => { hex!("DB8d758BCb971e482B2C45f7F8a7740283A1bd3A") => {
@@ -203,7 +203,7 @@ pub fn address_map(
("rate_providers", &json_serialize_address_list(&create_call.rate_providers)), ("rate_providers", &json_serialize_address_list(&create_call.rate_providers)),
("manual_updates", &[1u8]), ("manual_updates", &[1u8]),
]) ])
.as_swap_type("balancer_pool", ImplementationType::Vm), .as_swap_type("balancer_v2_pool", ImplementationType::Vm),
) )
} }
hex!("813EE7a840CE909E7Fea2117A44a90b8063bd4fd") => { hex!("813EE7a840CE909E7Fea2117A44a90b8063bd4fd") => {
@@ -240,7 +240,7 @@ pub fn address_map(
.to_signed_bytes_be(), .to_signed_bytes_be(),
), ),
]) ])
.as_swap_type("balancer_pool", ImplementationType::Vm), .as_swap_type("balancer_v2_pool", ImplementationType::Vm),
) )
} }
hex!("5F43FBa61f63Fa6bFF101a0A0458cEA917f6B347") => { hex!("5F43FBa61f63Fa6bFF101a0A0458cEA917f6B347") => {
@@ -277,7 +277,7 @@ pub fn address_map(
.to_signed_bytes_be(), .to_signed_bytes_be(),
), ),
]) ])
.as_swap_type("balancer_pool", ImplementationType::Vm), .as_swap_type("balancer_v2_pool", ImplementationType::Vm),
) )
} }
// ❌ Reading the deployed factory for Gearbox showcases that it's currently disabled // ❌ Reading the deployed factory for Gearbox showcases that it's currently disabled
@@ -362,7 +362,7 @@ pub fn address_map(
.to_signed_bytes_be(), .to_signed_bytes_be(),
), ),
]) ])
.as_swap_type("balancer_pool", ImplementationType::Vm), .as_swap_type("balancer_v2_pool", ImplementationType::Vm),
) )
} }
hex!("5F5222Ffa40F2AEd6380D022184D6ea67C776eE0") => { hex!("5F5222Ffa40F2AEd6380D022184D6ea67C776eE0") => {
@@ -399,7 +399,7 @@ pub fn address_map(
.to_signed_bytes_be(), .to_signed_bytes_be(),
), ),
]) ])
.as_swap_type("balancer_pool", ImplementationType::Vm), .as_swap_type("balancer_v2_pool", ImplementationType::Vm),
) )
} }
// The `WeightedPool2TokenFactory` is a deprecated contract, but we've included // The `WeightedPool2TokenFactory` is a deprecated contract, but we've included
@@ -429,7 +429,7 @@ pub fn address_map(
), ),
("manual_updates", &[1u8]), ("manual_updates", &[1u8]),
]) ])
.as_swap_type("balancer_pool", ImplementationType::Vm), .as_swap_type("balancer_v2_pool", ImplementationType::Vm),
) )
} }
_ => None, _ => None,

View File

@@ -1,7 +1,7 @@
specVersion: v0.1.0 specVersion: v0.1.0
package: package:
name: "ethereum_balancer" name: "ethereum_balancer_v2"
version: v0.2.2 version: v0.2.3
protobuf: protobuf:
files: files:
@@ -14,7 +14,7 @@ protobuf:
binaries: binaries:
default: default:
type: wasm/rust-v1 type: wasm/rust-v1
file: ../target/wasm32-unknown-unknown/release/ethereum_balancer.wasm file: ../target/wasm32-unknown-unknown/release/ethereum_balancer_v2.wasm
modules: modules:
- name: map_components - name: map_components

View File

@@ -10,7 +10,7 @@ use_field_init_shorthand = true
chain_width = 40 chain_width = 40
ignore = [ ignore = [
"crates/tycho-substreams/src/pb", "crates/tycho-substreams/src/pb",
"ethereum-balancer/src/abi", "ethereum-balancer-v2/src/abi",
"ethereum-sfraxeth/src/abi", "ethereum-sfraxeth/src/abi",
"ethereum-curve/src/abi", "ethereum-curve/src/abi",
"ethereum-uniswap-v2/src/abi", "ethereum-uniswap-v2/src/abi",

View File

@@ -97,14 +97,14 @@ python ./testing/src/runner/cli.py --package "your-package-name"
#### Example #### Example
If you want to run tests for `ethereum-balancer`, use: If you want to run tests for `ethereum-balancer-v2`, use:
```bash ```bash
conda activate propeller-protocol-lib-testing conda activate propeller-protocol-lib-testing
export RPC_URL="https://ethereum-mainnet.core.chainstack.com/123123123123" export RPC_URL="https://ethereum-mainnet.core.chainstack.com/123123123123"
export SUBSTREAMS_API_TOKEN=eyJhbGci... export SUBSTREAMS_API_TOKEN=eyJhbGci...
docker compose up -d db docker compose up -d db
python ./testing/src/runner/cli.py --package "ethereum-balancer" python ./testing/src/runner/cli.py --package "ethereum-balancer-v2"
``` ```
#### Testing CLI args #### Testing CLI args

View File

@@ -305,7 +305,7 @@ class TestRunner:
data = yaml.safe_load(file) data = yaml.safe_load(file)
modify_func(data) modify_func(data)
spkg_name = f"{yaml_file_path.rsplit('/', 1)[0]}/{data['package']['name'].replace('_', '-', 1)}-{data['package']['version']}.spkg" spkg_name = f"{yaml_file_path.rsplit('/', 1)[0]}/{data['package']['name'].replace('_', '-')}-{data['package']['version']}.spkg"
with open(yaml_file_path, "w") as file: with open(yaml_file_path, "w") as file:
yaml.dump(data, file, default_flow_style=False) yaml.dump(data, file, default_flow_style=False)