feat: accept exclusive legs that wrap into the output token - #437
Merged
Conversation
louise-poole
approved these changes
Aug 19, 2026
louise-poole
left a comment
Collaborator
There was a problem hiding this comment.
Ah yes of course! Good catch, looks good to me!
Troshchk
reviewed
Aug 19, 2026
Troshchk
left a comment
Contributor
There was a problem hiding this comment.
Thank you @tamaralipows! Left a couple of qs
Troshchk
approved these changes
Aug 19, 2026
The exclusive-route validator required the exclusive leg to produce the route's output token. A pool quoting the native token was therefore unusable for a request denominated in the wrapped token, because the wrap leg tycho streams sits after the exclusive leg and made it non-terminal. The candidate was dropped, so no commitment was made and the route fell back to public liquidity. A trailing wrap converts 1:1, so `pin_commitment` divides by a ratio of exactly 1 when it attributes surplus to the leg — the same arithmetic a terminal leg gets. Accept that one case and keep every other non-terminal shape rejected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
tamaralipows
force-pushed
the
tnl/exclusive-leg-native-wrap
branch
from
August 19, 2026 13:59
9d743e5 to
320204e
Compare
tamaralipows
enabled auto-merge
August 19, 2026 14:01
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
has_valid_exclusive_routerequired the exclusive leg to produce the route's output token. An exclusive pool quoting the native token could therefore never serve a request denominated in the wrapped token: tycho streams the ETH/WETH wrap as an ordinary component, so the wrap leg sits after the exclusive leg and makes it non-terminal.best_exclusive_candidatedropped the candidate,combine_with_surplusreturned the public ranking unchanged, and no exclusive commitment was ever made.This accepts one additional route shape — an exclusive leg followed by a single native wrap leg that produces the route's output token.
Why it is safe
A wrap converts 1:1.
pin_commitmentattributes captured surplus to a leg with the ratiopath_final_out / leg_out, which a wrap leaves at exactly 1, so the leg gets the same arithmetic as a terminal leg and needs no inverse simulation.Every other non-terminal shape stays rejected. The trailing leg must consume the exclusive leg's output, produce the route's output token, and be a native wrap; each of those three conditions has a test that fails without it.
Notes
Chainis threaded to the validator so the native/wrapped pair comes from tycho's chain config rather than a local constant. Thetry_accessors are used because the plain ones panic on an unregistered custom chain, which the crate's lints deny; an unresolved pair falls back to requiring a terminal leg.🤖 Generated with Claude Code