← Back to all products
$10
Vault Subgraph
TheGraph subgraph for indexing vault events with a GraphQL API for historical data.
TypeScriptMarkdownYAMLJSON
📁 File Structure 13 files
vault-subgraph/
├── LICENSE
├── README.md
├── config/
│ ├── arbitrum.json
│ ├── base.json
│ └── mainnet.json
├── examples/
│ └── queries.graphql
├── package.json
├── schema/
│ └── schema.graphql
├── security-notes.md
├── src/
│ ├── factory.ts
│ ├── helpers.ts
│ └── vault.ts
└── subgraph.yaml
📖 Documentation Preview README excerpt
vault-subgraph
TheGraph subgraph for indexing CryptoForge ERC-4626 vault events with a full GraphQL API.
Price: $9.99 | Store: vault-forge | Product #8
Overview
vault-subgraph is a production-ready subgraph definition for indexing all events from the CryptoForge vault system. It provides a GraphQL API for querying vault TVL, deposits, withdrawals, harvest events, fee changes, strategy allocations, user positions, and daily snapshots.
What's Indexed
| Entity | Source | Description |
|---|---|---|
| Vault | Factory + vault events | Core vault state and aggregated metrics |
| Deposit | Deposit event | Individual deposit records |
| Withdrawal | Withdraw event | Individual withdrawal records |
| Harvest | Harvest event | Strategy yield reports |
| FeeEvent | Various events | Fee recipient + strategy changes |
| Strategy | Factory events | Approved strategy registry |
| User | Deposit/Withdraw events | Aggregated user positions |
| DailySnapshot | Derived | Daily vault state for time-series |
Architecture
CryptoForgeVaultFactory ──────────────────────┐
VaultCreated → creates Vault entity │
StrategyApproved/Revoked → Strategy entity │
AssetApproved/Revoked → logged │
│
Creates dynamic data source per vault ──────┤
│
CryptoForgeVault (template) ──────────────────┤
Deposit → Deposit entity + Vault update │
Withdraw → Withdrawal entity + Vault update │
Harvest → Harvest entity + Vault update │
FeeRecipientChanged → FeeEvent entity │
StrategyChanged → FeeEvent entity │
Paused/Unpaused → Vault.paused update │
│
All events → DailySnapshot update ──────────┘
Installation
# Install dependencies
npm install
# Generate AssemblyScript types from schema and ABIs
npm run codegen
# Build the subgraph
npm run build
... continues with setup instructions, usage examples, and more.
📄 Code Sample .yaml preview
subgraph.yaml
specVersion: 0.0.5
schema:
file: ./schema/schema.graphql
description: >
CryptoForge Vault Subgraph — Indexes all ERC-4626 vault events from
CryptoForgeVaultFactory and individual CryptoForgeVault contracts.
Provides a GraphQL API for vault TVL, deposits, withdrawals, harvests,
fee events, strategy changes, and daily snapshots.
repository: https://github.com/cryptoforge/vault-subgraph
dataSources:
# ─────────────────────────────────────────────────────────
# CryptoForgeVaultFactory — indexes factory-level events
# ─────────────────────────────────────────────────────────
- kind: ethereum
name: CryptoForgeVaultFactory
network: mainnet
source:
address: "0x0000000000000000000000000000000000000000" # Replace with deployed factory
abi: CryptoForgeVaultFactory
startBlock: 0 # Replace with factory deployment block
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Vault
- Strategy
abis:
- name: CryptoForgeVaultFactory
file: ./abis/CryptoForgeVaultFactory.json
- name: CryptoForgeVault
file: ./abis/CryptoForgeVault.json
eventHandlers:
- event: VaultCreated(indexed address,indexed address,address,string,string)
handler: handleVaultCreated
- event: StrategyApproved(indexed address)
handler: handleStrategyApproved
- event: StrategyRevoked(indexed address)
handler: handleStrategyRevoked
- event: AssetApproved(indexed address)
handler: handleAssetApproved
- event: AssetRevoked(indexed address)
handler: handleAssetRevoked
file: ./src/factory.ts
templates:
# ─────────────────────────────────────────────────────────
# CryptoForgeVault — dynamically created for each new vault
# ─────────────────────────────────────────────────────────
# ... 39 more lines ...