@rango-dev/widget-embedded 0.22.4-next.0 → 0.22.4-next.10
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/QueueManager.d.ts.map +1 -1
- 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.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/languages.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/containers/Wallets/Wallets.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/hooks/useWalletList.d.ts +1 -0
- package/dist/hooks/useWalletList.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/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/Routes.d.ts +3 -0
- package/dist/pages/Routes.d.ts.map +1 -0
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +2 -2
- package/dist/store/app.d.ts +2 -2
- 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/settings.d.ts +2 -3
- package/dist/utils/settings.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 +4 -3
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/QueueManager.tsx +0 -3
- package/src/components/AppRoutes.tsx +5 -0
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +3 -3
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +22 -19
- package/src/components/ConfirmWalletsModal/WalletList.tsx +24 -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 +77 -18
- 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/languages.ts +2 -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/containers/Wallets/Wallets.tsx +5 -11
- 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/hooks/useWalletList.ts +5 -3
- package/src/pages/ConfirmSwapPage.tsx +12 -9
- package/src/pages/Home.tsx +25 -15
- package/src/pages/LiquiditySourcePage.tsx +3 -5
- package/src/pages/Routes.tsx +131 -0
- package/src/pages/SettingsPage.tsx +11 -13
- package/src/pages/WalletsPage.tsx +24 -18
- 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/settings.ts +2 -4
- package/src/utils/swap.ts +37 -77
- package/src/utils/wallets.ts +14 -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
|
@@ -35,19 +35,29 @@ import {
|
|
|
35
35
|
getSwapperDisplayName,
|
|
36
36
|
} from '../../utils/meta';
|
|
37
37
|
import { formatTooltipNumbers, numberToString } from '../../utils/numbers';
|
|
38
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
getPriceImpact,
|
|
40
|
+
getPriceImpactLevel,
|
|
41
|
+
getRouteTagColor,
|
|
42
|
+
sortTags,
|
|
43
|
+
} from '../../utils/quote';
|
|
39
44
|
|
|
40
45
|
import {
|
|
46
|
+
AllRoutesButton,
|
|
41
47
|
BasicInfoOutput,
|
|
42
48
|
basicInfoStyles,
|
|
43
49
|
ContainerInfoOutput,
|
|
44
50
|
Content,
|
|
45
51
|
FrameIcon,
|
|
46
52
|
HorizontalSeparator,
|
|
53
|
+
Line,
|
|
47
54
|
QuoteContainer,
|
|
48
55
|
stepsDetailsStyles,
|
|
49
56
|
SummaryContainer,
|
|
57
|
+
summaryHeaderStyles,
|
|
50
58
|
summaryStyles,
|
|
59
|
+
Tag,
|
|
60
|
+
TagContainer,
|
|
51
61
|
} from './Quote.styles';
|
|
52
62
|
import { QuoteCostDetails } from './QuoteCostDetails';
|
|
53
63
|
import { QuoteSummary } from './QuoteSummary';
|
|
@@ -61,11 +71,12 @@ export function Quote(props: QuoteProps) {
|
|
|
61
71
|
error,
|
|
62
72
|
warning,
|
|
63
73
|
type,
|
|
64
|
-
|
|
74
|
+
selected = false,
|
|
75
|
+
tagHidden = true,
|
|
76
|
+
onClickAllRoutes,
|
|
65
77
|
} = props;
|
|
66
78
|
const blockchains = useAppStore().blockchains();
|
|
67
79
|
const swappers = useAppStore().swappers();
|
|
68
|
-
|
|
69
80
|
const [expanded, setExpanded] = useState(props.expanded);
|
|
70
81
|
const quoteRef = useRef<HTMLButtonElement | null>(null);
|
|
71
82
|
const roundedInput = numberToString(
|
|
@@ -111,6 +122,14 @@ export function Quote(props: QuoteProps) {
|
|
|
111
122
|
stepState = 'warning';
|
|
112
123
|
}
|
|
113
124
|
|
|
125
|
+
let alertTitle = stepHasError
|
|
126
|
+
? i18n.t('Slippage Error')
|
|
127
|
+
: i18n.t('Slippage Warning');
|
|
128
|
+
|
|
129
|
+
if (error?.type === QuoteErrorType.BRIDGE_LIMIT) {
|
|
130
|
+
alertTitle = error?.recommendation;
|
|
131
|
+
}
|
|
132
|
+
|
|
114
133
|
return {
|
|
115
134
|
swapper: {
|
|
116
135
|
displayName: getSwapperDisplayName(swap.swapperId, swappers),
|
|
@@ -184,12 +203,9 @@ export function Quote(props: QuoteProps) {
|
|
|
184
203
|
stepHasError || stepHasWarning ? (
|
|
185
204
|
<FooterStepAlarm>
|
|
186
205
|
<Alert
|
|
206
|
+
variant="alarm"
|
|
187
207
|
type={stepHasError ? 'error' : 'warning'}
|
|
188
|
-
title={
|
|
189
|
-
error?.type === QuoteErrorType.BRIDGE_LIMIT
|
|
190
|
-
? error?.recommendation
|
|
191
|
-
: i18n.t(`Slippage ${stepHasError ? 'Error' : 'Warning'}:`)
|
|
192
|
-
}
|
|
208
|
+
title={alertTitle}
|
|
193
209
|
footer={
|
|
194
210
|
<FooterAlert>
|
|
195
211
|
{error?.type === QuoteErrorType.BRIDGE_LIMIT && (
|
|
@@ -258,18 +274,59 @@ export function Quote(props: QuoteProps) {
|
|
|
258
274
|
};
|
|
259
275
|
});
|
|
260
276
|
};
|
|
261
|
-
const steps = getQuoteSteps(quote
|
|
277
|
+
const steps = getQuoteSteps(quote?.swaps ?? []);
|
|
278
|
+
|
|
262
279
|
const numberOfSteps = steps.length;
|
|
263
|
-
const
|
|
280
|
+
const container = getContainer();
|
|
281
|
+
const sortedQuoteTags = sortTags(props.quote.tags || []);
|
|
282
|
+
const showAllRoutesButton = !!onClickAllRoutes;
|
|
264
283
|
|
|
265
284
|
return (
|
|
266
285
|
<>
|
|
267
286
|
<SummaryContainer
|
|
268
|
-
|
|
287
|
+
selected={selected}
|
|
269
288
|
listItem={type === 'list-item'}
|
|
270
289
|
basic={type === 'basic'}>
|
|
271
290
|
<div className={summaryStyles()}>
|
|
272
|
-
|
|
291
|
+
{!tagHidden && sortedQuoteTags.length ? (
|
|
292
|
+
<>
|
|
293
|
+
<TagContainer>
|
|
294
|
+
{sortedQuoteTags.map((tag, index) => {
|
|
295
|
+
const key = `${tag.value}_${index}`;
|
|
296
|
+
return (
|
|
297
|
+
<>
|
|
298
|
+
<Tag
|
|
299
|
+
style={{ color: getRouteTagColor(tag.value) }}
|
|
300
|
+
key={key}>
|
|
301
|
+
{tag.label}
|
|
302
|
+
</Tag>
|
|
303
|
+
<Divider size={4} direction="horizontal" />
|
|
304
|
+
</>
|
|
305
|
+
);
|
|
306
|
+
})}
|
|
307
|
+
</TagContainer>
|
|
308
|
+
<Line />
|
|
309
|
+
{!showAllRoutesButton && <Divider size={4} />}
|
|
310
|
+
</>
|
|
311
|
+
) : null}
|
|
312
|
+
<div id="portal-root" className={summaryHeaderStyles()}>
|
|
313
|
+
<QuoteCostDetails steps={numberOfSteps} quote={quote} />
|
|
314
|
+
|
|
315
|
+
{showAllRoutesButton && (
|
|
316
|
+
<AllRoutesButton
|
|
317
|
+
onClick={(e) => {
|
|
318
|
+
e.stopPropagation();
|
|
319
|
+
onClickAllRoutes();
|
|
320
|
+
}}
|
|
321
|
+
size="xxsmall"
|
|
322
|
+
type="secondary"
|
|
323
|
+
variant="default">
|
|
324
|
+
<Typography color="secondary" variant="label" size="medium">
|
|
325
|
+
{i18n.t('See All Routes')}
|
|
326
|
+
</Typography>
|
|
327
|
+
</AllRoutesButton>
|
|
328
|
+
)}
|
|
329
|
+
</div>
|
|
273
330
|
{type === 'basic' && (
|
|
274
331
|
<div className={basicInfoStyles()}>
|
|
275
332
|
<FrameIcon>
|
|
@@ -281,7 +338,7 @@ export function Quote(props: QuoteProps) {
|
|
|
281
338
|
</BasicInfoOutput>
|
|
282
339
|
<Tooltip
|
|
283
340
|
content={formatTooltipNumbers(output.value)}
|
|
284
|
-
container={
|
|
341
|
+
container={container}
|
|
285
342
|
open={!output.value ? false : undefined}>
|
|
286
343
|
<BasicInfoOutput size="small" variant="body">
|
|
287
344
|
|
|
@@ -293,7 +350,7 @@ export function Quote(props: QuoteProps) {
|
|
|
293
350
|
</ContainerInfoOutput>
|
|
294
351
|
<Tooltip
|
|
295
352
|
content={formatTooltipNumbers(output.usdValue)}
|
|
296
|
-
container={
|
|
353
|
+
container={container}
|
|
297
354
|
style={{
|
|
298
355
|
display: 'flex',
|
|
299
356
|
}}>
|
|
@@ -309,9 +366,9 @@ export function Quote(props: QuoteProps) {
|
|
|
309
366
|
)}
|
|
310
367
|
{type === 'list-item' && (
|
|
311
368
|
<TokenAmount
|
|
369
|
+
tooltipContainer={container}
|
|
312
370
|
type="output"
|
|
313
371
|
direction="vertical"
|
|
314
|
-
tooltipContainer={tooltipContainer}
|
|
315
372
|
price={{
|
|
316
373
|
value: roundedOutput,
|
|
317
374
|
usdValue: roundedOutputUsdValue,
|
|
@@ -340,12 +397,14 @@ export function Quote(props: QuoteProps) {
|
|
|
340
397
|
)}
|
|
341
398
|
</div>
|
|
342
399
|
<QuoteContainer
|
|
343
|
-
|
|
400
|
+
selected={selected}
|
|
401
|
+
listItem={type === 'list-item'}
|
|
344
402
|
open={expanded}
|
|
345
403
|
onOpenChange={setExpanded}>
|
|
346
404
|
<QuoteTrigger
|
|
405
|
+
type={type}
|
|
347
406
|
quoteRef={quoteRef}
|
|
348
|
-
|
|
407
|
+
selected={selected}
|
|
349
408
|
setExpanded={setExpanded}
|
|
350
409
|
expanded={expanded}
|
|
351
410
|
steps={steps}
|
|
@@ -359,10 +418,10 @@ export function Quote(props: QuoteProps) {
|
|
|
359
418
|
<StepDetails
|
|
360
419
|
type="quote-details"
|
|
361
420
|
key={key}
|
|
421
|
+
tooltipContainer={container}
|
|
362
422
|
step={step}
|
|
363
423
|
hasSeparator={index !== steps.length - 1}
|
|
364
424
|
state={step.state}
|
|
365
|
-
tooltipContainer={tooltipContainer}
|
|
366
425
|
/>
|
|
367
426
|
);
|
|
368
427
|
})}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import type { QuoteError, QuoteWarning } from '../../types';
|
|
1
|
+
import type { QuoteError, QuoteWarning, SelectedQuote } from '../../types';
|
|
2
2
|
import type { Step } from '@rango-dev/ui';
|
|
3
|
-
import type { BestRouteResponse } from 'rango-sdk';
|
|
4
3
|
import type { ReactNode } from 'react';
|
|
5
4
|
|
|
6
5
|
export type QuoteProps = {
|
|
7
6
|
type: 'basic' | 'list-item' | 'swap-preview';
|
|
8
7
|
error: QuoteError | null;
|
|
9
8
|
warning: QuoteWarning | null;
|
|
10
|
-
|
|
11
|
-
tag?: ReactNode;
|
|
12
|
-
quote: BestRouteResponse;
|
|
9
|
+
quote: SelectedQuote;
|
|
13
10
|
input: { value: string; usdValue: string };
|
|
14
11
|
output: { value: string; usdValue?: string };
|
|
15
12
|
expanded?: boolean;
|
|
13
|
+
tagHidden?: boolean;
|
|
14
|
+
selected?: boolean;
|
|
15
|
+
onClickAllRoutes?: () => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type optionProps = {
|
|
19
|
+
value: string;
|
|
20
|
+
label: string;
|
|
16
21
|
};
|
|
17
22
|
|
|
18
23
|
export type QuoteTriggerProps = {
|
|
24
|
+
type: QuoteProps['type'];
|
|
19
25
|
quoteRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
20
|
-
|
|
26
|
+
selected: boolean;
|
|
21
27
|
setExpanded: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
|
22
28
|
steps: Step[];
|
|
23
29
|
expanded?: boolean;
|
|
@@ -32,6 +38,6 @@ export type QuoteTriggerImagesProps = {
|
|
|
32
38
|
};
|
|
33
39
|
|
|
34
40
|
export type QuoteCostDetailsProps = {
|
|
35
|
-
quote:
|
|
41
|
+
quote: SelectedQuote | null;
|
|
36
42
|
steps: number;
|
|
37
43
|
};
|
|
@@ -72,8 +72,8 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
72
72
|
const [openCollapse, setOpenCollapse] = useState<boolean>(false);
|
|
73
73
|
const { steps, quote } = props;
|
|
74
74
|
const tokens = useAppStore().tokens();
|
|
75
|
-
const totalTime = secondsToString(totalArrivalTime(quote
|
|
76
|
-
const swaps = quote
|
|
75
|
+
const totalTime = secondsToString(totalArrivalTime(quote?.swaps));
|
|
76
|
+
const swaps = quote?.swaps ?? [];
|
|
77
77
|
const container = getContainer();
|
|
78
78
|
|
|
79
79
|
const totalFee = getTotalFeeInUsd(swaps, tokens);
|
|
@@ -83,7 +83,10 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
83
83
|
return (
|
|
84
84
|
<>
|
|
85
85
|
<QuoteCost
|
|
86
|
-
onClickFee={() =>
|
|
86
|
+
onClickFee={(e) => {
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
setOpen(!open);
|
|
89
|
+
}}
|
|
87
90
|
fee={numberToString(
|
|
88
91
|
totalFee,
|
|
89
92
|
GAS_FEE_MIN_DECIMALS,
|
|
@@ -110,7 +113,9 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
110
113
|
</IconButton>
|
|
111
114
|
</ModalHeader>
|
|
112
115
|
}
|
|
113
|
-
onClose={() =>
|
|
116
|
+
onClose={() => {
|
|
117
|
+
setOpen(false);
|
|
118
|
+
}}>
|
|
114
119
|
<ModalContainer>
|
|
115
120
|
<Typography variant="title" size="small">
|
|
116
121
|
{i18n.t('Details')}
|
|
@@ -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 {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FlagPropTypes, Language } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
|
-
import { English, French, Japanese, Spanish } from '@rango-dev/ui';
|
|
3
|
+
import { English, French, Japanese, Portuguese, Spanish } from '@rango-dev/ui';
|
|
4
4
|
|
|
5
5
|
export type LanguageItem = {
|
|
6
6
|
title: string;
|
|
@@ -14,6 +14,7 @@ export const LANGUAGES: LanguageItem[] = [
|
|
|
14
14
|
{ title: 'Spanish', label: 'Español', local: 'es', SVGFlag: Spanish },
|
|
15
15
|
{ title: 'French', label: 'Français', local: 'fr', SVGFlag: French },
|
|
16
16
|
{ title: 'Japanese', label: '日本語', local: 'ja', SVGFlag: Japanese },
|
|
17
|
+
{ title: 'Portuguese', label: 'Português', local: 'pt', SVGFlag: Portuguese },
|
|
17
18
|
];
|
|
18
19
|
|
|
19
20
|
export const DEFAULT_LANGUAGE = 'en';
|
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() ?? '',
|