@rango-dev/widget-embedded 0.1.11-next.10 → 0.1.11-next.11
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/pages/Home.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +2 -2
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +18 -18
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +18 -18
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +18 -18
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/TokenInfo.tsx +5 -5
- package/src/hooks/useConfirmSwap.ts +2 -2
- package/src/pages/ConfirmSwapPage.tsx +2 -2
- package/src/pages/Home.tsx +1 -2
- package/src/store/bestRoute.ts +2 -2
- package/src/store/wallets.ts +1 -1
- package/src/utils/swap.ts +16 -5
package/package.json
CHANGED
|
@@ -132,6 +132,7 @@ export function TokenInfo(props: PropTypes) {
|
|
|
132
132
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
133
133
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
134
134
|
const balances = useWalletsStore.use.balances();
|
|
135
|
+
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
135
136
|
const navigate = useNavigate();
|
|
136
137
|
const { t } = useTranslation();
|
|
137
138
|
|
|
@@ -307,11 +308,10 @@ export function TokenInfo(props: PropTypes) {
|
|
|
307
308
|
) : (
|
|
308
309
|
<OutputContainer>
|
|
309
310
|
<Typography variant="h4">
|
|
310
|
-
{
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
: '0'}
|
|
311
|
+
{fetchingBestRoute && '?'}
|
|
312
|
+
{!!bestRoute?.result &&
|
|
313
|
+
`≈ ${numberToString(props.outputAmount)}`}
|
|
314
|
+
{(!inputAmount || inputAmount === '0') && '0'}
|
|
315
315
|
</Typography>
|
|
316
316
|
</OutputContainer>
|
|
317
317
|
)}
|
|
@@ -47,6 +47,7 @@ export function ConfirmSwapPage() {
|
|
|
47
47
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
48
48
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
49
49
|
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
50
|
+
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
50
51
|
|
|
51
52
|
const bestRouteloadingStatus = getBestRouteStatus(
|
|
52
53
|
fetchingBestRoute,
|
|
@@ -96,7 +97,6 @@ export function ConfirmSwapPage() {
|
|
|
96
97
|
|
|
97
98
|
return (
|
|
98
99
|
<ConfirmSwap
|
|
99
|
-
// @ts-ignore
|
|
100
100
|
requiredWallets={getRequiredChains(bestRoute)}
|
|
101
101
|
selectableWallets={selectableWallets}
|
|
102
102
|
onBack={navigateBackFrom.bind(null, navigationRoutes.confirmSwap)}
|
|
@@ -106,13 +106,13 @@ export function ConfirmSwapPage() {
|
|
|
106
106
|
manager?.create(
|
|
107
107
|
'swap',
|
|
108
108
|
{ swapDetails: swap },
|
|
109
|
-
// @ts-ignore
|
|
110
109
|
{ id: swap.requestId }
|
|
111
110
|
);
|
|
112
111
|
setSelectedSwap(swap.requestId);
|
|
113
112
|
navigate(navigationRoutes.swaps + `/${swap.requestId}`, {
|
|
114
113
|
replace: true,
|
|
115
114
|
});
|
|
115
|
+
setInputAmount('');
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}}
|
package/src/pages/Home.tsx
CHANGED
|
@@ -110,7 +110,6 @@ export function Home() {
|
|
|
110
110
|
outputUsdValue
|
|
111
111
|
);
|
|
112
112
|
|
|
113
|
-
const inputIsZero = inputAmount === '0';
|
|
114
113
|
const swapButtonState = getSwapButtonState(
|
|
115
114
|
loadingMetaStatus,
|
|
116
115
|
accounts,
|
|
@@ -120,7 +119,7 @@ export function Home() {
|
|
|
120
119
|
highValueLoss,
|
|
121
120
|
priceImpactCanNotBeComputed,
|
|
122
121
|
needsToWarnEthOnPath,
|
|
123
|
-
|
|
122
|
+
inputAmount
|
|
124
123
|
);
|
|
125
124
|
|
|
126
125
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
package/src/store/bestRoute.ts
CHANGED
|
@@ -263,7 +263,6 @@ const bestRoute = (
|
|
|
263
263
|
[],
|
|
264
264
|
disabledLiquiditySources,
|
|
265
265
|
userSlippage,
|
|
266
|
-
false,
|
|
267
266
|
affiliateRef
|
|
268
267
|
);
|
|
269
268
|
if (!bestRouteStore.getState().loading)
|
|
@@ -297,7 +296,8 @@ const bestRoute = (
|
|
|
297
296
|
const bestRouteParamsListener = () => {
|
|
298
297
|
const { fromToken, toToken, inputAmount, inputUsdValue } =
|
|
299
298
|
useBestRouteStore.getState();
|
|
300
|
-
if (!inputAmount || inputAmount === '0' || inputUsdValue.eq(0))
|
|
299
|
+
if (!inputAmount || inputAmount === '0' || inputUsdValue.eq(0))
|
|
300
|
+
return bestRouteStore.setState({ loading: false });
|
|
301
301
|
|
|
302
302
|
if (tokensAreEqual(fromToken, toToken))
|
|
303
303
|
return bestRouteStore.setState({
|
package/src/store/wallets.ts
CHANGED
package/src/utils/swap.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
PendingSwapStep,
|
|
20
20
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
21
21
|
import { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
22
|
+
import { removeDuplicateFrom } from './common';
|
|
22
23
|
|
|
23
24
|
export function getOutputRatio(
|
|
24
25
|
inputUsdValue: BigNumber,
|
|
@@ -128,13 +129,14 @@ export function getSwapButtonState(
|
|
|
128
129
|
highValueLoss: boolean,
|
|
129
130
|
priceImpactCanNotBeComputed: boolean,
|
|
130
131
|
needsToWarnEthOnPath: boolean,
|
|
131
|
-
|
|
132
|
+
inputAmount: string
|
|
132
133
|
): SwapButtonState {
|
|
133
134
|
if (loadingMetaStatus !== 'success')
|
|
134
135
|
return { title: 'Connect Wallet', disabled: true };
|
|
135
136
|
if (accounts.length == 0) return { title: 'Connect Wallet', disabled: false };
|
|
136
137
|
if (loading) return { title: 'Finding Best Route...', disabled: true };
|
|
137
|
-
else if (
|
|
138
|
+
else if (!inputAmount || inputAmount === '0')
|
|
139
|
+
return { title: 'Enter an amount', disabled: true };
|
|
138
140
|
else if (!bestRoute || !bestRoute.result)
|
|
139
141
|
return { title: 'Swap', disabled: true };
|
|
140
142
|
else if (hasLimitError) return { title: 'Limit Error', disabled: true };
|
|
@@ -313,8 +315,8 @@ export function createBestRouteRequestBody(
|
|
|
313
315
|
selectedWallets: SelectedWallet[],
|
|
314
316
|
disabledLiquiditySources: string[],
|
|
315
317
|
slippage: number,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
+
affiliateRef: string | null,
|
|
319
|
+
initialRoute?: BestRouteResponse
|
|
318
320
|
): BestRouteRequest {
|
|
319
321
|
const selectedWalletsMap = selectedWallets.reduce(
|
|
320
322
|
(
|
|
@@ -341,7 +343,16 @@ export function createBestRouteRequestBody(
|
|
|
341
343
|
});
|
|
342
344
|
});
|
|
343
345
|
|
|
344
|
-
const
|
|
346
|
+
const checkPrerequisites = !!initialRoute;
|
|
347
|
+
|
|
348
|
+
const filteredBlockchains = removeDuplicateFrom(
|
|
349
|
+
(initialRoute?.result?.swaps || []).reduce(
|
|
350
|
+
(blockchains: string[], swap) => (
|
|
351
|
+
blockchains.push(swap.from.blockchain, swap.to.blockchain), blockchains
|
|
352
|
+
),
|
|
353
|
+
[]
|
|
354
|
+
)
|
|
355
|
+
);
|
|
345
356
|
|
|
346
357
|
const requestBody: BestRouteRequest = {
|
|
347
358
|
amount: inputAmount.toString(),
|