Skip to content

Add a configurable max route-hop limit to QuoteService.quote to cap how many anchors a single quote can spanΒ #156

Description

@Jagadeeshftw

πŸ“Œ Description

QuoteService.quote builds route: string[] by walking every anchor's liquidity entry for an asset, largest-first, until the requested amount is filled β€” with no limit on how many anchors can end up in the route. For an asset with many small-balance anchors, a single quote could return a route spanning dozens of anchors, which may be operationally awkward for whatever downstream settlement process ultimately has to coordinate with each one.

🧩 Requirements and context

  • Add an optional maxRouteHops constructor parameter to QuoteService, defaulting to unlimited (preserving current behavior).
  • When set and the fill would require more than maxRouteHops anchors, throw a 400/409 ApiError (pick and document the appropriate status) with a clear message rather than silently truncating the route and under-filling the amount.
  • Wire the limit through config.ts/app.ts as an optional env-configurable value.

πŸ› οΈ Suggested execution

  • Modify src/services/quoteService.ts's constructor and quote method to accept and enforce maxRouteHops.
  • Add maxQuoteRouteHops to Config in src/config.ts, wired into the QuoteService construction in src/app.ts.
  • Add tests in src/services/quoteService.test.ts for both the default (unlimited) and limited cases.

βœ… Acceptance criteria

  • With maxRouteHops unset, behavior is unchanged from today.
  • With maxRouteHops set, a quote requiring more anchors than the limit fails clearly instead of silently under-filling.
  • New tests cover both configurations.

πŸ”’ Security notes

N/A β€” operational/performance safeguard; prevents unbounded route fan-out from a single quote request.

πŸ“‹ Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issueenhancementNew feature or improvementperformancePerformance / caching

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions