feat(deposits): multi-pool routing optimisation + #283 coverage follow-up#619
Merged
edehvictor merged 1 commit intoMay 29, 2026
Merged
Conversation
…rage follow-up PR edehvictor#486 shipped the multi-asset routing API as a partial first delivery and explicitly deferred (a) multi-pool path optimisation and (b) the full 90% coverage target. This PR closes both. Multi-pool optimisation: - recommendDepositRouting() now accepts a `quoteProtocols` option (and falls back to `DEPOSIT_ROUTING_PROTOCOLS` env). When more than one candidate is supplied, each non-vault asset is quoted across every protocol; the route with the highest `amountOutAfterSlippage` wins. - Losing quotes are exposed on the route record as `alternativeQuotes`, so callers can render the optimisation savings. - A protocol that throws is silently skipped; if every candidate throws for a given asset, the asset is dropped from `routes` and a per-asset warning is surfaced. - The chosen route now carries a `protocol` field; the literal `"default"` token sends `protocol: undefined` to getZapQuote so the legacy single-pool path is unchanged. Coverage push: - New `multi-pool path optimisation` describe block: best-route pick, protocol-throw fallback, all-throw warning, env-var resolution, default→undefined remapping. - Extra cases for the pre-existing surface: trimmed/whitespace symbols, empty-symbol rejection, non-numeric amount sum, empty basket, ISO generatedAt timestamp. API back-compat: every existing test passes without modification — the single-pool default path is preserved.
|
@davedumto is attempting to deploy a commit to the Edeh Victor's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@davedumto Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR #486 delivered the multi-asset deposit routing API as a partial first cut and explicitly deferred two items in its body: multi-pool path optimisation and the full 90% coverage target. That's why #283 stayed open after #486 merged. This PR closes both.
Multi-pool path optimisation
recommendDepositRouting()gains an optionalquoteProtocolsoption (and aDEPOSIT_ROUTING_PROTOCOLSenv-var fallback). When more than one candidate protocol is configured, every non-vault asset is quoted against each protocol and the route with the highestamountOutAfterSlippagewins. Losing quotes ride along on the route record asalternativeQuotesso callers can show savings:{ "symbol": "XLM", "action": "convert", "protocol": "aquarius", "expectedVaultAmountStroops": "999", "reasoning": "XLM converted to USDC via a 2-hop route (...). Selected aquarius over 1 alternative quote(s) on output amount.", "alternativeQuotes": [ { "protocol": "soroswap", "expectedVaultAmountStroops": "990", "slippageApplied": 0.01, "source": "router_simulation", "isFallback": false } ] }routesand a per-asset warning is surfaced (rather than silently producing a zero output)."default"protocol token is mapped toprotocol: undefinedon the underlyinggetZapQuotecall, so the legacy single-pool path is unchanged when no option is supplied.Coverage push (toward 90%)
server/src/services/__tests__/depositRoutingService.test.tsgains:multi-pool path optimisationdescribe block — best-route pick, protocol-throw fallback, all-throw warning,DEPOSIT_ROUTING_PROTOCOLSenv-var resolution, default→undefined remapping.amountInStroopssumming safely as 0, empty basket, ISOgeneratedAttimestamp.Back-compat
The public API is additive. Every existing test passes without modification. The
routes[i].sourcefield still carries the chosen quote's source (router_simulationorfallback_rate); only the newprotocolandalternativeQuotesfields are added.Notes
npm install/jestlocally in the build sandbox; CI is the source of truth. Patterns mirror the existing tests in this file.DEPOSIT_ROUTING_PROTOCOLSis intentionally opt-in: with no env var and no option, behaviour is identical to PR feat(deposits): multi-asset deposit routing recommendation API (#283) #486.Test plan
npm test -- depositRoutingService— 21 tests pass (8 existing + 13 new)DEPOSIT_ROUTING_PROTOCOLS=soroswap,aquarius, hitPOST /api/deposits/recommendwith a mixed basket, verify each non-vault route hasprotocolandalternativeQuotespopulated