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
  • Token allowances
  • Permit2
  • Standard ERC20 Approvals
  • Direct Transfers
Export as PDF
  1. For Solvers

Execution

Execute swaps through any protocol.

PreviousSimulationNextEncoding

Last updated 9 days ago

Tycho Execution provides tools for encoding and executing swaps against Tycho routers and protocol executors. It is divided into two main components:

  • Encoding: A Rust crate that encodes swaps and generates calldata for execution.

  • Executing: Solidity contracts for executing trades on-chain.

Token allowances

You can authorize token transfers in one of three ways with Tycho Execution:

  • Permit2

  • Standard ERC20 Approvals

  • Direct Transfers

Permit2

Tycho Execution leverages Permit2 for token approvals. Before executing a swap via our router, you must approve the Permit2 contract for the specified token and amount. This ensures the router has the necessary permissions to execute trades on your behalf.

When encoding a transaction, we provide functionality to build the Permit struct. However, you are responsible for signing the permit.

Standard ERC20 Approvals

Tycho also supports traditional ERC20 approvals. In this model, you explicitly call approve on the token contract to grant the router permission to transfer tokens on your behalf. This is widely supported and may be preferred in environments where Permit2 is not yet available.

Direct Transfers

It is possible to bypass approvals altogether by directly transferring the input token to the router within the same transaction. When using this option, the router must be funded during execution.

⚠️ Warning: This feature is intended for advanced users only. The Tycho Router is not designed to securely hold funds — any tokens left in the router are considered lost. Ensure you have appropriate security measures in place to guarantee that funds pass through the router safely and cannot be intercepted or lost.

The source code for Tycho Execution is available . For a practical example of its usage, please refer to our .

For more details on Permit2 and how to use it, see the .

here
Quickstart
Permit2 official documentation