Skip to content

Conversation

@TaprootFreak
Copy link
Contributor

Summary

  • Add new public GET /support/swaps endpoint for swap statistics
  • Returns all swap types (chain, submarine, reverse) with filtering options
  • Provides aggregated stats (total, claimed, expired, refunded, pending, failed)
  • No authentication required - designed for public dashboards

Changes

  • New: src/subdomains/support/dto/swap-stats.dto.ts - Query/Response DTOs
  • Modified: support.service.ts - Added getSwapStats() with fetch/map methods for all swap types
  • Modified: support.controller.ts - Added public GET endpoint

API

GET /support/swaps?type=chain&status=claimed&pair=BTC/cBTC&direction=BTC -> cBTC

Query parameters (all optional):

  • type: chain | submarine | reverse
  • status: all | claimed | expired | refunded | pending | failed
  • pair: e.g. "BTC/cBTC", "USDT_POLYGON/JUSD_CITREA"
  • direction: e.g. "BTC -> cBTC"

Test plan

  • Verify endpoint is accessible without authentication
  • Test filtering by type, status, pair, direction
  • Verify stats calculation matches swap list
  • Test with production Boltz database connection

Add GET /support/swaps endpoint to expose swap statistics without authentication.

Features:
- Query all swap types (chain, submarine, reverse)
- Filter by type, pair, direction, status
- Returns aggregated stats (total, claimed, expired, refunded, pending, failed)
- Returns detailed swap list with source/destination info

New files:
- swap-stats.dto.ts: DTOs for query params and response

Modified:
- support.service.ts: Added getSwapStats() with fetch/map methods
- support.controller.ts: Added public GET endpoint
- Wrap DB queries in try-catch with proper error logging
- Fix sorting to handle invalid dates (NaN fallback to 0)
- Fix toIsoString: handle objects safely, support numeric timestamps
- Reduce cognitive complexity: extract matchesStatusFilter method
- Use pattern lookup instead of switch statement
- Add optional chaining (?.) in stats calculations
- Add nullish coalescing (?? '') in map functions
- Prevent TypeError when DB returns NULL status
@TaprootFreak TaprootFreak requested a review from Danswar January 29, 2026 11:46
@TaprootFreak TaprootFreak marked this pull request as ready for review January 29, 2026 11:46
@TaprootFreak TaprootFreak merged commit 696babf into develop Jan 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants