Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(router-sdk): Address wrapped/native currency conditions in mixed routes with v4 #81

Merged
merged 5 commits into from
Sep 5, 2024

Conversation

ewilz
Copy link
Member

@ewilz ewilz commented Aug 28, 2024

Description

fixes #67

Valid Routes:

  • v2/v3 --> v4 WETH unwraps to ETH
  • v4 --> v2/v3 ETH wraps to WETH

Invalid Routes:

  • v4 --> v4 WETH unwraps to ETH
  • v4 --> v4 ETH wraps to WETH
    v4 routes must trade through WETH/ETH pools to make this conversion

How Has This Been Tested?

unit tests

Are there any breaking changes?

I don't think so

(Optional) Feedback Focus

make sure all conditions are met.

(Optional) Follow Ups

@ewilz ewilz requested a review from a team as a code owner August 28, 2024 19:38
Copy link

graphite-app bot commented Aug 28, 2024

Graphite Automations

"Request reviewers once CI passes on sdks monorepo" took an action on this PR • (08/28/24)

1 reviewer was added and 1 assignee was added to this PR based on 's automation.

type TPool = Pair | V3Pool | V4Pool

export function isValidTokenPath(prevPool: TPool, currentPool: TPool, inputToken: Currency): boolean {
if (currentPool.involvesToken(inputToken as Token)) return true
Copy link
Contributor

Choose a reason for hiding this comment

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

this should always be true if inputToken is not native right, a comment could be helpful

Copy link
Member Author

@ewilz ewilz Aug 29, 2024

Choose a reason for hiding this comment

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

I have to put as Token bc v2/v3 pools only accept token parameters..so I'm basically hacking typescript so it will compile. this will work if the inputToken IS native as type Currency too....

Copy link
Member Author

Choose a reason for hiding this comment

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

I kind of want to go into v2/v3-sdks change these inputs to Currency and then throw an error if it's not type Token (a subset of Currency) then I can remove all of the as Token's from this sdk

@@ -4,6 +4,7 @@ import { Currency, Price, Token } from '@uniswap/sdk-core'
import { Pair } from '@uniswap/v2-sdk'
import { Pool as V3Pool } from '@uniswap/v3-sdk'
import { Pool as V4Pool } from '@uniswap/v4-sdk'
import { isValidTokenPath } from '../../utils/isValidTokenPath'

type TPool = Pair | V3Pool | V4Pool
Copy link
Member

Choose a reason for hiding this comment

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

nit: as I was coding v4 routing in SOR, I realized getting this type exported can be beneficial

Copy link
Member Author

Choose a reason for hiding this comment

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

yah I also need to DRY and put this somewhere, I keep meaning to do taht

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm afraid of needing new approvals, so I'm just gonna merge..

@ewilz ewilz merged commit df6348a into main Sep 5, 2024
6 checks passed
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.

router-sdk: Expand mixed route capabilities
4 participants