feat: eth output feature flag for uniswapx orders (#7078)
This commit is contained in:
parent
9e7d59f1fe
commit
5307d113a8
@ -5,6 +5,7 @@ import { DetailsV2Variant, useDetailsV2Flag } from 'featureFlags/flags/nftDetail
|
||||
import { useRoutingAPIForPriceFlag } from 'featureFlags/flags/priceRoutingApi'
|
||||
import { TraceJsonRpcVariant, useTraceJsonRpcFlag } from 'featureFlags/flags/traceJsonRpc'
|
||||
import { UniswapXVariant, useUniswapXFlag } from 'featureFlags/flags/uniswapx'
|
||||
import { useUniswapXEthOutputFlag } from 'featureFlags/flags/uniswapXEthOutput'
|
||||
import { useUniswapXSyntheticQuoteFlag } from 'featureFlags/flags/uniswapXUseSyntheticQuote'
|
||||
import { useUpdateAtom } from 'jotai/utils'
|
||||
import { Children, PropsWithChildren, ReactElement, ReactNode, useCallback, useState } from 'react'
|
||||
@ -230,6 +231,12 @@ export default function FeatureFlagModal() {
|
||||
featureFlag={FeatureFlag.uniswapXSyntheticQuote}
|
||||
label="Force synthetic quotes for UniswapX"
|
||||
/>
|
||||
<FeatureFlagOption
|
||||
variant={BaseVariant}
|
||||
value={useUniswapXEthOutputFlag()}
|
||||
featureFlag={FeatureFlag.uniswapXEthOutputEnabled}
|
||||
label="Enable eth output for UniswapX orders"
|
||||
/>
|
||||
<FeatureFlagOption
|
||||
variant={BaseVariant}
|
||||
value={useRoutingAPIForPriceFlag()}
|
||||
|
9
src/featureFlags/flags/uniswapXEthOutput.ts
Normal file
9
src/featureFlags/flags/uniswapXEthOutput.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { BaseVariant, FeatureFlag, useBaseFlag } from '../index'
|
||||
|
||||
export function useUniswapXEthOutputFlag(): BaseVariant {
|
||||
return useBaseFlag(FeatureFlag.uniswapXEthOutputEnabled)
|
||||
}
|
||||
|
||||
export function useUniswapXEthOutputEnabled(): boolean {
|
||||
return useUniswapXEthOutputFlag() === BaseVariant.Enabled
|
||||
}
|
@ -15,6 +15,7 @@ export enum FeatureFlag {
|
||||
uniswapXSyntheticQuote = 'uniswapx_synthetic_quote',
|
||||
routingAPIPrice = 'routing_api_price',
|
||||
forceUniswapXOn = 'uniswapx_force_on', // forces routing-api's feature flag for uniswapx to turn on as well
|
||||
uniswapXEthOutputEnabled = 'uniswapx_eth_output_enabled',
|
||||
baseEnabled = 'base_enabled',
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
|
||||
import { useForceUniswapXOn } from 'featureFlags/flags/forceUniswapXOn'
|
||||
import { useRoutingAPIForPrice } from 'featureFlags/flags/priceRoutingApi'
|
||||
import { useUniswapXEnabled } from 'featureFlags/flags/uniswapx'
|
||||
import { useUniswapXEthOutputEnabled } from 'featureFlags/flags/uniswapXEthOutput'
|
||||
import { useUniswapXSyntheticQuoteEnabled } from 'featureFlags/flags/uniswapXUseSyntheticQuote'
|
||||
import { useMemo } from 'react'
|
||||
import { GetQuoteArgs, INTERNAL_ROUTER_PREFERENCE_PRICE } from 'state/routing/slice'
|
||||
@ -34,6 +35,7 @@ export function useRoutingAPIArguments({
|
||||
const forceUniswapXOn = useForceUniswapXOn()
|
||||
const userDisabledUniswapX = useUserDisabledUniswapX()
|
||||
const isRoutingAPIPrice = useRoutingAPIForPrice()
|
||||
const uniswapXEthOutputEnabled = useUniswapXEthOutputEnabled()
|
||||
|
||||
return useMemo(
|
||||
() =>
|
||||
@ -58,6 +60,7 @@ export function useRoutingAPIArguments({
|
||||
uniswapXForceSyntheticQuotes,
|
||||
forceUniswapXOn,
|
||||
userDisabledUniswapX,
|
||||
uniswapXEthOutputEnabled,
|
||||
},
|
||||
[
|
||||
account,
|
||||
@ -71,6 +74,7 @@ export function useRoutingAPIArguments({
|
||||
uniswapXForceSyntheticQuotes,
|
||||
forceUniswapXOn,
|
||||
userDisabledUniswapX,
|
||||
uniswapXEthOutputEnabled,
|
||||
]
|
||||
)
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ export interface GetQuoteArgs {
|
||||
forceUniswapXOn: boolean
|
||||
userDisabledUniswapX: boolean
|
||||
isRoutingAPIPrice?: boolean
|
||||
uniswapXEthOutputEnabled: boolean
|
||||
}
|
||||
|
||||
const protocols: Protocol[] = [Protocol.V2, Protocol.V3, Protocol.MIXED]
|
||||
@ -60,7 +61,15 @@ const DEFAULT_QUERY_PARAMS = {
|
||||
}
|
||||
|
||||
function getRoutingAPIConfig(args: GetQuoteArgs): RoutingConfig {
|
||||
const { account, tradeType, tokenOutAddress, tokenInChainId, uniswapXForceSyntheticQuotes, routerPreference } = args
|
||||
const {
|
||||
account,
|
||||
tradeType,
|
||||
tokenOutAddress,
|
||||
tokenInChainId,
|
||||
uniswapXForceSyntheticQuotes,
|
||||
uniswapXEthOutputEnabled,
|
||||
routerPreference,
|
||||
} = args
|
||||
|
||||
const uniswapx = {
|
||||
useSyntheticQuotes: uniswapXForceSyntheticQuotes,
|
||||
@ -83,7 +92,7 @@ function getRoutingAPIConfig(args: GetQuoteArgs): RoutingConfig {
|
||||
if (
|
||||
!args.uniswapXEnabled ||
|
||||
(args.userDisabledUniswapX && routerPreference !== RouterPreference.X) ||
|
||||
tokenOutIsNative ||
|
||||
(tokenOutIsNative && !uniswapXEthOutputEnabled) ||
|
||||
tradeType === TradeType.EXACT_OUTPUT ||
|
||||
!isUniswapXSupportedChain(tokenInChainId)
|
||||
) {
|
||||
|
Loading…
Reference in New Issue
Block a user