π 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
π 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
π Description
QuoteService.quotebuildsroute: 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
maxRouteHopsconstructor parameter toQuoteService, defaulting to unlimited (preserving current behavior).maxRouteHopsanchors, throw a400/409ApiError(pick and document the appropriate status) with a clear message rather than silently truncating the route and under-filling the amount.config.ts/app.tsas an optional env-configurable value.π οΈ Suggested execution
src/services/quoteService.ts's constructor andquotemethod to accept and enforcemaxRouteHops.maxQuoteRouteHopstoConfiginsrc/config.ts, wired into theQuoteServiceconstruction insrc/app.ts.src/services/quoteService.test.tsfor both the default (unlimited) and limited cases.β Acceptance criteria
maxRouteHopsunset, behavior is unchanged from today.maxRouteHopsset, a quote requiring more anchors than the limit fails clearly instead of silently under-filling.π Security notes
N/A β operational/performance safeguard; prevents unbounded route fan-out from a single quote request.
π Guidelines