/uniswapv3-swaps-subsquid

Indexing UniswapV3 Swaps Data usig subsquid

Primary LanguageTypeScriptMIT LicenseMIT

UniswapV3 Swaps Indexing Lab

This is a lab to test indexing UniswapV3 swaps data using Subsquid. This project serves as a starter template of a squid indexer for EVM networks (Ethereum, Polygon, BSC, etc.). See Squid SDK docs for a complete reference.

For a step-by-step migration guide from TheGraph, see the dedicated docs page.

Prerequisites: Node.js, Docker.

Quickstart

Prerequisites

  1. Install Node.js from the official website.

  2. On Windows, resolve script execution policy issues by running the following PowerShell commands:

    Get-ExecutionPolicy
    Set-ExecutionPolicy RemoteSigned
    Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Setup

  1. Clone the repository:

    git clone https://github.com/subsquid-labs/uniswapv3-swaps-example.git
    cd uniswapv3-swaps-example
  2. Install @subsquid/cli globally:

    npm i -g @subsquid/cli
  3. Install dependencies:

    npm ci
  4. Start a Postgres database container and detach:

    sqd up
  5. Build and start the processor:

    sqd process
  6. The command above will block the terminal, being busy with fetching the chain data, transforming and storing it in the target database.

  7. To start the GraphQL server, open a separate terminal and run:

    sqd serve

A GraphiQL playground will be available at localhost:4350/graphql to query the indexed data.