Repository navigation
Conversation
The bound arrived in bc187be (2021-06-29) as one line in a bulk pass that put defensive limits on every field of the then-new v1 quote schema. It mirrored the interface's cap at the time — the neighboring deadline bound still says "same as interface max". The interface has since moved to a 100% max with a warning at 20%, and the Trading API's copy was removed in January 2025 with product sign-off, leaving routing as the only layer enforcing it. Users who set slippage above 20% get no quote and a generic "no quotes available" with no indication why. FOT and thin-liquidity tokens routinely need more headroom. There is no execution-safety argument for the value: minimumAmountOut is amountOut/(1+slippage), which asymptotes toward zero without reaching it, so even 100% slippage floors the trade at half the quote. The ceiling belongs to the client, which already has one and already warns. min(0) stays — the SDK asserts slippage >= 0 — and Joi.number() already rejects NaN and Infinity, so no other guard is needed here. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Author
|
Closing — routing-api is no longer in the serving path, so this bound is dead code and does not need changing. The live fix is https://github.com/Uniswap/backend/pull/12251, which removes the same 20% cap from uniroute's quote validator. Leaving the historical note here for anyone who greps this line later: |
Contributor
Graphite Automations"Request reviewers once CI passes on routing-api repo" took an action on this PR • (08/18/26)3 reviewers were added and 1 assignee was added to this PR based on Siyu Jiang (See-You John)'s automation. |
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.
What
Removes
.max(20)fromslippageTolerancein the quote schema.Companion PR in the backend monorepo (uniroute carries the same bound): https://github.com/Uniswap/backend/pull/12251
Why
This bound arrived in
bc187beb(2021-06-29, "New responses") as one line in a bulk pass that converted the quote schema to typed Joi and put defensive limits on every field at once —tokenIn/Out .max(40),amount .max(20),deadline .max(600), a recipient regex. Thedeadlineline right below it still carries// 180 mins, same as interface max, which is the tell: these mirrored the interface's caps, and the interface bounded slippage at 20% then.The interface has since moved to a 100% max with a warning at 20%, and the Trading API's copy of the bound was removed in January 2025 with product sign-off (CX-877) — but only in that one layer, leaving routing as the only place still enforcing it.
Effect today: slippage above 20% returns no quote and the app shows a generic "no quotes available" with no explanation. FOT and thin-liquidity tokens routinely need more headroom. Reported four separate times since 2021, and generating routing alert noise since Feb 2025.
No execution-safety argument supports the specific value.
minimumAmountOutisamountOut / (1 + slippage), which asymptotes toward zero without reaching it — 100% slippage still floors the trade at half the quote. The ceiling belongs to the client, which already has one and already warns.Why
min(0)staysThe SDK asserts
slippage >= 0inminimumAmountOut, so a negative value would throw downstream rather than degrade.Joi.number()already rejectsNaNandInfinityby default — verified:So dropping
.max(20)alone is sufficient here. (The uniroute validator needed an explicit finite/non-negative check instead, since it hand-rolls validation on a protodoublerather than going through Joi.)Rollout note
uniroute and routing-api both serve and both carry this bound. Requests over 20% keep failing on whichever path lands second.
🤖 Generated with Claude Code