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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uniswap/universal-router-sdk",
"version": "1.9.0",
"version": "1.9.1",
"description": "sdk for integrating with the Universal Router contracts",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions src/entities/protocols/uniswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ function addV2Swap<TInput extends Currency, TOutput extends Currency>(
route.path.map((pool) => pool.address),
payerIsUser,
])
} else {
throw new Error('TRADE_TYPE')
}
}

Expand Down Expand Up @@ -234,6 +236,8 @@ function addV3Swap<TInput extends Currency, TOutput extends Currency>(
path,
payerIsUser,
])
} else {
throw new Error('TRADE_TYPE')
}
}

Expand All @@ -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

throw new Error('TRADE_TYPE')
}

const trade = MixedRouteTrade.createUncheckedTrade({
route: route as MixedRoute<TInput, TOutput>,
inputAmount,
Expand Down
Loading