@agg-build/hooks 1.0.0 → 1.0.1
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-CDPQERUC.mjs → chunk-BWXNOWAS.mjs} +99 -36
- package/dist/chunk-PALQVBAQ.mjs +31 -0
- package/dist/chunk-QXBQRWFF.mjs +389 -0
- package/dist/deposit.d.mts +2 -1
- package/dist/deposit.d.ts +2 -1
- package/dist/deposit.js +57 -2
- package/dist/deposit.mjs +5 -3
- package/dist/index.d.mts +71 -193
- package/dist/index.d.ts +71 -193
- package/dist/index.js +663 -167
- package/dist/index.mjs +78 -37
- package/dist/{use-sync-balances-D1Jdkck9.d.mts → use-deposit-addresses-B9ICS-3U.d.mts} +1 -11
- package/dist/{use-sync-balances-D1Jdkck9.d.ts → use-deposit-addresses-B9ICS-3U.d.ts} +1 -11
- package/dist/use-sync-balances-B1_8tBKw.d.mts +14 -0
- package/dist/use-sync-balances-B1_8tBKw.d.ts +14 -0
- package/dist/withdraw.d.mts +293 -0
- package/dist/withdraw.d.ts +293 -0
- package/dist/withdraw.js +1402 -0
- package/dist/withdraw.mjs +16 -0
- package/package.json +15 -2
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useRampQuotes,
|
|
3
|
+
useRampSession
|
|
4
|
+
} from "./chunk-PALQVBAQ.mjs";
|
|
5
|
+
import {
|
|
6
|
+
useWithdrawFlow,
|
|
7
|
+
useWithdrawalLifecycle
|
|
8
|
+
} from "./chunk-QXBQRWFF.mjs";
|
|
1
9
|
import {
|
|
2
10
|
AggAuthContext,
|
|
3
11
|
AggBalanceProvider,
|
|
@@ -65,17 +73,16 @@ import {
|
|
|
65
73
|
useOnBalanceUpdate,
|
|
66
74
|
useOnOrderSubmitted,
|
|
67
75
|
useOnRedeemEvent,
|
|
76
|
+
useOnWithdrawalLifecycle,
|
|
68
77
|
usePositions,
|
|
69
78
|
useQuoteManaged,
|
|
70
|
-
useRampQuotes,
|
|
71
|
-
useRampSession,
|
|
72
79
|
useRedeem,
|
|
73
80
|
useRedeemEligibleCount,
|
|
74
81
|
useSdkLabels,
|
|
75
82
|
useSdkUiConfig,
|
|
76
83
|
useSyncBalances,
|
|
77
84
|
useWithdrawManaged
|
|
78
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-BWXNOWAS.mjs";
|
|
79
86
|
|
|
80
87
|
// src/index.ts
|
|
81
88
|
import { QueryClient as QueryClient4, QueryClientProvider, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
@@ -833,7 +840,9 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
833
840
|
continue;
|
|
834
841
|
}
|
|
835
842
|
const liveMidpoint = liveByOutcomeId.get(outcome.id);
|
|
836
|
-
|
|
843
|
+
if (liveMidpoint != null) {
|
|
844
|
+
prices.set(outcome.id, liveMidpoint);
|
|
845
|
+
}
|
|
837
846
|
}
|
|
838
847
|
}
|
|
839
848
|
prevRef.current = { fingerprint, prices };
|
|
@@ -881,29 +890,43 @@ function useMidpoints(venueMarkets) {
|
|
|
881
890
|
refetchOnWindowFocus: false,
|
|
882
891
|
refetchOnReconnect: false
|
|
883
892
|
});
|
|
884
|
-
const
|
|
885
|
-
var _a, _b, _c, _d;
|
|
893
|
+
const result = useMemo7(() => {
|
|
894
|
+
var _a, _b, _c, _d, _e, _f;
|
|
886
895
|
const map = /* @__PURE__ */ new Map();
|
|
887
|
-
|
|
896
|
+
const venueMap = /* @__PURE__ */ new Map();
|
|
897
|
+
if (!(data == null ? void 0 : data.data) || !venueMarkets) return { map, venueMap };
|
|
888
898
|
for (const item of data.data) {
|
|
889
899
|
if ((_a = item.outcomes) == null ? void 0 : _a.length) {
|
|
890
900
|
for (const o of item.outcomes) {
|
|
891
901
|
if (o.midpoint != null) {
|
|
892
902
|
map.set(o.venueMarketOutcomeId, o.midpoint);
|
|
903
|
+
if (item.venue) venueMap.set(o.venueMarketOutcomeId, item.venue);
|
|
893
904
|
}
|
|
894
905
|
}
|
|
895
906
|
if ((_b = item.matched) == null ? void 0 : _b.length) {
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
907
|
+
const market = venueMarkets.find((vm) => vm.id === item.venueMarketId);
|
|
908
|
+
if (market) {
|
|
909
|
+
const primaryYesOutcome = market.venueMarketOutcomes.find(
|
|
910
|
+
(o) => {
|
|
911
|
+
var _a2;
|
|
912
|
+
return ((_a2 = o.label) == null ? void 0 : _a2.toLowerCase()) === "yes";
|
|
913
|
+
}
|
|
914
|
+
);
|
|
915
|
+
const primaryYesMidpoint = primaryYesOutcome ? (_c = map.get(primaryYesOutcome.id)) != null ? _c : null : null;
|
|
916
|
+
let bestMatchedMidpoint = null;
|
|
917
|
+
let bestMatchedVenue = null;
|
|
918
|
+
for (const m of item.matched) {
|
|
919
|
+
if (m.midpoint == null) continue;
|
|
920
|
+
if (bestMatchedMidpoint == null || m.midpoint < bestMatchedMidpoint) {
|
|
921
|
+
bestMatchedMidpoint = m.midpoint;
|
|
922
|
+
bestMatchedVenue = (_d = m.venue) != null ? _d : null;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
if (bestMatchedMidpoint != null && (primaryYesMidpoint == null || bestMatchedMidpoint < primaryYesMidpoint)) {
|
|
900
926
|
for (const outcome of market.venueMarketOutcomes) {
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
if (existing == null || isYes && matchedPrice > existing || !isYes && matchedPrice < existing) {
|
|
905
|
-
map.set(outcome.id, matchedPrice);
|
|
906
|
-
}
|
|
927
|
+
const isYes = ((_e = outcome.label) == null ? void 0 : _e.toLowerCase()) === "yes";
|
|
928
|
+
map.set(outcome.id, isYes ? bestMatchedMidpoint : 1 - bestMatchedMidpoint);
|
|
929
|
+
if (bestMatchedVenue) venueMap.set(outcome.id, bestMatchedVenue);
|
|
907
930
|
}
|
|
908
931
|
}
|
|
909
932
|
}
|
|
@@ -914,14 +937,19 @@ function useMidpoints(venueMarkets) {
|
|
|
914
937
|
const market = venueMarkets.find((vm) => vm.id === item.venueMarketId);
|
|
915
938
|
if (!market) continue;
|
|
916
939
|
for (const outcome of market.venueMarketOutcomes) {
|
|
917
|
-
const isYes = ((
|
|
940
|
+
const isYes = ((_f = outcome.label) == null ? void 0 : _f.toLowerCase()) === "yes";
|
|
918
941
|
map.set(outcome.id, isYes ? item.midpoint : 1 - item.midpoint);
|
|
942
|
+
if (item.venue) venueMap.set(outcome.id, item.venue);
|
|
919
943
|
}
|
|
920
944
|
}
|
|
921
945
|
}
|
|
922
|
-
return map;
|
|
946
|
+
return { map, venueMap };
|
|
923
947
|
}, [data, venueMarkets]);
|
|
924
|
-
return {
|
|
948
|
+
return {
|
|
949
|
+
prices: result.map,
|
|
950
|
+
venueByOutcomeId: result.venueMap,
|
|
951
|
+
isLoading: isLoading && ids.length > 0
|
|
952
|
+
};
|
|
925
953
|
}
|
|
926
954
|
|
|
927
955
|
// src/use-market-orderbook.ts
|
|
@@ -1593,6 +1621,7 @@ function useVenueEvents(options) {
|
|
|
1593
1621
|
if (!lastPage.hasMore) return void 0;
|
|
1594
1622
|
return (_a2 = lastPage.nextCursor) != null ? _a2 : void 0;
|
|
1595
1623
|
},
|
|
1624
|
+
// TODO: RMIK - Comment out to show skeletons on category switch
|
|
1596
1625
|
placeholderData: keepPreviousData6,
|
|
1597
1626
|
enabled: enabled && !!client
|
|
1598
1627
|
},
|
|
@@ -1736,19 +1765,21 @@ var resolveUncachedVisibleMarketIds = (visibleMarkets, cache, inFlightIds) => {
|
|
|
1736
1765
|
return idsToFetch;
|
|
1737
1766
|
};
|
|
1738
1767
|
var buildCachedMidpointEntries = (requestedVenueMarketIds, rows) => {
|
|
1739
|
-
var _a, _b;
|
|
1768
|
+
var _a, _b, _c;
|
|
1740
1769
|
const rowsByVenueMarketId = new Map(rows.map((item) => [item.venueMarketId, item]));
|
|
1741
1770
|
const nextCacheEntries = /* @__PURE__ */ new Map();
|
|
1742
1771
|
for (const venueMarketId of requestedVenueMarketIds) {
|
|
1743
1772
|
const item = rowsByVenueMarketId.get(venueMarketId);
|
|
1744
1773
|
nextCacheEntries.set(venueMarketId, {
|
|
1745
1774
|
midpoint: (_a = item == null ? void 0 : item.midpoint) != null ? _a : null,
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1775
|
+
spread: (_b = item == null ? void 0 : item.spread) != null ? _b : null,
|
|
1776
|
+
matched: ((_c = item == null ? void 0 : item.matched) != null ? _c : []).map((matched) => {
|
|
1777
|
+
var _a2, _b2;
|
|
1778
|
+
return __spreadValues({
|
|
1749
1779
|
venueMarketId: matched.venueMarketId,
|
|
1750
|
-
midpoint: (_a2 = matched.midpoint) != null ? _a2 : null
|
|
1751
|
-
|
|
1780
|
+
midpoint: (_a2 = matched.midpoint) != null ? _a2 : null,
|
|
1781
|
+
spread: (_b2 = matched.spread) != null ? _b2 : null
|
|
1782
|
+
}, matched.venue ? { venue: matched.venue } : {});
|
|
1752
1783
|
})
|
|
1753
1784
|
});
|
|
1754
1785
|
}
|
|
@@ -1788,25 +1819,32 @@ function useViewportMidpoints(visibleMarkets) {
|
|
|
1788
1819
|
cancelled = true;
|
|
1789
1820
|
};
|
|
1790
1821
|
}, [visibleFp, cache]);
|
|
1791
|
-
const prices = useMemo10(() => {
|
|
1792
|
-
var _a;
|
|
1822
|
+
const { prices, venueByOutcomeId } = useMemo10(() => {
|
|
1823
|
+
var _a, _b;
|
|
1793
1824
|
const map = /* @__PURE__ */ new Map();
|
|
1825
|
+
const venueMap = /* @__PURE__ */ new Map();
|
|
1794
1826
|
for (const market of visibleMarkets) {
|
|
1795
1827
|
const entry = cache.get(market.id);
|
|
1796
1828
|
if (!entry) continue;
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
for (const m of entry.matched)
|
|
1800
|
-
|
|
1801
|
-
|
|
1829
|
+
let mid = entry.midpoint;
|
|
1830
|
+
let midVenue = market.venue;
|
|
1831
|
+
for (const m of entry.matched) {
|
|
1832
|
+
if (m.midpoint == null) continue;
|
|
1833
|
+
if (mid == null || m.midpoint < mid) {
|
|
1834
|
+
mid = m.midpoint;
|
|
1835
|
+
midVenue = (_a = m.venue) != null ? _a : market.venue;
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
if (mid == null) continue;
|
|
1802
1839
|
for (const outcome of market.venueMarketOutcomes) {
|
|
1803
|
-
const isYes = ((
|
|
1840
|
+
const isYes = ((_b = outcome.label) == null ? void 0 : _b.toLowerCase()) === "yes";
|
|
1804
1841
|
map.set(outcome.id, isYes ? mid : 1 - mid);
|
|
1842
|
+
venueMap.set(outcome.id, midVenue);
|
|
1805
1843
|
}
|
|
1806
1844
|
}
|
|
1807
|
-
return map;
|
|
1845
|
+
return { prices: map, venueByOutcomeId: venueMap };
|
|
1808
1846
|
}, [cache, visibleMarkets]);
|
|
1809
|
-
return { prices };
|
|
1847
|
+
return { prices, venueByOutcomeId };
|
|
1810
1848
|
}
|
|
1811
1849
|
|
|
1812
1850
|
// src/use-visible-ids.ts
|
|
@@ -1983,6 +2021,7 @@ export {
|
|
|
1983
2021
|
useOnBalanceUpdate,
|
|
1984
2022
|
useOnOrderSubmitted,
|
|
1985
2023
|
useOnRedeemEvent,
|
|
2024
|
+
useOnWithdrawalLifecycle,
|
|
1986
2025
|
useOrderBook,
|
|
1987
2026
|
useOrderbookQuote,
|
|
1988
2027
|
useOrders,
|
|
@@ -2006,5 +2045,7 @@ export {
|
|
|
2006
2045
|
useVenueMarkets,
|
|
2007
2046
|
useViewportMidpoints,
|
|
2008
2047
|
useVisibleIds,
|
|
2009
|
-
|
|
2048
|
+
useWithdrawFlow,
|
|
2049
|
+
useWithdrawManaged,
|
|
2050
|
+
useWithdrawalLifecycle
|
|
2010
2051
|
};
|
|
@@ -233,14 +233,4 @@ declare function useDepositAddresses(options?: UseDepositAddressesOptions): {
|
|
|
233
233
|
promise: Promise<DepositAddressesResponse>;
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
-
|
|
237
|
-
onSuccess?: () => void;
|
|
238
|
-
onError?: (error: Error) => void;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Mutation hook for triggering an on-chain balance sync.
|
|
242
|
-
* On success, invalidates balances queries.
|
|
243
|
-
*/
|
|
244
|
-
declare function useSyncBalances(options?: UseSyncBalancesOptions): _tanstack_react_query.UseMutationResult<_agg_build_sdk.SyncBalancesResponse, Error, void, unknown>;
|
|
245
|
-
|
|
246
|
-
export { type UseDepositAddressesOptions as U, type UseSyncBalancesOptions as a, useSyncBalances as b, getDepositAddress as g, useDepositAddresses as u };
|
|
236
|
+
export { type UseDepositAddressesOptions as U, getDepositAddress as g, useDepositAddresses as u };
|
|
@@ -233,14 +233,4 @@ declare function useDepositAddresses(options?: UseDepositAddressesOptions): {
|
|
|
233
233
|
promise: Promise<DepositAddressesResponse>;
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
-
|
|
237
|
-
onSuccess?: () => void;
|
|
238
|
-
onError?: (error: Error) => void;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Mutation hook for triggering an on-chain balance sync.
|
|
242
|
-
* On success, invalidates balances queries.
|
|
243
|
-
*/
|
|
244
|
-
declare function useSyncBalances(options?: UseSyncBalancesOptions): _tanstack_react_query.UseMutationResult<_agg_build_sdk.SyncBalancesResponse, Error, void, unknown>;
|
|
245
|
-
|
|
246
|
-
export { type UseDepositAddressesOptions as U, type UseSyncBalancesOptions as a, useSyncBalances as b, getDepositAddress as g, useDepositAddresses as u };
|
|
236
|
+
export { type UseDepositAddressesOptions as U, getDepositAddress as g, useDepositAddresses as u };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import * as _agg_build_sdk from '@agg-build/sdk';
|
|
3
|
+
|
|
4
|
+
interface UseSyncBalancesOptions {
|
|
5
|
+
onSuccess?: () => void;
|
|
6
|
+
onError?: (error: Error) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Mutation hook for triggering an on-chain balance sync.
|
|
10
|
+
* On success, invalidates balances queries.
|
|
11
|
+
*/
|
|
12
|
+
declare function useSyncBalances(options?: UseSyncBalancesOptions): _tanstack_react_query.UseMutationResult<_agg_build_sdk.SyncBalancesResponse, Error, void, unknown>;
|
|
13
|
+
|
|
14
|
+
export { type UseSyncBalancesOptions as U, useSyncBalances as u };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import * as _agg_build_sdk from '@agg-build/sdk';
|
|
3
|
+
|
|
4
|
+
interface UseSyncBalancesOptions {
|
|
5
|
+
onSuccess?: () => void;
|
|
6
|
+
onError?: (error: Error) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Mutation hook for triggering an on-chain balance sync.
|
|
10
|
+
* On success, invalidates balances queries.
|
|
11
|
+
*/
|
|
12
|
+
declare function useSyncBalances(options?: UseSyncBalancesOptions): _tanstack_react_query.UseMutationResult<_agg_build_sdk.SyncBalancesResponse, Error, void, unknown>;
|
|
13
|
+
|
|
14
|
+
export { type UseSyncBalancesOptions as U, useSyncBalances as u };
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import * as _agg_build_sdk from '@agg-build/sdk';
|
|
2
|
+
import { WsWithdrawalLifecycleStatus, WsWithdrawalLifecycleLeg, WithdrawManagedResponse, WithdrawManagedParams } from '@agg-build/sdk';
|
|
3
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
|
+
export { U as UseDepositAddressesOptions, u as useDepositAddresses } from './use-deposit-addresses-B9ICS-3U.mjs';
|
|
5
|
+
|
|
6
|
+
type WithdrawSelectOption = {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
};
|
|
10
|
+
type WithdrawSummary = {
|
|
11
|
+
/**
|
|
12
|
+
* The amount the user submitted for withdrawal — NOT a confirmed payout
|
|
13
|
+
* figure. The API today returns `pricingStatus: "unquoted"` with no fee
|
|
14
|
+
* or net-output guarantee, so labeling this "received" was misleading.
|
|
15
|
+
* The label string is "Amount" until the multi-stable quote layer ships.
|
|
16
|
+
*/
|
|
17
|
+
amountReceived: string;
|
|
18
|
+
network: string;
|
|
19
|
+
toWallet: string;
|
|
20
|
+
fees: string;
|
|
21
|
+
};
|
|
22
|
+
interface UseWithdrawFlowResult {
|
|
23
|
+
open: boolean;
|
|
24
|
+
onOpenChange: (open: boolean) => void;
|
|
25
|
+
withdrawFlow: {
|
|
26
|
+
balance: number;
|
|
27
|
+
balanceDisplay: string;
|
|
28
|
+
amount: string;
|
|
29
|
+
destinationWallet: string;
|
|
30
|
+
tokenOptions: WithdrawSelectOption[];
|
|
31
|
+
networkOptions: WithdrawSelectOption[];
|
|
32
|
+
selectedToken: string;
|
|
33
|
+
selectedNetwork: string;
|
|
34
|
+
purchaseSummary: WithdrawSummary;
|
|
35
|
+
/**
|
|
36
|
+
* The id returned by `POST /execution/withdraw-managed` once the user
|
|
37
|
+
* has submitted the flow — used by the success step to subscribe to
|
|
38
|
+
* `withdrawal_lifecycle` WS events. `null` until submission succeeds
|
|
39
|
+
* and reset to `null` when the modal closes.
|
|
40
|
+
*/
|
|
41
|
+
withdrawalId: string | null;
|
|
42
|
+
};
|
|
43
|
+
onWithdrawDestinationChange: (address: string) => void;
|
|
44
|
+
onWithdrawAmountChange: (amount: string) => void;
|
|
45
|
+
onWithdrawTokenChange: (token: string) => void;
|
|
46
|
+
onWithdrawNetworkChange: (network: string) => void;
|
|
47
|
+
onMaxClick: () => void;
|
|
48
|
+
onSelectWithdrawProvider: (providerId: string) => Promise<void>;
|
|
49
|
+
onDoneWithdraw: () => void;
|
|
50
|
+
}
|
|
51
|
+
interface UseWithdrawFlowOptions {
|
|
52
|
+
open: boolean;
|
|
53
|
+
onOpenChange: (open: boolean) => void;
|
|
54
|
+
}
|
|
55
|
+
declare function useWithdrawFlow(options: UseWithdrawFlowOptions): UseWithdrawFlowResult;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Latest lifecycle snapshot for a single withdrawal, materialized from the
|
|
59
|
+
* most recent `WsWithdrawalLifecycleEvent` whose `withdrawalId` matches.
|
|
60
|
+
*
|
|
61
|
+
* The wire format is intentionally additive (legs may arrive partial), so
|
|
62
|
+
* `legs` reflects the latest snapshot the server emitted — earlier per-leg
|
|
63
|
+
* deltas are not re-merged on the client. Consumers should treat `legs` as
|
|
64
|
+
* "last known truth" rather than a derived rollup.
|
|
65
|
+
*/
|
|
66
|
+
interface WithdrawalLifecycleState {
|
|
67
|
+
/** True until the first lifecycle event for this withdrawal arrives. */
|
|
68
|
+
pending: boolean;
|
|
69
|
+
/** Top-level status, or `null` until the first event arrives. */
|
|
70
|
+
status: WsWithdrawalLifecycleStatus | null;
|
|
71
|
+
/** Whether `status` is a terminal state (`completed` / `partial` / `failed`). */
|
|
72
|
+
terminal: boolean;
|
|
73
|
+
/** Last leg delta (the leg whose flip triggered the most recent event). */
|
|
74
|
+
lastLeg: WsWithdrawalLifecycleLeg | null;
|
|
75
|
+
/** All legs at the moment of the most recent event (server snapshot). */
|
|
76
|
+
legs: WsWithdrawalLifecycleLeg[];
|
|
77
|
+
/** Failure reason for terminal `failed` / `partial`. */
|
|
78
|
+
errorMessage: string | null;
|
|
79
|
+
/** Server timestamp (ms) of the most recent event. */
|
|
80
|
+
timestamp: number | null;
|
|
81
|
+
}
|
|
82
|
+
interface UseWithdrawalLifecycleResult {
|
|
83
|
+
/** Latest lifecycle snapshot for the watched `withdrawalId`. */
|
|
84
|
+
state: WithdrawalLifecycleState;
|
|
85
|
+
/** Reset to the initial pre-event state — call when the modal is closed or a new flow starts. */
|
|
86
|
+
reset: () => void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Subscribes to `withdrawal_lifecycle` WS events for a single `withdrawalId`
|
|
90
|
+
* and exposes the latest snapshot. Returns a stable `pending` initial state
|
|
91
|
+
* until the first matching event arrives.
|
|
92
|
+
*
|
|
93
|
+
* Pass `null` for `withdrawalId` to disable the subscription (e.g. before
|
|
94
|
+
* the user has submitted a withdrawal). Switching the `withdrawalId` resets
|
|
95
|
+
* the state so a stale snapshot from a prior withdrawal can never bleed
|
|
96
|
+
* across.
|
|
97
|
+
*
|
|
98
|
+
* **Backfill behavior**: on mount with a non-null `withdrawalId`, and again
|
|
99
|
+
* whenever the WS connection re-opens, the hook calls
|
|
100
|
+
* `GET /execution/withdrawals/:id` to recover any lifecycle events that fired
|
|
101
|
+
* before the listener was attached or while the socket was disconnected. WS
|
|
102
|
+
* events always win over REST snapshots (REST stamps as `timestamp: 0`), so a
|
|
103
|
+
* race between the two never regresses to a stale state.
|
|
104
|
+
*/
|
|
105
|
+
declare function useWithdrawalLifecycle(withdrawalId: string | null): UseWithdrawalLifecycleResult;
|
|
106
|
+
|
|
107
|
+
interface UseWithdrawManagedOptions {
|
|
108
|
+
onSuccess?: (data: WithdrawManagedResponse) => void;
|
|
109
|
+
onError?: (error: Error) => void;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Mutation hook for withdrawing funds from managed wallets.
|
|
113
|
+
* On success, invalidates balances queries.
|
|
114
|
+
*/
|
|
115
|
+
declare function useWithdrawManaged(options?: UseWithdrawManagedOptions): _tanstack_react_query.UseMutationResult<WithdrawManagedResponse, Error, WithdrawManagedParams, unknown>;
|
|
116
|
+
|
|
117
|
+
interface UseManagedBalancesOptions {
|
|
118
|
+
enabled?: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Query hook for fetching unified managed wallet balances across all chains.
|
|
122
|
+
*/
|
|
123
|
+
declare function useManagedBalances(options?: UseManagedBalancesOptions): {
|
|
124
|
+
balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
|
|
125
|
+
data: _agg_build_sdk.UnifiedBalanceResponse;
|
|
126
|
+
error: Error;
|
|
127
|
+
isError: true;
|
|
128
|
+
isPending: false;
|
|
129
|
+
isLoading: false;
|
|
130
|
+
isLoadingError: false;
|
|
131
|
+
isRefetchError: true;
|
|
132
|
+
isSuccess: false;
|
|
133
|
+
isPlaceholderData: false;
|
|
134
|
+
status: "error";
|
|
135
|
+
dataUpdatedAt: number;
|
|
136
|
+
errorUpdatedAt: number;
|
|
137
|
+
failureCount: number;
|
|
138
|
+
failureReason: Error | null;
|
|
139
|
+
errorUpdateCount: number;
|
|
140
|
+
isFetched: boolean;
|
|
141
|
+
isFetchedAfterMount: boolean;
|
|
142
|
+
isFetching: boolean;
|
|
143
|
+
isInitialLoading: boolean;
|
|
144
|
+
isPaused: boolean;
|
|
145
|
+
isRefetching: boolean;
|
|
146
|
+
isStale: boolean;
|
|
147
|
+
isEnabled: boolean;
|
|
148
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
|
|
149
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
150
|
+
promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
|
|
151
|
+
} | {
|
|
152
|
+
balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
|
|
153
|
+
data: _agg_build_sdk.UnifiedBalanceResponse;
|
|
154
|
+
error: null;
|
|
155
|
+
isError: false;
|
|
156
|
+
isPending: false;
|
|
157
|
+
isLoading: false;
|
|
158
|
+
isLoadingError: false;
|
|
159
|
+
isRefetchError: false;
|
|
160
|
+
isSuccess: true;
|
|
161
|
+
isPlaceholderData: false;
|
|
162
|
+
status: "success";
|
|
163
|
+
dataUpdatedAt: number;
|
|
164
|
+
errorUpdatedAt: number;
|
|
165
|
+
failureCount: number;
|
|
166
|
+
failureReason: Error | null;
|
|
167
|
+
errorUpdateCount: number;
|
|
168
|
+
isFetched: boolean;
|
|
169
|
+
isFetchedAfterMount: boolean;
|
|
170
|
+
isFetching: boolean;
|
|
171
|
+
isInitialLoading: boolean;
|
|
172
|
+
isPaused: boolean;
|
|
173
|
+
isRefetching: boolean;
|
|
174
|
+
isStale: boolean;
|
|
175
|
+
isEnabled: boolean;
|
|
176
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
|
|
177
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
178
|
+
promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
|
|
179
|
+
} | {
|
|
180
|
+
balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
|
|
181
|
+
data: undefined;
|
|
182
|
+
error: Error;
|
|
183
|
+
isError: true;
|
|
184
|
+
isPending: false;
|
|
185
|
+
isLoading: false;
|
|
186
|
+
isLoadingError: true;
|
|
187
|
+
isRefetchError: false;
|
|
188
|
+
isSuccess: false;
|
|
189
|
+
isPlaceholderData: false;
|
|
190
|
+
status: "error";
|
|
191
|
+
dataUpdatedAt: number;
|
|
192
|
+
errorUpdatedAt: number;
|
|
193
|
+
failureCount: number;
|
|
194
|
+
failureReason: Error | null;
|
|
195
|
+
errorUpdateCount: number;
|
|
196
|
+
isFetched: boolean;
|
|
197
|
+
isFetchedAfterMount: boolean;
|
|
198
|
+
isFetching: boolean;
|
|
199
|
+
isInitialLoading: boolean;
|
|
200
|
+
isPaused: boolean;
|
|
201
|
+
isRefetching: boolean;
|
|
202
|
+
isStale: boolean;
|
|
203
|
+
isEnabled: boolean;
|
|
204
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
|
|
205
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
206
|
+
promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
|
|
207
|
+
} | {
|
|
208
|
+
balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
|
|
209
|
+
data: undefined;
|
|
210
|
+
error: null;
|
|
211
|
+
isError: false;
|
|
212
|
+
isPending: true;
|
|
213
|
+
isLoading: true;
|
|
214
|
+
isLoadingError: false;
|
|
215
|
+
isRefetchError: false;
|
|
216
|
+
isSuccess: false;
|
|
217
|
+
isPlaceholderData: false;
|
|
218
|
+
status: "pending";
|
|
219
|
+
dataUpdatedAt: number;
|
|
220
|
+
errorUpdatedAt: number;
|
|
221
|
+
failureCount: number;
|
|
222
|
+
failureReason: Error | null;
|
|
223
|
+
errorUpdateCount: number;
|
|
224
|
+
isFetched: boolean;
|
|
225
|
+
isFetchedAfterMount: boolean;
|
|
226
|
+
isFetching: boolean;
|
|
227
|
+
isInitialLoading: boolean;
|
|
228
|
+
isPaused: boolean;
|
|
229
|
+
isRefetching: boolean;
|
|
230
|
+
isStale: boolean;
|
|
231
|
+
isEnabled: boolean;
|
|
232
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
|
|
233
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
234
|
+
promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
|
|
235
|
+
} | {
|
|
236
|
+
balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
|
|
237
|
+
data: undefined;
|
|
238
|
+
error: null;
|
|
239
|
+
isError: false;
|
|
240
|
+
isPending: true;
|
|
241
|
+
isLoadingError: false;
|
|
242
|
+
isRefetchError: false;
|
|
243
|
+
isSuccess: false;
|
|
244
|
+
isPlaceholderData: false;
|
|
245
|
+
status: "pending";
|
|
246
|
+
dataUpdatedAt: number;
|
|
247
|
+
errorUpdatedAt: number;
|
|
248
|
+
failureCount: number;
|
|
249
|
+
failureReason: Error | null;
|
|
250
|
+
errorUpdateCount: number;
|
|
251
|
+
isFetched: boolean;
|
|
252
|
+
isFetchedAfterMount: boolean;
|
|
253
|
+
isFetching: boolean;
|
|
254
|
+
isLoading: boolean;
|
|
255
|
+
isInitialLoading: boolean;
|
|
256
|
+
isPaused: boolean;
|
|
257
|
+
isRefetching: boolean;
|
|
258
|
+
isStale: boolean;
|
|
259
|
+
isEnabled: boolean;
|
|
260
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
|
|
261
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
262
|
+
promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
|
|
263
|
+
} | {
|
|
264
|
+
balances: _agg_build_sdk.UnifiedBalanceResponse | undefined;
|
|
265
|
+
data: _agg_build_sdk.UnifiedBalanceResponse;
|
|
266
|
+
isError: false;
|
|
267
|
+
error: null;
|
|
268
|
+
isPending: false;
|
|
269
|
+
isLoading: false;
|
|
270
|
+
isLoadingError: false;
|
|
271
|
+
isRefetchError: false;
|
|
272
|
+
isSuccess: true;
|
|
273
|
+
isPlaceholderData: true;
|
|
274
|
+
status: "success";
|
|
275
|
+
dataUpdatedAt: number;
|
|
276
|
+
errorUpdatedAt: number;
|
|
277
|
+
failureCount: number;
|
|
278
|
+
failureReason: Error | null;
|
|
279
|
+
errorUpdateCount: number;
|
|
280
|
+
isFetched: boolean;
|
|
281
|
+
isFetchedAfterMount: boolean;
|
|
282
|
+
isFetching: boolean;
|
|
283
|
+
isInitialLoading: boolean;
|
|
284
|
+
isPaused: boolean;
|
|
285
|
+
isRefetching: boolean;
|
|
286
|
+
isStale: boolean;
|
|
287
|
+
isEnabled: boolean;
|
|
288
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_agg_build_sdk.UnifiedBalanceResponse, Error>>;
|
|
289
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
290
|
+
promise: Promise<_agg_build_sdk.UnifiedBalanceResponse>;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export { type UseManagedBalancesOptions, type UseWithdrawFlowOptions, type UseWithdrawFlowResult, type UseWithdrawManagedOptions, type UseWithdrawalLifecycleResult, type WithdrawalLifecycleState, useManagedBalances, useWithdrawFlow, useWithdrawManaged, useWithdrawalLifecycle };
|