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
  • Integration Process
  • Indexing
  • Simulation
  • Execution
  • Integration Criteria
Export as PDF
  1. For DEXs

Protocol Integration

PreviousSupported ProtocolsNextIndexing

Last updated 2 months ago

is a library to integrate liquidity layer protocols (DEXs, Staking, Lending etc.) into Tycho.

Integration Process

Integrating with Tycho requires three components:

  1. Indexing: Provide the protocol state/data needed for simulation and execution

  2. Simulation: Implement the protocol's logic for simulations

  3. Execution: Define how to encode and execute swaps against your protocol

Indexing

Provide a package that emits a specified set of messages. If your protocol already has a , you can adjust it to emit the required messages.

Important: Simulation happens entirely off-chain. This means everything needed during simulation must be explicitly indexed.

Simulation

Tycho offers two integration modes:

  • VM Integration: Implement an adapter interface in a language that compiles to VM bytecode. This SDK provides a Solidity interface (). Simulations run in an empty VM loaded only with the indexed contracts, storage and token balances.

  • Native Rust Integration: Implement a Rust trait that defines the protocol logic. Values used in this logic must be indexed as state attributes.

Execution

To enable swap execution, implement:

  1. SwapEncoder: A Rust struct that formats input/output tokens, pool addresses, and other parameters correctly for the Executor contract.

  2. Executor: A Solidity contract that handles the execution of swaps over your protocol's liquidity pools.

Integration Criteria

Tycho supports many protocol designs, however certain architectures present indexing challenges.

Before integrating, consider these limitations:

Soon to be supported:

  • Protocols that interface with external contracts during operations Tycho should support (i.e swap, price and limit calculations etc.). External contracts are those not deployed by the protocol's factories. ERC20 token contracts are exempt from this restriction.

Not supported:

  • Protocols where any operation that Tycho should support requires off-chain data, such as signed prices.

Tycho Protocol SDK
substreams
substreams package
read more here