@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.
Files changed (33) hide show
  1. package/dist/components/Quote/Quote.d.ts.map +1 -1
  2. package/dist/components/Quote/Quote.styles.d.ts +157 -0
  3. package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
  4. package/dist/components/Quote/QuoteSummary.d.ts.map +1 -1
  5. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  6. package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
  7. package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
  8. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +2 -0
  9. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
  10. package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
  11. package/dist/constants/routing.d.ts +1 -0
  12. package/dist/constants/routing.d.ts.map +1 -1
  13. package/dist/index.js +1 -1
  14. package/dist/index.js.map +3 -3
  15. package/dist/pages/Home.d.ts.map +1 -1
  16. package/dist/utils/date.d.ts.map +1 -1
  17. package/dist/utils/numbers.d.ts +1 -5
  18. package/dist/utils/numbers.d.ts.map +1 -1
  19. package/dist/utils/time.d.ts.map +1 -1
  20. package/package.json +3 -3
  21. package/src/components/Quote/Quote.styles.ts +5 -1
  22. package/src/components/Quote/Quote.tsx +53 -15
  23. package/src/components/Quote/QuoteSummary.tsx +17 -2
  24. package/src/components/SwapDetails/SwapDetails.helpers.tsx +7 -1
  25. package/src/components/SwapDetails/SwapDetails.tsx +21 -1
  26. package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +6 -0
  27. package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +2 -0
  28. package/src/components/SwapsGroup/SwapsGroup.tsx +13 -7
  29. package/src/constants/routing.ts +2 -0
  30. package/src/pages/Home.tsx +11 -1
  31. package/src/utils/date.ts +22 -8
  32. package/src/utils/numbers.ts +8 -58
  33. package/src/utils/time.ts +25 -69
@@ -1 +1 @@
1
- {"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AA8C3D,wBAAgB,IAAI,sBAgOnB"}
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"}
@@ -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,OAqD9B,CAAC"}
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"}
@@ -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 limitDecimalPlaces(numberString: string, maxDecimalPlaces?: number): string;
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;AAEzC,eAAO,MAAM,eAAe,MAAO,MAAM,yBAAkB,MAC7B,CAAC;AAE/B,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,qBAAqB,UACzB,SAAS,YACN,MAAM,KACf,MAEF,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,UAAU,KAAG,MAKpD,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAoBrE;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAa5E;AAED,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,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,gBAAgB,SAAI,GACnB,MAAM,CASR"}
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"}
@@ -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;AAW/C,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAqDrD;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,WAAW,UAUnD"}
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.1",
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.0",
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
- <BasicInfoOutput size="small" variant="body">
295
- {`${roundedInput} ${
296
- steps[0].from.token.displayName
297
- } = ${roundedOutput} ${
298
- steps[steps.length - 1].to.token.displayName
299
- }`}
300
- </BasicInfoOutput>
301
- <Typography
302
- color="$neutral600"
303
- ml={2}
304
- size="xsmall"
305
- variant="body">
306
- {`($${roundedOutputUsdValue})`}
307
- </Typography>
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
+ &nbsp;
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
- price={{ value: roundedOutput, usdValue: roundedOutputUsdValue }}
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
- price={{ value: from.price.value, usdValue: from.price.usdValue }}
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={{ value: to.price.value, usdValue: to.price.usdValue }}
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 ? swap.inputAmount : swap.steps[index - 1].outputAmount;
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}
@@ -24,7 +24,9 @@ export interface CompleteModalPropTypes {
24
24
  onClose: () => void;
25
25
  status: 'success' | 'failed';
26
26
  priceValue: string;
27
+ realValue: string;
27
28
  usdValue: string;
29
+ realUsdValue: string;
28
30
  percentageChange: string;
29
31
  chain: {
30
32
  displayName?: string;
@@ -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 { limitDecimalPlaces } from '../../utils/numbers';
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: 'Last month',
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: limitDecimalPlaces(swap.inputAmount),
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: limitDecimalPlaces(
107
- lastStep.outputAmount || ''
109
+ amount: numberToString(
110
+ lastStep.outputAmount ||
111
+ lastStep.expectedOutputAmountHumanReadable ||
112
+ ''
108
113
  ),
109
- estimatedAmount: limitDecimalPlaces(
110
- lastStep.expectedOutputAmountHumanReadable || ''
114
+ realAmount: formatTooltipNumbers(
115
+ lastStep.outputAmount ||
116
+ lastStep.expectedOutputAmountHumanReadable
111
117
  ),
112
118
  },
113
119
  }}
@@ -15,3 +15,5 @@ export const PERCENTAGE_CHANGE_MAX_DECIMALS = 2;
15
15
 
16
16
  export const BALANCE_MIN_DECIMALS = 8;
17
17
  export const BALANCE_MAX_DECIMALS = 8;
18
+
19
+ export const TOOLTIP_DECIMALS = 12;
@@ -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 { numberToString } from '../utils/numbers';
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
- 'month',
22
+ 'week',
23
23
  {
24
- title: 'Last month',
24
+ title: 'This week',
25
25
  swaps: [],
26
26
  },
27
27
  ],
28
28
  [
29
- 'year',
29
+ 'month',
30
30
  {
31
- title: 'Last year',
31
+ title: 'This month',
32
32
  swaps: [],
33
33
  },
34
34
  ],
35
35
  [
36
- 'history',
36
+ 'year',
37
37
  {
38
- title: 'History',
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 swapDate = dayjs(Number(swap.creationTime));
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
- output.get('history')?.swaps.push(swap);
67
+ const year = new Date(time).getFullYear().toString();
68
+ addYearsToOutput(year, swap);
55
69
  }
56
70
  });
57
71
 
@@ -4,8 +4,7 @@ import type { BestRouteResponse } from 'rango-sdk';
4
4
 
5
5
  import { BigNumber } from 'bignumber.js';
6
6
 
7
- export const percentToString = (p: number, fractions = 0): string =>
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 limitDecimalPlaces(
171
- numberString: string,
172
- maxDecimalPlaces = 4
173
- ): string {
174
- const number = parseFloat(numberString);
175
- if (isNaN(number)) {
176
- return numberString;
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
  }