@lifi/widget 1.18.9 → 1.19.0

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 (155) hide show
  1. package/App.js +3 -3
  2. package/cjs/App.js +3 -3
  3. package/cjs/components/ActiveSwaps/ActiveSwaps.js +1 -1
  4. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +0 -14
  5. package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +1 -9
  6. package/cjs/components/AppContainer.d.ts +11 -1
  7. package/cjs/components/AppContainer.js +3 -6
  8. package/cjs/components/BottomSheet/BottomSheet.js +9 -32
  9. package/cjs/components/BottomSheet/types.d.ts +2 -2
  10. package/cjs/components/Card/Card.js +1 -1
  11. package/cjs/components/Card/CardHeader.d.ts +1 -1
  12. package/cjs/components/ChainSelect/ChainSelect.js +1 -1
  13. package/cjs/components/ChainSelect/useChainSelect.js +2 -4
  14. package/cjs/components/Dialog.d.ts +22 -1
  15. package/cjs/components/Dialog.js +23 -20
  16. package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +19 -22
  17. package/cjs/components/Header/NavigationHeader.js +1 -1
  18. package/cjs/components/Header/WalletHeader.js +2 -2
  19. package/cjs/components/PoweredBy/PoweredBy.js +1 -1
  20. package/cjs/components/ProgressToNextUpdate/ProgressToNextUpdate.js +1 -1
  21. package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +6 -6
  22. package/cjs/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
  23. package/cjs/components/SendToWallet/SendToWallet.d.ts +1 -0
  24. package/cjs/components/SendToWallet/SendToWallet.js +10 -5
  25. package/cjs/components/SendToWallet/SendToWalletButton.js +2 -2
  26. package/cjs/components/Step/StepProcess.js +1 -1
  27. package/cjs/components/SwapButton/SwapButton.js +4 -4
  28. package/cjs/components/SwapButton/types.d.ts +2 -0
  29. package/cjs/components/SwapInput/SwapInput.js +6 -2
  30. package/cjs/components/SwapInput/SwapInputAdornment.js +4 -2
  31. package/cjs/components/SwapInput/SwapInputAdornment.style.js +1 -13
  32. package/cjs/components/SwapRouteCard/SwapRouteCard.js +7 -6
  33. package/cjs/components/SwapRoutes/SwapRoutes.js +4 -4
  34. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +1 -0
  35. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +17 -12
  36. package/cjs/components/SwapRoutes/useSetRecommendedRoute.d.ts +2 -0
  37. package/cjs/components/SwapRoutes/useSetRecommendedRoute.js +13 -0
  38. package/cjs/components/TokenList/TokenList.js +9 -6
  39. package/cjs/config/theme.js +22 -8
  40. package/cjs/config/version.d.ts +1 -1
  41. package/cjs/config/version.js +1 -1
  42. package/cjs/hooks/index.d.ts +1 -0
  43. package/cjs/hooks/index.js +1 -0
  44. package/cjs/hooks/useExpandableVariant.d.ts +1 -0
  45. package/cjs/hooks/useExpandableVariant.js +14 -0
  46. package/cjs/hooks/useGasSufficiency.d.ts +3 -2
  47. package/cjs/hooks/useGasSufficiency.js +50 -26
  48. package/cjs/hooks/useSwapRoutes.js +4 -2
  49. package/cjs/hooks/useTokenBalance.js +2 -2
  50. package/cjs/i18n/en/translation.json +8 -7
  51. package/cjs/i18n/index.d.ts +6 -5
  52. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -4
  53. package/cjs/pages/MainPage/MainPage.js +3 -3
  54. package/cjs/pages/SelectWalletPage/SelectWalletPage.js +1 -1
  55. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
  56. package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
  57. package/cjs/pages/SwapPage/StatusBottomSheet.js +4 -4
  58. package/cjs/pages/SwapPage/SwapPage.js +4 -4
  59. package/cjs/providers/SwapFormProvider/SwapFormProvider.js +3 -2
  60. package/cjs/providers/SwapFormProvider/URLSearchParamsBuilder.d.ts +1 -0
  61. package/cjs/providers/SwapFormProvider/URLSearchParamsBuilder.js +46 -0
  62. package/cjs/providers/SwapFormProvider/types.d.ts +4 -4
  63. package/cjs/providers/SwapFormProvider/types.js +2 -2
  64. package/cjs/providers/WalletProvider/WalletFormUpdate.d.ts +5 -0
  65. package/cjs/providers/WalletProvider/WalletFormUpdate.js +64 -0
  66. package/cjs/providers/WalletProvider/WalletProvider.js +3 -58
  67. package/cjs/providers/WidgetProvider/WidgetProvider.js +12 -5
  68. package/cjs/stores/routes/index.d.ts +1 -1
  69. package/cjs/stores/routes/index.js +1 -1
  70. package/cjs/stores/routes/types.d.ts +4 -4
  71. package/cjs/stores/routes/useRecommendedRouteStore.d.ts +4 -0
  72. package/cjs/stores/routes/{useSelectedRouteStore.js → useRecommendedRouteStore.js} +4 -4
  73. package/cjs/stores/routes/useRouteExecutionStore.js +9 -2
  74. package/cjs/types/widget.d.ts +1 -0
  75. package/components/ActiveSwaps/ActiveSwaps.js +3 -3
  76. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +0 -14
  77. package/components/ActiveSwaps/ActiveSwaps.style.js +1 -9
  78. package/components/AppContainer.d.ts +11 -1
  79. package/components/AppContainer.js +2 -4
  80. package/components/BottomSheet/BottomSheet.js +9 -32
  81. package/components/BottomSheet/types.d.ts +2 -2
  82. package/components/Card/Card.js +1 -1
  83. package/components/Card/CardHeader.d.ts +1 -1
  84. package/components/ChainSelect/ChainSelect.js +1 -1
  85. package/components/ChainSelect/useChainSelect.js +2 -4
  86. package/components/Dialog.d.ts +22 -1
  87. package/components/Dialog.js +22 -19
  88. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +21 -24
  89. package/components/Header/NavigationHeader.js +2 -2
  90. package/components/Header/WalletHeader.js +2 -2
  91. package/components/PoweredBy/PoweredBy.js +1 -1
  92. package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +1 -1
  93. package/components/ReverseTokensButton/ReverseTokensButton.js +6 -6
  94. package/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
  95. package/components/SendToWallet/SendToWallet.d.ts +1 -0
  96. package/components/SendToWallet/SendToWallet.js +9 -5
  97. package/components/SendToWallet/SendToWalletButton.js +2 -2
  98. package/components/Step/StepProcess.js +1 -1
  99. package/components/SwapButton/SwapButton.js +4 -4
  100. package/components/SwapButton/types.d.ts +2 -0
  101. package/components/SwapInput/SwapInput.js +6 -2
  102. package/components/SwapInput/SwapInputAdornment.js +4 -2
  103. package/components/SwapInput/SwapInputAdornment.style.js +2 -14
  104. package/components/SwapRouteCard/SwapRouteCard.js +8 -7
  105. package/components/SwapRoutes/SwapRoutes.js +4 -4
  106. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +1 -0
  107. package/components/SwapRoutes/SwapRoutesExpanded.js +16 -12
  108. package/components/SwapRoutes/useSetRecommendedRoute.d.ts +2 -0
  109. package/components/SwapRoutes/useSetRecommendedRoute.js +9 -0
  110. package/components/TokenList/TokenList.js +9 -6
  111. package/config/theme.js +22 -8
  112. package/config/version.d.ts +1 -1
  113. package/config/version.js +1 -1
  114. package/hooks/index.d.ts +1 -0
  115. package/hooks/index.js +1 -0
  116. package/hooks/useExpandableVariant.d.ts +1 -0
  117. package/hooks/useExpandableVariant.js +10 -0
  118. package/hooks/useGasSufficiency.d.ts +3 -2
  119. package/hooks/useGasSufficiency.js +50 -26
  120. package/hooks/useSwapRoutes.js +4 -2
  121. package/hooks/useTokenBalance.js +2 -2
  122. package/i18n/en/translation.json +8 -7
  123. package/i18n/index.d.ts +6 -5
  124. package/package.json +11 -11
  125. package/pages/ActiveSwapsPage/ActiveSwapsPage.js +24 -7
  126. package/pages/MainPage/MainPage.js +3 -3
  127. package/pages/SelectWalletPage/SelectWalletPage.js +1 -1
  128. package/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
  129. package/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
  130. package/pages/SwapPage/StatusBottomSheet.js +4 -4
  131. package/pages/SwapPage/SwapPage.js +5 -5
  132. package/providers/SwapFormProvider/SwapFormProvider.js +4 -3
  133. package/providers/SwapFormProvider/URLSearchParamsBuilder.d.ts +1 -0
  134. package/providers/SwapFormProvider/URLSearchParamsBuilder.js +42 -0
  135. package/providers/SwapFormProvider/types.d.ts +4 -4
  136. package/providers/SwapFormProvider/types.js +2 -2
  137. package/providers/WalletProvider/WalletFormUpdate.d.ts +5 -0
  138. package/providers/WalletProvider/WalletFormUpdate.js +60 -0
  139. package/providers/WalletProvider/WalletProvider.js +5 -60
  140. package/providers/WidgetProvider/WidgetProvider.js +12 -5
  141. package/stores/routes/index.d.ts +1 -1
  142. package/stores/routes/index.js +1 -1
  143. package/stores/routes/types.d.ts +4 -4
  144. package/stores/routes/useRecommendedRouteStore.d.ts +4 -0
  145. package/stores/routes/useRecommendedRouteStore.js +9 -0
  146. package/stores/routes/useRouteExecutionStore.js +9 -2
  147. package/tsconfig.cjs.tsbuildinfo +1 -1
  148. package/types/widget.d.ts +1 -0
  149. package/cjs/components/SwapRoutes/useSetSelectedRoute.d.ts +0 -2
  150. package/cjs/components/SwapRoutes/useSetSelectedRoute.js +0 -13
  151. package/cjs/stores/routes/useSelectedRouteStore.d.ts +0 -4
  152. package/components/SwapRoutes/useSetSelectedRoute.d.ts +0 -2
  153. package/components/SwapRoutes/useSetSelectedRoute.js +0 -9
  154. package/stores/routes/useSelectedRouteStore.d.ts +0 -4
  155. package/stores/routes/useSelectedRouteStore.js +0 -9
@@ -1,20 +1,8 @@
1
1
  import { Button as MuiButton } from '@mui/material';
2
- import { lighten, styled } from '@mui/material/styles';
2
+ import { styled } from '@mui/material/styles';
3
3
  export const Button = styled(MuiButton)(({ theme }) => ({
4
- borderColor: theme.palette.mode === 'light'
5
- ? theme.palette.grey[300]
6
- : theme.palette.grey[800],
7
- color: theme.palette.text.secondary,
8
- padding: theme.spacing(0.125, 1, 0.375, 1),
4
+ padding: theme.spacing(0.5, 1, 0.625, 1),
9
5
  lineHeight: 1,
10
6
  fontSize: '0.875rem',
11
7
  minWidth: 'unset',
12
- '&:hover': {
13
- color: theme.palette.mode === 'light'
14
- ? theme.palette.primary.main
15
- : theme.palette.text.primary,
16
- borderColor: theme.palette.mode === 'light'
17
- ? lighten(theme.palette.primary.main, 0.5)
18
- : theme.palette.text.secondary,
19
- },
20
8
  }));
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { AccessTime as AccessTimeIcon, EvStationOutlined as EvStationIcon, ExpandLess as ExpandLessIcon, ExpandMore as ExpandMoreIcon, LayersOutlined as LayersIcon, } from '@mui/icons-material';
14
- import { Box, Collapse, Typography } from '@mui/material';
14
+ import { Box, Collapse, Tooltip, Typography } from '@mui/material';
15
15
  import { useState } from 'react';
16
16
  import { useTranslation } from 'react-i18next';
17
17
  import { Card } from '../Card';
@@ -31,15 +31,16 @@ export const SwapRouteCard = (_a) => {
31
31
  e.stopPropagation();
32
32
  setCardExpanded((expanded) => !expanded);
33
33
  };
34
- return (_jsxs(Card, Object.assign({ dense: variant === 'dense', variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2 }, { children: [_jsx(Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })), variant === 'stretched' ? (_jsx(SwapRouteCardEssentials, { route: route })) : null] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center" }, { children: [_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), step: variant === 'stretched' ? route.steps[0] : undefined }), variant === 'stretched' && !expanded ? (_jsx(IconButton, Object.assign({ onClick: handleExpand, size: "small" }, { children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) }))) : null] })), _jsx(Collapse, Object.assign({ mountOnEnter: true, unmountOnExit: true, in: cardExpanded }, { children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) })), variant !== 'stretched' ? (_jsx(SwapRouteCardEssentials, { route: route, dense: true })) : null] })));
34
+ return (_jsxs(Card, Object.assign({ dense: variant === 'dense', variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2 }, { children: [_jsx(Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })), variant === 'stretched' ? (_jsx(SwapRouteCardEssentials, { route: route })) : null] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center" }, { children: [_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), step: variant === 'stretched' ? route.steps[0] : undefined }), variant === 'stretched' && !expanded ? (_jsx(IconButton, Object.assign({ onClick: handleExpand, size: "small" }, { children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) }))) : null] })), _jsx(Collapse, Object.assign({ timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true }, { children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) })), variant !== 'stretched' ? (_jsx(SwapRouteCardEssentials, { route: route, dense: true })) : null] })));
35
35
  };
36
36
  export const SwapRouteCardEssentials = ({ route, dense }) => {
37
37
  var _a;
38
38
  const { t } = useTranslation();
39
- const executionTime = (route.steps
39
+ const executionTimeMinutes = Math.ceil(route.steps
40
40
  .map((step) => step.estimate.executionDuration)
41
- .reduce((duration, x) => duration + x) / 60).toFixed(0) || 1;
42
- return (_jsxs(Box, Object.assign({ display: "flex", justifyContent: dense ? 'space-between' : 'flex-end', flex: 1, pl: dense ? 0 : 2, mt: dense ? 2 : 0 }, { children: [_jsxs(Box, Object.assign({ display: "flex", alignItems: "center", pr: dense ? 0 : 2 }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(EvStationIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t(`swap.currency`, { value: (_a = route.gasCostUSD) !== null && _a !== void 0 ? _a : 0.01 }) }))] })), _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", pr: dense ? 0 : 2 }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(AccessTimeIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t('swap.estimatedTime', {
43
- value: executionTime,
44
- }) }))] })), !dense ? (_jsxs(Box, Object.assign({ display: "flex", alignItems: "center" }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(LayersIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: route.steps.length }))] }))) : null] })));
41
+ .reduce((duration, x) => duration + x, 0) / 60);
42
+ const gasCostUSD = parseFloat((_a = route.gasCostUSD) !== null && _a !== void 0 ? _a : '') || 0.01;
43
+ return (_jsxs(Box, Object.assign({ display: "flex", justifyContent: dense ? 'space-between' : 'flex-end', flex: 1, pl: dense ? 0 : 2, mt: dense ? 2 : 0 }, { children: [_jsx(Tooltip, Object.assign({ title: t(`tooltip.estimatedNetworkFee`), placement: "top", enterDelay: 400, enterNextDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", mr: dense ? 0 : 2 }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(EvStationIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t(`swap.currency`, { value: gasCostUSD }) }))] })) })), _jsx(Tooltip, Object.assign({ title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, enterNextDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", mr: dense ? 0 : 2 }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(AccessTimeIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t('swap.estimatedTime', {
44
+ value: executionTimeMinutes,
45
+ }) }))] })) })), !dense ? (_jsx(Tooltip, Object.assign({ title: t(`tooltip.numberOfSteps`), placement: "top", enterDelay: 400, enterNextDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center" }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(LayersIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: route.steps.length }))] })) }))) : null] })));
45
46
  };
@@ -10,14 +10,14 @@ import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '..
10
10
  import { useSwapRoutes } from '../../hooks';
11
11
  import { navigationRoutes } from '../../utils';
12
12
  import { Stack } from './SwapRoutes.style';
13
- import { useSetSelectedRoute } from './useSetSelectedRoute';
13
+ import { useSetRecommendedRoute } from './useSetRecommendedRoute';
14
14
  export const SwapRoutes = (props) => {
15
15
  const { t } = useTranslation();
16
16
  const navigate = useNavigate();
17
17
  const { isValid, isValidating } = useFormState();
18
18
  const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
19
19
  const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
20
- useSetSelectedRoute(currentRoute, isFetching);
20
+ useSetRecommendedRoute(currentRoute, isFetching);
21
21
  if (!currentRoute && !isLoading && !isFetching && !isFetched) {
22
22
  return null;
23
23
  }
@@ -30,8 +30,8 @@ export const SwapRoutes = (props) => {
30
30
  top: 8,
31
31
  right: 8,
32
32
  } }), _jsxs(Box, Object.assign({ sx: { display: 'flex' } }, { children: [_jsx(Stack, Object.assign({ direction: "row", spacing: 2, my: 2, ml: 2, mr: routeNotFound ? 2 : 1, sx: {
33
- borderWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
33
+ borderRightWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
34
34
  ? 1
35
35
  : 0,
36
- } }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense" })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes", disabled: isValidating || !isValid }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })));
36
+ } }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense" })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", disabled: isValidating || !isValid }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })));
37
37
  };
@@ -1,2 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  export declare const SwapRoutesExpanded: () => JSX.Element;
3
+ export declare const SwapRoutesExpandedElement: () => JSX.Element;
@@ -2,16 +2,26 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Collapse, Grow, Stack, Typography } from '@mui/material';
3
3
  import { useFormState } from 'react-hook-form';
4
4
  import { useTranslation } from 'react-i18next';
5
- import { useLocation, useNavigate } from 'react-router-dom';
5
+ import { useNavigate, useRoutes } from 'react-router-dom';
6
6
  import { useSwapRoutes } from '../../hooks';
7
7
  import { useWidgetConfig } from '../../providers';
8
8
  import { useSetExecutableRoute } from '../../stores';
9
- import { navigationRoutes, navigationRoutesValues } from '../../utils';
9
+ import { navigationRoutes } from '../../utils';
10
10
  import { ProgressToNextUpdate } from '../ProgressToNextUpdate';
11
11
  import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../SwapRouteCard';
12
12
  import { CollapseContainer, Container, Header, ScrollableContainer, } from './SwapRoutes.style';
13
- import { useSetSelectedRoute } from './useSetSelectedRoute';
13
+ import { useSetRecommendedRoute } from './useSetRecommendedRoute';
14
+ const timeout = { enter: 225, exit: 225, appear: 0 };
14
15
  export const SwapRoutesExpanded = () => {
16
+ const element = useRoutes([
17
+ {
18
+ path: '/',
19
+ element: null,
20
+ },
21
+ ]);
22
+ return (_jsx(CollapseContainer, { children: _jsx(Collapse, Object.assign({ timeout: timeout, in: !!element, orientation: "horizontal" }, { children: _jsx(Grow, Object.assign({ timeout: timeout, in: !!element, mountOnEnter: true, unmountOnExit: true }, { children: _jsx("div", { children: _jsx(SwapRoutesExpandedElement, {}) }) })) })) }));
23
+ };
24
+ export const SwapRoutesExpandedElement = () => {
15
25
  const { t } = useTranslation();
16
26
  const navigate = useNavigate();
17
27
  const setExecutableRoute = useSetExecutableRoute();
@@ -19,13 +29,7 @@ export const SwapRoutesExpanded = () => {
19
29
  const { isValid, isValidating } = useFormState();
20
30
  const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
21
31
  const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
22
- useSetSelectedRoute(currentRoute, isFetching);
23
- const { pathname } = useLocation();
24
- const cleanedPathname = pathname.endsWith('/')
25
- ? pathname.slice(0, -1)
26
- : pathname;
27
- const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1);
28
- const hasPath = navigationRoutesValues.includes(path);
32
+ useSetRecommendedRoute(currentRoute, isFetching);
29
33
  const handleRouteClick = (route) => {
30
34
  if (isValid && !isValidating) {
31
35
  setExecutableRoute(route);
@@ -34,7 +38,7 @@ export const SwapRoutesExpanded = () => {
34
38
  });
35
39
  }
36
40
  };
37
- const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched) && !hasPath;
41
+ const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
38
42
  const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
39
- return (_jsx(CollapseContainer, { children: _jsx(Collapse, Object.assign({ appear: true, timeout: 225, in: expanded, orientation: "horizontal" }, { children: _jsx(Grow, Object.assign({ appear: true, timeout: 225, in: expanded }, { children: _jsx(Container, Object.assign({ sx: containerStyle, enableColorScheme: true }, { children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "700", flex: 1, noWrap: true }, { children: t('swap.routes') })), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, Object.assign({ direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, { variant: "stretched" }, index)))) : (routes === null || routes === void 0 ? void 0 : routes.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "stretched", expanded: (routes === null || routes === void 0 ? void 0 : routes.length) <= 2 }, route.id)))) }))] }) })) })) })) }));
43
+ return (_jsx(Collapse, Object.assign({ timeout: timeout.enter, in: expanded, orientation: "horizontal" }, { children: _jsx(Grow, Object.assign({ timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true }, { children: _jsx(Container, Object.assign({ sx: containerStyle, enableColorScheme: true }, { children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "700", flex: 1, noWrap: true }, { children: t('swap.routes') })), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, Object.assign({ direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, { variant: "stretched" }, index)))) : (routes === null || routes === void 0 ? void 0 : routes.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "stretched", expanded: (routes === null || routes === void 0 ? void 0 : routes.length) <= 2 }, route.id)))) }))] }) })) })) })));
40
44
  };
@@ -0,0 +1,2 @@
1
+ import type { Route } from '@lifi/sdk';
2
+ export declare const useSetRecommendedRoute: (currentRoute?: Route, isFetching?: boolean) => void;
@@ -0,0 +1,9 @@
1
+ import { useEffect } from 'react';
2
+ import { useRecommendedRouteStore } from '../../stores';
3
+ export const useSetRecommendedRoute = (currentRoute, isFetching) => {
4
+ const setRecommendedRoute = useRecommendedRouteStore((state) => state.setRecommendedRoute);
5
+ useEffect(() => {
6
+ setRecommendedRoute(!isFetching ? currentRoute : undefined);
7
+ return () => setRecommendedRoute(undefined);
8
+ }, [currentRoute, isFetching, setRecommendedRoute]);
9
+ };
@@ -36,22 +36,25 @@ export const TokenList = ({ formType, height, onClick, }) => {
36
36
  : filteredTokens;
37
37
  const handleTokenClick = useCallback((tokenAddress) => {
38
38
  setValue(SwapFormKeyHelper.getTokenKey(formType), tokenAddress, {
39
- shouldDirty: true,
39
+ shouldTouch: true,
40
+ });
41
+ // Set chain again to trigger URL builder update
42
+ setValue(SwapFormKeyHelper.getChainKey(formType), selectedChainId, {
43
+ shouldTouch: true,
40
44
  });
41
45
  setValue(SwapFormKeyHelper.getAmountKey(formType), '');
42
46
  const oppositeFormType = formType === 'from' ? 'to' : 'from';
43
- const [selectedOppositeToken, selectedOppositeChain, selectedChain] = getValues([
47
+ const [selectedOppositeToken, selectedOppositeChainId] = getValues([
44
48
  SwapFormKeyHelper.getTokenKey(oppositeFormType),
45
49
  SwapFormKeyHelper.getChainKey(oppositeFormType),
46
- SwapFormKeyHelper.getChainKey(formType),
47
50
  ]);
48
51
  if (selectedOppositeToken === tokenAddress &&
49
- selectedOppositeChain === selectedChain) {
52
+ selectedOppositeChainId === selectedChainId) {
50
53
  setValue(SwapFormKeyHelper.getTokenKey(oppositeFormType), '', {
51
- shouldDirty: false,
54
+ shouldTouch: true,
52
55
  });
53
56
  }
54
57
  onClick === null || onClick === void 0 ? void 0 : onClick();
55
- }, [formType, getValues, onClick, setValue]);
58
+ }, [formType, getValues, onClick, selectedChainId, setValue]);
56
59
  return (_jsxs(Box, Object.assign({ ref: parentRef, style: { height, overflow: 'auto' } }, { children: [!tokens.length && !isLoading ? (_jsx(TokenNotFound, { formType: formType })) : null, _jsx(VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] })));
57
60
  };
package/config/theme.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { loadingButtonClasses } from '@mui/lab/LoadingButton';
1
2
  import { common } from '@mui/material/colors';
2
3
  import { dialogActionsClasses } from '@mui/material/DialogActions';
3
4
  import { alpha, createTheme as createMuiTheme, darken, getContrastRatio, lighten, } from '@mui/material/styles';
@@ -45,6 +46,9 @@ export const createTheme = (mode, theme = {}) => {
45
46
  const primaryMainColor = (_c = (_b = (_a = theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) !== null && _c !== void 0 ? _c : palette.primary.main;
46
47
  const primaryLightColor = lighten((_f = (_e = (_d = theme.palette) === null || _d === void 0 ? void 0 : _d.primary) === null || _e === void 0 ? void 0 : _e.main) !== null && _f !== void 0 ? _f : palette.primary.main, 0.5);
47
48
  const primaryDarkColor = darken((_j = (_h = (_g = theme.palette) === null || _g === void 0 ? void 0 : _g.primary) === null || _h === void 0 ? void 0 : _h.main) !== null && _j !== void 0 ? _j : palette.primary.main, 0.2);
49
+ const contrastButtonColor = getContrastRatio(common.white, primaryMainColor) >= 3
50
+ ? common.white
51
+ : common.black;
48
52
  return createMuiTheme({
49
53
  typography: Object.assign({ fontFamily: 'Inter var, Inter, sans-serif' }, theme.typography),
50
54
  palette: Object.assign(Object.assign(Object.assign({ mode }, palette), { primary: {
@@ -80,13 +84,25 @@ export const createTheme = (mode, theme = {}) => {
80
84
  borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
81
85
  textTransform: 'none',
82
86
  fontSize: '1rem',
83
- '&.Mui-disabled, &.Mui-disabled:hover': {
87
+ [`&.Mui-disabled, &.Mui-disabled:hover`]: {
84
88
  color: mode === 'light'
85
- ? 'rgb(0 0 0 / 70%)'
86
- : 'rgb(255 255 255 / 70%)',
89
+ ? 'rgb(0 0 0 / 56%)'
90
+ : 'rgb(255 255 255 / 56%)',
87
91
  cursor: 'not-allowed',
88
92
  pointerEvents: 'auto',
89
93
  },
94
+ [`&.${loadingButtonClasses.loading}.Mui-disabled`]: {
95
+ backgroundColor: primaryMainColor,
96
+ color: contrastButtonColor,
97
+ cursor: 'auto',
98
+ pointerEvents: 'auto',
99
+ },
100
+ [`.${loadingButtonClasses.loadingIndicator}`]: {
101
+ color: contrastButtonColor,
102
+ },
103
+ [`&.${loadingButtonClasses.root}.${loadingButtonClasses.loading}`]: {
104
+ color: 'transparent',
105
+ },
90
106
  }, text: {
91
107
  backgroundColor: alpha(primaryMainColor, 0.08),
92
108
  '&:hover': {
@@ -94,9 +110,7 @@ export const createTheme = (mode, theme = {}) => {
94
110
  },
95
111
  }, contained: {
96
112
  '&:hover': {
97
- color: getContrastRatio(common.white, primaryMainColor) >= 3
98
- ? common.white
99
- : common.black,
113
+ color: contrastButtonColor,
100
114
  },
101
115
  }, sizeMedium: {
102
116
  padding: '10px 16px',
@@ -114,10 +128,10 @@ export const createTheme = (mode, theme = {}) => {
114
128
  },
115
129
  },
116
130
  text: {
117
- backgroundColor: paletteDark.background.paper,
131
+ backgroundColor: lighten(paletteDark.background.paper, 0.08),
118
132
  color: common.white,
119
133
  '&:hover': {
120
- backgroundColor: lighten(paletteDark.background.paper, 0.02),
134
+ backgroundColor: lighten(paletteDark.background.paper, 0.12),
121
135
  },
122
136
  },
123
137
  }
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.18.9";
2
+ export declare const version = "1.19.0";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.18.9';
2
+ export const version = '1.19.0';
package/hooks/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from './useChain';
2
2
  export * from './useChains';
3
3
  export * from './useContentHeight';
4
4
  export * from './useDebouncedWatch';
5
+ export * from './useExpandableVariant';
5
6
  export * from './useFeaturedTokens';
6
7
  export * from './useGasSufficiency';
7
8
  export * from './useInitializer';
package/hooks/index.js CHANGED
@@ -2,6 +2,7 @@ export * from './useChain';
2
2
  export * from './useChains';
3
3
  export * from './useContentHeight';
4
4
  export * from './useDebouncedWatch';
5
+ export * from './useExpandableVariant';
5
6
  export * from './useFeaturedTokens';
6
7
  export * from './useGasSufficiency';
7
8
  export * from './useInitializer';
@@ -0,0 +1 @@
1
+ export declare const useExpandableVariant: () => boolean;
@@ -0,0 +1,10 @@
1
+ import { useMediaQuery } from '@mui/material';
2
+ import { useWidgetConfig } from '../providers';
3
+ const defaultExpandableWidth = 852;
4
+ export const useExpandableVariant = () => {
5
+ const { variant } = useWidgetConfig();
6
+ const expandableAllowed = useMediaQuery((theme) => {
7
+ return theme.breakpoints.up(defaultExpandableWidth);
8
+ });
9
+ return variant === 'expandable' && expandableAllowed;
10
+ };
@@ -9,7 +9,8 @@ interface GasSufficiency {
9
9
  chain?: EVMChain;
10
10
  }
11
11
  export declare const useGasSufficiency: (route?: Route) => {
12
- insufficientGas: GasSufficiency[] | undefined;
13
- insufficientFunds: boolean;
12
+ insufficientGas: GasSufficiency[] | null | undefined;
13
+ insufficientFunds: boolean | null | undefined;
14
+ isLoading: boolean;
14
15
  };
15
16
  export {};
@@ -7,23 +7,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { useQuery } from '@tanstack/react-query';
10
11
  import Big from 'big.js';
11
- import { useCallback, useEffect, useMemo, useState } from 'react';
12
12
  import { useChains } from '.';
13
13
  import { useWallet } from '../providers';
14
+ import { isRouteCompleted } from '../stores';
14
15
  import { useTokenBalance } from './useTokenBalance';
16
+ const refetchInterval = 30000;
15
17
  export const useGasSufficiency = (route) => {
16
18
  const { account } = useWallet();
17
19
  const { getChainById } = useChains();
18
20
  const { token: fromToken, getTokenBalancesWithRetry } = useTokenBalance(route === null || route === void 0 ? void 0 : route.fromToken);
19
- const [insufficientGas, setInsufficientGas] = useState();
20
- const checkInsufficientGas = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
21
+ const { data: insufficientGas, isInitialLoading: insufficientGasLoading } = useQuery(['gas-sufficiency-check', account.address, route === null || route === void 0 ? void 0 : route.id], () => __awaiter(void 0, void 0, void 0, function* () {
21
22
  var _a, _b;
22
23
  if (!account.address || !route) {
23
- setInsufficientGas(undefined);
24
- return;
24
+ return null;
25
25
  }
26
- const gasCosts = route.steps.reduce((groupedGasCosts, step) => {
26
+ const gasCosts = route.steps
27
+ .filter((step) => !step.execution || step.execution.status !== 'DONE')
28
+ .reduce((groupedGasCosts, step) => {
27
29
  if (step.estimate.gasCosts) {
28
30
  const { token } = step.estimate.gasCosts[0];
29
31
  const gasCostAmount = step.estimate.gasCosts
@@ -37,7 +39,6 @@ export const useGasSufficiency = (route) => {
37
39
  gasAmount,
38
40
  tokenAmount: gasAmount,
39
41
  token,
40
- chain: getChainById(token.chainId),
41
42
  };
42
43
  return groupedGasCosts;
43
44
  }
@@ -48,41 +49,64 @@ export const useGasSufficiency = (route) => {
48
49
  }
49
50
  const tokenBalances = yield getTokenBalancesWithRetry(account.address, Object.values(gasCosts).map((item) => item.token));
50
51
  if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
51
- setInsufficientGas(undefined);
52
- return;
52
+ return null;
53
53
  }
54
54
  [route.fromChainId, route.toChainId].forEach((chainId) => {
55
55
  var _a, _b, _c, _d, _e, _f;
56
56
  if (gasCosts[chainId]) {
57
57
  const gasTokenBalance = Big((_b = (_a = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
58
58
  t.address === gasCosts[chainId].token.address)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
59
- const insufficientFromChainGas = gasTokenBalance.lte(0) ||
59
+ const insufficient = gasTokenBalance.lte(0) ||
60
60
  gasTokenBalance.lt((_c = gasCosts[chainId].gasAmount) !== null && _c !== void 0 ? _c : Big(0)) ||
61
61
  gasTokenBalance.lt((_d = gasCosts[chainId].tokenAmount) !== null && _d !== void 0 ? _d : Big(0));
62
- const insufficientFromChainGasAmount = insufficientFromChainGas
62
+ const insufficientAmount = insufficient
63
63
  ? (_f = (_e = gasCosts[chainId].tokenAmount) === null || _e === void 0 ? void 0 : _e.minus(gasTokenBalance)) !== null && _f !== void 0 ? _f : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
64
64
  : undefined;
65
- gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient: insufficientFromChainGas, insufficientAmount: insufficientFromChainGasAmount === null || insufficientFromChainGasAmount === void 0 ? void 0 : insufficientFromChainGasAmount.round(5, Big.roundUp) });
65
+ gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient, insufficientAmount: insufficientAmount === null || insufficientAmount === void 0 ? void 0 : insufficientAmount.round(5, Big.roundUp), chain: insufficient ? getChainById(chainId) : undefined });
66
66
  }
67
67
  });
68
68
  const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
69
- setInsufficientGas(gasCostResult);
70
- }), [account.address, getChainById, getTokenBalancesWithRetry, route]);
71
- const insufficientFunds = useMemo(() => {
72
- var _a;
73
- if (!account.isActive || !fromToken || !route) {
74
- return false;
69
+ return gasCostResult;
70
+ }), {
71
+ enabled: Boolean(account.address && route),
72
+ refetchIntervalInBackground: true,
73
+ refetchInterval,
74
+ staleTime: refetchInterval,
75
+ cacheTime: refetchInterval,
76
+ });
77
+ const { data: insufficientFunds, isInitialLoading: insufficientFundsLoading, } = useQuery(['funds-sufficiency-check', account.address, route === null || route === void 0 ? void 0 : route.id], () => __awaiter(void 0, void 0, void 0, function* () {
78
+ var _c, _d, _e, _f;
79
+ if (!account.address || !fromToken || !route || isRouteCompleted(route)) {
80
+ return null;
81
+ }
82
+ let currentTokenBalance = Big((_c = fromToken === null || fromToken === void 0 ? void 0 : fromToken.amount) !== null && _c !== void 0 ? _c : 0);
83
+ const currentAction = (_d = route.steps.filter((step) => !step.execution || step.execution.status !== 'DONE')[0]) === null || _d === void 0 ? void 0 : _d.action;
84
+ if (fromToken.chainId === currentAction.fromToken.chainId &&
85
+ fromToken.address === currentAction.fromToken.address &&
86
+ currentTokenBalance.gt(0)) {
87
+ const insufficientFunds = Big(route.fromAmount)
88
+ .div(Math.pow(10, route.fromToken.decimals))
89
+ .gt(currentTokenBalance);
90
+ return insufficientFunds;
75
91
  }
76
- const balance = Big((_a = fromToken === null || fromToken === void 0 ? void 0 : fromToken.amount) !== null && _a !== void 0 ? _a : 0);
77
- return Big(route.fromAmount)
78
- .div(Math.pow(10, route.fromToken.decimals))
79
- .gt(balance);
80
- }, [account.isActive, fromToken, route]);
81
- useEffect(() => {
82
- checkInsufficientGas();
83
- }, [checkInsufficientGas]);
92
+ const tokenBalances = yield getTokenBalancesWithRetry(account.address, [
93
+ currentAction.fromToken,
94
+ ]);
95
+ currentTokenBalance = Big((_f = (_e = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances[0]) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : 0);
96
+ const insufficientFunds = Big(currentAction.fromAmount)
97
+ .div(Math.pow(10, currentAction.fromToken.decimals))
98
+ .gt(currentTokenBalance);
99
+ return insufficientFunds;
100
+ }), {
101
+ enabled: Boolean(account.address && route && fromToken),
102
+ refetchIntervalInBackground: true,
103
+ refetchInterval,
104
+ staleTime: refetchInterval,
105
+ cacheTime: refetchInterval,
106
+ });
84
107
  return {
85
108
  insufficientGas,
86
109
  insufficientFunds,
110
+ isLoading: insufficientGasLoading || insufficientFundsLoading,
87
111
  };
88
112
  };
@@ -74,16 +74,18 @@ export const useSwapRoutes = () => {
74
74
  catch (_d) {
75
75
  toWalletAddress = isAddress(toAddress) ? toAddress : fromAddress;
76
76
  }
77
+ const fromAmount = Big(Number(fromTokenAmount) * Math.pow(10, ((_c = token === null || token === void 0 ? void 0 : token.decimals) !== null && _c !== void 0 ? _c : 0))).toString();
78
+ const formattedSlippage = parseFloat(slippage) / 100;
77
79
  return lifi.getRoutes({
78
80
  fromChainId,
79
- fromAmount: Big(Number(fromTokenAmount) * Math.pow(10, ((_c = token === null || token === void 0 ? void 0 : token.decimals) !== null && _c !== void 0 ? _c : 0))).toString(),
81
+ fromAmount,
80
82
  fromTokenAddress,
81
83
  toChainId,
82
84
  toTokenAddress,
83
85
  fromAddress,
84
86
  toAddress: toWalletAddress,
85
87
  options: {
86
- slippage: slippage / 100,
88
+ slippage: formattedSlippage,
87
89
  bridges: {
88
90
  allow: enabledBridges,
89
91
  },
@@ -21,12 +21,12 @@ export const useTokenBalance = (token, accountAddress) => {
21
21
  try {
22
22
  const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
23
23
  if (!tokenBalances.every((token) => token.blockNumber)) {
24
- if (depth > 5) {
24
+ if (depth > 10) {
25
25
  console.warn('Token balance backoff depth exceeded.');
26
26
  return undefined;
27
27
  }
28
28
  yield new Promise((resolve) => {
29
- setTimeout(resolve, depth * 100);
29
+ setTimeout(resolve, Math.pow(1.5, depth) * 100);
30
30
  });
31
31
  return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
32
32
  }
@@ -44,10 +44,6 @@
44
44
  "routes": "You get",
45
45
  "approximateCurrency": "\u2248 {{value, currency(currency: USD)}}",
46
46
  "currency": "{{value, currency(currency: USD)}}",
47
- "sendToRecipient": "Send to recipient",
48
- "addressConfirmation": "I confirm that the address above is correct",
49
- "gas": "gas fee",
50
- "minutes": "minutes",
51
47
  "tokenSearch": "Search your token",
52
48
  "selectChain": "Chain",
53
49
  "selectToken": "Token",
@@ -98,12 +94,14 @@
98
94
  "title": {
99
95
  "insufficientGas": "Insufficient gas",
100
96
  "deleteSwap": "Delete this swap?",
101
- "deleteSwapHistory": "Delete swap history?"
97
+ "deleteSwapHistory": "Delete swap history?",
98
+ "deleteActiveSwaps": "Delete all active swaps?"
102
99
  },
103
100
  "message": {
104
101
  "insufficientFunds": "You don't have enough funds to execute the swap.",
105
102
  "insufficientGas": "You need to add at least:",
106
- "deleteSwap": "Swap history is only stored locally and can't be recovered if you delete it."
103
+ "deleteSwapHistory": "Swap history is only stored locally and can't be recovered if you delete it.",
104
+ "deleteActiveSwaps": "Active swaps are only stored locally and can't be recovered if you delete them."
107
105
  }
108
106
  },
109
107
  "error": {
@@ -179,6 +177,9 @@
179
177
  "title": "404",
180
178
  "text": "We couldn't find this page."
181
179
  },
182
- "progressToNextUpdate": "Displayed data will auto-refresh after {{value}} seconds. Click this circle to update manually."
180
+ "progressToNextUpdate": "Displayed data will auto-refresh after {{value}} seconds. Click here to update manually.",
181
+ "numberOfSteps": "A number of swap steps. Each step can contain 1-3 transactions that require a signature.",
182
+ "estimatedTime": "Estimated time in minutes.",
183
+ "estimatedNetworkFee": "Estimated network fee."
183
184
  }
184
185
  }
package/i18n/index.d.ts CHANGED
@@ -47,10 +47,6 @@ export declare const resources: {
47
47
  routes: string;
48
48
  approximateCurrency: string;
49
49
  currency: string;
50
- sendToRecipient: string;
51
- addressConfirmation: string;
52
- gas: string;
53
- minutes: string;
54
50
  tokenSearch: string;
55
51
  selectChain: string;
56
52
  selectToken: string;
@@ -102,11 +98,13 @@ export declare const resources: {
102
98
  insufficientGas: string;
103
99
  deleteSwap: string;
104
100
  deleteSwapHistory: string;
101
+ deleteActiveSwaps: string;
105
102
  };
106
103
  message: {
107
104
  insufficientFunds: string;
108
105
  insufficientGas: string;
109
- deleteSwap: string;
106
+ deleteSwapHistory: string;
107
+ deleteActiveSwaps: string;
110
108
  };
111
109
  };
112
110
  error: {
@@ -183,6 +181,9 @@ export declare const resources: {
183
181
  text: string;
184
182
  };
185
183
  progressToNextUpdate: string;
184
+ numberOfSteps: string;
185
+ estimatedTime: string;
186
+ estimatedNetworkFee: string;
186
187
  };
187
188
  };
188
189
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.18.9",
3
+ "version": "1.19.0",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",
@@ -45,25 +45,25 @@
45
45
  "@lifi/sdk": "^1.6.0",
46
46
  "@lifi/wallet-management": "^1.1.10",
47
47
  "@mui/icons-material": "^5.10.6",
48
- "@mui/lab": "^5.0.0-alpha.101",
49
- "@mui/material": "^5.10.7",
50
- "@sentry/integrations": "^7.14.0",
51
- "@sentry/react": "^7.14.0",
52
- "@sentry/tracing": "^7.14.0",
53
- "@tanstack/react-query": "^4.8.0",
48
+ "@mui/lab": "^5.0.0-alpha.102",
49
+ "@mui/material": "^5.10.8",
50
+ "@sentry/integrations": "^7.14.2",
51
+ "@sentry/react": "^7.14.2",
52
+ "@sentry/tracing": "^7.14.2",
53
+ "@tanstack/react-query": "^4.10.3",
54
54
  "@tanstack/react-virtual": "^3.0.0-beta.18",
55
55
  "big.js": "^6.2.1",
56
- "i18next": "^21.9.2",
56
+ "i18next": "^21.10.0",
57
57
  "immer": "^9.0.15",
58
58
  "microdiff": "^1.3.1",
59
59
  "mitt": "^3.0.0",
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0",
62
- "react-hook-form": "^7.36.1",
62
+ "react-hook-form": "^7.37.0",
63
63
  "react-i18next": "^11.18.6",
64
- "react-router-dom": "^6.4.1",
64
+ "react-router-dom": "^6.4.2",
65
65
  "react-timer-hook": "^3.0.5",
66
- "zustand": "^4.1.1"
66
+ "zustand": "^4.1.2"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@types/react": "^18.0.0",