@agg-build/hooks 1.2.0 → 1.2.12
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/{chunk-U3DRHUR5.mjs → chunk-2C7JR5OH.mjs} +636 -94
- package/dist/{chunk-FKTRXKYA.mjs → chunk-R6VANZRA.mjs} +1 -1
- package/dist/{chunk-KSSPFJM2.mjs → chunk-V34QGQBO.mjs} +66 -11
- package/dist/deposit.d.mts +8 -2
- package/dist/deposit.d.ts +8 -2
- package/dist/deposit.js +267 -75
- package/dist/deposit.mjs +119 -66
- package/dist/index.d.mts +821 -42
- package/dist/index.d.ts +821 -42
- package/dist/index.js +1490 -369
- package/dist/index.mjs +697 -170
- 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 +230 -25
- 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,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
|
|
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: {
|
|
@@ -359,6 +403,15 @@ var enUsLabels = {
|
|
|
359
403
|
eventList: {
|
|
360
404
|
matchedTab: "Matched",
|
|
361
405
|
allTab: "All",
|
|
406
|
+
sortByLabel: "Sort by",
|
|
407
|
+
sortBy24hVolume: "24h volume",
|
|
408
|
+
sortByTopArbitrage: "Top arbitrage",
|
|
409
|
+
sortByTotalVolume: "Total volume",
|
|
410
|
+
sortByEndingSoon: "Ending soon",
|
|
411
|
+
subcategoriesLabel: "Subcategories",
|
|
412
|
+
subcategoriesAll: "All",
|
|
413
|
+
subcategoriesOpenAria: "Open subcategories",
|
|
414
|
+
subcategoriesCloseAria: "Close subcategories",
|
|
362
415
|
loading: (title) => `Loading ${title}`,
|
|
363
416
|
tabsAria: (title) => `${title} tabs`,
|
|
364
417
|
emptyAria: "No events found",
|
|
@@ -545,6 +598,19 @@ var enUsLabels = {
|
|
|
545
598
|
noMarketSelected: "Select a market to place an order.",
|
|
546
599
|
noOrderbooks: "No live orderbooks are available for this market right now.",
|
|
547
600
|
quoteUnavailable: "Quote temporarily unavailable. Please try again.",
|
|
601
|
+
quoteBalanceMismatch: "Quote balance mismatch. Try a different amount.",
|
|
602
|
+
serviceTemporarilyUnavailable: "Service temporarily unavailable. Please try again in a moment.",
|
|
603
|
+
orderDeadlineExpiredBeforeSubmission: "Order deadline expired before submission. Please try again.",
|
|
604
|
+
sellNoOnchainPosition: "You don't currently hold any on-chain shares of this outcome. If you just sold or redeemed elsewhere, your position display will refresh shortly \u2014 try again after that.",
|
|
605
|
+
venueQuoteUnfillable: "The venue couldn't fill this order at the quoted price right now. Try a smaller size, a higher slippage tolerance, or wait a moment and re-quote.",
|
|
606
|
+
venueMinOrderSize: "Order size is below the venue minimum. Try a larger amount.",
|
|
607
|
+
sourceBalanceChanged: "Your balance changed since the quote. Refresh and try again, or pick a smaller amount.",
|
|
608
|
+
venueMarketResolved: "This market just resolved. Pick a different market or wait for the next round.",
|
|
609
|
+
dflowWalletUnverified: "Your Solana wallet needs to be verified with dFlow before you can trade Kalshi markets. Verify at https://dflow.net/proof, then try again.",
|
|
610
|
+
venueNoQuotePath: "No active quote path for this market right now. Try a different size, or wait a moment and re-quote.",
|
|
611
|
+
solanaBlockhashExpired: "Solana transaction expired before submission. Please re-quote and try again.",
|
|
612
|
+
venueRateLimited: "The venue is rate-limiting requests right now. Please wait a moment and try again.",
|
|
613
|
+
serviceBlockedOrder: "Something on our side blocked this order. Please contact support if it keeps happening \u2014 retrying with the same quote will hit the same issue.",
|
|
548
614
|
selectedVenueUnavailable: "The venue you selected is no longer available on this route. Review the updated options and try again.",
|
|
549
615
|
engineUnavailable: "The routing engine is temporarily unavailable. Please try again in a moment.",
|
|
550
616
|
insufficientInputAmount: "Trade amount is too small to cover bridging and execution costs. Increase your spend or deposit funds on the destination chain.",
|
|
@@ -558,6 +624,7 @@ var enUsLabels = {
|
|
|
558
624
|
deposit: "Deposit",
|
|
559
625
|
kycRequired: "Verify to trade Kalshi",
|
|
560
626
|
kycNotVerifiedTooltip: "You have not been verified yet",
|
|
627
|
+
kycVerify: "Verify Identity",
|
|
561
628
|
kycVerifyModalTitle: "Verify Your Identity",
|
|
562
629
|
kycVerifyModalDescription: "To start trading on Kalshi, you'll need to complete identity verification through dFlow. It only takes a few minutes and helps us stay compliant with regulations.",
|
|
563
630
|
kycStartVerification: "Start Verification",
|
|
@@ -571,6 +638,7 @@ var enUsLabels = {
|
|
|
571
638
|
splitOrderDescription: "We split your order for the best price:",
|
|
572
639
|
viewAllRoutes: (count) => `View all (${count})`,
|
|
573
640
|
venueUnavailableInRegion: "Unavailable in your region",
|
|
641
|
+
verified: "Verified",
|
|
574
642
|
platformFee: "0% platform fees",
|
|
575
643
|
estimatedFees: "Estimated fees",
|
|
576
644
|
estimatedFeesTooltipAria: "Estimated fees breakdown",
|
|
@@ -582,6 +650,7 @@ var enUsLabels = {
|
|
|
582
650
|
buyingOutcome: (label) => `Buying ${label}`,
|
|
583
651
|
sellingOutcome: (label) => `Selling ${label}`,
|
|
584
652
|
findingBestRoute: "Finding the best route...",
|
|
653
|
+
checkingBalance: "Checking balance",
|
|
585
654
|
submittingOrderProgress: "Submitting order...",
|
|
586
655
|
orderSubmittedProgress: (orderId) => `Order #${orderId.replace(/^#/, "")} submitted`,
|
|
587
656
|
executingOnVenue: (venueLabel) => `Executing on ${venueLabel}...`,
|
|
@@ -761,6 +830,57 @@ var enUsLabels = {
|
|
|
761
830
|
header: {
|
|
762
831
|
bannerAria: "Site header",
|
|
763
832
|
logoAria: "Home"
|
|
833
|
+
},
|
|
834
|
+
notifications: {
|
|
835
|
+
order: {
|
|
836
|
+
filledTitle: "Order filled",
|
|
837
|
+
filledMessage: ({ venueLabel, sideLabel, amountLabel, priceLabel }) => {
|
|
838
|
+
const action = sideLabel ? `${sideLabel} filled` : "Filled";
|
|
839
|
+
const amount = amountLabel ? ` ${amountLabel}` : "";
|
|
840
|
+
const price = priceLabel ? ` at ${priceLabel}` : "";
|
|
841
|
+
const venue = venueLabel ? ` on ${venueLabel}` : "";
|
|
842
|
+
return `${action}${amount}${price}${venue}`.trim();
|
|
843
|
+
},
|
|
844
|
+
partialFilledTitle: "Order partially filled",
|
|
845
|
+
partialFilledMessage: ({ venueLabel, sideLabel, amountLabel, priceLabel }) => {
|
|
846
|
+
const action = sideLabel ? `${sideLabel} partially filled` : "Partially filled";
|
|
847
|
+
const amount = amountLabel ? ` ${amountLabel}` : "";
|
|
848
|
+
const price = priceLabel ? ` at ${priceLabel}` : "";
|
|
849
|
+
const venue = venueLabel ? ` on ${venueLabel}` : "";
|
|
850
|
+
return `${action}${amount}${price}${venue}`.trim();
|
|
851
|
+
},
|
|
852
|
+
failedTitle: "Order failed",
|
|
853
|
+
failedMessage: (errorReason) => errorReason && errorReason.length > 0 ? errorReason : "Your order could not be completed. Please try again."
|
|
854
|
+
},
|
|
855
|
+
deposit: {
|
|
856
|
+
completedTitle: "Deposit complete",
|
|
857
|
+
completedMessage: ({ amountLabel, tokenLabel }) => {
|
|
858
|
+
if (amountLabel && tokenLabel) return `${amountLabel} ${tokenLabel} added to your balance.`;
|
|
859
|
+
if (tokenLabel) return `Your ${tokenLabel} has been added to your balance.`;
|
|
860
|
+
return "Your funds have been added to your balance.";
|
|
861
|
+
},
|
|
862
|
+
failedTitle: "Deposit failed",
|
|
863
|
+
failedMessage: ({ amountLabel, tokenLabel }) => {
|
|
864
|
+
const what = amountLabel && tokenLabel ? `${amountLabel} ${tokenLabel}` : "deposit";
|
|
865
|
+
return `We couldn't complete your ${what}.`;
|
|
866
|
+
}
|
|
867
|
+
},
|
|
868
|
+
withdrawal: {
|
|
869
|
+
completedTitle: "Withdrawal complete",
|
|
870
|
+
completedMessage: ({ amountLabel, tokenLabel }) => {
|
|
871
|
+
if (amountLabel && tokenLabel) return `${amountLabel} ${tokenLabel} sent to your wallet.`;
|
|
872
|
+
if (tokenLabel) return `Your ${tokenLabel} has been sent to your wallet.`;
|
|
873
|
+
return "Your withdrawal has been sent to your wallet.";
|
|
874
|
+
},
|
|
875
|
+
partialTitle: "Withdrawal partially completed",
|
|
876
|
+
partialMessage: ({ amountLabel, tokenLabel }) => {
|
|
877
|
+
if (amountLabel && tokenLabel)
|
|
878
|
+
return `Part of your ${tokenLabel} was sent. The remainder was returned to your balance.`;
|
|
879
|
+
return "Part of your withdrawal was sent. The remainder was returned to your balance.";
|
|
880
|
+
},
|
|
881
|
+
failedTitle: "Withdrawal failed",
|
|
882
|
+
failedMessage: (errorReason) => errorReason && errorReason.length > 0 ? errorReason : "Your funds have been returned to your balance."
|
|
883
|
+
}
|
|
764
884
|
}
|
|
765
885
|
};
|
|
766
886
|
var defaultAggUiLabelsByLocale = {
|
|
@@ -820,6 +940,7 @@ var defaultAggUiSearchConfig = {
|
|
|
820
940
|
var defaultAggUiConfig = {
|
|
821
941
|
enableLogs: false,
|
|
822
942
|
enableWebsocketsLogs: false,
|
|
943
|
+
enableDebug: false,
|
|
823
944
|
general: {
|
|
824
945
|
locale: DEFAULT_LOCALE,
|
|
825
946
|
theme: "light",
|
|
@@ -830,7 +951,9 @@ var defaultAggUiConfig = {
|
|
|
830
951
|
enableAnimations: true,
|
|
831
952
|
enableLiveUpdates: true,
|
|
832
953
|
showFeesBreakdown: false,
|
|
833
|
-
enableGradients: false
|
|
954
|
+
enableGradients: false,
|
|
955
|
+
enableVenueEventDiscoveryFilters: false,
|
|
956
|
+
enableNotifications: true
|
|
834
957
|
},
|
|
835
958
|
market: {
|
|
836
959
|
arbitrageThreshold: 0
|
|
@@ -894,6 +1017,33 @@ var invalidateBalanceQueries = (queryClient, options) => {
|
|
|
894
1017
|
refetchType
|
|
895
1018
|
});
|
|
896
1019
|
};
|
|
1020
|
+
var invalidatePositionQueries = (queryClient, options) => {
|
|
1021
|
+
var _a;
|
|
1022
|
+
queryClient.invalidateQueries({
|
|
1023
|
+
queryKey: executionKeys.positionsPrefix(),
|
|
1024
|
+
refetchType: (_a = options == null ? void 0 : options.refetchType) != null ? _a : "active"
|
|
1025
|
+
});
|
|
1026
|
+
};
|
|
1027
|
+
var userActivityQueryKeys = {
|
|
1028
|
+
all: () => ["user-activity"]
|
|
1029
|
+
};
|
|
1030
|
+
var invalidateUserActivityQueries = (queryClient, options) => {
|
|
1031
|
+
var _a;
|
|
1032
|
+
const strategy = (_a = options == null ? void 0 : options.strategy) != null ? _a : "remove";
|
|
1033
|
+
if (strategy === "remove") {
|
|
1034
|
+
queryClient.removeQueries({ queryKey: userActivityQueryKeys.all() });
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
queryClient.invalidateQueries({
|
|
1038
|
+
queryKey: userActivityQueryKeys.all(),
|
|
1039
|
+
refetchType: "all"
|
|
1040
|
+
});
|
|
1041
|
+
};
|
|
1042
|
+
var invalidateUserMoneyState = (queryClient, options) => {
|
|
1043
|
+
invalidateBalanceQueries(queryClient, { refetchType: options == null ? void 0 : options.refetchType });
|
|
1044
|
+
invalidatePositionQueries(queryClient, { refetchType: options == null ? void 0 : options.refetchType });
|
|
1045
|
+
invalidateUserActivityQueries(queryClient, { strategy: options == null ? void 0 : options.activityStrategy });
|
|
1046
|
+
};
|
|
897
1047
|
|
|
898
1048
|
// src/core/providers/ws-provider.tsx
|
|
899
1049
|
var import_react3 = require("react");
|
|
@@ -952,7 +1102,7 @@ function useWithdrawManaged(options) {
|
|
|
952
1102
|
mutationFn: (params) => client.withdrawManaged(params),
|
|
953
1103
|
onSuccess: (data) => {
|
|
954
1104
|
var _a;
|
|
955
|
-
|
|
1105
|
+
invalidateUserMoneyState(queryClient);
|
|
956
1106
|
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data);
|
|
957
1107
|
},
|
|
958
1108
|
onError: options == null ? void 0 : options.onError
|
|
@@ -1043,7 +1193,7 @@ function useSyncBalances(options) {
|
|
|
1043
1193
|
mutationFn: () => client.syncManagedBalances(),
|
|
1044
1194
|
onSuccess: () => {
|
|
1045
1195
|
var _a;
|
|
1046
|
-
|
|
1196
|
+
invalidateUserMoneyState(queryClient);
|
|
1047
1197
|
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options);
|
|
1048
1198
|
},
|
|
1049
1199
|
onError: options == null ? void 0 : options.onError
|
|
@@ -1065,7 +1215,9 @@ var WITHDRAWAL_SUPPORTED_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
|
1065
1215
|
// Base
|
|
1066
1216
|
56,
|
|
1067
1217
|
// BNB
|
|
1068
|
-
SOLANA_CHAIN_ID
|
|
1218
|
+
SOLANA_CHAIN_ID,
|
|
1219
|
+
1337
|
|
1220
|
+
// Hyperliquid
|
|
1069
1221
|
]);
|
|
1070
1222
|
var isValidDestinationAddress = (address, chainId) => {
|
|
1071
1223
|
if (chainId === SOLANA_CHAIN_ID) return SOLANA_ADDRESS_REGEX.test(address);
|
|
@@ -1302,12 +1454,60 @@ function useWithdrawFlow(options) {
|
|
|
1302
1454
|
};
|
|
1303
1455
|
}
|
|
1304
1456
|
|
|
1305
|
-
// src/withdraw/use-
|
|
1457
|
+
// src/withdraw/use-withdraw-estimate.ts
|
|
1306
1458
|
var import_react6 = require("react");
|
|
1459
|
+
function useWithdrawEstimate({
|
|
1460
|
+
amount,
|
|
1461
|
+
selectedToken,
|
|
1462
|
+
selectedNetwork
|
|
1463
|
+
}) {
|
|
1464
|
+
return (0, import_react6.useMemo)(() => {
|
|
1465
|
+
const numAmount = Number(amount);
|
|
1466
|
+
if (!amount || isNaN(numAmount) || numAmount <= 0 || !selectedToken || !selectedNetwork) {
|
|
1467
|
+
return null;
|
|
1468
|
+
}
|
|
1469
|
+
const network = selectedNetwork.toLowerCase();
|
|
1470
|
+
let feeVal = 0.1;
|
|
1471
|
+
let reserveVal = 0.2;
|
|
1472
|
+
if (network === "1" || network === "mainnet" || network === "ethereum") {
|
|
1473
|
+
feeVal = 1.22;
|
|
1474
|
+
reserveVal = 0.3;
|
|
1475
|
+
} else if (network === "137" || network === "polygon") {
|
|
1476
|
+
feeVal = 0.05;
|
|
1477
|
+
reserveVal = 0.15;
|
|
1478
|
+
} else if (network === "42161" || network === "arbitrum") {
|
|
1479
|
+
feeVal = 0.05;
|
|
1480
|
+
reserveVal = 0.15;
|
|
1481
|
+
} else if (network === "8453" || network === "base") {
|
|
1482
|
+
feeVal = 0.05;
|
|
1483
|
+
reserveVal = 0.15;
|
|
1484
|
+
} else if (network === "56" || network === "bnb" || network === "bsc") {
|
|
1485
|
+
feeVal = 0.1;
|
|
1486
|
+
reserveVal = 0.2;
|
|
1487
|
+
} else if (network === "792703809" || network === "solana") {
|
|
1488
|
+
feeVal = 0.01;
|
|
1489
|
+
reserveVal = 0.04;
|
|
1490
|
+
} else if (network === "1337" || network === "hyperliquid") {
|
|
1491
|
+
feeVal = 0.02;
|
|
1492
|
+
reserveVal = 0.08;
|
|
1493
|
+
}
|
|
1494
|
+
const youReceiveVal = Math.max(0, numAmount - feeVal);
|
|
1495
|
+
return {
|
|
1496
|
+
estimatedFees: `~$${feeVal.toFixed(2)}`,
|
|
1497
|
+
networkReserve: `~$${reserveVal.toFixed(2)}`,
|
|
1498
|
+
youReceive: `~${youReceiveVal.toFixed(2)} ${selectedToken}`
|
|
1499
|
+
};
|
|
1500
|
+
}, [amount, selectedToken, selectedNetwork]);
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
// src/withdraw/use-withdrawal-lifecycle.ts
|
|
1504
|
+
var import_react7 = require("react");
|
|
1307
1505
|
var import_react_query6 = require("@tanstack/react-query");
|
|
1308
1506
|
var INITIAL_STATE = {
|
|
1309
1507
|
pending: true,
|
|
1310
1508
|
status: null,
|
|
1509
|
+
requestedAmountRaw: null,
|
|
1510
|
+
completedAmountRaw: null,
|
|
1311
1511
|
terminal: false,
|
|
1312
1512
|
lastLeg: null,
|
|
1313
1513
|
legs: [],
|
|
@@ -1338,14 +1538,16 @@ var mergeLegs = (prev, snapshot, delta) => {
|
|
|
1338
1538
|
return next;
|
|
1339
1539
|
};
|
|
1340
1540
|
var restToLifecycleState = (response) => {
|
|
1341
|
-
var _a;
|
|
1541
|
+
var _a, _b;
|
|
1342
1542
|
return {
|
|
1343
1543
|
pending: false,
|
|
1344
1544
|
status: response.status,
|
|
1545
|
+
requestedAmountRaw: response.requested.amountRaw,
|
|
1546
|
+
completedAmountRaw: (_a = response.completedAmountRaw) != null ? _a : null,
|
|
1345
1547
|
terminal: response.status === "completed" || response.status === "partial" || response.status === "failed",
|
|
1346
1548
|
lastLeg: null,
|
|
1347
1549
|
legs: response.legs.map(restLegToWsLeg),
|
|
1348
|
-
errorMessage: (
|
|
1550
|
+
errorMessage: (_b = response.errorMessage) != null ? _b : null,
|
|
1349
1551
|
// No server timestamp on the REST response — we use 0 as "older than any
|
|
1350
1552
|
// WS timestamp" so a subsequent WS event always wins. Callers that read
|
|
1351
1553
|
// `timestamp` should treat 0/null interchangeably as "unset".
|
|
@@ -1356,14 +1558,14 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
1356
1558
|
const client = useAggClient();
|
|
1357
1559
|
const wsConnected = useAggWebSocketConnectionState();
|
|
1358
1560
|
const queryClient = (0, import_react_query6.useQueryClient)();
|
|
1359
|
-
const [state, setState] = (0,
|
|
1360
|
-
const stateRef = (0,
|
|
1561
|
+
const [state, setState] = (0, import_react7.useState)(INITIAL_STATE);
|
|
1562
|
+
const stateRef = (0, import_react7.useRef)(state);
|
|
1361
1563
|
stateRef.current = state;
|
|
1362
|
-
const balanceRefetchedForRef = (0,
|
|
1363
|
-
(0,
|
|
1564
|
+
const balanceRefetchedForRef = (0, import_react7.useRef)(null);
|
|
1565
|
+
(0, import_react7.useEffect)(() => {
|
|
1364
1566
|
setState(INITIAL_STATE);
|
|
1365
1567
|
}, [withdrawalId]);
|
|
1366
|
-
(0,
|
|
1568
|
+
(0, import_react7.useEffect)(() => {
|
|
1367
1569
|
if (!withdrawalId) return;
|
|
1368
1570
|
let cancelled = false;
|
|
1369
1571
|
(() => __async(null, null, function* () {
|
|
@@ -1382,17 +1584,19 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
1382
1584
|
cancelled = true;
|
|
1383
1585
|
};
|
|
1384
1586
|
}, [client, withdrawalId, wsConnected]);
|
|
1385
|
-
const handler = (0,
|
|
1587
|
+
const handler = (0, import_react7.useMemo)(() => {
|
|
1386
1588
|
if (!withdrawalId) return null;
|
|
1387
1589
|
return (msg) => {
|
|
1388
1590
|
if (msg.withdrawalId !== withdrawalId) return;
|
|
1389
1591
|
setState((prev) => {
|
|
1390
|
-
var _a, _b;
|
|
1592
|
+
var _a, _b, _c, _d;
|
|
1391
1593
|
return {
|
|
1392
1594
|
pending: false,
|
|
1393
1595
|
status: msg.status,
|
|
1596
|
+
requestedAmountRaw: (_a = msg.requestedAmountRaw) != null ? _a : prev.requestedAmountRaw,
|
|
1597
|
+
completedAmountRaw: (_b = msg.completedAmountRaw) != null ? _b : prev.completedAmountRaw,
|
|
1394
1598
|
terminal: msg.terminal,
|
|
1395
|
-
lastLeg: (
|
|
1599
|
+
lastLeg: (_c = msg.leg) != null ? _c : null,
|
|
1396
1600
|
// `legs[]` is the cumulative server-known truth. Snapshots
|
|
1397
1601
|
// (`pending` / terminal rollup) carry a full `legs[]` and replace
|
|
1398
1602
|
// it. Intermediate per-leg deltas carry only `leg` (no `legs[]`)
|
|
@@ -1400,29 +1604,30 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
1400
1604
|
// (sourceChainId, destChainId, type) so the timeline UI doesn't
|
|
1401
1605
|
// collapse to empty between snapshots.
|
|
1402
1606
|
legs: mergeLegs(prev.legs, msg.legs, msg.leg),
|
|
1403
|
-
errorMessage: (
|
|
1607
|
+
errorMessage: (_d = msg.errorMessage) != null ? _d : null,
|
|
1404
1608
|
timestamp: msg.timestamp
|
|
1405
1609
|
};
|
|
1406
1610
|
});
|
|
1407
1611
|
};
|
|
1408
1612
|
}, [withdrawalId]);
|
|
1409
1613
|
useOnWithdrawalLifecycle(handler);
|
|
1410
|
-
(0,
|
|
1614
|
+
(0, import_react7.useEffect)(() => {
|
|
1411
1615
|
if (!withdrawalId) return;
|
|
1412
1616
|
if (!state.terminal) return;
|
|
1413
1617
|
if (balanceRefetchedForRef.current === withdrawalId) return;
|
|
1414
1618
|
balanceRefetchedForRef.current = withdrawalId;
|
|
1415
|
-
|
|
1619
|
+
invalidateUserMoneyState(queryClient);
|
|
1416
1620
|
client.syncManagedBalances().catch(() => {
|
|
1417
1621
|
});
|
|
1418
1622
|
}, [client, queryClient, state.terminal, withdrawalId]);
|
|
1419
|
-
const reset = (0,
|
|
1623
|
+
const reset = (0, import_react7.useCallback)(() => setState(INITIAL_STATE), []);
|
|
1420
1624
|
return { state, reset };
|
|
1421
1625
|
}
|
|
1422
1626
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1423
1627
|
0 && (module.exports = {
|
|
1424
1628
|
useDepositAddresses,
|
|
1425
1629
|
useManagedBalances,
|
|
1630
|
+
useWithdrawEstimate,
|
|
1426
1631
|
useWithdrawFlow,
|
|
1427
1632
|
useWithdrawManaged,
|
|
1428
1633
|
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-V34QGQBO.mjs";
|
|
5
6
|
import {
|
|
6
7
|
useDepositAddresses,
|
|
7
8
|
useManagedBalances,
|
|
8
9
|
useWithdrawManaged
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2C7JR5OH.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.
|
|
3
|
+
"version": "1.2.12",
|
|
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.
|
|
86
|
+
"@agg-build/sdk": "^1.2.11"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@solana/wallet-adapter-react": {
|