feat: added settlement reconciliation report#670
Open
DTech-Wiz1 wants to merge 1 commit into
Open
Conversation
|
@DTech-Wiz1 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #642
Pull Request: Add Admin Settlement Reconciliation Report Endpoint
Summary
This PR introduces a read-only admin API endpoint for retrieving the latest settlement reconciliation results. The endpoint exposes reconciliation run metadata and a paginated list of unmatched records, enabling operators to investigate settlement discrepancies without relying on logs.
Problem
The settlement reconciler (
src/jobs/settlementReconciler.ts) currently compares payout records against the Horizon ledger and detects discrepancies. However, the results are only available through logs, making operational triage difficult during incidents.Operators need a queryable view of reconciliation results to quickly identify and investigate settlement drift.
Solution
New Admin Endpoint
Added:
Location:
Features:
Changes
Persistence Layer
Persist reconciliation results from each run, including:
This allows the latest reconciliation state to be queried without rerunning reconciliation logic.
API Response
Returns:
{ "success": true, "data": { "summary": { "matchedCount": 1200, "unmatchedCount": 12, "runTimestamp": "2026-06-30T12:00:00Z" }, "discrepancies": { "items": [...], "nextCursor": "..." } } }Pagination
Implemented cursor-based pagination using:
to ensure consistency with existing APIs.
Validation
Query parameters are validated using Zod before execution.
Supported parameters include:
cursorlimitValidation failures return standard API error responses.
Metrics
Added a Prometheus gauge via
prom-client:settlement_reconciliation_unmatched_countThe metric reflects the current unmatched record count from the latest reconciliation run.
Type Reuse
The endpoint reuses the reconciler's existing result types and discrepancy definitions rather than recalculating or redefining reconciliation output within the route layer.
Guarantees
Testing
Added/updated tests to verify:
Operational Impact
Before:
After: