@funkit/connect 10.4.0 → 10.6.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 (51) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/clients/{chunk-RCMAGKMG.js → chunk-3LJQTM37.js} +1 -2
  3. package/dist/clients/{chunk-APQYFP6X.js → chunk-A4WQS6QG.js} +1 -1
  4. package/dist/clients/{chunk-HOORQPSY.js → chunk-F6P4CN27.js} +24 -8
  5. package/dist/clients/{chunk-KNHO756P.js → chunk-FJ6GCMJ4.js} +1 -0
  6. package/dist/clients/{chunk-M6C7MBQN.js → chunk-TG2AACP2.js} +2 -2
  7. package/dist/clients/fanatics.js +1 -1
  8. package/dist/clients/internal/nado/hooks.js +2 -2
  9. package/dist/clients/internal/nado/products.js +2 -2
  10. package/dist/clients/internal/nado/withdrawalConfig.d.ts +11 -0
  11. package/dist/clients/internal/nado/withdrawalConfig.js +18 -0
  12. package/dist/clients/internal/nado/withdrawalTypes.d.ts +30 -0
  13. package/dist/clients/internal/nado/withdrawalTypes.js +1 -0
  14. package/dist/clients/lighter.css +5 -1
  15. package/dist/clients/lighter.d.ts +1 -0
  16. package/dist/clients/lighter.js +88 -21
  17. package/dist/clients/mallard.js +2 -2
  18. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +5 -1
  19. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +3 -3
  20. package/dist/clients/polymarket/index.css +5 -1
  21. package/dist/clients/polymarket/index.js +3 -3
  22. package/dist/components/BottomLinks/BottomLinks.d.ts +3 -1
  23. package/dist/consts/meld.d.ts +1 -1
  24. package/dist/hooks/queries/useSwappedDefaultCurrency.d.ts +3 -3
  25. package/dist/hooks/queries/useWithdrawFops.d.ts +0 -1
  26. package/dist/hooks/track/useTrack.d.ts +1 -0
  27. package/dist/hooks/useCheckoutDirectExecutionHistory.d.ts +2 -1
  28. package/dist/index.css +5 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +2705 -2080
  31. package/dist/modals/CheckoutModal/ConfirmationStep/CheckoutPrimaryInfo.d.ts +1 -2
  32. package/dist/modals/CheckoutModal/InputAmount/useCheckoutAmountLimits.d.ts +6 -9
  33. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +80 -19
  34. package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +1 -61
  35. package/dist/modals/WithdrawalModal/useFiatWithdrawal.d.ts +1 -1
  36. package/dist/modals/WithdrawalModal/useWithdrawal.d.ts +3 -15
  37. package/dist/modals/WithdrawalModal/withdrawalFormHelpers.d.ts +53 -0
  38. package/dist/modals/WithdrawalModal/withdrawalHooks.d.ts +38 -0
  39. package/dist/providers/FunkitCheckoutContext/types.d.ts +42 -4
  40. package/dist/providers/FunkitConfigContext.d.ts +9 -2
  41. package/dist/providers/GeneralWalletProvider.d.ts +1 -4
  42. package/dist/utils/consts.d.ts +1 -1
  43. package/dist/utils/customer.d.ts +18 -3
  44. package/dist/utils/lighter.d.ts +68 -1
  45. package/dist/utils/purifyCheckoutHistoryItem.d.ts +2 -41
  46. package/dist/utils/swapped.d.ts +1 -1
  47. package/dist/utils/userInfo.d.ts +8 -0
  48. package/dist/utils/withdrawal.d.ts +8 -1
  49. package/dist/wagmi/actions.d.ts +1 -1
  50. package/dist/wallets/walletConnectors/index.js +28 -28
  51. package/package.json +2 -2
@@ -3,7 +3,6 @@ import type { QuoteDisplayAmounts } from '../../../domains/quoteMode';
3
3
  import type { FunkitCheckoutConfig } from '../../../providers/FunkitCheckoutContext';
4
4
  interface CheckoutPrimaryInfoProps {
5
5
  showLeftAlignedDollarValueWithLabel: boolean;
6
- showTokenAmount: boolean;
7
6
  config: FunkitCheckoutConfig;
8
7
  usdAmount?: number;
9
8
  isLoading?: boolean;
@@ -12,5 +11,5 @@ interface CheckoutPrimaryInfoProps {
12
11
  /** In EXACT_IN mode, the fiat value the user entered on InputAmount (avoids skeleton flash) */
13
12
  inputFiatAmount?: number | null;
14
13
  }
15
- export declare function CheckoutPrimaryInfo({ showLeftAlignedDollarValueWithLabel, showTokenAmount, usdAmount, config, isLoading, displayAmounts, inputFiatAmount, }: CheckoutPrimaryInfoProps): React.JSX.Element;
14
+ export declare function CheckoutPrimaryInfo({ showLeftAlignedDollarValueWithLabel, usdAmount, config, isLoading, displayAmounts, inputFiatAmount, }: CheckoutPrimaryInfoProps): React.JSX.Element;
16
15
  export {};
@@ -1,15 +1,12 @@
1
- import { PaymentMethod } from '../../../domains/paymentMethods';
1
+ import { type CheckoutAmountLimitsUsd } from '@funkit/connect-core';
2
+ import type { PaymentMethod } from '../../../domains/paymentMethods';
2
3
  import type { FunkitCheckoutConfig } from '../../../providers/FunkitCheckoutContext';
3
- export interface CheckoutAmountLimitsUsd {
4
- minUsd: number | undefined;
5
- maxUsd: number;
6
- }
4
+ export type { CheckoutAmountLimitsUsd };
7
5
  /**
8
6
  * Resolves the min/max USD bounds for the amount input based on the active
9
- * payment method:
10
- * - Bitcoin Lightning and brokerage checkouts carry their own floors/ceilings.
11
- * - Everything else uses the customer-configured min deposit and the global
12
- * max-checkout dynamic config.
7
+ * payment method. Fetches the inputs (min-transfer floor, brokerage limits,
8
+ * global max) and delegates the per-method rules to
9
+ * `getCheckoutAmountLimitsUsd` in `@funkit/connect-core`.
13
10
  */
14
11
  export declare const useCheckoutAmountLimits: ({ checkoutConfig, paymentMethod, }: {
15
12
  checkoutConfig: FunkitCheckoutConfig;
@@ -3,11 +3,12 @@
3
3
  *
4
4
  * Extracted from WithdrawalContent.tsx to keep Lighter-specific logic isolated.
5
5
  */
6
- import type { LighterAccountIndex } from '@funkit/api-base';
6
+ import { type LighterAccountIndex } from '@funkit/api-base';
7
7
  import React from 'react';
8
- import type { Address } from 'viem';
8
+ import { type Address, type Hex } from 'viem';
9
+ import { type CheckoutConfirmationError } from '../../domains/checkoutErrors';
9
10
  import type { CustomWithdrawalConfig, LighterRouteType, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
10
- import type { LighterShare } from '../../utils/customer';
11
+ import type { LighterAsset, LighterPoolInfo, LighterShare } from '../../utils/customer';
11
12
  import type { SourceTokenOption } from './WithdrawAmountInput';
12
13
  /** Stable method ids for the Fast / Secure options (used for tracking + switching). */
13
14
  export declare const LIGHTER_FAST_METHOD_ID = "lighter-fast";
@@ -65,28 +66,45 @@ export declare function freeBalance(balance: string, lockedBalance: string): str
65
66
  * withdrawal amount before quoting — for users who aren't sufficiently staked
66
67
  * in Lighter's staking pool. Sufficiently-staked users pay nothing.
67
68
  *
68
- * "Sufficiently staked" = the user holds a share in the staking pool with a
69
- * principal above the threshold. The staking pool is identified by its index,
70
- * hardcoded here (previously read from `systemConfig.staking_pool_index`) since
71
- * it's currently the only public pool a withdrawing user holds a share in.
72
- * Non-stakers report `shares: []`.
69
+ * "Sufficiently staked" = the *current* LIT value of the user's staking-pool
70
+ * share is at or above the threshold. The pool is LIT-denominated and
71
+ * identified by its index, hardcoded here (previously read from
72
+ * `systemConfig.staking_pool_index`) since it's currently the only public pool
73
+ * a withdrawing user holds a share in. Non-stakers report `shares: []`.
73
74
  */
74
75
  export declare const LIGHTER_STAKING_POOL_INDEX = 281474976624800;
75
76
  export declare const LIGHTER_UNSTAKED_FEE_TOKENS = 3;
76
- export declare const LIGHTER_STAKING_PRINCIPAL_THRESHOLD = 100;
77
+ export declare const LIGHTER_STAKING_THRESHOLD_LIT = 100;
78
+ /**
79
+ * LIT per share unit for the staking pool: its LIT balance over total shares.
80
+ *
81
+ * `undefined` when the pool account is unavailable or reports no shares — the
82
+ * fee gate then degrades to the entry principal rather than guessing.
83
+ */
84
+ export declare function resolveLighterSharePrice(poolAccount: {
85
+ assets?: LighterAsset[];
86
+ pool_info?: LighterPoolInfo;
87
+ } | undefined): number | undefined;
77
88
  /**
78
89
  * Resolves the Lighter Fast unstaked fee (in source tokens, i.e. USDC) for a
79
- * user. Returns 0 when the user's staking-pool principal exceeds the threshold,
80
- * otherwise {@link LIGHTER_UNSTAKED_FEE_TOKENS}. A non-staker (`shares: []`,
81
- * or no staking-pool share) pays the fee.
90
+ * user. A non-staker (`shares: []`, or no staking-pool share) pays the fee.
91
+ *
92
+ * Gated on the share's *current* LIT value (`shares_amount × sharePrice` — the
93
+ * "Your Stake" figure in Lighter's UI), not `principal_amount`, which is the
94
+ * entry deposit and never grows with accrued yield. Gating on the principal
95
+ * charged stakers whose position had appreciated past the minimum from below.
96
+ *
97
+ * Falls back to the principal when `sharePrice` is unavailable — never worse
98
+ * than the previous behaviour, and avoids waiving the fee for everyone when
99
+ * the pool account fails to load.
82
100
  */
83
- export declare function resolveLighterUnstakedFeeTokens(shares: LighterShare[]): number;
101
+ export declare function resolveLighterUnstakedFeeTokens(shares: LighterShare[], sharePrice?: number): number;
84
102
  /**
85
- * Deducts the Lighter Fast unstaked fee from a withdrawal input amount, clamped
86
- * at 0. Uses `dnum` fixed-point math so the subtraction stays exact (e.g. the
87
- * input is a decimal string straight from the amount field).
103
+ * Share price for the staking pool, read off the pool's own account. Kept a
104
+ * separate query from the user's account: a user's `shares[]` carries entry
105
+ * state only, so current value is unobtainable without the pool's NAV.
88
106
  */
89
- export declare function deductLighterUnstakedFee(inputAmount: string, feeTokens: number): string;
107
+ export declare function useLighterStakingSharePrice(enabled: boolean): number | undefined;
90
108
  /**
91
109
  * Fetches all asset balances for a Lighter account. Returns:
92
110
  *
@@ -97,7 +115,7 @@ export declare function useLighterWithdrawalBalances({ accountIndex, }: {
97
115
  accountIndex: LighterAccountIndex | undefined;
98
116
  }): {
99
117
  balances: Record<string, string>;
100
- assets: import("../../utils/customer").LighterAsset[];
118
+ assets: LighterAsset[];
101
119
  shares: LighterShare[];
102
120
  isLoading: boolean;
103
121
  };
@@ -138,10 +156,46 @@ export declare function useLighterWithdrawal(config: FunkitWithdrawalConfig, set
138
156
  isUnifiedTradingMode: boolean;
139
157
  connectedAddress: `0x${string}` | undefined;
140
158
  lighterBalances: Record<string, string>;
141
- lighterAssets: import("../../utils/customer").LighterAsset[];
159
+ lighterAssets: LighterAsset[];
142
160
  lighterFastUnstakedFee: number;
143
161
  invalidateLighterAccount: () => void;
144
162
  };
163
+ /**
164
+ * Lighter Secure L1 on-chain withdrawal fallback.
165
+ *
166
+ * When the gasless L2 withdraw is rate-limited (error 23004), the user can
167
+ * withdraw directly on-chain via `zkLighter.withdraw`. This is a distinct,
168
+ * gas-paying, wallet-signed path — offered explicitly, never automatic.
169
+ *
170
+ * Availability latches on the first rate-limit error (the transient
171
+ * `withdrawalError` auto-clears after ~10s) and resets when the user edits the
172
+ * amount or source token, so a fresh attempt can retry the L2 path.
173
+ */
174
+ export declare function useLighterL1Fallback({ isLighterSecure, withdrawalError, connectedAddress, resetKey, }: {
175
+ isLighterSecure: boolean;
176
+ withdrawalError: CheckoutConfirmationError | null;
177
+ connectedAddress: Address | undefined;
178
+ /** Changes when the user edits amount/token — resets the latched offer. */
179
+ resetKey: string;
180
+ }): {
181
+ isL1FallbackAvailable: boolean;
182
+ submitL1Withdrawal: ({ assetIndex, routeType, amountTokenUnits, recipientAddr, tokenSymbol, mainnetTokenAddress, withdrawalUSD, onConfirmed, }: {
183
+ assetIndex: number;
184
+ routeType: LighterRouteType;
185
+ amountTokenUnits: string;
186
+ /** Connected wallet — L1 owner of the Lighter account (tracking userId). */
187
+ recipientAddr: Address;
188
+ /** Source-token symbol (may carry a ` (Spot)` suffix) — for tracking. */
189
+ tokenSymbol: string;
190
+ /** Mainnet ERC-20 the withdrawal lands as. */
191
+ mainnetTokenAddress: Address;
192
+ /** USD value (token amount × spot) — for tracking attribution. */
193
+ withdrawalUSD: string;
194
+ onConfirmed: (txHash: Hex) => void;
195
+ }) => Promise<void>;
196
+ isSubmittingL1: boolean;
197
+ l1FallbackError: CheckoutConfirmationError | null;
198
+ };
145
199
  /**
146
200
  * Resolves the source-token dropdown options for a Lighter customer.
147
201
  * Returns `undefined` for non-Lighter customers (no dropdown needed).
@@ -172,6 +226,13 @@ export declare function LighterSecureReceiveAmountValue({ amount, tokenSymbol: r
172
226
  amount: string;
173
227
  tokenSymbol: string;
174
228
  }): React.JSX.Element;
229
+ /**
230
+ * Lighter Secure: immediate success screen (no loading spinner).
231
+ *
232
+ * Unlike the standard `PendingSuccessScreen` that polls for relay status,
233
+ * Lighter Secure calls Lighter's API directly and runs outside of the
234
+ * FunKit relay system. This component shows an immediate success state.
235
+ */
175
236
  export declare function LighterSecureWithdrawalSuccess({ onClose, onNewWithdrawal, amount, tokenSymbol: rawTokenSymbol, txHash, }: {
176
237
  onClose: () => void;
177
238
  onNewWithdrawal: () => void;
@@ -1,8 +1,7 @@
1
- import type { TFunction } from 'i18next';
2
1
  import React from 'react';
3
2
  import type { Hex } from 'viem';
4
3
  import { type ModalBottomBarIdType } from '../../components/Dialog/Dialog';
5
- import type { CustomWithdrawalConfig, FunkitActiveWithdrawalItem, FunkitCheckoutConfig, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
4
+ import type { CustomWithdrawalConfig, FunkitActiveWithdrawalItem, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
6
5
  import { type WithdrawalFormData } from './useWithdrawal';
7
6
  /**
8
7
  * WithdrawalContent only operates on concrete single-method withdrawal configs.
@@ -32,64 +31,5 @@ interface WithdrawContentProps {
32
31
  */
33
32
  disableSubmit?: boolean;
34
33
  }
35
- /**
36
- * Converts a source-token amount string to its USD value using the given unit
37
- * price. Returns `undefined` when the price is not yet loaded so callers can
38
- * differentiate "still loading" from "actually $0".
39
- *
40
- * Exported for testing.
41
- */
42
- export declare function toUsdValue(sourceAmount: string, sourceTokenUsdPrice: number | undefined): number | undefined;
43
- export declare function getWithdrawButtonText({ isWithdrawing, isValidAddress, isRecipientBlacklisted, isRecipientSameAsSource, withdrawalInputAmount, isWithdrawAmountValid, isWithdrawAmountTooHigh, isValidAddressAndChain, selectedToken, selectedChainId, selectedChainName, t, }: {
44
- isWithdrawing: boolean;
45
- isValidAddress: boolean;
46
- isRecipientBlacklisted: boolean;
47
- isRecipientSameAsSource: boolean;
48
- withdrawalInputAmount: string;
49
- isWithdrawAmountValid: boolean;
50
- isWithdrawAmountTooHigh: boolean;
51
- isValidAddressAndChain: boolean;
52
- selectedToken: string | undefined;
53
- selectedChainId: number | undefined;
54
- selectedChainName: string | undefined;
55
- t: TFunction;
56
- }): string;
57
- export declare function isValidWithdrawal({ config, checkoutConfig, withdrawalInputAmount, sourceTokenUsdPrice, recipientAddress, selectedChainId, sourceTokenBalance, selectedSourceToken, }: {
58
- config: FunkitWithdrawalConfig;
59
- checkoutConfig: FunkitCheckoutConfig | undefined;
60
- /** User-entered amount in source-token units (e.g. "0.5" for 0.5 ETH). */
61
- withdrawalInputAmount: string;
62
- /**
63
- * USD price per unit of the source token. Hardcoded to 1 for stablecoin
64
- * sources; only Lighter Secure resolves a live spot price, and that path
65
- * uses `getMinWithdrawalAmount` (per-token) which takes priority over the
66
- * USD-min branch — so this field is only meaningfully consumed when it's 1.
67
- */
68
- sourceTokenUsdPrice: number;
69
- sourceTokenBalance: string;
70
- recipientAddress: string;
71
- selectedChainId: number | undefined;
72
- selectedSourceToken: string | undefined;
73
- }): {
74
- isValidAddress: boolean;
75
- isValidAddressAndChain: boolean;
76
- isWithdrawAmountTooLow: boolean;
77
- isWithdrawAmountTooHigh: boolean;
78
- isWithdrawAmountAboveBalance: boolean;
79
- isWithdrawAmountValid: boolean;
80
- minWithdrawalDisplayValue: number;
81
- };
82
- export declare const useFrozenSourceTokenBalance: ({ isWithdrawing, sourceTokenBalance, }: {
83
- isWithdrawing: boolean;
84
- sourceTokenBalance: string;
85
- }) => {
86
- displayedSourceTokenBalance: string;
87
- freezeDisplayedSourceTokenBalance(sourceTokenBalance: string): void;
88
- };
89
- /**
90
- * Builds the source-token options list for the Lighter compound input dropdown.
91
- * Currently returns a single option per config; expands when Lighter exposes
92
- * multi-asset API support.
93
- */
94
34
  export declare const WithdrawContent: ({ onContinue, config, withdrawalItem, onSwitchToSecure, bottomBarId, disableSubmit, }: WithdrawContentProps) => React.JSX.Element;
95
35
  export {};
@@ -1,4 +1,4 @@
1
- import { type Address } from 'viem';
1
+ import type { Address } from 'viem';
2
2
  import { type CustomWithdrawalConfig, type FunkitActiveWithdrawalItem, type WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
3
3
  /**
4
4
  * Provider-agnostic fiat off-ramp order: deliver `amount` of the accepted
@@ -1,27 +1,15 @@
1
- import type { Address, Hex } from 'viem';
1
+ import type { Hex } from 'viem';
2
2
  import { type CheckoutConfirmationError } from '../../domains/checkoutErrors';
3
- import type { FunkitCheckoutQuoteResult } from '../../domains/quote';
4
- import { type FunkitActiveWithdrawalItem, type FunkitWithdrawalConfig, type WithdrawalCustomerData } from '../../providers/FunkitCheckoutContext';
3
+ import { type FunkitActiveWithdrawalItem, type FunkitWithdrawalConfig, type WithdrawalFormData } from '../../providers/FunkitCheckoutContext';
5
4
  interface UseWithdrawalResult {
6
5
  handleWithdrawal: (withdrawal: WithdrawalFormData) => Promise<Hex | null>;
7
6
  isWithdrawing: boolean;
8
7
  withdrawalError: CheckoutConfirmationError | null;
9
8
  stepMessage: string | null;
10
9
  }
11
- export type WithdrawalFormData = {
12
- destinationAddress: Address;
13
- withdrawalUSD: string;
14
- tokenSymbol: string;
15
- tokenAddress: Address;
16
- chainId: number;
17
- quote?: FunkitCheckoutQuoteResult;
18
- /** Customer-specific data for quoteless flows (e.g. Lighter Secure). */
19
- customerData?: WithdrawalCustomerData;
20
- userInputAmount: string;
21
- };
10
+ export type { WithdrawalFormData };
22
11
  export declare function useWithdrawal({ config, withdrawalItem, onSuccess, }: {
23
12
  config: FunkitWithdrawalConfig;
24
13
  withdrawalItem: FunkitActiveWithdrawalItem | null;
25
14
  onSuccess?: (withdrawal: WithdrawalFormData, txHash: Hex) => void;
26
15
  }): UseWithdrawalResult;
27
- export {};
@@ -0,0 +1,53 @@
1
+ import type { TFunction } from 'i18next';
2
+ import type { FunkitCheckoutQuoteResult } from '../../domains/quote';
3
+ import type { CustomWithdrawalConfig, FunkitCheckoutConfig, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
4
+ type FunkitWithdrawalConfig = WalletWithdrawalConfig | CustomWithdrawalConfig;
5
+ export declare function getWithdrawButtonText({ isWithdrawing, isValidAddress, isRecipientBlacklisted, isRecipientSameAsSource, withdrawalInputAmount, isWithdrawAmountValid, isWithdrawAmountTooHigh, isValidAddressAndChain, selectedToken, selectedChainId, selectedChainName, t, }: {
6
+ isWithdrawing: boolean;
7
+ isValidAddress: boolean;
8
+ isRecipientBlacklisted: boolean;
9
+ isRecipientSameAsSource: boolean;
10
+ withdrawalInputAmount: string;
11
+ isWithdrawAmountValid: boolean;
12
+ isWithdrawAmountTooHigh: boolean;
13
+ isValidAddressAndChain: boolean;
14
+ selectedToken: string | undefined;
15
+ selectedChainId: number | undefined;
16
+ selectedChainName: string | undefined;
17
+ t: TFunction;
18
+ }): string;
19
+ export declare function isValidWithdrawal({ config, checkoutConfig, withdrawalInputAmount, sourceTokenUsdPrice, recipientAddress, selectedChainId, sourceTokenBalance, selectedSourceToken, }: {
20
+ config: FunkitWithdrawalConfig;
21
+ checkoutConfig: FunkitCheckoutConfig | undefined;
22
+ /** User-entered amount in source-token units (e.g. "0.5" for 0.5 ETH). */
23
+ withdrawalInputAmount: string;
24
+ /**
25
+ * USD price per unit of the source token. Hardcoded to 1 for stablecoin
26
+ * sources; only Lighter Secure resolves a live spot price, and that path
27
+ * uses `getMinWithdrawalAmount` (per-token) which takes priority over the
28
+ * USD-min branch — so this field is only meaningfully consumed when it's 1.
29
+ */
30
+ sourceTokenUsdPrice: number;
31
+ sourceTokenBalance: string;
32
+ recipientAddress: string;
33
+ selectedChainId: number | undefined;
34
+ selectedSourceToken: string | undefined;
35
+ }): {
36
+ isWithdrawAmountTooLow: boolean;
37
+ isWithdrawAmountTooHigh: boolean;
38
+ isWithdrawAmountAboveBalance: boolean;
39
+ isWithdrawAmountValid: boolean;
40
+ minWithdrawalDisplayValue: number;
41
+ isValidAddress: boolean;
42
+ isValidAddressAndChain: boolean;
43
+ };
44
+ /**
45
+ * Converts a source-token amount string to its USD value using the given unit
46
+ * price. Returns `undefined` when the price is not yet loaded so callers can
47
+ * differentiate "still loading" from "actually $0".
48
+ *
49
+ * Exported for testing.
50
+ */
51
+ export declare function toUsdValue(sourceAmount: string, sourceTokenUsdPrice: number | undefined): number | undefined;
52
+ export declare function getRelayOutputCurrencyAmount(quote: FunkitCheckoutQuoteResult, fallback: number | undefined): number;
53
+ export {};
@@ -0,0 +1,38 @@
1
+ import type { CustomWithdrawalConfig, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
2
+ type FunkitWithdrawalConfig = WalletWithdrawalConfig | CustomWithdrawalConfig;
3
+ export declare function useWithdrawalAssets(config: FunkitWithdrawalConfig): {
4
+ assets: import("../CheckoutModal/TransferToken/TransferToken").TokenTransferSourceChainsAndAssets;
5
+ selectedChainId: number | undefined;
6
+ handleChainChange: (chainId?: number, autoUpdate?: boolean) => void;
7
+ selectedToken: string | undefined;
8
+ selectedChainName: string | undefined;
9
+ handleTokenChange: (token: string, chainId?: number, autoUpdate?: boolean) => void;
10
+ chainIdSortOrder: number[];
11
+ popularTokenSymbols: string[];
12
+ priorityTokenSymbols: string[];
13
+ isLoadingAssets: boolean;
14
+ addressBySymbolByChainId: Record<number, Record<string, string>>;
15
+ };
16
+ export declare const useFrozenSourceTokenBalance: ({ isWithdrawing, sourceTokenBalance, }: {
17
+ isWithdrawing: boolean;
18
+ sourceTokenBalance: string;
19
+ }) => {
20
+ displayedSourceTokenBalance: string;
21
+ freezeDisplayedSourceTokenBalance(sourceTokenBalance: string): void;
22
+ };
23
+ /**
24
+ * The withdrawal form's warning logs. Effect bodies and dependency arrays are
25
+ * unchanged from WithdrawalContent; the refs that dedupe them move along too.
26
+ */
27
+ export declare function useWithdrawalLogging({ targetAssetFetchError, quoteErrorObject, isRisky, isRecipientBlacklisted, selectedChainId, selectedToken, recipientAddress, debouncedInputAmount, debouncedInputAmountUsd, }: {
28
+ targetAssetFetchError: unknown;
29
+ quoteErrorObject: unknown;
30
+ isRisky: boolean | undefined;
31
+ isRecipientBlacklisted: boolean;
32
+ selectedChainId: number | undefined;
33
+ selectedToken: string | undefined;
34
+ recipientAddress: string;
35
+ debouncedInputAmount: string;
36
+ debouncedInputAmountUsd: number | undefined;
37
+ }): void;
38
+ export {};
@@ -2,6 +2,7 @@ import type { FunAddress } from '@funkit/api-base';
2
2
  import type { ApiCheckoutClientMetadata, ApiFunkitCheckoutActionParams, ApiFunkitCheckoutConfig } from '@funkit/utils';
3
3
  import type { ReactNode } from 'react';
4
4
  import type { Address } from 'viem';
5
+ import type { NadoWithdrawalCustomerConfig, NadoWithdrawalCustomerData } from '../../clients/internal/nado/withdrawalTypes';
5
6
  import type { PaymentMethodInfo } from '../../domains/paymentMethods';
6
7
  import type { CheckoutBlockedReason } from '../../modals/CheckoutModal/CheckoutBlockedReason';
7
8
  import type { WithdrawalClient, WithdrawalTransaction } from '../../wallets/Wallet';
@@ -280,6 +281,12 @@ export interface CustomWithdrawalConfig extends WithdrawalConfigBase {
280
281
  * success screen can display and link to the transaction.
281
282
  */
282
283
  withdrawCallback: (param: WithdrawalParam) => Promise<undefined | string>;
284
+ /**
285
+ * Config-level customer-specific data, discriminated by `customerName`.
286
+ * Populated by a client hook (e.g. `use{Customer}WithdrawalConfig`), not hand-set —
287
+ * the `customerConfig` counterpart to the per-submission {@link WithdrawalCustomerData}.
288
+ */
289
+ customerConfig?: WithdrawalCustomerConfig;
283
290
  }
284
291
  /** Lighter L2 route type: 0 = perps (USDC collateral), 1 = spot. */
285
292
  export type LighterRouteType = 0 | 1;
@@ -298,7 +305,13 @@ export interface LighterWithdrawalCustomerData {
298
305
  * by `customerName` so future customers extend the union instead of adding
299
306
  * top-level params.
300
307
  */
301
- export type WithdrawalCustomerData = LighterWithdrawalCustomerData;
308
+ export type WithdrawalCustomerData = LighterWithdrawalCustomerData | NadoWithdrawalCustomerData;
309
+ /**
310
+ * Config-level customer-specific data, discriminated by `customerName`. The
311
+ * `customerConfig` counterpart to {@link WithdrawalCustomerData}.
312
+ */
313
+ export type WithdrawalCustomerConfig = NadoWithdrawalCustomerConfig;
314
+ export type { NadoWithdrawalCustomerConfig, NadoWithdrawalCustomerData };
302
315
  export interface WithdrawalParam {
303
316
  quoteId: string;
304
317
  funQuote: unknown;
@@ -316,6 +329,23 @@ export interface WithdrawalParam {
316
329
  */
317
330
  withdrawalUSD?: string;
318
331
  }
332
+ /**
333
+ * Form data for an in-flight withdrawal, passed as the second argument of
334
+ * `onWithdrawalConfirmation` (see {@link UseFunkitCheckoutProps}).
335
+ * `chainId` / `tokenAddress` / `tokenSymbol` describe the destination
336
+ * (receive) side the user selected in the modal.
337
+ */
338
+ export type WithdrawalFormData = {
339
+ destinationAddress: Address;
340
+ withdrawalUSD: string;
341
+ tokenSymbol: string;
342
+ tokenAddress: Address;
343
+ chainId: number;
344
+ quote?: FunkitCheckoutQuoteResult;
345
+ /** Customer-specific data for quoteless flows (e.g. Lighter Secure). */
346
+ customerData?: WithdrawalCustomerData;
347
+ userInputAmount: string;
348
+ };
319
349
  /**
320
350
  * A single entry in a {@link MultiMethodWithdrawalConfig}.
321
351
  *
@@ -422,8 +452,16 @@ interface UseFunkitCheckoutBaseProps {
422
452
  interface CashierFormFactorProps {
423
453
  formFactor: 'cashier';
424
454
  withdrawalConfig: FunkitWithdrawalConfig;
425
- /** @optional fires when a withdrawal is confirmed with the funkit server. Returns the newly created withdrawalId. **/
426
- onWithdrawalConfirmation?: (withdrawalId: string) => void;
455
+ /**
456
+ * @optional fires once the withdrawal has been submitted — after the wallet
457
+ * transaction is sent or the custom withdrawCallback resolves. `formData`
458
+ * carries the resolved destination chain/token
459
+ * ({@link WithdrawalFormData}) so integrators can track cross-chain
460
+ * withdrawals (e.g. security flows). The first argument is kept for
461
+ * backwards compatibility: the destination address on wallet flows, the
462
+ * quoteId on custom-callback flows.
463
+ */
464
+ onWithdrawalConfirmation?: (withdrawalId: string, formData: WithdrawalFormData) => void;
427
465
  /** @optional fires if the withdrawal fails at any point **/
428
466
  onWithdrawalError?: (result: FunkitCheckoutResult) => void;
429
467
  }
@@ -446,7 +484,7 @@ export interface UseFunkitCheckoutPropsWithFullConfig extends UseFunkitCheckoutB
446
484
  config: FunkitCheckoutConfig;
447
485
  formFactor?: 'cashier' | 'checkout';
448
486
  withdrawalConfig?: FunkitWithdrawalConfig;
449
- onWithdrawalConfirmation?: (withdrawalId: string) => void;
487
+ onWithdrawalConfirmation?: (withdrawalId: string, formData: WithdrawalFormData) => void;
450
488
  onWithdrawalError?: (result: FunkitCheckoutResult) => void;
451
489
  }
452
490
  /**
@@ -126,7 +126,7 @@ export interface FunkitUiCustomizationsConfig {
126
126
  * - "chainDependent": show price impact and additionally show gas as well for eth-mainnet
127
127
  */
128
128
  showTransactionDigest?: 'none' | 'chainDependent';
129
- /** Whether to show the amount of tokens below the USD equivalent - defaults to true */
129
+ /** @deprecated The token amount below the USD equivalent has been removed. This field is ignored. */
130
130
  showTokenAmount?: boolean;
131
131
  /** Instead of showing the dollar value centered, show it left-aligned with "Deposit" label - defaults to false */
132
132
  showLeftAlignedDollarValueWithLabel?: boolean;
@@ -247,7 +247,7 @@ export interface FunkitUiCustomizationsConfig {
247
247
  */
248
248
  type RequiredExceptCustomComponents<T> = Required<Omit<T & {}, `${string}Component`>>;
249
249
  export type FunkitUiCustomizationsConfigInternal = Required<FunkitUiCustomizationsConfig> & {
250
- confirmationScreen: FunkitUiCustomizationsConfig['confirmationScreen'] & Required<Omit<FunkitUiCustomizationsConfig['confirmationScreen'] & {}, 'destinationConfig' | 'selectedRouteConfig'>>;
250
+ confirmationScreen: FunkitUiCustomizationsConfig['confirmationScreen'] & Required<Omit<FunkitUiCustomizationsConfig['confirmationScreen'] & {}, 'destinationConfig' | 'selectedRouteConfig' | 'showTokenAmount'>>;
251
251
  inputAmountScreen: Required<FunkitUiCustomizationsConfig['inputAmountScreen'] & {}>;
252
252
  selectAssetScreen: RequiredExceptCustomComponents<FunkitUiCustomizationsConfig['selectAssetScreen']>;
253
253
  transferCryptoScreen: RequiredExceptCustomComponents<FunkitUiCustomizationsConfig['transferCryptoScreen']>;
@@ -273,6 +273,13 @@ export type FunkitConfig = {
273
273
  prefillFiatEmail?: string;
274
274
  /** Disable Datadog logging - defaults to false (logging enabled) */
275
275
  disableLogging?: boolean;
276
+ /**
277
+ * Source used to attribute your onchain activity — should be a domain (e.g.
278
+ * `'yourapp.com'`). Applied once at provider init. When omitted, a source is
279
+ * derived automatically, which may log a console warning; set this to
280
+ * attribute activity explicitly and silence it.
281
+ */
282
+ source?: string;
276
283
  };
277
284
  interface FinalFunkitConfigInternal extends FunkitConfig {
278
285
  textCustomizations: FunkitTextCustomizationsConfig;
@@ -34,10 +34,7 @@ export declare const useGeneralWallet: () => GeneralWalletContextProps;
34
34
  *
35
35
  * `userId` is `userInfo.id` (not `userInfo.address`). `walletAddress` is the
36
36
  * resolved `effectiveAddress` from context, normalized to the contract's `''`
37
- * sentinel when absent — `GeneralWalletProvider` types the field `Address | ''`
38
- * but leaks `undefined` for guests via a `@ts-expect-error`, so we coalesce
39
- * here to keep web aligned with the contract (and with the eventual React
40
- * Native implementation).
37
+ * sentinel when absent.
41
38
  */
42
39
  export declare const useIdentity: IdentityProvider['useIdentity'];
43
40
  /**
@@ -1,5 +1,5 @@
1
+ export { MAX_BTC_LIGHTNING_AMOUNT_USD } from '@funkit/connect-core';
1
2
  export declare const MIN_CHECKOUT_AMOUNT_USD = 1;
2
- export declare const MAX_BTC_LIGHTNING_AMOUNT_USD = 10000;
3
3
  export declare const LOW_BALANCE = "Low Balance";
4
4
  export declare const CONTACT_US_LINK = "https://intercom.help/funxyz/en/articles/10732578-contact-us";
5
5
  export declare const DEFAULT_CHECKOUT_HISTORY_DETAIL_TITLE = "Your Purchase";
@@ -52,9 +52,14 @@ export type LighterAsset = {
52
52
  locked_balance: string;
53
53
  };
54
54
  /**
55
- * A user's stake in a Lighter public pool. The staking pool is identified by
56
- * matching `public_pool_index` against the known staking pool index;
57
- * `principal_amount` is the staked USDC principal (decimal string).
55
+ * A user's stake in a Lighter public pool, identified by matching
56
+ * `public_pool_index` against the known pool index.
57
+ *
58
+ * Carries only *entry* state — there is no current-value field:
59
+ * - `principal_amount` — deposited at entry, in the pool's own asset (Lighter's
60
+ * UI shows this as "Your Deposits"). Never grows with accrued yield.
61
+ * - `shares_amount` — pool shares held. Current value ("Your Stake") is this
62
+ * times the pool's share price, so it needs the pool account too.
58
63
  */
59
64
  export type LighterShare = {
60
65
  public_pool_index: number;
@@ -63,6 +68,14 @@ export type LighterShare = {
63
68
  principal_amount: string;
64
69
  entry_timestamp: number;
65
70
  };
71
+ /**
72
+ * Public-pool accounting, present only on pool accounts (`account_type: 4`).
73
+ * Share price is `<pool asset balance> / total_shares`.
74
+ */
75
+ export type LighterPoolInfo = {
76
+ total_shares: number;
77
+ operator_shares: number;
78
+ };
66
79
  export type LighterAccount = {
67
80
  code: number;
68
81
  account_type: number;
@@ -90,6 +103,8 @@ export type LighterAccount = {
90
103
  cross_asset_value: string;
91
104
  shares: LighterShare[];
92
105
  pending_unlocks: unknown[];
106
+ /** Pool accounts only — absent on user accounts. */
107
+ pool_info?: LighterPoolInfo;
93
108
  };
94
109
  export type LighterAccountResponse = {
95
110
  code: number;
@@ -1,7 +1,74 @@
1
- import { type Address } from 'viem';
1
+ import { type Address, type Hex } from 'viem';
2
2
  export declare const LIGHTER_DEPOSIT_ADDRESS: Address;
3
3
  export declare const LIGHTER_SLOW_DEPOSIT_TIME_ESTIMATE_SECONDS: number;
4
4
  export declare const LIGHTER_DELAYED_AUTO_TRIGGER_CUTOFF: number;
5
+ /**
6
+ * zkLighter L1 `withdraw` ABI — selector `0xd20191bd`, non-payable, on the same
7
+ * contract as deposits. `amount` is in Lighter base units (see
8
+ * {@link lighterWithdrawBaseUnits}).
9
+ */
10
+ export declare const LIGHTER_WITHDRAW_ABI: readonly [{
11
+ readonly type: "function";
12
+ readonly name: "withdraw";
13
+ readonly stateMutability: "nonpayable";
14
+ readonly inputs: readonly [{
15
+ readonly name: "accountIndex";
16
+ readonly type: "uint48";
17
+ }, {
18
+ readonly name: "assetIndex";
19
+ readonly type: "uint16";
20
+ }, {
21
+ readonly name: "routeType";
22
+ readonly type: "uint8";
23
+ }, {
24
+ readonly name: "amount";
25
+ readonly type: "uint64";
26
+ }];
27
+ readonly outputs: readonly [];
28
+ }];
29
+ /** Strips fractional digits beyond `decimals` (string-based, no float math). */
30
+ export declare function truncateToDecimals(amount: string, decimals: number): string;
31
+ /**
32
+ * Converts a token-unit amount to Lighter L1 `withdraw` base units.
33
+ *
34
+ * Uses the L2 convention — USDC (asset index 3) = 6 decimals, all other assets
35
+ * = 8 — NOT the mainnet ERC-20 decimals (LIT/ETH would be 18). Confirmed on
36
+ * chain: 1 USDC → `1_000_000`, 1 LIT → `100_000_000`.
37
+ */
38
+ export declare function lighterWithdrawBaseUnits(assetIndex: number, amountTokenUnits: string): bigint;
39
+ /**
40
+ * Builds the on-chain `withdraw` transaction for the L1 fallback. `value` is 0
41
+ * (no protocol fee — the user pays gas only).
42
+ */
43
+ export declare function buildLighterL1WithdrawTransaction(params: {
44
+ accountIndex: number;
45
+ assetIndex: number;
46
+ routeType: number;
47
+ amountBaseUnit: bigint;
48
+ }): {
49
+ to: Address;
50
+ data: Hex;
51
+ value: bigint;
52
+ };
53
+ /**
54
+ * Explorer link for a Lighter Secure withdrawal tx. The L1 on-chain fallback
55
+ * produces a canonical 32-byte mainnet tx hash → Etherscan; L2 Secure hashes
56
+ * are Lighter's own (non-EVM) format → Lighter explorer. Detecting the EVM hash
57
+ * keeps L1-vs-L2 routing self-contained (no extra state threaded through the
58
+ * modal step machine).
59
+ */
60
+ export declare function resolveLighterWithdrawalExplorerUrl(txHash: string): string;
61
+ /**
62
+ * True when an error is Lighter's **L2 (Secure) withdrawal** rate limit —
63
+ * codes 23004 / 23005, e.g. "Too Many L2 Withdrawal Requests!: L2 withdrawal
64
+ * rate limit exceeded. Only 3 withdrawals allowed per 2 hours". Used to offer
65
+ * the on-chain L1 fallback (Secure withdrawals only).
66
+ *
67
+ * The L2 SDK usually surfaces this as a plain string (the numeric code isn't
68
+ * always preserved), so we match message content — plus the structured `code`
69
+ * field when the error carries one.
70
+ */
71
+ export declare function isLighterWithdrawalRateLimitError(error: unknown): boolean;
5
72
  export declare const LIGHTER_DYNAMIC_ROUTING_ID: {
6
73
  ETH_SPOT: string;
7
74
  USDC_PERPS: string;