Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

fix: throw on non matching trade types #172

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

zhongeric
Copy link
Contributor

If an incorrect trade type is passed into this SDK, it is possible for no calldata to be built at all which is a footgun and should be avoided. This PR throws explicitly on non matching trade types when building uniswap trades.

@@ -260,6 +264,10 @@ function addMixedSwap<TInput extends Currency, TOutput extends Currency>(
}
}

if(tradeType !== TradeType.EXACT_INPUT) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this one only exact in and not exact out too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only support mixed routes for EXACT_INPUT: https://github.com/Uniswap/router-sdk/blob/main/src/entities/mixedRoute/trade.ts#L200 , not sure exactly why

@zhongeric zhongeric requested a review from hensha256 April 3, 2024 02:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants