Files
tycho-protocol-sdk/substreams/ethereum-curve
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
..
2024-07-02 17:08:45 +02:00
2024-03-29 14:55:31 -05:00
2025-06-26 12:33:31 +02:00
2024-03-01 14:41:00 -05:00
2024-03-07 17:00:32 -05:00
2024-06-04 17:13:01 -04:00

Instructions

The run command for our substream is a little different here due to the inclusion of the dynamic parameters for manually admitted pools.

This command will add extra parameters to the map_components module via the python params.py script. This embeds directly in the bash/zsh compatible command here. If python is not ideal, the script can be easily converted into bash but it would require the jq executable (I've used AI to convert it just fine in testing).

$ substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml map_protocol_changes --start-block 11507454 --stop-block +100 -p map_components=`python params.py`

params.json

This json file is a top-level array containing objects that describe a specific ProtocolComponent. Each object contains the following fields:

  • name: Just for documentation purposes
  • address: The lowercase address of the component
  • tx_hash: The hash of the transaction where the component was emitted
  • tokens: A list of token addresses ordered in the exact same way as the Pool
  • static_attributes: A nested object of key to value that represents the static attributes of the component.
  • attributes: A nested object of key to value that represents attributes.

Please see the included 3 examples for 3pool, steth, and tricrypto2.

Open tasks

Add underlying tokens in metapools

Currently, metapools are not working properly due to the way we override token balances. The issue arises because when we modify token balances, we end up changing the token contract code and storage. This issue will be resolved once we implement a flexible method to adjust token balances without affecting the contracts functionality. We will also need to index additional contract such as the base pool lp token.

Handle rebasing, ERC4644 and others special kind of tokens

At the moment, we are unable to manage certain types of tokens, such as rebasing tokens or ERC4644 tokens, because they have unique behavior or specific logic that complicates simulations. To handle these tokens properly, we will likely need to use the dynamic contract indexer (DCI), which can track and index the full state of the token contract, allowing us to deal with their complexities effectively.

Static Attributes

name type description
pool_type str A unique identifier per pool type. Set depending on the factory.
name str A string representing the name of the pool, set if there is one.
factory_name str A string representing the name of the factory that created the pool. "na" if the pool was manually created.
factory bytes The address of the factory that created the pool. "0x000..." if the pool was manually created.
lp_token bytes The pool lp token, set if the lp token is not the pool itself
base_pool bytes The base pool related to this pool, set only for metapools.