This subgraph indexes events from the CM Protocol on the Arbitrum Sepolia network. It tracks factories, accounts, pools, tokens, and token transactions.
-
Install dependencies:
npm install -
Generate types:
graph codegen -
Build the subgraph:
graph build
To deploy the subgraph:
-
Authenticate with the Graph CLI:
graph auth --product hosted-service <YOUR_ACCESS_TOKEN> -
Deploy the subgraph:
graph deploy --product hosted-service <GITHUB_USER>/<SUBGRAPH_NAME>
schema.graphql: Defines the data schema for the subgraph.subgraph.yaml: Configuration file that defines the data sources and mappings.src/:registry.ts: Handles events from the Registry contract.factory.ts: Handles events from the CMAccountFactory contract.account.ts: Handles events from the MultiOwnerLightAccount contract.token.ts: Handles ERC20 token transfer events.
abis/: Contains the ABIs for the contracts being indexed.
Factory: Represents an CM Protocol factory.Account: Represents an account created by a factory.Pool: Represents a pool in the protocol.Token: Represents an ERC20 token supported by the protocol.Holding: Represents a token holding for an account.Transaction: Represents a token transfer involving an account.
When making changes:
- Update
schema.graphqlif you're changing the data model. - Modify
subgraph.yamlif you're changing event handlers or adding new data sources. - Update the TypeScript files in
src/to implement new logic. - Run
graph codegento regenerate types after schema changes. - Run
graph buildto check for any build errors. - Test locally if possible before deploying.
Once deployed, you can query the subgraph using GraphQL. Example query:
{
accounts(first: 5) {
id
owners
holdings {
token {
symbol
}
amount
}
transactions(first: 10) {
token {
symbol
}
amount
tag
}
}
}This query fetches the first 5 accounts, their owners, holdings, and recent transactions.