Skip to content

fix(provider-rewards): use actual reward pool for estimated amounts - #30

Merged
nimrod-teich merged 3 commits into
mainfrom
fix/provider-rewards-estimated-usd
Apr 16, 2026
Merged

nimrod-teich merged 3 commits into
mainfrom
fix/provider-rewards-estimated-usd

Conversation

@nimrod-teich

@nimrod-teich nimrod-teich commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • estimatedRewardsUsd was broken: computed share × lavaPrice (fraction × USD/token = nonsense). A provider with 10% share at LAVA=$2 would get $0.20.
  • Now fetches the 3 provider-side reward pools (distribution, allocation, iprpc) and computes share × providerPoolLava × lavaUsdPrice
  • Adds estimatedRewardsLava field per provider and providerPoolLava in response meta so consumers know the total pool being distributed

Changes

  • rpc/lava.ts — new fetchProviderRewardPoolsAmount() (provider pools only, excludes validator pools)
  • routes/provider-rewards.ts — pool fetch in parallel, fixed USD calc, added LAVA estimate field
  • __tests__/routes-provider-rewards.test.ts — pool mock, USD/LAVA assertions, pool-failure degradation test

Test plan

  • pnpm typecheck passes
  • pnpm test — all 72 tests pass
  • Verify response shape on staging: GET /provider-rewards?from=2026-03-17&to=2026-04-17
  • Confirm estimatedRewardsUsd values are sane (order of magnitude check against known pool size)
  • Confirm graceful null when CoinGecko or RPC is down

…amounts

estimatedRewardsUsd was computing share × lavaPrice which is dimensionally
wrong (fraction × USD/token = nonsense). Now uses the provider-side reward
pools (distribution + allocation + iprpc) so the formula is:
share × providerPoolLava × lavaUsdPrice.

Adds estimatedRewardsLava field and providerPoolLava in response meta.
Gracefully degrades to null when pool or price fetch fails.
Queries the chain's estimated_provider_rewards/{address} RPC for every
active provider, groups rewards by spec (collapsing Boost/Pools/Subscription
sources), converts multi-denom amounts to USD via CoinGecko, and returns
per-provider actual reward data sorted by total USD.

This replaces the gen_provider_rewards.py → push to jsinfo flow that
lava-ops Job 2 performed monthly. Consumers can now call this endpoint
on demand instead of depending on static JSON files.

Exports fetchRewardsBySpec, fetchProvidersWithSpecs, prewarmPriceCache,
and RewardsBySpecEntry from rpc/lava.ts for reuse.
…te docs

- Import BASE_SPECS from @info/shared instead of duplicating locally
- Extract shared fetchRewardPools() so both fetchRewardPoolsAmount and
  fetchProviderRewardPoolsAmount share one RPC call via request coalescing
- Document new /provider-estimated-rewards endpoint in CLAUDE.md
- Update /provider-rewards docs with new estimatedRewardsLava field
- Add no-co-author rule to git-workflow.md
- Add safe-range comment on Number(ulava) conversion
@nimrod-teich
nimrod-teich force-pushed the fix/provider-rewards-estimated-usd branch from fa05928 to 976b4a1 Compare April 16, 2026 13:13
@nimrod-teich
nimrod-teich merged commit 4cc50b8 into main Apr 16, 2026
2 checks passed
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