A full-stack for indexing DEX trades and tokens on Solana with high performance and low latency.
This monorepo is composed of two libraries available from npm, as well as examples and documentation. The libraries are:
@primodiumxyz/dex-indexer: The indexer for Solana DEX trades and token metadata@primodiumxyz/dex-graphql: The GraphQL client and Hasura/Timescale databases management framework
It is also responsible for building and publishing Docker images for both the indexer and databases to the GitHub Container Registry, that can be used for running the two packages in production, e.g. inside an AWS ECS instance. You will find examples on how to use them in the resources.
These images are available at:
See the dedicated README in each package for detailed documentation.
The DEX Indexer and DEX GraphQL packages compose the entire stack for indexing trades and tokens, managing the database in which the data is stored, and querying it through a type-safe GraphQL API.
The example dashboard and example server expose the way it is intended to query and interact with the database.
The codebase is structured as a pnpm monorepo with the following structure:
examples - "Example integrations with the indexer stack"
├── dashboard - "A React explorer for top-ranked tokens by 30-min volume, with price and candlestick charts"
└── server - "A Fastify server that exposes endpoints and performs periodic tasks on the database"
packages - "Libraries that compose the indexer stack"
│── indexer - "The indexer for Solana DEX trades and token metadata"
└── gql - "The GraphQL client and Hasura/Timescale databases management framework"
resources - "Examples and resources for running and understanding the stack"This monorepo uses pnpm as its package manager. First, install node, then npm, then install pnpm.
npm install -g pnpmThis repository is tested with node version 23.5.0 and pnpm version 9.15.2.
Then, clone the repository and install the necessary npm packages with the following from the root folder:
git clone https://github.com/primodiumxyz/dex-indexer-stack.git
cd dex-indexer-stack
pnpm iTo set the current environment variables for both local development and production, copy /.env.example to a new /.env.
cp .env.example .envSee the example environment file for information on each variable.
This stack—or specifically the indexer—requires some external services to request and subscribe to onchain data.
- Yellowstone GRPC for streaming transactions with low latency
- Jupiter for fetching token prices (
/prices) - DAS API for fetching token metadata in the Metaplex standard (
/getAssets)
All of these are available from QuickNode through add-ons, which is the recommended way to run the indexer.
Otherwise, Hasura and Timescale will be run locally during development, and can be either self-hosted or cloud-hosted with their respective offerings.
First, install Docker Desktop, or any other preferred Docker alternative. OrbStack is a good and efficient alternative for Mac users.
Running the following in the root directory of this monorepo will spin up both the indexer and databases/interfaces.
pnpm devTo run the examples, run the following as well:
pnpm dev:examples
# or just one of the examples
pnpm dev:examples:dashboard
pnpm dev:examples:serverTo build both the indexer and GraphQL packages, run the following:
pnpm buildAnd to test all packages, run the following:
pnpm testIf you wish to contribute to the package, please open an issue first to make sure that this is within the scope of the repository, and that it is not already being worked on.
This project is licensed under the MIT License - see LICENSE for details.