@rango-dev/widget-embedded 0.20.1-next.1 → 0.20.1-next.2
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/Quote.styles.d.ts +157 -0
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/QuoteSummary.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +2 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
- package/dist/constants/routing.d.ts +1 -0
- package/dist/constants/routing.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +1 -5
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/time.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/Quote/Quote.styles.ts +5 -1
- package/src/components/Quote/Quote.tsx +53 -15
- package/src/components/Quote/QuoteSummary.tsx +17 -2
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +7 -1
- package/src/components/SwapDetails/SwapDetails.tsx +21 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +6 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +2 -0
- package/src/components/SwapsGroup/SwapsGroup.tsx +13 -7
- package/src/constants/routing.ts +2 -0
- package/src/pages/Home.tsx +11 -1
- package/src/utils/date.ts +22 -8
- package/src/utils/numbers.ts +8 -58
- package/src/utils/time.ts +25 -69
package/dist/pages/Home.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AA+C3D,wBAAgB,IAAI,sBAyOnB"}
|
package/dist/utils/date.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAKzE,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAKzE,eAAO,MAAM,gBAAgB,EAAE,OAmE9B,CAAC"}
|
package/dist/utils/numbers.d.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import type { BestRouteResponse } from 'rango-sdk';
|
|
2
2
|
import { BigNumber } from 'bignumber.js';
|
|
3
|
-
export declare const percentToString: (p: number, fractions?: number) => string;
|
|
4
3
|
export declare const secondsToString: (s: number) => string;
|
|
5
4
|
export declare const numberToString: (number: BigNumber | string | number | null | undefined, minDecimals?: number | null, maxDecimals?: number | null) => string;
|
|
6
|
-
export declare const convertBigNumberToHex: (value: BigNumber, decimals: number) => string;
|
|
7
5
|
export declare const uint8ArrayToHex: (buffer: Uint8Array) => string;
|
|
8
|
-
export declare function dollarToConciseString(num: number | undefined): string;
|
|
9
|
-
export declare function removeExtraDecimals(num: string, maxDecimals: number): string;
|
|
10
6
|
export declare const totalArrivalTime: (data: {
|
|
11
7
|
estimatedTimeInSeconds: number | null;
|
|
12
8
|
}[] | undefined) => number;
|
|
13
9
|
export declare const rawFees: (data: BestRouteResponse) => string;
|
|
14
10
|
export declare const containsText: (text: string, searchText: string) => boolean;
|
|
15
11
|
export declare const isPositiveNumber: (text?: string) => boolean;
|
|
16
|
-
export declare function
|
|
12
|
+
export declare function formatTooltipNumbers(number: BigNumber | string | number | null | undefined): string;
|
|
17
13
|
//# sourceMappingURL=numbers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/utils/numbers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/utils/numbers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,eAAO,MAAM,eAAe,MAAO,MAAM,KAAG,MAM3C,CAAC;AAEF,eAAO,MAAM,cAAc,WACjB,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,gBACzC,MAAM,GAAG,IAAI,gBACb,MAAM,GAAG,IAAI,KACzB,MA2EF,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,UAAU,KAAG,MAKpD,CAAC;AAEF,eAAO,MAAM,gBAAgB,SACrB;IAAE,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,GAAG,SAAS,WACS,CAAC;AAEzE,eAAO,MAAM,OAAO,SAAU,iBAAiB,KAAG,MAOnC,CAAC;AAEhB,eAAO,MAAM,YAAY,SAAU,MAAM,cAAc,MAAM,YACF,CAAC;AAE5D,eAAO,MAAM,gBAAgB,UAAW,MAAM,YACd,CAAC;AAGjC,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,UAMvD"}
|
package/dist/utils/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/utils/time.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/utils/time.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAc/C,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,UAW5C;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,WAAW,UAKnD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.20.1-next.
|
|
3
|
+
"version": "0.20.1-next.2",
|
|
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.25.0",
|
|
26
26
|
"@rango-dev/queue-manager-rango-preset": "^0.25.1-next.0",
|
|
27
27
|
"@rango-dev/queue-manager-react": "^0.24.0",
|
|
28
|
-
"@rango-dev/ui": "^0.26.1-next.
|
|
28
|
+
"@rango-dev/ui": "^0.26.1-next.1",
|
|
29
29
|
"@rango-dev/wallets-react": "^0.11.1-next.0",
|
|
30
30
|
"@rango-dev/wallets-shared": "^0.25.1-next.0",
|
|
31
31
|
"bignumber.js": "^9.1.1",
|
|
@@ -47,4 +47,4 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
|
@@ -243,8 +243,12 @@ export const FrameIcon = styled('div', {
|
|
|
243
243
|
});
|
|
244
244
|
|
|
245
245
|
export const BasicInfoOutput = styled(Typography, {
|
|
246
|
-
width: '100%',
|
|
247
246
|
overflow: 'hidden',
|
|
248
247
|
textOverflow: 'ellipsis',
|
|
249
248
|
letterSpacing: 0.4,
|
|
250
249
|
});
|
|
250
|
+
|
|
251
|
+
export const ContainerInfoOutput = styled('div', {
|
|
252
|
+
display: 'flex',
|
|
253
|
+
flexWrap: 'wrap',
|
|
254
|
+
});
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
Tooltip,
|
|
17
17
|
Typography,
|
|
18
18
|
} from '@rango-dev/ui';
|
|
19
|
+
import BigNumber from 'bignumber.js';
|
|
19
20
|
import React, { useLayoutEffect, useRef, useState } from 'react';
|
|
20
21
|
|
|
21
22
|
import {
|
|
@@ -40,6 +41,7 @@ import {
|
|
|
40
41
|
getSwapperDisplayName,
|
|
41
42
|
} from '../../utils/meta';
|
|
42
43
|
import {
|
|
44
|
+
formatTooltipNumbers,
|
|
43
45
|
numberToString,
|
|
44
46
|
secondsToString,
|
|
45
47
|
totalArrivalTime,
|
|
@@ -52,6 +54,7 @@ import {
|
|
|
52
54
|
basicInfoStyles,
|
|
53
55
|
ChainImageContainer,
|
|
54
56
|
Chains,
|
|
57
|
+
ContainerInfoOutput,
|
|
55
58
|
Content,
|
|
56
59
|
EXPANDABLE_QUOTE_TRANSITION_DURATION,
|
|
57
60
|
FrameIcon,
|
|
@@ -162,6 +165,14 @@ export function Quote(props: QuoteProps) {
|
|
|
162
165
|
USD_VALUE_MIN_DECIMALS,
|
|
163
166
|
USD_VALUE_MAX_DECIMALS
|
|
164
167
|
),
|
|
168
|
+
realValue: formatTooltipNumbers(
|
|
169
|
+
index === 0 ? input.value : swap.fromAmount
|
|
170
|
+
),
|
|
171
|
+
realUsdValue: formatTooltipNumbers(
|
|
172
|
+
new BigNumber(swap.from.usdPrice ?? 0).multipliedBy(
|
|
173
|
+
swap.fromAmount
|
|
174
|
+
)
|
|
175
|
+
),
|
|
165
176
|
},
|
|
166
177
|
},
|
|
167
178
|
to: {
|
|
@@ -184,6 +195,10 @@ export function Quote(props: QuoteProps) {
|
|
|
184
195
|
USD_VALUE_MIN_DECIMALS,
|
|
185
196
|
USD_VALUE_MAX_DECIMALS
|
|
186
197
|
),
|
|
198
|
+
realValue: formatTooltipNumbers(swap.toAmount),
|
|
199
|
+
realUsdValue: formatTooltipNumbers(
|
|
200
|
+
new BigNumber(swap.to.usdPrice ?? 0).multipliedBy(swap.toAmount)
|
|
201
|
+
),
|
|
187
202
|
},
|
|
188
203
|
},
|
|
189
204
|
state: stepState,
|
|
@@ -291,27 +306,49 @@ export function Quote(props: QuoteProps) {
|
|
|
291
306
|
<FrameIcon>
|
|
292
307
|
<InfoIcon size={12} color="gray" />
|
|
293
308
|
</FrameIcon>
|
|
294
|
-
<
|
|
295
|
-
|
|
296
|
-
steps[0].from.token.displayName
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
309
|
+
<ContainerInfoOutput>
|
|
310
|
+
<BasicInfoOutput size="small" variant="body">
|
|
311
|
+
{`${roundedInput} ${steps[0].from.token.displayName} = `}
|
|
312
|
+
</BasicInfoOutput>
|
|
313
|
+
<Tooltip
|
|
314
|
+
content={formatTooltipNumbers(output.value)}
|
|
315
|
+
container={tooltipContainer}
|
|
316
|
+
open={!output.value ? false : undefined}>
|
|
317
|
+
<BasicInfoOutput size="small" variant="body">
|
|
318
|
+
|
|
319
|
+
{`${roundedOutput} ${
|
|
320
|
+
steps[steps.length - 1].to.token.displayName
|
|
321
|
+
}`}
|
|
322
|
+
</BasicInfoOutput>
|
|
323
|
+
</Tooltip>
|
|
324
|
+
</ContainerInfoOutput>
|
|
325
|
+
<Tooltip
|
|
326
|
+
content={formatTooltipNumbers(output.usdValue)}
|
|
327
|
+
container={tooltipContainer}
|
|
328
|
+
style={{
|
|
329
|
+
display: 'flex',
|
|
330
|
+
}}>
|
|
331
|
+
<Typography
|
|
332
|
+
color="$neutral600"
|
|
333
|
+
ml={2}
|
|
334
|
+
size="xsmall"
|
|
335
|
+
variant="body">
|
|
336
|
+
{`($${roundedOutputUsdValue})`}
|
|
337
|
+
</Typography>
|
|
338
|
+
</Tooltip>
|
|
308
339
|
</div>
|
|
309
340
|
)}
|
|
310
341
|
{type === 'list-item' && (
|
|
311
342
|
<TokenAmount
|
|
312
343
|
type="output"
|
|
313
344
|
direction="vertical"
|
|
314
|
-
|
|
345
|
+
tooltipContainer={tooltipContainer}
|
|
346
|
+
price={{
|
|
347
|
+
value: roundedOutput,
|
|
348
|
+
usdValue: roundedOutputUsdValue,
|
|
349
|
+
realValue: formatTooltipNumbers(output.value),
|
|
350
|
+
realUsdValue: formatTooltipNumbers(output.usdValue),
|
|
351
|
+
}}
|
|
315
352
|
token={{
|
|
316
353
|
displayName: steps[numberOfSteps - 1].to.token.displayName,
|
|
317
354
|
image: steps[numberOfSteps - 1].to.token.image,
|
|
@@ -402,6 +439,7 @@ export function Quote(props: QuoteProps) {
|
|
|
402
439
|
step={step}
|
|
403
440
|
hasSeparator={index !== steps.length - 1}
|
|
404
441
|
state={step.state}
|
|
442
|
+
tooltipContainer={tooltipContainer}
|
|
405
443
|
/>
|
|
406
444
|
);
|
|
407
445
|
})}
|
|
@@ -3,6 +3,8 @@ import type { PriceImpactWarningLevel, Step } from '@rango-dev/ui';
|
|
|
3
3
|
import { TokenAmount } from '@rango-dev/ui';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
6
|
+
import { getContainer } from '../../utils/common';
|
|
7
|
+
|
|
6
8
|
import { Container, separatorStyles } from './QuoteSummary.styles';
|
|
7
9
|
|
|
8
10
|
type PropTypes = {
|
|
@@ -14,13 +16,20 @@ type PropTypes = {
|
|
|
14
16
|
|
|
15
17
|
export function QuoteSummary(props: PropTypes) {
|
|
16
18
|
const { from, to, percentageChange, warningLevel } = props;
|
|
19
|
+
|
|
17
20
|
return (
|
|
18
21
|
<Container>
|
|
19
22
|
<TokenAmount
|
|
20
23
|
direction="horizontal"
|
|
21
24
|
label="Swap input"
|
|
22
25
|
type="input"
|
|
23
|
-
|
|
26
|
+
tooltipContainer={getContainer()}
|
|
27
|
+
price={{
|
|
28
|
+
value: from.price.value,
|
|
29
|
+
usdValue: from.price.usdValue,
|
|
30
|
+
realValue: from.price.realValue,
|
|
31
|
+
realUsdValue: from.price.realUsdValue,
|
|
32
|
+
}}
|
|
24
33
|
token={{
|
|
25
34
|
displayName: from.token.displayName,
|
|
26
35
|
image: from.token.image,
|
|
@@ -31,8 +40,14 @@ export function QuoteSummary(props: PropTypes) {
|
|
|
31
40
|
<TokenAmount
|
|
32
41
|
direction="horizontal"
|
|
33
42
|
label="Estimated output"
|
|
43
|
+
tooltipContainer={getContainer()}
|
|
34
44
|
type="output"
|
|
35
|
-
price={{
|
|
45
|
+
price={{
|
|
46
|
+
value: to.price.value,
|
|
47
|
+
usdValue: to.price.usdValue,
|
|
48
|
+
realValue: to.price.realValue,
|
|
49
|
+
realUsdValue: to.price.realUsdValue,
|
|
50
|
+
}}
|
|
36
51
|
token={{
|
|
37
52
|
displayName: to.token.displayName,
|
|
38
53
|
image: to.token.image,
|
|
@@ -20,7 +20,10 @@ export const getSteps = ({ swap, blockchains, ...args }: GetStep): Step[] => {
|
|
|
20
20
|
const hasAlreadyProceededToSign = swap.hasAlreadyProceededToSign !== false;
|
|
21
21
|
return swap.steps.map((step, index) => {
|
|
22
22
|
const amountToConvert =
|
|
23
|
-
index === 0
|
|
23
|
+
index === 0
|
|
24
|
+
? swap.inputAmount
|
|
25
|
+
: swap.steps[index - 1].outputAmount ||
|
|
26
|
+
swap.steps[index - 1].expectedOutputAmountHumanReadable;
|
|
24
27
|
return {
|
|
25
28
|
from: {
|
|
26
29
|
token: { displayName: step.fromSymbol, image: step.fromLogo ?? '' },
|
|
@@ -35,6 +38,7 @@ export const getSteps = ({ swap, blockchains, ...args }: GetStep): Step[] => {
|
|
|
35
38
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
36
39
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
37
40
|
),
|
|
41
|
+
realValue: amountToConvert,
|
|
38
42
|
},
|
|
39
43
|
},
|
|
40
44
|
to: {
|
|
@@ -50,6 +54,8 @@ export const getSteps = ({ swap, blockchains, ...args }: GetStep): Step[] => {
|
|
|
50
54
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
51
55
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
52
56
|
),
|
|
57
|
+
realValue:
|
|
58
|
+
step.outputAmount || step.expectedOutputAmountHumanReadable,
|
|
53
59
|
},
|
|
54
60
|
},
|
|
55
61
|
swapper: { displayName: step.swapperId, image: step.swapperLogo ?? '' },
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
useCopyToClipboard,
|
|
19
19
|
} from '@rango-dev/ui';
|
|
20
20
|
import { useWallets } from '@rango-dev/wallets-react';
|
|
21
|
+
import BigNumber from 'bignumber.js';
|
|
21
22
|
import { PendingSwapNetworkStatus } from 'rango-types';
|
|
22
23
|
import React, { useEffect, useRef, useState } from 'react';
|
|
23
24
|
import { useNavigate } from 'react-router-dom';
|
|
@@ -35,7 +36,9 @@ import {
|
|
|
35
36
|
import { useAppStore } from '../../store/AppStore';
|
|
36
37
|
import { useNotificationStore } from '../../store/notification';
|
|
37
38
|
import { useQuoteStore } from '../../store/quote';
|
|
39
|
+
import { getContainer } from '../../utils/common';
|
|
38
40
|
import {
|
|
41
|
+
formatTooltipNumbers,
|
|
39
42
|
numberToString,
|
|
40
43
|
secondsToString,
|
|
41
44
|
totalArrivalTime,
|
|
@@ -188,6 +191,16 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
188
191
|
USD_VALUE_MAX_DECIMALS
|
|
189
192
|
);
|
|
190
193
|
|
|
194
|
+
const realOutputUsdValue = outputAmount
|
|
195
|
+
? formatTooltipNumbers(
|
|
196
|
+
new BigNumber(outputAmount).multipliedBy(lastStep.toUsdPrice || 0)
|
|
197
|
+
)
|
|
198
|
+
: '';
|
|
199
|
+
|
|
200
|
+
const realInputUsdValue = formatTooltipNumbers(
|
|
201
|
+
new BigNumber(swap.inputAmount).multipliedBy(firstStep.fromUsdPrice || 0)
|
|
202
|
+
);
|
|
203
|
+
|
|
191
204
|
const percentageChange = getPriceImpact(inputUsdValue, outputUsdValue);
|
|
192
205
|
|
|
193
206
|
const completeModalDesc =
|
|
@@ -280,7 +293,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
280
293
|
</div>
|
|
281
294
|
<div className={rowStyles()}>
|
|
282
295
|
<Typography variant="label" size="large" color="neutral700">
|
|
283
|
-
{`${i18n.t('Created at')}:`}
|
|
296
|
+
{`${i18n.t(swap.finishTime ? 'Finished at' : 'Created at')}:`}
|
|
284
297
|
</Typography>
|
|
285
298
|
<Typography variant="label" size="small" color="neutral700">
|
|
286
299
|
{swapDate}
|
|
@@ -307,6 +320,8 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
307
320
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
308
321
|
),
|
|
309
322
|
usdValue: inputUsdValue,
|
|
323
|
+
realUsdValue: realInputUsdValue,
|
|
324
|
+
realValue: swap.inputAmount,
|
|
310
325
|
},
|
|
311
326
|
token: {
|
|
312
327
|
displayName: steps[0].from.token.displayName,
|
|
@@ -325,6 +340,8 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
325
340
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
326
341
|
),
|
|
327
342
|
usdValue: outputUsdValue,
|
|
343
|
+
realUsdValue: realOutputUsdValue,
|
|
344
|
+
realValue: outputAmount,
|
|
328
345
|
},
|
|
329
346
|
token: {
|
|
330
347
|
displayName: steps[numberOfSteps - 1].to.token.displayName,
|
|
@@ -368,6 +385,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
368
385
|
hasSeparator={index !== 0}
|
|
369
386
|
tabIndex={key}
|
|
370
387
|
isFocused={isFocused}
|
|
388
|
+
tooltipContainer={getContainer()}
|
|
371
389
|
/>
|
|
372
390
|
);
|
|
373
391
|
})}
|
|
@@ -393,6 +411,8 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
393
411
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
394
412
|
)}
|
|
395
413
|
usdValue={outputUsdValue}
|
|
414
|
+
realUsdValue={realOutputUsdValue}
|
|
415
|
+
realValue={formatTooltipNumbers(outputAmount)}
|
|
396
416
|
percentageChange={numberToString(
|
|
397
417
|
percentageChange,
|
|
398
418
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
@@ -13,6 +13,7 @@ import React from 'react';
|
|
|
13
13
|
import { useNavigate } from 'react-router-dom';
|
|
14
14
|
|
|
15
15
|
import { RANGO_SWAP_BOX_ID } from '../../constants';
|
|
16
|
+
import { getContainer } from '../../utils/common';
|
|
16
17
|
|
|
17
18
|
export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
|
|
18
19
|
const {
|
|
@@ -21,6 +22,8 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
|
|
|
21
22
|
status,
|
|
22
23
|
priceValue,
|
|
23
24
|
usdValue,
|
|
25
|
+
realUsdValue,
|
|
26
|
+
realValue,
|
|
24
27
|
token,
|
|
25
28
|
chain,
|
|
26
29
|
percentageChange,
|
|
@@ -38,11 +41,14 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
|
|
|
38
41
|
<MessageBox type="success" title={i18n.t('Swap Successful')}>
|
|
39
42
|
<TokenAmount
|
|
40
43
|
direction="vertical"
|
|
44
|
+
tooltipContainer={getContainer()}
|
|
41
45
|
type="output"
|
|
42
46
|
centerAlign={true}
|
|
43
47
|
price={{
|
|
44
48
|
value: priceValue,
|
|
45
49
|
usdValue,
|
|
50
|
+
realUsdValue,
|
|
51
|
+
realValue,
|
|
46
52
|
}}
|
|
47
53
|
token={token}
|
|
48
54
|
chain={chain}
|
|
@@ -4,7 +4,8 @@ import { i18n } from '@lingui/core';
|
|
|
4
4
|
import { Divider, SwapListItem, Typography } from '@rango-dev/ui';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { getContainer } from '../../utils/common';
|
|
8
|
+
import { formatTooltipNumbers, numberToString } from '../../utils/numbers';
|
|
8
9
|
|
|
9
10
|
import { Group, groupStyles, SwapList, Time } from './SwapsGroup.styles';
|
|
10
11
|
|
|
@@ -21,7 +22,7 @@ export function SwapsGroup(props: PropTypes) {
|
|
|
21
22
|
swaps,
|
|
22
23
|
},
|
|
23
24
|
{
|
|
24
|
-
title: '
|
|
25
|
+
title: 'This month',
|
|
25
26
|
swaps,
|
|
26
27
|
},
|
|
27
28
|
];
|
|
@@ -75,6 +76,7 @@ export function SwapsGroup(props: PropTypes) {
|
|
|
75
76
|
<SwapList>
|
|
76
77
|
{group.swaps.map((swap) => {
|
|
77
78
|
const firstStep = swap.steps[0];
|
|
79
|
+
|
|
78
80
|
const lastStep = swap.steps[swap.steps.length - 1];
|
|
79
81
|
return (
|
|
80
82
|
<React.Fragment key={swap.requestId}>
|
|
@@ -84,6 +86,7 @@ export function SwapsGroup(props: PropTypes) {
|
|
|
84
86
|
status={swap.status}
|
|
85
87
|
onClick={onSwapClick}
|
|
86
88
|
onlyShowTime={group.title === 'Today'}
|
|
89
|
+
tooltipContainer={getContainer()}
|
|
87
90
|
swapTokenData={{
|
|
88
91
|
from: {
|
|
89
92
|
token: {
|
|
@@ -93,7 +96,7 @@ export function SwapsGroup(props: PropTypes) {
|
|
|
93
96
|
blockchain: {
|
|
94
97
|
image: firstStep.fromBlockchainLogo || '',
|
|
95
98
|
},
|
|
96
|
-
amount:
|
|
99
|
+
amount: swap.inputAmount,
|
|
97
100
|
},
|
|
98
101
|
to: {
|
|
99
102
|
token: {
|
|
@@ -103,11 +106,14 @@ export function SwapsGroup(props: PropTypes) {
|
|
|
103
106
|
blockchain: {
|
|
104
107
|
image: lastStep.toBlockchainLogo || '',
|
|
105
108
|
},
|
|
106
|
-
amount:
|
|
107
|
-
lastStep.outputAmount ||
|
|
109
|
+
amount: numberToString(
|
|
110
|
+
lastStep.outputAmount ||
|
|
111
|
+
lastStep.expectedOutputAmountHumanReadable ||
|
|
112
|
+
''
|
|
108
113
|
),
|
|
109
|
-
|
|
110
|
-
lastStep.
|
|
114
|
+
realAmount: formatTooltipNumbers(
|
|
115
|
+
lastStep.outputAmount ||
|
|
116
|
+
lastStep.expectedOutputAmountHumanReadable
|
|
111
117
|
),
|
|
112
118
|
},
|
|
113
119
|
}}
|
package/src/constants/routing.ts
CHANGED
package/src/pages/Home.tsx
CHANGED
|
@@ -22,7 +22,8 @@ import { useAppStore } from '../store/AppStore';
|
|
|
22
22
|
import { useQuoteStore } from '../store/quote';
|
|
23
23
|
import { useUiStore } from '../store/ui';
|
|
24
24
|
import { useWalletsStore } from '../store/wallets';
|
|
25
|
-
import {
|
|
25
|
+
import { getContainer } from '../utils/common';
|
|
26
|
+
import { formatTooltipNumbers, numberToString } from '../utils/numbers';
|
|
26
27
|
import { getPriceImpact, getPriceImpactLevel } from '../utils/quote';
|
|
27
28
|
import { canComputePriceImpact, getSwapButtonState } from '../utils/swap';
|
|
28
29
|
import { formatBalance, isFetchingBalance } from '../utils/wallets';
|
|
@@ -192,6 +193,9 @@ export function Home() {
|
|
|
192
193
|
USD_VALUE_MIN_DECIMALS,
|
|
193
194
|
USD_VALUE_MAX_DECIMALS
|
|
194
195
|
),
|
|
196
|
+
realUsdValue: priceImpactInputCanNotBeComputed
|
|
197
|
+
? undefined
|
|
198
|
+
: formatTooltipNumbers(inputUsdValue),
|
|
195
199
|
error: priceImpactInputCanNotBeComputed
|
|
196
200
|
? errorMessages().unknownPriceError.impactTitle
|
|
197
201
|
: undefined,
|
|
@@ -199,6 +203,7 @@ export function Home() {
|
|
|
199
203
|
disabled={fetchMetaStatus === 'failed'}
|
|
200
204
|
loading={fetchMetaStatus === 'loading'}
|
|
201
205
|
loadingBalance={fetchingBalance}
|
|
206
|
+
tooltipContainer={getContainer()}
|
|
202
207
|
onSelectMaxBalance={() => {
|
|
203
208
|
if (fromTokenFormattedBalance !== '0') {
|
|
204
209
|
setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
@@ -239,6 +244,10 @@ export function Home() {
|
|
|
239
244
|
USD_VALUE_MIN_DECIMALS,
|
|
240
245
|
USD_VALUE_MAX_DECIMALS
|
|
241
246
|
),
|
|
247
|
+
realValue: formatTooltipNumbers(outputAmount),
|
|
248
|
+
realUsdValue: priceImpactOutputCanNotBeComputed
|
|
249
|
+
? undefined
|
|
250
|
+
: formatTooltipNumbers(outputUsdValue),
|
|
242
251
|
error: priceImpactOutputCanNotBeComputed
|
|
243
252
|
? errorMessages().unknownPriceError.impactTitle
|
|
244
253
|
: undefined,
|
|
@@ -246,6 +255,7 @@ export function Home() {
|
|
|
246
255
|
onClickToken={() => navigate(navigationRoutes.toSwap)}
|
|
247
256
|
disabled={fetchMetaStatus === 'failed'}
|
|
248
257
|
loading={fetchMetaStatus === 'loading'}
|
|
258
|
+
tooltipContainer={getContainer()}
|
|
249
259
|
/>
|
|
250
260
|
</InputsContainer>
|
|
251
261
|
<div className="quote__container">
|
package/src/utils/date.ts
CHANGED
|
@@ -19,39 +19,53 @@ export const groupSwapsByDate: GroupBy = (swaps) => {
|
|
|
19
19
|
},
|
|
20
20
|
],
|
|
21
21
|
[
|
|
22
|
-
'
|
|
22
|
+
'week',
|
|
23
23
|
{
|
|
24
|
-
title: '
|
|
24
|
+
title: 'This week',
|
|
25
25
|
swaps: [],
|
|
26
26
|
},
|
|
27
27
|
],
|
|
28
28
|
[
|
|
29
|
-
'
|
|
29
|
+
'month',
|
|
30
30
|
{
|
|
31
|
-
title: '
|
|
31
|
+
title: 'This month',
|
|
32
32
|
swaps: [],
|
|
33
33
|
},
|
|
34
34
|
],
|
|
35
35
|
[
|
|
36
|
-
'
|
|
36
|
+
'year',
|
|
37
37
|
{
|
|
38
|
-
title: '
|
|
38
|
+
title: 'This year',
|
|
39
39
|
swaps: [],
|
|
40
40
|
},
|
|
41
41
|
],
|
|
42
42
|
]);
|
|
43
43
|
|
|
44
|
+
function addYearsToOutput(key: string, swap: PendingSwap) {
|
|
45
|
+
if (!output.has(key)) {
|
|
46
|
+
output.set(key, {
|
|
47
|
+
title: key,
|
|
48
|
+
swaps: [],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
output.get(key)?.swaps.push(swap);
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
const now = dayjs();
|
|
45
55
|
swaps.forEach((swap) => {
|
|
46
|
-
const
|
|
56
|
+
const time = Number(swap.creationTime);
|
|
57
|
+
const swapDate = dayjs(time);
|
|
47
58
|
if (now.isSame(swapDate, 'day')) {
|
|
48
59
|
output.get('today')?.swaps.push(swap);
|
|
60
|
+
} else if (now.isSame(swapDate, 'week')) {
|
|
61
|
+
output.get('week')?.swaps.push(swap);
|
|
49
62
|
} else if (now.isSame(swapDate, 'month')) {
|
|
50
63
|
output.get('month')?.swaps.push(swap);
|
|
51
64
|
} else if (now.isSame(swapDate, 'year')) {
|
|
52
65
|
output.get('year')?.swaps.push(swap);
|
|
53
66
|
} else {
|
|
54
|
-
|
|
67
|
+
const year = new Date(time).getFullYear().toString();
|
|
68
|
+
addYearsToOutput(year, swap);
|
|
55
69
|
}
|
|
56
70
|
});
|
|
57
71
|
|
package/src/utils/numbers.ts
CHANGED
|
@@ -4,8 +4,7 @@ import type { BestRouteResponse } from 'rango-sdk';
|
|
|
4
4
|
|
|
5
5
|
import { BigNumber } from 'bignumber.js';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
(p * 100).toFixed(fractions);
|
|
7
|
+
import { TOOLTIP_DECIMALS } from '../constants/routing';
|
|
9
8
|
|
|
10
9
|
export const secondsToString = (s: number): string => {
|
|
11
10
|
const seconds = (s % 60).toString().padStart(2, '0');
|
|
@@ -96,13 +95,6 @@ export const numberToString = (
|
|
|
96
95
|
);
|
|
97
96
|
};
|
|
98
97
|
|
|
99
|
-
export const convertBigNumberToHex = (
|
|
100
|
-
value: BigNumber,
|
|
101
|
-
decimals: number
|
|
102
|
-
): string => {
|
|
103
|
-
return '0x' + value.shiftedBy(decimals).toString(16);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
98
|
export const uint8ArrayToHex = (buffer: Uint8Array): string => {
|
|
107
99
|
// buffer is an ArrayBuffer
|
|
108
100
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -110,43 +102,6 @@ export const uint8ArrayToHex = (buffer: Uint8Array): string => {
|
|
|
110
102
|
return [...buffer].map((x) => x.toString(16).padStart(2, '0')).join('');
|
|
111
103
|
};
|
|
112
104
|
|
|
113
|
-
export function dollarToConciseString(num: number | undefined): string {
|
|
114
|
-
if (!num) {
|
|
115
|
-
return '-';
|
|
116
|
-
}
|
|
117
|
-
if (num < 1) {
|
|
118
|
-
return ' < 1$';
|
|
119
|
-
}
|
|
120
|
-
if (num < 1000) {
|
|
121
|
-
return numberToString(new BigNumber(num)) + '$';
|
|
122
|
-
}
|
|
123
|
-
if (num < 10_000) {
|
|
124
|
-
return parseInt((num / 100).toString()) / 10 + 'K';
|
|
125
|
-
}
|
|
126
|
-
if (num < 1_000_000) {
|
|
127
|
-
return parseInt((num / 1000).toString()) + 'K';
|
|
128
|
-
}
|
|
129
|
-
if (num < 100_000_000) {
|
|
130
|
-
return parseInt((num / 100000).toString()) / 10 + 'M';
|
|
131
|
-
}
|
|
132
|
-
return parseInt((num / 1000000).toString()) + 'M';
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function removeExtraDecimals(num: string, maxDecimals: number): string {
|
|
136
|
-
try {
|
|
137
|
-
if (!num.includes('.')) {
|
|
138
|
-
return num;
|
|
139
|
-
}
|
|
140
|
-
const [b, f] = num.split('.');
|
|
141
|
-
if (f && f.length > maxDecimals) {
|
|
142
|
-
return `${b}.${f.substring(0, maxDecimals)}`;
|
|
143
|
-
}
|
|
144
|
-
return num;
|
|
145
|
-
} catch (e) {
|
|
146
|
-
return num;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
105
|
export const totalArrivalTime = (
|
|
151
106
|
data: { estimatedTimeInSeconds: number | null }[] | undefined
|
|
152
107
|
) => data?.reduce((a, b) => a + (b.estimatedTimeInSeconds ?? 0), 0) || 0;
|
|
@@ -167,16 +122,11 @@ export const isPositiveNumber = (text?: string) =>
|
|
|
167
122
|
!!text && parseFloat(text) > 0;
|
|
168
123
|
10;
|
|
169
124
|
|
|
170
|
-
export function
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
} // Return the original string if it's not a valid number
|
|
178
|
-
|
|
179
|
-
const multiplier = Math.pow(10, maxDecimalPlaces);
|
|
180
|
-
const roundedNumber = Math.round(number * multiplier) / multiplier;
|
|
181
|
-
return roundedNumber.toString();
|
|
125
|
+
export function formatTooltipNumbers(
|
|
126
|
+
number: BigNumber | string | number | null | undefined
|
|
127
|
+
) {
|
|
128
|
+
return numberToString(number, TOOLTIP_DECIMALS, TOOLTIP_DECIMALS).replace(
|
|
129
|
+
/(?:\.0*|(\.\d+?)0*)$/,
|
|
130
|
+
'$1'
|
|
131
|
+
);
|
|
182
132
|
}
|