@funkit/connect 9.7.2-next.0 → 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.
@@ -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
+ };
package/dist/index.js CHANGED
@@ -2985,7 +2985,7 @@ function setFunkitConnectVersion({ version }) {
2985
2985
  localStorage.setItem(storageKey, version);
2986
2986
  }
2987
2987
  function getCurrentSdkVersion() {
2988
- return "9.7.2-next.0";
2988
+ return "9.7.2-next.1";
2989
2989
  }
2990
2990
  function useFingerprint() {
2991
2991
  const fingerprint = useCallback3(() => {
@@ -30546,6 +30546,9 @@ function PaymentAmountSummary({
30546
30546
  }) {
30547
30547
  const { apiKey, textCustomizations, uiCustomizations } = useFunkitConfig();
30548
30548
  const targetChainId = isLighterxyzCustomer(apiKey) ? String(LIGHTER_CHAIN_ID) : originalChainId;
30549
+ const shouldRemoveSwapImpactFromYouReceive = useFeatureGate(
30550
+ "you-receive-remove-swap-impact"
30551
+ );
30549
30552
  const paymentMethod = checkoutItem?.selectedPaymentMethodInfo?.paymentMethod;
30550
30553
  const checkoutConfig = checkoutItem?.initSettings.config;
30551
30554
  const sourceAssetInfo = checkoutItem?.selectedSourceAssetInfo;
@@ -30623,7 +30626,12 @@ function PaymentAmountSummary({
30623
30626
  {
30624
30627
  labelIcon: uiCustomizations.customIcons.youReceive,
30625
30628
  label: receiveAmountLabel,
30626
- paymentTokenAmount: targetTokenAmount * (1 + swapImpactPct / 100),
30629
+ paymentTokenAmount: (() => {
30630
+ if (shouldRemoveSwapImpactFromYouReceive && displayAmounts?.isReceiveExact) {
30631
+ return targetTokenAmount;
30632
+ }
30633
+ return targetTokenAmount * (1 + swapImpactPct / 100);
30634
+ })(),
30627
30635
  valueSymbol: targetItemName ?? "",
30628
30636
  paymentUsdAmount: uiCustomizations.confirmationScreen.showReceiveAmountUsd ? receiveTokenUsdAmount : void 0,
30629
30637
  icon: /* @__PURE__ */ React174.createElement(