Solana DEX Indexer Stack
The Primodium DEX Indexer Stack is 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
(opens in a new tab): The indexer for Solana DEX trades and token metadata@primodiumxyz/dex-graphql
(opens in a new tab): 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 (opens in a new tab).
These images are available at:
sdi-indexer
(opens in a new tab) — example usagesdi-hasura-cache
(opens in a new tab) — example usage
Example Deployments:
Introduction
The source code for this repository is available on Github here (opens in a new tab).
See the dedicated README in each package for detailed documentation.
Overview
The
DEX Indexer
(opens in a new tab)
and
DEX GraphQL
(opens in a new tab)
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
(opens in a new tab)
and
example server
(opens in a new tab)
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"
Installation
This monorepo uses pnpm
as its package manager. First,
install node
, then npm
(opens in a new tab),
then install pnpm
.
npm install -g pnpm
This 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 i
Environment
To set the current environment variables for both local development and
production, copy /.env.example
to a new /.env
.
cp .env.example .env
See the example environment file (opens in a new tab) for information on each variable.
Dependencies
This stack—or specifically the indexer—requires some external services to request and subscribe to onchain data.
- Yellowstone GRPC (opens in a new tab) for streaming transactions with low latency
- Jupiter (opens in a new tab) for fetching token
prices (
/prices
) - DAS API (opens in a new tab) 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.
Development
Running the stack
First, install Docker Desktop (opens in a new tab), or any other preferred Docker alternative. OrbStack (opens in a new tab) 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 dev
To run the examples, run the following as well:
pnpm dev:examples
# or just one of the examples
pnpm dev:examples:dashboard
pnpm dev:examples:server
Testing and building
To build both the indexer and GraphQL packages, run the following:
pnpm build
And to test all packages, run the following:
pnpm test
Contributing
If 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.
License
This project is licensed under the MIT License - see LICENSE (opens in a new tab) for details.