@rango-dev/widget-embedded 0.29.1-next.19 → 0.29.1-next.20
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/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/constants/quote.d.ts +2 -1
- package/dist/constants/quote.d.ts.map +1 -1
- package/dist/constants/routing.d.ts +0 -1
- package/dist/constants/routing.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/utils/numbers.d.ts +0 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +2 -2
- package/src/components/HistoryGroupedList/HistoryGroupedList.tsx +5 -5
- package/src/components/Quote/Quote.tsx +18 -25
- package/src/components/Quote/QuoteCostDetails.tsx +10 -9
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +9 -10
- package/src/constants/quote.ts +11 -9
- package/src/constants/routing.ts +0 -2
- package/src/containers/Inputs/Inputs.tsx +4 -4
- package/src/utils/numbers.ts +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.29.1-next.
|
|
3
|
+
"version": "0.29.1-next.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@rango-dev/queue-manager-rango-preset": "^0.34.1-next.7",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.26.0",
|
|
32
32
|
"@rango-dev/signer-solana": "^0.29.1-next.1",
|
|
33
|
-
"@rango-dev/ui": "^0.35.1-next.
|
|
33
|
+
"@rango-dev/ui": "^0.35.1-next.10",
|
|
34
34
|
"@rango-dev/wallets-react": "^0.20.1-next.5",
|
|
35
35
|
"@rango-dev/wallets-shared": "^0.34.1-next.5",
|
|
36
36
|
"bignumber.js": "^9.1.1",
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
16
16
|
} from '../../constants/routing';
|
|
17
17
|
import { getContainer } from '../../utils/common';
|
|
18
|
-
import {
|
|
18
|
+
import { numberToString } from '../../utils/numbers';
|
|
19
19
|
|
|
20
20
|
import { calculateGroupsSoFar } from './HistoryGroupedList.helpers';
|
|
21
21
|
import {
|
|
@@ -130,7 +130,7 @@ export function HistoryGroupedList(props: PropTypes) {
|
|
|
130
130
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
131
131
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
132
132
|
),
|
|
133
|
-
realAmount:
|
|
133
|
+
realAmount: swap.inputAmount,
|
|
134
134
|
},
|
|
135
135
|
to: {
|
|
136
136
|
token: {
|
|
@@ -147,10 +147,10 @@ export function HistoryGroupedList(props: PropTypes) {
|
|
|
147
147
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
148
148
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
149
149
|
),
|
|
150
|
-
realAmount:
|
|
150
|
+
realAmount:
|
|
151
151
|
lastStep.outputAmount ||
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
lastStep.expectedOutputAmountHumanReadable ||
|
|
153
|
+
'',
|
|
154
154
|
},
|
|
155
155
|
}}
|
|
156
156
|
/>
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
Divider,
|
|
9
9
|
FullExpandedQuote,
|
|
10
10
|
InfoIcon,
|
|
11
|
+
NumericTooltip,
|
|
11
12
|
QuoteTag,
|
|
12
13
|
StepDetails,
|
|
13
14
|
TokenAmount,
|
|
14
|
-
Tooltip,
|
|
15
15
|
Typography,
|
|
16
16
|
} from '@rango-dev/ui';
|
|
17
17
|
import BigNumber from 'bignumber.js';
|
|
@@ -40,7 +40,6 @@ import {
|
|
|
40
40
|
getSwapperDisplayName,
|
|
41
41
|
} from '../../utils/meta';
|
|
42
42
|
import {
|
|
43
|
-
formatTooltipNumbers,
|
|
44
43
|
numberToString,
|
|
45
44
|
roundedSecondsToString,
|
|
46
45
|
totalArrivalTime,
|
|
@@ -186,14 +185,10 @@ export function Quote(props: QuoteProps) {
|
|
|
186
185
|
USD_VALUE_MIN_DECIMALS,
|
|
187
186
|
USD_VALUE_MAX_DECIMALS
|
|
188
187
|
),
|
|
189
|
-
realValue:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
new BigNumber(swap.from.usdPrice ?? 0).multipliedBy(
|
|
194
|
-
swap.fromAmount
|
|
195
|
-
)
|
|
196
|
-
),
|
|
188
|
+
realValue: index === 0 ? input.value : swap.fromAmount,
|
|
189
|
+
realUsdValue: new BigNumber(swap.from.usdPrice ?? 0)
|
|
190
|
+
.multipliedBy(swap.fromAmount)
|
|
191
|
+
.toString(),
|
|
197
192
|
},
|
|
198
193
|
},
|
|
199
194
|
to: {
|
|
@@ -216,10 +211,10 @@ export function Quote(props: QuoteProps) {
|
|
|
216
211
|
USD_VALUE_MIN_DECIMALS,
|
|
217
212
|
USD_VALUE_MAX_DECIMALS
|
|
218
213
|
),
|
|
219
|
-
realValue:
|
|
220
|
-
realUsdValue:
|
|
221
|
-
|
|
222
|
-
|
|
214
|
+
realValue: swap.toAmount,
|
|
215
|
+
realUsdValue: new BigNumber(swap.to.usdPrice ?? 0)
|
|
216
|
+
.multipliedBy(swap.toAmount)
|
|
217
|
+
.toString(),
|
|
223
218
|
},
|
|
224
219
|
},
|
|
225
220
|
state: stepState,
|
|
@@ -343,8 +338,8 @@ export function Quote(props: QuoteProps) {
|
|
|
343
338
|
outputPrice={{
|
|
344
339
|
value: roundedOutput,
|
|
345
340
|
usdValue: roundedOutputUsdValue,
|
|
346
|
-
realValue:
|
|
347
|
-
realUsdValue:
|
|
341
|
+
realValue: output.value,
|
|
342
|
+
realUsdValue: output.usdValue,
|
|
348
343
|
}}
|
|
349
344
|
/>
|
|
350
345
|
) : (
|
|
@@ -414,8 +409,8 @@ export function Quote(props: QuoteProps) {
|
|
|
414
409
|
<BasicInfoOutput size="small" variant="body">
|
|
415
410
|
{`${roundedInput} ${steps[0].from.token.displayName} = `}
|
|
416
411
|
</BasicInfoOutput>
|
|
417
|
-
<
|
|
418
|
-
content={
|
|
412
|
+
<NumericTooltip
|
|
413
|
+
content={output.value}
|
|
419
414
|
container={container}
|
|
420
415
|
open={!output.value ? false : undefined}>
|
|
421
416
|
<BasicInfoOutput size="small" variant="body">
|
|
@@ -424,16 +419,14 @@ export function Quote(props: QuoteProps) {
|
|
|
424
419
|
steps[steps.length - 1].to.token.displayName
|
|
425
420
|
}`}
|
|
426
421
|
</BasicInfoOutput>
|
|
427
|
-
</
|
|
422
|
+
</NumericTooltip>
|
|
428
423
|
</ContainerInfoOutput>
|
|
429
|
-
<
|
|
430
|
-
content={formatTooltipNumbers(output.usdValue)}
|
|
431
|
-
container={container}>
|
|
424
|
+
<NumericTooltip content={output.usdValue} container={container}>
|
|
432
425
|
<Divider size={2} direction="horizontal" />
|
|
433
426
|
<Typography color="$neutral600" size="xsmall" variant="body">
|
|
434
427
|
{`($${roundedOutputUsdValue})`}
|
|
435
428
|
</Typography>
|
|
436
|
-
</
|
|
429
|
+
</NumericTooltip>
|
|
437
430
|
</div>
|
|
438
431
|
)}
|
|
439
432
|
{type === 'list-item' && (
|
|
@@ -444,8 +437,8 @@ export function Quote(props: QuoteProps) {
|
|
|
444
437
|
price={{
|
|
445
438
|
value: roundedOutput,
|
|
446
439
|
usdValue: roundedOutputUsdValue,
|
|
447
|
-
realValue:
|
|
448
|
-
realUsdValue:
|
|
440
|
+
realValue: output.value,
|
|
441
|
+
realUsdValue: output.usdValue,
|
|
449
442
|
}}
|
|
450
443
|
token={{
|
|
451
444
|
displayName: steps[numberOfSteps - 1].to.token.displayName,
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
CloseIcon,
|
|
9
9
|
Divider,
|
|
10
10
|
IconButton,
|
|
11
|
+
NumericTooltip,
|
|
11
12
|
QuoteCost,
|
|
12
|
-
Tooltip,
|
|
13
13
|
Typography,
|
|
14
14
|
} from '@rango-dev/ui';
|
|
15
15
|
import React, { useState } from 'react';
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { getFeeLabel } from '../../constants/quote';
|
|
18
18
|
import {
|
|
19
19
|
GAS_FEE_MAX_DECIMALS,
|
|
20
20
|
GAS_FEE_MIN_DECIMALS,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
USD_VALUE_MIN_DECIMALS,
|
|
23
23
|
} from '../../constants/routing';
|
|
24
24
|
import { getContainer } from '../../utils/common';
|
|
25
|
-
import {
|
|
25
|
+
import { numberToString } from '../../utils/numbers';
|
|
26
26
|
import { getFeesGroup, getTotalFeesInUsd, getUsdFee } from '../../utils/swap';
|
|
27
27
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
28
28
|
import { CustomCollapsible } from '../CustomCollapsible/CustomCollapsible';
|
|
@@ -115,11 +115,9 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
115
115
|
variant="label"
|
|
116
116
|
size="medium"
|
|
117
117
|
color="neutral600">
|
|
118
|
-
{
|
|
118
|
+
{getFeeLabel(payableFeesKey as NameOfFees, i18n.t)}
|
|
119
119
|
</Typography>
|
|
120
|
-
<
|
|
121
|
-
content={formatTooltipNumbers(fee.amount)}
|
|
122
|
-
container={container}>
|
|
120
|
+
<NumericTooltip content={fee.amount} container={container}>
|
|
123
121
|
<Typography variant="label" size="medium">
|
|
124
122
|
{numberToString(
|
|
125
123
|
fee.amount,
|
|
@@ -134,7 +132,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
134
132
|
)}
|
|
135
133
|
)
|
|
136
134
|
</Typography>
|
|
137
|
-
</
|
|
135
|
+
</NumericTooltip>
|
|
138
136
|
</FeeSection>
|
|
139
137
|
);
|
|
140
138
|
})
|
|
@@ -184,7 +182,10 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
184
182
|
{Object.entries(feesGroup.nonePayable).map(
|
|
185
183
|
([nonPayableFeesKey, fees], index) => {
|
|
186
184
|
const totalFeeInUsd = getTotalFeesInUsd(fees);
|
|
187
|
-
const label =
|
|
185
|
+
const label = getFeeLabel(
|
|
186
|
+
nonPayableFeesKey as NameOfFees,
|
|
187
|
+
i18n.t
|
|
188
|
+
);
|
|
188
189
|
const key = `non-payable-fee-${index}`;
|
|
189
190
|
return (
|
|
190
191
|
<NonPayableFee
|
|
@@ -42,7 +42,6 @@ import { useQuoteStore } from '../../store/quote';
|
|
|
42
42
|
import { useUiStore } from '../../store/ui';
|
|
43
43
|
import { getContainer } from '../../utils/common';
|
|
44
44
|
import {
|
|
45
|
-
formatTooltipNumbers,
|
|
46
45
|
numberToString,
|
|
47
46
|
roundedSecondsToString,
|
|
48
47
|
totalArrivalTime,
|
|
@@ -206,14 +205,14 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
206
205
|
);
|
|
207
206
|
|
|
208
207
|
const realOutputUsdValue = outputAmount
|
|
209
|
-
?
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
? new BigNumber(outputAmount)
|
|
209
|
+
.multipliedBy(lastStep.toUsdPrice || 0)
|
|
210
|
+
.toString()
|
|
212
211
|
: '';
|
|
213
212
|
|
|
214
|
-
const realInputUsdValue =
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
const realInputUsdValue = new BigNumber(swap.inputAmount)
|
|
214
|
+
.multipliedBy(firstStep.fromUsdPrice || 0)
|
|
215
|
+
.toString();
|
|
217
216
|
|
|
218
217
|
const percentageChange = getPriceImpact(inputUsdValue, outputUsdValue);
|
|
219
218
|
|
|
@@ -272,7 +271,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
272
271
|
return (
|
|
273
272
|
<Layout
|
|
274
273
|
header={{
|
|
275
|
-
title: i18n.t('Swap
|
|
274
|
+
title: i18n.t('Swap Details'),
|
|
276
275
|
onCancel:
|
|
277
276
|
swap.status === 'running' ? () => setModalState('cancel') : undefined,
|
|
278
277
|
suffix: swap.status !== 'running' && (
|
|
@@ -338,7 +337,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
338
337
|
</div>
|
|
339
338
|
<div className={rowStyles()}>
|
|
340
339
|
<Typography variant="label" size="large" color="neutral700">
|
|
341
|
-
{
|
|
340
|
+
{swap.finishTime ? i18n.t('Finished at') : i18n.t('Created at')}
|
|
342
341
|
</Typography>
|
|
343
342
|
<Typography variant="label" size="small" color="neutral700">
|
|
344
343
|
{swapDate}
|
|
@@ -458,7 +457,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
458
457
|
)}
|
|
459
458
|
usdValue={outputUsdValue}
|
|
460
459
|
realUsdValue={realOutputUsdValue}
|
|
461
|
-
realValue={
|
|
460
|
+
realValue={outputAmount || ''}
|
|
462
461
|
percentageChange={numberToString(
|
|
463
462
|
percentageChange,
|
|
464
463
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
package/src/constants/quote.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import type { I18n } from '@lingui/core';
|
|
1
2
|
import type { SwapFee, TagValue } from 'rango-sdk';
|
|
2
3
|
|
|
3
|
-
import { i18n } from '@lingui/core';
|
|
4
|
-
|
|
5
4
|
export type NameOfFees =
|
|
6
5
|
| 'Swapper Fee'
|
|
7
6
|
| 'Affiliate Fee'
|
|
@@ -9,13 +8,16 @@ export type NameOfFees =
|
|
|
9
8
|
| 'Rango Fee'
|
|
10
9
|
| 'Network Fee';
|
|
11
10
|
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
export function getFeeLabel(fee: NameOfFees, t: I18n['t']): string {
|
|
12
|
+
const data: Record<NameOfFees, string> = {
|
|
13
|
+
'Network Fee': t('Network Fee'),
|
|
14
|
+
'Swapper Fee': t('Protocol Fee'),
|
|
15
|
+
'Affiliate Fee': t('Affiliate Fee'),
|
|
16
|
+
'Outbound network fee': t('Outbound Fee'),
|
|
17
|
+
'Rango Fee': t('Rango Fee'),
|
|
18
|
+
};
|
|
19
|
+
return data[fee];
|
|
20
|
+
}
|
|
19
21
|
|
|
20
22
|
export type FeesGroup = {
|
|
21
23
|
payable: { [key in NameOfFees]?: SwapFee[] };
|
package/src/constants/routing.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { useQuoteStore } from '../../store/quote';
|
|
18
18
|
import { useWalletsStore } from '../../store/wallets';
|
|
19
19
|
import { getContainer } from '../../utils/common';
|
|
20
|
-
import {
|
|
20
|
+
import { numberToString } from '../../utils/numbers';
|
|
21
21
|
import { getPriceImpact, getPriceImpactLevel } from '../../utils/quote';
|
|
22
22
|
import { canComputePriceImpact } from '../../utils/swap';
|
|
23
23
|
import { formatBalance, isFetchingBalance } from '../../utils/wallets';
|
|
@@ -97,7 +97,7 @@ export function Inputs(props: PropTypes) {
|
|
|
97
97
|
),
|
|
98
98
|
realUsdValue: priceImpactInputCanNotBeComputed
|
|
99
99
|
? undefined
|
|
100
|
-
:
|
|
100
|
+
: inputUsdValue?.toString(),
|
|
101
101
|
error: priceImpactInputCanNotBeComputed
|
|
102
102
|
? errorMessages().unknownPriceError.impactTitle
|
|
103
103
|
: undefined,
|
|
@@ -144,10 +144,10 @@ export function Inputs(props: PropTypes) {
|
|
|
144
144
|
USD_VALUE_MIN_DECIMALS,
|
|
145
145
|
USD_VALUE_MAX_DECIMALS
|
|
146
146
|
),
|
|
147
|
-
realValue:
|
|
147
|
+
realValue: outputAmount?.toString(),
|
|
148
148
|
realUsdValue: priceImpactOutputCanNotBeComputed
|
|
149
149
|
? undefined
|
|
150
|
-
:
|
|
150
|
+
: outputUsdValue?.toString(),
|
|
151
151
|
error: priceImpactOutputCanNotBeComputed
|
|
152
152
|
? errorMessages().unknownPriceError.impactTitle
|
|
153
153
|
: undefined,
|
package/src/utils/numbers.ts
CHANGED
|
@@ -4,8 +4,6 @@ import type { BestRouteResponse } from 'rango-sdk';
|
|
|
4
4
|
|
|
5
5
|
import { BigNumber } from 'bignumber.js';
|
|
6
6
|
|
|
7
|
-
import { TOOLTIP_DECIMALS } from '../constants/routing';
|
|
8
|
-
|
|
9
7
|
/*
|
|
10
8
|
* if time > 1h -> rounded with 5 minutes precision
|
|
11
9
|
* if time < 1h -> rounded with 15 seconds precision
|
|
@@ -127,13 +125,3 @@ export const containsText = (text: string, searchText: string) =>
|
|
|
127
125
|
|
|
128
126
|
export const isPositiveNumber = (text?: string) =>
|
|
129
127
|
!!text && parseFloat(text) > 0;
|
|
130
|
-
10;
|
|
131
|
-
|
|
132
|
-
export function formatTooltipNumbers(
|
|
133
|
-
number: BigNumber | string | number | null | undefined
|
|
134
|
-
) {
|
|
135
|
-
return numberToString(number, TOOLTIP_DECIMALS, TOOLTIP_DECIMALS).replace(
|
|
136
|
-
/(?:\.0*|(\.\d+?)0*)$/,
|
|
137
|
-
'$1'
|
|
138
|
-
);
|
|
139
|
-
}
|