Skip to content

Add settlement volume totals (sum of amount/fee) to the routes/metrics.ts snapshot, not just countsΒ #146

Description

@Jagadeeshftw

πŸ“Œ Description

routes/metrics.ts's snapshot() reports settlements/pendingSettlements as counts and totalLiquidity as a pool-wide sum, but never sums settlement amount/fee β€” an operator can't currently see total value settled or total protocol fees collected without fetching every settlement and summing client-side.

🧩 Requirements and context

  • Add totalSettledAmount and totalFeesCollected (or similarly named) fields to MetricsSnapshot, computed from executed settlements only (fees/amounts of pending/cancelled settlements shouldn't count toward "collected").
  • Keep existing fields (anchors, activeAnchors, pools, totalLiquidity, settlements, pendingSettlements) unchanged.

πŸ› οΈ Suggested execution

  • Modify src/routes/metrics.ts's MetricsSnapshot interface and snapshot() function to compute the new sums from deps.settlements.list() filtered to status === "executed".
  • Update src/openapi.ts's /api/v1/metrics entry to document the new fields.
  • Add tests in src/routes/metrics.test.ts covering a mix of pending/executed/cancelled settlements to verify only executed ones contribute to the new totals.

βœ… Acceptance criteria

  • GET /api/v1/metrics includes correct totalSettledAmount/totalFeesCollected computed only from executed settlements.
  • Existing fields and GET /api/v1/metrics/history snapshot shape remain backward compatible (new fields simply added).

πŸ”’ Security notes

N/A β€” read-only aggregate metric over already-exposed settlement data.

πŸ“‹ Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issueapiHTTP/WebSocket APIenhancementNew feature or improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions