Repository navigation
feat(api): migrate lava-ops monthly rewards pipeline to info endpoints - #32
Merged
Merged
Conversation
Replaces the fragile monthly cron pipeline (lava-ops Jobs 1, 2, 3) with on-demand API endpoints so the lava-rewards repo can become a thin Next.js client instead of a file-commit sink. - /provider-rewards: fix multi-chain aggregation. GraphQL groupBy is now [PROVIDER] by default (pools all chains before cbrt to match delta's non-linear formula) and [CHAIN_ID, PROVIDER] with the new ?groupBy=spec for per-spec rows. Adds within-spec rewardShare and meta.bySpec in spec mode. - /provider-estimated-rewards: new ?block=N threads blockHeight through fetchRewardsBySpec -> fetchRest via the existing x-cosmos-block-height header. Adds ?spec=X server-side filter and /provider-estimated-rewards/blocks sub-route listing the 17th-of- month snapshots via fetchBlockAtTimestamp. USD values keep using current CoinGecko prices even for historical blocks (matches the old Job 2 behavior). - /provider-claimable-rewards: ports jsinfo's /lava_mainnet_provider_claimable_rewards using the existing fetchDelegatorRewards + prewarmPriceCache plumbing. - /validators-and-rewards: ports jsinfo's /lava_mainnet_validators_and_rewards — 5 RPC calls per validator (distribution, outstanding, estimated, delegations, unbonding), batched 3 at a time, all denoms converted to USD. - /burn-rate: monthly total-supply snapshots with supply_diff. Replaces lava-ops Job 3 and the lavad/Python/burn-ui commit chain entirely. Test coverage: 97 tests (up from 79). Typecheck clean across all packages. Smoke test against a live stack was not run — local docker + indexer GraphQL required.
- Close cache-key amplification by setting additionalProperties:false on querystring schemas for burn-rate, provider-rewards, and both provider-estimated-rewards endpoints; Fastify now rejects unknown query params instead of spawning unique cache entries per junk key. - Register missing "Validators" swagger tag so /validators-and-rewards renders in /docs. - Introduce RPC_BATCH_SIZE env var (default 25, up from 3–5) used for every RPC fan-out in rpc/lava.ts plus the two batched routes; keep lower defaults for public RPC, raise via env on dedicated endpoints. - Surface priceLavaUsd + priceTimestamp in /provider-estimated-rewards meta so consumers of historical block queries see USD is priced at request time, not at the queried block. - Add AbortSignal.timeout to all remaining external fetches (Osmosis, Geckoterminal, Uniswap, CoinGecko, Keybase) to prevent hangs on slow upstreams from tying up request-loop slots. - Document RPC_BATCH_SIZE in env vars, updated meta fields on the estimated-rewards endpoint, and replaced the hard-coded validator batch doc with the configurable form.
nimrod-teich
added a commit
that referenced
this pull request
Apr 20, 2026
The chain RPC returns per-source entries like "Boost: ETH1", "Pools: ETH1",
"Subscription: ETH1". The previous implementation collapsed these into
per-spec totals, discarding the source categorization — which the
rewards-ui provider_rewards and validator_rewards pages need for their
Subscription / Pool / Boost / IPRPC columns.
- RewardsBySpecEntry now carries sources[]: per-source breakdown under
each spec with raw chain source string + token amounts + USD total.
- ValidatorWithRewards.estimated_rewards is now EstimatedRewardsWithInfo
which extends TokenBreakdown with info[]: the jsinfo-compatible
{source, amount: {tokens, total_usd}} shape.
- fetchRewardsBySpec tracks per-(spec, source) denom sums alongside the
existing per-spec sums.
- fetchValidatorEstimated returns {total, info}; fetchValidatorsWithRewards
runs USD conversion for each info entry in parallel with the total.
Additive change — existing fields (tokens, total_usd) are unchanged. Tests
updated to assert the new fields flow through; 98/98 passing.
Stacked on top of feat/rewards-migration-endpoints (PR #32).
2 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the fragile monthly cron pipeline (lava-ops Jobs 1, 2, 3) with on-demand API endpoints so the
lava-rewardsrepo can become a thin Next.js client instead of a file-commit sink.Changes
/provider-rewards: fix multi-chain aggregation. GraphQLgroupByis now[PROVIDER]by default (pools all chains beforecbrtto match delta's non-linear formula) and[CHAIN_ID, PROVIDER]with the new?groupBy=specfor per-spec rows. Adds within-specrewardShareandmeta.bySpecin spec mode./provider-estimated-rewards: new?block=NthreadsblockHeightthroughfetchRewardsBySpec→fetchRestvia the existingx-cosmos-block-heightheader. Adds?spec=Xserver-side filter and/provider-estimated-rewards/blockssub-route listing the 17th-of-month snapshots viafetchBlockAtTimestamp. USD values keep using current CoinGecko prices even for historical blocks (matches old Job 2 behavior)./provider-claimable-rewards(new): ports jsinfo's/lava_mainnet_provider_claimable_rewardsusing the existingfetchDelegatorRewards+prewarmPriceCacheplumbing./validators-and-rewards(new): ports jsinfo's/lava_mainnet_validators_and_rewards— 5 RPC calls per validator (distribution, outstanding, estimated, delegations, unbonding), batched 3 at a time, all denoms converted to USD./burn-rate(new): monthly total-supply snapshots withsupply_diff. Replaces lava-ops Job 3 and thelavad/Python/burn-uicommit chain entirely.Depends on
cu > 0guard on the MV QoS sums for byte-exact parity. Not blocking (numbers are practically identical), but should land together.Migration plan
REFRESH MATERIALIZED VIEW app.mv_relay_dailyon prod.lava-rewardsFE at info: repoint the 5 pages insrc/app/**(monthly_provider_data, provider_rewards, provider_rewards_by_spec, provider_claimable_rewards, validator_rewards).lava-rewards/scripts/andsrc/app/monthly_provider_data/data/*.csv. Deprecaterelayserver/pkg/handlers/adjustedrewards.go.Test plan
pnpm typecheckclean across all packagespnpm test— 97 tests passing (up from 79; 18 new tests across the new and refactored routes)/provider-rewards?from=&to=against a staging indexer and confirm numbers match an existing delta CSV for the same month/provider-rewards?groupBy=specand confirm per-spec numbers match per-spec CSVs/provider-estimated-rewards?block=<past block>and confirm non-empty response/provider-estimated-rewards/blocksreturns 12 monthly entries/provider-claimable-rewardsand compare shape with jsinfo's response/validators-and-rewardsand compare shape with jsinfo's response/burn-rate?months=6and confirm supply_diff values look sane