Skip to content

fix(alpha-router): apply L1 fees when seeding the unsplit best quote - #971

Open
ninglinLiu wants to merge 1 commit into
Uniswap:mainfrom
ninglinLiu:fix/l1-fee-initial-best-quote-968
Open

ninglinLiu wants to merge 1 commit into
Uniswap:mainfrom
ninglinLiu:fix/l1-fee-initial-best-quote-968

Conversation

@ninglinLiu

Copy link
Copy Markdown

Summary

On chains in HAS_L1_FEE, getBestSwapRouteBy compared L1-adjusted split candidates against an initial 100% route quote that skipped L1 fees. That biased selection toward the unsplit route (and skewed the per-split heap) because the competitor scores were not on the same basis.

  • Extract l1GasCostInQuoteToken shared by the unsplit seed and the BFS completion path
  • Apply the same L1 adjustment when seeding bestQuote / bestSwapsPerSplit from the 100% routes

Fixes #968 (selection bias; serialized L1 RPC during BFS left as follow-up)

Test plan

  • npx jest test/unit/routers/alpha-router/functions/best-swap-route.test.ts — 17/17 passed
  • npm run build succeeds

This PR was prepared with AI assistance and reviewed/tested by the author.

The BFS path compared L1-adjusted split candidates against an initial
100% route quote that skipped L1, biasing selection on HAS_L1_FEE chains.
Extract a shared helper and use it for both the unsplit seed and splits.

Fixes Uniswap#968
@ninglinLiu
ninglinLiu requested a review from a team as a code owner October 28, 2026 13:49

This branch has not been deployed

No deployments
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.

L1 fee handling in getBestSwapRouteBy causes inconsistent scoring and serialized RPC calls

1 participant