Executing
Once you have the calldata from Encoding, you can execute your trade in one of two ways:
Via the Tycho Router – Execute trades through our audited router for seamless execution.
Directly to the Executor – Bypass the Tycho Router and execute the trade using your own router.
Tycho Router
The source code for the Tycho Router is here (see contract addresses here). To execute a trade, simply send the calldata generated by the TychoEncoder
to the router. If you chose to encode your data without permit2 for token approval and transferring, then you need to send the tokens to our router beforehand.
For an example of how to execute trades using the Tycho Router, refer to the Quickstart.
Executing Directly to the Executor Contract
If you use the Execution Strategy (see here how to select strategies), you will receive only the calldata for a single swap without any Tycho Router-specific data.
This provides greater control on the token transfers and approvals. But also gives you greater responsibility to make sure that the swap was executed correctly. You are responsible for token approvals, token transfers and error handling in your execution flow.
You need to integrate Tycho Executors into your own router contract. Implement a mechanism similar to our Dispatcher
, which uses delegate calls to interact with the Executor
contracts.
Steps to integrate Tycho Executors into your own router:
Implement something similar to Dispatcher that routes calldata to the correct
Executor
contract.Ensure that your router contract correctly manages token approvals and transfers.
Append the calldata for the swap to your overall execution flow.
⚠️ Security Considerations
Tycho's Router has been audited, and its entire execution flow has been verified. However, when using direct_execution
, Tycho is not responsible for security checks, validation, or execution guarantees. You assume full responsibility for managing token approvals, transfers, and error handling. Ensure that your router contract implements the necessary security measures to prevent reentrancy, slippage manipulation, or loss of funds.
Last updated