284 Commits

Author SHA1 Message Date
tim
f1e602d414 Liquidity Party adapter 2025-12-10 15:53:45 -04:00
tim
f0f2f20c3c first pass at substreams 2025-10-22 16:56:40 -04:00
tim
e3ffa339bc first pass at substreams 2025-10-22 16:51:40 -04:00
TAMARA LIPOWSKI
1287d8c5c5 fix: Ekubo test 2025-10-09 17:52:31 +02:00
Zizou
568f26116e feat: add native balance in StorageChanges (#292)
* 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>
2025-10-06 10:12:37 +00:00
dianacarvalho1
128de3037e fix: Misc improvements (#291)
* fix: Misc improvements

Make module_name optional and default to map_protocol_changes
Add build instructions for the DB image inside of the docker-compose
Improve error message
Remove unnecessary module_name from yaml files

#time 39m

* fix: Bring back module_name in balancer v3 tests

#time 8m

* fix: Fix balance and allowance overwrites

For tokens with proxies we need to use the address that is returned by the detector

#time 13m
2025-10-03 14:37:49 +00:00
TAMARA LIPOWSKI
8de285a2ee feat: PancakeV3 test
- There are only two post-cancun PancakeV3 pools.
- One was ORDER-WETH which I guess had a liquidity issue, it failed with `StateDecodingFailure pool="0xb2dc4d7627501338b578985c214208eb32283086" error=Missing attributes tick_liquidities`
- The second one is this USDT-USDf pool used for this test, though we fail to detect the balance slot of USDT: `WrongSlotError(“Slot override didn’t change balance.“)`
- For this reason, we skip execution.
- Also includes stop_block fix (better explained in Uniswap V3 test PR)
2025-09-29 12:04:07 -04:00
TAMARA LIPOWSKI
f9b4b5c223 fix: UniswapV2 test - use post-cancun created pool
- Also fix balance check: this should use the stop block not start block, since the start block is before the component was even created.
2025-09-29 09:29:44 -04:00
Zizou
3c6f9c2083 fix: update balancer_v2 dependency after a fix in tycho-substreams (#281)
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
2025-09-26 21:28:39 +00:00
TAMARA LIPOWSKI
6cc1dcc505 fix: UniswapV3 proto definition
This fixes the error:
test-runner-1  | 2025-09-20T00:59:08.199125Z ERROR Substreams pack command failed: Error: validation failed: module "map_balance_changes" has invalid proto output type "proto:tycho.evm.uniswap.v3.BalanceDeltas": proto message type "tycho.evm.uniswap.v3.BalanceDeltas" not found in package proto definitions

And now it matches how it's done in UniswapV2
2025-09-26 10:31:31 -04:00
TAMARA LIPOWSKI
2ae5c4bcc7 feat: Add UniswapV3 test 2025-09-26 10:31:31 -04:00
dianacarvalho1
b577e7d6b2 refactor: Misc improvements to code (#277)
* refactor: Misc improvements to code

- Decouple validating logic from TychoRunner
- Move all data fetching and decoding the tycho message into the same method
- Split validate_state into validate_state, validate_token_balances and simulate_and_execute
- Make rpc_provider and runtime attributes of TestRunner
- Add references where possible to avoid clones
- Remove unnecessary code
- Make clippy happy

#time 2h 36m

#time 0m


#time 3m

* chore: Use tycho deps and foundry from tycho_simulation

This is to try to decrease the risk of using conflicting versions in the different repositories

#time 32m


#time 0m

* chore: Read RPC_URL in main.rs

#time 10m

* fix: Support eth trades (skip balance and allowance overwrites) and set balance overwrite to amount in

For tokens like USDC setting the balance super high was making us getting blacklisted

#time 1h 12m

* fix: Fix curve tests and filter components_by_id with the expected_component_ids

#time 1h 30m


#time 0m

* fix: Don't use all the possible executor addresses. Hardcode just one for the test

Refactor overwrites logic:
- renamed functions
- moved logic around that fits together
- don't use StateOverrides and then convert to alloy overrides. Use alloy's directly

#time 1h 21m

* fix: Assume that the executors mapping starts at storage value 1

Move setup_router_overwrites away from the rpc and into the execution file
Delete unnecessary get_storage_at

#time 33m
2025-09-25 17:27:05 +01:00
Zizou
12369c3981 fix: update get_block_storage_changes to correctly emit previous value (#280)
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>
2025-09-25 17:41:07 +02:00
Tamara
eaca47479b feat: Simulate txs against RPC (#261)
* feat: (WIP) Simulate txs against RPC

* fix: include test_executor_addresses.json

We should probably fetch this from execution instead. Will do later

* feat: (WIP) Attempt to use TokenProxyOverwriteFactory

* feat: (WIP) Attempt to use TokenProxyOverwriteFactory

* feat: Add simulating execution using debug_traceCall

Decoded amount out from execution and compared with the one from simulation
Allow for printing the execution traces
Moved all execution methods into execution.rs
Created traces.rs (heavily clauded) that prints the traces nicely and gets the function selectors frm 4byte (I decided not to use EtherscanIdentifier from foundry because adding foundry as a dependency is really heavy and I expect problems because of it)

Temporary: hardcoded storage slots for test_weighted_pool_v4 to pass

#time 1h 55m

* feat: Use BalanceSlotDetector and AllowanceSlotDetector from tycho_ethereum

#time 1h 14m

* fix: Improve traces.rs

#time 2m

* feat: Add skip_execution

Also get tycho router bytecode at compile time

#time 22m

* test: Skip tests that are before the Shanghai upgrade

Remove unnecessary TODOs

#time 35m

* feat: Point tycho dependencies to specific commits

#time 9m

* fix: Set historical_trade to true in TychoRouterEncoderBuilder

#time 41m


#time 0m

* feat: Improve traces.rs (use foundry instead of 4bytes)

Improved the format of the printed trace as well

#time 1h 7m

* fix: After merge fixes

#time 3m

* feat: Use new executors_addresses in tycho-execution and read it at startup

#time 1h 25m

* feat: Create a new flag to enable execution_traces

#time 9m

* fix: Small code, log and trace improvements

Add trying to decode method's calldatas in tracing

#time 1m

* fix: Simplify simulate_transactions_with_tracing by introducing a new method: bytes_to_fixed_32

#time 13m

* fix: After merge fixes

#time 1m

* fix: Include executor's bytecode at compile time

#time 11m

---------

Co-authored-by: TAMARA LIPOWSKI <data.lipowski@extaccount.com>
Co-authored-by: Diana Carvalho <diana@propellerheads.xyz>
2025-09-23 15:57:43 +01:00
TAMARA LIPOWSKI
69352511e7 chore: Make CI happy
Errors such as...
error: struct `Pools` is never constructed
2025-09-23 00:42:23 -04:00
TAMARA LIPOWSKI
2c0c4d97fb refactor: Move module_name to integration test yaml
It's not good to keep this in the test_runner because then we have multiple points that we need to edit the test config, which can be hard to find.

We need this because the module name for uniswap_v2 is so far different from the rest of the protocols.
2025-09-23 00:42:23 -04:00
TAMARA LIPOWSKI
99c8a32d23 feat: Add test for PancakeswapV2
- There are some ugly hardcodings here that I hope to improve.
2025-09-23 00:42:23 -04:00
TAMARA LIPOWSKI
1c5cf42d00 feat: Add test for UniswapV2
- Used a random post-Shanghai-created USV2 pool state with enough liquidity for the test

Necessary fixes:
- Don't hardcode to EVMPoolState
- Don't expect adapter to always be set.
- UniswapV2 names its module differently for some reason... this seems like a special case so instead of updating all integration test yamls, I'm just hardcoding it in test_runner.rs. Perhaps not the best decision?
- Log the static attributes if not found.
- Get the substreams yaml path from config instead of hardcoding it.
2025-09-23 00:42:23 -04:00
adrian
a895d7e1fe fix: add protocol_system key to ekubo test definition 2025-09-18 20:00:06 +02:00
TAMARA LIPOWSKI
ca7998c5ce fix: Curve SDK tests
- Don't care about token order when comparing. We did not care in the python package. Not sure there is any advantage to caring.
2025-09-18 11:51:38 -04:00
TAMARA LIPOWSKI
8ad709b07a fix: Maverick V2 SDK tests
- substreams.yaml was missing.
- verified both integration tests now pass in Rust and Python test suites
2025-09-18 11:18:41 -04:00
TAMARA LIPOWSKI
0cf444c5f9 fix: Remove failing Balancer V3 tests
- These were also failing in python.
2025-09-18 11:18:25 -04:00
TAMARA LIPOWSKI
0226bda482 fix: Compare lowercase component IDs
- This was failing. Make this more lenient so the user can specify component id in the test file in a non-case-sensitive manner.
- Also switched around a wrong token order which was causing a failure (not sure we care about token order but we may in the future? Python didn't care...)
2025-09-18 11:18:25 -04:00
TAMARA LIPOWSKI
779c690b6d fix: Fix python tests
- These are just used for comparison purposes and will eventually be deleted.
- Also balancer v3 test fix: add protocol_system to yaml, and remove "excludePaths" from protobuf in substreams.yaml (this entry was not supported)
2025-09-18 11:18:25 -04:00
adrian
b1315d1863 test: remove test_composable_stable_pool_creation for balancer-v2 2025-09-17 10:27:44 +02:00
adrian
e1d0c58e64 test: add ci workflow for substreams tests 2025-09-17 10:27:44 +02:00
adrian
183c034204 chore: remove ./substreams/target/wasm32-unknown-unknown/release/*.d files 2025-09-16 11:31:19 +02:00
adrian
d728440048 feat: add evm and wasm files 2025-09-16 11:31:19 +02:00
dianacarvalho1
22843cfd3b feat: Add encoding to test suite (#259)
* feat: Add encoding to test suite

Use execution from simulation
Add protocol_system to all test files and pass it to run tycho
Add encoding_utils.rs

#time 5h 0m

#time 1m

#time 7m

* refactor: Move encoding swap to its own method to simplify main code

Rename encoding_utils.rs to encoding.rs

#time 20m


#time 0m

#time 0m
2025-09-11 14:30:49 +01:00
adrian
24504d0f94 feat: add docker image to build binaries used in tests 2025-09-10 16:36:08 +02:00
Zizou
ed43a079c9 feat: update balancer v2 spkg to make it return old slot values (#252)
* 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>
2025-09-09 10:38:35 +02:00
kayibal
655fae77ab chore: Bump tycho-substreams version 2025-09-05 12:37:40 +01:00
adrian
eac74450bc test: add test for the token balances validation 2025-09-04 17:46:27 +02:00
kayibal
61ad26c17a feat: Add previous_value field to ContractSlot
This change is required by the DCI to properly detect potential address changes (retriggers) on packed storage slots.
2025-09-03 16:35:32 +01:00
kayibal
8b4611f9bb feat: Add previous_value field to ContractSlot
This change is required by the DCI to properly detect potential address changes (retriggers) on packed storage slots.
2025-09-03 16:35:32 +01:00
adrian
87c9a8b60f test: check that all the existing substreams integration test files can be parsed 2025-09-03 08:55:29 -04:00
Zizou
6fba0b3b3d fix: update sdk version for uniswapv3/v4 and ekubo (#227)
This is following the bugfix in https://github.com/propeller-heads/tycho-protocol-sdk/pull/213

Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
2025-06-30 16:40:00 +00:00
die-herdplatte
1ff97ff43f Ekubo TWAMM & MEV-resist integration (#192)
* 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
2025-06-30 14:45:08 +00:00
Louise Poole
58324a199f chore: fix typos 2025-06-26 12:33:31 +02:00
Louise Poole
c2bb3a8ca8 chore: fix cargo auto-resolution of tycho dependencies 2025-06-26 12:33:01 +02:00
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
Louise Poole
dfa87f662d fix(balancer_v2): skip adding zero address rate_provider entrypoints (#224) 2025-06-25 15:52:49 +00:00
Louise Poole
1c6c2c53c7 chore: bump tycho-substreams crate version (#223)
* chore: bump tycho-substreams crate version

* chore: update cargo.lock
2025-06-25 17:48:46 +02:00
Louise Poole
d4670d4312 chore: remove duplicate tycho-substreams from cargo.lock (#222) 2025-06-24 13:46:44 +02:00
Zizou
27f178de59 fix(sdk): properly handle deletion -> creation -> deletion sequence (#213)
* 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>
2025-06-24 09:41:10 +00:00
Louise Poole
648a3bf419 fix: skip processing balances of bpt tokens (#220) 2025-06-19 16:27:26 +02:00
tvinagre
3f1beeab7c fix: Make get_block_storage_changes public (#214)
* fix: Make get_block_storage_changes public

* Make RpcTraceData caller optional

* feat: Create function to decode list of addresses
2025-06-16 21:40:39 +00:00
Zizou
7da01c745b feat: Balancer V2 DCI integration (#219)
* 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>
2025-06-16 11:35:59 +02:00
Zizou
2620a5442d chore: add repository URL to ethereum-maverick-v2.yaml (#212)
* 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>
2025-05-23 17:21:44 +02:00
Zach
fb0a57bf07 feat: Add Maverick V2 adapter and substreams (#167)
Co-authored-by: Thales <thales@datarevenue.com>
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
2025-05-23 17:07:15 +02:00