Repository navigation
feat: staking epoch indexer and rewards accumulation API (#1086) - #1188
Chucks1093 merged 3 commits into
Conversation
…org#1086) Index StakeCreated, EpochRewardDistributed, and RewardsClaimed contract events into stakes and epoch_rewards tables. Expose three REST endpoints: GET /staking/:wallet/positions active stakes with live rewards GET /staking/:wallet/positions/:id single stake + epoch breakdown GET /keys/:keyId/epochs epoch reward history for a key Accrued rewards are fetched live per request via simulateTransaction on the staking contract's get_stake_rewards view function; failures degrade to '0' so a temporarily unavailable contract doesn't break list responses. - prisma/schema/staking-epoch.prisma: Stake and EpochReward models; both idempotent on @@unique([txHash, eventIndex]) - migration 20261020100000_add_staking_epochs: stakes and epoch_rewards DDL with composite indexes for active-position and epoch-history queries - staking-epoch.contract.ts: BigInt-safe ScVal decoder, mirrors lp-rewards contract pattern - staking-epoch.service.ts: recordStake/removeStake/recordEpochReward writes; getActivePositions/getPosition/getKeyEpochs reads with parallel live rewards - staking-epoch-indexer.service.ts: validates required fields + numeric/date sanity per event; REWARDS_CLAIMED closes position only when closePosition is true; checkpoints highest ledger after each batch - staking-epoch.routes.ts: wallet-scoped positions routes behind requireWalletParamMatch; epochs route behind requireJwtAuth - config.schema.ts: adds optional STAKING_CONTRACT_ID env var - indexer-pipeline.service.ts: routes STAKING_EPOCH_EVENT_TYPES via lazy import before cursor advance
|
@jennioo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
1 similar comment
|
✅ PR Ready for ReviewDue to a recent malware incident affecting our repositories, all PRs are required to pass automated security checks before being reviewed for merging. This PR has passed all automated checks:
Next step: Please share this PR link in our Telegram group so a maintainer can review and merge it: https://t.me/c/accesslayerorg/8514 |
Index StakeCreated, EpochRewardDistributed, and RewardsClaimed contract events into stakes and epoch_rewards tables. Expose three REST endpoints:
closes #1086
GET /staking/:wallet/positions active stakes with live rewards
GET /staking/:wallet/positions/:id single stake + epoch breakdown
GET /keys/:keyId/epochs epoch reward history for a key
Accrued rewards are fetched live per request via simulateTransaction on the staking contract's get_stake_rewards view function; failures degrade to '0' so a temporarily unavailable contract doesn't break list responses.
Summary
Testing
pnpm lintpnpm buildpnpm exec prisma generatewhen schema or generated types changedChecklist