feat: increased debounce swap quote rate (#6666)

* feat: increased debounce swap quote time

* fix
This commit is contained in:
Vignesh Mohankumar 2023-05-31 15:46:59 -04:00 committed by GitHub
parent 8c8300a5de
commit bc08e9263d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 12 deletions

@ -0,0 +1,7 @@
import { BaseVariant, FeatureFlag, useBaseFlag } from '../index'
export function useDebounceSwapQuoteFlag(): BaseVariant {
return useBaseFlag(FeatureFlag.debounceSwapQuote)
}
export { BaseVariant as DebounceSwapQuoteVariant }

@ -1,10 +0,0 @@
/**
* The value here must match the value in the statsig dashboard, if you plan to use statsig.
*/
export enum FeatureFlag {
traceJsonRpc = 'traceJsonRpc',
permit2 = 'permit2',
fiatOnRampButtonOnSwap = 'fiat_on_ramp_button_on_swap_page',
detailsV2 = 'details_v2',
uraEnabled = 'ura_enabled',
}

@ -1,7 +1,18 @@
import { atomWithStorage, useAtomValue, useUpdateAtom } from 'jotai/utils'
import { createContext, ReactNode, useCallback, useContext } from 'react'
import { useGate } from 'statsig-react'
export { FeatureFlag } from './flags/featureFlags'
/**
* The value here must match the value in the statsig dashboard, if you plan to use statsig.
*/
export enum FeatureFlag {
traceJsonRpc = 'traceJsonRpc',
permit2 = 'permit2',
fiatOnRampButtonOnSwap = 'fiat_on_ramp_button_on_swap_page',
detailsV2 = 'details_v2',
uraEnabled = 'ura_enabled',
debounceSwapQuote = 'debounce_swap_quote',
}
interface FeatureFlagsContextType {
isLoaded: boolean

@ -1,6 +1,7 @@
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core'
import { WRAPPED_NATIVE_CURRENCY } from 'constants/tokens'
import { DebounceSwapQuoteVariant, useDebounceSwapQuoteFlag } from 'featureFlags/flags/debounceSwapQuote'
import { useMemo } from 'react'
import { InterfaceTrade, TradeState } from 'state/routing/types'
import { useRoutingAPITrade } from 'state/routing/useRoutingAPITrade'
@ -14,6 +15,9 @@ import useIsWindowVisible from './useIsWindowVisible'
// Prevents excessive quote requests between keystrokes.
const DEBOUNCE_TIME = 350
// Temporary until we remove the feature flag.
const DEBOUNCE_TIME_INCREASED = 650
/**
* Returns the best v2+v3 trade for a desired swap.
* @param tradeType whether the swap is an exact in/out
@ -34,7 +38,7 @@ export function useBestTrade(
const [debouncedAmount, debouncedOtherCurrency] = useDebounce(
useMemo(() => [amountSpecified, otherCurrency], [amountSpecified, otherCurrency]),
DEBOUNCE_TIME
useDebounceSwapQuoteFlag() === DebounceSwapQuoteVariant.Enabled ? DEBOUNCE_TIME_INCREASED : DEBOUNCE_TIME
)
const isAWrapTransaction = useMemo(() => {