Unlock Uniswap V4 Data in Minutes with SQD SDK

TL;DR: Uniswap V4 introduces previously unthinkable levels of customization for devs building DeFi. Yet, this creates difficulties in accessing data, except when using SQD to do it. Learn how to build your first Uniswap V4 multichain indexer with just a few lines of code.
Uniswap V4 is currently revolutionizing DeFi with the latest innovations, including hooks and subscriptions. However, while V4 introduces meaningful improvements, it also makes AMM contracts more complex, making retrieving, analyzing, and displaying data increasingly challenging.
Why Uniswap V4?
Uniswap dominates the DEX space with a 67% market share and $3B+ daily trading volume. V4 introduces hooks, modular plugins that empower developers to tap into Uniswap’s liquidity using custom AMM logic without fragmenting the liquidity. It’s a great way to enhance one's DeFi projects and build analytics tools, but accessing the data isn’t as easy as it sounds.
The Problem: Indexing Uniswap V4 can be Hard
Indexers indexing Uniswap need to handle:
- Thousands of swaps and billions in transaction volume daily.
- Multi-chain support with a single database to handle cross-chain data.
- Increasing network speeds and blockspace.
Still want to get Uniswap V4 data? With SQD, it doesn’t have to be that hard. Our decentralized data access solution makes archive and real-time data more accessible than ever before.
In this tutorial, we will use SQD SDK to deploy a Uniswap V4 indexer across multiple chains with just a few lines of code. Scroll down to the actual setup or read on for more background information on the tech.
Enter the Squid SDK
Squid SDK is a modular toolkit that enables you to ingest on-chain data from the SQD data lake, along with RPC data, for incredibly fast archive retrieval and real-time indexing. The standard configuration includes a data processor and a Postgres database for data transformation storage. Most Squid (indexer) examples come with a GraphQL server, which can be replaced with a different server of your choice.
Advantages of using the SDK:
- Node.js / Typescript: Feel at home by installing your favorite Node libraries in a familiar Typescript environment.
- Quick Sync Speed: Sync data within minutes thanks to batching and filters. No need to wait weeks for a resync.
- Rapid Development: The SDK is streamlined to minimize boilerplate code. Just add your ABI, rebuild and start indexing.
- Off-Chain Data: Access third-party APIs or IPFS to enrich the on-chain data, for example, with offchain NFT metadata.
Uniswap V4 Squid Template
To help you get started with indexing Uniswap V4, the SQD Boost team has created a template that takes care of most indexing requirements.
This indexer takes advantage of many SQD features mentioned earlier: it is multi-chain out of the box, stores pool, position, token, and various other analytical data. It also features a set of flags you can toggle on and off to optimize the number of events and stats stored based on your requirements.
Ready to dive in? Here’s how to deploy your Uniswap V4 indexer with SQD:
Setting up Squid locally
Uniswap V4 template comes with the following project structure. Below you can read the explanation of each directory:

- abi/: stores the ABIs of the contracts you are indexing. This template comes with all relevant ABIs for Uniswap V4 development such as V4 Position NFT and the Pool Manager.
- squid.yaml: ingestion and deployment configuration
- schema.graphql: describes the structure of data
src/: contains all your core indexing logic, in our case it’s the mappings and chain constants. It includes the following subfolders and files:
- mappings/: for handling event data and mapping it to your schema.
- tools/: for utility functions or scripts used during indexing.
- utils/: for shared code or helper functions.
- main.ts: the entry point for your indexer logic.
- processor.ts: the file where you define what raw data you want to fetch and process (e.g. event logs, transactions, traces).
Follow the steps below to set up the Squid. By the end of the setup you will be able to start the indexer and play with the data locally via a local GraphQL server.
bash
# Clone the Uniswap V4 SQD template
git clone https://github.com/SQD-Boost/uniswapV4-squid
cd uniswapv4-indexer
# Install SQD CLI
npm i -g @subsquid/cli
# Install dependencies and run the codegen tools.
npm ci
sqd codegen && sqd typegen
# start the postgres instance
sqd up
# generate db migrations
sqd migration:generate
# generate a .env file from the example and add RPC endpoints
cp .env.example .env
# run all configured chains
sqd run .
# start a graphql server
sqd serve
GraphiQL playground will be available at localhost:{GQL_PORT}/graphql.
You can now build a query to fetch the data that’s currently being indexed locally.
Next Steps
Now that your Uniswap V4 indexer is up and running locally, you’re ready for the next steps:
- Explore Advanced Features: Experiment with indexing custom hooks, integrating off-chain data (e.g., token metadata from IPFS), or building real-time analytics pipelines using SQD’s modular toolkit.
- Deploy to SQD Cloud: Follow the step-by-step guide on SQD Cloud to deploy your indexer. SQD Cloud handles hosting, scaling, and monitoring, so you can focus on building without worrying about infrastructure. Once deployed, you’ll get a dedicated GraphQL API endpoint to power your applications.
- Integrate with Applications: Use your indexer's API endpoint to build dashboards, analytics tools, or AI-driven insights. Explore sample queries in the Core queries exposed by the OpenReader API | SQD to get started.
- Monitor and Optimize: Leverage SQD Cloud’s monitoring tools to track performance and ensure your indexer runs smoothly. Experiment with filters, and other optimizations to fine-tune your setup.
- Scale Across Chains: Expand your indexer to support additional chains by updating squid.yaml and adding RPC endpoints. SQD’s multi-chain capabilities make it easy to handle cross-chain data seamlessly.
Want to do more than just index UniswapV4?
Here are some ways to expand your knowledge and join the SQD ecosystem:
- Join the Community: Connect with developers, share your projects, and get support on telegram @HydraDevs. Stay updated on the latest features and best practices.
- Develop more with SQD: Dive deeper into the SQD’s ecosystem by trying out the templates and tutorials. Our active community developer organization, Boost, is consistently shipping new code in its dedicated repo.
- Contribute to SQD: Help improve the Uniswap V4 template or Squid SDK by contributing code, documentation, or feedback. Check out our GitHub SQD Boost repository and open issues.