components APIs
- Header
- Button
- Layout
- Footer
- Text
- Box
- Card
- Table
- Loading
- Select
- Loader
- Toolbar
- Icon
- CodeInput
- BottomSheet
- InfoBlock
- LanguageToggle
- ProgressCircles
- Ripple
- Toggle
- Tag
- Input
- Paginator
- Filter
- AsyncSelect
- CatalogBigButton
- ReadMore
- ConditionalWrapper
- LastCheckedDisplay
- PriceLabel
- PageTitle
- CartTable
- CartFinalPriceTable
- LoadingSpin
- InfoModal
- ProductCard
- RecommendCoupon
- PriceVales
- NomalLayout
- Web3ReactManager
- Popups
- CurrencyInput
- TransactionErrorContent
- TransactionConfirmationModal
- ConfirmationModalContent
- DoubleCurrencyLogo
- CustomModal
- CurrencySearchModal
- CurrencyLogo
- NumericalInput
- Logo
- QuestionHelper
- ListLogo
- DataTable
- WalletModal
- CustomTable
- MinimalPositionCard
- RemoveLiquidityModal
- CustomTooltip
- ColoredSlider
- ToggleSwitch
- FormattedPriceImpact
- SettingsModal
- ConfirmSwapModal
- AdvancedSwapDetails
- AddressInput
- LineChart
- StakeSyrupModal
- AccountDetails
- BetaWarningBanner
- AreaChart
- ChartType
- TokensTable
- PairTable
- TopMovers
- BarChart
- TransactionsTable
- StakeQuickModal
- UnstakeQuickModal
- SyrupCard
- CustomMenu
- SearchInput
- CustomSwitch
- FarmCard
- BuyFiatModal
- MoonpayModal
- RewardSlider
- Swap
- AddLiquidity
- PoolFinderModal
- PoolPositionCard
- SwapTokenDetails
- SuperHeader
- GlobalStyles
- PrimaryButton
- SectionTitle
- Section
- AccentSection
- ChainSelection
- CoinSelection
- AddressSelection
- SendAction
- Buttons
- Content
- Particles
- IconButton
- NotSupported
- InputSearch
- RouteGuard
- SearchBar
- FileInput
- GovBanner
- AuthForm
- DomainDetails
- Subnav
- ColumnFilter
- ImportExport
- selectFilter
- TaggedArrayInput
- FacetFilter
- ButtonSingleLine
- TextMultiline
- ButtonSelect
- BottomSheetBehavior
- InfoButton
- BulletPointX
- BulletPointCheck
- Title
- LoadingIcon
- SelectFilterControls
- CORInputForm
- SdnInputForm
- Navbar
- HomeRoute
- AuthRoute
- DocumentDetails
- DocumentStepper
- AddGame
- Auth
- Effectiveness
- Export
- PokemonType
- Moves
- Member
- MoveSelector
- Type
- Natures
- Move
- PokeInfo
- Share
- Badges
- Status
- UpdateSW
- About
- Builder
- Calculator
- Changelog
- Import
- Pokestats
- Report
- Rules
- Settings
- Tracker
- DarkThemeProvider
- NotificationHandler
- Background
- Indicator
- StyledButton
- StyledText
- Illustration
- OnboardingSlider
- FlexList
- AppLayout
- ScrollableList
- Visualization
- DataSearch
- Region
- App
- CompareApiLegend
- CompareApiBreadcrumbs
- CompareApiLink
- CompareApiCard
- ExploreApiBreadcrumbs
- ExploreApiLink
- ExploreApiSearch
- ExploreApiConst
- ApiLoader
- RefreshButton
- Listing
- PriceModal
- ConfirmationModal
- Transition
- AutoComplete
- useInput
- Avatar
- Badge
- Breadcrumbs
- ButtonDropdown
- ButtonGroup
- Capacity
- Checkbox
- Code
- Collapse
- CssBaseline
- GeistProvider
- Description
- Display
- Divider
- Dot
- Drawer
- useModal
- Fieldset
- Grid
- Image
- Keyboard
- Link
- Modal
- Note
- Page
- Pagination
- Popover
- Progress
- Radio
- Rating
- Slider
- Snippet
- Spacer
- Spinner
- Tabs
- Textarea
- Tooltip
- Tree
- useBodyScroll
- useClasses
- useClickAway
- useClipboard
- useCurrentState
- useKeyboard
- KeyMod
- KeyCode
- useMediaQuery
- useTabs
- useToasts
- User
- useTheme
- Themes
- GeistUIThemes
- useAllThemes
- CollapsableDialog
- Map
- IPForm
- IPMenu
- Container
- Parallax
- Nav
- SEO
- BlogNav
- ExtensionCard
- MenuComp
Other Related APIs
- react#useState
- @material-ui/core#Typography
- @material-ui/core#Box
- @material-ui/core/styles#makeStyles
- @material-ui/core/styles#useTheme
- react-i18next#useTranslation
- utils#formatTokenAmount
- components#CurrencyLogo
- components#QuestionHelper
- components#SettingsModal
- state/user/hooks#useUserSlippageTolerance
components#FormattedPriceImpact TypeScript Examples
The following examples show how to use
components#FormattedPriceImpact.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdvancedSwapDetails.tsx From interface-v2 with GNU General Public License v3.0 | 4 votes |
TradeSummary: React.FC<TradeSummaryProps> = ({
trade,
allowedSlippage,
}) => {
const [openSettingsModal, setOpenSettingsModal] = useState(false);
const { palette } = useTheme();
const { t } = useTranslation();
const { priceImpactWithoutFee, realizedLPFee } = computeTradePriceBreakdown(
trade,
);
const isExactIn = trade.tradeType === TradeType.EXACT_INPUT;
const slippageAdjustedAmounts = computeSlippageAdjustedAmounts(
trade,
allowedSlippage,
);
const classes = useStyles();
const tradeAmount = isExactIn ? trade.outputAmount : trade.inputAmount;
return (
<Box mt={1.5}>
{openSettingsModal && (
<SettingsModal
open={openSettingsModal}
onClose={() => setOpenSettingsModal(false)}
/>
)}
<Box className={classes.summaryRow}>
<Box display='flex' alignItems='center'>
<Typography variant='body2'>Slippage:</Typography>
<QuestionHelper text={t('slippageHelper')} />
</Box>
<Box
display='flex'
alignItems='center'
onClick={() => setOpenSettingsModal(true)}
style={{ cursor: 'pointer' }}
>
<Typography variant='body2' style={{ color: palette.primary.main }}>
{allowedSlippage / 100}%
</Typography>
<EditIcon style={{ marginLeft: 8 }} />
</Box>
</Box>
<Box className={classes.summaryRow}>
<Box display='flex' alignItems='center'>
<Typography variant='body2'>
{isExactIn ? t('minReceived') : t('maxSold')}:
</Typography>
<QuestionHelper text={t('txLimitHelper')} />
</Box>
<Box display='flex' alignItems='center'>
<Typography variant='body2'>
{formatTokenAmount(
slippageAdjustedAmounts[isExactIn ? Field.OUTPUT : Field.INPUT],
)}{' '}
{tradeAmount.currency.symbol}
</Typography>
<Box
width={16}
height={16}
ml={0.5}
borderRadius={8}
overflow='hidden'
>
<CurrencyLogo currency={tradeAmount.currency} size='16px' />
</Box>
</Box>
</Box>
<Box className={classes.summaryRow}>
<Box display='flex' alignItems='center'>
<Typography variant='body2'>Price Impact:</Typography>
<QuestionHelper text={t('priceImpactHelper')} />
</Box>
<FormattedPriceImpact priceImpact={priceImpactWithoutFee} />
</Box>
<Box className={classes.summaryRow}>
<Box display='flex' alignItems='center'>
<Typography variant='body2'>Liquidity Provider Fee:</Typography>
<QuestionHelper text={t('liquidityProviderFeeHelper')} />
</Box>
<Typography variant='body2'>
{formatTokenAmount(realizedLPFee)} {trade.inputAmount.currency.symbol}
</Typography>
</Box>
<Box className={classes.summaryRow}>
<Box display='flex' alignItems='center'>
<Typography variant='body2' style={{ marginRight: 4 }}>
Route
</Typography>
<QuestionHelper text={t('swapRouteHelper')} />
</Box>
<Box>
{trade.route.path.map((token, i, path) => {
const isLastItem: boolean = i === path.length - 1;
return (
<Box key={i} display='flex' alignItems='center'>
<Typography variant='body2'>
{token.symbol}{' '}
{// this is not to show the arrow at the end of the trade path
isLastItem ? '' : ' > '}
</Typography>
</Box>
);
})}
</Box>
</Box>
</Box>
);
}