Pathfinding Integration
Introduction
Architecture Overview
Dual Liquidity Model
┌─────────────────────────────────────────────────────────────┐
│ Payment Request │
│ (Source -> Destination) │
└─────────────────────────┬───────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Pathfinding Engine │
│ │
│ ┌───────────────────┐ ┌───────────────────┐ │
│ │ Order Book │ │ AMM Pool │ │
│ │ (CLOB) │ │ (Synthetic) │ │
│ │ │ │ │ │
│ │ Offer 1: 2.00 │ │ Quality: 2.05 │ │
│ │ Offer 2: 2.01 │ │ (calculated) │ │
│ │ Offer 3: 2.02 │ │ │ │
│ └─────────┬─────────┘ └─────────┬─────────┘ │
│ │ │ │
│ └───────────┬───────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────┐ │
│ │ Best Execution │ │
│ │ Path Selection │ │
│ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘Key Components
Component
Location
Purpose
AMMContext: State Management
Iteration Limit
AMMLiquidity: Offer Generation
Offer Generation Strategies
Single Path Mode
Multi-Path Mode
AMMOffer: Synthetic Offer Representation
When Are AMMOffers Created?
Key Insight: AMMOffers Are Ephemeral
CLOB Offer
AMMOffer
How AMMOffers Are Sized
Structure
Quality Calculation
Limiting Offers
Consuming Offers
Integration with BookStep
Processing Order
Quality Competition
Multi-Path Payment Example
Scenario
Execution
Flow Diagram
Performance Considerations
Iteration Limits
Quality Caching
Balance Snapshots
Edge Cases
Empty AMM Pool
Iteration Limit Reached
Quality Worse Than CLOB
Debugging Tips
Tracing AMM Offers
Verifying Integration
Testing Quality Competition
Summary
References to Source Code
Cross-References
Last updated

