Skip to content

Add a staking pool stats endpoint returning pool balance, total staked, and recent fee inflow per key #847

Description

@Chucks1093

Summary

The key detail page needs staking pool data to render the APY estimate. A GET /keys/:keyId/staking endpoint that reads staking pool balance, total staked quantity, and recent protocol fee inflow for the key should be added.

Scope

  • Add GET /keys/:keyId/staking endpoint (no auth required)
  • Return stakingPoolBalance, totalStaked, recentFeeInflow (sum of fees in the past 30 days), and stakerCount
  • Read staking state from on-chain contract storage via the Soroban RPC
  • Cache the response in Redis for 60 seconds and invalidate on each stake, unstake, or fee collection event
  • Return 404 for unknown key IDs

Acceptance Criteria

  • All required fields returned correctly
  • recentFeeInflow sums fees for the past 30 days
  • Redis cache served within 60-second TTL
  • Cache invalidated after stake, unstake, or fee event
  • 404 returned for unknown key ID

ETA: 12 hours


Coordinate on Telegram

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions