@agg-build/hooks 1.0.2 → 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.
- package/README.md +1 -1
- package/dist/{chunk-V6VNA7MX.mjs → chunk-553OI6M2.mjs} +565 -89
- package/dist/{chunk-NOYHQUW2.mjs → chunk-CWEJLBYY.mjs} +66 -11
- package/dist/{chunk-EB64HHYM.mjs → chunk-JWPZNCGY.mjs} +1 -1
- package/dist/deposit.d.mts +8 -2
- package/dist/deposit.d.ts +8 -2
- package/dist/deposit.js +215 -76
- package/dist/deposit.mjs +119 -66
- package/dist/index.d.mts +712 -42
- package/dist/index.d.ts +712 -42
- package/dist/index.js +1405 -357
- package/dist/index.mjs +681 -163
- package/dist/{use-sync-balances-B1_8tBKw.d.ts → use-sync-balances-CeD8qZWP.d.mts} +5 -2
- package/dist/{use-sync-balances-B1_8tBKw.d.mts → use-sync-balances-CeD8qZWP.d.ts} +5 -2
- package/dist/withdraw.d.mts +27 -3
- package/dist/withdraw.d.ts +27 -3
- package/dist/withdraw.js +178 -26
- package/dist/withdraw.mjs +4 -2
- package/package.json +2 -2
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
package/dist/withdraw.d.mts
CHANGED
|
@@ -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
|
-
*
|
|
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.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
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}
|
|
253
|
+
successDescriptionCompleted: (tokenSymbol) => `Your ${tokenSymbol} has been successfully sent to your wallet.`,
|
|
247
254
|
successTitlePartial: "Withdrawal partially completed",
|
|
248
|
-
successDescriptionPartial: (
|
|
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: (
|
|
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,24 +338,66 @@ 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
|
|
326
|
-
//
|
|
327
|
-
//
|
|
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: {
|
|
375
|
+
activeFilter: "Active",
|
|
376
|
+
closedFilter: "Closed",
|
|
377
|
+
marketHeader: "Market",
|
|
331
378
|
totalTradedHeader: "Total traded",
|
|
379
|
+
currentValueHeader: "Current value",
|
|
380
|
+
statusHeader: "Status",
|
|
381
|
+
resolutionHeader: "Resolution",
|
|
382
|
+
payoutHeader: "Payout",
|
|
383
|
+
resultHeader: "Result",
|
|
332
384
|
amountWonHeader: "Amount won",
|
|
333
385
|
claimHeader: "Claim",
|
|
334
386
|
claim: "Claim",
|
|
335
387
|
claimed: "Claimed",
|
|
336
388
|
pending: "Pending",
|
|
389
|
+
open: "Open",
|
|
337
390
|
won: "Won",
|
|
338
391
|
lost: "Lost",
|
|
392
|
+
sold: "Sold",
|
|
339
393
|
resolved: "Resolved",
|
|
340
394
|
marketClosed: "Market closed",
|
|
341
|
-
closed: "Closed"
|
|
395
|
+
closed: "Closed",
|
|
396
|
+
searchPlaceholder: "Search...",
|
|
397
|
+
noResults: "No results",
|
|
398
|
+
avgPrefix: "avg",
|
|
399
|
+
nowPrefix: "now",
|
|
400
|
+
finalPrefix: "final"
|
|
342
401
|
}
|
|
343
402
|
},
|
|
344
403
|
eventList: {
|
|
@@ -476,7 +535,7 @@ var enUsLabels = {
|
|
|
476
535
|
settlementEmpty: "No settlement details available.",
|
|
477
536
|
disclaimer: "By trading, you agree to the Terms of Use of each exchange.",
|
|
478
537
|
geoBlockTermsLink: "Terms of Use",
|
|
479
|
-
geoBlockGenericMessage: "
|
|
538
|
+
geoBlockGenericMessage: "None of the venues for this market are available in your region. See ",
|
|
480
539
|
geoBlockVenueMessage: (venueLabel) => `Trading on ${venueLabel} is not available in your region. See `,
|
|
481
540
|
geoBlockMessageSuffix: " for more information.",
|
|
482
541
|
geoBlockModalAriaLabel: "Geo-restricted location",
|
|
@@ -530,6 +589,7 @@ var enUsLabels = {
|
|
|
530
589
|
noMarketSelected: "Select a market to place an order.",
|
|
531
590
|
noOrderbooks: "No live orderbooks are available for this market right now.",
|
|
532
591
|
quoteUnavailable: "Quote temporarily unavailable. Please try again.",
|
|
592
|
+
quoteBalanceMismatch: "Quote balance mismatch. Try a different amount.",
|
|
533
593
|
selectedVenueUnavailable: "The venue you selected is no longer available on this route. Review the updated options and try again.",
|
|
534
594
|
engineUnavailable: "The routing engine is temporarily unavailable. Please try again in a moment.",
|
|
535
595
|
insufficientInputAmount: "Trade amount is too small to cover bridging and execution costs. Increase your spend or deposit funds on the destination chain.",
|
|
@@ -556,10 +616,18 @@ var enUsLabels = {
|
|
|
556
616
|
splitOrderDescription: "We split your order for the best price:",
|
|
557
617
|
viewAllRoutes: (count) => `View all (${count})`,
|
|
558
618
|
venueUnavailableInRegion: "Unavailable in your region",
|
|
619
|
+
platformFee: "0% platform fees",
|
|
620
|
+
estimatedFees: "Estimated fees",
|
|
621
|
+
estimatedFeesTooltipAria: "Estimated fees breakdown",
|
|
622
|
+
feeBreakdownVenueFees: "Venue fees",
|
|
623
|
+
feeBreakdownBridgeFees: "Bridge fees",
|
|
624
|
+
feeBreakdownExecutionGas: "Execution gas",
|
|
625
|
+
feeBreakdownTotalFees: "Total fees",
|
|
559
626
|
toWin: (tab) => tab === "buy" ? "To win" : "Payout",
|
|
560
627
|
buyingOutcome: (label) => `Buying ${label}`,
|
|
561
628
|
sellingOutcome: (label) => `Selling ${label}`,
|
|
562
629
|
findingBestRoute: "Finding the best route...",
|
|
630
|
+
checkingBalance: "Checking balance",
|
|
563
631
|
submittingOrderProgress: "Submitting order...",
|
|
564
632
|
orderSubmittedProgress: (orderId) => `Order #${orderId.replace(/^#/, "")} submitted`,
|
|
565
633
|
executingOnVenue: (venueLabel) => `Executing on ${venueLabel}...`,
|
|
@@ -798,6 +866,7 @@ var defaultAggUiSearchConfig = {
|
|
|
798
866
|
var defaultAggUiConfig = {
|
|
799
867
|
enableLogs: false,
|
|
800
868
|
enableWebsocketsLogs: false,
|
|
869
|
+
enableDebug: false,
|
|
801
870
|
general: {
|
|
802
871
|
locale: DEFAULT_LOCALE,
|
|
803
872
|
theme: "light",
|
|
@@ -807,6 +876,7 @@ var defaultAggUiConfig = {
|
|
|
807
876
|
features: {
|
|
808
877
|
enableAnimations: true,
|
|
809
878
|
enableLiveUpdates: true,
|
|
879
|
+
showFeesBreakdown: false,
|
|
810
880
|
enableGradients: false
|
|
811
881
|
},
|
|
812
882
|
market: {
|
|
@@ -871,6 +941,33 @@ var invalidateBalanceQueries = (queryClient, options) => {
|
|
|
871
941
|
refetchType
|
|
872
942
|
});
|
|
873
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
|
+
};
|
|
874
971
|
|
|
875
972
|
// src/core/providers/ws-provider.tsx
|
|
876
973
|
var import_react3 = require("react");
|
|
@@ -929,7 +1026,7 @@ function useWithdrawManaged(options) {
|
|
|
929
1026
|
mutationFn: (params) => client.withdrawManaged(params),
|
|
930
1027
|
onSuccess: (data) => {
|
|
931
1028
|
var _a;
|
|
932
|
-
|
|
1029
|
+
invalidateUserMoneyState(queryClient);
|
|
933
1030
|
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
|
|
934
1031
|
},
|
|
935
1032
|
onError: options == null ? void 0 : options.onError
|
|
@@ -1020,7 +1117,7 @@ function useSyncBalances(options) {
|
|
|
1020
1117
|
mutationFn: () => client.syncManagedBalances(),
|
|
1021
1118
|
onSuccess: () => {
|
|
1022
1119
|
var _a;
|
|
1023
|
-
|
|
1120
|
+
invalidateUserMoneyState(queryClient);
|
|
1024
1121
|
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options);
|
|
1025
1122
|
},
|
|
1026
1123
|
onError: options == null ? void 0 : options.onError
|
|
@@ -1042,7 +1139,9 @@ var WITHDRAWAL_SUPPORTED_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
|
1042
1139
|
// Base
|
|
1043
1140
|
56,
|
|
1044
1141
|
// BNB
|
|
1045
|
-
SOLANA_CHAIN_ID
|
|
1142
|
+
SOLANA_CHAIN_ID,
|
|
1143
|
+
1337
|
|
1144
|
+
// Hyperliquid
|
|
1046
1145
|
]);
|
|
1047
1146
|
var isValidDestinationAddress = (address, chainId) => {
|
|
1048
1147
|
if (chainId === SOLANA_CHAIN_ID) return SOLANA_ADDRESS_REGEX.test(address);
|
|
@@ -1279,12 +1378,60 @@ function useWithdrawFlow(options) {
|
|
|
1279
1378
|
};
|
|
1280
1379
|
}
|
|
1281
1380
|
|
|
1282
|
-
// src/withdraw/use-
|
|
1381
|
+
// src/withdraw/use-withdraw-estimate.ts
|
|
1283
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");
|
|
1284
1429
|
var import_react_query6 = require("@tanstack/react-query");
|
|
1285
1430
|
var INITIAL_STATE = {
|
|
1286
1431
|
pending: true,
|
|
1287
1432
|
status: null,
|
|
1433
|
+
requestedAmountRaw: null,
|
|
1434
|
+
completedAmountRaw: null,
|
|
1288
1435
|
terminal: false,
|
|
1289
1436
|
lastLeg: null,
|
|
1290
1437
|
legs: [],
|
|
@@ -1315,14 +1462,16 @@ var mergeLegs = (prev, snapshot, delta) => {
|
|
|
1315
1462
|
return next;
|
|
1316
1463
|
};
|
|
1317
1464
|
var restToLifecycleState = (response) => {
|
|
1318
|
-
var _a;
|
|
1465
|
+
var _a, _b;
|
|
1319
1466
|
return {
|
|
1320
1467
|
pending: false,
|
|
1321
1468
|
status: response.status,
|
|
1469
|
+
requestedAmountRaw: response.requested.amountRaw,
|
|
1470
|
+
completedAmountRaw: (_a = response.completedAmountRaw) != null ? _a : null,
|
|
1322
1471
|
terminal: response.status === "completed" || response.status === "partial" || response.status === "failed",
|
|
1323
1472
|
lastLeg: null,
|
|
1324
1473
|
legs: response.legs.map(restLegToWsLeg),
|
|
1325
|
-
errorMessage: (
|
|
1474
|
+
errorMessage: (_b = response.errorMessage) != null ? _b : null,
|
|
1326
1475
|
// No server timestamp on the REST response — we use 0 as "older than any
|
|
1327
1476
|
// WS timestamp" so a subsequent WS event always wins. Callers that read
|
|
1328
1477
|
// `timestamp` should treat 0/null interchangeably as "unset".
|
|
@@ -1333,14 +1482,14 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
1333
1482
|
const client = useAggClient();
|
|
1334
1483
|
const wsConnected = useAggWebSocketConnectionState();
|
|
1335
1484
|
const queryClient = (0, import_react_query6.useQueryClient)();
|
|
1336
|
-
const [state, setState] = (0,
|
|
1337
|
-
const stateRef = (0,
|
|
1485
|
+
const [state, setState] = (0, import_react7.useState)(INITIAL_STATE);
|
|
1486
|
+
const stateRef = (0, import_react7.useRef)(state);
|
|
1338
1487
|
stateRef.current = state;
|
|
1339
|
-
const balanceRefetchedForRef = (0,
|
|
1340
|
-
(0,
|
|
1488
|
+
const balanceRefetchedForRef = (0, import_react7.useRef)(null);
|
|
1489
|
+
(0, import_react7.useEffect)(() => {
|
|
1341
1490
|
setState(INITIAL_STATE);
|
|
1342
1491
|
}, [withdrawalId]);
|
|
1343
|
-
(0,
|
|
1492
|
+
(0, import_react7.useEffect)(() => {
|
|
1344
1493
|
if (!withdrawalId) return;
|
|
1345
1494
|
let cancelled = false;
|
|
1346
1495
|
(() => __async(null, null, function* () {
|
|
@@ -1359,17 +1508,19 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
1359
1508
|
cancelled = true;
|
|
1360
1509
|
};
|
|
1361
1510
|
}, [client, withdrawalId, wsConnected]);
|
|
1362
|
-
const handler = (0,
|
|
1511
|
+
const handler = (0, import_react7.useMemo)(() => {
|
|
1363
1512
|
if (!withdrawalId) return null;
|
|
1364
1513
|
return (msg) => {
|
|
1365
1514
|
if (msg.withdrawalId !== withdrawalId) return;
|
|
1366
1515
|
setState((prev) => {
|
|
1367
|
-
var _a, _b;
|
|
1516
|
+
var _a, _b, _c, _d;
|
|
1368
1517
|
return {
|
|
1369
1518
|
pending: false,
|
|
1370
1519
|
status: msg.status,
|
|
1520
|
+
requestedAmountRaw: (_a = msg.requestedAmountRaw) != null ? _a : prev.requestedAmountRaw,
|
|
1521
|
+
completedAmountRaw: (_b = msg.completedAmountRaw) != null ? _b : prev.completedAmountRaw,
|
|
1371
1522
|
terminal: msg.terminal,
|
|
1372
|
-
lastLeg: (
|
|
1523
|
+
lastLeg: (_c = msg.leg) != null ? _c : null,
|
|
1373
1524
|
// `legs[]` is the cumulative server-known truth. Snapshots
|
|
1374
1525
|
// (`pending` / terminal rollup) carry a full `legs[]` and replace
|
|
1375
1526
|
// it. Intermediate per-leg deltas carry only `leg` (no `legs[]`)
|
|
@@ -1377,29 +1528,30 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
1377
1528
|
// (sourceChainId, destChainId, type) so the timeline UI doesn't
|
|
1378
1529
|
// collapse to empty between snapshots.
|
|
1379
1530
|
legs: mergeLegs(prev.legs, msg.legs, msg.leg),
|
|
1380
|
-
errorMessage: (
|
|
1531
|
+
errorMessage: (_d = msg.errorMessage) != null ? _d : null,
|
|
1381
1532
|
timestamp: msg.timestamp
|
|
1382
1533
|
};
|
|
1383
1534
|
});
|
|
1384
1535
|
};
|
|
1385
1536
|
}, [withdrawalId]);
|
|
1386
1537
|
useOnWithdrawalLifecycle(handler);
|
|
1387
|
-
(0,
|
|
1538
|
+
(0, import_react7.useEffect)(() => {
|
|
1388
1539
|
if (!withdrawalId) return;
|
|
1389
1540
|
if (!state.terminal) return;
|
|
1390
1541
|
if (balanceRefetchedForRef.current === withdrawalId) return;
|
|
1391
1542
|
balanceRefetchedForRef.current = withdrawalId;
|
|
1392
|
-
|
|
1543
|
+
invalidateUserMoneyState(queryClient);
|
|
1393
1544
|
client.syncManagedBalances().catch(() => {
|
|
1394
1545
|
});
|
|
1395
1546
|
}, [client, queryClient, state.terminal, withdrawalId]);
|
|
1396
|
-
const reset = (0,
|
|
1547
|
+
const reset = (0, import_react7.useCallback)(() => setState(INITIAL_STATE), []);
|
|
1397
1548
|
return { state, reset };
|
|
1398
1549
|
}
|
|
1399
1550
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1400
1551
|
0 && (module.exports = {
|
|
1401
1552
|
useDepositAddresses,
|
|
1402
1553
|
useManagedBalances,
|
|
1554
|
+
useWithdrawEstimate,
|
|
1403
1555
|
useWithdrawFlow,
|
|
1404
1556
|
useWithdrawManaged,
|
|
1405
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-
|
|
5
|
+
} from "./chunk-CWEJLBYY.mjs";
|
|
5
6
|
import {
|
|
6
7
|
useDepositAddresses,
|
|
7
8
|
useManagedBalances,
|
|
8
9
|
useWithdrawManaged
|
|
9
|
-
} from "./chunk-
|
|
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.
|
|
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.
|
|
86
|
+
"@agg-build/sdk": "^1.2.11"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@solana/wallet-adapter-react": {
|