Skip to content

feat: accept exclusive legs that wrap into the output token - #437

Merged
tamaralipows merged 1 commit into
mainfrom
tnl/exclusive-leg-native-wrap
Aug 19, 2026
Merged

feat: accept exclusive legs that wrap into the output token#437
tamaralipows merged 1 commit into
mainfrom
tnl/exclusive-leg-native-wrap

Conversation

@tamaralipows

Copy link
Copy Markdown
Contributor

What

has_valid_exclusive_route required 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_candidate dropped the candidate, combine_with_surplus returned 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_commitment attributes captured surplus to a leg with the ratio path_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

  • Chain is threaded to the validator so the native/wrapped pair comes from tycho's chain config rather than a local constant. The try_ 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.
  • Effect on prod: the Ekubo exclusive ETH/USDC pool is denominated in native ETH, while observed exclusive demand asks for WETH.

🤖 Generated with Claude Code

@louise-poole louise-poole left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes of course! Good catch, looks good to me!

@Troshchk Troshchk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @tamaralipows! Left a couple of qs

Comment thread fynd-core/src/worker_pool_router/mod.rs
Comment thread fynd-core/src/worker_pool_router/mod.rs
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
tamaralipows force-pushed the tnl/exclusive-leg-native-wrap branch from 9d743e5 to 320204e Compare August 19, 2026 13:59
@tamaralipows
tamaralipows enabled auto-merge August 19, 2026 14:01
@tamaralipows
tamaralipows merged commit 5aff2f5 into main Aug 19, 2026
16 checks passed
@tamaralipows
tamaralipows deleted the tnl/exclusive-leg-native-wrap branch August 19, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants