Skip to content

feat: add total locked token metrics#101

Open
pyropy wants to merge 7 commits intomainfrom
feat/add-total-locked-token-metrics
Open

feat: add total locked token metrics#101
pyropy wants to merge 7 commits intomainfrom
feat/add-total-locked-token-metrics

Conversation

@pyropy
Copy link
Member

@pyropy pyropy commented Feb 3, 2026

Adds a totalFixedLockup and totalStreamingLockup properties to Token subgraph entity and displays "Total locked USDFC" and "Total locked FIL" token metrics on homepage.

Closes #100

@pyropy pyropy self-assigned this Feb 3, 2026
@FilOzzy FilOzzy added this to FOC Feb 3, 2026
@github-project-automation github-project-automation bot moved this to 📌 Triage in FOC Feb 3, 2026
@pyropy pyropy moved this from 📌 Triage to ⌨️ In Progress in FOC Feb 3, 2026
@pyropy pyropy marked this pull request as ready for review February 3, 2026 15:16
@pyropy pyropy moved this from ⌨️ In Progress to 🔎 Awaiting review in FOC Feb 3, 2026
totalSettledAmount
userFunds
totalUsers
totalLocked
Copy link
Member Author

Choose a reason for hiding this comment

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

NOTE: This query is broken until we actually deploy new subgraph with totalLocked field.

@rjan90 rjan90 added this to the M4.1: mainnet ready milestone Feb 3, 2026
@vercel
Copy link

vercel bot commented Feb 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
filecoin-pay-explorer Ready Ready Preview, Comment Feb 5, 2026 3:52pm

Request Review

Copy link
Collaborator

@silent-cipher silent-cipher left a comment

Choose a reason for hiding this comment

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

Overall looks good to me!

Comment on lines 365 to 372
if (!isTerminated) {
const token = Token.load(rail.token);
if (token) {
const streamingDelta = newLockup.minus(oldLockup);
token.totalStreamingLockup = token.totalStreamingLockup.plus(streamingDelta);
token.save();
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we only updating totalStreamingLockup for non-terminated rails? Shouldn’t this be updated in both cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the rail has already been terminated, the lockup period may not be altered and the fixed lockup may only be reduced.

This is from docs for modifyRailLockup method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But this handler is for 'RailRateModified'.

Copy link
Member Author

Choose a reason for hiding this comment

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

True, this shouldn't be called for terminated rails, but there's also other parts in this handler where the check is done

  const isTerminated = rail.state === "TERMINATED";
  if (!isTerminated) {
    updateOperatorRate(operatorApproval, oldRate, newRate);
    updateOperatorTokenRate(operatorToken, oldRate, newRate);

    if (payerToken) {
      payerToken.lockupRate = payerToken.lockupRate.minus(oldRate).plus(newRate);
      payerToken.save();
    }
  }

Should we just clear this handler to return early if rail state is terminated?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the handler can still be triggered for terminated rails. modifyRailPayment is allowed for both terminated and non-terminated rails.
The key differences for terminated rails are:

  • newRate must be lower than oldRate
  • the effective lockup period becomes endEpoch - currentBlockNumber

Because of this, some updates still need to be guarded rather than returning early for terminated rails.

There was also an audit issue related to this behavior of updating terminated rail's rate- more context here

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay I see now.. I've mixed modifyRailLockup and modifyRailPayment 😮‍💨

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in fc4a45b

@github-project-automation github-project-automation bot moved this from 🔎 Awaiting review to ⌨️ In Progress in FOC Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ⌨️ In Progress

Development

Successfully merging this pull request may close these issues.

Add Total USDFC & FIL locked metric

3 participants