Tycho
  • Quickstart
  • Overview
  • Motivation
  • Concepts
  • How to Contribute
    • Bounties
  • For Solvers
    • Indexer
      • Tycho RPC
      • Tycho Client
        • Binary / CLI
        • Rust Client
        • Python Client
    • Simulation
    • Execution
      • Encoding
      • Executing
      • Contract Addresses
      • Execution Venues
    • Hosted Endpoints
    • Supported Protocols
  • For DEXs
    • Protocol Integration
      • Indexing
        • 1. Setup
        • 2. Implementation
        • 3. Testing
          • How to Run
        • Common Problems & Patterns
          • Tracking Components
          • Tracking Contract Storage
          • Normalizing relative ERC20 Balances
          • Tracking Contract Balances
          • Custom protobuf models
        • Best Practices
        • Reserved Attributes
      • Simulation
        • Ethereum: Solidity
      • Execution
        • Code Architecture
      • Contributing guidelines
Powered by GitBook
On this page
  • Tycho Router
  • Executing Directly to the Executor Contract
Export as PDF
  1. For Solvers
  2. Execution

Executing

PreviousEncodingNextContract Addresses

Last updated 1 month ago

Once you have the calldata from , you can execute your trade in one of two ways:

  1. Via the Tycho Router – Execute trades through our audited router for seamless execution.

  2. 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 (see contract addresses ). To execute a trade, simply send the calldata generated by the TychoRouterEncoder to the router. The setup for token transfers will vary depending on the you chose: if you're using Permit2, ensure the Permit2 contract is approved; for standard ERC-20 approvals, approve the router to spend the token; and if you're using direct transfers, make sure you send tokens to the router before execution.

For an example of how to execute trades using the Tycho Router, refer to the .

Executing Directly to the Executor Contract

If you use the TychoExecutorEncoder (see how to select encoders), 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 , which uses delegate calls to interact with the Executor contracts.

Steps to integrate Tycho Executors into your own router:

  1. Implement something similar to Dispatcher that routes calldata to the correct Executor contract for swap and in case of callbacks.

  2. Ensure that your router contract correctly manages token approvals and transfers.

  3. 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.

here
here
Dispatcher
Encoding
token allowance method
Quickstart
here