@ensofinance/checkout-widget 0.0.12 → 0.0.14
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/checkout-widget.es.js +14486 -13826
- package/dist/checkout-widget.es.js.map +1 -1
- package/dist/checkout-widget.umd.js +44 -43
- package/dist/checkout-widget.umd.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/orval.config.ts +40 -6
- package/package.json +1 -1
- package/src/components/BridgeFee.tsx +3 -3
- package/src/components/Checkout.tsx +5 -53
- package/src/components/ExchangeConfirmSecurity.tsx +16 -3
- package/src/components/QuoteParameters.tsx +84 -65
- package/src/components/TransactionDetailRow.tsx +6 -5
- package/src/components/cards/AssetCard.tsx +2 -2
- package/src/components/cards/OptionCard.tsx +2 -0
- package/src/components/steps/ExchangeFlow.tsx +414 -135
- package/src/components/steps/{InitialStep.tsx → FlowSelector.tsx} +76 -33
- package/src/components/steps/WalletFlow/WalletAmountStep.tsx +214 -0
- package/src/components/steps/{WalletConfirmStep.tsx → WalletFlow/WalletConfirmStep.tsx} +107 -156
- package/src/components/steps/WalletFlow/WalletFlow.tsx +116 -0
- package/src/components/steps/{QuoteStep.tsx → WalletFlow/WalletQuoteStep.tsx} +9 -58
- package/src/components/steps/WalletFlow/WalletTokenStep.tsx +75 -0
- package/src/components/ui/index.tsx +0 -3
- package/src/enso-api/api.ts +192 -3
- package/src/enso-api/custom-instance.ts +1 -0
- package/src/enso-api/index.ts +29 -118
- package/src/enso-api/model/approveActionDto.ts +17 -0
- package/src/enso-api/model/approveArgsDto.ts +22 -0
- package/src/enso-api/model/approveArgsDtoAmount.ts +16 -0
- package/src/enso-api/model/balanceActionDto.ts +17 -0
- package/src/enso-api/model/balanceArgsDto.ts +15 -0
- package/src/enso-api/model/borrowActionDto.ts +18 -0
- package/src/enso-api/model/borrowArgsDto.ts +22 -0
- package/src/enso-api/model/borrowArgsDtoAmountOut.ts +16 -0
- package/src/enso-api/model/bridgeActionDto.ts +19 -0
- package/src/enso-api/model/bridgeArgsDto.ts +29 -0
- package/src/enso-api/model/bridgeArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/bridgeArgsDtoCallbackItem.ts +64 -0
- package/src/enso-api/model/bundleControllerBundleShortcutTransactionBodyItem.ts +69 -0
- package/src/enso-api/model/callActionDto.ts +18 -0
- package/src/enso-api/model/callArgsDto.ts +29 -0
- package/src/enso-api/model/callArgsDtoArgsItem.ts +17 -0
- package/src/enso-api/model/callArgsDtoArgsItemAnyOf.ts +12 -0
- package/src/enso-api/model/callArgsDtoValue.ts +16 -0
- package/src/enso-api/model/callOutput.ts +15 -0
- package/src/enso-api/model/depositActionDto.ts +18 -0
- package/src/enso-api/model/depositArgsDto.ts +28 -0
- package/src/enso-api/model/depositArgsDtoAmountIn.ts +20 -0
- package/src/enso-api/model/depositArgsDtoAmountInOneOfItem.ts +13 -0
- package/src/enso-api/model/depositArgsDtoTokenIn.ts +15 -0
- package/src/enso-api/model/depositArgsDtoTokenOut.ts +15 -0
- package/src/enso-api/model/depositCLMMActionDto.ts +18 -0
- package/src/enso-api/model/depositCLMMArgsDto.ts +30 -0
- package/src/enso-api/model/depositCLMMArgsDtoAmountInItem.ts +17 -0
- package/src/enso-api/model/depositCLMMArgsDtoAmountInItemAnyOf.ts +12 -0
- package/src/enso-api/model/ensoFeeActionDto.ts +17 -0
- package/src/enso-api/model/ensoFeeArgsDto.ts +20 -0
- package/src/enso-api/model/ensoFeeArgsDtoAmount.ts +16 -0
- package/src/enso-api/model/feeActionDto.ts +17 -0
- package/src/enso-api/model/feeArgsDto.ts +22 -0
- package/src/enso-api/model/feeArgsDtoAmount.ts +16 -0
- package/src/enso-api/model/harvestActionDto.ts +19 -0
- package/src/enso-api/model/harvestArgsDto.ts +17 -0
- package/src/enso-api/model/index.ts +115 -4
- package/src/enso-api/model/mergeActionDto.ts +17 -0
- package/src/enso-api/model/mergeArgsDto.ts +22 -0
- package/src/enso-api/model/mergeArgsDtoAmountInItem.ts +13 -0
- package/src/enso-api/model/minAmountOutActionDto.ts +17 -0
- package/src/enso-api/model/minAmountOutArgsDto.ts +19 -0
- package/src/enso-api/model/minAmountOutArgsDtoAmountOut.ts +16 -0
- package/src/enso-api/model/minAmountOutArgsDtoMinAmountOut.ts +16 -0
- package/src/enso-api/model/multiDepositActionDto.ts +18 -0
- package/src/enso-api/model/multiDepositArgsDto.ts +24 -0
- package/src/enso-api/model/multiDepositArgsDtoAmountInItem.ts +17 -0
- package/src/enso-api/model/multiDepositArgsDtoAmountInItemAnyOf.ts +12 -0
- package/src/enso-api/model/multiOutSingleDepositActionDto.ts +18 -0
- package/src/enso-api/model/multiOutSingleDepositArgsDto.ts +24 -0
- package/src/enso-api/model/multiOutSingleDepositArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/multiRedeemActionDto.ts +18 -0
- package/src/enso-api/model/multiRedeemArgs2Dto.ts +24 -0
- package/src/enso-api/model/multiRedeemArgs2DtoAmountIn.ts +16 -0
- package/src/enso-api/model/nontokenizedControllerRouteNontokenizedShorcutTransactionParams.ts +8 -0
- package/src/enso-api/model/nontokenizedControllerRouteNontokenizedShorcutTransactionRoutingStrategy.ts +1 -0
- package/src/enso-api/model/nontokenizedRouteShortcutTransaction.ts +31 -0
- package/src/enso-api/model/paymasterFeeActionDto.ts +17 -0
- package/src/enso-api/model/paymasterFeeArgsDto.ts +18 -0
- package/src/enso-api/model/paymasterFeeArgsDtoAmount.ts +16 -0
- package/src/enso-api/model/permitTransferFromActionDto.ts +18 -0
- package/src/enso-api/model/permitTransferFromArgsDto.ts +29 -0
- package/src/enso-api/model/permitTransferFromArgsDtoAmount.ts +20 -0
- package/src/enso-api/model/permitTransferFromArgsDtoAmountOneOfItem.ts +13 -0
- package/src/enso-api/model/permitTransferFromArgsDtoToken.ts +15 -0
- package/src/enso-api/model/positionModel.ts +14 -0
- package/src/enso-api/model/redeemActionDto.ts +18 -0
- package/src/enso-api/model/redeemArgsDto.ts +25 -0
- package/src/enso-api/model/redeemArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/redeemArgsDtoTokenOut.ts +15 -0
- package/src/enso-api/model/redeemCLMMActionDto.ts +18 -0
- package/src/enso-api/model/redeemCLMMArgsDto.ts +24 -0
- package/src/enso-api/model/redeemCLMMArgsDtoLiquidity.ts +16 -0
- package/src/enso-api/model/repayActionDto.ts +18 -0
- package/src/enso-api/model/repayArgsDto.ts +22 -0
- package/src/enso-api/model/repayArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/routeActionDto.ts +20 -0
- package/src/enso-api/model/routeArgsDto.ts +38 -0
- package/src/enso-api/model/routeArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/singleDepositActionDto.ts +18 -0
- package/src/enso-api/model/singleDepositArgsDto.ts +24 -0
- package/src/enso-api/model/singleDepositArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/singleRedeemActionDto.ts +18 -0
- package/src/enso-api/model/singleRedeemArgs2Dto.ts +24 -0
- package/src/enso-api/model/singleRedeemArgs2DtoAmountIn.ts +16 -0
- package/src/enso-api/model/slippageActionDto.ts +17 -0
- package/src/enso-api/model/slippageArgsDto.ts +18 -0
- package/src/enso-api/model/slippageArgsDtoAmountOut.ts +16 -0
- package/src/enso-api/model/splitActionDto.ts +17 -0
- package/src/enso-api/model/splitArgsDto.ts +22 -0
- package/src/enso-api/model/splitArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/swapActionDto.ts +18 -0
- package/src/enso-api/model/swapArgsDto.ts +30 -0
- package/src/enso-api/model/swapArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/tokenizedMultiDepositActionDto.ts +18 -0
- package/src/enso-api/model/tokenizedMultiDepositArgsDto.ts +24 -0
- package/src/enso-api/model/tokenizedMultiDepositArgsDtoAmountInItem.ts +17 -0
- package/src/enso-api/model/tokenizedMultiDepositArgsDtoAmountInItemAnyOf.ts +14 -0
- package/src/enso-api/model/tokenizedMultiRedeemActionDto.ts +18 -0
- package/src/enso-api/model/tokenizedMultiRedeemArgsDto.ts +24 -0
- package/src/enso-api/model/tokenizedMultiRedeemArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/tokenizedSingleDepositActionDto.ts +18 -0
- package/src/enso-api/model/tokenizedSingleDepositArgsDto.ts +24 -0
- package/src/enso-api/model/tokenizedSingleDepositArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/tokenizedSingleRedeemActionDto.ts +18 -0
- package/src/enso-api/model/tokenizedSingleRedeemArgsDto.ts +24 -0
- package/src/enso-api/model/tokenizedSingleRedeemArgsDtoAmountIn.ts +16 -0
- package/src/enso-api/model/tokensControllerTokensLiquidityType.ts +19 -0
- package/src/enso-api/model/tokensControllerTokensParams.ts +6 -0
- package/src/enso-api/model/transferActionDto.ts +18 -0
- package/src/enso-api/model/transferArgsDto.ts +22 -0
- package/src/enso-api/model/transferArgsDtoAmount.ts +16 -0
- package/src/enso-api/model/transferFromActionDto.ts +18 -0
- package/src/enso-api/model/transferFromArgsDto.ts +24 -0
- package/src/enso-api/model/transferFromArgsDtoAmount.ts +16 -0
- package/src/index.ts +1 -0
- package/src/store.ts +13 -5
- package/src/types/index.ts +9 -3
- package/src/util/common.tsx +4 -1
- package/src/util/enso-hooks.tsx +137 -14
- package/src/util/wallet.tsx +2 -69
- package/src/components/steps/WalletAmountStep.tsx +0 -267
- package/src/components/steps/WalletTokenStep.tsx +0 -128
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,13 @@ export declare const CheckoutModal: ({ config, setIsActive, isActive, onClose, }
|
|
|
16
16
|
|
|
17
17
|
export { CheckoutModalProps }
|
|
18
18
|
|
|
19
|
+
export declare enum SupportedExchanges {
|
|
20
|
+
Binance = "binance",
|
|
21
|
+
Kraken = "kraken",
|
|
22
|
+
Coinbase = "coinbase",
|
|
23
|
+
Bybit = "bybit"
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
export { WidgetTheme }
|
|
20
27
|
|
|
21
28
|
export { }
|
package/orval.config.ts
CHANGED
|
@@ -8,11 +8,9 @@ export default {
|
|
|
8
8
|
schemas: "src/enso-api/model",
|
|
9
9
|
client: "react-query",
|
|
10
10
|
override: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
retry: 2,
|
|
15
|
-
},
|
|
11
|
+
queryOptions: {
|
|
12
|
+
refetchInterval: 30_000,
|
|
13
|
+
retry: 2,
|
|
16
14
|
},
|
|
17
15
|
mutator: {
|
|
18
16
|
path: "./src/enso-api/custom-instance.ts",
|
|
@@ -20,6 +18,42 @@ export default {
|
|
|
20
18
|
},
|
|
21
19
|
},
|
|
22
20
|
},
|
|
23
|
-
input:
|
|
21
|
+
input: {
|
|
22
|
+
target: "https://api.enso.finance/api-yaml",
|
|
23
|
+
override: {
|
|
24
|
+
transformer: (spec: any) => {
|
|
25
|
+
// Fix all malformed array schemas that have items: { type: 'array' } without proper definition
|
|
26
|
+
const fixArraySchema = (obj: any) => {
|
|
27
|
+
if (!obj || typeof obj !== 'object') return;
|
|
28
|
+
|
|
29
|
+
// Fix array items that are themselves arrays without proper items definition
|
|
30
|
+
if (obj.type === 'array' && obj.items?.type === 'array' && !obj.items.items) {
|
|
31
|
+
obj.items = {
|
|
32
|
+
anyOf: [
|
|
33
|
+
{ type: 'string' },
|
|
34
|
+
{ type: 'number' },
|
|
35
|
+
{ type: 'boolean' },
|
|
36
|
+
{ type: 'object' },
|
|
37
|
+
]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Recursively fix nested objects
|
|
42
|
+
for (const key in obj) {
|
|
43
|
+
if (obj.hasOwnProperty(key)) {
|
|
44
|
+
fixArraySchema(obj[key]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Apply fix to all schemas
|
|
50
|
+
if (spec.components?.schemas) {
|
|
51
|
+
fixArraySchema(spec.components.schemas);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return spec;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
24
58
|
},
|
|
25
59
|
};
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ import { Fuel } from "lucide-react";
|
|
|
13
13
|
import { Tooltip } from "./ui/tooltip";
|
|
14
14
|
|
|
15
15
|
const BridgingFee = () => {
|
|
16
|
-
const {
|
|
16
|
+
const { routeData } = useRouteData();
|
|
17
17
|
const { tokenIn, chainIdIn, amountIn } = useAppDetails();
|
|
18
18
|
const { data: nativeTokenPriceData } = useEnsoPrice(chainIdIn, ETH_ADDRESS);
|
|
19
19
|
const {
|
|
@@ -21,14 +21,14 @@ const BridgingFee = () => {
|
|
|
21
21
|
} = useEnsoToken(ETH_ADDRESS, chainIdIn);
|
|
22
22
|
|
|
23
23
|
const gasValue = useMemo(() => {
|
|
24
|
-
let txCost = +(
|
|
24
|
+
let txCost = +(routeData?.tx?.value ?? 0);
|
|
25
25
|
|
|
26
26
|
if (compareCaseInsensitive(tokenIn, ETH_ADDRESS)) {
|
|
27
27
|
txCost -= +amountIn;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return normalizeValue(Math.max(0, txCost).toString(), 18);
|
|
31
|
-
}, [
|
|
31
|
+
}, [routeData?.tx?.value, tokenIn, amountIn]);
|
|
32
32
|
|
|
33
33
|
const gasCostUSD = +gasValue * +(nativeTokenPriceData ?? 0);
|
|
34
34
|
|
|
@@ -1,54 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
ReactElement,
|
|
4
|
-
useEffect,
|
|
5
|
-
useMemo,
|
|
6
|
-
useState,
|
|
7
|
-
ComponentType,
|
|
8
|
-
} from "react";
|
|
1
|
+
import { createContext, useEffect, useMemo, ComponentType } from "react";
|
|
9
2
|
import { Box } from "@chakra-ui/react";
|
|
10
|
-
import
|
|
11
|
-
import SelectTokenStep from "./steps/WalletTokenStep";
|
|
12
|
-
import SelectAmountStep from "./steps/WalletAmountStep";
|
|
13
|
-
import QuoteStep from "./steps/QuoteStep";
|
|
14
|
-
import WalletConfirmStep from "./steps/WalletConfirmStep";
|
|
15
|
-
import ExchangeFlow from "./steps/ExchangeFlow";
|
|
3
|
+
import FlowSelector from "./steps/FlowSelector";
|
|
16
4
|
import { useAppStore } from "@/store";
|
|
17
5
|
import { TxTracker } from "@/util/tx-tracker";
|
|
18
6
|
import ChakraProvider from "./ChakraProvider";
|
|
19
7
|
import { type CheckoutConfig, type SupportedExchanges } from "@/types";
|
|
20
8
|
|
|
21
9
|
type ICheckoutContext = {
|
|
22
|
-
step: string;
|
|
23
|
-
setStep: (step: string) => void;
|
|
24
|
-
|
|
25
|
-
flow: string;
|
|
26
|
-
setFlow: (flow: string) => void;
|
|
27
|
-
|
|
28
10
|
handleClose: () => void;
|
|
29
11
|
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const FLOWS: Record<
|
|
34
|
-
string,
|
|
35
|
-
{
|
|
36
|
-
steps: Record<string, ReactElement>;
|
|
37
|
-
}
|
|
38
|
-
> = {
|
|
39
|
-
mainFlow: {
|
|
40
|
-
steps: {
|
|
41
|
-
selectToken: <SelectTokenStep />,
|
|
42
|
-
selectAmount: <SelectAmountStep />,
|
|
43
|
-
quote: <QuoteStep />,
|
|
44
|
-
confirmTransfer: <WalletConfirmStep />,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
exchangeFlow: {
|
|
48
|
-
steps: {
|
|
49
|
-
connectExchange: <ExchangeFlow />,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
12
|
+
enableExchange?: SupportedExchanges[];
|
|
52
13
|
};
|
|
53
14
|
|
|
54
15
|
const CheckoutContext = createContext<ICheckoutContext>({} as ICheckoutContext);
|
|
@@ -62,9 +23,6 @@ const Checkout = ({
|
|
|
62
23
|
wrapper?: ComponentType;
|
|
63
24
|
onClose?: () => void;
|
|
64
25
|
}) => {
|
|
65
|
-
const [step, setStep] = useState("");
|
|
66
|
-
const [flow, setFlow] = useState("");
|
|
67
|
-
|
|
68
26
|
const setEnsoApiToken = useAppStore((state) => state.setEnsoApiToken);
|
|
69
27
|
const setTokenOut = useAppStore((state) => state.setTokenOut);
|
|
70
28
|
const setChainIdOut = useAppStore((state) => state.setChainIdOut);
|
|
@@ -76,8 +34,6 @@ const Checkout = ({
|
|
|
76
34
|
if (onClose) {
|
|
77
35
|
onClose();
|
|
78
36
|
}
|
|
79
|
-
setStep("");
|
|
80
|
-
setFlow("");
|
|
81
37
|
}
|
|
82
38
|
: undefined,
|
|
83
39
|
[onClose],
|
|
@@ -107,18 +63,14 @@ const Checkout = ({
|
|
|
107
63
|
return (
|
|
108
64
|
<CheckoutContext.Provider
|
|
109
65
|
value={{
|
|
110
|
-
step,
|
|
111
|
-
setStep,
|
|
112
|
-
flow,
|
|
113
|
-
setFlow,
|
|
114
66
|
handleClose,
|
|
115
|
-
|
|
67
|
+
enableExchange,
|
|
116
68
|
}}
|
|
117
69
|
>
|
|
118
70
|
<ChakraProvider themeConfig={theme}>
|
|
119
71
|
<WrapperComponent>
|
|
120
72
|
<TxTracker />
|
|
121
|
-
|
|
73
|
+
<FlowSelector />
|
|
122
74
|
</WrapperComponent>
|
|
123
75
|
</ChakraProvider>
|
|
124
76
|
</CheckoutContext.Provider>
|
|
@@ -45,11 +45,24 @@ const SecurityFeature = ({
|
|
|
45
45
|
</Box>
|
|
46
46
|
);
|
|
47
47
|
|
|
48
|
-
const ConfirmExchangeStep = ({
|
|
48
|
+
const ConfirmExchangeStep = ({
|
|
49
|
+
onConfirm,
|
|
50
|
+
exchangeName = "your exchange",
|
|
51
|
+
exchangeIcon,
|
|
52
|
+
}: {
|
|
53
|
+
onConfirm: () => void;
|
|
54
|
+
exchangeName?: string;
|
|
55
|
+
exchangeIcon?: string;
|
|
56
|
+
}) => {
|
|
49
57
|
return (
|
|
50
58
|
<BodyWrapper>
|
|
51
59
|
<Box display="flex" justifyContent="center" width="100%">
|
|
52
|
-
<Image
|
|
60
|
+
<Image
|
|
61
|
+
w={"48px"}
|
|
62
|
+
h={"48px"}
|
|
63
|
+
borderRadius={"full"}
|
|
64
|
+
src={exchangeIcon || BinanceIcon}
|
|
65
|
+
/>
|
|
53
66
|
</Box>
|
|
54
67
|
|
|
55
68
|
<Box
|
|
@@ -59,7 +72,7 @@ const ConfirmExchangeStep = ({ onConfirm }: { onConfirm: () => void }) => {
|
|
|
59
72
|
color="fg"
|
|
60
73
|
textAlign="center"
|
|
61
74
|
>
|
|
62
|
-
Enso Checkout uses a 3rd party to connect your
|
|
75
|
+
Enso Checkout uses a 3rd party to connect your {exchangeName} account.
|
|
63
76
|
</Box>
|
|
64
77
|
|
|
65
78
|
<Box display="flex" flexDirection="column" gap="12px" width="100%">
|
|
@@ -4,23 +4,28 @@ import {
|
|
|
4
4
|
Flex,
|
|
5
5
|
Icon,
|
|
6
6
|
Image,
|
|
7
|
+
Link,
|
|
7
8
|
Skeleton,
|
|
8
|
-
Text,
|
|
9
9
|
Table,
|
|
10
|
-
|
|
10
|
+
Text,
|
|
11
11
|
} from "@chakra-ui/react";
|
|
12
12
|
import { ExternalLink } from "lucide-react";
|
|
13
13
|
import { useAppDetails, useRouteData, useWalletIcon } from "@/util/enso-hooks";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
import {
|
|
15
|
+
formatNumber,
|
|
16
|
+
getChainIcon,
|
|
17
|
+
normalizeValue,
|
|
18
|
+
shortenAddress,
|
|
19
|
+
} from "@/util";
|
|
20
|
+
import { getChainEtherscanUrl, getChainName, Token } from "@/util/common";
|
|
17
21
|
import { Tooltip } from "@/components/ui/tooltip";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import
|
|
22
|
+
import {
|
|
23
|
+
MOCK_IMAGE_URL,
|
|
24
|
+
STARGATE_CHAIN_NAMES,
|
|
25
|
+
SupportedChainId,
|
|
26
|
+
} from "@/util/constants";
|
|
27
|
+
import { useMemo } from "react";
|
|
28
|
+
import { EXCHANGE_ICON_BY_TYPE } from "@/components/steps/ExchangeFlow";
|
|
24
29
|
|
|
25
30
|
export const ERROR_MSG =
|
|
26
31
|
"Swap not found for a required underlying of defi route, please make sure your amount is within an acceptable range";
|
|
@@ -93,11 +98,16 @@ const TokenIcon = ({
|
|
|
93
98
|
const QuoteParameters = () => {
|
|
94
99
|
const { address } = useAccount();
|
|
95
100
|
const { walletIcon, walletDisplayName } = useWalletIcon();
|
|
96
|
-
const {
|
|
97
|
-
|
|
101
|
+
const {
|
|
102
|
+
chainIdOut,
|
|
103
|
+
effectiveTokenOutData,
|
|
104
|
+
tokenInData,
|
|
105
|
+
amountIn,
|
|
106
|
+
chainIdIn,
|
|
107
|
+
selectedIntegration,
|
|
108
|
+
} = useAppDetails();
|
|
98
109
|
const { routeLoading, routeData, routeFetched, routerError } =
|
|
99
110
|
useRouteData();
|
|
100
|
-
const { isCheckout } = useAppStore();
|
|
101
111
|
const showRouteLoading = routeLoading || (!routeFetched && !routerError);
|
|
102
112
|
|
|
103
113
|
const routeErrorMessage: string | null =
|
|
@@ -117,6 +127,60 @@ const QuoteParameters = () => {
|
|
|
117
127
|
type: "/address",
|
|
118
128
|
});
|
|
119
129
|
|
|
130
|
+
const sourceInfo = useMemo(() => {
|
|
131
|
+
if (selectedIntegration?.type) {
|
|
132
|
+
const icon = EXCHANGE_ICON_BY_TYPE[selectedIntegration.type];
|
|
133
|
+
const name = selectedIntegration.name || selectedIntegration.type;
|
|
134
|
+
return (
|
|
135
|
+
<>
|
|
136
|
+
{icon && (
|
|
137
|
+
<Image
|
|
138
|
+
src={icon}
|
|
139
|
+
width={"16px"}
|
|
140
|
+
height={"16px"}
|
|
141
|
+
borderRadius={"full"}
|
|
142
|
+
/>
|
|
143
|
+
)}
|
|
144
|
+
<Text>{name}</Text>
|
|
145
|
+
</>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<>
|
|
151
|
+
{typeof walletIcon === "string" ? (
|
|
152
|
+
<Image src={walletIcon} width={"16px"} height={"16px"} />
|
|
153
|
+
) : (
|
|
154
|
+
walletIcon
|
|
155
|
+
)}
|
|
156
|
+
<Tooltip content={walletDisplayName}>
|
|
157
|
+
<Text>
|
|
158
|
+
{address &&
|
|
159
|
+
walletDisplayName +
|
|
160
|
+
" " +
|
|
161
|
+
shortenAddress(address, true)}
|
|
162
|
+
</Text>
|
|
163
|
+
</Tooltip>
|
|
164
|
+
{inWalletUrl && (
|
|
165
|
+
<Link href={inWalletUrl} target="_blank">
|
|
166
|
+
<Icon
|
|
167
|
+
as={ExternalLink}
|
|
168
|
+
color="fg.muted"
|
|
169
|
+
width={"16px"}
|
|
170
|
+
height={"16px"}
|
|
171
|
+
/>
|
|
172
|
+
</Link>
|
|
173
|
+
)}
|
|
174
|
+
</>
|
|
175
|
+
);
|
|
176
|
+
}, [
|
|
177
|
+
selectedIntegration,
|
|
178
|
+
walletIcon,
|
|
179
|
+
walletDisplayName,
|
|
180
|
+
address,
|
|
181
|
+
inWalletUrl,
|
|
182
|
+
]);
|
|
183
|
+
|
|
120
184
|
return (
|
|
121
185
|
<>
|
|
122
186
|
<Table.Root
|
|
@@ -126,7 +190,7 @@ const QuoteParameters = () => {
|
|
|
126
190
|
width={"100%"}
|
|
127
191
|
borderRadius={"sm"}
|
|
128
192
|
>
|
|
129
|
-
<Table.Body
|
|
193
|
+
<Table.Body>
|
|
130
194
|
<Table.Row>
|
|
131
195
|
<Table.Cell>Source</Table.Cell>
|
|
132
196
|
<Table.Cell
|
|
@@ -139,52 +203,7 @@ const QuoteParameters = () => {
|
|
|
139
203
|
gap={"8px"}
|
|
140
204
|
alignItems={"center"}
|
|
141
205
|
>
|
|
142
|
-
{
|
|
143
|
-
<>
|
|
144
|
-
<Image
|
|
145
|
-
src={BinanceBadge}
|
|
146
|
-
width={"16px"}
|
|
147
|
-
height={"16px"}
|
|
148
|
-
/>
|
|
149
|
-
<Text>Binance</Text>
|
|
150
|
-
</>
|
|
151
|
-
) : (
|
|
152
|
-
<>
|
|
153
|
-
{typeof walletIcon === "string" ? (
|
|
154
|
-
<Image
|
|
155
|
-
src={walletIcon}
|
|
156
|
-
width={"16px"}
|
|
157
|
-
height={"16px"}
|
|
158
|
-
/>
|
|
159
|
-
) : (
|
|
160
|
-
walletIcon
|
|
161
|
-
)}
|
|
162
|
-
<Tooltip content={walletDisplayName}>
|
|
163
|
-
<Text>
|
|
164
|
-
{address &&
|
|
165
|
-
walletDisplayName +
|
|
166
|
-
" " +
|
|
167
|
-
shortenAddress(
|
|
168
|
-
address,
|
|
169
|
-
true,
|
|
170
|
-
)}
|
|
171
|
-
</Text>
|
|
172
|
-
</Tooltip>
|
|
173
|
-
{inWalletUrl && (
|
|
174
|
-
<Link
|
|
175
|
-
href={inWalletUrl}
|
|
176
|
-
target="_blank"
|
|
177
|
-
>
|
|
178
|
-
<Icon
|
|
179
|
-
as={ExternalLink}
|
|
180
|
-
color="fg.muted"
|
|
181
|
-
width={"16px"}
|
|
182
|
-
height={"16px"}
|
|
183
|
-
/>
|
|
184
|
-
</Link>
|
|
185
|
-
)}
|
|
186
|
-
</>
|
|
187
|
-
)}
|
|
206
|
+
{sourceInfo}
|
|
188
207
|
</Box>
|
|
189
208
|
</Table.Cell>
|
|
190
209
|
</Table.Row>
|
|
@@ -243,7 +262,7 @@ const QuoteParameters = () => {
|
|
|
243
262
|
width={showRouteLoading ? "80px" : "auto"}
|
|
244
263
|
>
|
|
245
264
|
<Text>
|
|
246
|
-
{
|
|
265
|
+
{selectedIntegration?.type
|
|
247
266
|
? `~2min`
|
|
248
267
|
: chainIdIn !== chainIdOut
|
|
249
268
|
? `~1 min`
|
|
@@ -317,13 +336,13 @@ const QuoteParameters = () => {
|
|
|
317
336
|
{formatNumber(
|
|
318
337
|
normalizeValue(
|
|
319
338
|
routeData?.amountOut,
|
|
320
|
-
|
|
339
|
+
effectiveTokenOutData?.decimals,
|
|
321
340
|
),
|
|
322
341
|
)}{" "}
|
|
323
|
-
{
|
|
342
|
+
{effectiveTokenOutData?.symbol}
|
|
324
343
|
</Text>
|
|
325
344
|
<TokenIcon
|
|
326
|
-
token={
|
|
345
|
+
token={effectiveTokenOutData}
|
|
327
346
|
chainId={chainIdOut}
|
|
328
347
|
size={24}
|
|
329
348
|
/>
|
|
@@ -19,13 +19,14 @@ export const DetailRowContainer = chakra("div", {
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
export const TransactionDetailRow = () => {
|
|
22
|
-
const {
|
|
23
|
-
const { chainIdIn, chainIdOut,
|
|
22
|
+
const { routeData } = useRouteData();
|
|
23
|
+
const { chainIdIn, chainIdOut, selectedIntegration } = useAppDetails();
|
|
24
|
+
|
|
24
25
|
const slippage = useAppStore((state) => state.slippage);
|
|
25
26
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
26
27
|
|
|
27
|
-
const formattedPriceImpact =
|
|
28
|
-
? (-
|
|
28
|
+
const formattedPriceImpact = routeData?.priceImpact
|
|
29
|
+
? (-routeData?.priceImpact / 100).toFixed(2)
|
|
29
30
|
: "0.00";
|
|
30
31
|
|
|
31
32
|
const detailItems = [
|
|
@@ -38,7 +39,7 @@ export const TransactionDetailRow = () => {
|
|
|
38
39
|
label: "Max. slippage",
|
|
39
40
|
},
|
|
40
41
|
{
|
|
41
|
-
detail:
|
|
42
|
+
detail: selectedIntegration?.type
|
|
42
43
|
? `~2min`
|
|
43
44
|
: chainIdIn !== chainIdOut
|
|
44
45
|
? `~1 min`
|
|
@@ -80,13 +80,13 @@ const AssetCard = ({
|
|
|
80
80
|
}: {
|
|
81
81
|
icon?: ReactElement | string;
|
|
82
82
|
title: string;
|
|
83
|
-
balance
|
|
83
|
+
balance?: string | number;
|
|
84
84
|
usdBalance: string;
|
|
85
85
|
tag: string;
|
|
86
86
|
loading: boolean;
|
|
87
87
|
selected: boolean;
|
|
88
88
|
onClick: () => void;
|
|
89
|
-
chainId
|
|
89
|
+
chainId?: number;
|
|
90
90
|
}) => {
|
|
91
91
|
return (
|
|
92
92
|
<Card
|