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

260 lines
7.9 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 { SupportedChainId } from 'constants/chains'
import { useActiveWeb3React } from 'hooks/web3'
import { useContext, useRef, useState } from 'react'
import { Settings, X } from 'react-feather'
import ReactGA from 'react-ga'
2020-09-24 19:18:57 +03:00
import { Text } from 'rebass'
import styled, { ThemeContext } 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'
2020-09-24 19:18:57 +03:00
import { useModalOpen, 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)`
height: 20px;
width: 20px;
> * {
stroke: ${({ theme }) => theme.text2};
}
:hover {
opacity: 0.7;
}
`
const StyledCloseIcon = styled(X)`
height: 20px;
width: 20px;
:hover {
cursor: pointer;
}
> * {
stroke: ${({ theme }) => theme.text1};
}
`
const StyledMenuButton = styled.button`
position: relative;
width: 100%;
height: 100%;
border: none;
background-color: transparent;
margin: 0;
padding: 0;
border-radius: 0.5rem;
height: 20px;
:hover,
:focus {
cursor: pointer;
outline: none;
}
`
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`
min-width: 20.125rem;
2020-09-24 19:18:57 +03:00
background-color: ${({ theme }) => theme.bg2};
border: 1px solid ${({ theme }) => theme.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;
2020-09-24 19:18:57 +03:00
${({ theme }) => theme.mediaWidth.upToMedium`
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.bg3};
`
const ModalContentWrapper = styled.div`
display: flex;
align-items: center;
justify-content: center;
padding: 2rem 0;
background-color: ${({ theme }) => theme.bg2};
border-radius: 20px;
`
export default function SettingsTab({ placeholderSlippage }: { placeholderSlippage: Percent }) {
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 { chainId } = useActiveWeb3React()
const node = useRef<HTMLDivElement>()
2020-09-24 19:18:57 +03:00
const open = useModalOpen(ApplicationModal.SETTINGS)
const toggle = useToggleSettingsMenu()
const theme = useContext(ThemeContext)
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)} />
</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 onClick={toggle} id="open-settings-dialog-button" aria-label={t`Transaction Settings`}>
<StyledMenuIcon />
{expertMode ? (
<EmojiWrapper>
<span role="img" aria-label="wizard-icon">
🧙
</span>
</EmojiWrapper>
) : null}
</StyledMenuButton>
{open && (
<MenuFlyout>
<AutoColumn gap="md" style={{ padding: '1rem' }}>
<Text fontWeight={600} fontSize={14}>
<Trans>Transaction Settings</Trans>
</Text>
<TransactionSettings placeholderSlippage={placeholderSlippage} />
<Text fontWeight={600} fontSize={14}>
<Trans>Interface Settings</Trans>
</Text>
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
{chainId === SupportedChainId.MAINNET && (
<RowBetween>
<RowFixed>
<ThemedText.Black fontWeight={400} fontSize={14} color={theme.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>Auto Router</Trans>
</ThemedText.Black>
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
<QuestionHelper
text={<Trans>Use the Uniswap Labs API to get better pricing through a more efficient route.</Trans>}
/>
</RowFixed>
<Toggle
id="toggle-optimized-router-button"
isActive={!clientSideRouter}
toggle={() => {
ReactGA.event({
category: 'Routing',
action: clientSideRouter ? 'enable routing API' : 'disable routing API',
})
setClientSideRouter(!clientSideRouter)
}}
/>
</RowBetween>
)}
<RowBetween>
<RowFixed>
<ThemedText.Black fontWeight={400} fontSize={14} color={theme.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.Black>
<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>
)
}