Simulation
Adding a New Protocol to Tycho Simulation
To enable simulations for a newly added protocol, it must first be integrated into the Tycho Simulation repository. Please submit a pull request to the repository to include it.
Native Protocols
In order to add a new native protocol, you will need to complete the following high-level steps:
Create a protocol state struct that contains the state of the protocol, and implements the
ProtocolSim
trait (see here).Create a tycho decoder for the protocol state: i.e. implement
TryFromWithBlock
forComponentWithState
to your new protocol state.
Each native protocol should have its own module under tycho-simulation/src/evm/protocol
.
VM Protocols
In order to add a new VM protocol, its swap adapter will have to be implemented. More information about the adapter can be found at VM Integration.
Once you have the swap adapter implemented for the new protocol, you will need to:
Generate the adapter runtime file by running the
evm/scripts/buildRuntime.sh
script in our SDK repository with the proper input parameters. For example, in order to build theBalancer V2
runtime, the following command can be run:Add the associated adapter runtime file to
tycho-simulations/src/protocol/vm/assets
. Make sure to name the file according to the protocol name used by Tycho Indexer in the following format:<Protocol><Version>Adapter.evm.runtime
. For example:vm:balancer_v2
will beBalancerV2Adapter.evm.runtime
. Following this naming format is important as we use an automated name resolution for these files.
Filtering
If your implementation does not support all pools indexed for a protocol, you can create a filter function to handle this. This filter can then be used when registering an exchange in the ProtocolStreamBuilder
. See here for example implementations.
Last updated