This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a multi-chain subgraph indexing system for the Beanstalk/Pinto DeFi protocol. It consists of four specialized subgraphs that index blockchain events and provide GraphQL APIs for protocol data.
yarn codegen [subgraph]- Generate TypeScript types from GraphQL schema and ABIsyarn build <subgraph> <chain>- Build a subgraph for deployment (e.g.,yarn build bean arbitrum)yarn test [subgraph]- Run unit tests for a specific subgraph or all subgraphsyarn testd [subgraph]- Run tests in Docker (preferred method)yarn testd-named <TestName>- Run specific named tests in Dockeryarn build-cache- Update historical cached values for L1->L2 migrationyarn prettier- Format code
Most commands require specifying:
- subgraph: One of
bean,beanstalk,basin,beanft - chain: One of
ethereum,arbitrum,pinto(for Base network)
Docker testing is preferred since console output and some test cases can fail silently without it. First run yarn run graph test -d to build the Docker image, then use yarn testd scripts.
The codebase is organized into four domain-specific subgraphs:
beanstalk- Core protocol mechanics (silo staking, field farming, marketplace, seasons)bean- Token economics and price tracking across poolsbasin- Liquidity pool infrastructure and trading activitiesbeanft- NFT collections and metadata
Each subgraph supports three blockchain networks:
- Ethereum: Full Beanstalk protocol with legacy features
- Arbitrum: L2 deployment with migration support
- Base (Pinto): Simplified protocol without unripe assets
- Constants: Runtime chain detection and protocol configuration
- ABIs: Centralized contract ABIs with versioning support
- Utils: Mathematical operations, data conversions, test infrastructure
- Tests: Shared testing utilities and mocking infrastructure
- Entity-Driven Design: Core entities with time-series snapshots
- Handler-Based Processing: Event handlers organized by functional area
- Runtime Protocol Detection: Dynamic adaptation to different deployments
- Season-Based Synchronization: Time-period coordination across subgraphs
- Ethereum: Complete DeFi suite with unripe assets and fertilizer
- Base: Multi-asset LP pools with simplified gauge system
- Arbitrum: L2 scaling with L1 migration tracking
- Current events reference the latest protocol ABI (no version numbers)
- Legacy events reference the specific upgrade ABI and include version numbers
- Place legacy handlers in
legacy/folders - Separate business logic into
utils/files for reusability
Commands requiring manifest files should specify ./manifests/{chain}.yaml. Examples are provided in package.json scripts.
src/subgraphs/{name}/manifests/- Chain-specific deployment configssrc/subgraphs/{name}/src/entities/- GraphQL entity definitionssrc/subgraphs/{name}/src/handlers/- Event processing logicsrc/subgraphs/{name}/src/utils/- Business logic utilitiessrc/subgraphs/{name}/tests/- Unit tests and mocking utilities
The protocol operates on "seasons" (time periods), with cross-subgraph coordination:
- Season events trigger updates across all subgraphs
- Coordinated snapshot generation for analytics
The subgraphs work together to provide complete protocol visibility:
- Users trade through Wells (Basin subgraph)
- Silo and Field interactions (Beanstalk subgraph)
- Bean price discovery across multiple pools (Bean subgraph)
- NFT rewards track participation (BeanFT subgraph)
- Only develop new changes for
pinto, do not develop forethereumorarbitrum - Do not modify NFT project
- Do not modify L1->L2 migration or use the
yarn build-cachescript