π 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
π Security notes
N/A β read-only aggregate metric over already-exposed settlement data.
π Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
π Description
routes/metrics.ts'ssnapshot()reportssettlements/pendingSettlementsas counts andtotalLiquidityas a pool-wide sum, but never sums settlementamount/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
totalSettledAmountandtotalFeesCollected(or similarly named) fields toMetricsSnapshot, computed fromexecutedsettlements only (fees/amounts ofpending/cancelledsettlements shouldn't count toward "collected").anchors,activeAnchors,pools,totalLiquidity,settlements,pendingSettlements) unchanged.π οΈ Suggested execution
src/routes/metrics.ts'sMetricsSnapshotinterface andsnapshot()function to compute the new sums fromdeps.settlements.list()filtered tostatus === "executed".src/openapi.ts's/api/v1/metricsentry to document the new fields.src/routes/metrics.test.tscovering a mix of pending/executed/cancelled settlements to verify only executed ones contribute to the new totals.β Acceptance criteria
GET /api/v1/metricsincludes correcttotalSettledAmount/totalFeesCollectedcomputed only from executed settlements.GET /api/v1/metrics/historysnapshot shape remain backward compatible (new fields simply added).π Security notes
N/A β read-only aggregate metric over already-exposed settlement data.
π Guidelines