Code Architecture
Tycho Execution offers an encoding tool (a Rust crate for generating swap calldata) and execution components (Solidity contracts). This is how everything works together.
Last updated
Tycho Execution offers an encoding tool (a Rust crate for generating swap calldata) and execution components (Solidity contracts). This is how everything works together.
Last updated
The following diagram summarizes the code architecture:
The TychoEncoder
is responsible for validating the solutions of orders and providing the user with a list of transactions that you must execute against the TychoRouter
or Executor
s.
At initialization, you can choose which SwapStrategyEncoder
should the TychoEncoder
use:
SplitSwapStrategyEncoder:
executes the transaction through the TychoRouter
ExecutorStrategyEncoder:
bypasses the TychoRouter
and executes directly against our executors.
Internally, the user-selected SwapStrategyEncoder
chooses the appropriate SwapEncoder
(s) to encode the individual swaps, which depend on the protocols used in the solution.
The TychoRouter
calls one or more Executor
s (corresponding with the output of the SwapEncoder
s) to interact with the correct protocol and perform each swap of the solution. The TychoRouter
optionally verifies that the user receives a minimum amount of the output token.
If you select the ExecutorStrategyEncoder
during setup, you must execute the outputted calldata directly against the Executor
which corresponds to the solution’s swap’s protocol. Beware that you are responsible for performing any necessary output amount checks. This strategy is useful if you want to call Tycho executors through your own router. For more information direct execution, see here.