Skip to content

Conversation

@dianakocsis
Copy link
Contributor

@dianakocsis dianakocsis commented Dec 15, 2025

PR Scope

Please title your PR according to the following types and scopes following conventional commits:

  • fix(SDK name): will trigger a patch version
  • chore(<type>): will not trigger any release and should be used for internal repo changes
  • <type>(public): will trigger a patch version for non-code changes (e.g. README changes)
  • feat(SDK name): will trigger a minor version
  • feat(breaking): will trigger a major version for a breaking change

Description

[Summary of the change, motivation, and context]

How Has This Been Tested?

[e.g. Manually, E2E tests, unit tests, Storybook]

Are there any breaking changes?

[e.g. Type definitions, API definitions]

If there are breaking changes, please ensure you bump the major version Bump the major version (by using the title feat(breaking): ...), post a notice in #eng-sdks, and explicitly notify all Uniswap Labs consumers of the SDK.

(Optional) Feedback Focus

[Specific parts of this PR you'd like feedback on, or that reviewers should pay closer attention to]

(Optional) Follow Ups

[Things that weren't addressed in this PR, ways you plan to build on this work, or other ways this work could be extended]


✨ Claude-Generated Content

Description

Fixes an issue where split routes containing both V4 and non-V4 (V2/V3) swaps would fail when the output currency is ETH. V4 pools handle ETH natively, but V2/V3 pools use WETH. When both route types are combined in a split trade, the V4 route must take WETH instead of ETH to ensure proper unwrapping at the end.

Changes

  • Added shouldForceV4UnwrapForSplitNativeOutput getter to UniswapTrade class to detect if any V4 route (including mixed routes) ends with an ETH-WETH pool
  • Updated outputRequiresUnwrap to return true when output is native ETH and any V4 route has an ETH-WETH last pool
  • Modified addV4Swap to accept a shouldForceV4UnwrapForSplitNativeOutput parameter and use WETH for the take operation when this condition is true
  • Modified addMixedSwap to pass the flag through and use WETH for the final take in mixed routes when applicable
  • Added 10 new Forge tests covering split route scenarios with V4 and non-V4 combinations
  • Added test fixture data for new split route test cases in interop.json

How Has This Been Tested?

Unit tests and Forge tests added for the following scenarios:

  • V3 + V4 split routes outputting ETH
  • Mixed (V2->V3) + V4 split routes outputting ETH
  • Mixed routes with V4 pools ending in ETH or WETH
  • Pure V4 split routes with ETH-WETH pools

Are there any breaking changes?

No breaking changes. This is a bug fix that improves handling of edge cases in split route swaps.

@dianakocsis dianakocsis requested a review from a team as a code owner December 15, 2025 15:31
@github-actions
Copy link

github-actions bot commented Dec 15, 2025

🤖 Claude Code Review

🔄 Review in progress... Claude is analyzing this pull request. If a review can be seen below, it will be replaced by the results of this one.

⏱️ Reviews typically complete within 5-15 minutes depending on PR size.

Summary

This PR fixes handling of split routes when mixing V4 and non-V4 (V2/V3) swaps for ETH output. The issue is that V4 can handle native ETH directly, but V2/V3 require WETH. When splitting trades across both, you need consistent handling - this PR forces V4 to take WETH instead of ETH when there's a split route, then performs a final unwrap.

Key Changes

  1. New hasSplitRoutesWithV4AndNonV4 getter - Cached detection of whether a trade has split routes mixing V4 and non-V4 protocols. For mixed routes, only counts as non-V4 if the last pool is not V4 (since V4 can handle ETH natively).

  2. Updated outputRequiresUnwrap - Now returns true when split routes have V4 outputting ETH, ensuring the final WETH gets unwrapped to ETH for the recipient.

  3. Modified addV4Swap - When hasSplitRoutesWithV4AndNonV4 is true and the path outputs native ETH via an ETH-WETH pool, it takes WETH instead of ETH.

  4. Test coverage - Added 4 new test cases covering various split route scenarios, plus Forge integration tests validating the actual on-chain behavior.

Analysis

The logic is correct. The ETH-WETH pool detection at lines 443-445 checks if one currency is native and the other is its wrapped equivalent:

(lastPool.currency0.isNative && lastPool.currency1.wrapped.equals(lastPool.currency0.wrapped)) ||
(lastPool.currency1.isNative && lastPool.currency0.wrapped.equals(lastPool.currency1.wrapped))

This correctly identifies pools like ETH/WETH where swapping direction doesn't matter for the output token type.

The caching of _hasSplitRoutesWithV4AndNonV4 is appropriate since this property is accessed multiple times during encoding.

The Forge tests verify the end-to-end behavior: recipient receives ETH (not WETH), router balance ends at 0, and USDC is correctly deducted.

No issues found.


💡 Want a fresh review? Add a comment containing @request-claude-review to trigger a new review at any time.

@dianakocsis dianakocsis changed the title Eth weth fix fix(universal-router-sdk): Eth weth fix Dec 15, 2025
@github-actions github-actions bot changed the title fix(universal-router-sdk): Eth weth fix fix(universal-router-sdk): handle ETH/WETH output in V4 split routes Dec 15, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

📋 Review verdict: APPROVE

👆 The main review comment above is the source of truth for this PR review. It is automatically updated on each review cycle, so always refer to it for the most current feedback.

This formal review submission is for the verdict only.

@graphite-app graphite-app bot requested a review from a team December 15, 2025 15:38
@graphite-app
Copy link

graphite-app bot commented Dec 15, 2025

Graphite Automations

"Request reviewers once CI passes on sdks monorepo" took an action on this PR • (12/15/25)

2 reviewers were added and 1 assignee was added to this PR based on Siyu Jiang (See-You John)'s automation.

@github-actions
Copy link

🤖 Claude Code Review

Status: ⚠️ Partial (script error)
Job: View workflow run


The review was completed but there was an error posting inline comments.

Raw Review Output
No review output available

Please check the workflow logs for details.

@github-actions
Copy link

🤖 Claude Code Review

Status: ❌ Error
Job: View workflow run


⚠️ Review Failed

The automated code review encountered an error and could not complete.

Next Steps:

  1. Check the workflow logs for details
  2. Verify the GitHub Actions configuration
  3. Ensure the Anthropic API key is valid
  4. Check for any permission issues

If the problem persists, please contact your repository administrator.


You can manually re-trigger the review by pushing a new commit or re-running the workflow.

@github-actions
Copy link

🤖 Claude Code Review

Status: ⚠️ Partial (script error)
Job: View workflow run


The review was completed but there was an error posting inline comments.

Raw Review Output
No review output available

Please check the workflow logs for details.

@github-actions
Copy link

🤖 Claude Code Review

Status: ❌ Error
Job: View workflow run


⚠️ Review Failed

The automated code review encountered an error and could not complete.

Next Steps:

  1. Check the workflow logs for details
  2. Verify the GitHub Actions configuration
  3. Ensure the Anthropic API key is valid
  4. Check for any permission issues

If the problem persists, please contact your repository administrator.


You can manually re-trigger the review by pushing a new commit or re-running the workflow.

@github-actions
Copy link

🤖 Claude Code Review

Status: ⚠️ Partial (script error)
Job: View workflow run


The review was completed but there was an error posting inline comments.

Raw Review Output
No review output available

Please check the workflow logs for details.

@github-actions
Copy link

🤖 Claude Code Review

Status: ❌ Error
Job: View workflow run


⚠️ Review Failed

The automated code review encountered an error and could not complete.

Next Steps:

  1. Check the workflow logs for details
  2. Verify the GitHub Actions configuration
  3. Ensure the Anthropic API key is valid
  4. Check for any permission issues

If the problem persists, please contact your repository administrator.


You can manually re-trigger the review by pushing a new commit or re-running the workflow.

/**
* Checks if any route in a split trade ends with an ETH-WETH pool.
*
* When a split trade has routes ending in ETH-WETH pools alongside routes ending in WETH,
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this only affect pools ending with ETH-WETH or can it be any *-ETH pool? cc @jsy1218

Copy link
Collaborator

Choose a reason for hiding this comment

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

also curious if this change covers both exactIn and exactOut

Copy link
Member

Choose a reason for hiding this comment

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

its only ETH-WETH only

Copy link
Member

Choose a reason for hiding this comment

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

i think it should cover both exactIn and exactOut, because this change covers the tokenOut itself, and the exactIn and exactOut should have tokenOutput regardless. @dianakocsis to confirm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch - seems like routes ending in ETH-WETH always fail for exactOut - fixing this now

@jsy1218
Copy link
Member

jsy1218 commented Jan 6, 2026

@dianakocsis i think i prefer to have #476 merged first, then #462 should include as well

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

🤖 Claude Code Review

Status: ⚠️ Partial (script error)
Job: View workflow run


The review was completed but there was an error posting inline comments.

Raw Review Output
No review output available

Please check the workflow logs for details.

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

🤖 Claude Code Review

Status: ❌ Error
Job: View workflow run


⚠️ Review Failed

The automated code review encountered an error and could not complete.

Next Steps:

  1. Check the workflow logs for details
  2. Verify the GitHub Actions configuration
  3. Ensure the Anthropic API key is valid
  4. Check for any permission issues

If the problem persists, please contact your repository administrator.


You can manually re-trigger the review by pushing a new commit or re-running the workflow.

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

🤖 Claude Code Review

Status: ⚠️ Partial (script error)
Job: View workflow run


The review was completed but there was an error posting inline comments.

Raw Review Output
No review output available

Please check the workflow logs for details.

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

🤖 Claude Code Review

Status: ❌ Error
Job: View workflow run


⚠️ Review Failed

The automated code review encountered an error and could not complete.

Next Steps:

  1. Check the workflow logs for details
  2. Verify the GitHub Actions configuration
  3. Ensure the Anthropic API key is valid
  4. Check for any permission issues

If the problem persists, please contact your repository administrator.


You can manually re-trigger the review by pushing a new commit or re-running the workflow.

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.

5 participants