Enable timeseries for stateful-m-token (M Token subgraph for mainnet)#26
Enable timeseries for stateful-m-token (M Token subgraph for mainnet)#26oleksandr-fedorenko-m0 wants to merge 2 commits into
stateful-m-token (M Token subgraph for mainnet)#26Conversation
|
@jonalvarezz check it please |
There was a problem hiding this comment.
Pull request overview
This PR enables timeseries functionality for the M Token mainnet subgraph, allowing time-based aggregation of key metrics (latestIndex, latestRate, and latestUpdateTimestamp). The changes upgrade the subgraph infrastructure to support The Graph's timeseries features and migrate deployment from Alchemy to Goldsky.
Changes:
- Upgraded subgraph spec version from 1.0.0 to 1.2.0 and API version from 0.0.7 to 0.0.9 to support timeseries entities
- Converted LatestIndexSnapshot, LatestRateSnapshot, and LatestUpdateTimestampSnapshot to timeseries entities with corresponding aggregation types for hourly and daily data
- Migrated deployment infrastructure from Alchemy to Goldsky with improved dependency checks
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| stateful-m-token/subgraph.yaml | Updated spec and API versions; added LatestIndex entity to support timeseries aggregation |
| stateful-m-token/src/m-token.ts | Modified snapshot update functions to use constant timeseries ID; removed load logic for timeseries entities |
| stateful-m-token/schema.graphql | Converted three snapshot entities to timeseries format with Int8 IDs; added aggregation types; marked entities as immutable: false |
| stateful-m-token/package.json | Updated graph-cli to 0.98.1 and graph-ts to 0.38.2 for timeseries support |
| stateful-m-token/deploy.sh | Migrated from Alchemy to Goldsky deployment with dependency validation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jonalvarezz
left a comment
There was a problem hiding this comment.
I checked the information and compared to the one we in production (m-token-mainnet/0.0.1) and it matches the information ✅
It's a bummer though that the timeseries don't return the current value for the partially filled day. The documentation mentions an optional currentData arg, but I can't find it. So we had to get the latest one from the entity itself
However, the data to download is significantly lower for calculating daily yields.
I couldn't figure out how to add the _collection postfix.
It was automatically added for timeseries. Seems like they, luckily, removed it on recent versions.
Action: Let's add our prefix so it is explicit, how about latestRateTimeseries? so we can tell them apart from regular entities.
as for production deployment, it needs follow up on M earner worker to account for this changes. Let's have a call about it
I tried, but I couldn't get the current snapshot either. |
|
Thank you Olek, will need some time to plug in the m-earner-worker against this new indexer and compare the output. let's keep it open for now 👍 |

https://linear.app/mzero/issue/FS-553/improve-how-index-and-rate-are-stored
Deployment: https://api.goldsky.com/api/public/project_cmgzirwl000165np20d5n16h6/subgraphs/m-token-mainnet/0.0.2/gn
I couldn't figure out how to add the
_collectionpostfix.