Skip to content

Commit

Permalink
fix: not able to get quote from exact output
Browse files Browse the repository at this point in the history
  • Loading branch information
chefjackson committed Sep 10, 2024
1 parent 99327de commit 52d5e2e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions apps/web/src/hooks/useBestAMMTrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,11 @@ export function useBestTradeFromApi({
})
const serializedRes = await serverRes.json()

const isExactIn = tradeType === TradeType.EXACT_INPUT
const result = parseQuoteResponse(serializedRes, {
chainId: currency.chainId,
currencyIn: amount.currency,
currencyOut: currency,
currencyIn: isExactIn ? amount.currency : currency,
currencyOut: isExactIn ? currency : amount.currency,
tradeType,
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ interface SwapCommitButtonPropsType {
order?: PriceOrder
tradeError?: Error | null
tradeLoading?: boolean
// setLock: (lock: boolean) => void
}

const useSettingModal = (onDismiss) => {
Expand Down Expand Up @@ -163,7 +162,7 @@ const SwapCommitButtonInner = memo(function SwapCommitButtonInner({
}
const parsedAmounts = useParsedAmounts(order?.trade, currencyBalances, false)
const parsedIndependentFieldAmount = parsedAmounts[independentField]
const swapInputError = useSwapInputError(isClassicOrder(order) ? order : undefined, currencyBalances)
const swapInputError = useSwapInputError(order, currencyBalances)
const [tradeToConfirm, setTradeToConfirm] = useState<PriceOrder | undefined>(undefined)
const [indirectlyOpenConfirmModalState, setIndirectlyOpenConfirmModalState] = useState(false)

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/views/Swap/V3Swap/hooks/useSwapBestTrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function useSwapBestOrder({ maxHops }: Options = {}) {

const [xEnabled] = useUserXEnable()

const { isLoading, data, isStale, error, refetch } = useBestTradeFromApi({
const { fetchStatus, data, isStale, error, refetch } = useBestTradeFromApi({
enabled: xEnabled,
amount,
currency: dependentCurrency,
Expand All @@ -65,7 +65,7 @@ export function useSwapBestOrder({ maxHops }: Options = {}) {
refresh: refetch,
isStale,
error,
isLoading: useDeferredValue(Boolean(isLoading || (typedValue && !data && !error))),
isLoading: useDeferredValue(Boolean(fetchStatus === 'fetching' || (typedValue && !data && !error))),
order: typedValue ? data : undefined,
}
}
Expand Down

0 comments on commit 52d5e2e

Please sign in to comment.