@rango-dev/widget-embedded 0.23.0 → 0.23.1-next.1
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/CHANGELOG.md +19 -0
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +0 -162
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.types.d.ts +3 -0
- package/dist/components/Quote/Quote.types.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +2 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +1 -1
- package/dist/constants/quote.d.ts +1 -0
- package/dist/constants/quote.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/utils/quote.d.ts +2 -4
- package/dist/utils/quote.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/Quote/Quote.styles.ts +0 -7
- package/src/components/Quote/Quote.tsx +27 -9
- package/src/components/Quote/Quote.types.ts +3 -0
- package/src/components/Quote/QuoteCostDetails.tsx +8 -29
- package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +3 -1
- package/src/constants/quote.ts +2 -0
- package/src/utils/quote.ts +3 -19
package/dist/utils/quote.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { QuoteWarning, SelectedQuote, Wallet } from '../types';
|
|
2
|
-
import type { PriceImpactWarningLevel, Step } from '@rango-dev/ui';
|
|
3
|
-
import type {
|
|
4
|
-
import type { Asset, BlockchainMeta, MultiRouteResponse, MultiRouteSimulationResult, PreferenceType, RouteTag, TagValue, Token } from 'rango-sdk';
|
|
2
|
+
import type { PriceImpactWarningLevel, SimulationAssetAndAmount, SimulationValidationStatus, Step } from '@rango-dev/ui';
|
|
3
|
+
import type { Asset, BlockchainMeta, MultiRouteResponse, MultiRouteSimulationResult, PreferenceType, RouteTag, Token } from 'rango-sdk';
|
|
5
4
|
import type { PendingSwap } from 'rango-types';
|
|
6
5
|
import BigNumber from 'bignumber.js';
|
|
7
6
|
export declare function getQuoteToTokenUsdPrice(quote: SelectedQuote | null): number | null | undefined;
|
|
@@ -34,5 +33,4 @@ export declare const getUniqueBlockchains: (steps: Step[]) => {
|
|
|
34
33
|
export declare const sortQuotesBy: (strategy: PreferenceType, quotes: MultiRouteResponse['results']) => MultiRouteResponse['results'];
|
|
35
34
|
export declare const getDefaultQuote: (currentQuote: SelectedQuote | null, quotes: MultiRouteSimulationResult[], requestAmount: string) => SelectedQuote | null;
|
|
36
35
|
export declare const sortTags: (tags: RouteTag[]) => RouteTag[];
|
|
37
|
-
export declare const getRouteTagColor: (tag: TagValue) => string;
|
|
38
36
|
//# sourceMappingURL=quote.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,IAAI,EACL,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,cAAc,EACd,QAAQ,EACR,KAAK,EACN,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,SAAS,MAAM,cAAc,CAAC;AAmBrC,wBAAgB,uBAAuB,CACrC,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AAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,GACA,YAAY,GAAG,IAAI,CAiDrB;AAED,wBAAgB,cAAc,CAC5B,aAAa,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,EACxC,cAAc,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,GACxC,MAAM,GAAG,IAAI,CAcf;AAED,eAAO,MAAM,oBAAoB,UAAW,IAAI,EAAE;iBAEnB,MAAM;WAAS,MAAM;GAanD,CAAC;AAEF,eAAO,MAAM,YAAY,aACb,cAAc,UAChB,kBAAkB,CAAC,SAAS,CAAC,KACpC,kBAAkB,CAAC,SAAS,CAkB9B,CAAC;AAEF,eAAO,MAAM,eAAe,iBACZ,aAAa,GAAG,IAAI,UAC1B,0BAA0B,EAAE,iBACrB,MAAM,KACpB,aAAa,GAAG,IAgClB,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAU,QAAQ,EAAE,KAAG,QAAQ,EAmBnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@rango-dev/queue-manager-core": "^0.26.0",
|
|
26
26
|
"@rango-dev/queue-manager-rango-preset": "^0.28.0",
|
|
27
27
|
"@rango-dev/queue-manager-react": "^0.26.0",
|
|
28
|
-
"@rango-dev/ui": "^0.29.
|
|
28
|
+
"@rango-dev/ui": "^0.29.1-next.1",
|
|
29
29
|
"@rango-dev/wallets-react": "^0.14.0",
|
|
30
30
|
"@rango-dev/wallets-shared": "^0.28.0",
|
|
31
31
|
"bignumber.js": "^9.1.1",
|
|
@@ -365,13 +365,6 @@ export const MoreStep = styled('div', {
|
|
|
365
365
|
},
|
|
366
366
|
});
|
|
367
367
|
|
|
368
|
-
export const Tag = styled('div', {
|
|
369
|
-
backgroundColor: '$neutral400',
|
|
370
|
-
borderRadius: '$xs',
|
|
371
|
-
padding: '$2 $5',
|
|
372
|
-
fontSize: '$10',
|
|
373
|
-
fontWeight: 400,
|
|
374
|
-
});
|
|
375
368
|
export const TagContainer = styled('div', {
|
|
376
369
|
display: 'flex',
|
|
377
370
|
});
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Alert,
|
|
8
8
|
Divider,
|
|
9
9
|
InfoIcon,
|
|
10
|
+
QuoteTag,
|
|
10
11
|
StepDetails,
|
|
11
12
|
TokenAmount,
|
|
12
13
|
Tooltip,
|
|
@@ -15,7 +16,10 @@ import {
|
|
|
15
16
|
import BigNumber from 'bignumber.js';
|
|
16
17
|
import React, { useRef, useState } from 'react';
|
|
17
18
|
|
|
19
|
+
import { GAS_FEE_MAX } from '../../constants/quote';
|
|
18
20
|
import {
|
|
21
|
+
GAS_FEE_MAX_DECIMALS,
|
|
22
|
+
GAS_FEE_MIN_DECIMALS,
|
|
19
23
|
PERCENTAGE_CHANGE_MAX_DECIMALS,
|
|
20
24
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
21
25
|
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
@@ -34,13 +38,18 @@ import {
|
|
|
34
38
|
getBlockchainShortNameFor,
|
|
35
39
|
getSwapperDisplayName,
|
|
36
40
|
} from '../../utils/meta';
|
|
37
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
formatTooltipNumbers,
|
|
43
|
+
numberToString,
|
|
44
|
+
secondsToString,
|
|
45
|
+
totalArrivalTime,
|
|
46
|
+
} from '../../utils/numbers';
|
|
38
47
|
import {
|
|
39
48
|
getPriceImpact,
|
|
40
49
|
getPriceImpactLevel,
|
|
41
|
-
getRouteTagColor,
|
|
42
50
|
sortTags,
|
|
43
51
|
} from '../../utils/quote';
|
|
52
|
+
import { getTotalFeeInUsd } from '../../utils/swap';
|
|
44
53
|
|
|
45
54
|
import {
|
|
46
55
|
AllRoutesButton,
|
|
@@ -56,7 +65,6 @@ import {
|
|
|
56
65
|
SummaryContainer,
|
|
57
66
|
summaryHeaderStyles,
|
|
58
67
|
summaryStyles,
|
|
59
|
-
Tag,
|
|
60
68
|
TagContainer,
|
|
61
69
|
} from './Quote.styles';
|
|
62
70
|
import { QuoteCostDetails } from './QuoteCostDetails';
|
|
@@ -76,6 +84,7 @@ export function Quote(props: QuoteProps) {
|
|
|
76
84
|
onClickAllRoutes,
|
|
77
85
|
} = props;
|
|
78
86
|
const blockchains = useAppStore().blockchains();
|
|
87
|
+
const tokens = useAppStore().tokens();
|
|
79
88
|
const swappers = useAppStore().swappers();
|
|
80
89
|
const [expanded, setExpanded] = useState(props.expanded);
|
|
81
90
|
const quoteRef = useRef<HTMLButtonElement | null>(null);
|
|
@@ -280,6 +289,13 @@ export function Quote(props: QuoteProps) {
|
|
|
280
289
|
const container = getContainer();
|
|
281
290
|
const sortedQuoteTags = sortTags(props.quote.tags || []);
|
|
282
291
|
const showAllRoutesButton = !!onClickAllRoutes;
|
|
292
|
+
const totalTime = secondsToString(totalArrivalTime(quote?.swaps));
|
|
293
|
+
const totalFee = getTotalFeeInUsd(quote?.swaps ?? [], tokens);
|
|
294
|
+
const fee = numberToString(
|
|
295
|
+
totalFee,
|
|
296
|
+
GAS_FEE_MIN_DECIMALS,
|
|
297
|
+
GAS_FEE_MAX_DECIMALS
|
|
298
|
+
);
|
|
283
299
|
|
|
284
300
|
return (
|
|
285
301
|
<>
|
|
@@ -295,11 +311,7 @@ export function Quote(props: QuoteProps) {
|
|
|
295
311
|
const key = `${tag.value}_${index}`;
|
|
296
312
|
return (
|
|
297
313
|
<>
|
|
298
|
-
<
|
|
299
|
-
style={{ color: getRouteTagColor(tag.value) }}
|
|
300
|
-
key={key}>
|
|
301
|
-
{tag.label}
|
|
302
|
-
</Tag>
|
|
314
|
+
<QuoteTag label={tag.label} key={key} value={tag.value} />
|
|
303
315
|
<Divider size={4} direction="horizontal" />
|
|
304
316
|
</>
|
|
305
317
|
);
|
|
@@ -310,7 +322,13 @@ export function Quote(props: QuoteProps) {
|
|
|
310
322
|
</>
|
|
311
323
|
) : null}
|
|
312
324
|
<div id="portal-root" className={summaryHeaderStyles()}>
|
|
313
|
-
<QuoteCostDetails
|
|
325
|
+
<QuoteCostDetails
|
|
326
|
+
steps={numberOfSteps}
|
|
327
|
+
quote={quote}
|
|
328
|
+
time={totalTime}
|
|
329
|
+
fee={fee}
|
|
330
|
+
feeWarning={totalFee.gte(new BigNumber(GAS_FEE_MAX))}
|
|
331
|
+
/>
|
|
314
332
|
|
|
315
333
|
{showAllRoutesButton && (
|
|
316
334
|
<AllRoutesButton
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { QuoteCostDetailsProps } from './Quote.types';
|
|
2
2
|
import type { NameOfFees } from '../../constants/quote';
|
|
3
|
+
import type BigNumber from 'bignumber.js';
|
|
3
4
|
|
|
4
5
|
import { i18n } from '@lingui/core';
|
|
5
6
|
import {
|
|
@@ -11,7 +12,6 @@ import {
|
|
|
11
12
|
Tooltip,
|
|
12
13
|
Typography,
|
|
13
14
|
} from '@rango-dev/ui';
|
|
14
|
-
import BigNumber from 'bignumber.js';
|
|
15
15
|
import React, { useState } from 'react';
|
|
16
16
|
|
|
17
17
|
import { NAME_OF_FEES } from '../../constants/quote';
|
|
@@ -21,20 +21,9 @@ import {
|
|
|
21
21
|
USD_VALUE_MAX_DECIMALS,
|
|
22
22
|
USD_VALUE_MIN_DECIMALS,
|
|
23
23
|
} from '../../constants/routing';
|
|
24
|
-
import { useAppStore } from '../../store/AppStore';
|
|
25
24
|
import { getContainer } from '../../utils/common';
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
numberToString,
|
|
29
|
-
secondsToString,
|
|
30
|
-
totalArrivalTime,
|
|
31
|
-
} from '../../utils/numbers';
|
|
32
|
-
import {
|
|
33
|
-
getFeesGroup,
|
|
34
|
-
getTotalFeeInUsd,
|
|
35
|
-
getTotalFeesInUsd,
|
|
36
|
-
getUsdFee,
|
|
37
|
-
} from '../../utils/swap';
|
|
25
|
+
import { formatTooltipNumbers, numberToString } from '../../utils/numbers';
|
|
26
|
+
import { getFeesGroup, getTotalFeesInUsd, getUsdFee } from '../../utils/swap';
|
|
38
27
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
39
28
|
import { CustomCollapsible } from '../CustomCollapsible/CustomCollapsible';
|
|
40
29
|
import { ExpandedIcon } from '../CustomCollapsible/CustomCollapsible.styles';
|
|
@@ -47,8 +36,6 @@ import {
|
|
|
47
36
|
trigger,
|
|
48
37
|
} from './QuoteCostDetails.styles';
|
|
49
38
|
|
|
50
|
-
const GAS_FEE_MAX = 30;
|
|
51
|
-
|
|
52
39
|
const NonPayableFee = (props: { fee: BigNumber; label: string }) => {
|
|
53
40
|
return !props.fee.isZero() ? (
|
|
54
41
|
<FeeSection>
|
|
@@ -70,14 +57,10 @@ const NonPayableFee = (props: { fee: BigNumber; label: string }) => {
|
|
|
70
57
|
export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
71
58
|
const [open, setOpen] = useState<boolean>(false);
|
|
72
59
|
const [openCollapse, setOpenCollapse] = useState<boolean>(false);
|
|
73
|
-
const { steps, quote } = props;
|
|
74
|
-
const tokens = useAppStore().tokens();
|
|
75
|
-
const totalTime = secondsToString(totalArrivalTime(quote?.swaps));
|
|
60
|
+
const { steps, quote, fee, time, feeWarning } = props;
|
|
76
61
|
const swaps = quote?.swaps ?? [];
|
|
77
62
|
const container = getContainer();
|
|
78
63
|
|
|
79
|
-
const totalFee = getTotalFeeInUsd(swaps, tokens);
|
|
80
|
-
|
|
81
64
|
const feesGroup = getFeesGroup(swaps);
|
|
82
65
|
|
|
83
66
|
return (
|
|
@@ -87,13 +70,9 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
87
70
|
e.stopPropagation();
|
|
88
71
|
setOpen(!open);
|
|
89
72
|
}}
|
|
90
|
-
fee={
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
GAS_FEE_MAX_DECIMALS
|
|
94
|
-
)}
|
|
95
|
-
feeWarning={totalFee.gte(new BigNumber(GAS_FEE_MAX))}
|
|
96
|
-
time={totalTime}
|
|
73
|
+
fee={fee}
|
|
74
|
+
feeWarning={feeWarning}
|
|
75
|
+
time={time}
|
|
97
76
|
steps={steps}
|
|
98
77
|
tooltipGas={i18n.t('View more info')}
|
|
99
78
|
tooltipContainer={container}
|
|
@@ -164,7 +143,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
164
143
|
<Typography variant="label" size="medium">
|
|
165
144
|
$
|
|
166
145
|
{numberToString(
|
|
167
|
-
|
|
146
|
+
fee,
|
|
168
147
|
USD_VALUE_MIN_DECIMALS,
|
|
169
148
|
USD_VALUE_MAX_DECIMALS
|
|
170
149
|
)}
|
package/src/constants/quote.ts
CHANGED
package/src/utils/quote.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
2
|
import type { QuoteWarning, SelectedQuote, Wallet } from '../types';
|
|
3
|
-
import type { PriceImpactWarningLevel, Step } from '@rango-dev/ui';
|
|
4
3
|
import type {
|
|
4
|
+
PriceImpactWarningLevel,
|
|
5
5
|
SimulationAssetAndAmount,
|
|
6
6
|
SimulationValidationStatus,
|
|
7
|
-
|
|
7
|
+
Step,
|
|
8
|
+
} from '@rango-dev/ui';
|
|
8
9
|
import type {
|
|
9
10
|
Asset,
|
|
10
11
|
BlockchainMeta,
|
|
@@ -12,7 +13,6 @@ import type {
|
|
|
12
13
|
MultiRouteSimulationResult,
|
|
13
14
|
PreferenceType,
|
|
14
15
|
RouteTag,
|
|
15
|
-
TagValue,
|
|
16
16
|
Token,
|
|
17
17
|
} from 'rango-sdk';
|
|
18
18
|
import type { PendingSwap } from 'rango-types';
|
|
@@ -372,19 +372,3 @@ export const sortTags = (tags: RouteTag[]): RouteTag[] => {
|
|
|
372
372
|
|
|
373
373
|
return tags.sort(customSort);
|
|
374
374
|
};
|
|
375
|
-
|
|
376
|
-
export const getRouteTagColor = (tag: TagValue): string => {
|
|
377
|
-
switch (tag) {
|
|
378
|
-
case 'FASTEST':
|
|
379
|
-
return '#06C270';
|
|
380
|
-
case 'RECOMMENDED':
|
|
381
|
-
return '#469BF5';
|
|
382
|
-
case 'LOWEST_FEE':
|
|
383
|
-
return '#FF4DAD';
|
|
384
|
-
case 'HIGH_IMPACT':
|
|
385
|
-
return '#FF3B3B';
|
|
386
|
-
case 'CENTRALIZED':
|
|
387
|
-
default:
|
|
388
|
-
return '#FFF1D4';
|
|
389
|
-
}
|
|
390
|
-
};
|