Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
isWrapping check in price updater
Browse files Browse the repository at this point in the history
  • Loading branch information
W3stside committed Dec 3, 2021
1 parent a9a61fc commit 466ef3f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/custom/state/price/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useActiveWeb3React } from 'hooks/web3'
import useDebounce from 'hooks/useDebounce'
import useIsOnline from 'hooks/useIsOnline'
import { QuoteInformationObject } from './reducer'
import { WETH9_EXTENDED } from '@src/custom/constants/tokens'

const DEBOUNCE_TIME = 350
const REFETCH_CHECK_INTERVAL = 10000 // Every 10s
Expand Down Expand Up @@ -146,8 +147,15 @@ export default function FeesUpdater(): null {
// Don't refetch if:
// - window is not visible
// - some parameter is missing
// - it is a wrapping operation
if (!chainId || !sellToken || !buyToken || !typedValue || !windowVisible) return

const isWrapping =
(sellCurrency?.isNative && buyCurrency?.wrapped.equals(WETH9_EXTENDED[chainId])) ||
(sellCurrency?.wrapped.equals(WETH9_EXTENDED[chainId]) && buyCurrency?.isNative)

if (isWrapping) return

// Don't refetch if the amount is missing
const kind = independentField === Field.INPUT ? OrderKind.SELL : OrderKind.BUY
const amount = tryParseAmount(typedValue, (kind === OrderKind.SELL ? sellCurrency : buyCurrency) ?? undefined)
Expand Down

0 comments on commit 466ef3f

Please sign in to comment.