feat: bump uniswapx-sdk (#7023)

* bump uniswapx-sdk

* add feature flag

* use undefined if feature flag is off

* move to top level config

* remove unused variable
This commit is contained in:
Tina 2023-07-27 12:16:17 -04:00 committed by GitHub
parent b58d4b72ab
commit 7ec6a965d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 8 deletions

@ -180,7 +180,7 @@
"@uniswap/sdk-core": "^4.0.3", "@uniswap/sdk-core": "^4.0.3",
"@uniswap/smart-order-router": "^3.13.7", "@uniswap/smart-order-router": "^3.13.7",
"@uniswap/token-lists": "^1.0.0-beta.33", "@uniswap/token-lists": "^1.0.0-beta.33",
"@uniswap/uniswapx-sdk": "^1.0.1", "@uniswap/uniswapx-sdk": "^1.1.0",
"@uniswap/universal-router-sdk": "^1.5.6", "@uniswap/universal-router-sdk": "^1.5.6",
"@uniswap/v2-core": "^1.0.1", "@uniswap/v2-core": "^1.0.1",
"@uniswap/v2-periphery": "^1.1.0-beta.0", "@uniswap/v2-periphery": "^1.1.0-beta.0",

@ -1,4 +1,5 @@
import { BaseVariant, FeatureFlag, featureFlagSettings, useUpdateFlag } from 'featureFlags' import { BaseVariant, FeatureFlag, featureFlagSettings, useUpdateFlag } from 'featureFlags'
import { useForceUniswapXOnFlag } from 'featureFlags/flags/forceUniswapXOn'
import { DetailsV2Variant, useDetailsV2Flag } from 'featureFlags/flags/nftDetails' import { DetailsV2Variant, useDetailsV2Flag } from 'featureFlags/flags/nftDetails'
import { useRoutingAPIForPriceFlag } from 'featureFlags/flags/priceRoutingApi' import { useRoutingAPIForPriceFlag } from 'featureFlags/flags/priceRoutingApi'
import { TraceJsonRpcVariant, useTraceJsonRpcFlag } from 'featureFlags/flags/traceJsonRpc' import { TraceJsonRpcVariant, useTraceJsonRpcFlag } from 'featureFlags/flags/traceJsonRpc'
@ -214,7 +215,13 @@ export default function FeatureFlagModal() {
variant={UniswapXVariant} variant={UniswapXVariant}
value={useUniswapXFlag()} value={useUniswapXFlag()}
featureFlag={FeatureFlag.uniswapXEnabled} featureFlag={FeatureFlag.uniswapXEnabled}
label="Enable UniswapX" label="Enable UniswapX on interface"
/>
<FeatureFlagOption
variant={BaseVariant}
value={useForceUniswapXOnFlag()}
featureFlag={FeatureFlag.forceUniswapXOn}
label="Force routing api to enable UniswapX"
/> />
<FeatureFlagOption <FeatureFlagOption
variant={BaseVariant} variant={BaseVariant}

@ -0,0 +1,9 @@
import { BaseVariant, FeatureFlag, useBaseFlag } from '../index'
export function useForceUniswapXOnFlag(): BaseVariant {
return useBaseFlag(FeatureFlag.forceUniswapXOn)
}
export function useForceUniswapXOn(): boolean {
return useForceUniswapXOnFlag() === BaseVariant.Enabled
}

@ -11,9 +11,10 @@ export enum FeatureFlag {
fiatOnRampButtonOnSwap = 'fiat_on_ramp_button_on_swap_page', fiatOnRampButtonOnSwap = 'fiat_on_ramp_button_on_swap_page',
detailsV2 = 'details_v2', detailsV2 = 'details_v2',
debounceSwapQuote = 'debounce_swap_quote', debounceSwapQuote = 'debounce_swap_quote',
uniswapXEnabled = 'uniswapx_enabled', uniswapXEnabled = 'uniswapx_enabled', // enables sending dutch_limit config to routing-api
uniswapXSyntheticQuote = 'uniswapx_synthetic_quote', uniswapXSyntheticQuote = 'uniswapx_synthetic_quote',
routingAPIPrice = 'routing_api_price', routingAPIPrice = 'routing_api_price',
forceUniswapXOn = 'uniswapx_force_on', // forces routing-api's feature flag for uniswapx to turn on as well
} }
interface FeatureFlagsContextType { interface FeatureFlagsContextType {

@ -1,4 +1,5 @@
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core' import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
import { useForceUniswapXOn } from 'featureFlags/flags/forceUniswapXOn'
import { useRoutingAPIForPrice } from 'featureFlags/flags/priceRoutingApi' import { useRoutingAPIForPrice } from 'featureFlags/flags/priceRoutingApi'
import { useUniswapXEnabled } from 'featureFlags/flags/uniswapx' import { useUniswapXEnabled } from 'featureFlags/flags/uniswapx'
import { useUniswapXSyntheticQuoteEnabled } from 'featureFlags/flags/uniswapXUseSyntheticQuote' import { useUniswapXSyntheticQuoteEnabled } from 'featureFlags/flags/uniswapXUseSyntheticQuote'
@ -28,6 +29,7 @@ export function useRoutingAPIArguments({
}): GetQuoteArgs | undefined { }): GetQuoteArgs | undefined {
const uniswapXEnabled = useUniswapXEnabled() const uniswapXEnabled = useUniswapXEnabled()
const uniswapXForceSyntheticQuotes = useUniswapXSyntheticQuoteEnabled() const uniswapXForceSyntheticQuotes = useUniswapXSyntheticQuoteEnabled()
const forceUniswapXOn = useForceUniswapXOn()
const isRoutingAPIPrice = useRoutingAPIForPrice() const isRoutingAPIPrice = useRoutingAPIForPrice()
return useMemo( return useMemo(
@ -51,6 +53,7 @@ export function useRoutingAPIArguments({
needsWrapIfUniswapX: tokenIn.isNative, needsWrapIfUniswapX: tokenIn.isNative,
uniswapXEnabled, uniswapXEnabled,
uniswapXForceSyntheticQuotes, uniswapXForceSyntheticQuotes,
forceUniswapXOn,
}, },
[ [
account, account,
@ -62,6 +65,7 @@ export function useRoutingAPIArguments({
uniswapXEnabled, uniswapXEnabled,
isRoutingAPIPrice, isRoutingAPIPrice,
uniswapXForceSyntheticQuotes, uniswapXForceSyntheticQuotes,
forceUniswapXOn,
] ]
) )
} }

@ -52,6 +52,7 @@ export interface GetQuoteArgs {
needsWrapIfUniswapX: boolean needsWrapIfUniswapX: boolean
uniswapXEnabled: boolean uniswapXEnabled: boolean
uniswapXForceSyntheticQuotes: boolean uniswapXForceSyntheticQuotes: boolean
forceUniswapXOn: boolean
isRoutingAPIPrice?: boolean isRoutingAPIPrice?: boolean
} }
@ -133,7 +134,15 @@ export const routingApi = createApi({
const fellBack = false const fellBack = false
if (shouldUseAPIRouter(args)) { if (shouldUseAPIRouter(args)) {
try { try {
const { tokenInAddress, tokenInChainId, tokenOutAddress, tokenOutChainId, amount, tradeType } = args const {
tokenInAddress,
tokenInChainId,
tokenOutAddress,
tokenOutChainId,
amount,
tradeType,
forceUniswapXOn,
} = args
const type = isExactInput(tradeType) ? 'EXACT_INPUT' : 'EXACT_OUTPUT' const type = isExactInput(tradeType) ? 'EXACT_INPUT' : 'EXACT_OUTPUT'
const requestBody = { const requestBody = {
@ -143,6 +152,8 @@ export const routingApi = createApi({
tokenOut: tokenOutAddress, tokenOut: tokenOutAddress,
amount, amount,
type, type,
// if forceUniswapXOn is not ON, then use the backend's default value
useUniswapX: forceUniswapXOn || undefined,
configs: getRoutingAPIConfig(args), configs: getRoutingAPIConfig(args),
} }

@ -6374,10 +6374,10 @@
resolved "https://registry.yarnpkg.com/@uniswap/token-lists/-/token-lists-1.0.0-beta.33.tgz#966ba96c9ccc8f0e9e09809890b438203f2b1911" resolved "https://registry.yarnpkg.com/@uniswap/token-lists/-/token-lists-1.0.0-beta.33.tgz#966ba96c9ccc8f0e9e09809890b438203f2b1911"
integrity sha512-JQkXcpRI3jFG8y3/CGC4TS8NkDgcxXaOQuYW8Qdvd6DcDiIyg2vVYCG9igFEzF0G6UvxgHkBKC7cWCgzZNYvQg== integrity sha512-JQkXcpRI3jFG8y3/CGC4TS8NkDgcxXaOQuYW8Qdvd6DcDiIyg2vVYCG9igFEzF0G6UvxgHkBKC7cWCgzZNYvQg==
"@uniswap/uniswapx-sdk@^1.0.1": "@uniswap/uniswapx-sdk@^1.1.0":
version "1.0.1" version "1.1.0"
resolved "https://registry.yarnpkg.com/@uniswap/uniswapx-sdk/-/uniswapx-sdk-1.0.1.tgz#c1378da255a710bcaa9bbf553634d70db533bd90" resolved "https://registry.yarnpkg.com/@uniswap/uniswapx-sdk/-/uniswapx-sdk-1.1.0.tgz#fd0c56f7f1a820b2d47b05d020108ced35d87cbd"
integrity sha512-qll9TuZLWG8cbLOXy7C79vONyQgBoos/g9Xphcjdyi2O8dD/Kk7x3P2kQ7OZrcPnaJ1wOtMzKX/9PstDrjiHrQ== integrity sha512-LIEaVnuqaGnm66Rt8s3XB8DzUo6gUNfI2HDarCXpS4e2wVb4FA2/hzsC41vbL4qR579cRCn/br4bNfNI6wvDWQ==
dependencies: dependencies:
"@ethersproject/bytes" "^5.7.0" "@ethersproject/bytes" "^5.7.0"
"@ethersproject/providers" "^5.7.0" "@ethersproject/providers" "^5.7.0"