@funkit/connect 12.16.0 → 12.17.0

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 (64) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/clients/axiom.d.ts +1 -1
  3. package/dist/clients/{chunk-7JYLS7IF.js → chunk-2L6IKKNH.js} +48 -32
  4. package/dist/clients/{chunk-6IH7AWFA.js → chunk-HANOVGPH.js} +1 -1
  5. package/dist/clients/{chunk-OB5GKTP2.js → chunk-LVR6RQMO.js} +1 -1
  6. package/dist/clients/chunk-R25GIAD5.js +59 -0
  7. package/dist/clients/{chunk-UZ3NA7HN.js → chunk-TWP5LFPX.js} +5 -5
  8. package/dist/clients/{chunk-BKK2BFIP.js → chunk-V4RIF2NR.js} +1 -1
  9. package/dist/clients/fanatics.js +2 -2
  10. package/dist/clients/internal/nado/withdrawalCallback.js +3 -3
  11. package/dist/clients/internal/nado/withdrawalErrors.js +2 -2
  12. package/dist/clients/internal/nado/withdrawalForm.js +4 -4
  13. package/dist/clients/internal/nado/withdrawalStatus.js +3 -3
  14. package/dist/clients/lighter.d.ts +29 -16
  15. package/dist/clients/lighter.js +149 -68
  16. package/dist/clients/mallard.js +2 -2
  17. package/dist/clients/nado.js +3 -3
  18. package/dist/consts/customers.d.ts +12 -1
  19. package/dist/domains/convert/assets.d.ts +22 -0
  20. package/dist/domains/convert/balances.d.ts +21 -24
  21. package/dist/domains/convert/errors.d.ts +38 -0
  22. package/dist/domains/convert/execution.d.ts +39 -0
  23. package/dist/domains/convert/inputAmount.d.ts +24 -0
  24. package/dist/domains/convert/quote.d.ts +24 -0
  25. package/dist/domains/convert/settlement.d.ts +47 -0
  26. package/dist/domains/convert/submit.d.ts +46 -0
  27. package/dist/domains/convert/types.d.ts +39 -23
  28. package/dist/domains/nativeFeeReserve.d.ts +29 -0
  29. package/dist/domains/quote.d.ts +14 -1
  30. package/dist/hooks/queries/useWithdrawFops.d.ts +6 -0
  31. package/dist/hooks/queries/useWithdrawalQuote.d.ts +4 -1
  32. package/dist/hooks/track/WithdrawModalEvent.d.ts +1 -0
  33. package/dist/hooks/track/analytics/events.d.ts +59 -1
  34. package/dist/hooks/track/analytics/mappers.d.ts +5 -4
  35. package/dist/hooks/track/analytics/resolveIframeStepNavigation.d.ts +18 -0
  36. package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +2 -2
  37. package/dist/hooks/track/analytics/useTrackSwappedIframeEvents.d.ts +5 -0
  38. package/dist/hooks/track/analytics/useWithdrawalAnalytics.d.ts +2 -2
  39. package/dist/hooks/track/useQuoteAttemptCounter.d.ts +2 -0
  40. package/dist/hooks/useConvertAssets.d.ts +9 -0
  41. package/dist/hooks/useConvertBalances.d.ts +44 -0
  42. package/dist/hooks/useConvertExecute.d.ts +77 -0
  43. package/dist/hooks/useConvertInputAmount.d.ts +26 -0
  44. package/dist/hooks/useConvertMaxAmount.d.ts +11 -0
  45. package/dist/hooks/useConvertQuote.d.ts +33 -0
  46. package/dist/hooks/useConvertTransactionStatus.d.ts +23 -0
  47. package/dist/hooks/useMaxSpendableAmount.d.ts +19 -0
  48. package/dist/hooks/usePrepareConvertSubmit.d.ts +22 -0
  49. package/dist/hooks/useStepQueryReadiness.d.ts +45 -15
  50. package/dist/index.d.ts +1 -1
  51. package/dist/index.js +2396 -1598
  52. package/dist/modals/CheckoutModal/SwappedIframe/swappedIframeReady.track.d.ts +8 -0
  53. package/dist/modals/CheckoutModal/stepTransition.d.ts +1 -2
  54. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +48 -15
  55. package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +3 -1
  56. package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +4 -1
  57. package/dist/modals/WithdrawalModal/useMaxWithdrawableAmount.d.ts +10 -0
  58. package/dist/modals/WithdrawalModal/withdrawalFormHelpers.d.ts +28 -8
  59. package/dist/providers/FunkitQuoteContext.track.d.ts +23 -3
  60. package/dist/providers/SwappedProvider.d.ts +7 -0
  61. package/dist/utils/customer.d.ts +34 -4
  62. package/dist/wallets/walletConnectors/index.js +44 -44
  63. package/package.json +6 -6
  64. package/dist/clients/chunk-6EU6CXNH.js +0 -20
@@ -1,11 +1,12 @@
1
1
  "use client";
2
2
  import {
3
+ LIGHTER_API_KEY_BY_CHAIN_ID,
3
4
  useLighterAccountQuery,
4
5
  useLighterAccountsQuery
5
- } from "./chunk-6EU6CXNH.js";
6
+ } from "./chunk-R25GIAD5.js";
6
7
  import {
7
8
  useFunkitConfig
8
- } from "./chunk-6IH7AWFA.js";
9
+ } from "./chunk-HANOVGPH.js";
9
10
  import {
10
11
  AsyncImage,
11
12
  Box,
@@ -13,21 +14,24 @@ import {
13
14
  } from "./chunk-RQALGV5U.js";
14
15
  import {
15
16
  useFunkitTranslation
16
- } from "./chunk-OB5GKTP2.js";
17
+ } from "./chunk-LVR6RQMO.js";
17
18
  import "./chunk-OODIKHYE.js";
18
19
  import "./chunk-2W2P3OS6.js";
19
- import "./chunk-7JYLS7IF.js";
20
+ import "./chunk-2L6IKKNH.js";
20
21
  import {
21
22
  logger
22
23
  } from "./chunk-AHYOV7AV.js";
23
24
 
24
25
  // src/clients/lighter.tsx
25
- import { LIGHTERXYZ_API_KEY } from "@funkit/api-base";
26
- import { SOLANA_MAINNET_CHAIN_ID } from "@funkit/chains";
27
- import { RELAY_LIGHTER_CHAIN_ID as RELAY_LIGHTER_CHAIN_ID2 } from "@funkit/fun-relay";
26
+ import {
27
+ LIGHTER_CHAIN_ID as LIGHTER_CHAIN_ID2,
28
+ LIGHTER_RH_CHAIN_ID,
29
+ SOLANA_MAINNET_CHAIN_ID
30
+ } from "@funkit/chains";
31
+ import { useLogOnce as useLogOnce2 } from "@funkit/connect-core";
28
32
  import i18next from "i18next";
29
33
  import React7, { useMemo as useMemo3 } from "react";
30
- import { arbitrum, base, bsc, mainnet as mainnet2, optimism } from "viem/chains";
34
+ import { arbitrum, base, bsc, optimism } from "viem/chains";
31
35
 
32
36
  // src/components/Icons/EvmWallet.tsx
33
37
  import React from "react";
@@ -281,11 +285,12 @@ function SupportedChainList({
281
285
 
282
286
  // src/clients/lighter.tsx
283
287
  import {
284
- LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS as LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS2,
285
288
  LIGHTER_FAST_MAX_WITHDRAWAL_USD as LIGHTER_FAST_MAX_WITHDRAWAL_USD2,
286
- LIGHTER_USDC_SPOT_SYMBOL as LIGHTER_USDC_SPOT_SYMBOL2,
289
+ LIGHTER_INSTANCES as LIGHTER_INSTANCES2,
290
+ lighterWithdrawBaseUnits as coreLighterWithdrawBaseUnits,
287
291
  createLighterAdaptedWallet,
288
292
  getLighterBaseSymbol as getLighterBaseSymbol3,
293
+ getLighterDefaultSecureMinWithdrawalAmounts,
289
294
  trackLighterSecureWithdrawal,
290
295
  useLighterWithdrawalDelaySeconds
291
296
  } from "@funkit/connect-core/clients/lighter";
@@ -295,7 +300,11 @@ import {
295
300
  DirectExecutionType,
296
301
  createDirectExecution
297
302
  } from "@funkit/api-base";
298
- import { RELAY_LIGHTER_CHAIN_ID } from "@funkit/fun-relay";
303
+ import {
304
+ LIGHTER_CHAIN_ID,
305
+ LIGHTER_CHAIN_IDS,
306
+ toLighterChainId
307
+ } from "@funkit/chains";
299
308
  import { formatAddress, formatCryptoAndStringify } from "@funkit/utils";
300
309
  import { v4 as uuid } from "uuid";
301
310
  import React6, {
@@ -341,12 +350,16 @@ function formatSecondsTranslated(seconds, t, specifyUnderMinute = false, omitSec
341
350
  // src/modals/WithdrawalModal/LighterWithdrawal.tsx
342
351
  import { useLogOnce } from "@funkit/connect-core";
343
352
  import {
353
+ LIGHTER_INSTANCES,
344
354
  LIGHTER_ROUTE_TYPE,
345
355
  buildLighterL1WithdrawTransaction,
346
356
  getLighterBaseSymbol,
347
- getLighterSecureMainnetDecimals,
357
+ getLighterSecureL1Address,
358
+ getLighterSecureL1Decimals,
348
359
  isLighterWithdrawalRateLimitError,
349
360
  lighterWithdrawBaseUnits,
361
+ resolveLighterAssetIndex,
362
+ resolveLighterSecureRouteType,
350
363
  resolveLighterWithdrawalExplorerUrl,
351
364
  truncateToDecimals,
352
365
  useLighterFastUnstakedFeeTokens
@@ -361,9 +374,9 @@ import {
361
374
  LIGHTER_UNSTAKED_FEE_TOKENS,
362
375
  LIGHTER_USDC_SPOT_SYMBOL,
363
376
  getLighterBaseSymbol as getLighterBaseSymbol2,
364
- getLighterSecureMainnetAddress,
365
- resolveLighterAssetIndex,
366
- resolveLighterSecureRouteType
377
+ getLighterSecureL1Address as getLighterSecureL1Address2,
378
+ resolveLighterAssetIndex as resolveLighterAssetIndex2,
379
+ resolveLighterSecureRouteType as resolveLighterSecureRouteType2
367
380
  } from "@funkit/connect-core/clients/lighter";
368
381
  var LIGHTER_FAST_METHOD_ID = "lighter-fast";
369
382
  var LIGHTER_SECURE_METHOD_ID = "lighter-secure";
@@ -373,14 +386,15 @@ import { LIGHTER_ROUTE_TYPE as LIGHTER_ROUTE_TYPE3 } from "@funkit/connect-core/
373
386
  import {
374
387
  LIGHTER_WITHDRAW_ABI,
375
388
  buildLighterL1WithdrawTransaction as buildLighterL1WithdrawTransaction2,
376
- isLighterWithdrawalRateLimitError as isLighterWithdrawalRateLimitError2,
377
- lighterWithdrawBaseUnits as lighterWithdrawBaseUnits2
389
+ isLighterWithdrawalRateLimitError as isLighterWithdrawalRateLimitError2
378
390
  } from "@funkit/connect-core/clients/lighter";
379
391
  var LIGHTER_USDC_PERPS_ADDRESS = "0x0000000000000000000000000000000000000000";
380
- var MAINNET_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
381
- function useLighterSecureDelayText() {
392
+ function lighterWithdrawBaseUnits2(assetIndex, amountTokenUnits, chainId = LIGHTER_CHAIN_ID2) {
393
+ return coreLighterWithdrawBaseUnits(assetIndex, amountTokenUnits, chainId);
394
+ }
395
+ function useLighterSecureDelayText(enabled, chainId) {
382
396
  const { t } = useFunkitTranslation();
383
- const seconds = useLighterWithdrawalDelaySeconds();
397
+ const seconds = useLighterWithdrawalDelaySeconds({ enabled, chainId });
384
398
  if (seconds === void 0) {
385
399
  return void 0;
386
400
  }
@@ -394,7 +408,8 @@ function useLighterSecureDelayText() {
394
408
  );
395
409
  }
396
410
  function buildSecureWithdrawalCallback({
397
- exec
411
+ exec,
412
+ chainId
398
413
  }) {
399
414
  return async (param) => {
400
415
  const { targetAssetAddress, destinationAddress } = param;
@@ -418,7 +433,10 @@ function buildSecureWithdrawalCallback({
418
433
  return;
419
434
  }
420
435
  const withdrawalUSD = param.withdrawalUSD ?? "0";
436
+ const l1ChainId = LIGHTER_INSTANCES2[chainId].secureL1Chain.id;
421
437
  logger.info("lighter:withdrawal:secure:start", {
438
+ chainId,
439
+ l1ChainId,
422
440
  assetIndex,
423
441
  routeType,
424
442
  amountTokenUnits,
@@ -428,16 +446,19 @@ function buildSecureWithdrawalCallback({
428
446
  const txHash = await exec({
429
447
  amountTokenUnits,
430
448
  assetIndex,
431
- routeType
449
+ routeType,
450
+ chainId
432
451
  });
433
452
  logger.info("lighter:withdrawal:secure:submitted", {
453
+ chainId,
454
+ l1ChainId,
434
455
  amountTokenUnits,
435
456
  assetIndex,
436
457
  routeType,
437
458
  txHash
438
459
  });
439
460
  void trackLighterSecureWithdrawal({
440
- apiKey: LIGHTERXYZ_API_KEY,
461
+ apiKey: LIGHTER_API_KEY_BY_CHAIN_ID[chainId],
441
462
  logger,
442
463
  // Secure locks the destination to the connected wallet, so the L1
443
464
  // recipient address doubles as the userId for tracking purposes.
@@ -445,14 +466,17 @@ function buildSecureWithdrawalCallback({
445
466
  txHash,
446
467
  recipientAddr: destinationAddress,
447
468
  assetIndex,
448
- mainnetTokenAddress: targetAssetAddress,
469
+ l1TokenAddress: targetAssetAddress,
449
470
  amountTokenUnits,
450
- withdrawalUSD
471
+ withdrawalUSD,
472
+ chainId
451
473
  });
452
474
  return txHash;
453
475
  };
454
476
  }
455
477
  function createLighterSecureWithdrawalConfig(config) {
478
+ const chainId = config.chainId ?? LIGHTER_CHAIN_ID2;
479
+ const { perpsCollateral, secureL1Chain } = LIGHTER_INSTANCES2[chainId];
456
480
  return {
457
481
  modalTitle: config.modalTitle ?? i18next.t("withdrawal.withdraw"),
458
482
  disableConnectedWallet: config.disableConnectedWallet,
@@ -460,12 +484,14 @@ function createLighterSecureWithdrawalConfig(config) {
460
484
  sourceTokens: config.sourceTokens,
461
485
  withdrawalSourceTokenBalance: config.withdrawalSourceTokenBalance,
462
486
  withdrawCallback: buildSecureWithdrawalCallback({
463
- exec: config.sendLighterSecureWithdrawal
487
+ exec: config.sendLighterSecureWithdrawal,
488
+ chainId
464
489
  }),
465
- sourceChainId: mainnet2.id.toString(),
466
- sourceTokenSymbol: "USDC",
467
- defaultReceiveToken: "USDC",
468
- sourceTokenAddress: MAINNET_USDC,
490
+ // The L1 is the source chain the modal shows and prices against.
491
+ sourceChainId: secureL1Chain.id.toString(),
492
+ sourceTokenSymbol: perpsCollateral.symbol,
493
+ defaultReceiveToken: perpsCollateral.symbol,
494
+ sourceTokenAddress: perpsCollateral.l1Address,
469
495
  iconSrc: config.iconSrc ?? "https://sdk-cdn.fun.xyz/images/logos/lighter.png",
470
496
  getMinWithdrawalUSD: () => 0,
471
497
  getMinWithdrawalAmount: config.getMinWithdrawalAmount
@@ -474,24 +500,30 @@ function createLighterSecureWithdrawalConfig(config) {
474
500
  function buildLighterSourceTokenOptions({
475
501
  isSecure,
476
502
  lighterAssets,
477
- isUnifiedTradingMode = false
503
+ isUnifiedTradingMode = false,
504
+ chainId = LIGHTER_CHAIN_ID2
478
505
  }) {
479
- const usdcOption = {
480
- symbol: "USDC",
481
- label: isUnifiedTradingMode ? "USDC" : "USDC (Perps)",
482
- iconSrc: getTokenIconUrl("USDC")
506
+ const instance = LIGHTER_INSTANCES2[chainId];
507
+ const collateral = instance.perpsCollateral.symbol;
508
+ const perpsOption = {
509
+ symbol: collateral,
510
+ label: isUnifiedTradingMode ? collateral : `${collateral} (Perps)`,
511
+ iconSrc: getTokenIconUrl(collateral)
483
512
  };
484
513
  if (!isSecure) {
485
- return [usdcOption];
514
+ return [perpsOption];
486
515
  }
516
+ const supportedSymbols = new Set(
517
+ Object.values(instance.secureAssets).map((asset) => asset.symbol)
518
+ );
487
519
  const spotOptions = lighterAssets.filter(
488
- (asset) => !(isUnifiedTradingMode && asset.symbol.toUpperCase() === "USDC")
520
+ (asset) => supportedSymbols.has(asset.symbol.toUpperCase()) && !(isUnifiedTradingMode && asset.symbol.toUpperCase() === collateral)
489
521
  ).map((asset) => {
490
- if (asset.symbol.toUpperCase() === "USDC") {
522
+ if (asset.symbol.toUpperCase() === collateral) {
491
523
  return {
492
- symbol: LIGHTER_USDC_SPOT_SYMBOL2,
493
- label: LIGHTER_USDC_SPOT_SYMBOL2,
494
- iconSrc: getTokenIconUrl("USDC")
524
+ symbol: `${collateral} (Spot)`,
525
+ label: `${collateral} (Spot)`,
526
+ iconSrc: getTokenIconUrl(collateral)
495
527
  };
496
528
  }
497
529
  return {
@@ -500,7 +532,7 @@ function buildLighterSourceTokenOptions({
500
532
  iconSrc: getTokenIconUrl(asset.symbol)
501
533
  };
502
534
  });
503
- return [usdcOption, ...spotOptions];
535
+ return [perpsOption, ...spotOptions];
504
536
  }
505
537
  function buildLighterFastWalletWithdrawalConfig({
506
538
  signerClient,
@@ -510,18 +542,20 @@ function buildLighterFastWalletWithdrawalConfig({
510
542
  iconSrc,
511
543
  onBeforeSign,
512
544
  isUnifiedTradingMode,
513
- withdrawalSourceTokenBalance
545
+ withdrawalSourceTokenBalance,
546
+ chainId
514
547
  }) {
515
548
  const adaptedWallet = createLighterAdaptedWallet({
516
549
  signerClient,
517
550
  accountIndex,
518
- logger
551
+ logger,
552
+ chainId
519
553
  });
520
554
  const wallet = {
521
555
  _type: "lighter",
522
556
  adaptedWallet,
523
557
  address: () => String(accountIndex),
524
- getChainId: async () => Number(RELAY_LIGHTER_CHAIN_ID2),
558
+ getChainId: async () => chainId,
525
559
  // biome-ignore lint/suspicious/noEmptyBlockStatements: no-op — Lighter has no EVM chain switching
526
560
  switchChain: async () => {
527
561
  },
@@ -537,12 +571,13 @@ function buildLighterFastWalletWithdrawalConfig({
537
571
  disableConnectedWallet,
538
572
  onBeforeSign,
539
573
  wallet,
540
- sourceChainId: RELAY_LIGHTER_CHAIN_ID2,
541
- sourceTokenSymbol: "USDC",
574
+ sourceChainId: String(chainId),
575
+ sourceTokenSymbol: LIGHTER_INSTANCES2[chainId].perpsCollateral.symbol,
542
576
  sourceTokens: buildLighterSourceTokenOptions({
543
577
  isSecure: false,
544
578
  lighterAssets: [],
545
- isUnifiedTradingMode
579
+ isUnifiedTradingMode,
580
+ chainId
546
581
  }),
547
582
  withdrawalSourceTokenBalance,
548
583
  defaultReceiveToken: "USDC",
@@ -552,6 +587,17 @@ function buildLighterFastWalletWithdrawalConfig({
552
587
  getMaxWithdrawalUSD: () => LIGHTER_FAST_MAX_WITHDRAWAL_USD2
553
588
  };
554
589
  }
590
+ var LIGHTER_SECURE_DISCLAIMER = {
591
+ // Until the live value loads, show the localized "60+ minutes" historical
592
+ // estimate. The "+" lives in the per-locale fallback string so it doesn't
593
+ // bleed into live values, which are exact.
594
+ [LIGHTER_CHAIN_ID2]: (t, delay) => t("withdrawal.secureDisclaimer", {
595
+ delay: delay ?? t("withdrawal.secureFallbackDelay")
596
+ }),
597
+ // Mainnet's estimate would overstate RH's much shorter bridge delay, so RH
598
+ // omits the delay until the live value loads.
599
+ [LIGHTER_RH_CHAIN_ID]: (t, delay) => delay ? t("withdrawal.secureDisclaimerRobinhood", { delay }) : t("withdrawal.secureDisclaimerRobinhoodNoDelay")
600
+ };
555
601
  var LIGHTER_FAST_PREVIEW_CHAIN_IDS = [
556
602
  arbitrum.id,
557
603
  base.id,
@@ -559,14 +605,14 @@ var LIGHTER_FAST_PREVIEW_CHAIN_IDS = [
559
605
  bsc.id,
560
606
  SOLANA_MAINNET_CHAIN_ID
561
607
  ].map(String);
562
- var LIGHTER_SECURE_PREVIEW_CHAIN_IDS = [mainnet2.id].map(String);
563
608
  function buildLighterMultiMethodConfig({
564
609
  config,
565
610
  accountIndex,
566
611
  t,
567
612
  secureDelayText,
568
613
  isUnifiedTradingMode,
569
- assets
614
+ assets,
615
+ chainId
570
616
  }) {
571
617
  const fastConfig = buildLighterFastWalletWithdrawalConfig({
572
618
  signerClient: config.signerClient,
@@ -576,14 +622,17 @@ function buildLighterMultiMethodConfig({
576
622
  iconSrc: config.fastIconSrc,
577
623
  onBeforeSign: config.onBeforeSign,
578
624
  isUnifiedTradingMode,
579
- withdrawalSourceTokenBalance: config.withdrawalSourceTokenBalance
625
+ withdrawalSourceTokenBalance: config.withdrawalSourceTokenBalance,
626
+ chainId
580
627
  });
581
628
  const secureConfig = createLighterSecureWithdrawalConfig({
582
629
  accountIndex,
630
+ chainId,
583
631
  sourceTokens: buildLighterSourceTokenOptions({
584
632
  isSecure: true,
585
633
  lighterAssets: assets,
586
- isUnifiedTradingMode
634
+ isUnifiedTradingMode,
635
+ chainId
587
636
  }),
588
637
  withdrawalSourceTokenBalance: config.withdrawalSourceTokenBalance,
589
638
  modalTitle: config.modalTitle,
@@ -596,13 +645,17 @@ function buildLighterMultiMethodConfig({
596
645
  if (userMin !== void 0) {
597
646
  return userMin;
598
647
  }
599
- return LIGHTER_DEFAULT_SECURE_MIN_WITHDRAWAL_AMOUNTS2[getLighterBaseSymbol3(symbol).toUpperCase()] ?? 0;
648
+ return getLighterDefaultSecureMinWithdrawalAmounts(chainId)[getLighterBaseSymbol3(symbol).toUpperCase()] ?? 0;
600
649
  }
601
650
  });
602
651
  const fast = {
603
652
  id: LIGHTER_FAST_METHOD_ID,
604
653
  keyText: t("withdrawal.methodFast"),
605
- subtitleText: isUnifiedTradingMode ? t("withdrawal.fastDisclaimerUnified") : t("withdrawal.fastDisclaimer"),
654
+ subtitleText: isUnifiedTradingMode ? t("withdrawal.fastDisclaimerUnified", {
655
+ symbol: LIGHTER_INSTANCES2[chainId].perpsCollateral.symbol
656
+ }) : t("withdrawal.fastDisclaimer", {
657
+ symbol: LIGHTER_INSTANCES2[chainId].perpsCollateral.symbol
658
+ }),
606
659
  icon: /* @__PURE__ */ React7.createElement(EvmWallet, { size: 20 }),
607
660
  valueIcon: /* @__PURE__ */ React7.createElement(SupportedChainList, { chainIdList: LIGHTER_FAST_PREVIEW_CHAIN_IDS }),
608
661
  config: fastConfig
@@ -610,32 +663,39 @@ function buildLighterMultiMethodConfig({
610
663
  const secure = {
611
664
  id: LIGHTER_SECURE_METHOD_ID,
612
665
  keyText: t("withdrawal.methodSecure"),
613
- subtitleText: t("withdrawal.secureDisclaimer", {
614
- // Until the live value loads, show the localized "60+ minutes"
615
- // historical estimate. The "+" lives in the per-locale fallback string
616
- // so it doesn't bleed into live values, which are exact.
617
- delay: secureDelayText ?? t("withdrawal.secureFallbackDelay")
618
- }),
666
+ subtitleText: LIGHTER_SECURE_DISCLAIMER[chainId](t, secureDelayText),
619
667
  icon: /* @__PURE__ */ React7.createElement(EvmWallet, { size: 20 }),
620
- valueIcon: /* @__PURE__ */ React7.createElement(SupportedChainList, { chainIdList: LIGHTER_SECURE_PREVIEW_CHAIN_IDS }),
668
+ valueIcon: /* @__PURE__ */ React7.createElement(
669
+ SupportedChainList,
670
+ {
671
+ chainIdList: [LIGHTER_INSTANCES2[chainId].secureL1Chain.id.toString()]
672
+ }
673
+ ),
621
674
  config: secureConfig
622
675
  };
623
676
  return {
624
677
  modalTitle: config.modalTitle ?? t("withdrawal.withdraw"),
625
678
  sectionTitle: t("withdrawal.sectionCrypto"),
626
- methods: [fast, secure]
679
+ methods: LIGHTER_INSTANCES2[chainId].supportsSecure ? [fast, secure] : [fast]
627
680
  };
628
681
  }
629
682
  function useLighterWithdrawalConfig(config) {
630
683
  const { t } = useFunkitTranslation();
631
- const { mainAccountIndex: accountIndex, isUnifiedTradingMode } = useLighterAccountsQuery({ address: config?.l1Address });
632
- const secureDelayText = useLighterSecureDelayText();
684
+ const chainId = config?.chainId ?? LIGHTER_CHAIN_ID2;
685
+ const { mainAccountIndex: accountIndex, isUnifiedTradingMode } = useLighterAccountsQuery({
686
+ address: config?.l1Address,
687
+ chainId
688
+ });
689
+ const secureDelayText = useLighterSecureDelayText(
690
+ LIGHTER_INSTANCES2[chainId].supportsSecure,
691
+ chainId
692
+ );
633
693
  const { account } = useLighterAccountQuery(
634
694
  // The query validates it as numeric, so the template-literal narrowing holds.
635
- accountIndex ? { by: "index", value: accountIndex } : null
695
+ accountIndex ? { by: "index", value: accountIndex, chainId } : null
636
696
  );
637
697
  const assets = useMemo3(() => account?.assets ?? [], [account]);
638
- return useMemo3(() => {
698
+ const multiMethodConfig = useMemo3(() => {
639
699
  if (!config || !accountIndex) {
640
700
  return null;
641
701
  }
@@ -645,9 +705,30 @@ function useLighterWithdrawalConfig(config) {
645
705
  t,
646
706
  secureDelayText,
647
707
  isUnifiedTradingMode,
648
- assets
708
+ assets,
709
+ chainId
649
710
  });
650
- }, [config, accountIndex, t, secureDelayText, isUnifiedTradingMode, assets]);
711
+ }, [
712
+ config,
713
+ accountIndex,
714
+ t,
715
+ secureDelayText,
716
+ isUnifiedTradingMode,
717
+ assets,
718
+ chainId
719
+ ]);
720
+ const methodIds = multiMethodConfig?.methods.map((method) => method.id);
721
+ useLogOnce2(
722
+ methodIds ? `${chainId}|${accountIndex}|${methodIds.join(",")}` : void 0,
723
+ () => {
724
+ logger.info("lighter:withdrawal:instance", {
725
+ chainId,
726
+ accountIndex,
727
+ methodIds
728
+ });
729
+ }
730
+ );
731
+ return multiMethodConfig;
651
732
  }
652
733
  export {
653
734
  LIGHTER_ROUTE_TYPE3 as LIGHTER_ROUTE_TYPE,
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  useFunkitTranslation
4
- } from "./chunk-OB5GKTP2.js";
4
+ } from "./chunk-LVR6RQMO.js";
5
5
  import {
6
6
  getAccount,
7
7
  sendTransaction,
@@ -14,7 +14,7 @@ import {
14
14
  useAccount,
15
15
  useConfig
16
16
  } from "./chunk-2W2P3OS6.js";
17
- import "./chunk-7JYLS7IF.js";
17
+ import "./chunk-2L6IKKNH.js";
18
18
  import {
19
19
  logger
20
20
  } from "./chunk-AHYOV7AV.js";
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  createNadoWithdrawalCallback
4
- } from "./chunk-UZ3NA7HN.js";
5
- import "./chunk-BKK2BFIP.js";
4
+ } from "./chunk-TWP5LFPX.js";
6
5
  import "./chunk-4DBUYTEE.js";
6
+ import "./chunk-V4RIF2NR.js";
7
7
  import "./chunk-OODIKHYE.js";
8
8
  import {
9
9
  useAccount,
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-2W2P3OS6.js";
12
12
  import {
13
13
  i18n_default
14
- } from "./chunk-7JYLS7IF.js";
14
+ } from "./chunk-2L6IKKNH.js";
15
15
  import "./chunk-TKEBGMVW.js";
16
16
  import {
17
17
  logger
@@ -1,3 +1,4 @@
1
+ import { type LighterChainId } from '@funkit/chains';
1
2
  import type { FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext';
2
3
  export declare function isPolymarketCustomer(apiKey: string): boolean;
3
4
  export declare function isOstiumCustomer(apiKey: string): apiKey is "SMbBD7DS9b3EPcyBVg4a8az1rRWR9xB068chHoUN";
@@ -8,7 +9,17 @@ export declare function isMonkeyTiltCustomer(apiKey: string): apiKey is "2SrxurU
8
9
  export declare function isBasedCustomer(apiKey: string): apiKey is "clDebbfo9edXq1GydZ0CahSAfSimPj616lFa9p8e";
9
10
  export declare function isAvantisCustomer(apiKey: string): apiKey is "6TUi99Tq3O9MWj1IFX8Pv6spmPXzcvhy9NvBoeW2";
10
11
  export declare function isPerplCustomer(apiKey: string): apiKey is "wQDLu86Qab61vbtru7thf8Yj0xaeqVUH4ohoXESu";
11
- export declare function isLighterxyzCustomer(apiKey: string): apiKey is "i6e1I8cfX625TTwRJlD2DshKyAoaUtO8aeoaR4i2";
12
+ /**
13
+ * Each Lighter instance is its own Fun customer. A key only ever reaches its
14
+ * own instance: accounts and indexes differ per instance.
15
+ */
16
+ export declare const LIGHTER_API_KEY_BY_CHAIN_ID: Record<LighterChainId, string>;
17
+ /** The Lighter instance a key belongs to; undefined for non-Lighter keys. */
18
+ export declare function resolveLighterCustomerChainId(apiKey: string): LighterChainId | undefined;
19
+ /** Either Lighter instance's key: shared Lighter UI applies to both. */
20
+ export declare function isLighterxyzCustomer(apiKey: string): boolean;
21
+ /** The key of Lighter's Robinhood instance (customer q1aj098ygl). */
22
+ export declare function isLighterRhCustomer(apiKey: string): boolean;
12
23
  export declare function isFanaticsCustomer(apiKey: string): apiKey is "lI7amueGK94QtGa7sGGVf8n0XhIcn4sHFAZRu5Jj";
13
24
  export declare function isAaveCustomer(apiKey: string): apiKey is "EWzSv8tWnQ7UcZ2IsDqFw1dYo3Df56FX6KBJ5ztS";
14
25
  export declare function isNadoCustomer(apiKey: string): apiKey is "iFwbI36PWs6egzqjemCVz8PRmDwaANr51WtaARhV";
@@ -0,0 +1,22 @@
1
+ import type { GetSupportedAssetsResponse, SupportedAssetInfo } from '@funkit/api-base';
2
+ import type { Config } from '../../wagmi/hooks';
3
+ import type { ConvertAsset, ConvertResolvedAsset } from './types';
4
+ /**
5
+ * Looks a host-listed token up in the supported-assets list. Hosts key every
6
+ * native asset by the `NATIVE_TOKEN` placeholder, but the list keys Hypercore's
7
+ * under Relay's id, so a placeholder miss retries with the Relay key.
8
+ */
9
+ export declare function findSupportedAsset(supportedAssets: GetSupportedAssetsResponse, chainId: string, address: string): SupportedAssetInfo | undefined;
10
+ /** Host icon, then the asset list's, then the symbol default. */
11
+ export declare function resolveConvertAssetIcon(asset: ConvertAsset, supportedAssetLogo: string | undefined): string;
12
+ /**
13
+ * Resolves decimals and an icon for every host-listed asset. The supported
14
+ * list answers synchronously; a token it lacks falls back to the SDK's usual
15
+ * decimals lookup (on-chain, then Relay), in parallel across misses. A token
16
+ * neither can resolve is left out, never given guessed decimals.
17
+ */
18
+ export declare function resolveConvertAssets({ assets, supportedAssets, wagmiConfig, }: {
19
+ assets: ConvertAsset[];
20
+ supportedAssets: GetSupportedAssetsResponse;
21
+ wagmiConfig: Config;
22
+ }): Promise<ConvertResolvedAsset[]>;
@@ -1,38 +1,35 @@
1
- import type { ConvertResolvedAsset, ConvertSourceBalances, GetConvertSourceBalances } from './types';
1
+ import type { ConvertAssetBalance, ConvertResolvedAsset, GetConvertBalances } from './types';
2
2
  /**
3
- * One key per token for every lookup (supported-assets, host balances).
3
+ * One spelling per token address.
4
4
  * - EVM: checksummed; the asset list is checksummed and hosts send lowercase.
5
5
  * - Solana: as-is; base58 is case-sensitive.
6
6
  * - Anything else (Hypercore's `0x` + 32-zero placeholder): lowercase.
7
7
  */
8
- export declare function normalizeConvertAssetKey(chainId: string, tokenAddress: string): string;
9
- export type ConvertAssetBalance = {
8
+ export declare function normalizeTokenAddress(chainId: string, tokenAddress: string): string;
9
+ /** The key one asset's balance is stored under. */
10
+ export declare function convertBalanceKey(chainId: string, address: string): string;
11
+ export type ConvertBalanceState = {
10
12
  status: 'available';
11
13
  baseUnits: string;
12
14
  } | {
13
15
  status: 'unavailable';
14
16
  };
15
- export type ConvertBalancesResult = {
16
- status: 'success';
17
- walletAddress: string;
18
- balances: Record<string, ConvertAssetBalance>;
19
- } | {
20
- status: 'error';
21
- reason: 'invalidWalletAddress' | 'fetchFailed';
22
- error?: unknown;
23
- };
17
+ /** One entry per listed asset, keyed by {@link convertBalanceKey}. */
18
+ export type ConvertBalances = Record<string, ConvertBalanceState>;
24
19
  /**
25
- * Turns a host balance result into one entry per requested asset. An asset the
26
- * host left out, or returned malformed, is unavailable; it never becomes 0.
20
+ * Turns the host's asset balances into one state per listed asset. An asset
21
+ * the host left out, or returned malformed, is unavailable; it never becomes
22
+ * 0. Balances for assets that weren't requested are ignored.
27
23
  */
28
- export declare function parseConvertSourceBalances({ chainId, assets, result, }: {
29
- chainId: string;
24
+ export declare function parseConvertBalances({ assets, assetBalances, }: {
30
25
  assets: ConvertResolvedAsset[];
31
- result: ConvertSourceBalances;
32
- }): ConvertBalancesResult;
33
- /** Calls the host getter and parses its result; a throw is an error state. */
34
- export declare function fetchConvertSourceBalances({ chainId, assets, getSourceBalances, }: {
35
- chainId: string;
26
+ assetBalances: ConvertAssetBalance[];
27
+ }): ConvertBalances;
28
+ /**
29
+ * Calls the host getter and parses its result. A throw is logged and
30
+ * rethrown so the query keeps the last good read instead of replacing it.
31
+ */
32
+ export declare function fetchConvertBalances({ assets, getBalances, }: {
36
33
  assets: ConvertResolvedAsset[];
37
- getSourceBalances: GetConvertSourceBalances;
38
- }): Promise<ConvertBalancesResult>;
34
+ getBalances: GetConvertBalances;
35
+ }): Promise<ConvertBalances>;
@@ -0,0 +1,38 @@
1
+ import type { ConvertSubmitPreparation } from './submit';
2
+ import type { ConvertConfig, ConvertErrorResult } from './types';
3
+ /** Why the source leg failed, for copy and for whether to retry. */
4
+ export type ConvertSourceErrorReason = 'userRejected' | 'switchChain' | 'insufficientGas'
5
+ /** The transaction outlived its blockhash; it never landed, so re-sign. */
6
+ | 'blockhashExpired'
7
+ /** The wallet or RPC simulated the transaction and it would fail. */
8
+ | 'simulationFailed' | 'insufficientSol' | 'generic';
9
+ /**
10
+ * The shared wallet mapping, plus the Solana failures it doesn't know. Meant
11
+ * for failures before funds moved, after which the user can convert again.
12
+ */
13
+ export declare function getConvertSourceErrorReason(error: unknown): ConvertSourceErrorReason;
14
+ /** Every way a conversion can stop, from the pre-sign check to settlement. */
15
+ export type ConvertFailure = {
16
+ stage: 'preSign';
17
+ preparation: Extract<ConvertSubmitPreparation, {
18
+ status: 'blocked';
19
+ }>;
20
+ } | {
21
+ stage: 'source';
22
+ error: unknown;
23
+ }
24
+ /** Funds may have moved but the deposit could not be tracked. */
25
+ | {
26
+ stage: 'unknown';
27
+ error: unknown;
28
+ } | {
29
+ stage: 'settlement';
30
+ error: unknown;
31
+ };
32
+ /**
33
+ * The host's `onError` payload for a failure, or `undefined` for a block the
34
+ * user fixes on screen (balance, fee reserve, missing quote), which the host
35
+ * never needs to hear about.
36
+ */
37
+ export declare function toConvertErrorResult(failure: ConvertFailure): ConvertErrorResult | undefined;
38
+ export declare function reportConvertError(failure: ConvertFailure, onError: ConvertConfig['onError']): void;