From e9a432b58e9eb8a93993a0e5e7c36764e491e2b8 Mon Sep 17 00:00:00 2001 From: Moody Salem Date: Fri, 30 Apr 2021 22:43:29 -0500 Subject: [PATCH] fix a bug in v3 trade routing returning the wrong trade type for output trade --- src/hooks/useBestV3Trade.ts | 2 +- src/utils/isTradeBetter.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hooks/useBestV3Trade.ts b/src/hooks/useBestV3Trade.ts index b5f9d733ab..28f11ac74d 100644 --- a/src/hooks/useBestV3Trade.ts +++ b/src/hooks/useBestV3Trade.ts @@ -171,7 +171,7 @@ export function useBestV3TradeExactOut( state: isSyncing ? V3TradeState.SYNCING : V3TradeState.VALID, trade: Trade.createUncheckedTrade({ route: bestRoute, - tradeType: TradeType.EXACT_INPUT, + tradeType: TradeType.EXACT_OUTPUT, inputAmount: currencyIn instanceof Token ? new TokenAmount(currencyIn, amountIn.toString()) diff --git a/src/utils/isTradeBetter.ts b/src/utils/isTradeBetter.ts index 2c4a9197a7..c04d0a45f3 100644 --- a/src/utils/isTradeBetter.ts +++ b/src/utils/isTradeBetter.ts @@ -18,8 +18,7 @@ export function isTradeBetter( !currencyEquals(tradeA.inputAmount.currency, tradeB.inputAmount.currency) || !currencyEquals(tradeB.outputAmount.currency, tradeB.outputAmount.currency) ) { - console.error('Comparing incomparable trades', tradeA, tradeB) - return false + throw new Error('Comparing incomparable trades') } if (minimumDelta.equalTo(ZERO_PERCENT)) {