@agg-build/hooks 2.7.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __async,
3
3
  useAggClient
4
- } from "./chunk-TJRQ55UC.mjs";
4
+ } from "./chunk-XYWK7G2R.mjs";
5
5
 
6
6
  // src/use-ramp-quotes.ts
7
7
  import { useMutation } from "@tanstack/react-query";
@@ -278,6 +278,56 @@ var enUsLabels = {
278
278
  claimableWinningsTooltip: (count) => `${count} position${count === 1 ? "" : "s"} ready to claim`,
279
279
  walletMenuFor: (profileLabel) => `Profile menu for ${profileLabel}`
280
280
  },
281
+ balanceRefill: {
282
+ tabLabel: "Balance management",
283
+ title: "Automatic balance refill",
284
+ description: "Keep a minimum USDC balance on one network by moving funds from another managed network.",
285
+ networkLabel: "Network to maintain",
286
+ minimumLabel: "Minimum balance",
287
+ refillAmountLabel: "Refill by at least",
288
+ dailyCapLabel: "Maximum per day",
289
+ maximumFeeLabel: "Maximum fee per refill",
290
+ activeLabel: "Automatic refill is active",
291
+ pausedLabel: "Automatic refill is paused",
292
+ enableAction: "Enable automatic refill",
293
+ saveAction: "Save refill settings",
294
+ pauseAction: "Pause automatic refill",
295
+ resumeAction: "Resume automatic refill",
296
+ loading: "Loading refill settings...",
297
+ loadError: "Refill settings could not be loaded.",
298
+ saveError: "Refill settings could not be saved.",
299
+ saved: "Refill settings saved.",
300
+ consent: "By enabling, you authorize AGG to move USDC between your managed wallets within these limits.",
301
+ lastRefill: "Latest refill",
302
+ manageTitle: "Manage balances",
303
+ manageDescription: "Set a minimum balance and refill target for each venue. When a venue falls below your minimum, funds are automatically transferred from your balances on other venues to restore it to your refill target.",
304
+ noAutoRefill: "No auto-refill",
305
+ autoRefill: "Auto-refill",
306
+ minimumShortLabel: "Min",
307
+ refillToLabel: "Refill to",
308
+ unitLabel: "USDC",
309
+ resetAction: "Reset",
310
+ cancelAction: "Cancel",
311
+ saveChangesAction: "Save changes",
312
+ modalLoading: "Loading balances...",
313
+ modalEmptyTitle: "No supported networks",
314
+ modalEmptyDescription: "There are no supported networks to manage yet.",
315
+ modalLoadError: "Balances could not be loaded.",
316
+ requiredError: "Enter an amount.",
317
+ positiveError: "Enter an amount greater than 0.",
318
+ precisionError: "Use no more than 6 decimal places.",
319
+ relationshipError: "Refill to must be greater than or equal to Min.",
320
+ maximumError: (maximum) => `Enter an amount no greater than ${maximum} USDC.`,
321
+ createUnavailableError: "Auto-refill cannot be enabled for this network until refill limits are supported by the API.",
322
+ expandNetwork: (network) => `Expand ${network} balance settings`,
323
+ collapseNetwork: (network) => `Collapse ${network} balance settings`,
324
+ statuses: {
325
+ reserved: "Funds reserved",
326
+ executing: "Refill in progress",
327
+ completed: "Refill completed",
328
+ failed: "Refill failed"
329
+ }
330
+ },
281
331
  deposit: {
282
332
  title: "Deposit",
283
333
  back: "Go back",
@@ -481,7 +531,8 @@ var enUsLabels = {
481
531
  activity: "Activity"
482
532
  },
483
533
  balance: {
484
- availableBalance: "Available Balance",
534
+ availableBalance: "Withdrawable Balance",
535
+ manage: "Manage",
485
536
  reservedForOpenOrders: (amount) => `${amount} reserved for open orders`,
486
537
  positionsValue: "Positions Value",
487
538
  kalshiBalance: "Kalshi Balance",
@@ -853,6 +904,7 @@ var enUsLabels = {
853
904
  tradingAccessAddKalshiAccount: "Add Kalshi Account",
854
905
  outcome: (label) => `Outcome: ${label}`,
855
906
  smartRouting: "Smart Routing",
907
+ limitRoutingCurrentPrice: (priceLabel, feeLabel) => feeLabel ? `Current ${priceLabel} \xB7 Fee ${feeLabel}` : `Current ${priceLabel}`,
856
908
  orderTypeMarket: "Market",
857
909
  orderTypeLimit: "Limit",
858
910
  orderTypeAria: "Order type",
@@ -878,6 +930,10 @@ var enUsLabels = {
878
930
  limitOrderPlacedDescription: "Your limit order has been submitted.",
879
931
  orderSplitting: "Order Splitting",
880
932
  splitOrderDescription: "We split your order for the best price:",
933
+ maximizePayout: "Maximize payout",
934
+ maximizePayoutDescription: "We\u2019ll route your shares for the highest payout:",
935
+ venueInventory: (sharesLabel, priceLabel) => `${sharesLabel} \xB7 ${priceLabel}`,
936
+ insufficientVenueInventory: (sharesLabel, priceLabel) => `Only ${sharesLabel} \xB7 ${priceLabel}`,
881
937
  viewAllRoutes: (count) => `View all (${count})`,
882
938
  venueUnavailableInRegion: "Unavailable in your region",
883
939
  verified: "Verified",
@@ -1326,7 +1382,7 @@ var mergeAggUiSearchConfig = (config) => {
1326
1382
  };
1327
1383
  };
1328
1384
  var mergeAggUiConfig = (persisted, config) => {
1329
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$;
1385
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa;
1330
1386
  const locale = (_d = (_c = (_a = config == null ? void 0 : config.general) == null ? void 0 : _a.locale) != null ? _c : (_b = persisted.general) == null ? void 0 : _b.locale) != null ? _d : DEFAULT_LOCALE;
1331
1387
  const theme = (_h = (_g = (_e = config == null ? void 0 : config.general) == null ? void 0 : _e.theme) != null ? _g : (_f = persisted.general) == null ? void 0 : _f.theme) != null ? _h : defaultAggUiConfig.general.theme;
1332
1388
  const formatters = createFormatters(locale);
@@ -1364,13 +1420,16 @@ var mergeAggUiConfig = (persisted, config) => {
1364
1420
  formatting: {
1365
1421
  formatNumber: (_R = (_Q = config == null ? void 0 : config.formatting) == null ? void 0 : _Q.formatNumber) != null ? _R : formatters.formatNumber,
1366
1422
  formatPercent: (_T = (_S = config == null ? void 0 : config.formatting) == null ? void 0 : _S.formatPercent) != null ? _T : formatters.formatPercent,
1367
- formatCurrency: (_V = (_U = config == null ? void 0 : config.formatting) == null ? void 0 : _U.formatCurrency) != null ? _V : formatters.formatCurrency,
1368
- formatCompactCurrency: (_X = (_W = config == null ? void 0 : config.formatting) == null ? void 0 : _W.formatCompactCurrency) != null ? _X : formatters.formatCompactCurrency,
1369
- formatDate: (_Z = (_Y = config == null ? void 0 : config.formatting) == null ? void 0 : _Y.formatDate) != null ? _Z : formatters.formatDate
1423
+ // ponytail: no default here — each cents surface keeps its own rendering
1424
+ // when unset, so adding this knob changes nothing for existing partners.
1425
+ formatPrice: (_U = config == null ? void 0 : config.formatting) == null ? void 0 : _U.formatPrice,
1426
+ formatCurrency: (_W = (_V = config == null ? void 0 : config.formatting) == null ? void 0 : _V.formatCurrency) != null ? _W : formatters.formatCurrency,
1427
+ formatCompactCurrency: (_Y = (_X = config == null ? void 0 : config.formatting) == null ? void 0 : _X.formatCompactCurrency) != null ? _Y : formatters.formatCompactCurrency,
1428
+ formatDate: (__ = (_Z = config == null ? void 0 : config.formatting) == null ? void 0 : _Z.formatDate) != null ? __ : formatters.formatDate
1370
1429
  },
1371
1430
  search: mergeAggUiSearchConfig(config == null ? void 0 : config.search),
1372
1431
  trading: {
1373
- executionMode: (_$ = (__ = config == null ? void 0 : config.trading) == null ? void 0 : __.executionMode) != null ? _$ : defaultAggUiConfig.trading.executionMode
1432
+ executionMode: (_aa = (_$ = config == null ? void 0 : config.trading) == null ? void 0 : _$.executionMode) != null ? _aa : defaultAggUiConfig.trading.executionMode
1374
1433
  },
1375
1434
  walletActions: config == null ? void 0 : config.walletActions,
1376
1435
  solanaRpcUrl: config == null ? void 0 : config.solanaRpcUrl
@@ -1393,7 +1452,8 @@ var executionKeys = {
1393
1452
  claimableClosedPositionsCount: () => ["execution", "positions", "claimable-count"],
1394
1453
  orders: (status, cursor, limit) => ["execution", "orders", status != null ? status : null, cursor != null ? cursor : null, limit != null ? limit : null],
1395
1454
  ordersPrefix: () => ["execution", "orders"],
1396
- depositAddresses: () => ["execution", "deposit-addresses"]
1455
+ depositAddresses: () => ["execution", "deposit-addresses"],
1456
+ balanceRefillPolicies: () => ["execution", "balance-refill-policies"]
1397
1457
  };
1398
1458
 
1399
1459
  // src/execution/balance-invalidation.ts
@@ -1553,7 +1613,7 @@ function AggBalanceProvider({ children }) {
1553
1613
  (a, b) => a.localeCompare(b)
1554
1614
  );
1555
1615
  }, [managedBalances.positions]);
1556
- const balancesError = balancesQuery.error;
1616
+ const balancesError = managedBalancesData === void 0 ? balancesQuery.error : null;
1557
1617
  const isBalancesLoading = balancesQuery.isLoading;
1558
1618
  const refetchBalances = balancesQuery.refetch;
1559
1619
  const totalBalance = useMemo(() => {
@@ -1639,11 +1699,12 @@ function AggBalanceProvider({ children }) {
1639
1699
  }, [buildBalanceBreakdown]);
1640
1700
  const positionsBalanceTotal = useMemo(() => {
1641
1701
  const positions = managedBalances.positions;
1642
- return positions.reduce(
1702
+ const actualPositionsBalance = positions.reduce(
1643
1703
  (sum, position) => sum + (Number.isFinite(position.balance) ? position.balance : 0),
1644
1704
  0
1645
1705
  );
1646
- }, [managedBalances]);
1706
+ return actualPositionsBalance + reservedBalance;
1707
+ }, [managedBalances.positions, reservedBalance]);
1647
1708
  const kalshiVenueCash = (_a = managedBalances.venueCash) == null ? void 0 : _a.find((item) => item.venue === "kalshi");
1648
1709
  const kalshiBalance = kalshiVenueCash ? kalshiVenueCash.balanceCents / 100 : null;
1649
1710
  const kalshiPortfolioValue = (kalshiVenueCash == null ? void 0 : kalshiVenueCash.portfolioValueCents) == null ? null : kalshiVenueCash.portfolioValueCents / 100;
@@ -4611,6 +4672,53 @@ function useExecutionProgress({
4611
4672
  return { phase, submittedOrders, latestBalance, dagProgress, terminalOrderEvents };
4612
4673
  }
4613
4674
 
4675
+ // src/execution/use-balance-refill-policies.ts
4676
+ import { useMutation as useMutation7, useQuery as useQuery5, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
4677
+ function useBalanceRefillPolicies(options) {
4678
+ var _a, _b;
4679
+ const client = useAggClient();
4680
+ const queryClient = useQueryClient8();
4681
+ const queryKey = executionKeys.balanceRefillPolicies();
4682
+ const query = useQuery5({
4683
+ queryKey,
4684
+ queryFn: () => client.getBalanceRefillPolicies(),
4685
+ enabled: (_a = options == null ? void 0 : options.enabled) != null ? _a : true,
4686
+ staleTime: 15e3,
4687
+ refetchInterval: (state) => {
4688
+ var _a2;
4689
+ return ((_a2 = state.state.data) == null ? void 0 : _a2.some(
4690
+ (policy) => {
4691
+ var _a3, _b2;
4692
+ return ["reserved", "executing"].includes((_b2 = (_a3 = policy.latestAttempt) == null ? void 0 : _a3.status) != null ? _b2 : "");
4693
+ }
4694
+ )) ? 5e3 : false;
4695
+ }
4696
+ });
4697
+ const createPolicy = useMutation7({
4698
+ mutationFn: (params) => client.createBalanceRefillPolicy(params),
4699
+ onSuccess: (policy) => {
4700
+ queryClient.setQueryData(queryKey, [policy]);
4701
+ }
4702
+ });
4703
+ const updatePolicy = useMutation7({
4704
+ mutationFn: ({
4705
+ policyId,
4706
+ params
4707
+ }) => client.updateBalanceRefillPolicy(policyId, params),
4708
+ onSuccess: (updated) => {
4709
+ queryClient.setQueryData(
4710
+ queryKey,
4711
+ (current) => (current != null ? current : []).map((policy) => policy.id === updated.id ? updated : policy)
4712
+ );
4713
+ }
4714
+ });
4715
+ return __spreadProps(__spreadValues({}, query), {
4716
+ policies: (_b = query.data) != null ? _b : [],
4717
+ createPolicy,
4718
+ updatePolicy
4719
+ });
4720
+ }
4721
+
4614
4722
  // src/execution/compute-closed-position-totals.ts
4615
4723
  var computeClosedPositionTotals = (group) => {
4616
4724
  const outcomes = group.venueMarket.venueMarketOutcomes;
@@ -4650,7 +4758,7 @@ var computeClosedPositionTotals = (group) => {
4650
4758
  };
4651
4759
 
4652
4760
  // src/execution/use-redeem.ts
4653
- import { useMutation as useMutation7, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
4761
+ import { useMutation as useMutation8, useQueryClient as useQueryClient9 } from "@tanstack/react-query";
4654
4762
  var RedeemRejectedError = class extends Error {
4655
4763
  constructor(message, response) {
4656
4764
  super(message);
@@ -4661,8 +4769,8 @@ var RedeemRejectedError = class extends Error {
4661
4769
  var isLegRejected = (status) => status === "ineligible" || status === "rejected";
4662
4770
  var useRedeem = () => {
4663
4771
  const client = useAggClient();
4664
- const queryClient = useQueryClient8();
4665
- return useMutation7({
4772
+ const queryClient = useQueryClient9();
4773
+ return useMutation8({
4666
4774
  mutationFn: (body) => __async(null, null, function* () {
4667
4775
  const response = yield client.redeem(body);
4668
4776
  if (response.results.length > 0 && response.results.every((r) => isLegRejected(r.status))) {
@@ -4684,7 +4792,7 @@ var useOnRedeemEvent2 = (listener) => {
4684
4792
  };
4685
4793
 
4686
4794
  // src/execution/use-redeem-eligible-count.ts
4687
- import { useQuery as useQuery5 } from "@tanstack/react-query";
4795
+ import { useQuery as useQuery6 } from "@tanstack/react-query";
4688
4796
  var CLAIMABLE_COUNT_PAGE_LIMIT = 100;
4689
4797
  var getClaimablePositionsCount = (client) => __async(null, null, function* () {
4690
4798
  var _a;
@@ -4709,7 +4817,7 @@ var useRedeemEligibleCount = () => {
4709
4817
  var _a;
4710
4818
  const client = useAggClient();
4711
4819
  const { isAuthenticated } = useAggAuthState();
4712
- const query = useQuery5({
4820
+ const query = useQuery6({
4713
4821
  queryKey: executionKeys.claimablePositionsCount(),
4714
4822
  queryFn: () => getClaimablePositionsCount(client),
4715
4823
  enabled: isAuthenticated,
@@ -4938,6 +5046,7 @@ export {
4938
5046
  useDepositAddresses,
4939
5047
  useSyncBalances,
4940
5048
  useExecutionProgress,
5049
+ useBalanceRefillPolicies,
4941
5050
  computeClosedPositionTotals,
4942
5051
  RedeemRejectedError,
4943
5052
  useRedeem,
@@ -11,7 +11,7 @@ import {
11
11
  useOnWithdrawalLifecycle,
12
12
  useSyncBalances,
13
13
  useWithdrawManaged
14
- } from "./chunk-TJRQ55UC.mjs";
14
+ } from "./chunk-XYWK7G2R.mjs";
15
15
 
16
16
  // src/withdraw/use-withdraw-flow.ts
17
17
  import { useCallback, useEffect, useMemo, useState } from "react";
package/dist/deposit.js CHANGED
@@ -203,6 +203,56 @@ var enUsLabels = {
203
203
  claimableWinningsTooltip: (count) => `${count} position${count === 1 ? "" : "s"} ready to claim`,
204
204
  walletMenuFor: (profileLabel) => `Profile menu for ${profileLabel}`
205
205
  },
206
+ balanceRefill: {
207
+ tabLabel: "Balance management",
208
+ title: "Automatic balance refill",
209
+ description: "Keep a minimum USDC balance on one network by moving funds from another managed network.",
210
+ networkLabel: "Network to maintain",
211
+ minimumLabel: "Minimum balance",
212
+ refillAmountLabel: "Refill by at least",
213
+ dailyCapLabel: "Maximum per day",
214
+ maximumFeeLabel: "Maximum fee per refill",
215
+ activeLabel: "Automatic refill is active",
216
+ pausedLabel: "Automatic refill is paused",
217
+ enableAction: "Enable automatic refill",
218
+ saveAction: "Save refill settings",
219
+ pauseAction: "Pause automatic refill",
220
+ resumeAction: "Resume automatic refill",
221
+ loading: "Loading refill settings...",
222
+ loadError: "Refill settings could not be loaded.",
223
+ saveError: "Refill settings could not be saved.",
224
+ saved: "Refill settings saved.",
225
+ consent: "By enabling, you authorize AGG to move USDC between your managed wallets within these limits.",
226
+ lastRefill: "Latest refill",
227
+ manageTitle: "Manage balances",
228
+ manageDescription: "Set a minimum balance and refill target for each venue. When a venue falls below your minimum, funds are automatically transferred from your balances on other venues to restore it to your refill target.",
229
+ noAutoRefill: "No auto-refill",
230
+ autoRefill: "Auto-refill",
231
+ minimumShortLabel: "Min",
232
+ refillToLabel: "Refill to",
233
+ unitLabel: "USDC",
234
+ resetAction: "Reset",
235
+ cancelAction: "Cancel",
236
+ saveChangesAction: "Save changes",
237
+ modalLoading: "Loading balances...",
238
+ modalEmptyTitle: "No supported networks",
239
+ modalEmptyDescription: "There are no supported networks to manage yet.",
240
+ modalLoadError: "Balances could not be loaded.",
241
+ requiredError: "Enter an amount.",
242
+ positiveError: "Enter an amount greater than 0.",
243
+ precisionError: "Use no more than 6 decimal places.",
244
+ relationshipError: "Refill to must be greater than or equal to Min.",
245
+ maximumError: (maximum) => `Enter an amount no greater than ${maximum} USDC.`,
246
+ createUnavailableError: "Auto-refill cannot be enabled for this network until refill limits are supported by the API.",
247
+ expandNetwork: (network) => `Expand ${network} balance settings`,
248
+ collapseNetwork: (network) => `Collapse ${network} balance settings`,
249
+ statuses: {
250
+ reserved: "Funds reserved",
251
+ executing: "Refill in progress",
252
+ completed: "Refill completed",
253
+ failed: "Refill failed"
254
+ }
255
+ },
206
256
  deposit: {
207
257
  title: "Deposit",
208
258
  back: "Go back",
@@ -406,7 +456,8 @@ var enUsLabels = {
406
456
  activity: "Activity"
407
457
  },
408
458
  balance: {
409
- availableBalance: "Available Balance",
459
+ availableBalance: "Withdrawable Balance",
460
+ manage: "Manage",
410
461
  reservedForOpenOrders: (amount) => `${amount} reserved for open orders`,
411
462
  positionsValue: "Positions Value",
412
463
  kalshiBalance: "Kalshi Balance",
@@ -778,6 +829,7 @@ var enUsLabels = {
778
829
  tradingAccessAddKalshiAccount: "Add Kalshi Account",
779
830
  outcome: (label) => `Outcome: ${label}`,
780
831
  smartRouting: "Smart Routing",
832
+ limitRoutingCurrentPrice: (priceLabel, feeLabel) => feeLabel ? `Current ${priceLabel} \xB7 Fee ${feeLabel}` : `Current ${priceLabel}`,
781
833
  orderTypeMarket: "Market",
782
834
  orderTypeLimit: "Limit",
783
835
  orderTypeAria: "Order type",
@@ -803,6 +855,10 @@ var enUsLabels = {
803
855
  limitOrderPlacedDescription: "Your limit order has been submitted.",
804
856
  orderSplitting: "Order Splitting",
805
857
  splitOrderDescription: "We split your order for the best price:",
858
+ maximizePayout: "Maximize payout",
859
+ maximizePayoutDescription: "We\u2019ll route your shares for the highest payout:",
860
+ venueInventory: (sharesLabel, priceLabel) => `${sharesLabel} \xB7 ${priceLabel}`,
861
+ insufficientVenueInventory: (sharesLabel, priceLabel) => `Only ${sharesLabel} \xB7 ${priceLabel}`,
806
862
  viewAllRoutes: (count) => `View all (${count})`,
807
863
  venueUnavailableInRegion: "Unavailable in your region",
808
864
  verified: "Verified",
@@ -1242,7 +1298,8 @@ var executionKeys = {
1242
1298
  claimableClosedPositionsCount: () => ["execution", "positions", "claimable-count"],
1243
1299
  orders: (status, cursor, limit) => ["execution", "orders", status != null ? status : null, cursor != null ? cursor : null, limit != null ? limit : null],
1244
1300
  ordersPrefix: () => ["execution", "orders"],
1245
- depositAddresses: () => ["execution", "deposit-addresses"]
1301
+ depositAddresses: () => ["execution", "deposit-addresses"],
1302
+ balanceRefillPolicies: () => ["execution", "balance-refill-policies"]
1246
1303
  };
1247
1304
 
1248
1305
  // src/execution/balance-invalidation.ts
package/dist/deposit.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useRampQuotes,
3
3
  useRampSession
4
- } from "./chunk-Q4FRCMP6.mjs";
4
+ } from "./chunk-MGWCWGMA.mjs";
5
5
  import {
6
6
  __async,
7
7
  useAggAuthState,
@@ -11,7 +11,7 @@ import {
11
11
  useDepositAddresses,
12
12
  useOptionalAggClient,
13
13
  useSyncBalances
14
- } from "./chunk-TJRQ55UC.mjs";
14
+ } from "./chunk-XYWK7G2R.mjs";
15
15
 
16
16
  // src/deposit/normalize-wallet-error.ts
17
17
  function normalizeWalletError(error, supportedChains) {