Files
tycho-protocol-sdk/substreams/ethereum-balancer-v3/build.rs
mrBovo fc0fb1e540 BalancerV3: SwapAdapter and Substreams (#126)
* feat: add balancer swapAdapter and Substreams

* fix: undo tycho-substreams logs, ignore abi on rustmft

* ci: prevent warnings from failing CI

* ci: skip size check on CI

* chore: forge fmt

* feat: vault balance from storage

Vault contract tokenBalance message are set according to the vault
storage changes in the `_reserveOf` storage variable VaultStorage.sol
contract
This was the culprit that caused the failure in simulation since
balancer enforces the invariant that `token.balanceOf(vault_addr) == _reservesOf[token]`

* ci: warnings

* fix: avoid duplicated balance changes

* fix: order by ordinal

* chore: format

* feat: extract new contracts before extracting balance changes

* feat: skip unnecessary steps if no balance change is found

* refactor: filter out account balances for tokens that aren't part of any protocol components.

On the indexer side, when we receive an account balance, we need to know about the token. This commit ensure that the token was introduced before we emit any account balance with it.

* refactor: don't index liquidity buffers.

Liquidity buffers rely on rate providers. Therefore we need DCI (feature to be able to index previously created contract) to deal with them.

* refactor: cleanup tests and add docstrings

* chore: lock tycho-substreams version

* ci: set Foundry workflow to use stable foundry

* feat(DCI): Add DCI Entrypoints to BalancerV3 components (#218)

* refactor: fix typo in weighted_pool_factory_contract name

* feat: add rate_providers static attributes

* feat: add DCI entrypoints to BalancerV3 components

* fix: set default trade price to Fraction(0, 1)

* feat: remove buffers as components

Buffers are to be used internally by Boosted pools (stable/weighted pools that use ERC4626 tokens). They are not to be treated as a separate swap component.

* test: update test blocks

Extend tests some tests block range to ensure liquidity was added to the pool and can be simulated on

* feat: remove buffers as components

Remove balance updates for buffer components

* feat: listen for pool pause/unpause events

* chore: formating

* fix: encoding call data

* test: update Balancer V3 tests to use DCI

* test: set indexer log level to info

* docs: add comment on support of boosted pools

* feat: update balancer v3 package version

---------

Co-authored-by: Thales <thales@datarevenue.com>
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
Co-authored-by: Louise Poole <louise@datarevenue.com>
Co-authored-by: Louise Poole <louisecarmenpoole@gmail.com>
2025-06-26 12:19:39 +02:00

51 lines
1.6 KiB
Rust

#![allow(clippy::all)]
use anyhow::{Ok, Result};
use regex::Regex;
use std::fs;
use substreams_ethereum::Abigen;
fn main() -> Result<(), anyhow::Error> {
let file_names = [
"abi/vault_contract.abi.json",
"abi/stable_pool_factory_contract.abi.json",
"abi/weighted_pool_factory_contract.abi.json",
"abi/stable_pool_contract.abi.json",
"abi/weighted_pool_contract.abi.json",
];
let file_output_names = [
"src/abi/vault_contract.rs",
"src/abi/stable_pool_factory_contract.rs",
"src/abi/weighted_pool_factory_contract.rs",
"src/abi/stable_pool_contract.rs",
"src/abi/weighted_pool_contract.rs",
];
let mut i = 0;
for f in file_names {
let contents = fs::read_to_string(f).expect("Should have been able to read the file");
// sanitize fields and attributes starting with an underscore
let regex = Regex::new(r#"("\w+"\s?:\s?")_(\w+")"#).unwrap();
let sanitized_abi_file = regex.replace_all(contents.as_str(), "${1}u_${2}");
// sanitize fields and attributes with multiple consecutive underscores
let re = Regex::new(r"_+").unwrap();
let re_sanitized_abi_file =
re.replace_all(&sanitized_abi_file, |caps: &regex::Captures| {
let count = caps[0].len();
let replacement = format!("{}_", "_u".repeat(count - 1));
replacement
});
Abigen::from_bytes("Contract", re_sanitized_abi_file.as_bytes())?
.generate()?
.write_to_file(file_output_names[i])?;
i = i + 1;
}
Ok(())
}