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
Export as PDF
  1. For DEXs
  2. Protocol Integration
  3. Indexing

Best Practices

PreviousCustom protobuf modelsNextReserved Attributes

Last updated 1 month ago

Some best practices we encourage on all integrations are:

  • Clear Documentation: Write clear, thorough comments. Good documentation:

    • Helps reviewers understand your logic and provide better feedback

    • Serves as a guide for future developers who may adapt your solutions

    • Explains why you made certain decisions, not just what they do

  • Module Organisation: For complex implementations it is recommended to:

    • Break large module.rs files into smaller, focused files

    • Place these files in a modules directory

    • Name files clearly with numerical prefixes indicating execution order (e.g., 01_parse_events.rs, 02_process_data.rs)

    • Use the same number for parallel modules that depend on the same previous module

    A good example of this done well is in the .

  • Substream Initial Block: Your package will work just fine setting the initial block in your manifest file to 1, however it means anyone indexing your protocol has to wait for it to process an excessive number of unnecessary blocks before it reaches the first relevant block. This increases substream costs and causes long wait times for the protocol to reach the current block.

    A good rule of thumb is to identify the earliest deployed contract that you index and set this config to that block.

  • Performance Considerations:

    • Minimize use of .clone(), especially in loops or on complex/nested data structures. Instead use references (&) when possible.

uniswap-v4 implementation