@funkit/connect 10.3.0 → 10.5.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 (107) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/clients/chunk-2YWQL3AO.js +46 -0
  3. package/dist/clients/chunk-A4WQS6QG.js +207 -0
  4. package/dist/clients/chunk-BNMZM23Q.js +42 -0
  5. package/dist/clients/{chunk-HOORQPSY.js → chunk-F6P4CN27.js} +24 -8
  6. package/dist/clients/chunk-FJ6GCMJ4.js +29 -0
  7. package/dist/clients/chunk-II5CZTBC.js +18 -0
  8. package/dist/clients/chunk-L2KSNS7H.js +112 -0
  9. package/dist/clients/chunk-OZ3KD24N.js +107 -0
  10. package/dist/clients/{chunk-3STGJU6Z.js → chunk-QHS5N7GP.js} +2 -2
  11. package/dist/clients/{chunk-RWCJ4XGX.js → chunk-WRS7AFM2.js} +31 -2
  12. package/dist/clients/fanatics.js +1 -1
  13. package/dist/clients/internal/nado/consts.d.ts +16 -0
  14. package/dist/clients/internal/nado/consts.js +13 -0
  15. package/dist/clients/internal/nado/encoding.d.ts +22 -0
  16. package/dist/clients/internal/nado/encoding.js +32 -0
  17. package/dist/clients/internal/nado/errors.d.ts +55 -0
  18. package/dist/clients/internal/nado/errors.js +15 -0
  19. package/dist/clients/internal/nado/fetch.d.ts +15 -0
  20. package/dist/clients/internal/nado/fetch.js +9 -0
  21. package/dist/clients/internal/nado/gateway.d.ts +83 -0
  22. package/dist/clients/internal/nado/gateway.js +23 -0
  23. package/dist/clients/internal/nado/hooks.d.ts +360 -0
  24. package/dist/clients/internal/nado/hooks.js +132 -0
  25. package/dist/clients/internal/nado/indexer.d.ts +43 -0
  26. package/dist/clients/internal/nado/indexer.js +13 -0
  27. package/dist/clients/internal/nado/products.d.ts +36 -0
  28. package/dist/clients/internal/nado/products.js +19 -0
  29. package/dist/clients/internal/nado/typedData.d.ts +80 -0
  30. package/dist/clients/internal/nado/typedData.js +43 -0
  31. package/dist/clients/internal/nado/withdrawalConfig.d.ts +11 -0
  32. package/dist/clients/internal/nado/withdrawalConfig.js +17 -0
  33. package/dist/clients/internal/nado/withdrawalTypes.d.ts +30 -0
  34. package/dist/clients/internal/nado/withdrawalTypes.js +1 -0
  35. package/dist/clients/lighter.d.ts +1 -0
  36. package/dist/clients/lighter.js +202 -57
  37. package/dist/clients/mallard.js +9 -24
  38. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +3 -3
  39. package/dist/clients/polymarket/index.js +3 -3
  40. package/dist/components/ChainIcon/ChainIcon.d.ts +16 -0
  41. package/dist/components/FreeUsdcBanner/FreeUsdcBanner.d.ts +1 -1
  42. package/dist/components/FunAssetAvatar/FunAssetAvatar.d.ts +1 -2
  43. package/dist/hooks/useChainMetadata.d.ts +11 -0
  44. package/dist/hooks/useCheckoutDirectExecutionHistory.d.ts +2 -1
  45. package/dist/hooks/usePaymentMethodTabs.d.ts +8 -2
  46. package/dist/hooks/useSwappedIframeLifecycle.d.ts +5 -2
  47. package/dist/hooks/useSwappedPreload.d.ts +7 -11
  48. package/dist/hooks/useUserIpInfo.d.ts +1 -19
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.js +3700 -3299
  51. package/dist/modals/CheckoutModal/SourceChange/SourceChange.d.ts +3 -0
  52. package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframe.d.ts +4 -1
  53. package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframeController.d.ts +3 -0
  54. package/dist/modals/CheckoutModal/isWithdrawalStep.d.ts +3 -2
  55. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +46 -2
  56. package/dist/modals/WithdrawalModal/useFiatWithdrawal.d.ts +1 -1
  57. package/dist/modals/WithdrawalModal/useWithdrawal.d.ts +3 -15
  58. package/dist/providers/FunkitCheckoutContext/types.d.ts +73 -14
  59. package/dist/providers/FunkitConfigContext.d.ts +11 -0
  60. package/dist/providers/GeneralWalletProvider.d.ts +1 -4
  61. package/dist/providers/SwappedProvider.d.ts +5 -3
  62. package/dist/utils/lighter.d.ts +68 -1
  63. package/dist/utils/purifyCheckoutHistoryItem.d.ts +2 -41
  64. package/dist/utils/swapped.d.ts +1 -1
  65. package/dist/utils/tokenIconUrl.d.ts +5 -0
  66. package/dist/utils/userInfo.d.ts +8 -0
  67. package/dist/utils/withdrawal.d.ts +2 -1
  68. package/dist/wagmi/actions.d.ts +1 -1
  69. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  70. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  71. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  72. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  73. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  74. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  75. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  76. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  77. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  78. package/dist/wallets/walletConnectors/index.js +33 -33
  79. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  80. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  81. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  82. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  83. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  84. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  85. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  86. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  87. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  88. package/package.json +3 -2
  89. package/dist/hooks/useSkipSwappedPreload.d.ts +0 -7
  90. package/dist/wallets/walletConnectors/{chunk-W2LCLDPX.js → chunk-2VP2F6EK.js} +3 -3
  91. package/dist/wallets/walletConnectors/{chunk-IULPZP2Q.js → chunk-4T6ZSRJF.js} +3 -3
  92. package/dist/wallets/walletConnectors/{chunk-WAHGI5L7.js → chunk-6BW3HLBG.js} +3 -3
  93. package/dist/wallets/walletConnectors/{chunk-YO2K4MBH.js → chunk-CCQV2ZET.js} +3 -3
  94. package/dist/wallets/walletConnectors/{chunk-TKB2OY6G.js → chunk-CPI4TD43.js} +3 -3
  95. package/dist/wallets/walletConnectors/{chunk-OX37G4YT.js → chunk-F5XEEVG6.js} +3 -3
  96. package/dist/wallets/walletConnectors/{chunk-JPN6TWIT.js → chunk-HNRB7KJU.js} +3 -3
  97. package/dist/wallets/walletConnectors/{chunk-WKNQMP4A.js → chunk-HTHAK6XB.js} +3 -3
  98. package/dist/wallets/walletConnectors/{chunk-GUQM4QSL.js → chunk-MIQTHJ6X.js} +3 -3
  99. package/dist/wallets/walletConnectors/{chunk-4NV5BYRP.js → chunk-RB3HR4R2.js} +3 -3
  100. package/dist/wallets/walletConnectors/{chunk-SWFF3TWJ.js → chunk-RVOY537T.js} +3 -3
  101. package/dist/wallets/walletConnectors/{chunk-KI5Y2BBF.js → chunk-STVVP43G.js} +3 -3
  102. package/dist/wallets/walletConnectors/{chunk-OEEGYENV.js → chunk-UK7C2JXW.js} +3 -3
  103. package/dist/wallets/walletConnectors/{chunk-YQFGVZGR.js → chunk-VAPGUPHO.js} +3 -3
  104. package/dist/wallets/walletConnectors/{chunk-XCNHV3HS.js → chunk-VTM6EECM.js} +3 -3
  105. package/dist/wallets/walletConnectors/{chunk-NR2OGDHQ.js → chunk-X6CGV36L.js} +3 -3
  106. package/dist/wallets/walletConnectors/{chunk-AVDUNQUW.js → chunk-YEZM4CK4.js} +3 -3
  107. package/dist/wallets/walletConnectors/{chunk-KCRO2AGO.js → chunk-ZNX4EMPB.js} +3 -3
@@ -0,0 +1,360 @@
1
+ /**
2
+ * React-query hooks over the Nado gateway/indexer. Poll cadences are budgeted
3
+ * against Nado's IP rate limit (2400 query-weight/min): an open modal spends
4
+ * ~15 weight/min; the indexer poll runs only while a settlement is pending.
5
+ *
6
+ * @see {@link https://docs.nado.xyz/developer-resources/api/rate-limits | Nado rate limits}
7
+ */
8
+ import type { Hex } from 'viem';
9
+ /**
10
+ * React-query owns retries (the fetch layer never retries) — up to 2 with
11
+ * backoff, except deterministic api failures, 429s (retrying hammers the
12
+ * limit we just tripped), and timeouts (the caller already waited 30s; the
13
+ * next scheduled poll is the retry).
14
+ */
15
+ export declare function shouldRetryNadoQuery(failureCount: number, error: unknown): boolean;
16
+ /** Live product list; falls back to the static list while loading or on gateway failure. */
17
+ export declare function useNadoProducts(): {
18
+ data: import("./products").NadoProduct[];
19
+ error: unknown;
20
+ isError: true;
21
+ isPending: false;
22
+ isLoading: false;
23
+ isLoadingError: false;
24
+ isRefetchError: true;
25
+ isSuccess: false;
26
+ isPlaceholderData: false;
27
+ status: "error";
28
+ dataUpdatedAt: number;
29
+ errorUpdatedAt: number;
30
+ failureCount: number;
31
+ failureReason: unknown;
32
+ errorUpdateCount: number;
33
+ isFetched: boolean;
34
+ isFetchedAfterMount: boolean;
35
+ isFetching: boolean;
36
+ isInitialLoading: boolean;
37
+ isPaused: boolean;
38
+ isRefetching: boolean;
39
+ isStale: boolean;
40
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
41
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
42
+ promise: Promise<import("./products").NadoProduct[]>;
43
+ } | {
44
+ data: import("./products").NadoProduct[];
45
+ error: null;
46
+ isError: false;
47
+ isPending: false;
48
+ isLoading: false;
49
+ isLoadingError: false;
50
+ isRefetchError: false;
51
+ isSuccess: true;
52
+ isPlaceholderData: false;
53
+ status: "success";
54
+ dataUpdatedAt: number;
55
+ errorUpdatedAt: number;
56
+ failureCount: number;
57
+ failureReason: unknown;
58
+ errorUpdateCount: number;
59
+ isFetched: boolean;
60
+ isFetchedAfterMount: boolean;
61
+ isFetching: boolean;
62
+ isInitialLoading: boolean;
63
+ isPaused: boolean;
64
+ isRefetching: boolean;
65
+ isStale: boolean;
66
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
67
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
68
+ promise: Promise<import("./products").NadoProduct[]>;
69
+ } | {
70
+ data: import("./products").NadoProduct[];
71
+ error: unknown;
72
+ isError: true;
73
+ isPending: false;
74
+ isLoading: false;
75
+ isLoadingError: true;
76
+ isRefetchError: false;
77
+ isSuccess: false;
78
+ isPlaceholderData: false;
79
+ status: "error";
80
+ dataUpdatedAt: number;
81
+ errorUpdatedAt: number;
82
+ failureCount: number;
83
+ failureReason: unknown;
84
+ errorUpdateCount: number;
85
+ isFetched: boolean;
86
+ isFetchedAfterMount: boolean;
87
+ isFetching: boolean;
88
+ isInitialLoading: boolean;
89
+ isPaused: boolean;
90
+ isRefetching: boolean;
91
+ isStale: boolean;
92
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
93
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
94
+ promise: Promise<import("./products").NadoProduct[]>;
95
+ } | {
96
+ data: import("./products").NadoProduct[];
97
+ error: null;
98
+ isError: false;
99
+ isPending: true;
100
+ isLoading: true;
101
+ isLoadingError: false;
102
+ isRefetchError: false;
103
+ isSuccess: false;
104
+ isPlaceholderData: false;
105
+ status: "pending";
106
+ dataUpdatedAt: number;
107
+ errorUpdatedAt: number;
108
+ failureCount: number;
109
+ failureReason: unknown;
110
+ errorUpdateCount: number;
111
+ isFetched: boolean;
112
+ isFetchedAfterMount: boolean;
113
+ isFetching: boolean;
114
+ isInitialLoading: boolean;
115
+ isPaused: boolean;
116
+ isRefetching: boolean;
117
+ isStale: boolean;
118
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
119
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
120
+ promise: Promise<import("./products").NadoProduct[]>;
121
+ } | {
122
+ data: import("./products").NadoProduct[];
123
+ error: null;
124
+ isError: false;
125
+ isPending: true;
126
+ isLoadingError: false;
127
+ isRefetchError: false;
128
+ isSuccess: false;
129
+ isPlaceholderData: false;
130
+ status: "pending";
131
+ dataUpdatedAt: number;
132
+ errorUpdatedAt: number;
133
+ failureCount: number;
134
+ failureReason: unknown;
135
+ errorUpdateCount: number;
136
+ isFetched: boolean;
137
+ isFetchedAfterMount: boolean;
138
+ isFetching: boolean;
139
+ isLoading: boolean;
140
+ isInitialLoading: boolean;
141
+ isPaused: boolean;
142
+ isRefetching: boolean;
143
+ isStale: boolean;
144
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
145
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
146
+ promise: Promise<import("./products").NadoProduct[]>;
147
+ } | {
148
+ data: import("./products").NadoProduct[];
149
+ isError: false;
150
+ error: null;
151
+ isPending: false;
152
+ isLoading: false;
153
+ isLoadingError: false;
154
+ isRefetchError: false;
155
+ isSuccess: true;
156
+ isPlaceholderData: true;
157
+ status: "success";
158
+ dataUpdatedAt: number;
159
+ errorUpdatedAt: number;
160
+ failureCount: number;
161
+ failureReason: unknown;
162
+ errorUpdateCount: number;
163
+ isFetched: boolean;
164
+ isFetchedAfterMount: boolean;
165
+ isFetching: boolean;
166
+ isInitialLoading: boolean;
167
+ isPaused: boolean;
168
+ isRefetching: boolean;
169
+ isStale: boolean;
170
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("./products").NadoProduct[], unknown>>;
171
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
172
+ promise: Promise<import("./products").NadoProduct[]>;
173
+ };
174
+ export declare function useNadoSubaccountBalances(subaccount: Hex | undefined): import("@tanstack/react-query").UseQueryResult<import("./gateway").NadoSubaccountInfo, unknown>;
175
+ export declare function useNadoMaxWithdrawable(params: {
176
+ productId: number | undefined;
177
+ sender: Hex | undefined;
178
+ spotLeverage: boolean;
179
+ }): import("@tanstack/react-query").UseQueryResult<string, unknown>;
180
+ export declare function useNadoFeeRates(sender: Hex | undefined): import("@tanstack/react-query").UseQueryResult<import("./gateway").NadoFeeRates, unknown>;
181
+ export interface NadoSettlementStatus {
182
+ /** True once the sequencer has recorded the withdrawal we signed. */
183
+ isSequenced: boolean;
184
+ /** Unix seconds of the sequenced tx, when available. */
185
+ sequencedAt: number | undefined;
186
+ }
187
+ /**
188
+ * Poll the indexer for the withdrawal signed with `nonce` until it appears
189
+ * or the wall-clock timeout passes. `isTimedOut` flips after the cap — show
190
+ * a "still pending, check Nado" state.
191
+ */
192
+ export declare function useNadoSettlementStatus(params: {
193
+ subaccount: Hex | undefined;
194
+ nonce: bigint | undefined;
195
+ /** When the withdrawal was submitted — anchors the timeout. */
196
+ submittedAtMs: number | undefined;
197
+ enabled: boolean;
198
+ }): {
199
+ isTimedOut: boolean;
200
+ data: NadoSettlementStatus;
201
+ error: Error;
202
+ isError: true;
203
+ isPending: false;
204
+ isLoading: false;
205
+ isLoadingError: false;
206
+ isRefetchError: true;
207
+ isSuccess: false;
208
+ isPlaceholderData: false;
209
+ status: "error";
210
+ dataUpdatedAt: number;
211
+ errorUpdatedAt: number;
212
+ failureCount: number;
213
+ failureReason: Error | null;
214
+ errorUpdateCount: number;
215
+ isFetched: boolean;
216
+ isFetchedAfterMount: boolean;
217
+ isFetching: boolean;
218
+ isInitialLoading: boolean;
219
+ isPaused: boolean;
220
+ isRefetching: boolean;
221
+ isStale: boolean;
222
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NadoSettlementStatus, Error>>;
223
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
224
+ promise: Promise<NadoSettlementStatus>;
225
+ } | {
226
+ isTimedOut: boolean;
227
+ data: NadoSettlementStatus;
228
+ error: null;
229
+ isError: false;
230
+ isPending: false;
231
+ isLoading: false;
232
+ isLoadingError: false;
233
+ isRefetchError: false;
234
+ isSuccess: true;
235
+ isPlaceholderData: false;
236
+ status: "success";
237
+ dataUpdatedAt: number;
238
+ errorUpdatedAt: number;
239
+ failureCount: number;
240
+ failureReason: Error | null;
241
+ errorUpdateCount: number;
242
+ isFetched: boolean;
243
+ isFetchedAfterMount: boolean;
244
+ isFetching: boolean;
245
+ isInitialLoading: boolean;
246
+ isPaused: boolean;
247
+ isRefetching: boolean;
248
+ isStale: boolean;
249
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NadoSettlementStatus, Error>>;
250
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
251
+ promise: Promise<NadoSettlementStatus>;
252
+ } | {
253
+ isTimedOut: boolean;
254
+ data: undefined;
255
+ error: Error;
256
+ isError: true;
257
+ isPending: false;
258
+ isLoading: false;
259
+ isLoadingError: true;
260
+ isRefetchError: false;
261
+ isSuccess: false;
262
+ isPlaceholderData: false;
263
+ status: "error";
264
+ dataUpdatedAt: number;
265
+ errorUpdatedAt: number;
266
+ failureCount: number;
267
+ failureReason: Error | null;
268
+ errorUpdateCount: number;
269
+ isFetched: boolean;
270
+ isFetchedAfterMount: boolean;
271
+ isFetching: boolean;
272
+ isInitialLoading: boolean;
273
+ isPaused: boolean;
274
+ isRefetching: boolean;
275
+ isStale: boolean;
276
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NadoSettlementStatus, Error>>;
277
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
278
+ promise: Promise<NadoSettlementStatus>;
279
+ } | {
280
+ isTimedOut: boolean;
281
+ data: undefined;
282
+ error: null;
283
+ isError: false;
284
+ isPending: true;
285
+ isLoading: true;
286
+ isLoadingError: false;
287
+ isRefetchError: false;
288
+ isSuccess: false;
289
+ isPlaceholderData: false;
290
+ status: "pending";
291
+ dataUpdatedAt: number;
292
+ errorUpdatedAt: number;
293
+ failureCount: number;
294
+ failureReason: Error | null;
295
+ errorUpdateCount: number;
296
+ isFetched: boolean;
297
+ isFetchedAfterMount: boolean;
298
+ isFetching: boolean;
299
+ isInitialLoading: boolean;
300
+ isPaused: boolean;
301
+ isRefetching: boolean;
302
+ isStale: boolean;
303
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NadoSettlementStatus, Error>>;
304
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
305
+ promise: Promise<NadoSettlementStatus>;
306
+ } | {
307
+ isTimedOut: boolean;
308
+ data: undefined;
309
+ error: null;
310
+ isError: false;
311
+ isPending: true;
312
+ isLoadingError: false;
313
+ isRefetchError: false;
314
+ isSuccess: false;
315
+ isPlaceholderData: false;
316
+ status: "pending";
317
+ dataUpdatedAt: number;
318
+ errorUpdatedAt: number;
319
+ failureCount: number;
320
+ failureReason: Error | null;
321
+ errorUpdateCount: number;
322
+ isFetched: boolean;
323
+ isFetchedAfterMount: boolean;
324
+ isFetching: boolean;
325
+ isLoading: boolean;
326
+ isInitialLoading: boolean;
327
+ isPaused: boolean;
328
+ isRefetching: boolean;
329
+ isStale: boolean;
330
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NadoSettlementStatus, Error>>;
331
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
332
+ promise: Promise<NadoSettlementStatus>;
333
+ } | {
334
+ isTimedOut: boolean;
335
+ data: NadoSettlementStatus;
336
+ isError: false;
337
+ error: null;
338
+ isPending: false;
339
+ isLoading: false;
340
+ isLoadingError: false;
341
+ isRefetchError: false;
342
+ isSuccess: true;
343
+ isPlaceholderData: true;
344
+ status: "success";
345
+ dataUpdatedAt: number;
346
+ errorUpdatedAt: number;
347
+ failureCount: number;
348
+ failureReason: Error | null;
349
+ errorUpdateCount: number;
350
+ isFetched: boolean;
351
+ isFetchedAfterMount: boolean;
352
+ isFetching: boolean;
353
+ isInitialLoading: boolean;
354
+ isPaused: boolean;
355
+ isRefetching: boolean;
356
+ isStale: boolean;
357
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<NadoSettlementStatus, Error>>;
358
+ fetchStatus: import("@tanstack/react-query").FetchStatus;
359
+ promise: Promise<NadoSettlementStatus>;
360
+ };
@@ -0,0 +1,132 @@
1
+ "use client";
2
+ import {
3
+ NADO_SUPPORTED_PRODUCTS,
4
+ fetchNadoProducts
5
+ } from "../../chunk-A4WQS6QG.js";
6
+ import {
7
+ getNadoFeeRates,
8
+ getNadoMaxWithdrawable,
9
+ getNadoSubaccountInfo
10
+ } from "../../chunk-OZ3KD24N.js";
11
+ import {
12
+ findSettlementForNonce,
13
+ getNadoWithdrawalEvents
14
+ } from "../../chunk-BNMZM23Q.js";
15
+ import "../../chunk-II5CZTBC.js";
16
+ import "../../chunk-L2KSNS7H.js";
17
+ import {
18
+ NadoGatewayError
19
+ } from "../../chunk-2YWQL3AO.js";
20
+ import "../../chunk-FJ6GCMJ4.js";
21
+ import {
22
+ useConfig
23
+ } from "../../chunk-UPZNKPYU.js";
24
+ import {
25
+ logger
26
+ } from "../../chunk-AHYOV7AV.js";
27
+
28
+ // src/clients/internal/nado/hooks.ts
29
+ import { skipToken, useQuery } from "@tanstack/react-query";
30
+ import { useEffect, useReducer } from "react";
31
+ var BALANCES_REFETCH_MS = 3e4;
32
+ var MAX_WITHDRAWABLE_REFETCH_MS = 3e4;
33
+ var FEE_RATES_STALE_MS = 5 * 6e4;
34
+ var SETTLEMENT_POLL_MS = 1e4;
35
+ var SETTLEMENT_TIMEOUT_MS = 10 * 6e4;
36
+ function shouldRetryNadoQuery(failureCount, error) {
37
+ if (error instanceof NadoGatewayError && (error.kind === "api" || error.kind === "timeout" || error.httpStatus === 429)) {
38
+ return false;
39
+ }
40
+ return failureCount < 2;
41
+ }
42
+ function useNadoProducts() {
43
+ const wagmiConfig = useConfig();
44
+ const query = useQuery({
45
+ queryKey: ["nadoProducts"],
46
+ queryFn: ({ signal }) => fetchNadoProducts(wagmiConfig, signal),
47
+ staleTime: Number.POSITIVE_INFINITY,
48
+ gcTime: Number.POSITIVE_INFINITY,
49
+ retry: shouldRetryNadoQuery
50
+ });
51
+ useEffect(() => {
52
+ if (query.isError) {
53
+ logger.warn("nado:products_fallback", {
54
+ message: "gateway_error",
55
+ errorMessage: query.error instanceof Error ? query.error.message : String(query.error)
56
+ });
57
+ }
58
+ }, [query.isError, query.error]);
59
+ return { ...query, data: query.data ?? NADO_SUPPORTED_PRODUCTS };
60
+ }
61
+ function useNadoSubaccountBalances(subaccount) {
62
+ return useQuery({
63
+ queryKey: ["nadoSubaccountInfo", subaccount],
64
+ queryFn: subaccount ? ({ signal }) => getNadoSubaccountInfo(subaccount, signal) : skipToken,
65
+ refetchInterval: BALANCES_REFETCH_MS,
66
+ retry: shouldRetryNadoQuery
67
+ });
68
+ }
69
+ function useNadoMaxWithdrawable(params) {
70
+ const { productId, sender, spotLeverage } = params;
71
+ return useQuery({
72
+ queryKey: ["nadoMaxWithdrawable", sender, productId, spotLeverage],
73
+ queryFn: productId !== void 0 && sender ? ({ signal }) => getNadoMaxWithdrawable({ productId, sender, spotLeverage }, signal) : skipToken,
74
+ refetchInterval: MAX_WITHDRAWABLE_REFETCH_MS,
75
+ retry: shouldRetryNadoQuery
76
+ });
77
+ }
78
+ function useNadoFeeRates(sender) {
79
+ return useQuery({
80
+ queryKey: ["nadoFeeRates", sender],
81
+ queryFn: sender ? ({ signal }) => getNadoFeeRates(sender, signal) : skipToken,
82
+ staleTime: FEE_RATES_STALE_MS,
83
+ retry: shouldRetryNadoQuery
84
+ });
85
+ }
86
+ function useNadoSettlementStatus(params) {
87
+ const { subaccount, nonce, submittedAtMs, enabled } = params;
88
+ const isPastTimeout = () => submittedAtMs !== void 0 && Date.now() - submittedAtMs >= SETTLEMENT_TIMEOUT_MS;
89
+ const query = useQuery({
90
+ queryKey: ["nadoSettlementStatus", subaccount, nonce?.toString()],
91
+ queryFn: subaccount && nonce !== void 0 ? async ({ signal }) => {
92
+ const { txs } = await getNadoWithdrawalEvents(
93
+ { subaccount, limit: 3 },
94
+ signal
95
+ );
96
+ const settlement = findSettlementForNonce(txs, nonce);
97
+ return {
98
+ isSequenced: settlement !== void 0,
99
+ sequencedAt: settlement ? Number(settlement.timestamp) : void 0
100
+ };
101
+ } : skipToken,
102
+ enabled: enabled && submittedAtMs !== void 0,
103
+ // Only the 10s interval drives fetches — a sequenced result is final, so
104
+ // focus/remount refetches would re-ask an answered question
105
+ staleTime: Number.POSITIVE_INFINITY,
106
+ // No retry — the next 10s poll is the retry
107
+ retry: false,
108
+ refetchInterval: (query2) => query2.state.data?.isSequenced || isPastTimeout() ? false : SETTLEMENT_POLL_MS
109
+ });
110
+ const [, rerenderAtTimeout] = useReducer((n) => n + 1, 0);
111
+ useEffect(() => {
112
+ if (submittedAtMs === void 0 || !enabled) {
113
+ return;
114
+ }
115
+ const remainingMs = submittedAtMs + SETTLEMENT_TIMEOUT_MS - Date.now();
116
+ if (remainingMs <= 0) {
117
+ return;
118
+ }
119
+ const id = setTimeout(rerenderAtTimeout, remainingMs);
120
+ return () => clearTimeout(id);
121
+ }, [submittedAtMs, enabled]);
122
+ const isTimedOut = isPastTimeout() && query.data?.isSequenced !== true;
123
+ return { ...query, isTimedOut };
124
+ }
125
+ export {
126
+ shouldRetryNadoQuery,
127
+ useNadoFeeRates,
128
+ useNadoMaxWithdrawable,
129
+ useNadoProducts,
130
+ useNadoSettlementStatus,
131
+ useNadoSubaccountBalances
132
+ };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Nado archive/indexer queries — tracks a submitted withdrawal through
3
+ * sequencing so the UI can show settlement progress.
4
+ *
5
+ * @see {@link https://docs.nado.xyz/developer-resources/api/archive-indexer | Nado archive indexer API}
6
+ */
7
+ import type { Hex } from 'viem';
8
+ interface NadoWithdrawalTxPayload {
9
+ sender: Hex;
10
+ product_id: number;
11
+ /** Raw base units (native decimals). */
12
+ amount: string;
13
+ nonce: number | string;
14
+ }
15
+ export interface NadoIndexerTx {
16
+ tx: {
17
+ withdraw_collateral?: NadoWithdrawalTxPayload;
18
+ withdraw_collateral_v2?: NadoWithdrawalTxPayload;
19
+ };
20
+ submission_idx: string;
21
+ /** Unix seconds. */
22
+ timestamp: string;
23
+ }
24
+ export interface NadoWithdrawalEventsResponse {
25
+ /** Present in the response; settlement matching only reads `txs`. */
26
+ events: unknown[];
27
+ txs: NadoIndexerTx[];
28
+ }
29
+ /**
30
+ * Sequenced withdraw-collateral (v1 + v2) events for a subaccount, newest
31
+ * first. Unlike the gateway, a successful indexer response returns the
32
+ * payload bare — only failures carry the `{status, error}` wrapper.
33
+ */
34
+ export declare function getNadoWithdrawalEvents(params: {
35
+ subaccount: Hex;
36
+ limit?: number;
37
+ }, signal?: AbortSignal): Promise<NadoWithdrawalEventsResponse>;
38
+ /**
39
+ * Find the sequenced tx for a withdrawal we submitted, matched by the signed
40
+ * nonce. Presence means Nado's sequencer accepted it.
41
+ */
42
+ export declare function findSettlementForNonce(txs: NadoIndexerTx[], nonce: bigint): NadoIndexerTx | undefined;
43
+ export {};
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import {
3
+ findSettlementForNonce,
4
+ getNadoWithdrawalEvents
5
+ } from "../../chunk-BNMZM23Q.js";
6
+ import "../../chunk-II5CZTBC.js";
7
+ import "../../chunk-L2KSNS7H.js";
8
+ import "../../chunk-2YWQL3AO.js";
9
+ import "../../chunk-AHYOV7AV.js";
10
+ export {
11
+ findSettlementForNonce,
12
+ getNadoWithdrawalEvents
13
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Withdrawable Nado spot products: live `all_products` ⋈ `symbols` join with
3
+ * a verified static list as fallback.
4
+ *
5
+ * @see {@link https://docs.nado.xyz/developer-resources/api/gateway/queries/all-products | Nado all-products query}
6
+ * @see {@link https://docs.nado.xyz/developer-resources/api/gateway/queries/symbols | Nado symbols query}
7
+ */
8
+ import { type Address } from 'viem';
9
+ import type { Config } from '../../../wagmi/hooks';
10
+ export interface NadoProduct {
11
+ productId: number;
12
+ symbol: string;
13
+ tokenAddress: Address;
14
+ decimals: number;
15
+ isXstock: boolean;
16
+ isTradable: boolean;
17
+ /** Withdraw sequencer fee from the product config, x18 token units. */
18
+ withdrawFeeX18: string;
19
+ }
20
+ /**
21
+ * Xstocks stay out of the source picker until the backend confirms
22
+ * same-token pass-through routing at the UDA. Flip to enable.
23
+ */
24
+ export declare const NADO_XSTOCK_WITHDRAWALS_ENABLED = false;
25
+ /**
26
+ * The withdrawable-product allowlist (membership gates the picker) and the
27
+ * fallback when the gateway is down. Also the symbol source for USDT0,
28
+ * which is absent from the symbols query. Verified against prod 2026-07-16.
29
+ */
30
+ export declare const NADO_SUPPORTED_PRODUCTS: NadoProduct[];
31
+ export declare function isWithdrawableNadoProduct(product: NadoProduct): boolean;
32
+ /**
33
+ * Live product list: `all_products` ⋈ `symbols`, decimals from one multicall.
34
+ * Per-field static fallbacks keep a partial gateway response usable.
35
+ */
36
+ export declare function fetchNadoProducts(wagmiConfig: Config, signal?: AbortSignal): Promise<NadoProduct[]>;
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import {
3
+ NADO_SUPPORTED_PRODUCTS,
4
+ NADO_XSTOCK_WITHDRAWALS_ENABLED,
5
+ fetchNadoProducts,
6
+ isWithdrawableNadoProduct
7
+ } from "../../chunk-A4WQS6QG.js";
8
+ import "../../chunk-OZ3KD24N.js";
9
+ import "../../chunk-II5CZTBC.js";
10
+ import "../../chunk-L2KSNS7H.js";
11
+ import "../../chunk-2YWQL3AO.js";
12
+ import "../../chunk-FJ6GCMJ4.js";
13
+ import "../../chunk-AHYOV7AV.js";
14
+ export {
15
+ NADO_SUPPORTED_PRODUCTS,
16
+ NADO_XSTOCK_WITHDRAWALS_ENABLED,
17
+ fetchNadoProducts,
18
+ isWithdrawableNadoProduct
19
+ };
@@ -0,0 +1,80 @@
1
+ /**
2
+ * EIP-712 typed data for Nado's `withdraw_collateral_v2` execute.
3
+ *
4
+ * @see {@link https://docs.nado.xyz/developer-resources/api/gateway/executes/withdraw-collateral | Nado withdraw collateral execute}
5
+ */
6
+ import type { Address, Hex } from 'viem';
7
+ export declare const WITHDRAW_COLLATERAL_V2_TYPES: {
8
+ readonly WithdrawCollateralV2: readonly [{
9
+ readonly name: "sender";
10
+ readonly type: "bytes32";
11
+ }, {
12
+ readonly name: "productId";
13
+ readonly type: "uint32";
14
+ }, {
15
+ readonly name: "amount";
16
+ readonly type: "uint128";
17
+ }, {
18
+ readonly name: "nonce";
19
+ readonly type: "uint64";
20
+ }, {
21
+ readonly name: "sendTo";
22
+ readonly type: "address";
23
+ }, {
24
+ readonly name: "appendix";
25
+ readonly type: "uint128";
26
+ }];
27
+ };
28
+ export interface WithdrawCollateralV2Params {
29
+ /** Packed subaccount id (see `buildNadoSubaccountId`). */
30
+ sender: Hex;
31
+ productId: number;
32
+ /** Raw base units in the token's native decimals — not x18. */
33
+ amount: bigint;
34
+ /** `tx_nonce` from the nonces query, fetched immediately before signing. */
35
+ nonce: bigint;
36
+ /** Payout recipient. Non-zero forces owner-wallet signing on Nado's side. */
37
+ sendTo: Address;
38
+ }
39
+ /**
40
+ * Typed data for Nado's `withdraw_collateral_v2` execute. `appendix` is
41
+ * reserved by Nado and must be 0.
42
+ */
43
+ export declare function buildWithdrawCollateralV2TypedData(params: WithdrawCollateralV2Params): {
44
+ readonly domain: {
45
+ readonly name: "Nado";
46
+ readonly version: "0.0.1";
47
+ readonly chainId: 57073;
48
+ readonly verifyingContract: `0x${string}`;
49
+ };
50
+ readonly types: {
51
+ readonly WithdrawCollateralV2: readonly [{
52
+ readonly name: "sender";
53
+ readonly type: "bytes32";
54
+ }, {
55
+ readonly name: "productId";
56
+ readonly type: "uint32";
57
+ }, {
58
+ readonly name: "amount";
59
+ readonly type: "uint128";
60
+ }, {
61
+ readonly name: "nonce";
62
+ readonly type: "uint64";
63
+ }, {
64
+ readonly name: "sendTo";
65
+ readonly type: "address";
66
+ }, {
67
+ readonly name: "appendix";
68
+ readonly type: "uint128";
69
+ }];
70
+ };
71
+ readonly primaryType: "WithdrawCollateralV2";
72
+ readonly message: {
73
+ readonly sender: `0x${string}`;
74
+ readonly productId: number;
75
+ readonly amount: bigint;
76
+ readonly nonce: bigint;
77
+ readonly sendTo: `0x${string}`;
78
+ readonly appendix: 0n;
79
+ };
80
+ };