Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use WarningAcknowledgement component #6647

Merged
merged 58 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4513c3b
Merge branch 'main' into develop
woodenfurniture Apr 2, 2024
bd20bf0
feat: regenerate asset data 04/02/2024 (#6620)
gomesalexandre Apr 2, 2024
88ab918
feat: disable sym deposits after RUNE (#6622)
gomesalexandre Apr 2, 2024
b1e3490
fix: don't bork asset generation on idle API failures (#6619)
gomesalexandre Apr 2, 2024
ca37e0e
feat: collect 0x trade surplus (#6625)
0xApotheosis Apr 3, 2024
76119c8
feat: bottom sheet dialog (#6623)
reallybeard Apr 3, 2024
faa414f
chore: use unchained proxy endpoints over nownodes proxy (#6606)
kaladinlight Apr 3, 2024
f1f0d1b
feat: use proxy validation endpoint (#6626)
0xApotheosis Apr 4, 2024
ced5a38
feat: many migrations (#6631)
gomesalexandre Apr 4, 2024
939320c
fix: remove portal on account dropdown (#6635)
reallybeard Apr 4, 2024
4844a2c
feat: cow affiliate fees (#6621)
gomesalexandre Apr 4, 2024
e038343
chore: update app translations (#6638)
firebomb1 Apr 4, 2024
8967dcd
feat: cow quote/unsigned order build cleanup (#6639)
gomesalexandre Apr 5, 2024
340c9fc
fix: deep merge opportunities accounts (#6627)
gomesalexandre Apr 5, 2024
43db1bb
feat: regenerate asset data 04/04/2024 (#6636)
gomesalexandre Apr 5, 2024
88b3612
fix: defi aggregated opportunities uniqBy id first (#6628)
gomesalexandre Apr 5, 2024
62d6160
feat: lending loan summary repayment lock (#6642)
gomesalexandre Apr 5, 2024
ef740bb
fix: mobile dashboard routing (#6637)
gomesalexandre Apr 5, 2024
0bfb6ba
feat: thorchain lp disable max deposits (#6645)
gomesalexandre Apr 5, 2024
0da4bb9
feat: uni-v2 pools static generation (#6629)
gomesalexandre Apr 7, 2024
43fb92c
Merge branch 'main' into develop
0xApotheosis Apr 8, 2024
60aab31
feat: regenerate asset data 04/08/2024 (#6648)
gomesalexandre Apr 8, 2024
d3f4241
feat: thorchain LP charts (#6624)
gomesalexandre Apr 9, 2024
aa484a3
feat: tag foxy as expired opportunity (#6651)
gomesalexandre Apr 9, 2024
ddec22a
fix: empty my position pools page (#6656)
reallybeard Apr 9, 2024
8e3487b
feat: add first pass WarningAcknowledgement component
0xApotheosis Apr 8, 2024
a5bc377
chore: use translations
0xApotheosis Apr 9, 2024
a77d372
chore: wire up savers deposit
0xApotheosis Apr 9, 2024
9651bcc
chore: tidy
0xApotheosis Apr 9, 2024
19582f0
feat: use warningAcknowledgement in trade quote confirm
0xApotheosis Apr 9, 2024
725e53c
feat: use warningAcknowledgement in trade quote confirm
0xApotheosis Apr 10, 2024
caebbe5
Merge branch 'develop' into warning-ack
0xApotheosis Apr 11, 2024
56eb92a
feat: use warningAcknowledgement in trade lp deposit
0xApotheosis Apr 11, 2024
34dfc9a
fix: trade quote input warning logic
0xApotheosis Apr 11, 2024
a877d68
chore: use dimmed background
0xApotheosis Apr 11, 2024
56b0b15
chore: component a little closer to mock
0xApotheosis Apr 11, 2024
561a41d
chore: component tweaks
0xApotheosis Apr 11, 2024
9e709d5
Merge branch 'develop' into warning-ack
0xApotheosis Apr 12, 2024
d8267dc
chore: style fixes
0xApotheosis Apr 12, 2024
2a1dae0
chore: use cancel translation
0xApotheosis Apr 12, 2024
4eb4138
fix: trade confirm warning
0xApotheosis Apr 12, 2024
da141c3
Update WarningAcknowledgement.tsx
reallybeard Apr 12, 2024
98517f8
Update WarningAcknowledgement.tsx
reallybeard Apr 12, 2024
d0c6e85
Merge branch 'develop' into warning-ack
gomesalexandre Apr 12, 2024
d169ae2
feat: chart styles and loading state (#6655)
reallybeard Apr 12, 2024
ff32121
fix: thor token repayments (#6676)
gomesalexandre Apr 12, 2024
ead8c2e
fix: don't render back button on modals initial routes (#6675)
gomesalexandre Apr 14, 2024
05c292f
chore: use translations & constants
0xApotheosis Apr 15, 2024
916ecb4
chore: address review feedback
0xApotheosis Apr 15, 2024
508d80f
Merge branch 'develop' into warning-ack
0xApotheosis Apr 16, 2024
66420d8
fix: unbork trade widget size
0xApotheosis Apr 16, 2024
c281c20
fix: show minimum trade amount when unsafe
0xApotheosis Apr 16, 2024
68d0ff7
fix: trade confirm width
0xApotheosis Apr 16, 2024
d1295c2
Merge branch 'develop' into warning-ack
gomesalexandre Apr 16, 2024
a4d7407
chore: trigger CI
gomesalexandre Apr 16, 2024
08201d0
fix: typo
gomesalexandre Apr 16, 2024
a80e329
chore: extract motion style to constant
0xApotheosis Apr 16, 2024
ab30e3c
fix: add no min fallback message
0xApotheosis Apr 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/assets/translations/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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(() => {
Expand Down Expand Up @@ -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 (
<TradeSlideTransition>
<Card
Expand All @@ -74,38 +98,47 @@ export const MultiHopTradeConfirm = memo(() => {
variant='dashboard'
maxWidth='500px'
>
<CardHeader px={6} pt={4}>
<WithBackButton onBack={handleBack}>
<Heading textAlign='center' fontSize='md'>
<Text
translation={
[TradeExecutionState.Initializing, TradeExecutionState.Previewing].includes(
tradeExecutionState,
)
? 'trade.confirmDetails'
: 'trade.trade'
}
/>
</Heading>
</WithBackButton>
</CardHeader>
{isTradeComplete ? (
<TradeSuccessTemp handleBack={handleBack}>
<Hops isFirstHopOpen isSecondHopOpen />
</TradeSuccessTemp>
) : (
<>
<CardBody py={0} px={0}>
<Hops
isFirstHopOpen={isFirstHopOpen}
isSecondHopOpen={isSecondHopOpen}
onToggleFirstHop={onToggleFirstHop}
onToggleSecondHop={onToggleSecondHop}
/>
</CardBody>
<Footer />
</>
)}
<WarningAcknowledgement
message={translate('warningAcknowledgement.highSlippageTrade', {
slippagePercentage: bnOrZero(priceImpactPercentage).toFixed(2).toString(),
})}
onAcknowledge={handleTradeConfirm}
shouldShowWarningAcknowledgement={shouldShowWarningAcknowledgement}
setShouldShowWarningAcknowledgement={setShouldShowWarningAcknowledgement}
>
<CardHeader px={6} pt={4}>
<WithBackButton onBack={handleBack}>
<Heading textAlign='center' fontSize='md'>
<Text
translation={
[TradeExecutionState.Initializing, TradeExecutionState.Previewing].includes(
tradeExecutionState,
)
? 'trade.confirmDetails'
: 'trade.trade'
}
/>
</Heading>
</WithBackButton>
</CardHeader>
{isTradeComplete ? (
<TradeSuccessTemp handleBack={handleBack}>
<Hops isFirstHopOpen isSecondHopOpen />
</TradeSuccessTemp>
) : (
<>
<CardBody py={0} px={0}>
<Hops
isFirstHopOpen={isFirstHopOpen}
isSecondHopOpen={isSecondHopOpen}
onToggleFirstHop={onToggleFirstHop}
onToggleSecondHop={onToggleSecondHop}
/>
</CardBody>
<Footer handleSubmit={handleSubmit} />
</>
)}
</WarningAcknowledgement>
</Card>
</TradeSlideTransition>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,34 @@ import {
Stack,
} from '@chakra-ui/react'
import { SwapperName } from '@shapeshiftoss/swapper'
import { useCallback, useMemo } from 'react'
import type { FC } from 'react'
import { useMemo } from 'react'
import { useTranslate } from 'react-polyglot'
import { usePriceImpact } from 'components/MultiHopTrade/hooks/quoteValidation/usePriceImpact'
import { chainSupportsTxHistory } from 'components/MultiHopTrade/utils'
import { Text } from 'components/Text'
import type { TextPropTypes } from 'components/Text/Text'
import { bnOrZero } from 'lib/bignumber/bignumber'
import {
selectActiveQuote,
selectActiveSwapperName,
selectLastHopBuyAsset,
selectQuoteSellAmountUserCurrency,
selectTotalNetworkFeeUserCurrencyPrecision,
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'
import { useAppSelector } from 'state/store'

export const Footer = () => {
type FooterProps = {
handleSubmit: () => void
}

export const Footer: FC<FooterProps> = ({ handleSubmit }) => {
const translate = useTranslate()
const dispatch = useAppDispatch()
const swapperName = useAppSelector(selectActiveSwapperName)
const activeQuote = useAppSelector(selectActiveQuote)
const lastHopBuyAsset = useAppSelector(selectLastHopBuyAsset)
const tradeExecutionState = useAppSelector(selectTradeExecutionState)
const networkFeeUserCurrency = useAppSelector(selectTotalNetworkFeeUserCurrencyPrecision)
const sellAmountBeforeFeesUserCurrency = useAppSelector(selectQuoteSellAmountUserCurrency)
const { isModeratePriceImpact } = usePriceImpact(activeQuote)

const handleConfirm = useCallback(() => {
dispatch(tradeQuoteSlice.actions.confirmTrade())
}, [dispatch])

const networkFeeToTradeRatioPercentage = useMemo(
() =>
Expand Down Expand Up @@ -140,13 +135,13 @@ export const Footer = () => {
</Alert>
)}
<Button
colorScheme={isModeratePriceImpact ? 'red' : 'blue'}
colorScheme={'blue'}
size='lg'
width='full'
onClick={handleConfirm}
onClick={handleSubmit}
isLoading={isLoading}
>
<Text translation={isModeratePriceImpact ? 'trade.tradeAnyway' : 'trade.confirmAndTrade'} />
<Text translation={'trade.confirmAndTrade'} />
</Button>
</CardFooter>
) : null
Expand Down
Loading
Loading