Skip to content

Commit 5ded55e

Browse files
authored
feat: x rollout cleanup (Uniswap#7582)
* feat: cleanup post x rollout * feat: remove feature flag * fix: remove more unused styled components * fix: delete deprecated value from redux store * fix: lint * fix: remove userOptedOutOfUniswapX * fix: migrate verion in edge case, add test
1 parent 0f4ca59 commit 5ded55e

File tree

26 files changed

+172
-495
lines changed

26 files changed

+172
-495
lines changed

cypress/e2e/swap/fees.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,7 @@ describe('Swap with fees', () => {
120120
describe('UniswapX swaps', () => {
121121
it('displays UniswapX fee in UI', () => {
122122
cy.visit('/swap', {
123-
featureFlags: [
124-
{ name: FeatureFlag.feesEnabled, value: true },
125-
{ name: FeatureFlag.uniswapXDefaultEnabled, value: true },
126-
],
123+
featureFlags: [{ name: FeatureFlag.feesEnabled, value: true }],
127124
})
128125

129126
// Intercept the trade quote

cypress/e2e/swap/uniswapx.test.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ChainId, CurrencyAmount } from '@uniswap/sdk-core'
22
import { CyHttpMessages } from 'cypress/types/net-stubbing'
3-
import { FeatureFlag } from 'featureFlags'
43

54
import { DAI, nativeOnChain, USDC_MAINNET } from '../../../src/constants/tokens'
65
import { getTestSelector } from '../../utils'
@@ -45,9 +44,7 @@ function stubSwapTxReceipt() {
4544
describe('UniswapX Toggle', () => {
4645
beforeEach(() => {
4746
stubNonPriceQuoteWith(QuoteWhereUniswapXIsBetter)
48-
cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`, {
49-
featureFlags: [{ name: FeatureFlag.uniswapXDefaultEnabled, value: true }],
50-
})
47+
cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`)
5148
})
5249

5350
it('displays uniswapx ui when setting is on', () => {
@@ -69,9 +66,7 @@ describe('UniswapX Orders', () => {
6966
stubSwapTxReceipt()
7067

7168
cy.hardhat().then((hardhat) => hardhat.fund(hardhat.wallet, CurrencyAmount.fromRawAmount(USDC_MAINNET, 3e8)))
72-
cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`, {
73-
featureFlags: [{ name: FeatureFlag.uniswapXDefaultEnabled, value: true }],
74-
})
69+
cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`)
7570
})
7671

7772
it('can swap exact-in trades using uniswapX', () => {
@@ -159,9 +154,7 @@ describe('UniswapX Eth Input', () => {
159154

160155
stubSwapTxReceipt()
161156

162-
cy.visit(`/swap/?inputCurrency=ETH&outputCurrency=${DAI.address}`, {
163-
featureFlags: [{ name: FeatureFlag.uniswapXDefaultEnabled, value: true }],
164-
})
157+
cy.visit(`/swap/?inputCurrency=ETH&outputCurrency=${DAI.address}`)
165158
})
166159

167160
it('can swap using uniswapX with ETH as input', () => {
@@ -247,9 +240,7 @@ describe('UniswapX activity history', () => {
247240
cy.hardhat().then(async (hardhat) => {
248241
await hardhat.fund(hardhat.wallet, CurrencyAmount.fromRawAmount(USDC_MAINNET, 3e8))
249242
})
250-
cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`, {
251-
featureFlags: [{ name: FeatureFlag.uniswapXDefaultEnabled, value: true }],
252-
})
243+
cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`)
253244
})
254245

255246
it('can view UniswapX order status progress in activity', () => {

src/components/FeatureFlagModal/FeatureFlagModal.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { useMultichainUXFlag } from 'featureFlags/flags/multichainUx'
1414
import { useProgressIndicatorV2Flag } from 'featureFlags/flags/progressIndicatorV2'
1515
import { useQuickRouteMainnetFlag } from 'featureFlags/flags/quickRouteMainnet'
1616
import { TraceJsonRpcVariant, useTraceJsonRpcFlag } from 'featureFlags/flags/traceJsonRpc'
17-
import { useUniswapXDefaultEnabledFlag } from 'featureFlags/flags/uniswapXDefault'
1817
import { useUniswapXSyntheticQuoteFlag } from 'featureFlags/flags/uniswapXUseSyntheticQuote'
1918
import { useFeesEnabledFlag } from 'featureFlags/flags/useFees'
2019
import { useUpdateAtom } from 'jotai/utils'
@@ -324,12 +323,6 @@ export default function FeatureFlagModal() {
324323
featureFlag={FeatureFlag.uniswapXSyntheticQuote}
325324
label="Force synthetic quotes for UniswapX"
326325
/>
327-
<FeatureFlagOption
328-
variant={BaseVariant}
329-
value={useUniswapXDefaultEnabledFlag()}
330-
featureFlag={FeatureFlag.uniswapXDefaultEnabled}
331-
label="Enable UniswapX by default"
332-
/>
333326
</FeatureFlagGroup>
334327
<FeatureFlagGroup name="Info Site Migration">
335328
<FeatureFlagOption

src/components/Popover/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ReferenceElement = styled.div`
2020
height: inherit;
2121
`
2222

23-
export const Arrow = styled.div`
23+
const Arrow = styled.div`
2424
width: 8px;
2525
height: 8px;
2626
z-index: 9998;

src/components/Settings/RouterPreferenceSettings/index.tsx

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ import Column from 'components/Column'
33
import UniswapXBrandMark from 'components/Logo/UniswapXBrandMark'
44
import { RowBetween, RowFixed } from 'components/Row'
55
import Toggle from 'components/Toggle'
6-
import { useUniswapXDefaultEnabled } from 'featureFlags/flags/uniswapXDefault'
7-
import { useAppDispatch } from 'state/hooks'
86
import { RouterPreference } from 'state/routing/types'
9-
import { useRouterPreference, useUserOptedOutOfUniswapX } from 'state/user/hooks'
10-
import { updateDisabledUniswapX, updateOptedOutOfUniswapX } from 'state/user/reducer'
7+
import { useRouterPreference } from 'state/user/hooks'
118
import styled from 'styled-components'
129
import { ExternalLink, ThemedText } from 'theme/components'
1310

@@ -22,12 +19,6 @@ const InlineLink = styled(ThemedText.BodySmall)`
2219

2320
export default function RouterPreferenceSettings() {
2421
const [routerPreference, setRouterPreference] = useRouterPreference()
25-
const dispatch = useAppDispatch()
26-
const userOptedOutOfUniswapX = useUserOptedOutOfUniswapX()
27-
const isUniswapXDefaultEnabled = useUniswapXDefaultEnabled()
28-
const isUniswapXOverrideEnabled = isUniswapXDefaultEnabled && !userOptedOutOfUniswapX
29-
30-
const uniswapXInEffect = routerPreference === RouterPreference.X || isUniswapXOverrideEnabled
3122

3223
return (
3324
<RowBetween gap="sm">
@@ -46,21 +37,9 @@ export default function RouterPreferenceSettings() {
4637
</RowFixed>
4738
<Toggle
4839
id="toggle-uniswap-x-button"
49-
// If UniswapX-by-default is enabled we need to render this as active even if routerPreference === RouterPreference.API
50-
// because we're going to default to the UniswapX quote.
51-
// If the user manually toggles it off, this doesn't apply.
52-
isActive={uniswapXInEffect}
40+
isActive={routerPreference === RouterPreference.X}
5341
toggle={() => {
54-
if (uniswapXInEffect) {
55-
if (isUniswapXDefaultEnabled) {
56-
// We need to remember if a opts out of UniswapX, so we don't request UniswapX quotes.
57-
dispatch(updateOptedOutOfUniswapX({ optedOutOfUniswapX: true }))
58-
} else {
59-
// We need to remember if a user disables Uniswap X, so we don't show the opt-in flow again.
60-
dispatch(updateDisabledUniswapX({ disabledUniswapX: true }))
61-
}
62-
}
63-
setRouterPreference(uniswapXInEffect ? RouterPreference.API : RouterPreference.X)
42+
setRouterPreference(routerPreference === RouterPreference.X ? RouterPreference.API : RouterPreference.X)
6443
}}
6544
/>
6645
</RowBetween>

src/components/swap/styled.tsx

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { AlertTriangle } from 'react-feather'
44
import styled, { css } from 'styled-components'
55
import { Z_INDEX } from 'theme/zIndex'
66

7-
import { useIsDarkMode } from '../../theme/components/ThemeToggle'
87
import { AutoColumn } from '../Column'
98

109
export const PageWrapper = styled.div`
@@ -61,109 +60,6 @@ const SwapWrapperInner = styled.div`
6160
padding-top: 12px;
6261
`
6362

64-
export const UniswapPopoverContainer = styled.div`
65-
padding: 18px;
66-
color: ${({ theme }) => theme.neutral1};
67-
font-weight: 485;
68-
font-size: 12px;
69-
line-height: 16px;
70-
word-break: break-word;
71-
background: ${({ theme }) => theme.surface1};
72-
border-radius: 20px;
73-
border: 1px solid ${({ theme }) => theme.surface3};
74-
box-shadow: 0 4px 8px 0 ${({ theme }) => transparentize(0.9, theme.shadow1)};
75-
position: relative;
76-
overflow: hidden;
77-
`
78-
79-
const springDownKeyframes = `@keyframes spring-down {
80-
0% { transform: translateY(-80px); }
81-
25% { transform: translateY(4px); }
82-
50% { transform: translateY(-1px); }
83-
75% { transform: translateY(0px); }
84-
100% { transform: translateY(0px); }
85-
}`
86-
87-
const backUpKeyframes = `@keyframes back-up {
88-
0% { transform: translateY(0px); }
89-
100% { transform: translateY(-80px); }
90-
}`
91-
92-
export const UniswapXShine = (props: any) => {
93-
const isDarkMode = useIsDarkMode()
94-
return <UniswapXShineInner {...props} style={{ opacity: isDarkMode ? 0.15 : 0.05, ...props.style }} />
95-
}
96-
97-
const UniswapXShineInner = styled.div`
98-
position: absolute;
99-
top: 0;
100-
left: 0;
101-
right: 0;
102-
bottom: 0;
103-
z-index: -1;
104-
pointer-events: none;
105-
background: linear-gradient(130deg, transparent 20%, ${({ theme }) => theme.accent1}, transparent 80%);
106-
opacity: 0.15;
107-
`
108-
109-
// overflow hidden to hide the SwapMustacheShadow
110-
export const SwapOptInSmallContainer = styled.div<{ visible: boolean }>`
111-
visibility: ${({ visible }) => (visible ? 'visible' : 'hidden')};
112-
overflow: hidden;
113-
margin-top: -14px;
114-
transform: translateY(${({ visible }) => (visible ? 0 : -80)}px);
115-
transition: all ease 400ms;
116-
animation: ${({ visible }) => (visible ? `spring-down 900ms ease forwards` : 'back-up 200ms ease forwards')};
117-
118-
${springDownKeyframes}
119-
${backUpKeyframes}
120-
`
121-
122-
export const UniswapXOptInLargeContainerPositioner = styled.div`
123-
position: absolute;
124-
top: 211px;
125-
right: ${-320 - 15}px;
126-
width: 320px;
127-
align-items: center;
128-
min-height: 170px;
129-
display: flex;
130-
pointer-events: none;
131-
`
132-
133-
export const UniswapXOptInLargeContainer = styled.div<{ visible: boolean }>`
134-
opacity: ${({ visible }) => (visible ? 1 : 0)};
135-
transform: ${({ visible }) => `translateY(${visible ? 0 : -6}px)`};
136-
transition: all ease-in 300ms;
137-
transition-delay: ${({ visible }) => (visible ? '350ms' : '0')};
138-
pointer-events: ${({ visible }) => (visible ? 'auto' : 'none')};
139-
`
140-
141-
export const SwapMustache = styled.main`
142-
position: relative;
143-
background: ${({ theme }) => theme.surface1};
144-
border-radius: 16px;
145-
border-top-left-radius: 0;
146-
border-top-right-radius: 0;
147-
border: 1px solid ${({ theme }) => theme.surface3};
148-
border-top-width: 0;
149-
padding: 18px;
150-
padding-top: calc(12px + 18px);
151-
z-index: 0;
152-
transition: transform 250ms ease;
153-
`
154-
155-
export const SwapMustacheShadow = styled.main`
156-
position: absolute;
157-
top: 0;
158-
left: 0;
159-
border-radius: 16px;
160-
height: 100%;
161-
width: 100%;
162-
transform: translateY(-100%);
163-
box-shadow: 0 0 20px 20px ${({ theme }) => theme.surface2};
164-
background: red;
165-
`
166-
16763
export const ArrowWrapper = styled.div<{ clickable: boolean }>`
16864
border-radius: 12px;
16965
height: 40px;

src/featureFlags/flags/uniswapXDefault.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/featureFlags/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export enum FeatureFlag {
1616
infoTDP = 'info_tdp',
1717
infoPoolPage = 'info_pool_page',
1818
infoLiveViews = 'info_live_views',
19-
uniswapXDefaultEnabled = 'uniswapx_default_enabled',
2019
quickRouteMainnet = 'enable_quick_route_mainnet',
2120
progressIndicatorV2 = 'progress_indicator_v2',
2221
feesEnabled = 'fees_enabled',

src/lib/hooks/routing/useRoutingAPIArguments.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { SkipToken, skipToken } from '@reduxjs/toolkit/query/react'
22
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
3-
import { useUniswapXDefaultEnabled } from 'featureFlags/flags/uniswapXDefault'
43
import { useUniswapXSyntheticQuoteEnabled } from 'featureFlags/flags/uniswapXUseSyntheticQuote'
54
import { useFeesEnabled } from 'featureFlags/flags/useFees'
65
import { useMemo } from 'react'
76
import { GetQuoteArgs, INTERNAL_ROUTER_PREFERENCE_PRICE, RouterPreference } from 'state/routing/types'
87
import { currencyAddressForSwapQuote } from 'state/routing/utils'
9-
import { useUserDisabledUniswapX, useUserOptedOutOfUniswapX } from 'state/user/hooks'
108

119
/**
1210
* Returns query arguments for the Routing API query or undefined if the
@@ -29,9 +27,6 @@ export function useRoutingAPIArguments({
2927
routerPreference: RouterPreference | typeof INTERNAL_ROUTER_PREFERENCE_PRICE
3028
}): GetQuoteArgs | SkipToken {
3129
const uniswapXForceSyntheticQuotes = useUniswapXSyntheticQuoteEnabled()
32-
const userDisabledUniswapX = useUserDisabledUniswapX()
33-
const userOptedOutOfUniswapX = useUserOptedOutOfUniswapX()
34-
const isUniswapXDefaultEnabled = useUniswapXDefaultEnabled()
3530

3631
const feesEnabled = useFeesEnabled()
3732
// Don't enable fee logic if this is a quote for pricing
@@ -56,23 +51,8 @@ export function useRoutingAPIArguments({
5651
tradeType,
5752
needsWrapIfUniswapX: tokenIn.isNative,
5853
uniswapXForceSyntheticQuotes,
59-
userDisabledUniswapX,
60-
userOptedOutOfUniswapX,
61-
isUniswapXDefaultEnabled,
6254
sendPortionEnabled,
6355
},
64-
[
65-
account,
66-
amount,
67-
routerPreference,
68-
tokenIn,
69-
tokenOut,
70-
tradeType,
71-
uniswapXForceSyntheticQuotes,
72-
userDisabledUniswapX,
73-
userOptedOutOfUniswapX,
74-
isUniswapXDefaultEnabled,
75-
sendPortionEnabled,
76-
]
56+
[account, amount, routerPreference, tokenIn, tokenOut, tradeType, uniswapXForceSyntheticQuotes, sendPortionEnabled]
7757
)
7858
}

src/pages/App.tsx

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ import ErrorBoundary from 'components/ErrorBoundary'
55
import Loader from 'components/Icons/LoadingSpinner'
66
import NavBar, { PageTabs } from 'components/NavBar'
77
import { UK_BANNER_HEIGHT, UK_BANNER_HEIGHT_MD, UK_BANNER_HEIGHT_SM, UkBanner } from 'components/NavBar/UkBanner'
8-
import { FeatureFlag, useFeatureFlagsIsLoaded } from 'featureFlags'
9-
import { useUniswapXDefaultEnabled } from 'featureFlags/flags/uniswapXDefault'
8+
import { useFeatureFlagsIsLoaded } from 'featureFlags'
109
import { useAtom } from 'jotai'
1110
import { useBag } from 'nft/hooks/useBag'
1211
import { lazy, Suspense, useEffect, useLayoutEffect, useMemo, useState } from 'react'
1312
import { Navigate, Route, Routes, useLocation, useSearchParams } from 'react-router-dom'
1413
import { shouldDisableNFTRoutesAtom } from 'state/application/atoms'
1514
import { useAppSelector } from 'state/hooks'
1615
import { AppState } from 'state/reducer'
17-
import { RouterPreference } from 'state/routing/types'
18-
import { useRouterPreference, useUserOptedOutOfUniswapX } from 'state/user/hooks'
19-
import { StatsigProvider, StatsigUser, useGate } from 'statsig-react'
16+
import { useRouterPreference } from 'state/user/hooks'
17+
import { StatsigProvider, StatsigUser } from 'statsig-react'
2018
import styled from 'styled-components'
2119
import DarkModeQueryParamReader from 'theme/components/DarkModeQueryParamReader'
2220
import { useIsDarkMode } from 'theme/components/ThemeToggle'
@@ -212,9 +210,6 @@ function UserPropertyUpdater() {
212210
const isDarkMode = useIsDarkMode()
213211

214212
const [routerPreference] = useRouterPreference()
215-
const userOptedOutOfUniswapX = useUserOptedOutOfUniswapX()
216-
const isUniswapXDefaultEnabled = useUniswapXDefaultEnabled()
217-
const { isLoading: isUniswapXDefaultLoading } = useGate(FeatureFlag.uniswapXDefaultEnabled)
218213
const rehydrated = useAppSelector((state) => state._persist.rehydrated)
219214

220215
useEffect(() => {
@@ -248,22 +243,8 @@ function UserPropertyUpdater() {
248243
}, [isDarkMode])
249244

250245
useEffect(() => {
251-
if (isUniswapXDefaultLoading || !rehydrated) return
252-
253-
// If we're not in the transition period to UniswapX opt-out, set the router preference to whatever is specified.
254-
if (!isUniswapXDefaultEnabled) {
255-
user.set(CustomUserProperties.ROUTER_PREFERENCE, routerPreference)
256-
return
257-
}
258-
259-
// In the transition period, override the stored API preference to UniswapX if the user hasn't opted out.
260-
if (routerPreference === RouterPreference.API && !userOptedOutOfUniswapX) {
261-
user.set(CustomUserProperties.ROUTER_PREFERENCE, RouterPreference.X)
262-
return
263-
}
264-
265-
// Otherwise, the user has opted out or their preference is UniswapX/client, so set the preference to whatever is specified.
246+
if (!rehydrated) return
266247
user.set(CustomUserProperties.ROUTER_PREFERENCE, routerPreference)
267-
}, [routerPreference, isUniswapXDefaultEnabled, userOptedOutOfUniswapX, isUniswapXDefaultLoading, rehydrated])
248+
}, [routerPreference, rehydrated])
268249
return null
269250
}

0 commit comments

Comments
 (0)