Composable Subgraphs
Blockchain2023

COMPOSABLESUBGRAPHS

Composable subgraph architecture for reusable DeFi protocol building blocks.

2
Source DEX subgraphs
1
Composed GraphQL endpoint
4+
Shared pool entity types
SCROLL
Client
Open Source
Domain
Blockchain / Indexing
Platform
The Graph
Duration
2023
Core Stack
TypeScript · AssemblyScript
The Brief

THE
PROBLEM

Uniswap v3 and PancakeSwap v3 emit overlapping pool lifecycle events, yet institutional consumers wanted a single GraphQL surface for TVL, volume, and fees — not two schemas that drift every upgrade.

Two thin source subgraphs (per-DEX factories, NFPM, tuned start blocks) feed a composed layer that merges entities, rolls protocol-level counters, and exposes one endpoint for cross-venue analytics.

Core Engineering Challenge

Compose `kind: subgraph` sources via IPFS CIDs, graft Pancake state for faster sync, and normalize Mint/Burn/Swap/Collect into shared Protocol / Pool / Token entities without double-counting liquidity.

2
Protocols
Extended stack
frontend
TypeScript
blockchain
AssemblyScript
Composable Architecture
Composable Architecture
How we built it

THE ARCHITECTURE

01
Source subgraphs

Isolate each DEX’s factory, NFPM, and event surface with minimal cross-talk.

The GraphAssemblyScript
02
Composition wiring

Wire `kind: subgraph` sources with pinned IPFS CIDs and explicit schema imports.

SubgraphIPFS
03
Graft & sync

Graft Pancake state where applicable to shorten cold-sync time on new networks.

The GraphDevOps
04
Entity normalization

Map Mint/Burn/Swap/Collect into shared Protocol/Pool/Token with consistent decimals.

AssemblyScriptDeFi
05
Cross-venue metrics

Protocol-level counters for combined TVL and fee revenue without double counting NFPM positions.

GraphQLAnalytics
System Data Flow
Ingestion
CrawlerContent Hash10K+ pages
Processing
ChunkerDeduplicatorEmbedding API
Storage
pgvectorPostgreSQLRedis Cache
Auth
Identity ProviderJWT BridgeSessions
Query
HNSW SearchRe-rankerLLM Stream
Delivery
Web AppMobile AppUsers
What we delivered

THE RESULTS

2

Uniswap v3 and PancakeSwap v3 unified in one composed schema so dashboards could answer “aggregate DEX volume” without client-side joins across two subgraph deployments.

2
Protocols

Uniswap v3 and PancakeSwap v3 unified in one composed schema so dashboards could answer “aggregate DEX volume” without client-side joins across two subgraph deployments.

Engineering decisions

TECH
DEEP DIVE

CMP
Composition vs mega-handler

Composed sources let each DEX evolve independently while the umbrella schema stayed stable.

Grafting turned multi-day Pancake syncs into hours on new chains without rewriting mappings.

CID
IPFS-pinned sources

Immutable subgraph artifacts made promotions reproducible and audit-friendly.

Shared entity IDs required strict factory ordering rules to avoid hash collisions in merged pools.

Next Case Study
Analytics
HorizonDashboard

Trading Analytics

PythonStreamlitTimescaleDB
Start a project

LET'S
BUILD
SOMETHING.

We take on a small number of projects at a time. If the problem is hard, we're interested.

Email
hello@techmusketeers.com
Response time
Within 24 hours
Availability
Open for new projects · 2025