@funkit/connect 10.6.0 → 11.0.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 (45) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/clients/chunk-2FSEE3AW.js +277 -0
  3. package/dist/clients/chunk-5MY7WMEJ.js +20 -0
  4. package/dist/clients/chunk-6CYZKITE.js +33 -0
  5. package/dist/clients/{chunk-TG2AACP2.js → chunk-C4SHJFOV.js} +2 -2
  6. package/dist/clients/{chunk-3LJQTM37.js → chunk-FNB7OPJI.js} +12 -198
  7. package/dist/clients/{chunk-2NBYHUIW.js → chunk-HZP4DXIZ.js} +1 -0
  8. package/dist/clients/{chunk-F6P4CN27.js → chunk-JD2J5K6S.js} +16 -8
  9. package/dist/clients/chunk-LT4EWLDA.js +30 -0
  10. package/dist/clients/chunk-MGQLVTSH.js +100 -0
  11. package/dist/clients/{chunk-FJ6GCMJ4.js → chunk-OODIKHYE.js} +3 -1
  12. package/dist/clients/chunk-SFDEST63.js +18 -0
  13. package/dist/clients/{chunk-OZ3KD24N.js → chunk-ZCCLJW6F.js} +0 -8
  14. package/dist/clients/fanatics.js +5 -6
  15. package/dist/clients/internal/nado/encoding.js +4 -25
  16. package/dist/clients/internal/nado/gateway.d.ts +0 -21
  17. package/dist/clients/internal/nado/gateway.js +1 -5
  18. package/dist/clients/internal/nado/hooks.d.ts +0 -158
  19. package/dist/clients/internal/nado/hooks.js +10 -121
  20. package/dist/clients/internal/nado/withdrawalConfig.js +3 -13
  21. package/dist/clients/internal/nado/withdrawalForm.css +17529 -0
  22. package/dist/clients/internal/nado/withdrawalForm.d.ts +41 -0
  23. package/dist/clients/internal/nado/withdrawalForm.js +283 -0
  24. package/dist/clients/internal/nado/withdrawalTypes.d.ts +7 -2
  25. package/dist/clients/lighter.d.ts +29 -1
  26. package/dist/clients/lighter.js +105 -99
  27. package/dist/clients/mallard.js +24 -3
  28. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +6 -3
  29. package/dist/clients/polymarket/index.js +6 -3
  30. package/dist/domains/swapped.d.ts +1 -10
  31. package/dist/hooks/useTokenAndChainDropdown.d.ts +8 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +1369 -892
  34. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +20 -31
  35. package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +5 -9
  36. package/dist/providers/FunkitCheckoutContext/types.d.ts +61 -4
  37. package/dist/utils/customer.d.ts +349 -0
  38. package/dist/utils/withdrawal.d.ts +13 -6
  39. package/dist/wagmi/actions.d.ts +1 -1
  40. package/dist/wallets/Wallet.d.ts +21 -1
  41. package/dist/wallets/walletConnectors/index.js +11 -11
  42. package/package.json +3 -3
  43. package/dist/clients/chunk-A4WQS6QG.js +0 -207
  44. package/dist/clients/internal/nado/products.d.ts +0 -36
  45. package/dist/clients/internal/nado/products.js +0 -19
@@ -7,9 +7,8 @@ import { type LighterAccountIndex } from '@funkit/api-base';
7
7
  import React from 'react';
8
8
  import { type Address, type Hex } from 'viem';
9
9
  import { type CheckoutConfirmationError } from '../../domains/checkoutErrors';
10
- import type { CustomWithdrawalConfig, LighterRouteType, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
10
+ import type { CustomWithdrawalConfig, LighterRouteType, TokenInfo, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
11
11
  import type { LighterAsset, LighterPoolInfo, LighterShare } from '../../utils/customer';
12
- import type { SourceTokenOption } from './WithdrawAmountInput';
13
12
  /** Stable method ids for the Fast / Secure options (used for tracking + switching). */
14
13
  export declare const LIGHTER_FAST_METHOD_ID = "lighter-fast";
15
14
  export declare const LIGHTER_SECURE_METHOD_ID = "lighter-secure";
@@ -39,6 +38,21 @@ export declare function getLighterBaseSymbol(symbol: string): string;
39
38
  * including the `USDC (Spot)` pseudo-symbol — is a spot asset (route 1).
40
39
  */
41
40
  export declare function resolveLighterSecureRouteType(selectedSourceToken: string): LighterRouteType;
41
+ /**
42
+ * The selected source token as identified on Lighter's own L2, rather than by
43
+ * its mainnet bridge address — two Secure selections can share one mainnet
44
+ * address (USDC perps and USDC spot both bridge mainnet USDC), so the bridge
45
+ * address can't name which balance is meant.
46
+ *
47
+ * Follows `RELAY_LIGHTER_FUN_ADDRESS_MAP`: the asset index left-padded into an
48
+ * address (`0x…01` = ETH spot, `0x…03` = USDC spot). `undefined` when the index
49
+ * hasn't resolved yet, so callers keep their existing value rather than pointing
50
+ * at asset 0.
51
+ */
52
+ export declare function resolveLighterSourceAsset({ assetIndex, routeType, }: {
53
+ assetIndex: number | undefined;
54
+ routeType: LighterRouteType;
55
+ }): TokenInfo | undefined;
42
56
  /**
43
57
  * Mainnet ERC-20 address for a Lighter Secure source token symbol, or undefined
44
58
  * if the symbol isn't a known Secure asset.
@@ -59,8 +73,6 @@ export declare const LIGHTER_FAST_MAX_WITHDRAWAL_USD = 3000000;
59
73
  export declare function LighterFastMaxExceededMessage({ onSwitchToSecure, }: {
60
74
  onSwitchToSecure: () => void;
61
75
  }): React.JSX.Element;
62
- /** Free (withdrawable) balance for a single Lighter asset: balance - locked. */
63
- export declare function freeBalance(balance: string, lockedBalance: string): string;
64
76
  /**
65
77
  * Lighter Fast charges an "unstaked" fee — a flat deduction taken off the
66
78
  * withdrawal amount before quoting — for users who aren't sufficiently staked
@@ -106,15 +118,14 @@ export declare function resolveLighterUnstakedFeeTokens(shares: LighterShare[],
106
118
  */
107
119
  export declare function useLighterStakingSharePrice(enabled: boolean): number | undefined;
108
120
  /**
109
- * Fetches all asset balances for a Lighter account. Returns:
110
- *
111
- * - `balances` — `Record<SYMBOL, freeBalance>` (uppercased symbol keys)
112
- * - `assets` — raw asset list from the API (for building source-token options)
121
+ * Fetches the Lighter account for the data the SDK still derives itself:
122
+ * `shares` for the unstaked-fee gate, and `assets` to resolve the L2 asset index
123
+ * of a Secure selection. Withdrawable balances are the integrator's to supply
124
+ * (`withdrawalSourceTokenBalance`), so nothing here computes them.
113
125
  */
114
126
  export declare function useLighterWithdrawalBalances({ accountIndex, }: {
115
127
  accountIndex: LighterAccountIndex | undefined;
116
128
  }): {
117
- balances: Record<string, string>;
118
129
  assets: LighterAsset[];
119
130
  shares: LighterShare[];
120
131
  isLoading: boolean;
@@ -131,20 +142,6 @@ export declare function resolveLighterAssetIndex(lighterAssets: {
131
142
  symbol: string;
132
143
  asset_id: number;
133
144
  }[], selectedSourceToken: string): number | undefined;
134
- /**
135
- * Builds the source-token options list for the Lighter compound input dropdown.
136
- *
137
- * - Fast path: only USDC (Perps).
138
- * - Secure path: USDC (Perps) (from total_asset_value) + USDC (Spot) when the
139
- * account carries a spot USDC asset + every non-USDC asset on the account.
140
- *
141
- * Unified Trading accounts (`isUnifiedTradingMode`) have a single USDC balance
142
- * — no spot/perps split — so the perps entry is labeled plain `USDC` and the
143
- * `USDC (Spot)` entry is hidden on both paths.
144
- */
145
- export declare function buildLighterSourceTokenOptions(config: FunkitWithdrawalConfig, lighterAssets: {
146
- symbol: string;
147
- }[], isUnifiedTradingMode?: boolean): SourceTokenOption[];
148
145
  /**
149
146
  * Detects Lighter Secure withdrawal (mainnet source chain), auto-fills the
150
147
  * recipient address with the connected wallet, and fetches the Lighter account
@@ -155,7 +152,6 @@ export declare function useLighterWithdrawal(config: FunkitWithdrawalConfig, set
155
152
  isLighterFast: boolean;
156
153
  isUnifiedTradingMode: boolean;
157
154
  connectedAddress: `0x${string}` | undefined;
158
- lighterBalances: Record<string, string>;
159
155
  lighterAssets: LighterAsset[];
160
156
  lighterFastUnstakedFee: number;
161
157
  invalidateLighterAccount: () => void;
@@ -196,13 +192,6 @@ export declare function useLighterL1Fallback({ isLighterSecure, withdrawalError,
196
192
  isSubmittingL1: boolean;
197
193
  l1FallbackError: CheckoutConfirmationError | null;
198
194
  };
199
- /**
200
- * Resolves the source-token dropdown options for a Lighter customer.
201
- * Returns `undefined` for non-Lighter customers (no dropdown needed).
202
- */
203
- export declare function useLighterSourceTokenOptions(config: FunkitWithdrawalConfig, apiKey: string, lighterAssets: {
204
- symbol: string;
205
- }[], isUnifiedTradingMode?: boolean): SourceTokenOption[] | undefined;
206
195
  /**
207
196
  * Lighter Secure: recipient address, locked to the connected wallet. A
208
197
  * read-only `FunInput` (not a `<div>`) keeps it focusable and announced by
@@ -1,11 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { FunkitWithdrawalConfig, MultiMethodWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
3
- export interface SourceTokenOption {
4
- symbol: string;
5
- /** Display label (may differ from symbol, e.g. "USDC (Perps)") */
6
- label: string;
7
- iconSrc?: string;
8
- }
3
+ import type { SourceTokenOption } from '../../providers/FunkitCheckoutContext';
4
+ export type { SourceTokenOption };
9
5
  export declare function WithdrawAmountInput({ withdrawalInputAmount, setWithdrawalInputAmount, sourceTokenBalance, isWithdrawAmountTooLow, isWithdrawAmountTooHigh, isWithdrawAmountAboveBalance, isWithdrawAmountValid, minWithdrawalDisplayValue, config, sourceTokenOptions, onSourceTokenChange, selectedSourceToken, sourceTokenUsdPrice, }: {
10
6
  config: Exclude<FunkitWithdrawalConfig, MultiMethodWithdrawalConfig>;
11
7
  sourceTokenBalance: string;
@@ -24,9 +20,9 @@ export declare function WithdrawAmountInput({ withdrawalInputAmount, setWithdraw
24
20
  isWithdrawAmountAboveBalance: boolean;
25
21
  isWithdrawAmountValid: boolean;
26
22
  /**
27
- * Minimum-withdrawal value formatted for display. Token units when the
28
- * config provides `getMinWithdrawalAmount` (Lighter Secure); USD otherwise.
29
- * The component picks the rendering style from `isLighter`.
23
+ * Minimum-withdrawal value for display. Carries no unit of its own — token
24
+ * units when the config provides `getMinWithdrawalAmount`, USD otherwise — so
25
+ * the component re-derives which one it got (see `isMinInTokenUnits`).
30
26
  */
31
27
  minWithdrawalDisplayValue: number;
32
28
  sourceTokenOptions?: SourceTokenOption[];
@@ -136,7 +136,7 @@ export interface FunkitCheckoutConfig extends Omit<ApiFunkitCheckoutConfig, 'gen
136
136
  /** Title of the item being checked out. e.g. Staked Ether, XYZ Option, Solar Bond ABC **/
137
137
  checkoutItemTitle: string;
138
138
  /** amount of source token. it is not baseUnit **/
139
- withdrawalSourceTokenBalance?: () => string | number;
139
+ withdrawalSourceTokenBalance?: (params: WithdrawalSourceTokenBalanceParams) => string | number;
140
140
  /** @deprecated isDefiMode has been removed. This field is ignored. */
141
141
  isDefiMode?: boolean;
142
142
  /** The step at which the checkout process should start */
@@ -187,6 +187,31 @@ export interface FunkitCheckoutConfig extends Omit<ApiFunkitCheckoutConfig, 'gen
187
187
  */
188
188
  addToWalletToken?: AddToWalletToken;
189
189
  }
190
+ /** One entry in the withdrawal source-token dropdown. */
191
+ export interface SourceTokenOption {
192
+ /** Selection key. May be a pseudo-symbol where one token has variants. */
193
+ symbol: string;
194
+ /** Display label (may differ from symbol, e.g. "USDC (Perps)") */
195
+ label: string;
196
+ iconSrc?: string;
197
+ /**
198
+ * This option's own asset identity, passed to
199
+ * {@link WithdrawalConfigBase.withdrawalSourceTokenBalance} when selected.
200
+ * Omit only when every option shares the config's source token — otherwise the
201
+ * balance is requested for the wrong asset. `decimals` is required by flows
202
+ * that scale a signed amount from this option.
203
+ */
204
+ asset?: TokenInfo & {
205
+ decimals?: number;
206
+ };
207
+ /**
208
+ * Flow-specific identity for this option, forwarded to
209
+ * {@link WithdrawalConfigBase.withdrawalSourceTokenBalance} when selected.
210
+ * Carries the venue's own key for the asset where {@link asset} can't express
211
+ * it — Nado addresses balances by product id, not by token address.
212
+ */
213
+ customData?: WithdrawalSourceCustomData;
214
+ }
190
215
  export interface WithdrawalConfigBase {
191
216
  /** Title to show in the checkout modal. Defaults to "Checkout" **/
192
217
  modalTitle: string;
@@ -195,6 +220,12 @@ export interface WithdrawalConfigBase {
195
220
  /** Icon to show in the checkout modal (50px x 50px). If not specified, no icon will be shown. **/
196
221
  iconSrc?: null | string;
197
222
  sourceTokenSymbol: string;
223
+ /**
224
+ * Selectable source tokens, when the flow has more than one. Omit for
225
+ * single-source flows — {@link sourceTokenSymbol} is then the only option.
226
+ * {@link withdrawalSourceTokenBalance} is called with whichever is selected.
227
+ */
228
+ sourceTokens?: SourceTokenOption[];
198
229
  /** source chain id to withdraw **/
199
230
  sourceChainId: string;
200
231
  /** source token id to withdraw **/
@@ -217,11 +248,13 @@ export interface WithdrawalConfigBase {
217
248
  */
218
249
  getMaxWithdrawalUSD?: (asset: TokenInfo) => number;
219
250
  /**
220
- * Returns the current withdrawable balance for the source token.
251
+ * Returns the current withdrawable balance for `sourceAsset`. Takes precedence
252
+ * over any balance the SDK derives itself, so it must account for whatever the
253
+ * SDK cannot see (margin requirements, locked collateral).
221
254
  * Called on every render — use a ref-backed stable callback so the value
222
255
  * stays live without triggering unnecessary re-renders.
223
256
  */
224
- withdrawalSourceTokenBalance?: () => string | number;
257
+ withdrawalSourceTokenBalance?: (params: WithdrawalSourceTokenBalanceParams) => string | number;
225
258
  /**
226
259
  * Optional async hook fired when the user commits to the withdrawal — after
227
260
  * the withdraw CTA, but before any nonce fetch, wallet signature, or tx
@@ -312,6 +345,28 @@ export type WithdrawalCustomerData = LighterWithdrawalCustomerData | NadoWithdra
312
345
  */
313
346
  export type WithdrawalCustomerConfig = NadoWithdrawalCustomerConfig;
314
347
  export type { NadoWithdrawalCustomerConfig, NadoWithdrawalCustomerData };
348
+ /**
349
+ * Flow-specific descriptor for the selected source token, discriminated by
350
+ * `type`. Needed where {@link TokenInfo} alone can't name the balance:
351
+ * - Lighter exposes USDC twice, as perps collateral and as a spot asset, and
352
+ * both bridge to the same mainnet address (`routeType` matches
353
+ * {@link LighterWithdrawalCustomerData.routeType}).
354
+ * - Nado keys every subaccount query on a product id, not a token address.
355
+ */
356
+ export type WithdrawalSourceCustomData = {
357
+ type: 'lighter';
358
+ routeType: LighterRouteType;
359
+ } | {
360
+ type: 'nado';
361
+ /** Nado's own key for the asset — every subaccount query is keyed on it. */
362
+ productId: number;
363
+ };
364
+ /** Argument of {@link WithdrawalConfigBase.withdrawalSourceTokenBalance}. */
365
+ export interface WithdrawalSourceTokenBalanceParams {
366
+ sourceAsset: TokenInfo;
367
+ /** Absent for flows whose source token needs no further disambiguation. */
368
+ customData?: WithdrawalSourceCustomData;
369
+ }
315
370
  export interface WithdrawalParam {
316
371
  quoteId: string;
317
372
  funQuote: unknown;
@@ -523,5 +578,7 @@ export interface FunkitActiveWithdrawalItem {
523
578
  id: string;
524
579
  /** Final settings the withdrawal was init-ed with **/
525
580
  initSettings: Partial<UseFunkitCheckoutPropsWithFullConfig>;
526
- withdrawalSourceTokenBalance: () => string | number;
581
+ /** Absent when the integrator wired no callback — never defaulted to `0`, so
582
+ * the flow can tell "unknown" from "nothing withdrawable". */
583
+ withdrawalSourceTokenBalance?: (params: WithdrawalSourceTokenBalanceParams) => string | number;
527
584
  }
@@ -284,6 +284,177 @@ export declare function useLighterAccount(lookup: LighterAccountLookup | null, o
284
284
  fetchStatus: import("@tanstack/react-query").FetchStatus;
285
285
  promise: Promise<LighterAccountResponse>;
286
286
  };
287
+ /**
288
+ * Ungated {@link useLighterAccount}. For callers whose module is Lighter-specific
289
+ * by construction — `clients/lighter` is a separate bundle entry with its own copy
290
+ * of the config context, so `useFunkitConfig()` there yields no api key and a
291
+ * customer check would disable the query forever.
292
+ */
293
+ export declare function useLighterAccountQuery(lookup: LighterAccountLookup | null, options?: {
294
+ activeOnly?: boolean;
295
+ }): {
296
+ account: LighterAccount | undefined;
297
+ data: LighterAccountResponse;
298
+ error: Error;
299
+ isError: true;
300
+ isPending: false;
301
+ isLoading: false;
302
+ isLoadingError: false;
303
+ isRefetchError: true;
304
+ isSuccess: false;
305
+ isPlaceholderData: false;
306
+ status: "error";
307
+ dataUpdatedAt: number;
308
+ errorUpdatedAt: number;
309
+ failureCount: number;
310
+ failureReason: Error | null;
311
+ errorUpdateCount: number;
312
+ isFetched: boolean;
313
+ isFetchedAfterMount: boolean;
314
+ isFetching: boolean;
315
+ isInitialLoading: boolean;
316
+ isPaused: boolean;
317
+ isRefetching: boolean;
318
+ isStale: boolean;
319
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountResponse, Error>>;
320
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
321
+ promise: Promise<LighterAccountResponse>;
322
+ } | {
323
+ account: LighterAccount | undefined;
324
+ data: LighterAccountResponse;
325
+ error: null;
326
+ isError: false;
327
+ isPending: false;
328
+ isLoading: false;
329
+ isLoadingError: false;
330
+ isRefetchError: false;
331
+ isSuccess: true;
332
+ isPlaceholderData: false;
333
+ status: "success";
334
+ dataUpdatedAt: number;
335
+ errorUpdatedAt: number;
336
+ failureCount: number;
337
+ failureReason: Error | null;
338
+ errorUpdateCount: number;
339
+ isFetched: boolean;
340
+ isFetchedAfterMount: boolean;
341
+ isFetching: boolean;
342
+ isInitialLoading: boolean;
343
+ isPaused: boolean;
344
+ isRefetching: boolean;
345
+ isStale: boolean;
346
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountResponse, Error>>;
347
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
348
+ promise: Promise<LighterAccountResponse>;
349
+ } | {
350
+ account: LighterAccount | undefined;
351
+ data: undefined;
352
+ error: Error;
353
+ isError: true;
354
+ isPending: false;
355
+ isLoading: false;
356
+ isLoadingError: true;
357
+ isRefetchError: false;
358
+ isSuccess: false;
359
+ isPlaceholderData: false;
360
+ status: "error";
361
+ dataUpdatedAt: number;
362
+ errorUpdatedAt: number;
363
+ failureCount: number;
364
+ failureReason: Error | null;
365
+ errorUpdateCount: number;
366
+ isFetched: boolean;
367
+ isFetchedAfterMount: boolean;
368
+ isFetching: boolean;
369
+ isInitialLoading: boolean;
370
+ isPaused: boolean;
371
+ isRefetching: boolean;
372
+ isStale: boolean;
373
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountResponse, Error>>;
374
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
375
+ promise: Promise<LighterAccountResponse>;
376
+ } | {
377
+ account: LighterAccount | undefined;
378
+ data: undefined;
379
+ error: null;
380
+ isError: false;
381
+ isPending: true;
382
+ isLoading: true;
383
+ isLoadingError: false;
384
+ isRefetchError: false;
385
+ isSuccess: false;
386
+ isPlaceholderData: false;
387
+ status: "pending";
388
+ dataUpdatedAt: number;
389
+ errorUpdatedAt: number;
390
+ failureCount: number;
391
+ failureReason: Error | null;
392
+ errorUpdateCount: number;
393
+ isFetched: boolean;
394
+ isFetchedAfterMount: boolean;
395
+ isFetching: boolean;
396
+ isInitialLoading: boolean;
397
+ isPaused: boolean;
398
+ isRefetching: boolean;
399
+ isStale: boolean;
400
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountResponse, Error>>;
401
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
402
+ promise: Promise<LighterAccountResponse>;
403
+ } | {
404
+ account: LighterAccount | undefined;
405
+ data: undefined;
406
+ error: null;
407
+ isError: false;
408
+ isPending: true;
409
+ isLoadingError: false;
410
+ isRefetchError: false;
411
+ isSuccess: false;
412
+ isPlaceholderData: false;
413
+ status: "pending";
414
+ dataUpdatedAt: number;
415
+ errorUpdatedAt: number;
416
+ failureCount: number;
417
+ failureReason: Error | null;
418
+ errorUpdateCount: number;
419
+ isFetched: boolean;
420
+ isFetchedAfterMount: boolean;
421
+ isFetching: boolean;
422
+ isLoading: boolean;
423
+ isInitialLoading: boolean;
424
+ isPaused: boolean;
425
+ isRefetching: boolean;
426
+ isStale: boolean;
427
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountResponse, Error>>;
428
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
429
+ promise: Promise<LighterAccountResponse>;
430
+ } | {
431
+ account: LighterAccount | undefined;
432
+ data: LighterAccountResponse;
433
+ isError: false;
434
+ error: null;
435
+ isPending: false;
436
+ isLoading: false;
437
+ isLoadingError: false;
438
+ isRefetchError: false;
439
+ isSuccess: true;
440
+ isPlaceholderData: true;
441
+ status: "success";
442
+ dataUpdatedAt: number;
443
+ errorUpdatedAt: number;
444
+ failureCount: number;
445
+ failureReason: Error | null;
446
+ errorUpdateCount: number;
447
+ isFetched: boolean;
448
+ isFetchedAfterMount: boolean;
449
+ isFetching: boolean;
450
+ isInitialLoading: boolean;
451
+ isPaused: boolean;
452
+ isRefetching: boolean;
453
+ isStale: boolean;
454
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountResponse, Error>>;
455
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
456
+ promise: Promise<LighterAccountResponse>;
457
+ };
287
458
  export declare function useLighterAccounts({ address, }: {
288
459
  address: Address | '' | undefined;
289
460
  }): {
@@ -461,6 +632,184 @@ export declare function useLighterAccounts({ address, }: {
461
632
  fetchStatus: import("@tanstack/react-query").FetchStatus;
462
633
  promise: Promise<LighterAccountsByL1AddressResponse>;
463
634
  };
635
+ /** Ungated {@link useLighterAccounts}. See {@link useLighterAccountQuery}. */
636
+ export declare function useLighterAccountsQuery({ address, }: {
637
+ address: Address | '' | undefined;
638
+ }): {
639
+ mainAccountIndex: string | undefined;
640
+ isUnifiedTradingMode: boolean;
641
+ subAccounts: LighterSubAccount[] | undefined;
642
+ data: LighterAccountsByL1AddressResponse;
643
+ error: Error;
644
+ isError: true;
645
+ isPending: false;
646
+ isLoading: false;
647
+ isLoadingError: false;
648
+ isRefetchError: true;
649
+ isSuccess: false;
650
+ isPlaceholderData: false;
651
+ status: "error";
652
+ dataUpdatedAt: number;
653
+ errorUpdatedAt: number;
654
+ failureCount: number;
655
+ failureReason: Error | null;
656
+ errorUpdateCount: number;
657
+ isFetched: boolean;
658
+ isFetchedAfterMount: boolean;
659
+ isFetching: boolean;
660
+ isInitialLoading: boolean;
661
+ isPaused: boolean;
662
+ isRefetching: boolean;
663
+ isStale: boolean;
664
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountsByL1AddressResponse, Error>>;
665
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
666
+ promise: Promise<LighterAccountsByL1AddressResponse>;
667
+ } | {
668
+ mainAccountIndex: string | undefined;
669
+ isUnifiedTradingMode: boolean;
670
+ subAccounts: LighterSubAccount[] | undefined;
671
+ data: LighterAccountsByL1AddressResponse;
672
+ error: null;
673
+ isError: false;
674
+ isPending: false;
675
+ isLoading: false;
676
+ isLoadingError: false;
677
+ isRefetchError: false;
678
+ isSuccess: true;
679
+ isPlaceholderData: false;
680
+ status: "success";
681
+ dataUpdatedAt: number;
682
+ errorUpdatedAt: number;
683
+ failureCount: number;
684
+ failureReason: Error | null;
685
+ errorUpdateCount: number;
686
+ isFetched: boolean;
687
+ isFetchedAfterMount: boolean;
688
+ isFetching: boolean;
689
+ isInitialLoading: boolean;
690
+ isPaused: boolean;
691
+ isRefetching: boolean;
692
+ isStale: boolean;
693
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountsByL1AddressResponse, Error>>;
694
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
695
+ promise: Promise<LighterAccountsByL1AddressResponse>;
696
+ } | {
697
+ mainAccountIndex: string | undefined;
698
+ isUnifiedTradingMode: boolean;
699
+ subAccounts: LighterSubAccount[] | undefined;
700
+ data: undefined;
701
+ error: Error;
702
+ isError: true;
703
+ isPending: false;
704
+ isLoading: false;
705
+ isLoadingError: true;
706
+ isRefetchError: false;
707
+ isSuccess: false;
708
+ isPlaceholderData: false;
709
+ status: "error";
710
+ dataUpdatedAt: number;
711
+ errorUpdatedAt: number;
712
+ failureCount: number;
713
+ failureReason: Error | null;
714
+ errorUpdateCount: number;
715
+ isFetched: boolean;
716
+ isFetchedAfterMount: boolean;
717
+ isFetching: boolean;
718
+ isInitialLoading: boolean;
719
+ isPaused: boolean;
720
+ isRefetching: boolean;
721
+ isStale: boolean;
722
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountsByL1AddressResponse, Error>>;
723
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
724
+ promise: Promise<LighterAccountsByL1AddressResponse>;
725
+ } | {
726
+ mainAccountIndex: string | undefined;
727
+ isUnifiedTradingMode: boolean;
728
+ subAccounts: LighterSubAccount[] | undefined;
729
+ data: undefined;
730
+ error: null;
731
+ isError: false;
732
+ isPending: true;
733
+ isLoading: true;
734
+ isLoadingError: false;
735
+ isRefetchError: false;
736
+ isSuccess: false;
737
+ isPlaceholderData: false;
738
+ status: "pending";
739
+ dataUpdatedAt: number;
740
+ errorUpdatedAt: number;
741
+ failureCount: number;
742
+ failureReason: Error | null;
743
+ errorUpdateCount: number;
744
+ isFetched: boolean;
745
+ isFetchedAfterMount: boolean;
746
+ isFetching: boolean;
747
+ isInitialLoading: boolean;
748
+ isPaused: boolean;
749
+ isRefetching: boolean;
750
+ isStale: boolean;
751
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountsByL1AddressResponse, Error>>;
752
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
753
+ promise: Promise<LighterAccountsByL1AddressResponse>;
754
+ } | {
755
+ mainAccountIndex: string | undefined;
756
+ isUnifiedTradingMode: boolean;
757
+ subAccounts: LighterSubAccount[] | undefined;
758
+ data: undefined;
759
+ error: null;
760
+ isError: false;
761
+ isPending: true;
762
+ isLoadingError: false;
763
+ isRefetchError: false;
764
+ isSuccess: false;
765
+ isPlaceholderData: false;
766
+ status: "pending";
767
+ dataUpdatedAt: number;
768
+ errorUpdatedAt: number;
769
+ failureCount: number;
770
+ failureReason: Error | null;
771
+ errorUpdateCount: number;
772
+ isFetched: boolean;
773
+ isFetchedAfterMount: boolean;
774
+ isFetching: boolean;
775
+ isLoading: boolean;
776
+ isInitialLoading: boolean;
777
+ isPaused: boolean;
778
+ isRefetching: boolean;
779
+ isStale: boolean;
780
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountsByL1AddressResponse, Error>>;
781
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
782
+ promise: Promise<LighterAccountsByL1AddressResponse>;
783
+ } | {
784
+ mainAccountIndex: string | undefined;
785
+ isUnifiedTradingMode: boolean;
786
+ subAccounts: LighterSubAccount[] | undefined;
787
+ data: LighterAccountsByL1AddressResponse;
788
+ isError: false;
789
+ error: null;
790
+ isPending: false;
791
+ isLoading: false;
792
+ isLoadingError: false;
793
+ isRefetchError: false;
794
+ isSuccess: true;
795
+ isPlaceholderData: true;
796
+ status: "success";
797
+ dataUpdatedAt: number;
798
+ errorUpdatedAt: number;
799
+ failureCount: number;
800
+ failureReason: Error | null;
801
+ errorUpdateCount: number;
802
+ isFetched: boolean;
803
+ isFetchedAfterMount: boolean;
804
+ isFetching: boolean;
805
+ isInitialLoading: boolean;
806
+ isPaused: boolean;
807
+ isRefetching: boolean;
808
+ isStale: boolean;
809
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<LighterAccountsByL1AddressResponse, Error>>;
810
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
811
+ promise: Promise<LighterAccountsByL1AddressResponse>;
812
+ };
464
813
  /**
465
814
  * Returns a callback that invalidates the cached Lighter account queries so the
466
815
  * balance refetches eagerly (e.g. right after a withdrawal). No-op for
@@ -1,4 +1,4 @@
1
- import type { CustomWithdrawalConfig, FunkitWithdrawalConfig, MultiMethodWithdrawalConfig, WalletWithdrawalConfig } from '../providers/FunkitCheckoutContext';
1
+ import type { CustomWithdrawalConfig, FunkitWithdrawalConfig, MultiMethodWithdrawalConfig, WalletWithdrawalConfig, WithdrawalSourceTokenBalanceParams } from '../providers/FunkitCheckoutContext';
2
2
  /**
3
3
  * Deducts a flat fee (in token units) from a withdrawal input amount, clamped
4
4
  * at 0. Uses `dnum` fixed-point math so decimal strings straight off the amount
@@ -6,12 +6,19 @@ import type { CustomWithdrawalConfig, FunkitWithdrawalConfig, MultiMethodWithdra
6
6
  */
7
7
  export declare function deductFlatFee(inputAmount: string, feeTokens: number): string;
8
8
  /**
9
- * Evaluates the integrator's `withdrawalSourceTokenBalance` callback to a safe
10
- * numeric string. Returns `'0'` (with a warn) for missing/empty/NaN/negative
11
- * values, or if the callback throws. Shared by the withdrawal amount screen and
12
- * the Swapped cash cap.
9
+ * Resolves the integrator's `withdrawalSourceTokenBalance` callback to a numeric
10
+ * string. Shared by the withdrawal amount screen and the Swapped cash cap.
11
+ *
12
+ * Named `resolve*`, not `safeEvaluate*`: it may legitimately not resolve. It
13
+ * never throws either way.
14
+ *
15
+ * - `undefined` means the integrator supplied no callback — distinct from a
16
+ * callback returning `0`, which means "nothing withdrawable". Callers that
17
+ * only display a number should coalesce to `'0'`.
18
+ * - A throw or an unusable value yields `'0'` (with a warn), never `undefined`:
19
+ * a broken callback must not silently fall through to another balance source.
13
20
  */
14
- export declare function safeEvaluateWithdrawalSourceTokenBalance(fn: (() => string | number) | undefined): string;
21
+ export declare function resolveWithdrawalSourceTokenBalance(fn: ((params: WithdrawalSourceTokenBalanceParams) => string | number) | undefined, params: WithdrawalSourceTokenBalanceParams): string | undefined;
15
22
  /**
16
23
  * Type guard to check if withdrawal config uses wallet-based flow
17
24
  */
@@ -1,6 +1,6 @@
1
1
  import type { Config } from 'wagmi';
2
2
  import { type GetBalanceParameters, type GetBalanceReturnType } from 'wagmi/actions';
3
- export { estimateGas, getAccount, getGasPrice, getTransaction, getWalletClient, multicall, readContract, sendTransaction, signTypedData, switchChain, waitForTransactionReceipt, } from 'wagmi/actions';
3
+ export { estimateGas, getAccount, getGasPrice, getTransaction, getWalletClient, multicall, readContract, sendTransaction, signMessage, signTypedData, switchChain, waitForTransactionReceipt, } from 'wagmi/actions';
4
4
  export type GetBalanceReturnTypeCompat = GetBalanceReturnType & {
5
5
  formatted: string;
6
6
  };