@agg-build/hooks 2.0.0 → 2.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.
package/dist/deposit.mjs CHANGED
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  useRampQuotes,
3
3
  useRampSession
4
- } from "./chunk-KXO3JOXF.mjs";
4
+ } from "./chunk-QKVR32KC.mjs";
5
5
  import {
6
6
  __async,
7
7
  useAggAuthState,
8
8
  useAggBalanceState,
9
+ useAggClient,
9
10
  useAggUiConfig,
10
11
  useDepositAddresses,
11
12
  useSyncBalances
12
- } from "./chunk-VLYLQSDD.mjs";
13
+ } from "./chunk-V7VCT62L.mjs";
13
14
 
14
15
  // src/deposit/normalize-wallet-error.ts
15
16
  function normalizeWalletError(error, supportedChains) {
@@ -33,13 +34,17 @@ function normalizeWalletError(error, supportedChains) {
33
34
  }
34
35
 
35
36
  // src/deposit/use-wallet-token-balance.ts
36
- import { Connection, PublicKey } from "@solana/web3.js";
37
+ import { PublicKey } from "@solana/web3.js";
37
38
  import { useQuery } from "@tanstack/react-query";
38
39
  import { formatUnits } from "viem";
39
40
  import { useAccount, useReadContract } from "wagmi";
40
41
 
41
42
  // src/deposit/constants.ts
42
- var DEFAULT_SOLANA_RPC_ENDPOINT = "https://solana-rpc.publicnode.com";
43
+ var DEFAULT_SOLANA_RPC_ENDPOINTS = [
44
+ "https://api.mainnet.solana.com",
45
+ "https://solana-rpc.publicnode.com"
46
+ ];
47
+ var DEFAULT_SOLANA_RPC_ENDPOINT = DEFAULT_SOLANA_RPC_ENDPOINTS[0];
43
48
  var SVM_CHAIN_IDS = /* @__PURE__ */ new Set([792703809]);
44
49
  var MULTI_CHAIN_SOLANA_WALLET_NAMES = /* @__PURE__ */ new Set(["Phantom"]);
45
50
 
@@ -71,6 +76,45 @@ function useSvmAddress() {
71
76
  return (_a = adapterPublicKey == null ? void 0 : adapterPublicKey.toBase58()) != null ? _a : phantomAddress;
72
77
  }
73
78
 
79
+ // src/deposit/svm-connections.ts
80
+ import { Connection } from "@solana/web3.js";
81
+ import { useMemo } from "react";
82
+ function resolveSvmRpcEndpoints(partnerUrl) {
83
+ const seen = /* @__PURE__ */ new Set();
84
+ const out = [];
85
+ const candidates = partnerUrl ? [partnerUrl, ...DEFAULT_SOLANA_RPC_ENDPOINTS] : DEFAULT_SOLANA_RPC_ENDPOINTS;
86
+ for (const url of candidates) {
87
+ if (!seen.has(url)) {
88
+ seen.add(url);
89
+ out.push(url);
90
+ }
91
+ }
92
+ return out;
93
+ }
94
+ function useSvmConnections(commitment) {
95
+ const { solanaRpcUrl } = useAggUiConfig();
96
+ return useMemo(() => {
97
+ const endpoints = resolveSvmRpcEndpoints(solanaRpcUrl);
98
+ return endpoints.map((url) => new Connection(url, commitment));
99
+ }, [solanaRpcUrl, commitment]);
100
+ }
101
+ function withSvmFailover(connections, operation) {
102
+ return __async(this, null, function* () {
103
+ if (connections.length === 0) {
104
+ throw new Error("No Solana RPC connections configured");
105
+ }
106
+ let lastError;
107
+ for (const connection of connections) {
108
+ try {
109
+ return yield operation(connection);
110
+ } catch (err) {
111
+ lastError = err;
112
+ }
113
+ }
114
+ throw lastError instanceof Error ? lastError : new Error(typeof lastError === "string" ? lastError : "All Solana RPC endpoints failed");
115
+ });
116
+ }
117
+
74
118
  // src/deposit/use-wallet-token-balance.ts
75
119
  var ERC20_BALANCE_OF_ABI = [
76
120
  {
@@ -104,22 +148,24 @@ function withTimeout(promise, timeoutMs) {
104
148
  );
105
149
  });
106
150
  }
107
- function fetchSvmTokenBalance(rpcUrl, owner, mint) {
151
+ function fetchSvmTokenBalance(connections, owner, mint) {
108
152
  return __async(this, null, function* () {
109
- var _a;
110
- const connection = new Connection(rpcUrl);
111
- const accounts = yield withTimeout(
112
- connection.getTokenAccountsByOwner(owner, { mint }),
113
- SVM_BALANCE_RPC_TIMEOUT_MS
114
- );
115
- if (accounts.value.length === 0) return 0;
116
- const first = accounts.value[0];
117
- if (!first) return 0;
118
- const balance = yield withTimeout(
119
- connection.getTokenAccountBalance(first.pubkey),
120
- SVM_BALANCE_RPC_TIMEOUT_MS
153
+ var _a, _b, _c;
154
+ const accounts = yield withSvmFailover(
155
+ connections,
156
+ (connection) => withTimeout(
157
+ connection.getParsedTokenAccountsByOwner(owner, { mint }),
158
+ SVM_BALANCE_RPC_TIMEOUT_MS
159
+ )
121
160
  );
122
- return (_a = balance.value.uiAmount) != null ? _a : 0;
161
+ let total = 0;
162
+ for (const entry of accounts.value) {
163
+ const uiAmount = (_c = (_b = (_a = entry.account.data.parsed) == null ? void 0 : _a.info) == null ? void 0 : _b.tokenAmount) == null ? void 0 : _c.uiAmount;
164
+ if (typeof uiAmount === "number" && Number.isFinite(uiAmount)) {
165
+ total += uiAmount;
166
+ }
167
+ }
168
+ return total;
123
169
  });
124
170
  }
125
171
  function useWalletTokenBalance({
@@ -130,8 +176,6 @@ function useWalletTokenBalance({
130
176
  svmAddress
131
177
  }) {
132
178
  var _a;
133
- const { solanaRpcUrl } = useAggUiConfig();
134
- const rpcEndpoint = solanaRpcUrl != null ? solanaRpcUrl : DEFAULT_SOLANA_RPC_ENDPOINT;
135
179
  const isSvm = chainId !== void 0 && SVM_CHAIN_IDS.has(chainId);
136
180
  const { address: evmAddress } = useAccount();
137
181
  const evmEnabled = isOpen && !isSvm && !!chainId && !!tokenAddress && !!evmAddress && decimals !== void 0;
@@ -146,6 +190,7 @@ function useWalletTokenBalance({
146
190
  const detectedSvmAddress = useSvmAddress();
147
191
  const resolvedSvmAddress = detectedSvmAddress != null ? detectedSvmAddress : svmAddress;
148
192
  const svmEnabled = isOpen && isSvm && !!resolvedSvmAddress && !!tokenAddress;
193
+ const svmConnections = useSvmConnections();
149
194
  const svmQuery = useQuery({
150
195
  queryKey: ["svm-token-balance", resolvedSvmAddress != null ? resolvedSvmAddress : null, tokenAddress != null ? tokenAddress : null, isOpen],
151
196
  enabled: svmEnabled,
@@ -157,7 +202,7 @@ function useWalletTokenBalance({
157
202
  if (!resolvedSvmAddress || !tokenAddress) return 0;
158
203
  const owner = new PublicKey(resolvedSvmAddress);
159
204
  const mint = new PublicKey(tokenAddress);
160
- return yield fetchSvmTokenBalance(rpcEndpoint, owner, mint);
205
+ return yield fetchSvmTokenBalance(svmConnections, owner, mint);
161
206
  })
162
207
  });
163
208
  if (isSvm) {
@@ -178,7 +223,6 @@ import { parseUnits } from "viem";
178
223
  import { useWriteContract } from "wagmi";
179
224
  import { useWallet as useWallet2 } from "@solana/wallet-adapter-react";
180
225
  import {
181
- Connection as Connection2,
182
226
  Keypair,
183
227
  PublicKey as PublicKey2,
184
228
  SystemProgram,
@@ -204,13 +248,11 @@ var ERC20_TRANSFER_ABI = [
204
248
  }
205
249
  ];
206
250
  function useWalletSendToken() {
207
- const { solanaRpcUrl } = useAggUiConfig();
208
- const rpcEndpoint = solanaRpcUrl != null ? solanaRpcUrl : DEFAULT_SOLANA_RPC_ENDPOINT;
251
+ const svmConnections = useSvmConnections("confirmed");
209
252
  const { writeContractAsync } = useWriteContract();
210
253
  const { publicKey, sendTransaction } = useWallet2();
211
254
  return useCallback(
212
255
  (params) => __async(null, null, function* () {
213
- var _a, _b;
214
256
  const isSvm = SVM_CHAIN_IDS.has(params.chainId);
215
257
  if (!isSvm) {
216
258
  const tokenAddress = params.token.address;
@@ -245,7 +287,6 @@ function useWalletSendToken() {
245
287
  if (!ownerBase58) {
246
288
  throw new Error("No Solana wallet connected");
247
289
  }
248
- const sendConnection = new Connection2(rpcEndpoint, "confirmed");
249
290
  const TOKEN_PROGRAM_ID = new PublicKey2("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
250
291
  const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey2(
251
292
  "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
@@ -262,126 +303,124 @@ function useWalletSendToken() {
262
303
  };
263
304
  const sourceAta = getAta(owner, mint);
264
305
  const destinationAta = getAta(destinationOwner, mint);
265
- const tx = new Transaction();
266
- let destinationTokenAccountSigner = null;
267
- const destinationOwnerInfo = yield sendConnection.getAccountInfo(destinationOwner);
268
- const destinationInfo = yield sendConnection.getAccountInfo(destinationAta);
269
- let destinationTokenAccount = destinationAta;
270
- if (!destinationInfo) {
271
- const rentExemptLamports = yield sendConnection.getMinimumBalanceForRentExemption(165);
272
- const payerLamports = yield sendConnection.getBalance(owner, "confirmed");
273
- const feeBufferLamports = 1e4;
274
- const requiredLamports = rentExemptLamports + feeBufferLamports;
275
- if (payerLamports < requiredLamports) {
276
- const requiredSol = (requiredLamports / 1e9).toFixed(6);
277
- const currentSol = (payerLamports / 1e9).toFixed(6);
278
- throw new Error(
279
- `This Solana deposit needs about ${requiredSol} SOL to create the destination token account, but the connected wallet only has ${currentSol} SOL available.`
280
- );
281
- }
282
- const canCreateAta = (_b = (_a = destinationOwnerInfo == null ? void 0 : destinationOwnerInfo.owner) == null ? void 0 : _a.equals(SystemProgram.programId)) != null ? _b : false;
283
- if (canCreateAta) {
284
- const createIx = new TransactionInstruction({
285
- programId: ASSOCIATED_TOKEN_PROGRAM_ID,
286
- keys: [
287
- { pubkey: owner, isSigner: true, isWritable: true },
288
- { pubkey: destinationAta, isSigner: false, isWritable: true },
289
- { pubkey: destinationOwner, isSigner: false, isWritable: false },
290
- { pubkey: mint, isSigner: false, isWritable: false },
291
- { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
292
- { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }
293
- ],
294
- data: Buffer.alloc(0)
295
- });
296
- tx.add(createIx);
297
- } else {
298
- destinationTokenAccountSigner = Keypair.generate();
299
- destinationTokenAccount = destinationTokenAccountSigner.publicKey;
300
- tx.add(
301
- SystemProgram.createAccount({
302
- fromPubkey: owner,
303
- newAccountPubkey: destinationTokenAccount,
304
- lamports: rentExemptLamports,
305
- space: 165,
306
- programId: TOKEN_PROGRAM_ID
307
- })
308
- );
309
- const initAccountData = Buffer.concat([
310
- Buffer.from([18]),
311
- // InitializeAccount3
312
- destinationOwner.toBuffer()
313
- ]);
314
- tx.add(
315
- new TransactionInstruction({
316
- programId: TOKEN_PROGRAM_ID,
306
+ const signature = yield withSvmFailover(svmConnections, (sendConnection) => __async(null, null, function* () {
307
+ var _a, _b;
308
+ const tx = new Transaction();
309
+ let destinationTokenAccountSigner = null;
310
+ const destinationOwnerInfo = yield sendConnection.getAccountInfo(destinationOwner);
311
+ const destinationInfo = yield sendConnection.getAccountInfo(destinationAta);
312
+ let destinationTokenAccount = destinationAta;
313
+ if (!destinationInfo) {
314
+ const rentExemptLamports = yield sendConnection.getMinimumBalanceForRentExemption(165);
315
+ const payerLamports = yield sendConnection.getBalance(owner, "confirmed");
316
+ const feeBufferLamports = 1e4;
317
+ const requiredLamports = rentExemptLamports + feeBufferLamports;
318
+ if (payerLamports < requiredLamports) {
319
+ const requiredSol = (requiredLamports / 1e9).toFixed(6);
320
+ const currentSol = (payerLamports / 1e9).toFixed(6);
321
+ throw new Error(
322
+ `This Solana deposit needs about ${requiredSol} SOL to create the destination token account, but the connected wallet only has ${currentSol} SOL available.`
323
+ );
324
+ }
325
+ const canCreateAta = (_b = (_a = destinationOwnerInfo == null ? void 0 : destinationOwnerInfo.owner) == null ? void 0 : _a.equals(SystemProgram.programId)) != null ? _b : false;
326
+ if (canCreateAta) {
327
+ const createIx = new TransactionInstruction({
328
+ programId: ASSOCIATED_TOKEN_PROGRAM_ID,
317
329
  keys: [
318
- { pubkey: destinationTokenAccount, isSigner: false, isWritable: true },
319
- { pubkey: mint, isSigner: false, isWritable: false }
330
+ { pubkey: owner, isSigner: true, isWritable: true },
331
+ { pubkey: destinationAta, isSigner: false, isWritable: true },
332
+ { pubkey: destinationOwner, isSigner: false, isWritable: false },
333
+ { pubkey: mint, isSigner: false, isWritable: false },
334
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
335
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }
320
336
  ],
321
- data: initAccountData
322
- })
323
- );
337
+ data: Buffer.alloc(0)
338
+ });
339
+ tx.add(createIx);
340
+ } else {
341
+ destinationTokenAccountSigner = Keypair.generate();
342
+ destinationTokenAccount = destinationTokenAccountSigner.publicKey;
343
+ tx.add(
344
+ SystemProgram.createAccount({
345
+ fromPubkey: owner,
346
+ newAccountPubkey: destinationTokenAccount,
347
+ lamports: rentExemptLamports,
348
+ space: 165,
349
+ programId: TOKEN_PROGRAM_ID
350
+ })
351
+ );
352
+ const initAccountData = Buffer.concat([
353
+ Buffer.from([18]),
354
+ // InitializeAccount3
355
+ destinationOwner.toBuffer()
356
+ ]);
357
+ tx.add(
358
+ new TransactionInstruction({
359
+ programId: TOKEN_PROGRAM_ID,
360
+ keys: [
361
+ { pubkey: destinationTokenAccount, isSigner: false, isWritable: true },
362
+ { pubkey: mint, isSigner: false, isWritable: false }
363
+ ],
364
+ data: initAccountData
365
+ })
366
+ );
367
+ }
368
+ }
369
+ let factor = BigInt(1);
370
+ for (let i = 0; i < params.token.decimals; i += 1) {
371
+ factor *= BigInt(10);
372
+ }
373
+ const amountRaw = BigInt(Math.trunc(Number(params.amount || "0") * Number(factor)));
374
+ const data = new Uint8Array(10);
375
+ data[0] = 12;
376
+ let remaining = amountRaw;
377
+ const mask = BigInt(255);
378
+ for (let i = 0; i < 8; i += 1) {
379
+ data[1 + i] = Number(remaining & mask);
380
+ remaining >>= BigInt(8);
381
+ }
382
+ data[9] = params.token.decimals;
383
+ const transferIx = new TransactionInstruction({
384
+ programId: TOKEN_PROGRAM_ID,
385
+ keys: [
386
+ { pubkey: sourceAta, isSigner: false, isWritable: true },
387
+ { pubkey: mint, isSigner: false, isWritable: false },
388
+ { pubkey: destinationTokenAccount, isSigner: false, isWritable: true },
389
+ { pubkey: owner, isSigner: true, isWritable: false }
390
+ ],
391
+ data: Buffer.from(data)
392
+ });
393
+ tx.add(transferIx);
394
+ tx.feePayer = owner;
395
+ const { blockhash } = yield sendConnection.getLatestBlockhash("confirmed");
396
+ tx.recentBlockhash = blockhash;
397
+ if (destinationTokenAccountSigner) {
398
+ tx.partialSign(destinationTokenAccountSigner);
399
+ }
400
+ if (publicKey && sendTransaction) {
401
+ return yield sendTransaction(tx, sendConnection);
402
+ }
403
+ if (phantom) {
404
+ const res = yield phantom.signAndSendTransaction(tx);
405
+ return res.signature;
324
406
  }
325
- }
326
- let factor = BigInt(1);
327
- for (let i = 0; i < params.token.decimals; i += 1) {
328
- factor *= BigInt(10);
329
- }
330
- const amountRaw = BigInt(Math.trunc(Number(params.amount || "0") * Number(factor)));
331
- const data = new Uint8Array(10);
332
- data[0] = 12;
333
- let remaining = amountRaw;
334
- const mask = BigInt(255);
335
- for (let i = 0; i < 8; i += 1) {
336
- data[1 + i] = Number(remaining & mask);
337
- remaining >>= BigInt(8);
338
- }
339
- data[9] = params.token.decimals;
340
- const transferIx = new TransactionInstruction({
341
- programId: TOKEN_PROGRAM_ID,
342
- keys: [
343
- { pubkey: sourceAta, isSigner: false, isWritable: true },
344
- { pubkey: mint, isSigner: false, isWritable: false },
345
- { pubkey: destinationTokenAccount, isSigner: false, isWritable: true },
346
- { pubkey: owner, isSigner: true, isWritable: false }
347
- ],
348
- data: Buffer.from(data)
349
- });
350
- tx.add(transferIx);
351
- tx.feePayer = owner;
352
- const { blockhash } = yield sendConnection.getLatestBlockhash("confirmed");
353
- tx.recentBlockhash = blockhash;
354
- if (destinationTokenAccountSigner) {
355
- tx.partialSign(destinationTokenAccountSigner);
356
- }
357
- let signature;
358
- if (publicKey && sendTransaction) {
359
- signature = yield sendTransaction(tx, sendConnection);
360
- } else if (phantom) {
361
- const res = yield phantom.signAndSendTransaction(tx);
362
- signature = res.signature;
363
- } else {
364
407
  throw new Error("No Solana signer available");
365
- }
408
+ }));
366
409
  return { txId: signature };
367
410
  }),
368
- [publicKey, rpcEndpoint, sendTransaction, writeContractAsync]
411
+ [publicKey, sendTransaction, svmConnections, writeContractAsync]
369
412
  );
370
413
  }
371
414
 
372
415
  // src/deposit/use-wallet-transaction-status.ts
373
- import { useMemo } from "react";
374
416
  import { useQuery as useQuery2 } from "@tanstack/react-query";
375
417
  import { formatEther } from "viem";
376
- import { Connection as Connection3 } from "@solana/web3.js";
377
418
  import { useWaitForTransactionReceipt } from "wagmi";
378
419
  function useWalletTransactionStatus({
379
420
  chainId,
380
421
  txId
381
422
  }) {
382
423
  var _a;
383
- const { solanaRpcUrl } = useAggUiConfig();
384
- const rpcEndpoint = solanaRpcUrl != null ? solanaRpcUrl : DEFAULT_SOLANA_RPC_ENDPOINT;
385
424
  const isSvm = chainId !== void 0 && SVM_CHAIN_IDS.has(chainId);
386
425
  const evmHash = !isSvm && txId ? txId : void 0;
387
426
  const evmReceipt = useWaitForTransactionReceipt({
@@ -392,14 +431,17 @@ function useWalletTransactionStatus({
392
431
  refetchInterval: 2e3
393
432
  }
394
433
  });
395
- const connection = useMemo(() => new Connection3(rpcEndpoint, "confirmed"), [rpcEndpoint]);
434
+ const svmConnections = useSvmConnections("confirmed");
396
435
  const svmQuery = useQuery2({
397
436
  queryKey: ["wallet-transaction-status", chainId != null ? chainId : null, txId != null ? txId : null],
398
437
  enabled: isSvm && !!txId,
399
438
  refetchInterval: (query) => query.state.data === "settled" || query.state.data === "error" ? false : 2e3,
400
439
  queryFn: () => __async(null, null, function* () {
401
440
  if (!txId) return "submitted";
402
- const [status] = (yield connection.getSignatureStatuses([txId], { searchTransactionHistory: true })).value;
441
+ const [status] = (yield withSvmFailover(
442
+ svmConnections,
443
+ (connection) => connection.getSignatureStatuses([txId], { searchTransactionHistory: true })
444
+ )).value;
403
445
  if (!status) return "submitted";
404
446
  if (status.err) return "error";
405
447
  if (status.confirmationStatus === "confirmed" || status.confirmationStatus === "finalized") {
@@ -436,6 +478,7 @@ var DEFAULT_WALLET_TOKEN_SYMBOL = "USDC";
436
478
  function useDepositFlow(options) {
437
479
  var _a, _b, _c;
438
480
  const { open, onOpenChange } = options;
481
+ const client = useAggClient();
439
482
  const { user } = useAggAuthState();
440
483
  const { walletActions } = useAggUiConfig();
441
484
  const { totalBalance } = useAggBalanceState();
@@ -575,6 +618,8 @@ function useDepositFlow(options) {
575
618
  amount
576
619
  });
577
620
  setWalletTransaction({ chainId, txId });
621
+ void client.recordDepositIntent({ chainId, txHash: txId }).catch(() => {
622
+ });
578
623
  } catch (err) {
579
624
  setWalletTransaction(null);
580
625
  const normalizedError = normalizeWalletError(err, supportedChains);
@@ -583,7 +628,7 @@ function useDepositFlow(options) {
583
628
  throw err;
584
629
  }
585
630
  }),
586
- [connectedChainId, sendToken, supportedChains, switchChainAsync]
631
+ [client, connectedChainId, sendToken, supportedChains, switchChainAsync]
587
632
  );
588
633
  const handleGetCardQuotes = useCallback2(
589
634
  (params) => __async(null, null, function* () {
package/dist/index.d.mts CHANGED
@@ -5,7 +5,7 @@ import * as _agg_build_sdk from '@agg-build/sdk';
5
5
  import { CandleBuilder, AggAuthStartBody, AggAuthStartResult, AggClientSessionInput, AggClient, RampQuote, RampQuoteRequest, RampWidgetSession, RampSessionRequest, QuoteManagedResponse, QuoteManagedParams, ExecuteManagedResponse, ExecuteManagedParams, GetPositionsParams, WsOrderSubmitted, WsBalanceUpdate, RedeemResponse, RedeemRequest, WsRedeemEvent, AggWebSocket, WsOrderEvent, WsWithdrawalLifecycleEvent, WsCandleInterval, WsTrade, AggregatedOrderbookResponse, AggLinkAccountBody, AggLinkAccountResult, AggLinkAccountConfirmResult, Category, UserActivityQuery, UserActivityItem, PaginatedResponse, CandleInterval, OrderbookState, OrderbookQuoteResponse, OrderListQuery, TradeExecutorOrder, SmartRouteSide, ExecutionMode, SmartRouteResponse, RecurrenceFilter, MidpointRow, BatchMidpointsResponse, AppClientConfigResponse } from '@agg-build/sdk';
6
6
  export { TurnstileChallengeError } from '@agg-build/sdk';
7
7
  import React, { ReactNode } from 'react';
8
- export { UseManagedBalancesOptions, UseWithdrawEstimateParams, UseWithdrawFlowOptions, UseWithdrawFlowResult, UseWithdrawManagedOptions, UseWithdrawalLifecycleResult, WithdrawFeeEstimate, WithdrawalLifecycleState, useManagedBalances, useWithdrawEstimate, useWithdrawFlow, useWithdrawManaged, useWithdrawalLifecycle } from './withdraw.mjs';
8
+ export { UseManagedBalancesOptions, UseWithdrawEstimateParams, UseWithdrawFlowOptions, UseWithdrawFlowResult, UseWithdrawManagedOptions, UseWithdrawPreviewParams, UseWithdrawalLifecycleResult, WithdrawFeeEstimate, WithdrawalLifecycleState, useManagedBalances, useWithdrawEstimate, useWithdrawFlow, useWithdrawManaged, useWithdrawPreview, useWithdrawalLifecycle } from './withdraw.mjs';
9
9
  export { U as UseDepositAddressesOptions, g as getDepositAddress, u as useDepositAddresses } from './use-deposit-addresses-B9ICS-3U.mjs';
10
10
  export { U as UseSyncBalancesOptions, u as useSyncBalances } from './use-sync-balances-CeD8qZWP.mjs';
11
11
 
@@ -313,6 +313,8 @@ type VenueEvent = {
313
313
  displayName: string | null;
314
314
  parentId: string | null;
315
315
  eventCount: number;
316
+ volume24hr: number;
317
+ volume: number;
316
318
  };
317
319
  }[];
318
320
  status?: MarketStatus | undefined;
@@ -433,6 +435,8 @@ interface AggUiLabels {
433
435
  errorPrefix: string;
434
436
  tabsAria: string;
435
437
  hiddenTabsAria: string;
438
+ scrollTabsLeft: string;
439
+ scrollTabsRight: string;
436
440
  selectAria: string;
437
441
  lineChartAria: string;
438
442
  candlestickChartAria: string;
@@ -586,6 +590,7 @@ interface AggUiLabels {
586
590
  networkReserveTooltipLineTwo: string;
587
591
  youReceive: string;
588
592
  confirm: string;
593
+ calculatingFees: string;
589
594
  successTitle: string;
590
595
  successDescription: (tokenSymbol: string) => string;
591
596
  successTitleCompleted: string;
@@ -1041,6 +1046,9 @@ interface AggUiLabels {
1041
1046
  buyingOutcome: (label: string) => string;
1042
1047
  sellingOutcome: (label: string) => string;
1043
1048
  findingBestRoute: string;
1049
+ findingBestOdds: string;
1050
+ updatingRoute: string;
1051
+ refreshingQuotes: string;
1044
1052
  checkingBalance: string;
1045
1053
  submittingOrderProgress: string;
1046
1054
  orderSubmittedProgress: (orderId: string) => string;
@@ -1321,6 +1329,11 @@ type AggUiFeatureFlagsConfigInput = Partial<AggUiFeatureFlagsConfig>;
1321
1329
  interface AggUiMarketConfig {
1322
1330
  /** Arbitrage threshold for the UI */
1323
1331
  arbitrageThreshold: number;
1332
+ /**
1333
+ * Maximum venue market IDs sent in each REST `/midpoints` request.
1334
+ * Lower this when proxy/CDN URL limits are stricter than AGG's backend cap.
1335
+ */
1336
+ maxMidpointIdsPerRequest: number;
1324
1337
  }
1325
1338
  type AggUiMarketConfigInput = Partial<AggUiMarketConfig>;
1326
1339
  interface AggUiChartConfig {
@@ -3359,6 +3372,9 @@ declare function mergeBestPricesPreferringLive(rest: ReadonlyMap<string, {
3359
3372
  */
3360
3373
  declare function useLiveTrades(canonicalMarketId: string | null): WsTrade[];
3361
3374
 
3375
+ interface UseMidpointsOptions {
3376
+ maxMidpointIdsPerRequest?: number;
3377
+ }
3362
3378
  interface UseMidpointsResult {
3363
3379
  /** Map of outcomeId → price. Empty while loading. */
3364
3380
  prices: Map<string, number>;
@@ -3419,7 +3435,7 @@ interface UseMidpointsResult {
3419
3435
  * sides because MVMO links same-side counterparts regardless of label
3420
3436
  * inversion. No label heuristics; no `1 - midpoint` flips.
3421
3437
  */
3422
- declare function useMidpoints(venueMarkets: VenueMarket[] | null | undefined): UseMidpointsResult;
3438
+ declare function useMidpoints(venueMarkets: VenueMarket[] | null | undefined, options?: UseMidpointsOptions): UseMidpointsResult;
3423
3439
 
3424
3440
  interface UseTradableVenuesResult {
3425
3441
  /**
@@ -4056,12 +4072,21 @@ interface UseSmartRouteOptions {
4056
4072
  /** Cache freshness and polling interval in milliseconds. Defaults to SMART_ROUTE_STALE_TIME_MS. */
4057
4073
  staleTimeMs?: number;
4058
4074
  }
4075
+ /**
4076
+ * Why the smart route query is currently loading.
4077
+ * - `"finding-best-odds"` — first fetch, no prior data in cache
4078
+ * - `"updating-route"` — query key changed (e.g. amount changed), placeholder data shown
4079
+ * - `"refreshing-quotes"` — background poll/revalidation with existing data
4080
+ */
4081
+ type SmartRouteLoadingReason = "finding-best-odds" | "updating-route" | "refreshing-quotes";
4059
4082
  interface UseSmartRouteResult {
4060
4083
  data: SmartRouteResponse | null;
4061
4084
  isLoading: boolean;
4062
4085
  isFetching: boolean;
4063
4086
  error: Error | null;
4064
4087
  refetch: () => Promise<unknown>;
4088
+ /** Null when not loading. See {@link SmartRouteLoadingReason}. */
4089
+ loadingReason: SmartRouteLoadingReason | null;
4065
4090
  }
4066
4091
  /**
4067
4092
  * Compute optimal order routing across venues via the MILP solver.
@@ -5176,6 +5201,7 @@ declare function useVenueMarkets(options?: UseVenueMarketsOptions): {
5176
5201
  interface UseVenueMarketMidpointsOptions {
5177
5202
  venueMarketIds: string[];
5178
5203
  enabled?: boolean;
5204
+ maxMidpointIdsPerRequest?: number;
5179
5205
  }
5180
5206
  declare function useVenueMarketMidpoints(options: UseVenueMarketMidpointsOptions): {
5181
5207
  midpointRows: (MidpointRow & {
@@ -5405,7 +5431,10 @@ declare const computePriceGaps: ({ markets, midpointsByVenueMarketId, }: Compute
5405
5431
  * outcome — semantically correct for both Yes and No sides because MVMO
5406
5432
  * links same-side counterparts regardless of label inversion.
5407
5433
  */
5408
- declare function useViewportMidpoints(visibleMarkets: VenueMarket[]): {
5434
+ interface UseViewportMidpointsOptions {
5435
+ maxMidpointIdsPerRequest?: number;
5436
+ }
5437
+ declare function useViewportMidpoints(visibleMarkets: VenueMarket[], options?: UseViewportMidpointsOptions): {
5409
5438
  prices: Map<string, number>;
5410
5439
  /**
5411
5440
  * Map of outcomeId → venue name that provided the price in `prices`.
@@ -5458,4 +5487,4 @@ declare function useAppConfig(): UseAppConfigResult;
5458
5487
  */
5459
5488
  declare function useCachedAppConfig(): UseAppConfigResult;
5460
5489
 
5461
- export { AUTH_CHOOSER_OPEN_EVENT, type AggAuthContextValue, type AggAuthSignInOptions, type AggBalanceContextValue, AggBalanceProvider, AggProvider, type AggProviderProps, AggProvider as AggSdkProvider, type AggProviderProps as AggSdkProviderProps, type AggUiConfig, type AggUiConfigInput, type AggUiLabels, type AggUiLabelsInput, AggUiProvider, CHART_TIME_RANGES, CONFIRMED_MATCH_STATUSES, type ChartTimeRange, type ClosedPositionTotals, type ComputePriceGapsOptions, DEFAULT_AGG_ROOT_CLASS_NAME, type DagStepProgress, type EventListStateContextValue, EventListStateProvider, type EventListStateSnapshot, type EventTradingContextValue, type EventTradingState, type ExecutionProgressPhase, type ExecutionTerminalOrderEvent, type GeoBlockState, type GetOrdersQuery, type GetPositionsQuery, type InvalidateUserActivityOptions, type InvalidateUserMoneyStateOptions, type LiveBestPrices, type LiveCandle, MAX_PRICE_GAP_PCT, MIN_PRICE_GAP_PCT, type MarketChartCandle, type MarketChartData, type MarketChartVenueData, type MarketOrderbookData, type MarketOrderbookIntegrity, MarketStatus, type MarketTradingState, MatchStatus, MatchType, type OrderEligibility, type OrderEligibilityReason, type OrderListItem, type OrderbookResult, type PositionGroup, type PriceGapValue, type RedeemEvent, type RedeemLegLifecycle, type RedeemLifecycleState, RedeemRejectedError, type RollingChartWindow, type ScaledCandlePoint, type SdkUiConfig, type SdkUiConfigInput, type SdkUiProviderProps, type ThemeMode, TradeSide, type TradingAction, type TradingState, type TradingStateBase, type TradingStateKind, type UseAggAuthOptions, type UseAggAuthReturn, type UseAppConfigResult, type UseArbFeedResult, type UseCategoriesOptions, type UseCategoryChildrenOptions, type UseEnrichedVenueEventOptions, type UseExecuteManagedOptions, type UseExecutionOrdersOptions, type UseExecutionPositionsOptions, type UseExecutionProgressOptions, type UseExecutionProgressResult, type UseExternalIdOptions, type UseExternalIdReturn, type UseLinkAccountReturn, type UseLiveCandleOverlayOptions, type UseLiveCandleOverlayResult, type UseLiveCandlesOptions, type UseLiveCandlesResult, type UseLiveMarketResult, type UseMarketArbResult, type UseMarketChartOptions, type UseMarketChartResult, type UseMarketOrderbookOptions, type UseMarketOrderbookResult, type UseMarketOrderbookVenueOutcome, type UseMarketSearchOptions, type UseMidpointsResult, type UseOrderBookOptions, type UseOrderbookQuoteOptions, type UseOrderbookQuoteResult, type UseOrdersOptions, type UsePositionsOptions, type UseQuoteManagedOptions, type UseRedeemLifecycleInput, type UseRollingChartWindowOptions, type UseSearchOptions, type UseSmartRouteOptions, type UseSmartRouteResult, type UseTradableVenuesResult, type UseUserActivityOptions, type UseUserHoldingsOptions, type UseVenueEventOptions, type UseVenueEventsOptions, type UseVenueMarketMidpointsOptions, type UseVenueMarketsOptions, type UseVisibleIdsOptions, type UseVisibleIdsResult, type UserActivityInvalidationStrategy, Venue, type VenueAvailabilityState, type VenueEvent, type VenueEventWithMarkets, type VenueMarket, type VenueMarketOutcome, type WalletActionSendTokenParams, type WalletActions, computeClosedPositionTotals, computePriceGaps, defaultAggUiConfig, defaultAggUiConfig as defaultSdkUiConfig, executionKeys, findLivePriceById, getBuilder, getOrCreateBuilder, getVenueAvailabilityState, getVisibleVenueIdsByConfig, getVisibleVenuesByConfig, getWalletAddressFromUserProfile, invalidateBalanceQueries, invalidatePositionQueries, invalidateUserActivityQueries, invalidateUserClaimState, invalidateUserMoneyState, isVenueDisabledByConfig, mergeBestPricesPreferringLive, normalizeVenueId, optimizedImageUrl, parseEmail, parseEmailStrict, rangeToSeconds, requestAggAuthChooserOpen, resolveAggUiLabels, resolveDefaultMarket as resolveDefaultTradingMarket, resolveEventTradingState, resolveMarketTradingState, resolveMarketWinningOutcome, resolveOrderEligibility, resolveRollingWindow, resolveTradingStateKind, sortVenues, timeRangeToInterval, tradingReducer, useAggAuth, useAggAuthContext, useAggAuthState, useAggBalance, useAggBalanceContext, useAggBalanceState, useAggClient, useAggLabels, useAggUiConfig, useAggWebSocket, useAppConfig, useArbFeed, useCachedAppConfig, useCategories, useCategoryChildren, useDebouncedValue, useEnrichedVenueEvent, useEventListState, useEventOrderbookData, useEventTradingContext, useExecuteManaged, useExecutionOrders, useExecutionPositions, useExecutionProgress, useExternalId, useGeoBlock, useLabels, useLinkAccount, useLiveBestPrices, useLiveCandleOverlay, useLiveCandles, useLiveMarket, useLiveMarketStores, useLiveOutcomePrices, useLiveTrades, useMarketArb, useMarketChart, useMarketOrderbook, useMarketSearch, useMidpoints, useOnBalanceUpdate, useOnOrderEvent, useOnOrderSubmitted, useOnRedeemEvent, useOnWithdrawalLifecycle, useOptionalAggClient, useOrderBook, useOrderbookQuote, useOrders, usePositions, useQuoteManaged, useRampQuotes, useRampSession, useRedeem, useRedeemEligibleCount, useRedeemLifecycle, useRedeemLifecycles, useRollingChartWindow, useSdkLabels, useSdkUiConfig, useSearch, useSmartRoute, useTradableVenues, useUserActivity, useUserHoldings, useVenueEvent, useVenueEvents, useVenueMarketMidpoints, useVenueMarkets, useViewportMidpoints, useVisibleIds, userActivityQueryKeys };
5490
+ export { AUTH_CHOOSER_OPEN_EVENT, type AggAuthContextValue, type AggAuthSignInOptions, type AggBalanceContextValue, AggBalanceProvider, AggProvider, type AggProviderProps, AggProvider as AggSdkProvider, type AggProviderProps as AggSdkProviderProps, type AggUiConfig, type AggUiConfigInput, type AggUiLabels, type AggUiLabelsInput, AggUiProvider, CHART_TIME_RANGES, CONFIRMED_MATCH_STATUSES, type ChartTimeRange, type ClosedPositionTotals, type ComputePriceGapsOptions, DEFAULT_AGG_ROOT_CLASS_NAME, type DagStepProgress, type EventListStateContextValue, EventListStateProvider, type EventListStateSnapshot, type EventTradingContextValue, type EventTradingState, type ExecutionProgressPhase, type ExecutionTerminalOrderEvent, type GeoBlockState, type GetOrdersQuery, type GetPositionsQuery, type InvalidateUserActivityOptions, type InvalidateUserMoneyStateOptions, type LiveBestPrices, type LiveCandle, MAX_PRICE_GAP_PCT, MIN_PRICE_GAP_PCT, type MarketChartCandle, type MarketChartData, type MarketChartVenueData, type MarketOrderbookData, type MarketOrderbookIntegrity, MarketStatus, type MarketTradingState, MatchStatus, MatchType, type OrderEligibility, type OrderEligibilityReason, type OrderListItem, type OrderbookResult, type PositionGroup, type PriceGapValue, type RedeemEvent, type RedeemLegLifecycle, type RedeemLifecycleState, RedeemRejectedError, type RollingChartWindow, type ScaledCandlePoint, type SdkUiConfig, type SdkUiConfigInput, type SdkUiProviderProps, type SmartRouteLoadingReason, type ThemeMode, TradeSide, type TradingAction, type TradingState, type TradingStateBase, type TradingStateKind, type UseAggAuthOptions, type UseAggAuthReturn, type UseAppConfigResult, type UseArbFeedResult, type UseCategoriesOptions, type UseCategoryChildrenOptions, type UseEnrichedVenueEventOptions, type UseExecuteManagedOptions, type UseExecutionOrdersOptions, type UseExecutionPositionsOptions, type UseExecutionProgressOptions, type UseExecutionProgressResult, type UseExternalIdOptions, type UseExternalIdReturn, type UseLinkAccountReturn, type UseLiveCandleOverlayOptions, type UseLiveCandleOverlayResult, type UseLiveCandlesOptions, type UseLiveCandlesResult, type UseLiveMarketResult, type UseMarketArbResult, type UseMarketChartOptions, type UseMarketChartResult, type UseMarketOrderbookOptions, type UseMarketOrderbookResult, type UseMarketOrderbookVenueOutcome, type UseMarketSearchOptions, type UseMidpointsOptions, type UseMidpointsResult, type UseOrderBookOptions, type UseOrderbookQuoteOptions, type UseOrderbookQuoteResult, type UseOrdersOptions, type UsePositionsOptions, type UseQuoteManagedOptions, type UseRedeemLifecycleInput, type UseRollingChartWindowOptions, type UseSearchOptions, type UseSmartRouteOptions, type UseSmartRouteResult, type UseTradableVenuesResult, type UseUserActivityOptions, type UseUserHoldingsOptions, type UseVenueEventOptions, type UseVenueEventsOptions, type UseVenueMarketMidpointsOptions, type UseVenueMarketsOptions, type UseViewportMidpointsOptions, type UseVisibleIdsOptions, type UseVisibleIdsResult, type UserActivityInvalidationStrategy, Venue, type VenueAvailabilityState, type VenueEvent, type VenueEventWithMarkets, type VenueMarket, type VenueMarketOutcome, type WalletActionSendTokenParams, type WalletActions, computeClosedPositionTotals, computePriceGaps, defaultAggUiConfig, defaultAggUiConfig as defaultSdkUiConfig, executionKeys, findLivePriceById, getBuilder, getOrCreateBuilder, getVenueAvailabilityState, getVisibleVenueIdsByConfig, getVisibleVenuesByConfig, getWalletAddressFromUserProfile, invalidateBalanceQueries, invalidatePositionQueries, invalidateUserActivityQueries, invalidateUserClaimState, invalidateUserMoneyState, isVenueDisabledByConfig, mergeBestPricesPreferringLive, normalizeVenueId, optimizedImageUrl, parseEmail, parseEmailStrict, rangeToSeconds, requestAggAuthChooserOpen, resolveAggUiLabels, resolveDefaultMarket as resolveDefaultTradingMarket, resolveEventTradingState, resolveMarketTradingState, resolveMarketWinningOutcome, resolveOrderEligibility, resolveRollingWindow, resolveTradingStateKind, sortVenues, timeRangeToInterval, tradingReducer, useAggAuth, useAggAuthContext, useAggAuthState, useAggBalance, useAggBalanceContext, useAggBalanceState, useAggClient, useAggLabels, useAggUiConfig, useAggWebSocket, useAppConfig, useArbFeed, useCachedAppConfig, useCategories, useCategoryChildren, useDebouncedValue, useEnrichedVenueEvent, useEventListState, useEventOrderbookData, useEventTradingContext, useExecuteManaged, useExecutionOrders, useExecutionPositions, useExecutionProgress, useExternalId, useGeoBlock, useLabels, useLinkAccount, useLiveBestPrices, useLiveCandleOverlay, useLiveCandles, useLiveMarket, useLiveMarketStores, useLiveOutcomePrices, useLiveTrades, useMarketArb, useMarketChart, useMarketOrderbook, useMarketSearch, useMidpoints, useOnBalanceUpdate, useOnOrderEvent, useOnOrderSubmitted, useOnRedeemEvent, useOnWithdrawalLifecycle, useOptionalAggClient, useOrderBook, useOrderbookQuote, useOrders, usePositions, useQuoteManaged, useRampQuotes, useRampSession, useRedeem, useRedeemEligibleCount, useRedeemLifecycle, useRedeemLifecycles, useRollingChartWindow, useSdkLabels, useSdkUiConfig, useSearch, useSmartRoute, useTradableVenues, useUserActivity, useUserHoldings, useVenueEvent, useVenueEvents, useVenueMarketMidpoints, useVenueMarkets, useViewportMidpoints, useVisibleIds, userActivityQueryKeys };