@@ -95,28 +125,26 @@ export const DepositForm = ({
{/* TODO(deposit2.0): Show difference between current and new balance here */}
- {selectedRoute && (
-
- {/* TODO(deposit2.0): localization */}
-
Available balance
-
- +
-
-
+
+ {/* TODO(deposit2.0): localization */}
+
Available balance
+
+ +
+
- )}
+
);
diff --git a/src/views/dialogs/DepositDialog2/RouteOptions.tsx b/src/views/dialogs/DepositDialog2/RouteOptions.tsx
index f4c6696f1..71eae60c7 100644
--- a/src/views/dialogs/DepositDialog2/RouteOptions.tsx
+++ b/src/views/dialogs/DepositDialog2/RouteOptions.tsx
@@ -1,4 +1,4 @@
-import { ReactNode } from 'react';
+import { ReactNode, useMemo } from 'react';
import { RouteResponse } from '@skip-go/client';
import { formatUnits } from 'viem';
@@ -12,7 +12,7 @@ import { LightningIcon, ShieldIcon } from '@/icons';
import { Output, OutputType } from '@/components/Output';
type Props = {
- routes: { slow?: RouteResponse; fast?: RouteResponse };
+ routes?: { slow?: RouteResponse; fast?: RouteResponse };
isLoading: boolean;
disabled: boolean;
selectedSpeed: SkipRouteSpeed;
@@ -26,24 +26,55 @@ export const RouteOptions = ({
onSelectSpeed,
disabled,
}: Props) => {
- // TODO(deposit2.0): finalize error handling here
- if (!routes.slow && !routes.fast) {
- return
There was an error loading deposit quotes.
;
- }
+ const fastRouteDescription = useMemo(() => {
+ const fastOperationFee = // @ts-ignore
+ routes?.fast?.operations.find((op) => Boolean(op.goFastTransfer))?.goFastTransfer?.fee;
+ const totalFastFee = fastOperationFee
+ ? formatUnits(
+ BigInt(fastOperationFee.bpsFeeAmount ?? 0) +
+ BigInt(fastOperationFee.destinationChainFeeAmount ?? 0) +
+ BigInt(fastOperationFee.sourceChainFeeAmount ?? 0),
+ 6
+ )
+ : '-';
- const fastOperationFee = // @ts-ignore
- routes.fast?.operations.find((op) => Boolean(op.goFastTransfer))?.goFastTransfer?.fee;
- const totalFastFee = fastOperationFee
- ? formatUnits(
- BigInt(fastOperationFee.bpsFeeAmount ?? 0) +
- BigInt(fastOperationFee.destinationChainFeeAmount ?? 0) +
- BigInt(fastOperationFee.sourceChainFeeAmount ?? 0),
- 6
- )
- : '-';
+ // TODO(deposit2.0): localization
+ if (!routes || disabled) return '$$ fee, $10k limit';
+ if (!routes.fast) return 'Unavailable';
+
+ return (
+
+ {' '}
+ fee, $10k limit
+
+ );
+ }, [routes, disabled]);
+
+ const slowRouteDescription = useMemo(() => {
+ // TODO(deposit2.0): localization
+ if (!routes || disabled) return '$ fee, no limit';
+ if (!routes.slow) return 'Unavailable';
+
+ return (
+
+ {' '}
+ fee, no limit
+
+ );
+ }, [routes, disabled]);
return (
-
+
}
selected={selectedSpeed === 'fast'}
- disabled={disabled || !routes.fast || isLoading}
+ disabled={disabled || !routes?.fast || isLoading}
onClick={() => onSelectSpeed('fast')}
// TODO(deposit2.0): localization
title="Instant"
- description={
- routes.fast ? (
-
- {' '}
- fee, $10k limit
-
- ) : (
- 'Unavailable'
- )
- }
+ description={fastRouteDescription}
/>
}
selected={selectedSpeed === 'slow'}
- disabled={disabled || isLoading || !routes.slow}
+ disabled={disabled || isLoading || !routes?.slow}
onClick={() => onSelectSpeed('slow')}
// TODO(deposit2.0): localization
title="~20 mins"
- description={
- routes.slow ? (
-
- {' '}
- fee, no limit
-
- ) : (
- 'Unavailable'
- )
- }
+ description={slowRouteDescription}
/>
);
diff --git a/src/views/dialogs/DepositDialog2/queries.ts b/src/views/dialogs/DepositDialog2/queries.ts
index e0e295121..c01d232e9 100644
--- a/src/views/dialogs/DepositDialog2/queries.ts
+++ b/src/views/dialogs/DepositDialog2/queries.ts
@@ -124,6 +124,8 @@ async function getSkipDepositRoutes(
destAssetChainID: DYDX_DEPOSIT_CHAIN,
amountIn: parseUnits(amount, token.decimals).toString(),
smartRelay: true,
+ // allow quotes even if they have large price impact, as the user would see the difference in fees anyway
+ allowUnsafe: true,
smartSwapOptions: { evmSwaps: true },
};
@@ -147,6 +149,7 @@ export function useDepositRoutes(token: TokenForTransfer, amount: string) {
staleTime: 1 * timeUnits.minute,
refetchOnMount: 'always',
placeholderData: (prev) => prev,
+ retry: false,
});
}