Skip to content

Enable timeseries for stateful-m-token (M Token subgraph for mainnet)#26

Open
oleksandr-fedorenko-m0 wants to merge 2 commits into
mainfrom
feat/FS-553
Open

Enable timeseries for stateful-m-token (M Token subgraph for mainnet)#26
oleksandr-fedorenko-m0 wants to merge 2 commits into
mainfrom
feat/FS-553

Conversation

@oleksandr-fedorenko-m0

@oleksandr-fedorenko-m0 oleksandr-fedorenko-m0 commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

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 _collection postfix.

{
  latestIndexes (interval:day, orderBy:timestamp, first:5) {
    id
    timestamp
    value
    count
	}
  latestRates (interval:day,orderBy:timestamp, first:5) {
    id
    timestamp
    value
    count
	}
  latestUpdateTimestamps(interval:day, orderBy:timestamp, first:5) {
    id
    timestamp
    value
    count
	}
}

@oleksandr-fedorenko-m0

Copy link
Copy Markdown
Contributor Author

@jonalvarezz check it please

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread stateful-m-token/schema.graphql Outdated
Comment thread stateful-m-token/subgraph.yaml
Comment thread stateful-m-token/schema.graphql
Comment thread stateful-m-token/schema.graphql

@jonalvarezz jonalvarezz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the information and compared to the one we in production (m-token-mainnet/0.0.1) and it matches the information ✅

Image

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

@oleksandr-fedorenko-m0

Copy link
Copy Markdown
Contributor Author

I checked the information and compared to the one we in production (m-token-mainnet/0.0.1) and it matches the information ✅

Image 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](https://thegraph.com/docs/en/subgraphs/best-practices/timeseries/#notes), 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.

@jonalvarezz

Copy link
Copy Markdown
Contributor

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants