Skip to content

Zup-Protocol/pools-indexer

Repository files navigation

Pools Indexer

Zup Protocol

The Pools Indexer is the primary indexing engine used by the Zup Protocol. It aggregates, normalizes, and indexes liquidity data across all supported blockchains and protocols to power yield calculations and protocol analytics.


Table of Contents


Prerequisites

Ensure your environment meets the following requirements before proceeding.

Dependency Verification Command Installation Guide Note
Node.js node --version https://nodejs.org/en/learn/getting-started/how-to-install-nodejs Latest LTS recommended
pnpm pnpm --version https://pnpm.io/installation Used for package management
Docker docker --version https://docs.docker.com/get-docker/ Required for local indexing

Quick Start

1. Installation

Clone the repository and install dependencies:

git clone <repo-url>
cd <repo-name>
pnpm install

2. Environment Setup

Configure your RPC providers.

3. Local Execution

Start the local indexer using Docker and Envio:

pnpm dev

The service will sync immediately and stream logs to the terminal.


Configuration

Adding a New Network

To support a new blockchain, update the configuration in the following order:

1. Update config.yaml

Append the network details to the chains section:

  • id: Must match the network's Chain ID (refer to Chainlist)
  • start_block: Deployment block of the oldest contract to be indexed
  • max_reorg_depth: Safe reorg depth (typically ~3 minutes of blocks)

2. Register Network Enum

Add the network to the IndexerNetwork enum in
src/core/network/indexer-network.ts.

The value must match the id defined in config.yaml.

3. Configure Network Constants

In the IndexerNetwork namespace (src/core/network/indexer-network.ts), add:

  • RPC URLs
  • Stablecoin addresses
  • Wrapped native token addresses

4. Update Address Maps

Modify the following files to include addresses for the new network:


Protocol Integration

Follow the specific guide below based on the DEX architecture.


Uniswap V3 Standard

For pure clones using identical ABIs and bytecode.


Uniswap V3 Custom

For DEXs with V3-like logic but modified ABIs.

  • ABIs:
  • Config:
    • Register the Factory in config.yaml (reference new ABI)
    • Register the Pool in contracts (reference new ABI)
    • Add the Pool as a dynamic contract in the chains section
  • Metadata: Register in Supported Protocols
  • Handlers:
UniswapV3Factory.PairCreated.contractRegister(({ event, context }) => {
  context.addUniswapV3Pool(event.params.pair);
});

Algebra Integral

Supported versions: v1.2.0, v1.2.2


Slipstream

  • Config: Register the factory in config.yaml
  • ABI: SlipstreamFactory.json
  • Required Event:
    PoolCreated(address indexed token0, address indexed token1, int24 indexed tickSpacing, address pool)
  • Metadata: Register in Supported Protocols
  • Handler: Create a factory handler in src/handlers/slipstream-handlers/factory
  • Addresses: Update Position Manager addresses

Uniswap V4


Testing

Note: Comprehensive test suite coverage is currently pending implementation.

Run the test suite:

pnpm test

About

This is the primary indexer used by the Zup Protocol to calculate yields. It aggregates data from all protocols supported by Zup across different networks. For each network, it includes all Zup-supported DEXs in a single indexer.

Topics

Resources

License

Stars

Watchers

Forks

Contributors