8.6 KiB
8.6 KiB
M-RTGS Settlement Flow
Overview
The Multi-Asset RTGS System (M-RTGS) provides instantaneous settlement (< 100ms target) for multiple asset types (fiat, CBDC, SSU, commodities, securities) in a single synchronized settlement cycle. This flow documents the priority queue management and multi-asset settlement process.
Prerequisites
- Payment request with valid source and destination accounts
- Sufficient balance/position in source account
- Asset type supported by M-RTGS
- M-RTGS service operational
- Queue manager initialized
Visual Flow Diagram
┌─────────────┐
│ Payment │
│ Request │
└──────┬──────┘
│
│ 1. Add to Queue
▼
┌─────────────────────────┐
│ Queue Manager │
│ - Calculate priority │
│ - Priority = systemic │
│ + fx_cost + │
│ liquidity + SRI │
└──────┬──────────────────┘
│
│ 2. Priority Score
▼
┌─────────────────────────┐
│ Queue Processing │
│ - Tier 1: Sovereign │
│ - Tier 2: Interbank │
│ - Tier 3: Retail │
└──────┬──────────────────┘
│
│ 3. Process Next
▼
┌─────────────────────────┐
│ Risk Monitor │
│ - Velocity check │
│ - Liquidity check │
│ - FX slip check │
└──────┬──────────────────┘
│
│ 4. Risk Cleared
▼
┌─────────────────────────┐
│ Multi-Asset Settlement │
│ - Multi-ledger sync │
│ - < 100ms target │
│ - Status tracking │
└──────┬──────────────────┘
│
│ 5. Settled
▼
┌─────────────┐
│ Settlement │
│ Complete │
└─────────────┘
Step-by-Step Process
Step 1: Payment Queue Addition
- Receive payment request with:
- Source bank ID
- Destination bank ID
- Amount and currency
- Asset type (fiat, CBDC, SSU, commodity, security)
- Payment priority
- Calculate priority score:
priority = systemic_value + fx_cost_penalty + liquidity_weight + SRI_adjustment - Determine priority tier:
- Tier 1: Sovereign & systemic transactions
- Tier 2: Interbank transactions
- Tier 3: Retail CBDC traffic during peak hours
- Add payment to appropriate queue with priority score
- Generate queue entry ID
Code Reference: src/core/settlement/m-rtgs/ (queue manager service)
Step 2: Queue Processing
- Queue manager selects next payment based on:
- Priority tier
- Priority score within tier
- First-in-first-out for same priority
- Lock payment entry to prevent concurrent processing
- Verify payment still valid:
- Source account still active
- Sufficient balance available
- Destination account still active
Step 3: Risk Monitoring
- Check transaction velocity:
- Count transactions from source in time window
- Verify within velocity limits
- Check liquidity congestion:
- Verify sufficient liquidity in system
- Check for liquidity bottlenecks
- Check FX slip (if cross-currency):
- Verify FX rate stability
- Check for excessive volatility
- Check commodity price shocks (if commodity asset):
- Verify commodity price stability
- Check CBDC routing patterns:
- Verify no abnormal routing detected
- If any risk check fails, flag payment and escalate
Code Reference: src/core/settlement/m-rtgs/ (risk monitor service)
Step 4: Multi-Asset Settlement Execution
- Determine settlement method based on asset type:
- Fiat: Standard ledger posting
- CBDC: CBDC ledger posting
- SSU: SSU transaction service
- Commodity: CDT settlement service
- Security: Security token settlement
- Execute multi-ledger synchronization:
- Post to source ledger
- Post to destination ledger
- Post to master ledger (if required)
- Monitor settlement time:
- Start timer at settlement initiation
- Target: < 100ms total time
- Log if exceeds target
- Update payment status:
- Mark as "settling" during execution
- Mark as "settled" on completion
- Record settlement timestamp
Code Reference:
src/core/settlement/m-rtgs/(settlement service)src/core/ledger/ledger.service.tssrc/core/settlement/ssu/ssu-service.tssrc/core/commodities/cbds/cdt-settlement.service.ts
Step 5: MACE Integration (if collateralized)
- If payment requires collateral:
- Calculate required initial margin (IM):
IM = exposure * volatility * SRI_factor - Verify collateral availability
- Allocate collateral via MACE engine
- Calculate required initial margin (IM):
- Update collateral positions
- Monitor margin requirements
Code Reference: src/core/settlement/m-rtgs/ (MACE integration service)
Step 6: Settlement Confirmation
- Verify all ledger entries posted successfully
- Generate settlement confirmation
- Update queue entry status
- Release queue lock
- Notify payment initiator
- Log settlement event with metrics
Error Handling
Error: Insufficient Balance
- Detection: Balance check fails
- Action: Remove from queue, return error
- Recovery: Notify initiator, suggest alternative
Error: Risk Check Failed
- Detection: Risk monitor flags payment
- Action: Hold payment, escalate to operations
- Recovery: Manual review, adjust risk parameters if needed
Error: Settlement Timeout
- Detection: Settlement exceeds 100ms target
- Action: Log warning, continue processing
- Recovery: Investigate performance bottleneck
Error: Multi-Ledger Sync Failure
- Detection: One or more ledger posts fail
- Action: Rollback all ledger entries
- Recovery: Retry settlement, escalate if persistent
Error: Queue Lock Timeout
- Detection: Payment locked too long
- Action: Release lock, retry or fail
- Recovery: Investigate deadlock conditions
Integration Points
Related Services
- M-RTGS Queue Manager:
src/core/settlement/m-rtgs/(queue manager) - M-RTGS Settlement Service:
src/core/settlement/m-rtgs/(settlement) - M-RTGS Risk Monitor:
src/core/settlement/m-rtgs/(risk monitor) - M-RTGS MACE Integration:
src/core/settlement/m-rtgs/(MACE) - Ledger Service:
src/core/ledger/ledger.service.ts - SSU Service:
src/core/settlement/ssu/ssu-service.ts - CDT Settlement:
src/core/commodities/cbds/cdt-settlement.service.ts
API Endpoints
POST /api/v1/m-rtgs/queue/add- Add payment to queueGET /api/v1/m-rtgs/queue/next- Get next payment from queuePOST /api/v1/m-rtgs/settle- Execute settlementPOST /api/v1/m-rtgs/risk/monitor- Risk monitoring
Database Models
MrtgsQueue- Queue entries with priority scoresMrtgsSettlement- Settlement records with multi-asset supportMrtgsRiskAlert- Risk monitoring alerts
Performance Metrics
- Queue Addition: < 10ms target
- Priority Calculation: < 5ms target
- Risk Monitoring: < 20ms target
- Settlement Execution: < 100ms target (total)
- Total End-to-End: < 135ms target
- Throughput: 50,000+ payments/second
- Availability: 99.99% uptime target
Security Considerations
Access Control
- Only authorized banks can submit payments
- Queue access restricted to M-RTGS service
Data Integrity
- Queue entries locked during processing
- Multi-ledger synchronization ensures consistency
- Settlement timestamps provide audit trail
Risk Controls
- Real-time velocity monitoring
- Liquidity congestion detection
- FX and commodity price shock detection
Testing Scenarios
Happy Path
- Valid payment request
- Successful queue addition
- Priority calculation correct
- Risk checks pass
- Settlement completes < 100ms
- All ledgers synchronized
Error Scenarios
- Insufficient balance
- Risk check failure
- Settlement timeout
- Multi-ledger sync failure
- Queue lock timeout
Edge Cases
- Maximum priority payment
- Minimum priority payment
- All asset types
- Concurrent high-priority payments
- System under heavy load
Related Flows: