Skip to content

feat(dashboard,backend): implement real-time swap calculator (#1219) … - #1270

Merged
Ceejaytech25 merged 2 commits into
ceejaylaboratory:mainfrom
melvilmz:feat/issue-1219-1209-swap-calculator-worker-graceful-shutdown
Oct 1, 2026
Merged

Ceejaytech25 merged 2 commits into
ceejaylaboratory:mainfrom
melvilmz:feat/issue-1219-1209-swap-calculator-worker-graceful-shutdown

Conversation

@melvilmz

Copy link
Copy Markdown
Contributor

🚀 Pull Request: Real-Time Asset Swap & FX Quote Calculator (#1219) & Worker Graceful Shutdown (#1209)

📌 Summary

This PR addresses two critical issues in a single unified branch:

  1. [Dashboard/SEP38] Implement Real-Time Asset Swap & FX Quote Calculator ([Dashboard/SEP38] Implement Real-Time Asset Swap & FX Quote Calculator #1219):

    • Implements an interactive, responsive FX currency swap calculator (SwapCalculator.tsx) in dashboard/src/components/ fetching live SEP-38 prices.
    • Provides asset pair dropdown selection (USDC, EURC, XLM, USDT, ARST, BTC, ETH), instant input debouncing (350ms), quick asset flip toggle, quick percentage presets (25%, 50%, 75%, 100%), live fee breakdown, and a 30-second live countdown timer with auto-refresh and expired indicator.
    • Implements backend GET /sep38/prices endpoint compliant with SEP-38 specifications in sep38.route.ts.
    • Adds comprehensive unit and component tests in SwapCalculator.test.tsx.
  2. [Backend/Workers] Add Worker Graceful Shutdown Handlers to Prevent Job Corruption ([Backend/Workers] Add Worker Graceful Shutdown Handlers to Prevent Job Corruption #1209):

    • Creates a reusable graceful shutdown utility (graceful-shutdown.ts) with SIGTERM and SIGINT signal listeners.
    • Ensures active BullMQ jobs are given up to a configurable 15-second grace period to finish before closing workers (worker.close()), disconnecting queue connections, and exiting cleanly.
    • Integrates the graceful shutdown handler across background workers including contract-queue.worker.ts, fee-report.worker.ts, and webhook.worker.ts.
    • Adds unit tests in graceful-shutdown.test.ts covering signal capture, clean termination, timeout force-exit, deduplicated signal handling, and error logging.

🛠️ Changes Breakdown

1. Dashboard: SEP-38 Swap Calculator

  • Component Creation:
    • SwapCalculator.tsx: Interactive FX exchange rate calculator with sell/buy inputs, asset selectors, fee computation, expiration countdown bar, and execute swap callbacks.
  • Unit Tests:
    • SwapCalculator.test.tsx: Validates initial rendering, input debouncing, live rate computation, asset flipping, countdown timers, and swap execution.
  • Backend API:
    • sep38.route.ts: Added GET /sep38/prices endpoint to query exchange rates against supported SEP-38 anchor assets.

2. Backend: Worker Graceful Shutdown Handlers

  • Reusable Utility:
    • graceful-shutdown.ts: Exports setupWorkerGracefulShutdown managing BullMQ Worker / Queue teardown, process signal traps (SIGTERM/SIGINT), and 15s timeout protection (process.exit(1) fallback on deadlock).
  • Worker Integration:
    • contract-queue.worker.ts: Registered graceful shutdown on worker launch.
    • fee-report.worker.ts: Registered graceful shutdown on worker launch.
    • webhook.worker.ts: Registered graceful shutdown on worker launch.
  • Unit Tests:
    • graceful-shutdown.test.ts: 5 dedicated unit tests verifying signal registration, timeout escalation, cleanup execution, and error resilience.

3. Repository Stability & Build Verification

  • Resolved router layer conflicts and typing incompatibilities across backend services and frontend components.
  • Verified all unit test suites pass and production builds compile with zero errors (tsc, vite build).

🧪 Testing Matrix

Test Suite Result Details
dashboard/src/components/SwapCalculator.test.tsx ✅ PASSED 7 tests passing (render, debounce, flip, timer expiry, presets, submit)
dashboard/src/components/Sep38QuotePanel.test.tsx ✅ PASSED 6 tests passing (quote lifecycle & auto-refresh)
backend/src/workers/__tests__/graceful-shutdown.test.ts ✅ PASSED 5 tests passing (SIGTERM, SIGINT, timeout, error handling)
backend/src/workers/__tests__/fee-report.worker.test.ts ✅ PASSED Worker initialization & shutdown
backend/src/api/routes/sep38.route.test.ts ✅ PASSED SEP-38 endpoints verification
backend Build (npm run build) ✅ PASSED Clean tsc compilation with 0 errors
dashboard Build (npm run build) ✅ PASSED Production Vite bundle compiled in 1.31s

🔗 Related Issues

@drips-wave

drips-wave Bot commented Sep 24, 2026

Copy link
Copy Markdown

@melvilmz 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! 🚀

Learn more about application limits

@melvilmz
melvilmz force-pushed the feat/issue-1219-1209-swap-calculator-worker-graceful-shutdown branch from 73d91aa to 2dab4c6 Compare September 25, 2026 08:58
@melvilmz
melvilmz force-pushed the feat/issue-1219-1209-swap-calculator-worker-graceful-shutdown branch from 2dab4c6 to 0897dc6 Compare September 25, 2026 09:14
@Ceejaytech25

Copy link
Copy Markdown
Contributor

Nice implementation, LGTM! 🚀 Great work on this contribution — the approach is clean and well thought out. Thanks for contributing to AnchorPoint!

@Ceejaytech25
Ceejaytech25 merged commit ea23d45 into ceejaylaboratory:main Oct 1, 2026
7 of 13 checks 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

2 participants