* feat: add native balance in StorageChanges
This will be used by the next update of DCI to properly track native balance for all the contract that it's indexing. Also added a performance optimization, we now ignore slot updates if the value after the transaction is the same than before.
* docs: add docs on how to generate test assets
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
Before this commit we were using the latest `ContractSlot` for both previous and new value. This is not correct because if the value changed twice we would have the middle value emitted as "previous". For example if a value was changed like this in a single transaction 1 -> 10 -> 2 we would have `new_value=2` and `previous_values=10` while the previous value was actually 1.
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
* feat: update balancer v2 spkg to make it return old slot values
This is needed for the new DCI version that uses old values to look into exactly what part of the slot change and compare with the retrigger offset
* refactor: use crate registry instead of github
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
* Add Ekubo TWAMM support
* Change order of words
* Account TWAMM order balances
* Fix tracking wrong component balance deltas
Swapped and PositionUpdated are the only events affecting pool TVL
* Fix fee addition
Fees are a .64 instead of a .128 since v2 & the result is rounded
* Consistent naming
* cargo fmt
* Add method for selecting store method from change type
* Only store the affected sale rate delta on OrderUpdated events
* Remove unnecessary parameterization
* Index Ekubo MEV-resist pools
* cargo clippy
* 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 Entrypoints to BalancerV2 components
* fix: miscellaneous fixes before Balancer V2 resync
This commit fixes the entrypoints created by Balancer v2 packages, removes some disabled factories and remove support for BPT tokens (this is still to be investigated but so far we won't be able to support them)
* refactor: fix CI and bump version
* chore: update comments
---------
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>
* chore: add repository URL to ethereum-maverick-v2.yaml
* chore: bump maverick-v2 version.
This bump is needed because we changed the version of `tycho-substreams` in a previous commit (to fix the bug with contract creation).
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.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: add `balance_owner` attribute for ekubo_v2 components
* refactor: rename `ekubo` into `ekubo-v2`
* refactor: freeze `substreams-helper` version in ekubo V2 module
* docs: improve integration test comment
* docs: add TODO to remove `balance_owner` in favor of `AccountBalances`
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
* feat: Add Pancakeswap V3 Substreams module
At this point it's just hard copy of Uniswap V3. It will be adapted in the following commits to make reviewing easier.
* refactor: adapt uniswapv3 module logic for pancakeswap v3
The main change is how they handle protocol fees. Protocol fees are set by default depending on the fee of the pool.
* refactor: use new protobuf structs
The "EntityChanges" got deprecated in favor of the hybrid messages. This commit makes PancakeswapV3 module use the new structs.
* fix: set correct factory address
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
Co-authored-by: Louise Poole <louise@datarevenue.com>
Also fixes a bug that would lead to emitting wrong balances if there is a `CollectProtocol` event triggered (currently not affecting because it's not enabled)
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
Add a more detailed protocol implementation in the template. This should allow more ppl to get started quicker. Additionally more people will follow a predetermined structure
* feat: initial data structure + ABI & buf models
* feat: initial modules: identify new pools and events
* feat: map liquidity and balance changes, introduce balance delta calculation from liquidity
* feat: map tick deltas
* chore: undo weird formatting
* chore: undo weird formatting
* feat: map fee changes and aggregate data to final block structure
* feat: reimplement math natively, remove alloy and univ3sdk dependencies
* chore: make clippy happy + misc improvements
* chore: add rust generated files from buf & ABI
* chore: make clippy happy
* feat: add all modules to ethereum-uniswap-v4.yaml
* chore: update yaml file to skip unnecessary buf paths
* fix: update pb mod.rs
* fix: fix hex / utf-8 encoding. working version
* fix: simplify error handling, rename yaml file to match chain & formatting
* fix: fix ChangeType for sqrt_price_x96 on Initialization
* fix: make fee a non-static attribute
* fix: add balance_owner to univ4 pool
* feat: add uniswap-v4 mainnet yaml
* fix(uniswap-v4): miscellaneous fixes for UniswapV4 (#147)
* fix(uniswap-v4): correctly decode swap event deltas.
Deltas are given from a user debt perspective by the event (negative if received by the pool, positive if sent by the pool). In our usecase we need the opposite of this. This commit uses `.neg()` on the amount to apply them correctly.
* fix(uniswap-v4): correctly compute token amounts.
We were using `get_sqrt_ratio_at_tick` at the current tick to compute the amounts. This was incorrect because it provides the price at the tick boundary, but we might be mid-tick, which could lead to erroneous balances.
We now track the current price (updated by `initialization` and `swap` events) and use it when calculating the amounts.
* fix(uniswapv4): do not account for fees in swaps.
Previously we were adding fees as balances. But they are actually not part of the TVL and we aren't accounting for fees in the position changes (withdrawals). This commit addresses this and remove the fees from the token balances.
* refactor: fix pb mod.rs
* refactor: bump version and update sepolia config
* ci: make clippy happy
* refactor: clean unimath tests
* refactor: make logic clearer and improve docstrings
---------
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
---------
Co-authored-by: Zizou <111426680+zizou0x@users.noreply.github.com>
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
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>
* 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>