Skip to content

Fix Total Stake hero value to use validator staking pool - #62

Open
ignacio-rsg wants to merge 1 commit into
Magma-Devs:mainfrom
ignacio-rsg:fix/total-stake-staking-pool
Open

Fix Total Stake hero value to use validator staking pool#62
ignacio-rsg wants to merge 1 commit into
Magma-Devs:mainfrom
ignacio-rsg:fix/total-stake-staking-pool

Conversation

@ignacio-rsg

Copy link
Copy Markdown

Summary

Fixes the dashboard hero Total Stake metric on Lava Info.

Previously, /index/stats calculated totalStake by summing provider stake plus provider delegation across all providers:

provider.totalStake + provider.totalDelegation

That made the dashboard display a provider restake/delegation total instead of the validator staking total expected by the UI label.

This PR changes totalStake to use the official Cosmos staking pool value from:

/cosmos/staking/v1beta1/pool

Specifically, the dashboard now uses:

pool.bonded_tokens

This matches the ticket expectation of approximately 381M LAVA.

What Changed

  • Updated GET /index/stats to fetch the staking pool via the existing fetchStakingPool() helper.
  • Changed totalStake to return stakingPool.bonded_tokens.
  • Kept fetchAllProviders() in place for activeProviderCount.
  • Updated the /index/stats route test to ensure totalStake comes from the staking pool, not provider stake/delegation totals.

What Did Not Change

The rest of the dashboard stat logic is unchanged:

  • totalCu still comes from Indexer GraphQL all-time relay aggregates.
  • totalRelays still comes from Indexer GraphQL all-time relay aggregates.
  • cu30d still comes from Indexer GraphQL 30-day aggregates.
  • relays30d still comes from Indexer GraphQL 30-day aggregates.
  • activeProviderCount still comes from fetchAllProviders().
  • latestBlock still comes from fetchLatestBlockHeight().

Local Verification

Verified locally that /index/stats now returns:

"totalStake": "381345490217757"

which renders as approximately:

381.35M LAVA

Verified source endpoint:

https://lava.rest.lava.build/cosmos/staking/v1beta1/pool

returns:

{
  "pool": {
    "not_bonded_tokens": "41395102178952",
    "bonded_tokens": "381345490217757"
  }
}

Tests

Passed:

pnpm --filter @info/api exec vitest run src/__tests__/routes-index.test.ts
pnpm --filter @info/api test
pnpm --filter @info/api typecheck
pnpm --filter @info/web typecheck

Notes

The local dashboard may show 0 for CU and relay metrics unless a real INDEXER_GRAPHQL_URL is configured. That is unrelated to this fix. Those values still use the same existing indexer logic.

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.

1 participant