@rango-dev/widget-embedded 0.22.4-next.5 → 0.22.4-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts +3 -0
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +2 -2
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +15 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +3 -0
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
- package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts +4 -0
- package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.d.ts +4 -0
- package/dist/components/HeaderButtons/HeaderButtons.d.ts.map +1 -0
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +5 -0
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +3 -2
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -1
- package/dist/components/HeaderButtons/index.d.ts +1 -1
- package/dist/components/HeaderButtons/index.d.ts.map +1 -1
- package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts +6 -0
- package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts +3 -0
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/Layout/Layout.types.d.ts +1 -0
- package/dist/components/Layout/Layout.types.d.ts.map +1 -1
- package/dist/components/Layout/PageContainer.d.ts +1 -0
- package/dist/components/Layout/PageContainer.d.ts.map +1 -1
- package/dist/components/Layout/ScrollableArea.d.ts +1 -0
- package/dist/components/Layout/ScrollableArea.d.ts.map +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +1 -0
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +14 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.styles.d.ts +3 -0
- package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +4 -0
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +1136 -25
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.types.d.ts +12 -7
- package/dist/components/Quote/Quote.types.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.styles.d.ts +5 -0
- package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -1
- package/dist/components/Quote/QuoteSummary.styles.d.ts +2 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -1
- package/dist/components/Quote/QuoteTrigger .d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +4 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +1 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +20 -10
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts +1 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +5 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +4 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts +1 -0
- package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +3 -0
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +5 -0
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +13 -0
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +1 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +2 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/index.d.ts +1 -1
- package/dist/components/SwapDetailsModal/index.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +17 -0
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts +4 -0
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
- package/dist/constants/navigationRoutes.d.ts +1 -0
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/quote.d.ts +5 -1
- package/dist/constants/quote.d.ts.map +1 -1
- package/dist/containers/App/App.styles.d.ts +1 -0
- package/dist/containers/App/App.styles.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +3 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +6 -3
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +5 -4
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -1
- package/dist/hooks/useFetch.d.ts +12 -0
- package/dist/hooks/useFetch.d.ts.map +1 -0
- package/dist/hooks/useFetchAllQuotes.d.ts +4 -0
- package/dist/hooks/useFetchAllQuotes.d.ts.map +1 -0
- package/dist/hooks/useFetchConfirmQuote.d.ts +4 -0
- package/dist/hooks/useFetchConfirmQuote.d.ts.map +1 -0
- package/dist/hooks/useSwapInput.d.ts +5 -5
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/Routes.d.ts +3 -0
- package/dist/pages/Routes.d.ts.map +1 -0
- package/dist/store/quote.d.ts +32 -10
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +0 -2
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/quote.d.ts +19 -1
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +12 -9
- package/dist/utils/quote.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +18 -18
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +3 -3
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/AppRoutes.tsx +5 -0
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +3 -3
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +21 -18
- package/src/components/HeaderButtons/{HomeButtons.tsx → HeaderButtons.tsx} +39 -26
- package/src/components/HeaderButtons/HeaderButtons.types.ts +3 -2
- package/src/components/HeaderButtons/index.ts +1 -1
- package/src/components/Layout/Layout.tsx +13 -1
- package/src/components/Layout/Layout.types.ts +1 -0
- package/src/components/Quote/Quote.styles.ts +133 -38
- package/src/components/Quote/Quote.tsx +68 -13
- package/src/components/Quote/Quote.types.ts +13 -7
- package/src/components/Quote/QuoteCostDetails.tsx +9 -4
- package/src/components/Quote/QuoteTrigger .tsx +7 -3
- package/src/components/QuoteSkeleton/QuoteSkeleton.tsx +2 -2
- package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +1 -1
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.styles.ts +10 -12
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.tsx +28 -9
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.types.ts +1 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +19 -19
- package/src/components/SwapDetails/SwapDetails.tsx +1 -1
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +1 -1
- package/src/components/SwapDetailsModal/index.ts +1 -1
- package/src/constants/navigationRoutes.ts +1 -0
- package/src/constants/quote.ts +17 -1
- package/src/containers/QuoteInfo/QuoteInfo.tsx +32 -7
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +6 -3
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +36 -20
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +76 -78
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +1 -1
- package/src/hooks/useFetch.ts +48 -0
- package/src/hooks/useFetchAllQuotes.ts +21 -0
- package/src/hooks/useFetchConfirmQuote.ts +21 -0
- package/src/hooks/useSwapInput.ts +59 -31
- package/src/pages/ConfirmSwapPage.tsx +12 -9
- package/src/pages/Home.tsx +25 -15
- package/src/pages/Routes.tsx +131 -0
- package/src/store/quote.ts +60 -22
- package/src/store/wallets.ts +0 -2
- package/src/types/quote.ts +27 -1
- package/src/utils/quote.ts +129 -67
- package/src/utils/swap.ts +37 -77
- package/src/utils/wallets.ts +10 -9
- package/dist/components/HeaderButtons/HomeButtons.d.ts +0 -4
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +0 -1
- package/dist/hooks/useFetchQuote.d.ts +0 -9
- package/dist/hooks/useFetchQuote.d.ts.map +0 -1
- package/src/hooks/useFetchQuote.ts +0 -38
|
@@ -44,7 +44,7 @@ const ImageComponent = (props: QuoteTriggerImagesProps) => {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export function QuoteTrigger(props: QuoteTriggerProps) {
|
|
47
|
-
const { quoteRef,
|
|
47
|
+
const { quoteRef, selected, setExpanded, steps, expanded, type } = props;
|
|
48
48
|
const tooltipContainer = getContainer();
|
|
49
49
|
const numberOfSteps = steps.length;
|
|
50
50
|
const blockchains = getUniqueBlockchains(steps);
|
|
@@ -65,9 +65,13 @@ export function QuoteTrigger(props: QuoteTriggerProps) {
|
|
|
65
65
|
|
|
66
66
|
return (
|
|
67
67
|
<Trigger
|
|
68
|
+
listItem={type === 'list-item'}
|
|
68
69
|
ref={(ref) => (quoteRef.current = ref)}
|
|
69
|
-
|
|
70
|
-
onClick={() =>
|
|
70
|
+
selected={selected}
|
|
71
|
+
onClick={(e) => {
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
setExpanded((prevState) => !prevState);
|
|
74
|
+
}}>
|
|
71
75
|
<div className={rowStyles()}>
|
|
72
76
|
<Typography variant="body" size="xsmall">
|
|
73
77
|
{i18n.t('Via:')}
|
|
@@ -8,11 +8,11 @@ import { QuoteSummarySkeleton } from './QuoteSummarySkeleton';
|
|
|
8
8
|
import { StepSkeleton } from './StepSkeleton';
|
|
9
9
|
|
|
10
10
|
export function QuoteSkeleton(props: PropTypes) {
|
|
11
|
-
const { type, expanded,
|
|
11
|
+
const { type, expanded, tagHidden = false } = props;
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<Container rounded={type !== 'basic'}>
|
|
15
|
-
<QuoteSummarySkeleton type={type}
|
|
15
|
+
<QuoteSummarySkeleton type={type} tagHidden={tagHidden} />
|
|
16
16
|
<Chains>
|
|
17
17
|
<Skeleton height={15} variant="rounded" />
|
|
18
18
|
</Chains>
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import { styled } from '@rango-dev/ui';
|
|
1
|
+
import { css, styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
display: 'flex',
|
|
5
|
-
justifyContent: 'space-between',
|
|
6
|
-
alignItems: 'center',
|
|
7
|
-
height: '22px',
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
export const Cost = styled('div', {
|
|
3
|
+
export const FlexContent = styled('div', {
|
|
11
4
|
display: 'flex',
|
|
12
5
|
});
|
|
13
6
|
|
|
14
7
|
export const BasicSummary = styled('div', {
|
|
15
|
-
padding: '$
|
|
8
|
+
padding: '$10 $0 $20',
|
|
16
9
|
});
|
|
17
10
|
|
|
18
11
|
export const Output = styled('div', {
|
|
19
|
-
padding: '$
|
|
12
|
+
padding: '$12 $0 $20 $0',
|
|
20
13
|
display: 'flex',
|
|
21
14
|
flexDirection: 'column',
|
|
22
15
|
});
|
|
@@ -25,7 +18,6 @@ export const OutputTokenInfo = styled('div', {
|
|
|
25
18
|
display: 'flex',
|
|
26
19
|
justifyContent: 'start',
|
|
27
20
|
alignItems: 'center',
|
|
28
|
-
paddingBottom: '$5',
|
|
29
21
|
});
|
|
30
22
|
|
|
31
23
|
export const QuoteSummary = styled('div', {
|
|
@@ -55,3 +47,9 @@ export const TokenAmountLabel = styled('div', {
|
|
|
55
47
|
});
|
|
56
48
|
|
|
57
49
|
export const SwapPreview = styled('div', { padding: '$15 $0 $15 $0' });
|
|
50
|
+
|
|
51
|
+
export const RowStyle = css({
|
|
52
|
+
display: 'flex',
|
|
53
|
+
justifyContent: 'space-between',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
});
|
|
@@ -3,21 +3,23 @@ import type { PropTypes } from './QuoteSummarySkeleton.types';
|
|
|
3
3
|
import { ChainToken, Divider, Skeleton } from '@rango-dev/ui';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
6
|
+
import { Line } from '../Quote/Quote.styles';
|
|
7
|
+
|
|
6
8
|
import {
|
|
7
9
|
BasicSummary,
|
|
8
|
-
|
|
9
|
-
CostAndTag,
|
|
10
|
+
FlexContent,
|
|
10
11
|
Output,
|
|
11
12
|
OutputTokenInfo,
|
|
12
13
|
QuoteSummary,
|
|
13
14
|
QuoteSummarySeparator,
|
|
15
|
+
RowStyle,
|
|
14
16
|
SwapPreview,
|
|
15
17
|
TokenAmount,
|
|
16
18
|
TokenAmountLabel,
|
|
17
19
|
} from './QuoteSummarySkeleton.styles';
|
|
18
20
|
|
|
19
21
|
export function QuoteSummarySkeleton(props: PropTypes) {
|
|
20
|
-
const { type,
|
|
22
|
+
const { type, tagHidden = true } = props;
|
|
21
23
|
const quotePreview = (
|
|
22
24
|
<QuoteSummary>
|
|
23
25
|
<TokenAmount>
|
|
@@ -32,19 +34,36 @@ export function QuoteSummarySkeleton(props: PropTypes) {
|
|
|
32
34
|
<Skeleton height={12} width={64} variant="rounded" />
|
|
33
35
|
</QuoteSummary>
|
|
34
36
|
);
|
|
37
|
+
const showAllRoutesSkeleton = type === 'basic' && !tagHidden;
|
|
35
38
|
|
|
36
39
|
return (
|
|
37
40
|
<div>
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
{!tagHidden && (
|
|
42
|
+
<>
|
|
43
|
+
<FlexContent>
|
|
44
|
+
<Skeleton width={65} height={14} variant="rounded" />
|
|
45
|
+
<Divider size={4} direction="horizontal" />
|
|
46
|
+
<Skeleton width={65} height={14} variant="rounded" />
|
|
47
|
+
<Divider size={4} direction="horizontal" />
|
|
48
|
+
<Skeleton width={65} height={14} variant="rounded" />
|
|
49
|
+
</FlexContent>
|
|
50
|
+
<Line />
|
|
51
|
+
{!showAllRoutesSkeleton && <Divider size={4} />}
|
|
52
|
+
</>
|
|
53
|
+
)}
|
|
54
|
+
<div className={RowStyle()}>
|
|
55
|
+
<FlexContent>
|
|
40
56
|
<Skeleton width={60} height={10} variant="rounded" />
|
|
41
57
|
<Divider size={4} direction="horizontal" />
|
|
42
58
|
<Skeleton width={60} height={10} variant="rounded" />
|
|
43
59
|
<Divider size={4} direction="horizontal" />
|
|
44
60
|
<Skeleton width={60} height={10} variant="rounded" />
|
|
45
|
-
</
|
|
46
|
-
{
|
|
47
|
-
|
|
61
|
+
</FlexContent>
|
|
62
|
+
{showAllRoutesSkeleton && (
|
|
63
|
+
<Skeleton width={100} height={22} variant="rounded" />
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
|
|
48
67
|
{type === 'basic' && (
|
|
49
68
|
<BasicSummary>
|
|
50
69
|
<Skeleton height={15} width={148} variant="rounded" />
|
|
@@ -57,7 +76,7 @@ export function QuoteSummarySkeleton(props: PropTypes) {
|
|
|
57
76
|
<Divider direction="horizontal" size={4} />
|
|
58
77
|
<Skeleton height={15} width={150} variant="rounded" />
|
|
59
78
|
</OutputTokenInfo>
|
|
60
|
-
<Divider size={
|
|
79
|
+
<Divider size={10} />
|
|
61
80
|
<Skeleton height={10} width={184} variant="rounded" />
|
|
62
81
|
</Output>
|
|
63
82
|
)}
|
|
@@ -25,6 +25,25 @@ export function makeAlerts(
|
|
|
25
25
|
title: '',
|
|
26
26
|
action: 'show-info',
|
|
27
27
|
};
|
|
28
|
+
if (error) {
|
|
29
|
+
alertInfo.alertType = 'error';
|
|
30
|
+
if (error.type === QuoteErrorType.BRIDGE_LIMIT) {
|
|
31
|
+
alertInfo.title = error.recommendation;
|
|
32
|
+
alertInfo.action = 'show-info';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (error.type === QuoteErrorType.INSUFFICIENT_SLIPPAGE) {
|
|
36
|
+
alertInfo.title = i18n.t({
|
|
37
|
+
id: 'You need to increase slippage to at least {minRequiredSlippage} for this route.',
|
|
38
|
+
values: {
|
|
39
|
+
minRequiredSlippage: error.minRequiredSlippage,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
alertInfo.action = 'change-settings';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return alertInfo;
|
|
46
|
+
}
|
|
28
47
|
if (warning) {
|
|
29
48
|
if (warning.type === QuoteWarningType.HIGH_VALUE_LOSS) {
|
|
30
49
|
const warningLevel = getPriceImpactLevel(warning.priceImpact);
|
|
@@ -51,24 +70,5 @@ export function makeAlerts(
|
|
|
51
70
|
}
|
|
52
71
|
return alertInfo;
|
|
53
72
|
}
|
|
54
|
-
if (error) {
|
|
55
|
-
alertInfo.alertType = 'error';
|
|
56
|
-
if (error.type === QuoteErrorType.BRIDGE_LIMIT) {
|
|
57
|
-
alertInfo.title = error.recommendation;
|
|
58
|
-
alertInfo.action = 'show-info';
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (error.type === QuoteErrorType.INSUFFICIENT_SLIPPAGE) {
|
|
62
|
-
alertInfo.title = i18n.t({
|
|
63
|
-
id: 'You need to increase slippage to at least {minRequiredSlippage} for this route.',
|
|
64
|
-
values: {
|
|
65
|
-
minRequiredSlippage: error.minRequiredSlippage,
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
alertInfo.action = 'change-settings';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return alertInfo;
|
|
72
|
-
}
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
@@ -163,7 +163,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
163
163
|
setNetworkModal: setModalState,
|
|
164
164
|
message: stepMessage,
|
|
165
165
|
blockchains: blockchains,
|
|
166
|
-
swappers
|
|
166
|
+
swappers,
|
|
167
167
|
});
|
|
168
168
|
const numberOfSteps = steps.length;
|
|
169
169
|
const [firstStep, lastStep] = [swap.steps[0], swap.steps[numberOfSteps - 1]];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { getSwapMessages } from '../../utils/swap';
|
|
2
2
|
import type { ModalState } from '../SwapDetailsModal';
|
|
3
3
|
import type { ConnectResult } from '@rango-dev/wallets-react';
|
|
4
|
+
import type { SwapperMeta } from 'rango-sdk';
|
|
4
5
|
import type {
|
|
5
6
|
BlockchainMeta,
|
|
6
7
|
PendingSwap,
|
|
7
8
|
PendingSwapNetworkStatus,
|
|
8
9
|
PendingSwapStep,
|
|
9
|
-
SwapperMeta,
|
|
10
10
|
} from 'rango-types';
|
|
11
11
|
|
|
12
12
|
export interface SwapAlertsProps extends WaningAlertsProps {
|
package/src/constants/quote.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SwapFee } from 'rango-sdk';
|
|
1
|
+
import type { PreferenceType, SwapFee, TagValue } from 'rango-sdk';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
|
|
@@ -21,3 +21,19 @@ export type FeesGroup = {
|
|
|
21
21
|
payable: { [key in NameOfFees]?: SwapFee[] };
|
|
22
22
|
nonePayable: { [key in NameOfFees]?: SwapFee[] };
|
|
23
23
|
};
|
|
24
|
+
|
|
25
|
+
export const ROUTE_SORTING_STRATEGY: { [key in PreferenceType]: string } = {
|
|
26
|
+
SPEED: i18n.t('Fastest Transfer'),
|
|
27
|
+
NET_OUTPUT: i18n.t('Maximum Return'),
|
|
28
|
+
FEE: i18n.t('Lowest Fee'),
|
|
29
|
+
PRICE: i18n.t('Maximum Output'),
|
|
30
|
+
SMART: i18n.t('Smart Routing'),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const HIGH_PRIORITY_TAGS: TagValue[] = [
|
|
34
|
+
'RECOMMENDED',
|
|
35
|
+
'CENTRALIZED',
|
|
36
|
+
'LOWEST_FEE',
|
|
37
|
+
'FASTEST',
|
|
38
|
+
'HIGH_IMPACT',
|
|
39
|
+
];
|
|
@@ -1,43 +1,68 @@
|
|
|
1
1
|
import type { PropTypes } from './QuoteInfo.types';
|
|
2
2
|
|
|
3
|
+
import BigNumber from 'bignumber.js';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
|
|
5
6
|
import { Quote } from '../../components/Quote';
|
|
6
7
|
import { QuoteSkeleton } from '../../components/QuoteSkeleton';
|
|
7
8
|
import { useQuoteStore } from '../../store/quote';
|
|
8
9
|
import { QuoteErrorType } from '../../types';
|
|
10
|
+
import { getQuoteToTokenUsdPrice } from '../../utils/quote';
|
|
11
|
+
import { calcOutputUsdValue } from '../../utils/swap';
|
|
9
12
|
|
|
10
13
|
import { QuoteContainer } from './QuoteInfo.styles';
|
|
11
14
|
|
|
12
15
|
export function QuoteInfo(props: PropTypes) {
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const {
|
|
17
|
+
quote,
|
|
18
|
+
type,
|
|
19
|
+
loading,
|
|
20
|
+
error,
|
|
21
|
+
warning,
|
|
22
|
+
expanded = false,
|
|
23
|
+
tagHidden,
|
|
24
|
+
onClick,
|
|
25
|
+
selected,
|
|
26
|
+
onClickAllRoutes,
|
|
27
|
+
} = props;
|
|
28
|
+
const { inputAmount, inputUsdValue, toToken } = useQuoteStore();
|
|
29
|
+
|
|
30
|
+
const outputAmount = !!quote?.outputAmount
|
|
31
|
+
? new BigNumber(quote?.outputAmount)
|
|
32
|
+
: null;
|
|
33
|
+
const outputUsdValue = !!quote?.outputAmount
|
|
34
|
+
? calcOutputUsdValue(
|
|
35
|
+
quote?.outputAmount,
|
|
36
|
+
getQuoteToTokenUsdPrice(quote) || toToken?.usdPrice
|
|
37
|
+
)
|
|
38
|
+
: null;
|
|
16
39
|
|
|
17
40
|
const noResult =
|
|
18
41
|
error &&
|
|
19
42
|
(error.type === QuoteErrorType.NO_RESULT ||
|
|
20
43
|
error.type === QuoteErrorType.REQUEST_FAILED);
|
|
21
44
|
|
|
22
|
-
const showQuote = !noResult && quote &&
|
|
45
|
+
const showQuote = !noResult && quote && !loading;
|
|
23
46
|
|
|
24
47
|
if (loading) {
|
|
25
48
|
return (
|
|
26
49
|
<QuoteContainer>
|
|
27
|
-
<QuoteSkeleton type={type} expanded={expanded} />
|
|
50
|
+
<QuoteSkeleton tagHidden={tagHidden} type={type} expanded={expanded} />
|
|
28
51
|
</QuoteContainer>
|
|
29
52
|
);
|
|
30
53
|
}
|
|
31
54
|
|
|
32
55
|
return showQuote ? (
|
|
33
|
-
<QuoteContainer>
|
|
56
|
+
<QuoteContainer onClick={() => onClick?.(quote)}>
|
|
34
57
|
<Quote
|
|
35
58
|
quote={quote}
|
|
36
59
|
error={error}
|
|
37
60
|
warning={warning}
|
|
61
|
+
tagHidden={tagHidden}
|
|
62
|
+
selected={selected}
|
|
38
63
|
type={type}
|
|
39
64
|
expanded={expanded}
|
|
40
|
-
|
|
65
|
+
onClickAllRoutes={onClickAllRoutes}
|
|
41
66
|
input={{
|
|
42
67
|
value: inputAmount,
|
|
43
68
|
usdValue: inputUsdValue?.toString() ?? '',
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { QuoteProps } from '../../components/Quote/Quote.types';
|
|
2
|
-
import type { QuoteError, QuoteWarning } from '../../types';
|
|
3
|
-
import type { BestRouteResponse } from 'rango-sdk';
|
|
2
|
+
import type { QuoteError, QuoteWarning, SelectedQuote } from '../../types';
|
|
4
3
|
|
|
5
4
|
export type PropTypes = {
|
|
6
|
-
quote:
|
|
5
|
+
quote: SelectedQuote | null;
|
|
7
6
|
type: QuoteProps['type'];
|
|
7
|
+
onClick?: (quote: SelectedQuote) => void;
|
|
8
8
|
loading: boolean;
|
|
9
|
+
tagHidden?: boolean;
|
|
9
10
|
error: QuoteError | null;
|
|
10
11
|
warning: QuoteWarning | null;
|
|
11
12
|
autoScrollOnExpanding?: boolean;
|
|
12
13
|
expanded?: boolean;
|
|
14
|
+
onClickAllRoutes?: () => void;
|
|
15
|
+
selected?: boolean;
|
|
13
16
|
};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { ConfirmSwapFetchResult } from './useConfirmSwap.types';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
ConfirmSwapWarnings,
|
|
4
|
+
QuoteErrorResponse,
|
|
5
|
+
QuoteResponse,
|
|
6
|
+
SelectedQuote,
|
|
7
|
+
Wallet,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
import type { BlockchainMeta, SwapResult, Token } from 'rango-sdk';
|
|
4
10
|
|
|
5
11
|
import { errorMessages } from '../../constants/errors';
|
|
6
12
|
import { QuoteErrorType, QuoteUpdateType } from '../../types';
|
|
@@ -26,8 +32,8 @@ import {
|
|
|
26
32
|
/**
|
|
27
33
|
* A request can be successful but in body of the response, it can be some case which is considered as failed.
|
|
28
34
|
*/
|
|
29
|
-
export function throwErrorIfResponseIsNotValid(response:
|
|
30
|
-
if (!response.
|
|
35
|
+
export function throwErrorIfResponseIsNotValid(response: QuoteResponse) {
|
|
36
|
+
if (!response.swaps) {
|
|
31
37
|
throw new Error(errorMessages().noResultError.title, {
|
|
32
38
|
cause: {
|
|
33
39
|
type: QuoteErrorType.NO_RESULT,
|
|
@@ -35,40 +41,49 @@ export function throwErrorIfResponseIsNotValid(response: BestRouteResponse) {
|
|
|
35
41
|
},
|
|
36
42
|
});
|
|
37
43
|
}
|
|
38
|
-
const
|
|
44
|
+
const quoteError = getQuoteError(response.swaps);
|
|
45
|
+
if (quoteError) {
|
|
46
|
+
throw new Error(quoteError.message, {
|
|
47
|
+
cause: quoteError.options,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function getQuoteError(swaps: SwapResult[]): QuoteErrorResponse | null {
|
|
53
|
+
const limitError = hasLimitError(swaps);
|
|
39
54
|
if (limitError) {
|
|
40
55
|
const { swap, recommendation, fromAmountRangeError } =
|
|
41
|
-
getLimitErrorMessage(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
getLimitErrorMessage(swaps);
|
|
57
|
+
return {
|
|
58
|
+
message: 'bridge limit error',
|
|
59
|
+
options: {
|
|
45
60
|
type: QuoteErrorType.BRIDGE_LIMIT,
|
|
46
|
-
swap
|
|
61
|
+
swap,
|
|
47
62
|
recommendation,
|
|
48
63
|
fromAmountRangeError,
|
|
49
64
|
},
|
|
50
|
-
}
|
|
65
|
+
};
|
|
51
66
|
}
|
|
52
67
|
|
|
53
|
-
const recommendedSlippages = checkSlippageErrors(
|
|
68
|
+
const recommendedSlippages = checkSlippageErrors(swaps);
|
|
54
69
|
|
|
55
70
|
if (recommendedSlippages) {
|
|
56
|
-
const minRequiredSlippage = getMinRequiredSlippage(
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
const minRequiredSlippage = getMinRequiredSlippage(swaps);
|
|
72
|
+
return {
|
|
73
|
+
message: '',
|
|
74
|
+
options: {
|
|
59
75
|
type: QuoteErrorType.INSUFFICIENT_SLIPPAGE,
|
|
60
76
|
recommendedSlippages,
|
|
61
77
|
minRequiredSlippage,
|
|
62
78
|
},
|
|
63
|
-
}
|
|
79
|
+
};
|
|
64
80
|
}
|
|
65
|
-
|
|
66
|
-
return response;
|
|
81
|
+
return null;
|
|
67
82
|
}
|
|
68
83
|
|
|
69
84
|
export function generateWarnings(
|
|
70
|
-
previousQuote:
|
|
71
|
-
currentQuote:
|
|
85
|
+
previousQuote: SelectedQuote | undefined,
|
|
86
|
+
currentQuote: SelectedQuote,
|
|
72
87
|
params: {
|
|
73
88
|
fromToken: Token;
|
|
74
89
|
toToken: Token;
|
|
@@ -132,6 +147,7 @@ export function generateWarnings(
|
|
|
132
147
|
params.selectedWallets,
|
|
133
148
|
params.meta.blockchains
|
|
134
149
|
);
|
|
150
|
+
|
|
135
151
|
const enoughBalance = balanceWarnings.length === 0;
|
|
136
152
|
|
|
137
153
|
if (!enoughBalance) {
|