feat: increased debounce swap quote rate (#6666)
* feat: increased debounce swap quote time * fix
This commit is contained in:
parent
8c8300a5de
commit
bc08e9263d
7
src/featureFlags/flags/debounceSwapQuote.ts
Normal file
7
src/featureFlags/flags/debounceSwapQuote.ts
Normal file
@ -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 { atomWithStorage, useAtomValue, useUpdateAtom } from 'jotai/utils'
|
||||||
import { createContext, ReactNode, useCallback, useContext } from 'react'
|
import { createContext, ReactNode, useCallback, useContext } from 'react'
|
||||||
import { useGate } from 'statsig-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 {
|
interface FeatureFlagsContextType {
|
||||||
isLoaded: boolean
|
isLoaded: boolean
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
|
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
|
||||||
import { useWeb3React } from '@web3-react/core'
|
import { useWeb3React } from '@web3-react/core'
|
||||||
import { WRAPPED_NATIVE_CURRENCY } from 'constants/tokens'
|
import { WRAPPED_NATIVE_CURRENCY } from 'constants/tokens'
|
||||||
|
import { DebounceSwapQuoteVariant, useDebounceSwapQuoteFlag } from 'featureFlags/flags/debounceSwapQuote'
|
||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { InterfaceTrade, TradeState } from 'state/routing/types'
|
import { InterfaceTrade, TradeState } from 'state/routing/types'
|
||||||
import { useRoutingAPITrade } from 'state/routing/useRoutingAPITrade'
|
import { useRoutingAPITrade } from 'state/routing/useRoutingAPITrade'
|
||||||
@ -14,6 +15,9 @@ import useIsWindowVisible from './useIsWindowVisible'
|
|||||||
// Prevents excessive quote requests between keystrokes.
|
// Prevents excessive quote requests between keystrokes.
|
||||||
const DEBOUNCE_TIME = 350
|
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.
|
* Returns the best v2+v3 trade for a desired swap.
|
||||||
* @param tradeType whether the swap is an exact in/out
|
* @param tradeType whether the swap is an exact in/out
|
||||||
@ -34,7 +38,7 @@ export function useBestTrade(
|
|||||||
|
|
||||||
const [debouncedAmount, debouncedOtherCurrency] = useDebounce(
|
const [debouncedAmount, debouncedOtherCurrency] = useDebounce(
|
||||||
useMemo(() => [amountSpecified, otherCurrency], [amountSpecified, otherCurrency]),
|
useMemo(() => [amountSpecified, otherCurrency], [amountSpecified, otherCurrency]),
|
||||||
DEBOUNCE_TIME
|
useDebounceSwapQuoteFlag() === DebounceSwapQuoteVariant.Enabled ? DEBOUNCE_TIME_INCREASED : DEBOUNCE_TIME
|
||||||
)
|
)
|
||||||
|
|
||||||
const isAWrapTransaction = useMemo(() => {
|
const isAWrapTransaction = useMemo(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user