diff --git a/src/assets/translations/en/main.json b/src/assets/translations/en/main.json index 60f38fdc016..0a2e5aab12e 100644 --- a/src/assets/translations/en/main.json +++ b/src/assets/translations/en/main.json @@ -2226,8 +2226,7 @@ "yourLoans": "Your Loans", "emptyTitle": "The Land of Zero Loans!", "emptyBody": "It appears you don't have any loans at the moment. Is this financial zen or just a break before your next big lending adventure? Either way, enjoy the calm!" - }, - "unsafeBorrow": "This borrow has high slippage (%{slippagePercentage}%). Proceed with caution." + } }, "foxDiscounts": { "currentFoxPower": "Your FOX Power", @@ -2332,6 +2331,14 @@ } } }, + "warningAcknowledgement": { + "understand": "I understand", + "attention": "Attention!", + "highSlippageDeposit": "This deposit has high slippage (%{slippagePercentage}%). Proceed with caution.", + "highSlippageBorrow": "This borrow has high slippage (%{slippagePercentage}%). Proceed with caution.", + "highSlippageTrade": "This trade is impacted by price movement (%{slippagePercentage}%). Proceed with caution.", + "unsafeTrade": "This trade may be unsafe or below the recommended minimum size, proceed with caution." + }, "watchlist": { "empty": { "title": "Start building your watchlist", diff --git a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/MultiHopTradeConfirm.tsx b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/MultiHopTradeConfirm.tsx index 4b6452f1cd1..88b85c4c015 100644 --- a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/MultiHopTradeConfirm.tsx +++ b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/MultiHopTradeConfirm.tsx @@ -1,11 +1,18 @@ import { Card, CardBody, CardHeader, Heading, useDisclosure, usePrevious } from '@chakra-ui/react' -import { memo, useCallback, useEffect, useMemo } from 'react' +import { memo, useCallback, useEffect, useMemo, useState } from 'react' +import { useTranslate } from 'react-polyglot' import { useHistory } from 'react-router-dom' import { WithBackButton } from 'components/MultiHopTrade/components/WithBackButton' +import { usePriceImpact } from 'components/MultiHopTrade/hooks/quoteValidation/usePriceImpact' import { TradeSlideTransition } from 'components/MultiHopTrade/TradeSlideTransition' import { TradeRoutePaths } from 'components/MultiHopTrade/types' import { Text } from 'components/Text' -import { selectTradeExecutionState } from 'state/slices/tradeQuoteSlice/selectors' +import { WarningAcknowledgement } from 'components/WarningAcknowledgement/WarningAcknowledgement' +import { bnOrZero } from 'lib/bignumber/bignumber' +import { + selectActiveQuote, + selectTradeExecutionState, +} from 'state/slices/tradeQuoteSlice/selectors' import { tradeQuoteSlice } from 'state/slices/tradeQuoteSlice/tradeQuoteSlice' import { TradeExecutionState } from 'state/slices/tradeQuoteSlice/types' import { useAppDispatch, useAppSelector } from 'state/store' @@ -22,10 +29,15 @@ const useDisclosureProps = { export const MultiHopTradeConfirm = memo(() => { const dispatch = useAppDispatch() + const translate = useTranslate() const tradeExecutionState = useAppSelector(selectTradeExecutionState) const previousTradeExecutionState = usePrevious(tradeExecutionState) const history = useHistory() + const [shouldShowWarningAcknowledgement, setShouldShowWarningAcknowledgement] = useState(false) + const activeQuote = useAppSelector(selectActiveQuote) + const { isModeratePriceImpact, priceImpactPercentage } = usePriceImpact(activeQuote) + const { isLoading } = useIsApprovalInitiallyNeeded() useEffect(() => { @@ -65,6 +77,18 @@ export const MultiHopTradeConfirm = memo(() => { [tradeExecutionState], ) + const handleTradeConfirm = useCallback(() => { + dispatch(tradeQuoteSlice.actions.confirmTrade()) + }, [dispatch]) + + const handleSubmit = useCallback(() => { + if (isModeratePriceImpact) { + setShouldShowWarningAcknowledgement(true) + } else { + handleTradeConfirm() + } + }, [handleTradeConfirm, isModeratePriceImpact]) + return ( { variant='dashboard' maxWidth='500px' > - - - - - - - - {isTradeComplete ? ( - - - - ) : ( - <> - - - -