@agg-build/hooks 1.2.0 → 1.2.11

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.
@@ -6,8 +6,11 @@ interface UseSyncBalancesOptions {
6
6
  onError?: (error: Error) => void;
7
7
  }
8
8
  /**
9
- * Mutation hook for triggering an on-chain balance sync.
10
- * On success, invalidates balances queries.
9
+ * Mutation hook for triggering an on-chain balance sync. Acts as the
10
+ * deposit-completion signal (`useDepositFlow` fires it after a wallet tx
11
+ * settles and after a card-purchase redirect returns), so on success we
12
+ * invalidate the full money-state cache surface — balances, positions, and
13
+ * the activity feed — not just balances.
11
14
  */
12
15
  declare function useSyncBalances(options?: UseSyncBalancesOptions): _tanstack_react_query.UseMutationResult<_agg_build_sdk.SyncBalancesResponse, Error, void, unknown>;
13
16
 
@@ -6,8 +6,11 @@ interface UseSyncBalancesOptions {
6
6
  onError?: (error: Error) => void;
7
7
  }
8
8
  /**
9
- * Mutation hook for triggering an on-chain balance sync.
10
- * On success, invalidates balances queries.
9
+ * Mutation hook for triggering an on-chain balance sync. Acts as the
10
+ * deposit-completion signal (`useDepositFlow` fires it after a wallet tx
11
+ * settles and after a card-purchase redirect returns), so on success we
12
+ * invalidate the full money-state cache surface — balances, positions, and
13
+ * the activity feed — not just balances.
11
14
  */
12
15
  declare function useSyncBalances(options?: UseSyncBalancesOptions): _tanstack_react_query.UseMutationResult<_agg_build_sdk.SyncBalancesResponse, Error, void, unknown>;
13
16
 
@@ -54,6 +54,23 @@ interface UseWithdrawFlowOptions {
54
54
  }
55
55
  declare function useWithdrawFlow(options: UseWithdrawFlowOptions): UseWithdrawFlowResult;
56
56
 
57
+ interface WithdrawFeeEstimate {
58
+ estimatedFees: string;
59
+ networkReserve: string;
60
+ youReceive: string;
61
+ }
62
+ interface UseWithdrawEstimateParams {
63
+ amount: string;
64
+ selectedToken: string;
65
+ selectedNetwork: string;
66
+ }
67
+ /**
68
+ * Natively estimates withdrawal fees, network reserves, and the expected net
69
+ * amount to be received based on the selected token, destination network,
70
+ * and transfer amount.
71
+ */
72
+ declare function useWithdrawEstimate({ amount, selectedToken, selectedNetwork, }: UseWithdrawEstimateParams): WithdrawFeeEstimate | null;
73
+
57
74
  /**
58
75
  * Latest lifecycle snapshot for a single withdrawal, materialized from the
59
76
  * most recent `WsWithdrawalLifecycleEvent` whose `withdrawalId` matches.
@@ -68,6 +85,10 @@ interface WithdrawalLifecycleState {
68
85
  pending: boolean;
69
86
  /** Top-level status, or `null` until the first event arrives. */
70
87
  status: WsWithdrawalLifecycleStatus | null;
88
+ /** Requested withdrawal amount in destination-token native decimals. */
89
+ requestedAmountRaw: string | null;
90
+ /** Terminal settled amount in destination-token native decimals. */
91
+ completedAmountRaw: string | null;
71
92
  /** Whether `status` is a terminal state (`completed` / `partial` / `failed`). */
72
93
  terminal: boolean;
73
94
  /** Last leg delta (the leg whose flip triggered the most recent event). */
@@ -109,8 +130,11 @@ interface UseWithdrawManagedOptions {
109
130
  onError?: (error: Error) => void;
110
131
  }
111
132
  /**
112
- * Mutation hook for withdrawing funds from managed wallets.
113
- * On success, invalidates balances queries.
133
+ * Mutation hook for withdrawing funds from managed wallets. On submission
134
+ * success the backend has already debited the managed-side balance and
135
+ * recorded the activity row, so we invalidate the full money-state cache
136
+ * surface (balances, positions, activity). Terminal lifecycle invalidation
137
+ * is handled separately by `useWithdrawalLifecycle`.
114
138
  */
115
139
  declare function useWithdrawManaged(options?: UseWithdrawManagedOptions): _tanstack_react_query.UseMutationResult<WithdrawManagedResponse, Error, WithdrawManagedParams, unknown>;
116
140
 
@@ -290,4 +314,4 @@ declare function useManagedBalances(options?: UseManagedBalancesOptions): {
290
314
  promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
291
315
  };
292
316
 
293
- export { type UseManagedBalancesOptions, type UseWithdrawFlowOptions, type UseWithdrawFlowResult, type UseWithdrawManagedOptions, type UseWithdrawalLifecycleResult, type WithdrawalLifecycleState, useManagedBalances, useWithdrawFlow, useWithdrawManaged, useWithdrawalLifecycle };
317
+ export { type UseManagedBalancesOptions, type UseWithdrawEstimateParams, type UseWithdrawFlowOptions, type UseWithdrawFlowResult, type UseWithdrawManagedOptions, type UseWithdrawalLifecycleResult, type WithdrawFeeEstimate, type WithdrawalLifecycleState, useManagedBalances, useWithdrawEstimate, useWithdrawFlow, useWithdrawManaged, useWithdrawalLifecycle };
@@ -54,6 +54,23 @@ interface UseWithdrawFlowOptions {
54
54
  }
55
55
  declare function useWithdrawFlow(options: UseWithdrawFlowOptions): UseWithdrawFlowResult;
56
56
 
57
+ interface WithdrawFeeEstimate {
58
+ estimatedFees: string;
59
+ networkReserve: string;
60
+ youReceive: string;
61
+ }
62
+ interface UseWithdrawEstimateParams {
63
+ amount: string;
64
+ selectedToken: string;
65
+ selectedNetwork: string;
66
+ }
67
+ /**
68
+ * Natively estimates withdrawal fees, network reserves, and the expected net
69
+ * amount to be received based on the selected token, destination network,
70
+ * and transfer amount.
71
+ */
72
+ declare function useWithdrawEstimate({ amount, selectedToken, selectedNetwork, }: UseWithdrawEstimateParams): WithdrawFeeEstimate | null;
73
+
57
74
  /**
58
75
  * Latest lifecycle snapshot for a single withdrawal, materialized from the
59
76
  * most recent `WsWithdrawalLifecycleEvent` whose `withdrawalId` matches.
@@ -68,6 +85,10 @@ interface WithdrawalLifecycleState {
68
85
  pending: boolean;
69
86
  /** Top-level status, or `null` until the first event arrives. */
70
87
  status: WsWithdrawalLifecycleStatus | null;
88
+ /** Requested withdrawal amount in destination-token native decimals. */
89
+ requestedAmountRaw: string | null;
90
+ /** Terminal settled amount in destination-token native decimals. */
91
+ completedAmountRaw: string | null;
71
92
  /** Whether `status` is a terminal state (`completed` / `partial` / `failed`). */
72
93
  terminal: boolean;
73
94
  /** Last leg delta (the leg whose flip triggered the most recent event). */
@@ -109,8 +130,11 @@ interface UseWithdrawManagedOptions {
109
130
  onError?: (error: Error) => void;
110
131
  }
111
132
  /**
112
- * Mutation hook for withdrawing funds from managed wallets.
113
- * On success, invalidates balances queries.
133
+ * Mutation hook for withdrawing funds from managed wallets. On submission
134
+ * success the backend has already debited the managed-side balance and
135
+ * recorded the activity row, so we invalidate the full money-state cache
136
+ * surface (balances, positions, activity). Terminal lifecycle invalidation
137
+ * is handled separately by `useWithdrawalLifecycle`.
114
138
  */
115
139
  declare function useWithdrawManaged(options?: UseWithdrawManagedOptions): _tanstack_react_query.UseMutationResult<WithdrawManagedResponse, Error, WithdrawManagedParams, unknown>;
116
140
 
@@ -290,4 +314,4 @@ declare function useManagedBalances(options?: UseManagedBalancesOptions): {
290
314
  promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
291
315
  };
292
316
 
293
- export { type UseManagedBalancesOptions, type UseWithdrawFlowOptions, type UseWithdrawFlowResult, type UseWithdrawManagedOptions, type UseWithdrawalLifecycleResult, type WithdrawalLifecycleState, useManagedBalances, useWithdrawFlow, useWithdrawManaged, useWithdrawalLifecycle };
317
+ export { type UseManagedBalancesOptions, type UseWithdrawEstimateParams, type UseWithdrawFlowOptions, type UseWithdrawFlowResult, type UseWithdrawManagedOptions, type UseWithdrawalLifecycleResult, type WithdrawFeeEstimate, type WithdrawalLifecycleState, useManagedBalances, useWithdrawEstimate, useWithdrawFlow, useWithdrawManaged, useWithdrawalLifecycle };
package/dist/withdraw.js CHANGED
@@ -59,6 +59,7 @@ var withdraw_exports = {};
59
59
  __export(withdraw_exports, {
60
60
  useDepositAddresses: () => useDepositAddresses,
61
61
  useManagedBalances: () => useManagedBalances,
62
+ useWithdrawEstimate: () => useWithdrawEstimate,
62
63
  useWithdrawFlow: () => useWithdrawFlow,
63
64
  useWithdrawManaged: () => useWithdrawManaged,
64
65
  useWithdrawalLifecycle: () => useWithdrawalLifecycle
@@ -235,6 +236,12 @@ var enUsLabels = {
235
236
  max: "Max",
236
237
  tokenLabel: "Receive token",
237
238
  networkLabel: "Receive network",
239
+ estimatedFees: "Est. fees",
240
+ networkReserve: "Network reserve",
241
+ networkReserveTooltipAria: "Network reserve details",
242
+ networkReserveTooltipLineOne: "This reserve helps cover network and bridge costs.",
243
+ networkReserveTooltipLineTwo: "Any unused amount stays in your balance.",
244
+ youReceive: "You'll receive",
238
245
  confirm: "Confirm withdrawal",
239
246
  successTitle: "Withdrawal submitted",
240
247
  successDescription: (tokenSymbol) => `Your ${tokenSymbol} withdrawal is being processed and will arrive shortly.`,
@@ -243,12 +250,16 @@ var enUsLabels = {
243
250
  // terminal status — otherwise a finished withdrawal would keep showing
244
251
  // "submitted / processing" forever and force the user to hard-refresh.
245
252
  successTitleCompleted: "Withdrawal complete",
246
- successDescriptionCompleted: (tokenSymbol) => `Your ${tokenSymbol} withdrawal has been delivered.`,
253
+ successDescriptionCompleted: (tokenSymbol) => `Your ${tokenSymbol} has been successfully sent to your wallet.`,
247
254
  successTitlePartial: "Withdrawal partially completed",
248
- successDescriptionPartial: (tokenSymbol) => `Some legs of your ${tokenSymbol} withdrawal completed; see details below.`,
255
+ successDescriptionPartial: () => "Part of your withdrawal was completed successfully, but the remaining funds failed to transfer and were returned to your balance.",
249
256
  successTitleFailed: "Withdrawal failed",
250
- successDescriptionFailed: (tokenSymbol) => `Your ${tokenSymbol} withdrawal could not be completed.`,
257
+ successDescriptionFailed: () => "We couldn't complete your withdrawal. Your funds were returned to your balance.",
258
+ retry: "Try Again",
259
+ close: "Close",
260
+ loadingDescription: "This may take a few minutes. You can safely close this window and check the status later in your activity.",
251
261
  summary: {
262
+ requestedWithdrawal: "Requested withdrawal",
252
263
  // The response is `pricingStatus: "unquoted"` — we don't know net
253
264
  // output until on-chain settlement. Calling this "Amount received"
254
265
  // would imply receipt before the lifecycle has confirmed. Keep it
@@ -266,6 +277,12 @@ var enUsLabels = {
266
277
  completed: "Withdrawal complete.",
267
278
  partial: "Withdrawal partially completed \u2014 see details below.",
268
279
  failed: "Withdrawal failed.",
280
+ loadingSteps: {
281
+ preparing: "Preparing funds",
282
+ bridging: "Bridging between networks",
283
+ sending: "Sending to your wallet",
284
+ confirming: "Waiting for network confirmation"
285
+ },
269
286
  steps: {
270
287
  bridge: (sourceChainName, destChainName) => `Bridging from ${sourceChainName} to ${destChainName}`,
271
288
  transfer: (destChainName) => `Transferring on ${destChainName}`
@@ -321,10 +338,37 @@ var enUsLabels = {
321
338
  externalWallet: "Deposit from external wallet",
322
339
  card: "Deposit with card"
323
340
  },
341
+ depositStatusTitles: {
342
+ connectedWallet: {
343
+ pending: "Processing deposit from connected wallet",
344
+ completed: "Successful deposit from connected wallet",
345
+ failed: "Failed deposit from connected wallet",
346
+ canceled: "Canceled deposit from connected wallet"
347
+ },
348
+ externalWallet: {
349
+ pending: "Processing deposit from external wallet",
350
+ completed: "Successful deposit from external wallet",
351
+ failed: "Failed deposit from external wallet",
352
+ canceled: "Canceled deposit from external wallet"
353
+ },
354
+ card: {
355
+ pending: "Processing deposit with card",
356
+ completed: "Successful deposit with card",
357
+ failed: "Failed deposit with card",
358
+ canceled: "Canceled deposit with card"
359
+ }
360
+ },
361
+ withdrawalStatusTitles: {
362
+ pending: "Processing withdrawal",
363
+ completed: "Successful withdrawal",
364
+ failed: "Failed withdrawal",
365
+ canceled: "Canceled withdrawal"
366
+ },
324
367
  // Activity-row title for any withdrawal regardless of lifecycle
325
- // state (pending / completed / failed) — render the asset rather
326
- // than implying success. The ActivityRow renders a separate status
327
- // chip when the row is failed.
368
+ // state — render the asset rather than implying success. The
369
+ // ActivityRow renders a separate status chip when the row is
370
+ // failed. Retained for partner overrides that still want a
371
+ // status-agnostic title.
328
372
  withdrawalTitle: (tokenSymbol) => `Withdraw ${tokenSymbol}`
329
373
  },
330
374
  positions: {
@@ -545,6 +589,7 @@ var enUsLabels = {
545
589
  noMarketSelected: "Select a market to place an order.",
546
590
  noOrderbooks: "No live orderbooks are available for this market right now.",
547
591
  quoteUnavailable: "Quote temporarily unavailable. Please try again.",
592
+ quoteBalanceMismatch: "Quote balance mismatch. Try a different amount.",
548
593
  selectedVenueUnavailable: "The venue you selected is no longer available on this route. Review the updated options and try again.",
549
594
  engineUnavailable: "The routing engine is temporarily unavailable. Please try again in a moment.",
550
595
  insufficientInputAmount: "Trade amount is too small to cover bridging and execution costs. Increase your spend or deposit funds on the destination chain.",
@@ -582,6 +627,7 @@ var enUsLabels = {
582
627
  buyingOutcome: (label) => `Buying ${label}`,
583
628
  sellingOutcome: (label) => `Selling ${label}`,
584
629
  findingBestRoute: "Finding the best route...",
630
+ checkingBalance: "Checking balance",
585
631
  submittingOrderProgress: "Submitting order...",
586
632
  orderSubmittedProgress: (orderId) => `Order #${orderId.replace(/^#/, "")} submitted`,
587
633
  executingOnVenue: (venueLabel) => `Executing on ${venueLabel}...`,
@@ -820,6 +866,7 @@ var defaultAggUiSearchConfig = {
820
866
  var defaultAggUiConfig = {
821
867
  enableLogs: false,
822
868
  enableWebsocketsLogs: false,
869
+ enableDebug: false,
823
870
  general: {
824
871
  locale: DEFAULT_LOCALE,
825
872
  theme: "light",
@@ -894,6 +941,33 @@ var invalidateBalanceQueries = (queryClient, options) => {
894
941
  refetchType
895
942
  });
896
943
  };
944
+ var invalidatePositionQueries = (queryClient, options) => {
945
+ var _a;
946
+ queryClient.invalidateQueries({
947
+ queryKey: executionKeys.positionsPrefix(),
948
+ refetchType: (_a = options == null ? void 0 : options.refetchType) != null ? _a : "active"
949
+ });
950
+ };
951
+ var userActivityQueryKeys = {
952
+ all: () => ["user-activity"]
953
+ };
954
+ var invalidateUserActivityQueries = (queryClient, options) => {
955
+ var _a;
956
+ const strategy = (_a = options == null ? void 0 : options.strategy) != null ? _a : "remove";
957
+ if (strategy === "remove") {
958
+ queryClient.removeQueries({ queryKey: userActivityQueryKeys.all() });
959
+ return;
960
+ }
961
+ queryClient.invalidateQueries({
962
+ queryKey: userActivityQueryKeys.all(),
963
+ refetchType: "all"
964
+ });
965
+ };
966
+ var invalidateUserMoneyState = (queryClient, options) => {
967
+ invalidateBalanceQueries(queryClient, { refetchType: options == null ? void 0 : options.refetchType });
968
+ invalidatePositionQueries(queryClient, { refetchType: options == null ? void 0 : options.refetchType });
969
+ invalidateUserActivityQueries(queryClient, { strategy: options == null ? void 0 : options.activityStrategy });
970
+ };
897
971
 
898
972
  // src/core/providers/ws-provider.tsx
899
973
  var import_react3 = require("react");
@@ -952,7 +1026,7 @@ function useWithdrawManaged(options) {
952
1026
  mutationFn: (params) => client.withdrawManaged(params),
953
1027
  onSuccess: (data) => {
954
1028
  var _a;
955
- invalidateBalanceQueries(queryClient);
1029
+ invalidateUserMoneyState(queryClient);
956
1030
  (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
957
1031
  },
958
1032
  onError: options == null ? void 0 : options.onError
@@ -1043,7 +1117,7 @@ function useSyncBalances(options) {
1043
1117
  mutationFn: () => client.syncManagedBalances(),
1044
1118
  onSuccess: () => {
1045
1119
  var _a;
1046
- invalidateBalanceQueries(queryClient);
1120
+ invalidateUserMoneyState(queryClient);
1047
1121
  (_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options);
1048
1122
  },
1049
1123
  onError: options == null ? void 0 : options.onError
@@ -1065,7 +1139,9 @@ var WITHDRAWAL_SUPPORTED_CHAIN_IDS = /* @__PURE__ */ new Set([
1065
1139
  // Base
1066
1140
  56,
1067
1141
  // BNB
1068
- SOLANA_CHAIN_ID
1142
+ SOLANA_CHAIN_ID,
1143
+ 1337
1144
+ // Hyperliquid
1069
1145
  ]);
1070
1146
  var isValidDestinationAddress = (address, chainId) => {
1071
1147
  if (chainId === SOLANA_CHAIN_ID) return SOLANA_ADDRESS_REGEX.test(address);
@@ -1302,12 +1378,60 @@ function useWithdrawFlow(options) {
1302
1378
  };
1303
1379
  }
1304
1380
 
1305
- // src/withdraw/use-withdrawal-lifecycle.ts
1381
+ // src/withdraw/use-withdraw-estimate.ts
1306
1382
  var import_react6 = require("react");
1383
+ function useWithdrawEstimate({
1384
+ amount,
1385
+ selectedToken,
1386
+ selectedNetwork
1387
+ }) {
1388
+ return (0, import_react6.useMemo)(() => {
1389
+ const numAmount = Number(amount);
1390
+ if (!amount || isNaN(numAmount) || numAmount <= 0 || !selectedToken || !selectedNetwork) {
1391
+ return null;
1392
+ }
1393
+ const network = selectedNetwork.toLowerCase();
1394
+ let feeVal = 0.1;
1395
+ let reserveVal = 0.2;
1396
+ if (network === "1" || network === "mainnet" || network === "ethereum") {
1397
+ feeVal = 1.22;
1398
+ reserveVal = 0.3;
1399
+ } else if (network === "137" || network === "polygon") {
1400
+ feeVal = 0.05;
1401
+ reserveVal = 0.15;
1402
+ } else if (network === "42161" || network === "arbitrum") {
1403
+ feeVal = 0.05;
1404
+ reserveVal = 0.15;
1405
+ } else if (network === "8453" || network === "base") {
1406
+ feeVal = 0.05;
1407
+ reserveVal = 0.15;
1408
+ } else if (network === "56" || network === "bnb" || network === "bsc") {
1409
+ feeVal = 0.1;
1410
+ reserveVal = 0.2;
1411
+ } else if (network === "792703809" || network === "solana") {
1412
+ feeVal = 0.01;
1413
+ reserveVal = 0.04;
1414
+ } else if (network === "1337" || network === "hyperliquid") {
1415
+ feeVal = 0.02;
1416
+ reserveVal = 0.08;
1417
+ }
1418
+ const youReceiveVal = Math.max(0, numAmount - feeVal);
1419
+ return {
1420
+ estimatedFees: `~$${feeVal.toFixed(2)}`,
1421
+ networkReserve: `~$${reserveVal.toFixed(2)}`,
1422
+ youReceive: `~${youReceiveVal.toFixed(2)} ${selectedToken}`
1423
+ };
1424
+ }, [amount, selectedToken, selectedNetwork]);
1425
+ }
1426
+
1427
+ // src/withdraw/use-withdrawal-lifecycle.ts
1428
+ var import_react7 = require("react");
1307
1429
  var import_react_query6 = require("@tanstack/react-query");
1308
1430
  var INITIAL_STATE = {
1309
1431
  pending: true,
1310
1432
  status: null,
1433
+ requestedAmountRaw: null,
1434
+ completedAmountRaw: null,
1311
1435
  terminal: false,
1312
1436
  lastLeg: null,
1313
1437
  legs: [],
@@ -1338,14 +1462,16 @@ var mergeLegs = (prev, snapshot, delta) => {
1338
1462
  return next;
1339
1463
  };
1340
1464
  var restToLifecycleState = (response) => {
1341
- var _a;
1465
+ var _a, _b;
1342
1466
  return {
1343
1467
  pending: false,
1344
1468
  status: response.status,
1469
+ requestedAmountRaw: response.requested.amountRaw,
1470
+ completedAmountRaw: (_a = response.completedAmountRaw) != null ? _a : null,
1345
1471
  terminal: response.status === "completed" || response.status === "partial" || response.status === "failed",
1346
1472
  lastLeg: null,
1347
1473
  legs: response.legs.map(restLegToWsLeg),
1348
- errorMessage: (_a = response.errorMessage) != null ? _a : null,
1474
+ errorMessage: (_b = response.errorMessage) != null ? _b : null,
1349
1475
  // No server timestamp on the REST response — we use 0 as "older than any
1350
1476
  // WS timestamp" so a subsequent WS event always wins. Callers that read
1351
1477
  // `timestamp` should treat 0/null interchangeably as "unset".
@@ -1356,14 +1482,14 @@ function useWithdrawalLifecycle(withdrawalId) {
1356
1482
  const client = useAggClient();
1357
1483
  const wsConnected = useAggWebSocketConnectionState();
1358
1484
  const queryClient = (0, import_react_query6.useQueryClient)();
1359
- const [state, setState] = (0, import_react6.useState)(INITIAL_STATE);
1360
- const stateRef = (0, import_react6.useRef)(state);
1485
+ const [state, setState] = (0, import_react7.useState)(INITIAL_STATE);
1486
+ const stateRef = (0, import_react7.useRef)(state);
1361
1487
  stateRef.current = state;
1362
- const balanceRefetchedForRef = (0, import_react6.useRef)(null);
1363
- (0, import_react6.useEffect)(() => {
1488
+ const balanceRefetchedForRef = (0, import_react7.useRef)(null);
1489
+ (0, import_react7.useEffect)(() => {
1364
1490
  setState(INITIAL_STATE);
1365
1491
  }, [withdrawalId]);
1366
- (0, import_react6.useEffect)(() => {
1492
+ (0, import_react7.useEffect)(() => {
1367
1493
  if (!withdrawalId) return;
1368
1494
  let cancelled = false;
1369
1495
  (() => __async(null, null, function* () {
@@ -1382,17 +1508,19 @@ function useWithdrawalLifecycle(withdrawalId) {
1382
1508
  cancelled = true;
1383
1509
  };
1384
1510
  }, [client, withdrawalId, wsConnected]);
1385
- const handler = (0, import_react6.useMemo)(() => {
1511
+ const handler = (0, import_react7.useMemo)(() => {
1386
1512
  if (!withdrawalId) return null;
1387
1513
  return (msg) => {
1388
1514
  if (msg.withdrawalId !== withdrawalId) return;
1389
1515
  setState((prev) => {
1390
- var _a, _b;
1516
+ var _a, _b, _c, _d;
1391
1517
  return {
1392
1518
  pending: false,
1393
1519
  status: msg.status,
1520
+ requestedAmountRaw: (_a = msg.requestedAmountRaw) != null ? _a : prev.requestedAmountRaw,
1521
+ completedAmountRaw: (_b = msg.completedAmountRaw) != null ? _b : prev.completedAmountRaw,
1394
1522
  terminal: msg.terminal,
1395
- lastLeg: (_a = msg.leg) != null ? _a : null,
1523
+ lastLeg: (_c = msg.leg) != null ? _c : null,
1396
1524
  // `legs[]` is the cumulative server-known truth. Snapshots
1397
1525
  // (`pending` / terminal rollup) carry a full `legs[]` and replace
1398
1526
  // it. Intermediate per-leg deltas carry only `leg` (no `legs[]`)
@@ -1400,29 +1528,30 @@ function useWithdrawalLifecycle(withdrawalId) {
1400
1528
  // (sourceChainId, destChainId, type) so the timeline UI doesn't
1401
1529
  // collapse to empty between snapshots.
1402
1530
  legs: mergeLegs(prev.legs, msg.legs, msg.leg),
1403
- errorMessage: (_b = msg.errorMessage) != null ? _b : null,
1531
+ errorMessage: (_d = msg.errorMessage) != null ? _d : null,
1404
1532
  timestamp: msg.timestamp
1405
1533
  };
1406
1534
  });
1407
1535
  };
1408
1536
  }, [withdrawalId]);
1409
1537
  useOnWithdrawalLifecycle(handler);
1410
- (0, import_react6.useEffect)(() => {
1538
+ (0, import_react7.useEffect)(() => {
1411
1539
  if (!withdrawalId) return;
1412
1540
  if (!state.terminal) return;
1413
1541
  if (balanceRefetchedForRef.current === withdrawalId) return;
1414
1542
  balanceRefetchedForRef.current = withdrawalId;
1415
- invalidateBalanceQueries(queryClient);
1543
+ invalidateUserMoneyState(queryClient);
1416
1544
  client.syncManagedBalances().catch(() => {
1417
1545
  });
1418
1546
  }, [client, queryClient, state.terminal, withdrawalId]);
1419
- const reset = (0, import_react6.useCallback)(() => setState(INITIAL_STATE), []);
1547
+ const reset = (0, import_react7.useCallback)(() => setState(INITIAL_STATE), []);
1420
1548
  return { state, reset };
1421
1549
  }
1422
1550
  // Annotate the CommonJS export names for ESM import in node:
1423
1551
  0 && (module.exports = {
1424
1552
  useDepositAddresses,
1425
1553
  useManagedBalances,
1554
+ useWithdrawEstimate,
1426
1555
  useWithdrawFlow,
1427
1556
  useWithdrawManaged,
1428
1557
  useWithdrawalLifecycle
package/dist/withdraw.mjs CHANGED
@@ -1,15 +1,17 @@
1
1
  import {
2
+ useWithdrawEstimate,
2
3
  useWithdrawFlow,
3
4
  useWithdrawalLifecycle
4
- } from "./chunk-KSSPFJM2.mjs";
5
+ } from "./chunk-CWEJLBYY.mjs";
5
6
  import {
6
7
  useDepositAddresses,
7
8
  useManagedBalances,
8
9
  useWithdrawManaged
9
- } from "./chunk-U3DRHUR5.mjs";
10
+ } from "./chunk-553OI6M2.mjs";
10
11
  export {
11
12
  useDepositAddresses,
12
13
  useManagedBalances,
14
+ useWithdrawEstimate,
13
15
  useWithdrawFlow,
14
16
  useWithdrawManaged,
15
17
  useWithdrawalLifecycle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agg-build/hooks",
3
- "version": "1.2.0",
3
+ "version": "1.2.11",
4
4
  "description": "React hooks and providers for the AGG prediction market aggregator. Wraps @agg-build/sdk with TanStack Query, shared session state, and live WebSocket data.",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -83,7 +83,7 @@
83
83
  "react": "^18.0.0 || ^19.0.0",
84
84
  "viem": "^2.0.0",
85
85
  "wagmi": "^3.0.0 || ^2.0.0",
86
- "@agg-build/sdk": "^1.2.0"
86
+ "@agg-build/sdk": "^1.2.11"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@solana/wallet-adapter-react": {