Skip to content

Core: Implement AI-Powered Payment Routing Optimization Engine #446

Description

@Smartdevs17

Context

AgenticPay processes payments across Stellar (Soroban) and EVM chains. Currently, the routing engine selects chains based on static configuration rather than real-time conditions, leading to suboptimal fee/speed tradeoffs.

Current Limitation/Problem

The routing system uses hardcoded chain priorities. It cannot dynamically adapt to network congestion, fluctuating gas prices, or historical reliability metrics.

Expected Outcome

An ML-driven routing engine that selects the optimal chain for each payment based on real-time and historical data, minimizing cost and latency while maximizing success rate.

Acceptance Criteria

  • Implement feature extraction pipeline collecting gas prices, confirmation times, and success rates per chain
  • Train a lightweight ranking model (XGBoost or similar) for chain selection
  • Expose routing decision logs with rationale for auditability
  • Achieve <50ms routing decision latency at p99
  • Support manual override via admin API
  • A/B test framework comparing static vs AI routing outcomes

Technical Scope

  • backend/src/services/routing/ - new routing engine module
  • backend/src/services/routing/ai-router.ts - ML inference wrapper
  • backend/src/queues/routing-evaluation.queue.ts - periodic feature collection
  • Prisma schema additions for routing metrics table
  • Redis sorted sets for real-time chain performance data
  • Integration with existing PaymentService and ChainConnector interfaces
  • Edge cases: chain outage fallback, stale data handling, model cold start

Metadata

Metadata

Assignees

Labels

200-points200 point issueStellar WaveIssues in the Stellar wave programdrips-waveIssues in the Drips Wave programhighHigh complexity issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions