Uniswap is one of the leading decentralised exchanges (DEX) in web3 and is one that relies on indexers to serve data to its UI so users can interact with it. By systematically organising tokens, liquidity pools, transactions, and other essential information, indexers like SubQuery provide users with a quick and efficient means to search, find, and analyse data within Uniswap.

The objective of this article is to offer a detailed, step-by-step guide on setting up a SubQuery indexer for Uniswap v3 protocol. We will comprehensively cover the necessary configurations and delve into the intricacies of the underlying logic. It's an excellent example of how to do indexing for a complex DEX like Uniswap.


The Uniswap example project comprehensively captures all exchange-related data, encompassing token purchases, liquidity creation, daily aggregations, historical trading volumes, price fluctuations, and user interactions.

Key Resources


Below, we will discuss some use cases for intriguing historical analyses that address a wide range of needs. Let's delve into a few examples:

The query mentioned above retrieves the top 5 pools with the highest number of associated transactions. This type of query is essential as it automates all calculations and sorting if you intend to construct a leaderboard or a statistical dApp.

This particular query retrieves the most recent 5 swaps conducted within the Uniswap V3 protocol, making it highly valuable for maintaining a real-time trading history. Given the somewhat intricate structure of the Uniswap V3 protocol, which essentially involves three types of contracts (detailed further in the documentation), attempting this task without SubQuery would require manually inspecting the logs of each contract, followed by separate data aggregation and subsequent filtering and sorting.

Lastly, the above query furnishes you with statistical data spanning the entire protocol for the past 10 days. Such insights can offer a snapshot of the current health of the protocol and serve as the basis for various statistical visualisations.

About Uniswap

Uniswap V3 is a third version of Uniswap decentralised exchange and an Ethereum streetwear pioneer. It allows anyone to exchange ERC20 tokens, create a liquidity pool and earn income by providing liquidity.

Uniswap is an implementation of an x * y = k market making model, that was originally proposed by Alan Lu of Gnosis. This model dictates that for a token pair of x and y, the size of each token’s liquidity pool will change but k will always remain constant; meaning future exchange rates will always fall along the equation’s original curve.

Learn more about Uniswap and its history here!

About Subquery

SubQuery is a leading blockchain data indexer that provides developers with fast, flexible, universal, and decentralised APIs for web3 projects. We empower developers from over 100+ ecosystems including Ethereum, Polygon, Polkadot, Cosmos, Algorand, NEAR, and Avalanche with rich indexed data to allow them to build intuitive and immersive decentralised applications. This blockchain developer toolkit enables developers to focus on their core use case and front-end without wasting time building a custom backend for data processing activities. In the near future, the SubQuery Network will replicate this scalable and reliable solution in a completely decentralised manner.

Share this post