* 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>
* fix(sdk): properly handle deletion -> creation -> deletion sequence
This commit resolves a bug that occurred when an attribute underwent a deletion, followed by creation, and then another deletion. The system would incorrectly ignore the final deletion because the attribute was mistakenly marked as newly created during the process.
* docs: fix typo
Co-authored-by: Louise Poole <louisecarmenpoole@gmail.com>
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
Co-authored-by: Louise Poole <louisecarmenpoole@gmail.com>
* feat: add DCI message definitions
#time 4m
#time 2m
* fix: Make entrypoints into a HashSet instead of Vec
#time 0m
* fix: Rollback on message index change in ContractSlot
#time 5m
* feat: Add get_block_storage_changes
#time 34m
#time 0m
* Update substreams/crates/tycho-substreams/src/block_storage.rs
Co-authored-by: Louise Poole <louisecarmenpoole@gmail.com>
* Update substreams/crates/tycho-substreams/src/block_storage.rs
Co-authored-by: Louise Poole <louisecarmenpoole@gmail.com>
* fix: Filter out calls that are reverted and sort change by ordinal
#time 0m
* fix: Improve performance of get_block_storage_changes
We expect this util function to collect and handle a lot of information repeatedly (on every single block). So top performance optimisation (both memory and computation) is vital to minimise substream lags.
#time 6m
* fix: Use filter and flat_map instead of if and for loops
#time 1m
---------
Co-authored-by: Louise Poole <louise@datarevenue.com>
Co-authored-by: Louise Poole <louisecarmenpoole@gmail.com>
* feat: add DCI message definitions
#time 4m
#time 0m
* feat: Add add_entrypoint to TransactionChangesBuilder
#time 15m
#time 0m
* fix: Make entrypoints into a HashSet instead of Vec
#time 0m
* fix: Rollback on message index change in ContractSlot
#time 5m
* fix: Ignore examples in docstrings when running cargo test
---------
Co-authored-by: Louise Poole <louise@datarevenue.com>
the `call.account_creations` field had been deprecated by Substreams because of some edge cases where a new account wasn't detected.
This commit removes the usage of this field in our sdk contract extraction logic and some others specific places. We decided to rely on the call type instead. This approach should be much more robust.
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
* fix: remove unnecessary tx field in ProtocolComponent
* chore: move ambient protobuf files to ambient module
* chore: remove dependency on common message types
This allows us to isolate the ambient specific messages within the ambient module
* feat: update ambient substream with new message structs
* chore: update substream configs
And remove use of deprecated BlockContractChanges.
* feat: implement From for AmbientProtocolComponent to ProtocolComponent
* refactor: stop using private pypi
This was required because our repos were not public. Now that they are, people can directly access our Python packages and therefore they don't need access to our private codeartifact anymore
* docs: add a list of dependencies in the readme and early check in the setup env script
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
This is to make each substreams completely independent, before when we would need a new version of a dependency, we would have to change it for every crate which would lead to a change of every substreams module hash. We want to make every Substreams completely independant and frozen, this also helps to maintain a correct versionning.
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
* chore: add sfrax to rust fmt ignore
* fix(substreams-sdk): correctly mark contract creation.
Previously we would mark a contract as created if it was created in any transaction in this block. This would lead to some unexpected behavior if the contract was created and updated in the same block but in different transactions. In that case the update would be tagged as creation.
* feat: extract asset types for ng factory
This will allow us to detect pools with rebasing tokens and blacklist them until we can support them in `tycho-simulation`
* fix: correctly index math implementation for twocrypto factory
This implementation is immutable and not dynamic.
* fix: index cryptopool factory
This factory is needed for simulations by pools that have admin fees.
* chore: fix build sfrax abi contract
* Bump curve version
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
Co-authored-by: tvinagre <tvinagre@gmail.com>
Co-authored-by: Thales <thales@datarevenue.com>
* refactor(substreams): ignore transaction if contracts update are ignored.
There are some cases where we ignore contracts updates (for example if the old and new values are the same). In that case if the transaction only contains ignored updates we don't emit it.
* refactor(substreams): ignore deletions for freshly created attributes.
There are cases where an attribute can be created and deleted during the same transaction. To avoid sending a confusing deletion for something that was never created before, we just ignore the deletion in that particular case.
* feat(substreams): Add uniswap V3 logs only module (#98)
* feat(substreams): add uniswapV3 logs only Substreams module
* refactor(substreams): encode everything as big endian
* refactor(substreams): mark changes as creation when a tick liq is updated from 0
This will allow the SDK to detect cases where a tick is created and deleted in the same transaction and ignore it.
* ci(substreams): ignore built files for uniswapv3 logs only module and clean code
* refactor(substreams): update uniswapv3 substreams with new SDK interface
* feat(subtreams): emit default token balances value for uniswapv3
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
The `aggregate_balances_changes` was keeping a map of token -> balance_change per transaction. Therefore, if a transaction was causing a balance change for the same token but on differents components we would only keep the update for the last component updated and drop the others.
Adds the rate providers and additional attributes to balancers static attributes. These will help in the future to migrate some of the components to use the DCI.
Adds a small attributes module to tycho-substreams to make json encoding a bit easier.
This builder allows easier access to already changed contract addresses, and entity attributes while avoiding duplicated entries.
This is needed to implement the update markers on balancer substreams.
In case we get negative balances, which happens sometimes e.g. in balancer and seems to be due to some rounding issues within the protocol, we simply clip the balance at 0 so we never emit negative balances as tycho-indexer the upstream system will interpret the balance bytes as unsigned integers.