uniswap-interface-uncensored/src/components/Settings/index.tsx

266 lines
8.8 KiB
TypeScript
Raw Normal View History

// eslint-disable-next-line no-restricted-imports
import { t, Trans } from '@lingui/macro'
import { Percent } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core'
import { sendEvent } from 'components/analytics'
import { RedesignVariant, useRedesignFlag } from 'featureFlags/flags/redesign'
feat: add support for Celo (#3915) * feat: Support for Celo * fix: wrong condition * combine celo and alfajores lists * use celo erc20 representation * fix: refactor infura.ts to networks.ts & add celo to rpc urls * feature: add celo contract addresses fix: remove celo from supported gas estimate chains until feature is available * refactor: useUSDCPrice to useStablecoinPrice fix: add celo to supported gas estimate chains * fix: use unique factory address for getting pool address * fix: darkmode background graident * fix: removing a comment left behind * fix: remove bad import * fix: remove dead link until the Celo is live on info.uniswap.org * fix: add asset to common bases & minor refactoring * fix: celo info links point to root info.uniswap.org * fix: change celo token bridge to portal * fix: update redux-multicall to latest version * refactor: for code readability * fix: celo banner colors & remove unused alternative logo * fix: change celo token list to hosted version * fix: update celo banner colors * fix: move celo to the bottom of the network selector list * fix: dedup dependencies @uniswap/router-sdk @uniswap/v3-sdk * fix: refactoring + move Celo above L2s * fix: update celo contract addresses * fix: update celo subgraph * fix: update v3-sdk and smart-order-router versions * fix: move Celo to the bottom of the network selector list * fix: downgrade smart-order-router and add casting fix * fix: downgrade smart-order-router and add casting fix * fix: resolve Pool dependency * fix: bridge chain id types * fix: explorer link test * fix: use quoter v2 ABI in useClientSideV3Trade fro Celo * fix: update connection "infura_rpc" to networks * fix: revert yarn.lock and force install * fix: dedup router and v3 sdk * refactor: mv quoter v2 to client side v3 trade * build: dedup lockfile * feature: add portal ether to common bases * fix: add comment for chains that use QuoterV2 * fix: use token as native asset * fix: supply correct factory address to getPoolAddress call & refactor nativeOnChain method * feature: adjust celo tokens presetned * fix: update celo explorer to celoscan * fix: celo token casting * fix: celo celo explorer it * fix: celo chain info should be consistent with block explorer used. Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
2022-07-12 17:48:03 +03:00
import { isSupportedChainId } from 'lib/hooks/routing/clientSideSmartOrderRouter'
import { useRef, useState } from 'react'
import { Settings, X } from 'react-feather'
2020-09-24 19:18:57 +03:00
import { Text } from 'rebass'
import styled, { useTheme } from 'styled-components/macro'
feat(lists): allow selecting and adding token lists (#1023) * more list stuff Use the selected list instead of the default list, but also use the default list start list selection code * move token warning to a modal, fix the install issue * add/remove/enter key * handle enter on currency select for ETHER * change slippage tolerance to be a slider * make ui closer to the mocks * commit slider changes * back to tabs * copy changes * bump list version * some styling for the list select * bump uniswap default list version * use contract calls to get ens names and addresses * show list logo * fix failing integration test * .eth.link * list introduction screen * remove showSendWithSwap * fix integration and unit tests * resolve ENS names * logos from ens * fix the lint errors * some refactoring to better support using a the library provider from the user for resolving ENS names * load list info from the list url for the introduction page * make it slightly harder to remove a list * minor clean up, some help text and links * remove icon from list update popup * show added/removed tokens * add GA everywhere, don't debounce contenthash lookups * show tags * fix tag key * tag display, list rendering, needs optimization * fix list fetching in firefox, style issue in safari * sort the lists, clean up styling * use client provider when possible * show token warning for url loaded tokens * improve the warning modal * some refactoring to fix the list fetching on networks other than mainnet * fix tests * some minor improvements * increase timeout to maybe fix integration tests which pass locally * build for tests using the dev network url * reset the lists if we deleted the other two copies * improve how we handle updating the default list of lists * fix integration test * Update token list selection styles * fix external links, reuse the on click outside code, show add errors * show the list origin instead of the full url * fix update list link * show host instead of hostname do not automatically dismiss major version upgrades for lists * fix link to tokenlists.org * add uma * clean up styling in list rows * bump token list version * bump token list version again * hover symbol to see currency name * bump version * add cmc lists, dharma list Co-authored-by: Callil Capuozzo <callil.capuozzo@gmail.com>
2020-08-26 16:46:21 +03:00
import { useOnClickOutside } from '../../hooks/useOnClickOutside'
import { useModalIsOpen, useToggleSettingsMenu } from '../../state/application/hooks'
import { ApplicationModal } from '../../state/application/reducer'
import { useClientSideRouter, useExpertModeManager } from '../../state/user/hooks'
import { ThemedText } from '../../theme'
import { ButtonError } from '../Button'
2020-09-24 19:18:57 +03:00
import { AutoColumn } from '../Column'
import Modal from '../Modal'
2020-09-24 19:18:57 +03:00
import QuestionHelper from '../QuestionHelper'
import { RowBetween, RowFixed } from '../Row'
import Toggle from '../Toggle'
import TransactionSettings from '../TransactionSettings'
const StyledMenuIcon = styled(Settings)<{ redesignFlag: boolean }>`
height: 20px;
width: 20px;
> * {
stroke: ${({ theme, redesignFlag }) => (redesignFlag ? theme.textSecondary : theme.deprecated_text1)};
}
`
const StyledCloseIcon = styled(X)<{ redesignFlag: boolean }>`
height: 20px;
width: 20px;
:hover {
cursor: pointer;
}
> * {
stroke: ${({ theme, redesignFlag }) => (redesignFlag ? theme.textSecondary : theme.deprecated_text1)};
}
`
const StyledMenuButton = styled.button<{ disabled: boolean }>`
position: relative;
width: 100%;
height: 100%;
border: none;
background-color: transparent;
margin: 0;
padding: 0;
border-radius: 0.5rem;
height: 20px;
${({ disabled }) =>
!disabled &&
`
:hover,
:focus {
cursor: pointer;
outline: none;
opacity: 0.7;
}
`}
`
const EmojiWrapper = styled.div`
position: absolute;
bottom: -6px;
right: 0px;
font-size: 14px;
`
const StyledMenu = styled.div`
margin-left: 0.5rem;
display: flex;
justify-content: center;
align-items: center;
position: relative;
border: none;
text-align: left;
`
const MenuFlyout = styled.span<{ redesignFlag: boolean }>`
min-width: 20.125rem;
background-color: ${({ theme, redesignFlag }) => (redesignFlag ? theme.backgroundSurface : theme.deprecated_bg2)};
border: 1px solid ${({ theme, redesignFlag }) => (redesignFlag ? theme.backgroundOutline : theme.deprecated_bg3)};
box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.01), 0px 4px 8px rgba(0, 0, 0, 0.04), 0px 16px 24px rgba(0, 0, 0, 0.04),
0px 24px 32px rgba(0, 0, 0, 0.01);
2020-09-24 19:18:57 +03:00
border-radius: 12px;
display: flex;
flex-direction: column;
font-size: 1rem;
position: absolute;
top: 2rem;
right: 0rem;
z-index: 100;
color: ${({ theme, redesignFlag }) => redesignFlag && theme.textPrimary};
${({ theme }) => theme.deprecated_mediaWidth.deprecated_upToMedium`
2020-09-24 19:18:57 +03:00
min-width: 18.125rem;
`};
2021-05-12 21:01:31 +03:00
user-select: none;
`
const Break = styled.div`
width: 100%;
height: 1px;
background-color: ${({ theme }) => theme.deprecated_bg3};
`
const ModalContentWrapper = styled.div`
display: flex;
align-items: center;
justify-content: center;
padding: 2rem 0;
background-color: ${({ theme }) => theme.deprecated_bg2};
border-radius: 20px;
`
export default function SettingsTab({ placeholderSlippage }: { placeholderSlippage: Percent }) {
const { chainId } = useWeb3React()
const redesignFlag = useRedesignFlag()
const redesignFlagEnabled = redesignFlag === RedesignVariant.Enabled
feat: routing api integration (#2116) * initial routing api integration * add routing api slice * display route in dialog * addressed pr feedback * improved routing * switch to `get` * first pass at integration new MultiRouteTrade * initial implementation of RoutingDiagram * add RoutingDiagram tests * improve tests in RoutingDiagram * integrate with v3-sdk 3.3.1 * removed references to MultiRouteTrade * revert swapcallback * fix abi compilation error * added useRoute hook to build a Route from edges and nodes * added react-hooks-testing-library * integrated latest changes * renamed router hook to routerTrade * improve integration * fixed routing * usability * mock RoutingDiagram children to reduce size * undo mocked children * adjust ui * better support long routes * use routing api logo and adjust ux * set default percent to 0 * added intermediary hook to combine local and routing api trades * added intermediary hook to combine local and routing api trades * make account optional * improve ux * improve router * fixed duplicate pool bug and inputAmount undefined bug * extract input/outputAmounts from routes * add todo * fixed uninitialized issue and added % * fixed tests * fix duplicate pool bug * added routing api setting * change router label based on router version * improve useRoutes and fix duplicate pool bug * debounce routing api/local routing * removed single hop setting * fix bug when moving between v2/v3 * consider isUnitialized non loading * ui fixes * reverted change to usedebounce * use new route schema * visual updates * log quoteId for polish session * fix: persist advanced swap details toggle state * fix no route found * poll every 10s * derive currencies from pool rather than input * polish query status handling in useRouterTrade * removed RouterVersion * update ui * update ui * update loading state * animate auto router * apply loading treatment to out * disable routing api on l2 and support auto slippage * use opacity on the whole element * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * feat: [draft] routing api polish (#2224) * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * polished loading state * add dashes * fixed tooltip styles * fixed merge conflict * few updates * polish * updated yarn.lock * fixed styles * updated routing diagram * Fix code style issues with ESLint * routing api enabled without localstorage upgrade * fixed lint error * Fix code style issues with ESLint * refined mocks in routing diagram tests * addressed pr feedback * polish * revert sending eth * improved loading animation * handle stale routing api * Fix code style issues with ESLint * updated yarn.lock * support native eth * Compute gas adjusted quote for V2 trade and compare to V3 gas adjusted quote * Incorporate approval gas cost estimate * feat: simplify routing api ux (#2258) * support native eth * simplified ui * perf optimization * implement realized lp fee * improved route realized lp fee * fix lp realized fee * fix auto router gradient * initial route overlay * add auto router svg * adjusted ux to mocks * fix lp fee * upddated routing diagram * optimize tradeBetter hook * adjust type and name * add useBetterTrade * useBetterTrade takes gasEstimateWei * implement gasEstimateForApproval * import state from react * use gas estimate * improve integration with gas estimate comparison * remove dependency on account * fix currency switch bug * improve syncing state * add loadingbar * style tooltip container * updated tooltip styles * increase opacity range * always keep dependent currency input interactable * show placeholders in tooltips * Revert v2 gas estimates and approval estimates * Add debug logs * refactor * fix bug * removed comment * update engish key * add try-catch * addressed pr feedback * remove loading bar for price impact * addressed pr feedback and bug bash feedback * fix: use url to force version * addressed pr feedback and bug bash feedback * stop fetching when losing focus * only show auto router label when activated * avoid showing syncing status * move V3TradeSTate to own file * make useRoutes a function rather than hook * use logo from active list when possible * renamed and refactored hook * renamed and refactored hook * update status * polish * remove unused import * fixed merge error * updated combined trade tests * remove priceimpact while loading * Design tweaks * polish latest design * removed some styles * log gaevent on tooltip open and clean up origin * Small tweaks * addressed pr feedback * wrap route length in a loading container * renamed local to clientside * fix percent and token logo * addressed pr feedback * avoid comparing trades when v3 not ready * some refactor Co-authored-by: Lint Action <lint-action@samuelmeuli.com> Co-authored-by: Will Pote <will@uniswap.org> Co-authored-by: Callil Capuozzo <callil.capuozzo@gmail.com>
2021-09-16 17:50:58 +03:00
const node = useRef<HTMLDivElement>()
const open = useModalIsOpen(ApplicationModal.SETTINGS)
const toggle = useToggleSettingsMenu()
const theme = useTheme()
const [expertMode, toggleExpertMode] = useExpertModeManager()
feat: routing api integration (#2116) * initial routing api integration * add routing api slice * display route in dialog * addressed pr feedback * improved routing * switch to `get` * first pass at integration new MultiRouteTrade * initial implementation of RoutingDiagram * add RoutingDiagram tests * improve tests in RoutingDiagram * integrate with v3-sdk 3.3.1 * removed references to MultiRouteTrade * revert swapcallback * fix abi compilation error * added useRoute hook to build a Route from edges and nodes * added react-hooks-testing-library * integrated latest changes * renamed router hook to routerTrade * improve integration * fixed routing * usability * mock RoutingDiagram children to reduce size * undo mocked children * adjust ui * better support long routes * use routing api logo and adjust ux * set default percent to 0 * added intermediary hook to combine local and routing api trades * added intermediary hook to combine local and routing api trades * make account optional * improve ux * improve router * fixed duplicate pool bug and inputAmount undefined bug * extract input/outputAmounts from routes * add todo * fixed uninitialized issue and added % * fixed tests * fix duplicate pool bug * added routing api setting * change router label based on router version * improve useRoutes and fix duplicate pool bug * debounce routing api/local routing * removed single hop setting * fix bug when moving between v2/v3 * consider isUnitialized non loading * ui fixes * reverted change to usedebounce * use new route schema * visual updates * log quoteId for polish session * fix: persist advanced swap details toggle state * fix no route found * poll every 10s * derive currencies from pool rather than input * polish query status handling in useRouterTrade * removed RouterVersion * update ui * update ui * update loading state * animate auto router * apply loading treatment to out * disable routing api on l2 and support auto slippage * use opacity on the whole element * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * feat: [draft] routing api polish (#2224) * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * polished loading state * add dashes * fixed tooltip styles * fixed merge conflict * few updates * polish * updated yarn.lock * fixed styles * updated routing diagram * Fix code style issues with ESLint * routing api enabled without localstorage upgrade * fixed lint error * Fix code style issues with ESLint * refined mocks in routing diagram tests * addressed pr feedback * polish * revert sending eth * improved loading animation * handle stale routing api * Fix code style issues with ESLint * updated yarn.lock * support native eth * Compute gas adjusted quote for V2 trade and compare to V3 gas adjusted quote * Incorporate approval gas cost estimate * feat: simplify routing api ux (#2258) * support native eth * simplified ui * perf optimization * implement realized lp fee * improved route realized lp fee * fix lp realized fee * fix auto router gradient * initial route overlay * add auto router svg * adjusted ux to mocks * fix lp fee * upddated routing diagram * optimize tradeBetter hook * adjust type and name * add useBetterTrade * useBetterTrade takes gasEstimateWei * implement gasEstimateForApproval * import state from react * use gas estimate * improve integration with gas estimate comparison * remove dependency on account * fix currency switch bug * improve syncing state * add loadingbar * style tooltip container * updated tooltip styles * increase opacity range * always keep dependent currency input interactable * show placeholders in tooltips * Revert v2 gas estimates and approval estimates * Add debug logs * refactor * fix bug * removed comment * update engish key * add try-catch * addressed pr feedback * remove loading bar for price impact * addressed pr feedback and bug bash feedback * fix: use url to force version * addressed pr feedback and bug bash feedback * stop fetching when losing focus * only show auto router label when activated * avoid showing syncing status * move V3TradeSTate to own file * make useRoutes a function rather than hook * use logo from active list when possible * renamed and refactored hook * renamed and refactored hook * update status * polish * remove unused import * fixed merge error * updated combined trade tests * remove priceimpact while loading * Design tweaks * polish latest design * removed some styles * log gaevent on tooltip open and clean up origin * Small tweaks * addressed pr feedback * wrap route length in a loading container * renamed local to clientside * fix percent and token logo * addressed pr feedback * avoid comparing trades when v3 not ready * some refactor Co-authored-by: Lint Action <lint-action@samuelmeuli.com> Co-authored-by: Will Pote <will@uniswap.org> Co-authored-by: Callil Capuozzo <callil.capuozzo@gmail.com>
2021-09-16 17:50:58 +03:00
const [clientSideRouter, setClientSideRouter] = useClientSideRouter()
// show confirmation view before turning on
const [showConfirmation, setShowConfirmation] = useState(false)
feat(lists): allow selecting and adding token lists (#1023) * more list stuff Use the selected list instead of the default list, but also use the default list start list selection code * move token warning to a modal, fix the install issue * add/remove/enter key * handle enter on currency select for ETHER * change slippage tolerance to be a slider * make ui closer to the mocks * commit slider changes * back to tabs * copy changes * bump list version * some styling for the list select * bump uniswap default list version * use contract calls to get ens names and addresses * show list logo * fix failing integration test * .eth.link * list introduction screen * remove showSendWithSwap * fix integration and unit tests * resolve ENS names * logos from ens * fix the lint errors * some refactoring to better support using a the library provider from the user for resolving ENS names * load list info from the list url for the introduction page * make it slightly harder to remove a list * minor clean up, some help text and links * remove icon from list update popup * show added/removed tokens * add GA everywhere, don't debounce contenthash lookups * show tags * fix tag key * tag display, list rendering, needs optimization * fix list fetching in firefox, style issue in safari * sort the lists, clean up styling * use client provider when possible * show token warning for url loaded tokens * improve the warning modal * some refactoring to fix the list fetching on networks other than mainnet * fix tests * some minor improvements * increase timeout to maybe fix integration tests which pass locally * build for tests using the dev network url * reset the lists if we deleted the other two copies * improve how we handle updating the default list of lists * fix integration test * Update token list selection styles * fix external links, reuse the on click outside code, show add errors * show the list origin instead of the full url * fix update list link * show host instead of hostname do not automatically dismiss major version upgrades for lists * fix link to tokenlists.org * add uma * clean up styling in list rows * bump token list version * bump token list version again * hover symbol to see currency name * bump version * add cmc lists, dharma list Co-authored-by: Callil Capuozzo <callil.capuozzo@gmail.com>
2020-08-26 16:46:21 +03:00
useOnClickOutside(node, open ? toggle : undefined)
return (
2020-08-27 21:10:00 +03:00
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/30451
<StyledMenu ref={node as any}>
<Modal isOpen={showConfirmation} onDismiss={() => setShowConfirmation(false)} maxHeight={100}>
<ModalContentWrapper>
<AutoColumn gap="lg">
<RowBetween style={{ padding: '0 2rem' }}>
<div />
<Text fontWeight={500} fontSize={20}>
<Trans>Are you sure?</Trans>
</Text>
<StyledCloseIcon onClick={() => setShowConfirmation(false)} redesignFlag={redesignFlagEnabled} />
</RowBetween>
<Break />
<AutoColumn gap="lg" style={{ padding: '0 2rem' }}>
<Text fontWeight={500} fontSize={20}>
<Trans>
Expert mode turns off the confirm transaction prompt and allows high slippage trades that often result
in bad rates and lost funds.
</Trans>
</Text>
<Text fontWeight={600} fontSize={20}>
<Trans>ONLY USE THIS MODE IF YOU KNOW WHAT YOU ARE DOING.</Trans>
</Text>
<ButtonError
error={true}
padding={'12px'}
onClick={() => {
const confirmWord = t`confirm`
if (window.prompt(t`Please type the word "${confirmWord}" to enable expert mode.`) === confirmWord) {
toggleExpertMode()
setShowConfirmation(false)
}
}}
>
2020-08-24 21:52:41 +03:00
<Text fontSize={20} fontWeight={500} id="confirm-expert-mode">
<Trans>Turn On Expert Mode</Trans>
</Text>
</ButtonError>
</AutoColumn>
</AutoColumn>
</ModalContentWrapper>
</Modal>
<StyledMenuButton
disabled={!isSupportedChainId(chainId)}
onClick={toggle}
id="open-settings-dialog-button"
aria-label={t`Transaction Settings`}
>
<StyledMenuIcon redesignFlag={redesignFlagEnabled} />
{expertMode ? (
<EmojiWrapper>
<span role="img" aria-label="wizard-icon">
🧙
</span>
</EmojiWrapper>
) : null}
</StyledMenuButton>
{open && (
<MenuFlyout redesignFlag={redesignFlagEnabled}>
<AutoColumn gap="md" style={{ padding: '1rem' }}>
<Text fontWeight={600} fontSize={14}>
<Trans>{redesignFlagEnabled ? 'Settings' : 'Transaction Settings'}</Trans>
</Text>
<TransactionSettings placeholderSlippage={placeholderSlippage} />
<Text fontWeight={600} fontSize={14}>
<Trans>Interface Settings</Trans>
</Text>
feat: add support for Celo (#3915) * feat: Support for Celo * fix: wrong condition * combine celo and alfajores lists * use celo erc20 representation * fix: refactor infura.ts to networks.ts & add celo to rpc urls * feature: add celo contract addresses fix: remove celo from supported gas estimate chains until feature is available * refactor: useUSDCPrice to useStablecoinPrice fix: add celo to supported gas estimate chains * fix: use unique factory address for getting pool address * fix: darkmode background graident * fix: removing a comment left behind * fix: remove bad import * fix: remove dead link until the Celo is live on info.uniswap.org * fix: add asset to common bases & minor refactoring * fix: celo info links point to root info.uniswap.org * fix: change celo token bridge to portal * fix: update redux-multicall to latest version * refactor: for code readability * fix: celo banner colors & remove unused alternative logo * fix: change celo token list to hosted version * fix: update celo banner colors * fix: move celo to the bottom of the network selector list * fix: dedup dependencies @uniswap/router-sdk @uniswap/v3-sdk * fix: refactoring + move Celo above L2s * fix: update celo contract addresses * fix: update celo subgraph * fix: update v3-sdk and smart-order-router versions * fix: move Celo to the bottom of the network selector list * fix: downgrade smart-order-router and add casting fix * fix: downgrade smart-order-router and add casting fix * fix: resolve Pool dependency * fix: bridge chain id types * fix: explorer link test * fix: use quoter v2 ABI in useClientSideV3Trade fro Celo * fix: update connection "infura_rpc" to networks * fix: revert yarn.lock and force install * fix: dedup router and v3 sdk * refactor: mv quoter v2 to client side v3 trade * build: dedup lockfile * feature: add portal ether to common bases * fix: add comment for chains that use QuoterV2 * fix: use token as native asset * fix: supply correct factory address to getPoolAddress call & refactor nativeOnChain method * feature: adjust celo tokens presetned * fix: update celo explorer to celoscan * fix: celo token casting * fix: celo celo explorer it * fix: celo chain info should be consistent with block explorer used. Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
2022-07-12 17:48:03 +03:00
{isSupportedChainId(chainId) && (
feat: routing api integration (#2116) * initial routing api integration * add routing api slice * display route in dialog * addressed pr feedback * improved routing * switch to `get` * first pass at integration new MultiRouteTrade * initial implementation of RoutingDiagram * add RoutingDiagram tests * improve tests in RoutingDiagram * integrate with v3-sdk 3.3.1 * removed references to MultiRouteTrade * revert swapcallback * fix abi compilation error * added useRoute hook to build a Route from edges and nodes * added react-hooks-testing-library * integrated latest changes * renamed router hook to routerTrade * improve integration * fixed routing * usability * mock RoutingDiagram children to reduce size * undo mocked children * adjust ui * better support long routes * use routing api logo and adjust ux * set default percent to 0 * added intermediary hook to combine local and routing api trades * added intermediary hook to combine local and routing api trades * make account optional * improve ux * improve router * fixed duplicate pool bug and inputAmount undefined bug * extract input/outputAmounts from routes * add todo * fixed uninitialized issue and added % * fixed tests * fix duplicate pool bug * added routing api setting * change router label based on router version * improve useRoutes and fix duplicate pool bug * debounce routing api/local routing * removed single hop setting * fix bug when moving between v2/v3 * consider isUnitialized non loading * ui fixes * reverted change to usedebounce * use new route schema * visual updates * log quoteId for polish session * fix: persist advanced swap details toggle state * fix no route found * poll every 10s * derive currencies from pool rather than input * polish query status handling in useRouterTrade * removed RouterVersion * update ui * update ui * update loading state * animate auto router * apply loading treatment to out * disable routing api on l2 and support auto slippage * use opacity on the whole element * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * feat: [draft] routing api polish (#2224) * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * polished loading state * add dashes * fixed tooltip styles * fixed merge conflict * few updates * polish * updated yarn.lock * fixed styles * updated routing diagram * Fix code style issues with ESLint * routing api enabled without localstorage upgrade * fixed lint error * Fix code style issues with ESLint * refined mocks in routing diagram tests * addressed pr feedback * polish * revert sending eth * improved loading animation * handle stale routing api * Fix code style issues with ESLint * updated yarn.lock * support native eth * Compute gas adjusted quote for V2 trade and compare to V3 gas adjusted quote * Incorporate approval gas cost estimate * feat: simplify routing api ux (#2258) * support native eth * simplified ui * perf optimization * implement realized lp fee * improved route realized lp fee * fix lp realized fee * fix auto router gradient * initial route overlay * add auto router svg * adjusted ux to mocks * fix lp fee * upddated routing diagram * optimize tradeBetter hook * adjust type and name * add useBetterTrade * useBetterTrade takes gasEstimateWei * implement gasEstimateForApproval * import state from react * use gas estimate * improve integration with gas estimate comparison * remove dependency on account * fix currency switch bug * improve syncing state * add loadingbar * style tooltip container * updated tooltip styles * increase opacity range * always keep dependent currency input interactable * show placeholders in tooltips * Revert v2 gas estimates and approval estimates * Add debug logs * refactor * fix bug * removed comment * update engish key * add try-catch * addressed pr feedback * remove loading bar for price impact * addressed pr feedback and bug bash feedback * fix: use url to force version * addressed pr feedback and bug bash feedback * stop fetching when losing focus * only show auto router label when activated * avoid showing syncing status * move V3TradeSTate to own file * make useRoutes a function rather than hook * use logo from active list when possible * renamed and refactored hook * renamed and refactored hook * update status * polish * remove unused import * fixed merge error * updated combined trade tests * remove priceimpact while loading * Design tweaks * polish latest design * removed some styles * log gaevent on tooltip open and clean up origin * Small tweaks * addressed pr feedback * wrap route length in a loading container * renamed local to clientside * fix percent and token logo * addressed pr feedback * avoid comparing trades when v3 not ready * some refactor Co-authored-by: Lint Action <lint-action@samuelmeuli.com> Co-authored-by: Will Pote <will@uniswap.org> Co-authored-by: Callil Capuozzo <callil.capuozzo@gmail.com>
2021-09-16 17:50:58 +03:00
<RowBetween>
<RowFixed>
<ThemedText.DeprecatedBlack fontWeight={400} fontSize={14} color={theme.deprecated_text2}>
<Trans>Auto Router API</Trans>
</ThemedText.DeprecatedBlack>
<QuestionHelper text={<Trans>Use the Uniswap Labs API to get faster quotes.</Trans>} />
feat: routing api integration (#2116) * initial routing api integration * add routing api slice * display route in dialog * addressed pr feedback * improved routing * switch to `get` * first pass at integration new MultiRouteTrade * initial implementation of RoutingDiagram * add RoutingDiagram tests * improve tests in RoutingDiagram * integrate with v3-sdk 3.3.1 * removed references to MultiRouteTrade * revert swapcallback * fix abi compilation error * added useRoute hook to build a Route from edges and nodes * added react-hooks-testing-library * integrated latest changes * renamed router hook to routerTrade * improve integration * fixed routing * usability * mock RoutingDiagram children to reduce size * undo mocked children * adjust ui * better support long routes * use routing api logo and adjust ux * set default percent to 0 * added intermediary hook to combine local and routing api trades * added intermediary hook to combine local and routing api trades * make account optional * improve ux * improve router * fixed duplicate pool bug and inputAmount undefined bug * extract input/outputAmounts from routes * add todo * fixed uninitialized issue and added % * fixed tests * fix duplicate pool bug * added routing api setting * change router label based on router version * improve useRoutes and fix duplicate pool bug * debounce routing api/local routing * removed single hop setting * fix bug when moving between v2/v3 * consider isUnitialized non loading * ui fixes * reverted change to usedebounce * use new route schema * visual updates * log quoteId for polish session * fix: persist advanced swap details toggle state * fix no route found * poll every 10s * derive currencies from pool rather than input * polish query status handling in useRouterTrade * removed RouterVersion * update ui * update ui * update loading state * animate auto router * apply loading treatment to out * disable routing api on l2 and support auto slippage * use opacity on the whole element * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * feat: [draft] routing api polish (#2224) * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * polished loading state * add dashes * fixed tooltip styles * fixed merge conflict * few updates * polish * updated yarn.lock * fixed styles * updated routing diagram * Fix code style issues with ESLint * routing api enabled without localstorage upgrade * fixed lint error * Fix code style issues with ESLint * refined mocks in routing diagram tests * addressed pr feedback * polish * revert sending eth * improved loading animation * handle stale routing api * Fix code style issues with ESLint * updated yarn.lock * support native eth * Compute gas adjusted quote for V2 trade and compare to V3 gas adjusted quote * Incorporate approval gas cost estimate * feat: simplify routing api ux (#2258) * support native eth * simplified ui * perf optimization * implement realized lp fee * improved route realized lp fee * fix lp realized fee * fix auto router gradient * initial route overlay * add auto router svg * adjusted ux to mocks * fix lp fee * upddated routing diagram * optimize tradeBetter hook * adjust type and name * add useBetterTrade * useBetterTrade takes gasEstimateWei * implement gasEstimateForApproval * import state from react * use gas estimate * improve integration with gas estimate comparison * remove dependency on account * fix currency switch bug * improve syncing state * add loadingbar * style tooltip container * updated tooltip styles * increase opacity range * always keep dependent currency input interactable * show placeholders in tooltips * Revert v2 gas estimates and approval estimates * Add debug logs * refactor * fix bug * removed comment * update engish key * add try-catch * addressed pr feedback * remove loading bar for price impact * addressed pr feedback and bug bash feedback * fix: use url to force version * addressed pr feedback and bug bash feedback * stop fetching when losing focus * only show auto router label when activated * avoid showing syncing status * move V3TradeSTate to own file * make useRoutes a function rather than hook * use logo from active list when possible * renamed and refactored hook * renamed and refactored hook * update status * polish * remove unused import * fixed merge error * updated combined trade tests * remove priceimpact while loading * Design tweaks * polish latest design * removed some styles * log gaevent on tooltip open and clean up origin * Small tweaks * addressed pr feedback * wrap route length in a loading container * renamed local to clientside * fix percent and token logo * addressed pr feedback * avoid comparing trades when v3 not ready * some refactor Co-authored-by: Lint Action <lint-action@samuelmeuli.com> Co-authored-by: Will Pote <will@uniswap.org> Co-authored-by: Callil Capuozzo <callil.capuozzo@gmail.com>
2021-09-16 17:50:58 +03:00
</RowFixed>
<Toggle
id="toggle-optimized-router-button"
isActive={!clientSideRouter}
toggle={() => {
sendEvent({
feat: routing api integration (#2116) * initial routing api integration * add routing api slice * display route in dialog * addressed pr feedback * improved routing * switch to `get` * first pass at integration new MultiRouteTrade * initial implementation of RoutingDiagram * add RoutingDiagram tests * improve tests in RoutingDiagram * integrate with v3-sdk 3.3.1 * removed references to MultiRouteTrade * revert swapcallback * fix abi compilation error * added useRoute hook to build a Route from edges and nodes * added react-hooks-testing-library * integrated latest changes * renamed router hook to routerTrade * improve integration * fixed routing * usability * mock RoutingDiagram children to reduce size * undo mocked children * adjust ui * better support long routes * use routing api logo and adjust ux * set default percent to 0 * added intermediary hook to combine local and routing api trades * added intermediary hook to combine local and routing api trades * make account optional * improve ux * improve router * fixed duplicate pool bug and inputAmount undefined bug * extract input/outputAmounts from routes * add todo * fixed uninitialized issue and added % * fixed tests * fix duplicate pool bug * added routing api setting * change router label based on router version * improve useRoutes and fix duplicate pool bug * debounce routing api/local routing * removed single hop setting * fix bug when moving between v2/v3 * consider isUnitialized non loading * ui fixes * reverted change to usedebounce * use new route schema * visual updates * log quoteId for polish session * fix: persist advanced swap details toggle state * fix no route found * poll every 10s * derive currencies from pool rather than input * polish query status handling in useRouterTrade * removed RouterVersion * update ui * update ui * update loading state * animate auto router * apply loading treatment to out * disable routing api on l2 and support auto slippage * use opacity on the whole element * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * feat: [draft] routing api polish (#2224) * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * polished loading state * add dashes * fixed tooltip styles * fixed merge conflict * few updates * polish * updated yarn.lock * fixed styles * updated routing diagram * Fix code style issues with ESLint * routing api enabled without localstorage upgrade * fixed lint error * Fix code style issues with ESLint * refined mocks in routing diagram tests * addressed pr feedback * polish * revert sending eth * improved loading animation * handle stale routing api * Fix code style issues with ESLint * updated yarn.lock * support native eth * Compute gas adjusted quote for V2 trade and compare to V3 gas adjusted quote * Incorporate approval gas cost estimate * feat: simplify routing api ux (#2258) * support native eth * simplified ui * perf optimization * implement realized lp fee * improved route realized lp fee * fix lp realized fee * fix auto router gradient * initial route overlay * add auto router svg * adjusted ux to mocks * fix lp fee * upddated routing diagram * optimize tradeBetter hook * adjust type and name * add useBetterTrade * useBetterTrade takes gasEstimateWei * implement gasEstimateForApproval * import state from react * use gas estimate * improve integration with gas estimate comparison * remove dependency on account * fix currency switch bug * improve syncing state * add loadingbar * style tooltip container * updated tooltip styles * increase opacity range * always keep dependent currency input interactable * show placeholders in tooltips * Revert v2 gas estimates and approval estimates * Add debug logs * refactor * fix bug * removed comment * update engish key * add try-catch * addressed pr feedback * remove loading bar for price impact * addressed pr feedback and bug bash feedback * fix: use url to force version * addressed pr feedback and bug bash feedback * stop fetching when losing focus * only show auto router label when activated * avoid showing syncing status * move V3TradeSTate to own file * make useRoutes a function rather than hook * use logo from active list when possible * renamed and refactored hook * renamed and refactored hook * update status * polish * remove unused import * fixed merge error * updated combined trade tests * remove priceimpact while loading * Design tweaks * polish latest design * removed some styles * log gaevent on tooltip open and clean up origin * Small tweaks * addressed pr feedback * wrap route length in a loading container * renamed local to clientside * fix percent and token logo * addressed pr feedback * avoid comparing trades when v3 not ready * some refactor Co-authored-by: Lint Action <lint-action@samuelmeuli.com> Co-authored-by: Will Pote <will@uniswap.org> Co-authored-by: Callil Capuozzo <callil.capuozzo@gmail.com>
2021-09-16 17:50:58 +03:00
category: 'Routing',
action: clientSideRouter ? 'enable routing API' : 'disable routing API',
})
setClientSideRouter(!clientSideRouter)
}}
/>
</RowBetween>
)}
<RowBetween>
<RowFixed>
<ThemedText.DeprecatedBlack fontWeight={400} fontSize={14} color={theme.deprecated_text2}>
feat: routing api integration (#2116) * initial routing api integration * add routing api slice * display route in dialog * addressed pr feedback * improved routing * switch to `get` * first pass at integration new MultiRouteTrade * initial implementation of RoutingDiagram * add RoutingDiagram tests * improve tests in RoutingDiagram * integrate with v3-sdk 3.3.1 * removed references to MultiRouteTrade * revert swapcallback * fix abi compilation error * added useRoute hook to build a Route from edges and nodes * added react-hooks-testing-library * integrated latest changes * renamed router hook to routerTrade * improve integration * fixed routing * usability * mock RoutingDiagram children to reduce size * undo mocked children * adjust ui * better support long routes * use routing api logo and adjust ux * set default percent to 0 * added intermediary hook to combine local and routing api trades * added intermediary hook to combine local and routing api trades * make account optional * improve ux * improve router * fixed duplicate pool bug and inputAmount undefined bug * extract input/outputAmounts from routes * add todo * fixed uninitialized issue and added % * fixed tests * fix duplicate pool bug * added routing api setting * change router label based on router version * improve useRoutes and fix duplicate pool bug * debounce routing api/local routing * removed single hop setting * fix bug when moving between v2/v3 * consider isUnitialized non loading * ui fixes * reverted change to usedebounce * use new route schema * visual updates * log quoteId for polish session * fix: persist advanced swap details toggle state * fix no route found * poll every 10s * derive currencies from pool rather than input * polish query status handling in useRouterTrade * removed RouterVersion * update ui * update ui * update loading state * animate auto router * apply loading treatment to out * disable routing api on l2 and support auto slippage * use opacity on the whole element * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * feat: [draft] routing api polish (#2224) * show loading card when syncing * updated gradient * polished ui * create routerlabel component * disable router on all bu mainnet * polish * polished loading state * add dashes * fixed tooltip styles * fixed merge conflict * few updates * polish * updated yarn.lock * fixed styles * updated routing diagram * Fix code style issues with ESLint * routing api enabled without localstorage upgrade * fixed lint error * Fix code style issues with ESLint * refined mocks in routing diagram tests * addressed pr feedback * polish * revert sending eth * improved loading animation * handle stale routing api * Fix code style issues with ESLint * updated yarn.lock * support native eth * Compute gas adjusted quote for V2 trade and compare to V3 gas adjusted quote * Incorporate approval gas cost estimate * feat: simplify routing api ux (#2258) * support native eth * simplified ui * perf optimization * implement realized lp fee * improved route realized lp fee * fix lp realized fee * fix auto router gradient * initial route overlay * add auto router svg * adjusted ux to mocks * fix lp fee * upddated routing diagram * optimize tradeBetter hook * adjust type and name * add useBetterTrade * useBetterTrade takes gasEstimateWei * implement gasEstimateForApproval * import state from react * use gas estimate * improve integration with gas estimate comparison * remove dependency on account * fix currency switch bug * improve syncing state * add loadingbar * style tooltip container * updated tooltip styles * increase opacity range * always keep dependent currency input interactable * show placeholders in tooltips * Revert v2 gas estimates and approval estimates * Add debug logs * refactor * fix bug * removed comment * update engish key * add try-catch * addressed pr feedback * remove loading bar for price impact * addressed pr feedback and bug bash feedback * fix: use url to force version * addressed pr feedback and bug bash feedback * stop fetching when losing focus * only show auto router label when activated * avoid showing syncing status * move V3TradeSTate to own file * make useRoutes a function rather than hook * use logo from active list when possible * renamed and refactored hook * renamed and refactored hook * update status * polish * remove unused import * fixed merge error * updated combined trade tests * remove priceimpact while loading * Design tweaks * polish latest design * removed some styles * log gaevent on tooltip open and clean up origin * Small tweaks * addressed pr feedback * wrap route length in a loading container * renamed local to clientside * fix percent and token logo * addressed pr feedback * avoid comparing trades when v3 not ready * some refactor Co-authored-by: Lint Action <lint-action@samuelmeuli.com> Co-authored-by: Will Pote <will@uniswap.org> Co-authored-by: Callil Capuozzo <callil.capuozzo@gmail.com>
2021-09-16 17:50:58 +03:00
<Trans>Expert Mode</Trans>
</ThemedText.DeprecatedBlack>
<QuestionHelper
text={
<Trans>Allow high price impact trades and skip the confirm screen. Use at your own risk.</Trans>
}
/>
</RowFixed>
<Toggle
2020-08-24 21:52:41 +03:00
id="toggle-expert-mode-button"
isActive={expertMode}
toggle={
expertMode
? () => {
toggleExpertMode()
setShowConfirmation(false)
}
: () => {
toggle()
setShowConfirmation(true)
}
}
/>
</RowBetween>
</AutoColumn>
</MenuFlyout>
)}
</StyledMenu>
)
}