@funkit/connect 10.6.0 → 11.1.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 (86) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/clients/{chunk-F6P4CN27.js → chunk-2QYQNTOI.js} +161 -18
  3. package/dist/clients/chunk-5MY7WMEJ.js +20 -0
  4. package/dist/clients/chunk-63XTVHO3.js +19 -0
  5. package/dist/clients/chunk-6T6URLBM.js +33 -0
  6. package/dist/clients/chunk-A44M6EAG.js +160 -0
  7. package/dist/clients/chunk-A6OXZWCN.js +40 -0
  8. package/dist/clients/chunk-BPDLF2R6.js +31 -0
  9. package/dist/clients/chunk-C53FRCUM.js +190 -0
  10. package/dist/clients/{chunk-6PIIYPQK.js → chunk-EJKHMZW3.js} +4 -327
  11. package/dist/clients/chunk-FAYBQQNB.js +15 -0
  12. package/dist/clients/{chunk-3LJQTM37.js → chunk-FNB7OPJI.js} +12 -198
  13. package/dist/clients/{chunk-2NBYHUIW.js → chunk-HZP4DXIZ.js} +1 -0
  14. package/dist/clients/chunk-NAVU6W7V.js +89 -0
  15. package/dist/clients/{chunk-BNMZM23Q.js → chunk-OJZNF6EM.js} +2 -2
  16. package/dist/clients/{chunk-FJ6GCMJ4.js → chunk-OODIKHYE.js} +3 -1
  17. package/dist/clients/chunk-PENJ5JGH.js +331 -0
  18. package/dist/clients/{chunk-TG2AACP2.js → chunk-QIMCURVA.js} +10 -10
  19. package/dist/clients/{chunk-YFHTV7DT.js → chunk-SH3MHRHX.js} +1 -1
  20. package/dist/clients/chunk-SO756ELD.js +35 -0
  21. package/dist/clients/chunk-SYFHMTUO.js +106 -0
  22. package/dist/clients/chunk-WVM4ZJD2.js +61 -0
  23. package/dist/clients/{chunk-L2KSNS7H.js → chunk-WZRW6WUM.js} +1 -1
  24. package/dist/clients/chunk-YMGRBJAS.js +302 -0
  25. package/dist/clients/chunk-YZSO4EMO.js +44 -0
  26. package/dist/clients/{chunk-2YWQL3AO.js → chunk-Z7HTQFEO.js} +26 -3
  27. package/dist/clients/fanatics.js +6 -6
  28. package/dist/clients/internal/nado/encoding.d.ts +5 -2
  29. package/dist/clients/internal/nado/encoding.js +4 -25
  30. package/dist/clients/internal/nado/errors.d.ts +14 -1
  31. package/dist/clients/internal/nado/errors.js +7 -3
  32. package/dist/clients/internal/nado/fetch.js +2 -2
  33. package/dist/clients/internal/nado/gateway.d.ts +19 -41
  34. package/dist/clients/internal/nado/gateway.js +3 -9
  35. package/dist/clients/internal/nado/hooks.d.ts +8 -160
  36. package/dist/clients/internal/nado/hooks.js +13 -124
  37. package/dist/clients/internal/nado/indexer.js +3 -3
  38. package/dist/clients/internal/nado/typedData.js +4 -37
  39. package/dist/clients/internal/nado/withdrawalCallback.d.ts +20 -0
  40. package/dist/clients/internal/nado/withdrawalCallback.js +20 -0
  41. package/dist/clients/internal/nado/withdrawalConfig.d.ts +8 -3
  42. package/dist/clients/internal/nado/withdrawalConfig.js +8 -14
  43. package/dist/clients/internal/nado/withdrawalErrors.d.ts +14 -0
  44. package/dist/clients/internal/nado/withdrawalErrors.js +11 -0
  45. package/dist/clients/internal/nado/withdrawalForm.css +17529 -0
  46. package/dist/clients/internal/nado/withdrawalForm.d.ts +40 -0
  47. package/dist/clients/internal/nado/withdrawalForm.js +262 -0
  48. package/dist/clients/internal/nado/withdrawalStatus.d.ts +41 -0
  49. package/dist/clients/internal/nado/withdrawalStatus.js +231 -0
  50. package/dist/clients/internal/nado/withdrawalTypes.d.ts +28 -9
  51. package/dist/clients/lighter.css +18 -18
  52. package/dist/clients/lighter.d.ts +29 -1
  53. package/dist/clients/lighter.js +109 -100
  54. package/dist/clients/mallard.js +27 -5
  55. package/dist/clients/nado.d.ts +67 -0
  56. package/dist/clients/nado.js +73 -0
  57. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +60 -60
  58. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +11 -5
  59. package/dist/clients/polymarket/createPolymarketDepositConfig.js +3 -2
  60. package/dist/clients/polymarket/index.css +60 -60
  61. package/dist/clients/polymarket/index.js +11 -5
  62. package/dist/clients/polymarket/polymarket.js +2 -1
  63. package/dist/consts/customers.d.ts +1 -1
  64. package/dist/domains/swapped.d.ts +1 -10
  65. package/dist/hooks/track/analytics/events.d.ts +57 -0
  66. package/dist/hooks/track/analytics/mappers.d.ts +6 -0
  67. package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +20 -0
  68. package/dist/hooks/track/useTrack.d.ts +2 -1
  69. package/dist/hooks/useTokenAndChainDropdown.d.ts +8 -1
  70. package/dist/index.d.ts +1 -1
  71. package/dist/index.js +3647 -2728
  72. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +20 -31
  73. package/dist/modals/WithdrawalModal/NadoWithdrawalSuccess.d.ts +20 -0
  74. package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +5 -9
  75. package/dist/providers/FunkitCheckoutContext/types.d.ts +61 -5
  76. package/dist/providers/GeneralWalletProvider.d.ts +1 -0
  77. package/dist/utils/customer.d.ts +349 -0
  78. package/dist/utils/withdrawal.d.ts +13 -6
  79. package/dist/wagmi/actions.d.ts +1 -1
  80. package/dist/wallets/Wallet.d.ts +21 -1
  81. package/dist/wallets/walletConnectors/index.js +43 -43
  82. package/package.json +4 -4
  83. package/dist/clients/chunk-A4WQS6QG.js +0 -207
  84. package/dist/clients/chunk-OZ3KD24N.js +0 -107
  85. package/dist/clients/internal/nado/products.d.ts +0 -36
  86. package/dist/clients/internal/nado/products.js +0 -19
@@ -1,6 +1,6 @@
1
1
  import type { WalletConnectParameters } from '../wagmi/connectors';
2
2
  import type { Connector, CreateConnectorFn } from '../wagmi/hooks';
3
- import type { TransactionReceipt } from 'viem';
3
+ import type { TransactionReceipt, TypedDataDomain } from 'viem';
4
4
  import type { CoinbaseWalletOptions } from './walletConnectors/coinbaseWallet/coinbaseWallet';
5
5
  import type { WalletConnectWalletOptions } from './walletConnectors/walletConnectWallet/walletConnectWallet';
6
6
  export type InstructionStepName = 'install' | 'create' | 'scan' | 'connect' | 'refresh';
@@ -104,6 +104,16 @@ export type WithdrawalTransaction = {
104
104
  data: string;
105
105
  value: string;
106
106
  };
107
+ /** EIP-712 payload passed to {@link WithdrawalClient.signTypedData}. */
108
+ export type WithdrawalTypedData = {
109
+ domain: TypedDataDomain;
110
+ types: Record<string, readonly {
111
+ name: string;
112
+ type: string;
113
+ }[]>;
114
+ primaryType: string;
115
+ message: Record<string, unknown>;
116
+ };
107
117
  export interface WithdrawalClient {
108
118
  getChainId: () => Promise<number>;
109
119
  switchChain: (chainId: number) => Promise<void>;
@@ -121,6 +131,16 @@ export interface WithdrawalClient {
121
131
  sendTransactions?: (chainId: number, transactions: WithdrawalTransaction[]) => Promise<string>;
122
132
  confirmTransaction: (txHash: string, chainId: number) => Promise<TransactionReceipt>;
123
133
  address: () => string;
134
+ /**
135
+ * Optional signers for gasless relay routes (permit / EIP-3009), where Relay
136
+ * returns a signature step instead of a transaction. Implemented by
137
+ * connected-wallet clients (see `clients/mallard.tsx`).
138
+ */
139
+ signTypedData?: (typedData: WithdrawalTypedData) => Promise<string>;
140
+ /** 32-byte hashes arrive as `{ raw }` — sign as raw bytes. */
141
+ signMessage?: (message: string | {
142
+ raw: string;
143
+ }) => Promise<string>;
124
144
  }
125
145
  /**
126
146
  * WithdrawalClient variant for Lighter (LVM). Satisfies WithdrawalClient for
@@ -5,9 +5,6 @@ import {
5
5
  import {
6
6
  zerionWallet
7
7
  } from "./chunk-SWFF3TWJ.js";
8
- import {
9
- tahoWallet
10
- } from "./chunk-7ZYCBDQ4.js";
11
8
  import {
12
9
  talismanWallet
13
10
  } from "./chunk-4DCO3TGL.js";
@@ -17,6 +14,9 @@ import {
17
14
  import {
18
15
  tokenaryWallet
19
16
  } from "./chunk-VH3THHJY.js";
17
+ import {
18
+ oneKeyWallet
19
+ } from "./chunk-WVT6BBJH.js";
20
20
  import {
21
21
  trustWallet
22
22
  } from "./chunk-KCRO2AGO.js";
@@ -29,21 +29,15 @@ import {
29
29
  import {
30
30
  xdefiWallet
31
31
  } from "./chunk-JN5I3DNC.js";
32
- import {
33
- rabbyWallet
34
- } from "./chunk-RB66PKPA.js";
35
- import {
36
- rainbowWallet
37
- } from "./chunk-W2LCLDPX.js";
38
- import {
39
- ramperWallet
40
- } from "./chunk-OQB55QXP.js";
41
32
  import {
42
33
  roninWallet
43
34
  } from "./chunk-YQFGVZGR.js";
44
35
  import {
45
36
  safeWallet
46
37
  } from "./chunk-RCY66YHF.js";
38
+ import {
39
+ okxWallet
40
+ } from "./chunk-KI5Y2BBF.js";
47
41
  import {
48
42
  safeheronWallet
49
43
  } from "./chunk-76S7R2ND.js";
@@ -57,14 +51,11 @@ import {
57
51
  metaMaskWallet
58
52
  } from "./chunk-YO2K4MBH.js";
59
53
  import {
60
- mewWallet
61
- } from "./chunk-MQM45ADF.js";
54
+ tahoWallet
55
+ } from "./chunk-7ZYCBDQ4.js";
62
56
  import {
63
57
  oktoWallet
64
58
  } from "./chunk-YWOVAU6O.js";
65
- import {
66
- okxWallet
67
- } from "./chunk-KI5Y2BBF.js";
68
59
  import {
69
60
  omniWallet
70
61
  } from "./chunk-2CX7LX4J.js";
@@ -72,38 +63,47 @@ import {
72
63
  oneInchWallet
73
64
  } from "./chunk-QG6ZHI7B.js";
74
65
  import {
75
- oneKeyWallet
76
- } from "./chunk-WVT6BBJH.js";
66
+ ledgerWallet
67
+ } from "./chunk-RPV27V2Y.js";
77
68
  import {
78
69
  phantomWallet
79
70
  } from "./chunk-QY53O7WG.js";
80
71
  import {
81
- enkryptWallet
82
- } from "./chunk-HBQK5RD5.js";
72
+ rabbyWallet
73
+ } from "./chunk-RB66PKPA.js";
83
74
  import {
84
- frontierWallet
85
- } from "./chunk-AVDUNQUW.js";
75
+ rainbowWallet
76
+ } from "./chunk-W2LCLDPX.js";
77
+ import {
78
+ ramperWallet
79
+ } from "./chunk-OQB55QXP.js";
80
+ import {
81
+ foxWallet
82
+ } from "./chunk-GUQM4QSL.js";
86
83
  import {
87
84
  frameWallet
88
85
  } from "./chunk-BU3ZAT5X.js";
89
86
  import {
90
87
  gateWallet
91
88
  } from "./chunk-JPN6TWIT.js";
89
+ import {
90
+ frontierWallet
91
+ } from "./chunk-AVDUNQUW.js";
92
92
  import {
93
93
  imTokenWallet
94
94
  } from "./chunk-WNAGGFMG.js";
95
- import {
96
- injectedWallet
97
- } from "./chunk-T6LGKC3F.js";
98
95
  import {
99
96
  kresusWallet
100
97
  } from "./chunk-RICTB3FA.js";
101
98
  import {
102
- ledgerWallet
103
- } from "./chunk-RPV27V2Y.js";
99
+ mewWallet
100
+ } from "./chunk-MQM45ADF.js";
104
101
  import {
105
- bybitWallet
106
- } from "./chunk-OX37G4YT.js";
102
+ injectedWallet
103
+ } from "./chunk-T6LGKC3F.js";
104
+ import {
105
+ bloomWallet
106
+ } from "./chunk-PJ7Y57EH.js";
107
107
  import {
108
108
  clvWallet
109
109
  } from "./chunk-OEEGYENV.js";
@@ -116,37 +116,37 @@ import {
116
116
  import {
117
117
  coreWallet
118
118
  } from "./chunk-4NV5BYRP.js";
119
+ import {
120
+ dawnWallet
121
+ } from "./chunk-G2PHTVL6.js";
119
122
  import {
120
123
  desigWallet
121
124
  } from "./chunk-FW3WZETT.js";
122
125
  import {
123
- dawnWallet
124
- } from "./chunk-G2PHTVL6.js";
126
+ enkryptWallet
127
+ } from "./chunk-HBQK5RD5.js";
125
128
  import {
126
- foxWallet
127
- } from "./chunk-GUQM4QSL.js";
129
+ bifrostWallet
130
+ } from "./chunk-IULPZP2Q.js";
128
131
  import {
129
132
  argentWallet
130
133
  } from "./chunk-NTMBEOR2.js";
131
- import {
132
- bitgetWallet
133
- } from "./chunk-TKB2OY6G.js";
134
134
  import {
135
135
  bitskiWallet
136
136
  } from "./chunk-7HRFUZFX.js";
137
137
  import {
138
- bifrostWallet
139
- } from "./chunk-IULPZP2Q.js";
138
+ bitgetWallet
139
+ } from "./chunk-TKB2OY6G.js";
140
140
  import {
141
141
  bitverseWallet
142
142
  } from "./chunk-NSK6A7TI.js";
143
- import {
144
- bloomWallet
145
- } from "./chunk-PJ7Y57EH.js";
146
- import "./chunk-N4IJLYFY.js";
147
143
  import {
148
144
  braveWallet
149
145
  } from "./chunk-DS73TZ6O.js";
146
+ import {
147
+ bybitWallet
148
+ } from "./chunk-OX37G4YT.js";
149
+ import "./chunk-N4IJLYFY.js";
150
150
  import "./chunk-OLZ7626J.js";
151
151
  import "./chunk-IGKXZBTA.js";
152
152
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funkit/connect",
3
- "version": "10.6.0",
3
+ "version": "11.1.0",
4
4
  "description": "Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.",
5
5
  "files": [
6
6
  "dist",
@@ -108,9 +108,9 @@
108
108
  "use-debounce": "^10.0.5",
109
109
  "uuid": "^11.1.1",
110
110
  "@funkit/api-base": "6.0.0",
111
- "@funkit/connect-core": "2.3.0",
112
- "@funkit/chains": "2.1.3",
113
- "@funkit/fun-relay": "2.9.0",
111
+ "@funkit/chains": "2.2.0",
112
+ "@funkit/connect-core": "2.4.1",
113
+ "@funkit/fun-relay": "2.10.0",
114
114
  "@funkit/utils": "4.0.0"
115
115
  },
116
116
  "repository": {
@@ -1,207 +0,0 @@
1
- "use client";
2
- import {
3
- getNadoAllProducts,
4
- getNadoSymbols
5
- } from "./chunk-OZ3KD24N.js";
6
- import {
7
- INK_CHAIN_ID
8
- } from "./chunk-II5CZTBC.js";
9
- import {
10
- multicall
11
- } from "./chunk-FJ6GCMJ4.js";
12
- import {
13
- logger
14
- } from "./chunk-AHYOV7AV.js";
15
-
16
- // src/clients/internal/nado/products.ts
17
- import { erc20Abi, getAddress, isAddress } from "viem";
18
- var NADO_XSTOCK_WITHDRAWALS_ENABLED = false;
19
- var XSTOCK_SYMBOL_PATTERN = /^w\w+x$/;
20
- var NADO_SUPPORTED_PRODUCTS = [
21
- {
22
- productId: 0,
23
- symbol: "USDT0",
24
- tokenAddress: getAddress("0x0200C29006150606B650577BBE7B6248F58470c1"),
25
- decimals: 6,
26
- isXstock: false,
27
- isTradable: true,
28
- withdrawFeeX18: "1000000000000000000"
29
- },
30
- {
31
- productId: 1,
32
- symbol: "KBTC",
33
- tokenAddress: getAddress("0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98"),
34
- decimals: 8,
35
- isXstock: false,
36
- isTradable: true,
37
- withdrawFeeX18: "10000000000000"
38
- },
39
- {
40
- productId: 3,
41
- symbol: "WETH",
42
- tokenAddress: getAddress("0x4200000000000000000000000000000000000006"),
43
- decimals: 18,
44
- isXstock: false,
45
- isTradable: true,
46
- withdrawFeeX18: "300000000000000"
47
- },
48
- {
49
- productId: 5,
50
- symbol: "USDC",
51
- tokenAddress: getAddress("0x2D270e6886d130D724215A266106e6832161EAEd"),
52
- decimals: 6,
53
- isXstock: false,
54
- isTradable: true,
55
- withdrawFeeX18: "1000000000000000000"
56
- },
57
- {
58
- productId: 115,
59
- symbol: "wQQQx",
60
- tokenAddress: getAddress("0x4C1AE29c159838fC1b224636E28E086EB69101f7"),
61
- decimals: 18,
62
- isXstock: true,
63
- isTradable: true,
64
- withdrawFeeX18: "2000000000000000"
65
- },
66
- {
67
- productId: 117,
68
- symbol: "wSPYx",
69
- tokenAddress: getAddress("0xe7e553cd128f0011777323a0b44a7b96ea1cb540"),
70
- decimals: 18,
71
- isXstock: true,
72
- isTradable: true,
73
- withdrawFeeX18: "2000000000000000"
74
- },
75
- {
76
- productId: 143,
77
- symbol: "wAAPLx",
78
- tokenAddress: getAddress("0x943bf64d566c32a2bcd41ac92fb63c111cc9de8f"),
79
- decimals: 18,
80
- isXstock: true,
81
- isTradable: true,
82
- withdrawFeeX18: "2000000000000000"
83
- },
84
- {
85
- productId: 145,
86
- symbol: "wAMZNx",
87
- tokenAddress: getAddress("0x910cabde3eba7fc1ce64fd14bd680b9f60fa0f90"),
88
- decimals: 18,
89
- isXstock: true,
90
- isTradable: false,
91
- withdrawFeeX18: "2000000000000000"
92
- },
93
- {
94
- productId: 147,
95
- symbol: "wGOOGLx",
96
- tokenAddress: getAddress("0xf8c5308f80e459bb53d9ebe689854d9cbb2caa6f"),
97
- decimals: 18,
98
- isXstock: true,
99
- isTradable: true,
100
- withdrawFeeX18: "2000000000000000"
101
- },
102
- {
103
- productId: 149,
104
- symbol: "wMETAx",
105
- tokenAddress: getAddress("0xe840946ffebcd66b7c4e95095effafadfa0d0e56"),
106
- decimals: 18,
107
- isXstock: true,
108
- isTradable: true,
109
- withdrawFeeX18: "2000000000000000"
110
- },
111
- {
112
- productId: 151,
113
- symbol: "wMSFTx",
114
- tokenAddress: getAddress("0x166fbe68274b6a47e025f4ba17388c539f1fa1d0"),
115
- decimals: 18,
116
- isXstock: true,
117
- isTradable: false,
118
- withdrawFeeX18: "2000000000000000"
119
- },
120
- {
121
- productId: 153,
122
- symbol: "wNVDAx",
123
- tokenAddress: getAddress("0xa8ddb5cd96b5222afe198316e9a57caa642850d5"),
124
- decimals: 18,
125
- isXstock: true,
126
- isTradable: true,
127
- withdrawFeeX18: "2000000000000000"
128
- },
129
- {
130
- productId: 155,
131
- symbol: "wTSLAx",
132
- tokenAddress: getAddress("0xc3FdBe3A68EE5dE461D30415a8165cf9Aefe1171"),
133
- decimals: 18,
134
- isXstock: true,
135
- isTradable: true,
136
- withdrawFeeX18: "2000000000000000"
137
- }
138
- ];
139
- var SUPPORTED_BY_PRODUCT_ID = new Map(
140
- NADO_SUPPORTED_PRODUCTS.map((p) => [p.productId, p])
141
- );
142
- function isWithdrawableNadoProduct(product) {
143
- return !product.isXstock || NADO_XSTOCK_WITHDRAWALS_ENABLED;
144
- }
145
- async function fetchNadoProducts(wagmiConfig, signal) {
146
- const [{ spot_products }, { symbols }] = await Promise.all([
147
- getNadoAllProducts(signal),
148
- getNadoSymbols(signal)
149
- ]);
150
- const symbolByProductId = new Map(
151
- Object.values(symbols).filter((s) => s.type === "spot").map((s) => [s.product_id, s])
152
- );
153
- const supported = spot_products.flatMap((product) => {
154
- const fallback = SUPPORTED_BY_PRODUCT_ID.get(product.product_id);
155
- if (!fallback) {
156
- return [];
157
- }
158
- if (!isAddress(product.config.token)) {
159
- logger.warn("nado:products_invalid_token", {
160
- productId: product.product_id,
161
- token: product.config.token
162
- });
163
- return [];
164
- }
165
- return [{ product, fallback }];
166
- });
167
- if (supported.length === 0) {
168
- logger.warn("nado:products_fallback", { message: "empty_join" });
169
- return NADO_SUPPORTED_PRODUCTS;
170
- }
171
- const decimalResults = await multicall(wagmiConfig, {
172
- chainId: INK_CHAIN_ID,
173
- allowFailure: true,
174
- contracts: supported.map(({ product }) => ({
175
- address: getAddress(product.config.token),
176
- abi: erc20Abi,
177
- functionName: "decimals"
178
- }))
179
- }).catch((error) => {
180
- logger.warn("nado:products_decimals_multicall_failed", {
181
- errorMessage: error instanceof Error ? error.message : String(error)
182
- });
183
- return void 0;
184
- });
185
- return supported.map(({ product, fallback }, i) => {
186
- const symbolInfo = symbolByProductId.get(product.product_id);
187
- const decimals = decimalResults?.[i];
188
- return {
189
- productId: product.product_id,
190
- symbol: symbolInfo?.symbol ?? fallback.symbol,
191
- tokenAddress: getAddress(product.config.token),
192
- decimals: decimals?.status === "success" ? decimals.result : fallback.decimals,
193
- isXstock: symbolInfo ? XSTOCK_SYMBOL_PATTERN.test(symbolInfo.symbol) : fallback.isXstock,
194
- // Withdrawals don't depend on market status (post_only/soft_reduce_only
195
- // are routine weekend states) — only fully disabled products are out
196
- isTradable: symbolInfo ? symbolInfo.trading_status !== "not_tradable" : fallback.isTradable,
197
- withdrawFeeX18: product.config.withdraw_fee_x18 ?? fallback.withdrawFeeX18
198
- };
199
- });
200
- }
201
-
202
- export {
203
- NADO_XSTOCK_WITHDRAWALS_ENABLED,
204
- NADO_SUPPORTED_PRODUCTS,
205
- isWithdrawableNadoProduct,
206
- fetchNadoProducts
207
- };
@@ -1,107 +0,0 @@
1
- "use client";
2
- import {
3
- NADO_GATEWAY_URL
4
- } from "./chunk-II5CZTBC.js";
5
- import {
6
- nadoFetch
7
- } from "./chunk-L2KSNS7H.js";
8
- import {
9
- NadoGatewayError,
10
- createNadoGatewayError,
11
- isNadoTransportError
12
- } from "./chunk-2YWQL3AO.js";
13
-
14
- // src/clients/internal/nado/gateway.ts
15
- function parseNadoGatewayResponse(response) {
16
- if (response.status !== "success") {
17
- throw createNadoGatewayError(response, "Nado gateway request failed");
18
- }
19
- return response.data;
20
- }
21
- async function nadoQuery(params, signal) {
22
- const response = await nadoFetch({
23
- uri: `${NADO_GATEWAY_URL}/query?${new URLSearchParams(params)}`,
24
- method: "GET",
25
- signal
26
- });
27
- const data = parseNadoGatewayResponse(response);
28
- if (data === void 0) {
29
- throw new NadoGatewayError("Nado returned success without data", {
30
- kind: "api"
31
- });
32
- }
33
- return data;
34
- }
35
- async function getNadoMaxWithdrawable(params, signal) {
36
- const data = await nadoQuery(
37
- {
38
- type: "max_withdrawable",
39
- product_id: params.productId.toString(),
40
- sender: params.sender,
41
- spot_leverage: params.spotLeverage ? "true" : "false"
42
- },
43
- signal
44
- );
45
- return data.max_withdrawable;
46
- }
47
- async function getNadoTxNonce(address) {
48
- const query = () => nadoQuery({ type: "nonces", address });
49
- let data;
50
- try {
51
- data = await query();
52
- } catch (error) {
53
- if (!isNadoTransportError(error)) {
54
- throw error;
55
- }
56
- data = await query();
57
- }
58
- return BigInt(data.tx_nonce);
59
- }
60
- async function getNadoFeeRates(sender, signal) {
61
- return nadoQuery({ type: "fee_rates", sender }, signal);
62
- }
63
- async function getNadoSubaccountInfo(subaccount, signal) {
64
- return nadoQuery(
65
- { type: "subaccount_info", subaccount },
66
- signal
67
- );
68
- }
69
- async function getNadoAllProducts(signal) {
70
- return nadoQuery({ type: "all_products" }, signal);
71
- }
72
- async function getNadoSymbols(signal) {
73
- return nadoQuery({ type: "symbols" }, signal);
74
- }
75
- async function executeNadoWithdrawCollateralV2(params) {
76
- const response = await nadoFetch({
77
- uri: `${NADO_GATEWAY_URL}/execute`,
78
- method: "POST",
79
- body: {
80
- // spot_leverage sits INSIDE the execute object (sibling of tx/signature),
81
- // matching @nadohq's EngineBaseClient — top-level is silently ignored.
82
- withdraw_collateral_v2: {
83
- tx: {
84
- sender: params.sender,
85
- productId: params.productId,
86
- amount: params.amount.toString(),
87
- nonce: params.nonce.toString(),
88
- sendTo: params.sendTo,
89
- appendix: "0"
90
- },
91
- signature: params.signature,
92
- spot_leverage: params.spotLeverage
93
- }
94
- }
95
- });
96
- parseNadoGatewayResponse(response);
97
- }
98
-
99
- export {
100
- getNadoMaxWithdrawable,
101
- getNadoTxNonce,
102
- getNadoFeeRates,
103
- getNadoSubaccountInfo,
104
- getNadoAllProducts,
105
- getNadoSymbols,
106
- executeNadoWithdrawCollateralV2
107
- };
@@ -1,36 +0,0 @@
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[]>;
@@ -1,19 +0,0 @@
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
- };