feat: comprehensive stablecoin hardening — atomicity, middleware, polyglot services, UI/UX parity#26
Merged
munisp merged 1 commit intoJun 23, 2026
Conversation
…yglot services, UI/UX parity - Wire all 14 stablecoin endpoints through atomic fund flow middleware (Redis locks, idempotency, TigerBeetle double-entry, Temporal sagas, Kafka events) - Fix non-atomic wallet updates with pessimistic WHERE balance >= amount - Add DCA scheduler, auto-convert watcher, P2P claim flow with 30-day expiry - Add 3 new router endpoints: redeemP2pClaim, pauseDcaPlan, resumeDcaPlan - Wire insider threat controls (maker-checker, geo-fence, DLP) on stablecoin ops Polyglot services: - Go settlement orchestrator (port 8200): TigerBeetle ledger, Dapr state, Kafka events, Circle/Yellow Card webhook handlers, Mojaloop ILP settlement - Rust on-chain guard (port 8210): Ed25519/ECDSA signature verification, fencing tokens, double-spend detection, receipt chain - Python oracle (port 8220): Live FX rates (4-source median), de-peg monitoring (1% threshold), DeFi yield tracking (Aave/Compound/Venus), Fluvio streaming Infrastructure: - APISix: 14 stablecoin routes with circuit breaking + rate limiting - OpenAppSec: WAF rules for webhook endpoints - OpenSearch: Index templates for transactions, settlements, depeg events, FX rates - Fluvio: 11 topics with SmartModules (depeg filter, high-value filter, FX anomaly) - Lakehouse: Bronze/Silver/Gold tables for stablecoin analytics UI/UX parity: - PWA: 11-tab stablecoin dashboard (on-ramp, off-ramp, swap, send, yield, bridge, P2P, bill pay, DCA, virtual card, history) with de-peg alerts - Flutter: Full stablecoin screen with all 7 operations - React Native: Full stablecoin screen with 7 tabs and modal picker Tests: 50+ vitest assertions covering atomicity, DCA, auto-convert, P2P claims, APISix routes, OpenSearch templates, Fluvio topics, Lakehouse tables, UI parity Co-Authored-By: Patrick Munis <pmunis@gmail.com>
Contributor
Author
Original prompt from Patrick
|
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Closes all 10 stablecoin gaps identified in the audit. Every stablecoin endpoint now flows through the atomic fund flow middleware (Redis distributed lock → idempotency cache → TigerBeetle double-entry → Temporal saga compensation → Kafka/Fluvio events), matching the safety guarantees on fiat fund flows from PRs #21-23.
Core changes
Atomicity wrapper (
server/middleware/stablecoinAtomicity.ts): All 14 stablecoin mutations now callexecuteAtomicStablecoinFlow()which delegates towithAtomicFundFlow()from PR #22, adding stablecoin-specific Kafka topic routing and insider threat control checks (maker-checker for ops >$10K, geo-fencing, DLP).Non-atomic wallet fix:
stakeForYieldandbridgeChainpreviously didSELECT balance→ JS check →UPDATE. Now use pessimisticWHERE CAST(balance AS DECIMAL) >= amounton all debit paths.3 new router endpoints on
stablecoinEnhanced:redeemP2pClaim— validates claim link, checks 30-day expiry, credits stablecoinpauseDcaPlan/resumeDcaPlan— DCA lifecycle managementDCA + auto-convert + P2P claim (
server/services/stablecoinScheduler.ts):executeDcaPurchase(plan)→ atomic fiat→stablecoin viaexecuteAtomicStablecoinFlowautoConvertIncomingRemittance(userId, amount, fiatCurrency, ref)→ checks user preference, converts % to target stablecoinexecuteP2pClaim(claimId, userId)→ validates 30-day expiry, atomic creditexpireStaleP2pClaims()→ daily cron refunds expired claims to sendersPolyglot services
Infrastructure configs
infra/apisix/stablecoin-routes.yaml): 14 routes with circuit breaking (2-5 failure threshold), rate limiting, OpenAppSec WAF on webhook endpointsinfra/opensearch/stablecoin-index-templates.json): Index templates for transactions, settlements, depeg events, FX ratesinfra/fluvio/stablecoin-streaming.yaml): 11 topics with SmartModules (depeg-filter, high-value-filter, fx-anomaly-detector)infra/lakehouse/stablecoin-tables.yaml): Bronze (raw events) → Silver (enriched) → Gold (aggregated) analytics tablesUI/UX parity
Stablecoin.tsx): 11-tab dashboard — on-ramp, off-ramp, bank withdrawal, swap, send, yield, bridge, P2P send, bill pay, DCA, virtual card. De-peg alert banner. Fixedtrpc.stablecoin.*→trpc.stablecoinPlatform.*for enhanced endpoints.stablecoin_screen.dart): 7-tab screen with all operations, matching dark themeStablecoinScreen.tsx): 7-tab screen with modal picker, all 8 mutations wiredTests
50+ vitest assertions in
server/stablecoin-hardening.test.tscovering: atomicity wrapper, pessimistic debit, DCA scheduler, auto-convert, P2P claim flow (30-day expiry), APISix routes (14 routes, 11 circuit breakers), OpenSearch templates, Fluvio topics, Lakehouse tables, Go/Rust/Python service structure, UI parity verification.6,633 lines added across 16 files, 0 TypeScript errors.
Link to Devin session: https://app.devin.ai/sessions/64d054ae77da41e9a2b74d8593fa635c
Requested by: @munisp