@funkit/connect 9.7.1 → 9.7.2-next.1

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 (87) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/__generated__/default_feature_gates.d.ts +1 -0
  3. package/dist/chunk-64NZSUGQ.js +368 -0
  4. package/dist/chunk-B2B6HDIE.js +238 -0
  5. package/dist/chunk-OQNN7EMQ.js +238 -0
  6. package/dist/chunk-S65TG73G.js +247 -0
  7. package/dist/chunk-VLAOBEJN.js +247 -0
  8. package/dist/clients/chunk-3LSYVQXK.js +289 -0
  9. package/dist/clients/chunk-SBQ2UUPK.js +214 -0
  10. package/dist/clients/chunk-V526Q43Z.js +271 -0
  11. package/dist/clients/fanatics.css +1 -1
  12. package/dist/clients/lighter.css +14393 -0
  13. package/dist/clients/lighter.d.ts +138 -0
  14. package/dist/clients/lighter.js +563 -0
  15. package/dist/components/Dropdown/TokenAndChainDropdown.css.d.ts +1 -0
  16. package/dist/hooks/queries/useRecentDeposits.d.ts +2 -0
  17. package/dist/hooks/track/CheckoutTrackingContext.d.ts +60 -0
  18. package/dist/hooks/useTokenChain.d.ts +21 -0
  19. package/dist/index.css +10 -10
  20. package/dist/index.js +16 -8
  21. package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframeContainer.d.ts +17 -0
  22. package/dist/modals/CheckoutModal/TransferToken/CheckoutNotifications.d.ts +6 -0
  23. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +76 -0
  24. package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +27 -0
  25. package/dist/modals/WithdrawalModal/WithdrawalTypeSelect.d.ts +16 -0
  26. package/dist/modals/WithdrwalModal/WithdrawalCallbackSuccess.d.ts +10 -0
  27. package/dist/modals/WithdrwalModal/WithdrawalContent.d.ts +11 -0
  28. package/dist/modals/WithdrwalModal/WithdrawalModal.d.ts +9 -0
  29. package/dist/modals/WithdrwalModal/WithdrawalSuccess.d.ts +15 -0
  30. package/dist/modals/WithdrwalModal/types.d.ts +5 -0
  31. package/dist/modals/WithdrwalModal/useWithdrawal.d.ts +24 -0
  32. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  33. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  34. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  35. package/dist/wallets/walletConnectors/chunk-34HACM5U.js +110 -0
  36. package/dist/wallets/walletConnectors/chunk-4C7ER452.js +93 -0
  37. package/dist/wallets/walletConnectors/chunk-53VYSPXK.js +66 -0
  38. package/dist/wallets/walletConnectors/chunk-5TN5Z2WY.js +87 -0
  39. package/dist/wallets/walletConnectors/chunk-6DRCY52E.js +69 -0
  40. package/dist/wallets/walletConnectors/chunk-6UCI7GM6.js +98 -0
  41. package/dist/wallets/walletConnectors/chunk-6YO27XOM.js +96 -0
  42. package/dist/wallets/walletConnectors/chunk-7OARWILZ.js +92 -0
  43. package/dist/wallets/walletConnectors/chunk-7V33VJAL.js +218 -0
  44. package/dist/wallets/walletConnectors/chunk-APHCF4DT.js +103 -0
  45. package/dist/wallets/walletConnectors/chunk-CJJT7LMT.js +96 -0
  46. package/dist/wallets/walletConnectors/chunk-DEFRRPXB.js +98 -0
  47. package/dist/wallets/walletConnectors/chunk-EKJHJFRN.js +69 -0
  48. package/dist/wallets/walletConnectors/chunk-FG2LDVXL.js +92 -0
  49. package/dist/wallets/walletConnectors/chunk-GH4M6FTK.js +95 -0
  50. package/dist/wallets/walletConnectors/chunk-GSHSWVEG.js +70 -0
  51. package/dist/wallets/walletConnectors/chunk-GVOQTORD.js +87 -0
  52. package/dist/wallets/walletConnectors/chunk-HETS3KKI.js +218 -0
  53. package/dist/wallets/walletConnectors/chunk-HOPH3TQ3.js +99 -0
  54. package/dist/wallets/walletConnectors/chunk-HRDPUW3V.js +94 -0
  55. package/dist/wallets/walletConnectors/chunk-HXWUH73P.js +93 -0
  56. package/dist/wallets/walletConnectors/chunk-IICWJWGZ.js +110 -0
  57. package/dist/wallets/walletConnectors/chunk-KO56HCTI.js +106 -0
  58. package/dist/wallets/walletConnectors/chunk-KWX2SYU2.js +100 -0
  59. package/dist/wallets/walletConnectors/chunk-LCIPVVH5.js +70 -0
  60. package/dist/wallets/walletConnectors/chunk-LI6QY2B5.js +94 -0
  61. package/dist/wallets/walletConnectors/chunk-PKMAPNN6.js +92 -0
  62. package/dist/wallets/walletConnectors/chunk-T4ROGPMF.js +106 -0
  63. package/dist/wallets/walletConnectors/chunk-TTHM3WUR.js +100 -0
  64. package/dist/wallets/walletConnectors/chunk-UDTBQV4Q.js +96 -0
  65. package/dist/wallets/walletConnectors/chunk-V6UOWTEZ.js +95 -0
  66. package/dist/wallets/walletConnectors/chunk-VJZWNQOF.js +92 -0
  67. package/dist/wallets/walletConnectors/chunk-XBLHZICW.js +103 -0
  68. package/dist/wallets/walletConnectors/chunk-XVBSJCW5.js +96 -0
  69. package/dist/wallets/walletConnectors/chunk-YIEASHLS.js +99 -0
  70. package/dist/wallets/walletConnectors/chunk-ZPSPK6LH.js +66 -0
  71. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  72. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  73. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  74. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  75. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  76. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  77. package/dist/wallets/walletConnectors/index.js +47 -47
  78. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  79. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  80. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  81. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  82. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  83. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  84. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  85. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  86. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  87. package/package.json +3 -3
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Lighter.xyz withdrawal.
3
+ *
4
+ * Lighter supports two withdrawal types — the SDK exposes them as a
5
+ * multi-method config so the user is shown a selection screen first:
6
+ *
7
+ * 1. **Fast** — routed through Fun + Relay. USDC Perps only. Multiple
8
+ * destination chains/tokens supported. Completes in seconds.
9
+ * 2. **Secure** — Lighter's native bridge to Ethereum mainnet. Supports all
10
+ * Lighter assets. Destination chain is locked to Ethereum and the
11
+ * destination token matches the source. Completion ~60+ minutes.
12
+ *
13
+ * Both callbacks conform to CustomWithdrawalConfig.withdrawCallback; the
14
+ * caller provides the actual on-chain implementation.
15
+ */
16
+ import { type LighterAccountIndex } from '@funkit/api-base';
17
+ import type { Address } from 'viem';
18
+ import type { CustomWithdrawalConfig, MultiMethodWithdrawalConfig } from '../providers/FunkitCheckoutContext/types';
19
+ /** Arbitrum USDC — the source token shown on the Fast withdrawal screen. */
20
+ export declare const ARBITRUM_USDC: Address;
21
+ /** Ethereum mainnet USDC — the source token shown on the Secure withdrawal screen. */
22
+ export declare const MAINNET_USDC: Address;
23
+ export interface LighterFastWithdrawalCallbackParams {
24
+ /** The UDA address to receive the withdrawn funds on the source chain. */
25
+ udaAddress: Address;
26
+ /** Amount in base units (from the quote). */
27
+ amountBaseUnit: bigint;
28
+ }
29
+ type LighterFastWithdrawalExec = (params: LighterFastWithdrawalCallbackParams) => Promise<void>;
30
+ export interface LighterFastWithdrawalConfig {
31
+ userId: string;
32
+ modalTitle?: string;
33
+ disableConnectedWallet?: boolean;
34
+ iconSrc?: string;
35
+ /**
36
+ * Submit the Fast withdrawal on Lighter targeting the UDA. Routed through
37
+ * Fun + Relay so the destination can be any supported chain/token.
38
+ */
39
+ sendLighterFastWithdrawal: LighterFastWithdrawalExec;
40
+ }
41
+ export interface LighterWithdrawalConfig {
42
+ userId: string;
43
+ /** Title shown on the selection screen. Defaults to "Withdraw". */
44
+ modalTitle?: string;
45
+ disableConnectedWallet?: boolean;
46
+ fastIconSrc?: string;
47
+ secureIconSrc?: string;
48
+ sendLighterFastWithdrawal: LighterFastWithdrawalExec;
49
+ sendLighterSecureWithdrawal: LighterSecureWithdrawalExec;
50
+ /**
51
+ * Returns the minimum Secure withdrawal amount in token units for the given symbol.
52
+ *
53
+ * ```ts
54
+ * getSecureMinWithdrawalAmount: (symbol) => ({ USDC: 1, ETH: 0.001 }[symbol] ?? 0)
55
+ * ```
56
+ */
57
+ getSecureMinWithdrawalAmount?: (symbol: string) => number;
58
+ }
59
+ export interface LighterSecureWithdrawalCallbackParams {
60
+ /** Withdrawal amount in token units (e.g. "1.5" for 1.5 ETH). */
61
+ amountTokenUnits: string;
62
+ /** The Lighter asset index (e.g. 1 for ETH, 3 for USDC). */
63
+ assetIndex: number;
64
+ }
65
+ type LighterSecureWithdrawalExec = (params: LighterSecureWithdrawalCallbackParams) => Promise<string>;
66
+ export interface LighterSecureWithdrawalConfig {
67
+ userId: string;
68
+ modalTitle?: string;
69
+ disableConnectedWallet?: boolean;
70
+ iconSrc?: string;
71
+ /**
72
+ * Submit the Secure withdrawal on Lighter's L2. Funds bridge directly to
73
+ * Ethereum mainnet. No relay/swap — the token withdrawn is the token received.
74
+ */
75
+ sendLighterSecureWithdrawal: LighterSecureWithdrawalExec;
76
+ /**
77
+ * Returns the minimum withdrawal amount in token units for the given symbol.
78
+ *
79
+ * ```ts
80
+ * getMinWithdrawalAmount: (symbol) => ({ USDC: 1, ETH: 0.001 }[symbol] ?? 0)
81
+ * ```
82
+ */
83
+ getMinWithdrawalAmount?: (symbol: string) => number;
84
+ }
85
+ /** Free (withdrawable) balance for a single Lighter asset: balance - locked. */
86
+ export declare function freeBalance(balance: string, lockedBalance: string): string;
87
+ /**
88
+ * Fetches all asset balances for a Lighter account. Returns:
89
+ *
90
+ * - `balances` — `Record<SYMBOL, freeBalance>` (uppercased symbol keys)
91
+ * - `assets` — raw asset list from the API (for building source-token options)
92
+ */
93
+ export declare function useLighterWithdrawalBalances({ accountIndex, }: {
94
+ accountIndex: LighterAccountIndex | undefined;
95
+ }): {
96
+ balances: Record<string, string>;
97
+ assets: import("../utils/customer").LighterAsset[];
98
+ isLoading: boolean;
99
+ };
100
+ /** Single-method config for Lighter's Secure withdrawal (bridge to Ethereum). */
101
+ export declare function createLighterSecureWithdrawalConfig(config: LighterSecureWithdrawalConfig): CustomWithdrawalConfig;
102
+ /** Single-method config for Lighter's Fast withdrawal. */
103
+ export declare function createLighterFastWithdrawalConfig(config: LighterFastWithdrawalConfig): CustomWithdrawalConfig;
104
+ /**
105
+ * Hook version of {@link createLighterWithdrawalConfig}.
106
+ *
107
+ * Fetches all Lighter asset balances for `config.userId` and injects them as
108
+ * `withdrawalSourceTokenBalance` into each method's config so the withdrawal
109
+ * form displays and validates against the real Lighter account balance.
110
+ *
111
+ * Drop-in replacement for `createLighterWithdrawalConfig` — call it in any
112
+ * React component/hook and pass the result directly to the withdrawal modal:
113
+ *
114
+ * ```tsx
115
+ * const withdrawalConfig = useLighterWithdrawalConfig({
116
+ * userId,
117
+ * sendLighterFastWithdrawal: ...,
118
+ * sendLighterSecureWithdrawal: ...,
119
+ * })
120
+ * <WithdrawalModal config={withdrawalConfig} ... />
121
+ * ```
122
+ */
123
+ export declare function useLighterWithdrawalConfig(config: LighterWithdrawalConfig): MultiMethodWithdrawalConfig;
124
+ /**
125
+ * Creates a full {@link MultiMethodWithdrawalConfig} for Lighter that renders
126
+ * the Fast vs Secure selection screen before the standard withdrawal flow.
127
+ *
128
+ * Usage:
129
+ * ```ts
130
+ * const withdrawalConfig = createLighterWithdrawalConfig({
131
+ * userId: walletAddress,
132
+ * sendLighterFastWithdrawal: async ({ udaAddress, amountBaseUnit }) => { ... },
133
+ * sendLighterSecureWithdrawal: async ({ amountTokenUnits, assetIndex }) => { ... },
134
+ * })
135
+ * ```
136
+ */
137
+ export declare function createLighterWithdrawalConfig(config: LighterWithdrawalConfig): MultiMethodWithdrawalConfig;
138
+ export {};
@@ -0,0 +1,563 @@
1
+ "use client";
2
+ import {
3
+ AsyncImage,
4
+ Box,
5
+ useFunkitTranslation
6
+ } from "./chunk-3LSYVQXK.js";
7
+ import {
8
+ generateClientMetadataForTokenTransfer
9
+ } from "./chunk-V526Q43Z.js";
10
+ import {
11
+ logger
12
+ } from "./chunk-H6F75ULR.js";
13
+
14
+ // src/clients/lighter.tsx
15
+ import {
16
+ LIGHTERXYZ_API_KEY as LIGHTERXYZ_API_KEY2,
17
+ initializeCheckoutTokenTransferAddress
18
+ } from "@funkit/api-base";
19
+ import { SOLANA_MAINNET_CHAIN_ID } from "@funkit/chains";
20
+ import i18next from "i18next";
21
+ import React2, { useEffect, useMemo as useMemo2 } from "react";
22
+ import { arbitrum, base, bsc, mainnet as mainnet2, optimism } from "viem/chains";
23
+
24
+ // src/components/Icons/EvmWallet.tsx
25
+ import React from "react";
26
+ var EvmWallet = ({ size = 20 }) => /* @__PURE__ */ React.createElement(
27
+ "svg",
28
+ {
29
+ width: size,
30
+ height: size,
31
+ viewBox: "0 0 20 20",
32
+ fill: "none",
33
+ xmlns: "http://www.w3.org/2000/svg"
34
+ },
35
+ /* @__PURE__ */ React.createElement(
36
+ "path",
37
+ {
38
+ d: "M13.3333 6.66628V3.75016C13.3333 3.05704 13.3333 2.71048 13.1873 2.49751C13.0598 2.31143 12.8622 2.18503 12.6398 2.14718C12.3852 2.10386 12.0706 2.24909 11.4413 2.53955L4.04918 5.95127C3.48792 6.21031 3.20729 6.33984 3.00175 6.54071C2.82005 6.71829 2.68135 6.93507 2.59625 7.17447C2.5 7.44527 2.5 7.75435 2.5 8.3725V12.4996M13.75 12.0829H13.7583M2.5 9.33295L2.5 14.8329C2.5 15.7664 2.5 16.2331 2.68166 16.5896C2.84144 16.9032 3.09641 17.1582 3.41002 17.318C3.76654 17.4996 4.23325 17.4996 5.16667 17.4996H14.8333C15.7668 17.4996 16.2335 17.4996 16.59 17.318C16.9036 17.1582 17.1586 16.9032 17.3183 16.5896C17.5 16.2331 17.5 15.7664 17.5 14.8329V9.33295C17.5 8.39953 17.5 7.93282 17.3183 7.5763C17.1586 7.26269 16.9036 7.00773 16.59 6.84794C16.2335 6.66628 15.7668 6.66628 14.8333 6.66628L5.16667 6.66628C4.23325 6.66628 3.76654 6.66628 3.41002 6.84793C3.09641 7.00772 2.84144 7.26269 2.68166 7.57629C2.5 7.93281 2.5 8.39952 2.5 9.33295ZM14.1667 12.0829C14.1667 12.3131 13.9801 12.4996 13.75 12.4996C13.5199 12.4996 13.3333 12.3131 13.3333 12.0829C13.3333 11.8528 13.5199 11.6663 13.75 11.6663C13.9801 11.6663 14.1667 11.8528 14.1667 12.0829Z",
39
+ stroke: "currentColor",
40
+ strokeWidth: "1.5",
41
+ strokeLinecap: "round",
42
+ strokeLinejoin: "round"
43
+ }
44
+ )
45
+ );
46
+
47
+ // src/providers/provideFunkitConnectChains.ts
48
+ import { chainMetadataById } from "@funkit/chains";
49
+
50
+ // src/utils/customer.ts
51
+ import { useQuery } from "@tanstack/react-query";
52
+
53
+ // src/consts/customers.ts
54
+ import {
55
+ AVANTIS_API_KEY,
56
+ BASED_API_KEY,
57
+ BSX_API_KEY,
58
+ ETHEREAL_API_KEY,
59
+ FANATICS_API_KEY,
60
+ HYENA_API_KEY,
61
+ HYPERDASH_API_KEY,
62
+ LIGHTERXYZ_API_KEY,
63
+ MONAD_API_KEY,
64
+ MONKEY_TILT_API_KEY,
65
+ OSTIUM_API_KEY,
66
+ PERPL_API_KEY,
67
+ POLYMARKET_API_KEY
68
+ } from "@funkit/api-base";
69
+ import { mainnet } from "viem/chains";
70
+ function isLighterxyzCustomer(apiKey) {
71
+ return apiKey === LIGHTERXYZ_API_KEY;
72
+ }
73
+
74
+ // src/providers/FunkitConfigContext.tsx
75
+ import {
76
+ createContext,
77
+ useContext,
78
+ useMemo
79
+ } from "react";
80
+ var DEFAULT_TEXT_CUSTOMIZATIONS = {
81
+ virtualFiat: "Deposit with SEPA",
82
+ brokerageOrExchange: "Connect Exchange",
83
+ debitOrCredit: "Deposit with Card",
84
+ accountBalance: "Wallet",
85
+ selectAccount: "Select an exchange",
86
+ sourceMethodTitle: "Your source",
87
+ tokensListTitle: "Your tokens",
88
+ transferTokens: "Transfer Crypto",
89
+ receiveDropdownTitle: "",
90
+ // Default to empty
91
+ receiveDropdownLabel: "Asset to Receive",
92
+ confirmationScreen: {
93
+ payAmountLabel: "You send",
94
+ receiveAmountLabel: "You receive"
95
+ },
96
+ paymentMethodSubtitles: {}
97
+ };
98
+ var DEFAULT_UI_CUSTOMIZATIONS = {
99
+ alignTitle: "center",
100
+ alwaysShowTopDivider: false,
101
+ showModalTitle: true,
102
+ callToActionsUppercase: false,
103
+ enableCompactList: false,
104
+ checkoutHistory: {
105
+ showGetHelpAsAlert: true,
106
+ simplifiedUi: false
107
+ },
108
+ confirmationScreen: {
109
+ preferDestinationWhenSame: false,
110
+ showAmountSummaryAbovePaymentMethod: false,
111
+ showDisclaimerAsAlert: true,
112
+ showInstantTimeEstimate: false,
113
+ showLeftAlignedDollarValueWithLabel: false,
114
+ showPaymentAmountUsd: false,
115
+ showReceiveAmountUsd: false,
116
+ stepIndicatorType: "spinner",
117
+ showTokenAmount: true,
118
+ showTransactionDigest: "none"
119
+ },
120
+ sourceChangeScreen: {
121
+ bottomBarCloseButton: {
122
+ enabled: false,
123
+ labelKey: "common.close"
124
+ },
125
+ showTargetAssetSelection: false,
126
+ showWalletOnInsufficientBalance: false,
127
+ paymentMethodIcons: {}
128
+ },
129
+ inputAmountScreen: {
130
+ allowTokenAmountInput: true
131
+ },
132
+ selectAssetScreen: {
133
+ isSecondaryTokenSymbolVisible: true,
134
+ navigateOnAssetClick: false
135
+ },
136
+ transferCryptoScreen: {
137
+ showYouSendYouReceive: false
138
+ },
139
+ withdrawalScreen: {},
140
+ selectBrokerageScreen: {},
141
+ connectExchangeScreen: {},
142
+ customIcons: {},
143
+ customFontFamily: {
144
+ primary: "",
145
+ secondary: "",
146
+ tertiary: ""
147
+ }
148
+ };
149
+ var DEFAULT_FUNKIT_CONFIG = {
150
+ apiKey: "",
151
+ appName: "",
152
+ textCustomizations: DEFAULT_TEXT_CUSTOMIZATIONS,
153
+ uiCustomizations: DEFAULT_UI_CUSTOMIZATIONS
154
+ };
155
+ var FunkitConfigContext = createContext(
156
+ DEFAULT_FUNKIT_CONFIG
157
+ );
158
+ function useFunkitConfig() {
159
+ const originalFunkitConfig = useContext(FunkitConfigContext);
160
+ const { t } = useFunkitTranslation();
161
+ const translatedDefaults = useMemo(() => {
162
+ return {
163
+ virtualFiat: t("textCustomizations.virtualFiat"),
164
+ brokerageOrExchange: t("textCustomizations.brokerageOrExchange"),
165
+ debitOrCredit: t("textCustomizations.debitOrCredit"),
166
+ accountBalance: t("textCustomizations.accountBalance"),
167
+ selectAccount: t("textCustomizations.selectAccount"),
168
+ sourceMethodTitle: t("textCustomizations.sourceMethodTitle"),
169
+ tokensListTitle: t("textCustomizations.tokensListTitle"),
170
+ transferTokens: t("textCustomizations.transferTokens"),
171
+ receiveDropdownTitle: t("textCustomizations.receiveDropdownTitle"),
172
+ receiveDropdownLabel: t("textCustomizations.receiveDropdownLabel"),
173
+ confirmationScreen: {
174
+ payAmountLabel: t("textCustomizations.payAmountLabel"),
175
+ receiveAmountLabel: t("textCustomizations.receiveAmountLabel")
176
+ },
177
+ paymentMethodSubtitles: {}
178
+ };
179
+ }, [t]);
180
+ const finalFunkitConfig = useMemo(() => {
181
+ return {
182
+ ...DEFAULT_FUNKIT_CONFIG,
183
+ ...originalFunkitConfig,
184
+ textCustomizations: {
185
+ ...translatedDefaults,
186
+ ...originalFunkitConfig.textCustomizations,
187
+ confirmationScreen: {
188
+ ...translatedDefaults.confirmationScreen,
189
+ ...originalFunkitConfig.textCustomizations?.confirmationScreen
190
+ },
191
+ paymentMethodSubtitles: {
192
+ ...translatedDefaults.paymentMethodSubtitles,
193
+ ...originalFunkitConfig.textCustomizations?.paymentMethodSubtitles
194
+ }
195
+ },
196
+ uiCustomizations: {
197
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations,
198
+ ...originalFunkitConfig.uiCustomizations,
199
+ checkoutHistory: {
200
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations.checkoutHistory,
201
+ ...originalFunkitConfig.uiCustomizations?.checkoutHistory
202
+ },
203
+ confirmationScreen: {
204
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations.confirmationScreen,
205
+ ...originalFunkitConfig.uiCustomizations?.confirmationScreen
206
+ },
207
+ connectExchangeScreen: {
208
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations.connectExchangeScreen,
209
+ ...originalFunkitConfig.uiCustomizations?.connectExchangeScreen
210
+ },
211
+ inputAmountScreen: {
212
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations.inputAmountScreen,
213
+ ...originalFunkitConfig.uiCustomizations?.inputAmountScreen
214
+ },
215
+ selectAssetScreen: {
216
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations.selectAssetScreen,
217
+ ...originalFunkitConfig.uiCustomizations?.selectAssetScreen
218
+ },
219
+ selectBrokerageScreen: {
220
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations.selectBrokerageScreen,
221
+ ...originalFunkitConfig.uiCustomizations?.selectBrokerageScreen
222
+ },
223
+ sourceChangeScreen: {
224
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations.sourceChangeScreen,
225
+ ...originalFunkitConfig.uiCustomizations?.sourceChangeScreen,
226
+ bottomBarCloseButton: {
227
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations.sourceChangeScreen.bottomBarCloseButton,
228
+ ...originalFunkitConfig.uiCustomizations?.sourceChangeScreen?.bottomBarCloseButton
229
+ }
230
+ },
231
+ transferCryptoScreen: {
232
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations.transferCryptoScreen,
233
+ ...originalFunkitConfig.uiCustomizations?.transferCryptoScreen
234
+ },
235
+ withdrawalScreen: {
236
+ ...DEFAULT_FUNKIT_CONFIG.uiCustomizations.withdrawalScreen,
237
+ ...originalFunkitConfig.uiCustomizations?.withdrawalScreen
238
+ }
239
+ }
240
+ };
241
+ }, [originalFunkitConfig, translatedDefaults]);
242
+ return finalFunkitConfig;
243
+ }
244
+
245
+ // src/utils/customer.ts
246
+ async function getLighterAccount(lookup, activeOnly) {
247
+ const params = new URLSearchParams({
248
+ by: lookup.by,
249
+ value: String(lookup.value),
250
+ ...activeOnly !== void 0 && { active_only: String(activeOnly) }
251
+ });
252
+ const response = await fetch(
253
+ `https://mainnet.zklighter.elliot.ai/api/v1/account?${params}`
254
+ );
255
+ if (!response.ok) {
256
+ throw new Error(`Failed to fetch lighter account: ${response.statusText}`);
257
+ }
258
+ return response.json();
259
+ }
260
+ function useLighterAccount(lookup, options) {
261
+ const { apiKey } = useFunkitConfig();
262
+ const isLighter = isLighterxyzCustomer(apiKey);
263
+ const enabled = isLighter && lookup !== null && (lookup.by === "index" ? true : !!lookup.value && lookup.value !== "0x");
264
+ const query = useQuery({
265
+ queryKey: [
266
+ "lighterAccount",
267
+ lookup?.by,
268
+ lookup?.value,
269
+ options?.activeOnly
270
+ ],
271
+ // biome-ignore lint/style/noNonNullAssertion: already checked for null
272
+ queryFn: () => getLighterAccount(lookup, options?.activeOnly),
273
+ enabled,
274
+ staleTime: 3e4,
275
+ retry: false
276
+ });
277
+ return {
278
+ ...query,
279
+ account: query.data?.accounts?.[0]
280
+ };
281
+ }
282
+
283
+ // src/clients/lighter.tsx
284
+ var ARBITRUM_USDC = "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
285
+ var MAINNET_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
286
+ function freeBalance(balance, lockedBalance) {
287
+ return String(Math.max(0, Number(balance) - Number(lockedBalance)));
288
+ }
289
+ function asLighterAccountIndex(s) {
290
+ if (!/^\d+$/.test(s)) {
291
+ throw new Error(`Invalid LighterAccountIndex: ${s}`);
292
+ }
293
+ return s;
294
+ }
295
+ function useLighterWithdrawalBalances({
296
+ accountIndex
297
+ }) {
298
+ const { account, isLoading, error } = useLighterAccount(
299
+ accountIndex ? { by: "index", value: accountIndex } : null
300
+ );
301
+ useEffect(() => {
302
+ logger.debug("lighter:withdrawal:balances:query", {
303
+ accountIndex,
304
+ isLoading,
305
+ hasAccount: !!account,
306
+ error: error instanceof Error ? error.message : error
307
+ });
308
+ }, [accountIndex, isLoading, account, error]);
309
+ const balances = useMemo2(() => {
310
+ if (!account) {
311
+ return {};
312
+ }
313
+ const result = {};
314
+ for (const asset of account.assets) {
315
+ const symbol = asset.symbol.toUpperCase();
316
+ if (symbol === "USDC") {
317
+ continue;
318
+ }
319
+ result[symbol] = freeBalance(asset.balance, asset.locked_balance);
320
+ }
321
+ result.USDC = account.total_asset_value;
322
+ logger.info("lighter:withdrawal:balances:resolved", {
323
+ accountIndex,
324
+ balances: result
325
+ });
326
+ return result;
327
+ }, [account, accountIndex]);
328
+ return {
329
+ balances,
330
+ assets: account?.assets ?? [],
331
+ isLoading
332
+ };
333
+ }
334
+ function buildSecureWithdrawalCallback({
335
+ exec
336
+ }) {
337
+ return async (param) => {
338
+ const { targetAssetAddress, destinationAddress } = param;
339
+ const assetIndex = param.lighterAssetIndex;
340
+ if (assetIndex === void 0) {
341
+ logger.error(
342
+ "lighter:withdrawal:secure:missingAssetIndex",
343
+ new Error("Missing lighterAssetIndex for Secure withdrawal"),
344
+ { targetAssetAddress, destinationAddress }
345
+ );
346
+ return;
347
+ }
348
+ const amountTokenUnits = param.userInputAmount;
349
+ if (!amountTokenUnits) {
350
+ logger.error(
351
+ "lighter:withdrawal:secure:missingAmount",
352
+ new Error("Missing userInputAmount for Secure withdrawal"),
353
+ { assetIndex, targetAssetAddress, destinationAddress }
354
+ );
355
+ return;
356
+ }
357
+ logger.info("lighter:withdrawal:secure:start", {
358
+ assetIndex,
359
+ amountTokenUnits,
360
+ targetAssetAddress,
361
+ destinationAddress
362
+ });
363
+ const txHash = await exec({
364
+ amountTokenUnits,
365
+ assetIndex
366
+ });
367
+ logger.info("lighter:withdrawal:secure:submitted", {
368
+ amountTokenUnits,
369
+ assetIndex,
370
+ txHash
371
+ });
372
+ return txHash;
373
+ };
374
+ }
375
+ function createLighterSecureWithdrawalConfig(config) {
376
+ return {
377
+ modalTitle: config.modalTitle ?? i18next.t("withdrawal.withdraw"),
378
+ disableConnectedWallet: config.disableConnectedWallet,
379
+ withdrawCallback: buildSecureWithdrawalCallback({
380
+ exec: config.sendLighterSecureWithdrawal
381
+ }),
382
+ sourceChainId: mainnet2.id.toString(),
383
+ sourceTokenSymbol: "USDC",
384
+ defaultReceiveToken: "USDC",
385
+ sourceTokenAddress: MAINNET_USDC,
386
+ iconSrc: config.iconSrc ?? "https://sdk-cdn.fun.xyz/images/logos/lighter.png",
387
+ getMinWithdrawalUSD: () => 0,
388
+ getMinWithdrawalAmount: config.getMinWithdrawalAmount
389
+ };
390
+ }
391
+ function buildFastWithdrawalCallback({
392
+ userId,
393
+ exec
394
+ }) {
395
+ return async (param) => {
396
+ const { targetAssetAddress, targetChainId, destinationAddress, funQuote } = param;
397
+ logger.info("lighter:withdrawal:fast:start", {
398
+ targetChainId,
399
+ targetAssetAddress,
400
+ destinationAddress,
401
+ quoteId: param.quoteId
402
+ });
403
+ const transferInit = await initializeCheckoutTokenTransferAddress({
404
+ apiKey: LIGHTERXYZ_API_KEY2,
405
+ userId,
406
+ recipientAddr: destinationAddress,
407
+ toChainId: targetChainId.toString(),
408
+ toTokenAddress: targetAssetAddress,
409
+ logger,
410
+ clientMetadata: {
411
+ ...generateClientMetadataForTokenTransfer(),
412
+ isWithdrawal: true
413
+ }
414
+ });
415
+ const udaAddress = transferInit.depositAddr;
416
+ const quote = funQuote;
417
+ const amountStr = quote?.baseQuote?.estTotalFromAmountBaseUnit;
418
+ if (!amountStr) {
419
+ logger.error(
420
+ "lighter:withdrawal:fast:missingAmountInQuote",
421
+ new Error("Missing withdrawal amount in quote"),
422
+ { quote, udaAddress, targetChainId, targetAssetAddress }
423
+ );
424
+ return;
425
+ }
426
+ await exec({ udaAddress, amountBaseUnit: BigInt(amountStr) });
427
+ logger.info("lighter:withdrawal:fast:submitted", {
428
+ udaAddress,
429
+ amountBaseUnit: amountStr
430
+ });
431
+ };
432
+ }
433
+ function createLighterFastWithdrawalConfig(config) {
434
+ return {
435
+ modalTitle: config.modalTitle ?? i18next.t("withdrawal.withdraw"),
436
+ disableConnectedWallet: config.disableConnectedWallet,
437
+ withdrawCallback: buildFastWithdrawalCallback({
438
+ userId: config.userId,
439
+ exec: config.sendLighterFastWithdrawal
440
+ }),
441
+ // Fast withdrawals source USDC out of Lighter Perps; Relay takes over
442
+ // on Arbitrum and routes to any supported destination token/chain.
443
+ sourceChainId: arbitrum.id.toString(),
444
+ sourceTokenSymbol: "USDC",
445
+ defaultReceiveToken: "USDC",
446
+ sourceTokenAddress: ARBITRUM_USDC,
447
+ iconSrc: config.iconSrc ?? "https://sdk-cdn.fun.xyz/images/logos/lighter.png",
448
+ getMinWithdrawalUSD: () => 4
449
+ };
450
+ }
451
+ function ChainIconStack({ chainIds }) {
452
+ return /* @__PURE__ */ React2.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "flex-end" }, chainIds.map((chainId, index) => {
453
+ const metadata = chainMetadataById[chainId];
454
+ return /* @__PURE__ */ React2.createElement(
455
+ Box,
456
+ {
457
+ key: chainId,
458
+ position: "relative",
459
+ style: { right: `${(chainIds.length - index - 1) * -2}px` }
460
+ },
461
+ /* @__PURE__ */ React2.createElement(
462
+ AsyncImage,
463
+ {
464
+ alt: metadata?.name ?? "",
465
+ borderRadius: "full",
466
+ src: metadata?.iconUrl ?? "",
467
+ height: 16,
468
+ width: 16
469
+ }
470
+ )
471
+ );
472
+ }));
473
+ }
474
+ var LIGHTER_FAST_PREVIEW_CHAIN_IDS = [
475
+ arbitrum.id,
476
+ base.id,
477
+ optimism.id,
478
+ bsc.id,
479
+ SOLANA_MAINNET_CHAIN_ID
480
+ ];
481
+ var LIGHTER_SECURE_PREVIEW_CHAIN_IDS = [mainnet2.id];
482
+ function buildLighterMultiMethodConfig({
483
+ config,
484
+ t,
485
+ withBalance
486
+ }) {
487
+ const fastConfig = createLighterFastWithdrawalConfig({
488
+ userId: config.userId,
489
+ modalTitle: config.modalTitle,
490
+ disableConnectedWallet: config.disableConnectedWallet,
491
+ iconSrc: config.fastIconSrc,
492
+ sendLighterFastWithdrawal: config.sendLighterFastWithdrawal
493
+ });
494
+ const secureConfig = createLighterSecureWithdrawalConfig({
495
+ userId: config.userId,
496
+ modalTitle: config.modalTitle,
497
+ disableConnectedWallet: config.disableConnectedWallet,
498
+ iconSrc: config.secureIconSrc,
499
+ sendLighterSecureWithdrawal: config.sendLighterSecureWithdrawal,
500
+ getMinWithdrawalAmount: config.getSecureMinWithdrawalAmount
501
+ });
502
+ const fast = {
503
+ id: "lighter-fast",
504
+ keyText: t("withdrawal.methodFast"),
505
+ subtitleText: t("withdrawal.fastDisclaimer"),
506
+ icon: /* @__PURE__ */ React2.createElement(EvmWallet, { size: 20 }),
507
+ valueIcon: /* @__PURE__ */ React2.createElement(ChainIconStack, { chainIds: LIGHTER_FAST_PREVIEW_CHAIN_IDS }),
508
+ config: withBalance ? {
509
+ ...fastConfig,
510
+ withdrawalSourceTokenBalance: withBalance(
511
+ fastConfig.sourceTokenSymbol
512
+ )
513
+ } : fastConfig
514
+ };
515
+ const secure = {
516
+ id: "lighter-secure",
517
+ keyText: t("withdrawal.methodSecure"),
518
+ subtitleText: t("withdrawal.secureDisclaimer"),
519
+ icon: /* @__PURE__ */ React2.createElement(EvmWallet, { size: 20 }),
520
+ valueIcon: /* @__PURE__ */ React2.createElement(ChainIconStack, { chainIds: LIGHTER_SECURE_PREVIEW_CHAIN_IDS }),
521
+ config: withBalance ? {
522
+ ...secureConfig,
523
+ withdrawalSourceTokenBalance: withBalance(
524
+ secureConfig.sourceTokenSymbol
525
+ )
526
+ } : secureConfig
527
+ };
528
+ return {
529
+ modalTitle: config.modalTitle ?? t("withdrawal.withdraw"),
530
+ sectionTitle: t("withdrawal.sectionCrypto"),
531
+ methods: [fast, secure]
532
+ };
533
+ }
534
+ function useLighterWithdrawalConfig(config) {
535
+ const { t } = useFunkitTranslation();
536
+ const { balances } = useLighterWithdrawalBalances({
537
+ accountIndex: asLighterAccountIndex(config.userId)
538
+ });
539
+ return useMemo2(
540
+ () => buildLighterMultiMethodConfig({
541
+ config,
542
+ t,
543
+ withBalance: (symbol) => () => balances[symbol.toUpperCase()] ?? "0"
544
+ }),
545
+ [config, balances, t]
546
+ );
547
+ }
548
+ function createLighterWithdrawalConfig(config) {
549
+ return buildLighterMultiMethodConfig({
550
+ config,
551
+ t: i18next.t.bind(i18next)
552
+ });
553
+ }
554
+ export {
555
+ ARBITRUM_USDC,
556
+ MAINNET_USDC,
557
+ createLighterFastWithdrawalConfig,
558
+ createLighterSecureWithdrawalConfig,
559
+ createLighterWithdrawalConfig,
560
+ freeBalance,
561
+ useLighterWithdrawalBalances,
562
+ useLighterWithdrawalConfig
563
+ };
@@ -0,0 +1 @@
1
+ export declare const hideOnXsmallScreenSize: string;