@agg-build/hooks 2.0.0 → 2.1.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-OBHXWQ6L.mjs → chunk-5P53A3NQ.mjs} +88 -27
- package/dist/{chunk-KXO3JOXF.mjs → chunk-AFZD3GIQ.mjs} +1 -1
- package/dist/{chunk-VLYLQSDD.mjs → chunk-FYEPQHKO.mjs} +42 -14
- package/dist/deposit.d.mts +5 -1
- package/dist/deposit.d.ts +5 -1
- package/dist/deposit.js +245 -181
- package/dist/deposit.mjs +176 -131
- package/dist/index.d.mts +50 -4
- package/dist/index.d.ts +50 -4
- package/dist/index.js +236 -141
- package/dist/index.mjs +48 -40
- package/dist/withdraw.d.mts +31 -2
- package/dist/withdraw.d.ts +31 -2
- package/dist/withdraw.js +106 -28
- package/dist/withdraw.mjs +4 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -336,7 +336,7 @@ Import from `@agg-build/hooks/deposit` to keep wallet-heavy hooks out of your ma
|
|
|
336
336
|
- `enableLogs` / `enableWebsocketsLogs` — turn on debug logging
|
|
337
337
|
- `general` — `locale`, `theme` (`"light" | "dark"`), `rootClassName`, `labels`
|
|
338
338
|
- `features` — `showVenueLogo`, `enableAnimations`, `enableLiveUpdates`, `showFeesBreakdown`, `enableGradients`
|
|
339
|
-
- `market` — `arbitrageThreshold`
|
|
339
|
+
- `market` — `arbitrageThreshold`, `maxMidpointIdsPerRequest` for proxy/CDN-safe midpoint batching
|
|
340
340
|
- `chart` — `defaultChartTimeRange`, `selectedChartTimeRange`
|
|
341
341
|
- `search` — provider-owned search state + callbacks for host-app routing/analytics
|
|
342
342
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__async,
|
|
3
|
+
__spreadValues,
|
|
3
4
|
invalidateUserMoneyState,
|
|
4
5
|
useAggBalanceState,
|
|
5
6
|
useAggClient,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
useOnWithdrawalLifecycle,
|
|
11
12
|
useSyncBalances,
|
|
12
13
|
useWithdrawManaged
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-FYEPQHKO.mjs";
|
|
14
15
|
|
|
15
16
|
// src/withdraw/use-withdraw-flow.ts
|
|
16
17
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
@@ -36,6 +37,13 @@ var isValidDestinationAddress = (address, chainId) => {
|
|
|
36
37
|
if (chainId === SOLANA_CHAIN_ID) return SOLANA_ADDRESS_REGEX.test(address);
|
|
37
38
|
return EVM_ADDRESS_REGEX.test(address);
|
|
38
39
|
};
|
|
40
|
+
var detectDestinationAddressKind = (address) => {
|
|
41
|
+
const trimmed = address.trim();
|
|
42
|
+
if (!trimmed) return null;
|
|
43
|
+
if (EVM_ADDRESS_REGEX.test(trimmed)) return "evm";
|
|
44
|
+
if (SOLANA_ADDRESS_REGEX.test(trimmed)) return "solana";
|
|
45
|
+
return null;
|
|
46
|
+
};
|
|
39
47
|
var DEFAULT_WITHDRAW_SUMMARY = {
|
|
40
48
|
amountReceived: "",
|
|
41
49
|
network: "",
|
|
@@ -73,7 +81,7 @@ var parseTokenAmountToRaw = (amount, decimals) => {
|
|
|
73
81
|
};
|
|
74
82
|
var shortenAddress = (address) => address.length > 12 ? `${address.slice(0, 6)}...${address.slice(-4)}` : address;
|
|
75
83
|
function useWithdrawFlow(options) {
|
|
76
|
-
var _a, _b;
|
|
84
|
+
var _a, _b, _c, _d, _e;
|
|
77
85
|
const { open, onOpenChange } = options;
|
|
78
86
|
const { totalBalance } = useAggBalanceState();
|
|
79
87
|
const { balances } = useManagedBalances({ enabled: open });
|
|
@@ -94,31 +102,42 @@ function useWithdrawFlow(options) {
|
|
|
94
102
|
const [withdrawNetwork, setWithdrawNetwork] = useState("");
|
|
95
103
|
const [withdrawSummary, setWithdrawSummary] = useState(DEFAULT_WITHDRAW_SUMMARY);
|
|
96
104
|
const [withdrawalId, setWithdrawalId] = useState(null);
|
|
105
|
+
const [isMax, setIsMax] = useState(false);
|
|
106
|
+
const detectedAddressKind = useMemo(
|
|
107
|
+
() => detectDestinationAddressKind(withdrawDestination),
|
|
108
|
+
[withdrawDestination]
|
|
109
|
+
);
|
|
97
110
|
const networkOptions = useMemo(
|
|
98
|
-
() => (supportedChains != null ? supportedChains : []).filter((chain) => WITHDRAWAL_SUPPORTED_CHAIN_IDS.has(chain.chainId)).map((chain) =>
|
|
99
|
-
value
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
() => (supportedChains != null ? supportedChains : []).filter((chain) => WITHDRAWAL_SUPPORTED_CHAIN_IDS.has(chain.chainId)).map((chain) => {
|
|
112
|
+
const value = String(chain.chainId);
|
|
113
|
+
const isSolana = chain.chainId === SOLANA_CHAIN_ID;
|
|
114
|
+
const disabled = detectedAddressKind === "solana" ? !isSolana : detectedAddressKind === "evm" ? isSolana : false;
|
|
115
|
+
return { value, label: chain.name, disabled };
|
|
116
|
+
}),
|
|
117
|
+
[supportedChains, detectedAddressKind]
|
|
103
118
|
);
|
|
104
|
-
const
|
|
119
|
+
const firstEnabledNetwork = (_d = (_c = (_a = networkOptions.find((option) => !option.disabled)) == null ? void 0 : _a.value) != null ? _c : (_b = networkOptions[0]) == null ? void 0 : _b.value) != null ? _d : "";
|
|
120
|
+
const isCurrentNetworkSelectable = networkOptions.some(
|
|
121
|
+
(option) => option.value === withdrawNetwork && !option.disabled
|
|
122
|
+
);
|
|
123
|
+
const resolvedWithdrawNetwork = isCurrentNetworkSelectable ? withdrawNetwork : firstEnabledNetwork;
|
|
105
124
|
useEffect(() => {
|
|
106
125
|
if (!networkOptions.length) return;
|
|
107
|
-
if (!
|
|
108
|
-
setWithdrawNetwork(
|
|
126
|
+
if (!isCurrentNetworkSelectable && firstEnabledNetwork) {
|
|
127
|
+
setWithdrawNetwork(firstEnabledNetwork);
|
|
109
128
|
}
|
|
110
|
-
}, [networkOptions,
|
|
129
|
+
}, [networkOptions, isCurrentNetworkSelectable, firstEnabledNetwork]);
|
|
111
130
|
const tokenOptions = useMemo(() => {
|
|
112
|
-
var _a2, _b2,
|
|
131
|
+
var _a2, _b2, _c2;
|
|
113
132
|
const selectedChainId = Number(resolvedWithdrawNetwork);
|
|
114
133
|
const supportedTokensForNetwork = (_b2 = (_a2 = supportedChains == null ? void 0 : supportedChains.find((chain) => chain.chainId === selectedChainId)) == null ? void 0 : _a2.tokens) != null ? _b2 : [];
|
|
115
134
|
const withdrawableSymbols = new Set(supportedTokensForNetwork.map((token) => token.symbol));
|
|
116
|
-
return ((
|
|
135
|
+
return ((_c2 = balances == null ? void 0 : balances.cash) != null ? _c2 : []).filter((cashEntry) => withdrawableSymbols.has(cashEntry.tokenSymbol)).map((cashEntry) => ({
|
|
117
136
|
value: cashEntry.tokenSymbol,
|
|
118
137
|
label: cashEntry.tokenSymbol
|
|
119
138
|
}));
|
|
120
139
|
}, [balances, resolvedWithdrawNetwork, supportedChains]);
|
|
121
|
-
const resolvedWithdrawToken = tokenOptions.some((option) => option.value === withdrawToken) ? withdrawToken : ((
|
|
140
|
+
const resolvedWithdrawToken = tokenOptions.some((option) => option.value === withdrawToken) ? withdrawToken : ((_e = tokenOptions[0]) == null ? void 0 : _e.value) || "";
|
|
122
141
|
useEffect(() => {
|
|
123
142
|
if (!tokenOptions.length) return;
|
|
124
143
|
if (!tokenOptions.some((option) => option.value === withdrawToken)) {
|
|
@@ -130,9 +149,9 @@ function useWithdrawFlow(options) {
|
|
|
130
149
|
[balances, resolvedWithdrawToken]
|
|
131
150
|
);
|
|
132
151
|
const selectedTokenDecimals = useMemo(() => {
|
|
133
|
-
var _a2, _b2,
|
|
152
|
+
var _a2, _b2, _c2, _d2;
|
|
134
153
|
const selectedChainId = Number(resolvedWithdrawNetwork);
|
|
135
|
-
return (
|
|
154
|
+
return (_d2 = (_c2 = (_b2 = (_a2 = supportedChains == null ? void 0 : supportedChains.find((chain) => chain.chainId === selectedChainId)) == null ? void 0 : _a2.tokens.find((token) => token.symbol === resolvedWithdrawToken)) == null ? void 0 : _b2.decimals) != null ? _c2 : selectedCashEntry == null ? void 0 : selectedCashEntry.decimals) != null ? _d2 : 6;
|
|
136
155
|
}, [
|
|
137
156
|
resolvedWithdrawNetwork,
|
|
138
157
|
resolvedWithdrawToken,
|
|
@@ -157,6 +176,7 @@ function useWithdrawFlow(options) {
|
|
|
157
176
|
setWithdrawNetwork("");
|
|
158
177
|
setWithdrawSummary(DEFAULT_WITHDRAW_SUMMARY);
|
|
159
178
|
setWithdrawalId(null);
|
|
179
|
+
setIsMax(false);
|
|
160
180
|
}, []);
|
|
161
181
|
const handleWithdrawOpenChange = useCallback(
|
|
162
182
|
(isOpen) => {
|
|
@@ -196,19 +216,19 @@ function useWithdrawFlow(options) {
|
|
|
196
216
|
}
|
|
197
217
|
return scaleBy(native, selectedTokenDecimals - selectedCashEntry.decimals);
|
|
198
218
|
})();
|
|
199
|
-
if (BigInt(amountRaw) > balanceInDestFrame) {
|
|
219
|
+
if (!isMax && BigInt(amountRaw) > balanceInDestFrame) {
|
|
200
220
|
throw new Error("Withdrawal amount exceeds your available balance.");
|
|
201
221
|
}
|
|
202
222
|
}
|
|
203
223
|
ws == null ? void 0 : ws.connect();
|
|
204
224
|
yield new Promise((resolve, reject) => {
|
|
205
225
|
withdrawMutation.mutate(
|
|
206
|
-
{
|
|
226
|
+
__spreadValues({
|
|
207
227
|
amountRaw,
|
|
208
228
|
tokenSymbol: resolvedWithdrawToken,
|
|
209
229
|
destinationAddress: trimmedDestination,
|
|
210
230
|
destinationChainId
|
|
211
|
-
},
|
|
231
|
+
}, isMax ? { max: true } : {}),
|
|
212
232
|
{
|
|
213
233
|
onSuccess: (data) => {
|
|
214
234
|
setWithdrawalId(data.withdrawalId);
|
|
@@ -225,6 +245,7 @@ function useWithdrawFlow(options) {
|
|
|
225
245
|
fees: "\u2014"
|
|
226
246
|
});
|
|
227
247
|
}), [
|
|
248
|
+
isMax,
|
|
228
249
|
resolvedWithdrawNetwork,
|
|
229
250
|
resolvedWithdrawToken,
|
|
230
251
|
selectedCashEntry,
|
|
@@ -248,13 +269,18 @@ function useWithdrawFlow(options) {
|
|
|
248
269
|
selectedToken: resolvedWithdrawToken,
|
|
249
270
|
selectedNetwork: resolvedWithdrawNetwork,
|
|
250
271
|
purchaseSummary: withdrawSummary,
|
|
251
|
-
withdrawalId
|
|
272
|
+
withdrawalId,
|
|
273
|
+
isMax
|
|
252
274
|
},
|
|
253
275
|
onWithdrawDestinationChange: setWithdrawDestination,
|
|
254
|
-
onWithdrawAmountChange:
|
|
276
|
+
onWithdrawAmountChange: useCallback((v) => {
|
|
277
|
+
setIsMax(false);
|
|
278
|
+
setWithdrawAmount(v);
|
|
279
|
+
}, []),
|
|
255
280
|
onWithdrawTokenChange: setWithdrawToken,
|
|
256
281
|
onWithdrawNetworkChange: setWithdrawNetwork,
|
|
257
282
|
onMaxClick: useCallback(() => {
|
|
283
|
+
setIsMax(true);
|
|
258
284
|
setWithdrawAmount(exactBalance === "0" ? "0" : exactBalance);
|
|
259
285
|
}, [exactBalance]),
|
|
260
286
|
onSelectWithdrawProvider: useCallback(
|
|
@@ -321,6 +347,7 @@ var INITIAL_STATE = {
|
|
|
321
347
|
status: null,
|
|
322
348
|
requestedAmountRaw: null,
|
|
323
349
|
completedAmountRaw: null,
|
|
350
|
+
feeRaw: null,
|
|
324
351
|
terminal: false,
|
|
325
352
|
lastLeg: null,
|
|
326
353
|
legs: [],
|
|
@@ -351,16 +378,17 @@ var mergeLegs = (prev, snapshot, delta) => {
|
|
|
351
378
|
return next;
|
|
352
379
|
};
|
|
353
380
|
var restToLifecycleState = (response) => {
|
|
354
|
-
var _a, _b;
|
|
381
|
+
var _a, _b, _c;
|
|
355
382
|
return {
|
|
356
383
|
pending: false,
|
|
357
384
|
status: response.status,
|
|
358
385
|
requestedAmountRaw: response.requested.amountRaw,
|
|
359
386
|
completedAmountRaw: (_a = response.completedAmountRaw) != null ? _a : null,
|
|
387
|
+
feeRaw: (_b = response.expected.feeRaw) != null ? _b : null,
|
|
360
388
|
terminal: response.status === "completed" || response.status === "partial" || response.status === "failed",
|
|
361
389
|
lastLeg: null,
|
|
362
390
|
legs: response.legs.map(restLegToWsLeg),
|
|
363
|
-
errorMessage: (
|
|
391
|
+
errorMessage: (_c = response.errorMessage) != null ? _c : null,
|
|
364
392
|
// No server timestamp on the REST response — we use 0 as "older than any
|
|
365
393
|
// WS timestamp" so a subsequent WS event always wins. Callers that read
|
|
366
394
|
// `timestamp` should treat 0/null interchangeably as "unset".
|
|
@@ -402,14 +430,15 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
402
430
|
return (msg) => {
|
|
403
431
|
if (msg.withdrawalId !== withdrawalId) return;
|
|
404
432
|
setState((prev) => {
|
|
405
|
-
var _a, _b, _c, _d;
|
|
433
|
+
var _a, _b, _c, _d, _e;
|
|
406
434
|
return {
|
|
407
435
|
pending: false,
|
|
408
436
|
status: msg.status,
|
|
409
437
|
requestedAmountRaw: (_a = msg.requestedAmountRaw) != null ? _a : prev.requestedAmountRaw,
|
|
410
438
|
completedAmountRaw: (_b = msg.completedAmountRaw) != null ? _b : prev.completedAmountRaw,
|
|
439
|
+
feeRaw: (_c = msg.feeRaw) != null ? _c : null,
|
|
411
440
|
terminal: msg.terminal,
|
|
412
|
-
lastLeg: (
|
|
441
|
+
lastLeg: (_d = msg.leg) != null ? _d : null,
|
|
413
442
|
// `legs[]` is the cumulative server-known truth. Snapshots
|
|
414
443
|
// (`pending` / terminal rollup) carry a full `legs[]` and replace
|
|
415
444
|
// it. Intermediate per-leg deltas carry only `leg` (no `legs[]`)
|
|
@@ -417,7 +446,7 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
417
446
|
// (sourceChainId, destChainId, type) so the timeline UI doesn't
|
|
418
447
|
// collapse to empty between snapshots.
|
|
419
448
|
legs: mergeLegs(prev.legs, msg.legs, msg.leg),
|
|
420
|
-
errorMessage: (
|
|
449
|
+
errorMessage: (_e = msg.errorMessage) != null ? _e : null,
|
|
421
450
|
timestamp: msg.timestamp
|
|
422
451
|
};
|
|
423
452
|
});
|
|
@@ -437,8 +466,40 @@ function useWithdrawalLifecycle(withdrawalId) {
|
|
|
437
466
|
return { state, reset };
|
|
438
467
|
}
|
|
439
468
|
|
|
469
|
+
// src/withdraw/use-withdraw-preview.ts
|
|
470
|
+
import { useQuery } from "@tanstack/react-query";
|
|
471
|
+
function useWithdrawPreview({
|
|
472
|
+
amountRaw,
|
|
473
|
+
tokenSymbol,
|
|
474
|
+
destinationChainId,
|
|
475
|
+
destinationAddress,
|
|
476
|
+
max
|
|
477
|
+
}) {
|
|
478
|
+
const client = useAggClient();
|
|
479
|
+
const enabled = !!amountRaw && BigInt(amountRaw || "0") > BigInt(0) && !!tokenSymbol && !!destinationChainId && !!destinationAddress;
|
|
480
|
+
return useQuery({
|
|
481
|
+
queryKey: [
|
|
482
|
+
"withdraw-preview",
|
|
483
|
+
tokenSymbol,
|
|
484
|
+
amountRaw,
|
|
485
|
+
destinationChainId,
|
|
486
|
+
destinationAddress,
|
|
487
|
+
max != null ? max : false
|
|
488
|
+
],
|
|
489
|
+
enabled,
|
|
490
|
+
staleTime: 15e3,
|
|
491
|
+
queryFn: () => client.withdrawPreview(__spreadValues({
|
|
492
|
+
amountRaw,
|
|
493
|
+
tokenSymbol,
|
|
494
|
+
destinationChainId,
|
|
495
|
+
destinationAddress
|
|
496
|
+
}, max ? { max: true } : {}))
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
|
|
440
500
|
export {
|
|
441
501
|
useWithdrawFlow,
|
|
442
502
|
useWithdrawEstimate,
|
|
443
|
-
useWithdrawalLifecycle
|
|
503
|
+
useWithdrawalLifecycle,
|
|
504
|
+
useWithdrawPreview
|
|
444
505
|
};
|
|
@@ -215,6 +215,8 @@ var enUsLabels = {
|
|
|
215
215
|
errorPrefix: "Error",
|
|
216
216
|
tabsAria: "Tabs",
|
|
217
217
|
hiddenTabsAria: "Hidden tabs",
|
|
218
|
+
scrollTabsLeft: "Scroll tabs left",
|
|
219
|
+
scrollTabsRight: "Scroll tabs right",
|
|
218
220
|
selectAria: "Select",
|
|
219
221
|
lineChartAria: "Line chart",
|
|
220
222
|
candlestickChartAria: "Candlestick chart",
|
|
@@ -377,6 +379,7 @@ var enUsLabels = {
|
|
|
377
379
|
networkReserveTooltipLineTwo: "Any unused amount stays in your balance.",
|
|
378
380
|
youReceive: "You'll receive",
|
|
379
381
|
confirm: "Confirm withdrawal",
|
|
382
|
+
calculatingFees: "Calculating fees\u2026",
|
|
380
383
|
successTitle: "Withdrawal submitted",
|
|
381
384
|
successDescription: (tokenSymbol) => `Your ${tokenSymbol} withdrawal is being processed and will arrive shortly.`,
|
|
382
385
|
// Terminal-state copy. The success step swaps `successTitle` /
|
|
@@ -460,6 +463,13 @@ var enUsLabels = {
|
|
|
460
463
|
categoryTabsAria: "Home page category tabs"
|
|
461
464
|
},
|
|
462
465
|
userProfile: {
|
|
466
|
+
balance: {
|
|
467
|
+
availableBalance: "Available Balance",
|
|
468
|
+
balanceByNetwork: "Balance by network",
|
|
469
|
+
paperModeNetwork: "Paper",
|
|
470
|
+
paperModeWarning: "Paper mode is enabled. These are simulated funds for paper trading.",
|
|
471
|
+
networkTooltipDescription: "Funds are stored across networks. We handle routing automatically, but keeping funds on the right network enables faster trades and lower fees. When depositing, you can choose your preferred network."
|
|
472
|
+
},
|
|
463
473
|
activity: {
|
|
464
474
|
depositType: "Deposit",
|
|
465
475
|
redeemType: "Claim",
|
|
@@ -791,6 +801,9 @@ var enUsLabels = {
|
|
|
791
801
|
buyingOutcome: (label) => `Buying ${label}`,
|
|
792
802
|
sellingOutcome: (label) => `Selling ${label}`,
|
|
793
803
|
findingBestRoute: "Finding the best route...",
|
|
804
|
+
findingBestOdds: "Finding best odds\u2026",
|
|
805
|
+
updatingRoute: "Updating route\u2026",
|
|
806
|
+
refreshingQuotes: "Refreshing quotes\u2026",
|
|
794
807
|
checkingBalance: "Checking balance",
|
|
795
808
|
submittingOrderProgress: "Submitting order...",
|
|
796
809
|
orderSubmittedProgress: (orderId) => `Order #${orderId.replace(/^#/, "")} submitted`,
|
|
@@ -1131,7 +1144,8 @@ var defaultAggUiConfig = {
|
|
|
1131
1144
|
enableNotifications: true
|
|
1132
1145
|
},
|
|
1133
1146
|
market: {
|
|
1134
|
-
arbitrageThreshold: 0
|
|
1147
|
+
arbitrageThreshold: 0,
|
|
1148
|
+
maxMidpointIdsPerRequest: 75
|
|
1135
1149
|
},
|
|
1136
1150
|
chart: {
|
|
1137
1151
|
defaultChartTimeRange: "1D",
|
|
@@ -1140,7 +1154,10 @@ var defaultAggUiConfig = {
|
|
|
1140
1154
|
}
|
|
1141
1155
|
},
|
|
1142
1156
|
formatting: defaultFormatters,
|
|
1143
|
-
search: defaultAggUiSearchConfig
|
|
1157
|
+
search: defaultAggUiSearchConfig,
|
|
1158
|
+
trading: {
|
|
1159
|
+
executionMode: "live"
|
|
1160
|
+
}
|
|
1144
1161
|
};
|
|
1145
1162
|
var mergeAggUiSearchConfig = (config) => {
|
|
1146
1163
|
var _a, _b, _c;
|
|
@@ -1155,7 +1172,7 @@ var mergeAggUiSearchConfig = (config) => {
|
|
|
1155
1172
|
};
|
|
1156
1173
|
};
|
|
1157
1174
|
var mergeAggUiConfig = (persisted, config) => {
|
|
1158
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T;
|
|
1175
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X;
|
|
1159
1176
|
const locale = (_d = (_c = (_a = config == null ? void 0 : config.general) == null ? void 0 : _a.locale) != null ? _c : (_b = persisted.general) == null ? void 0 : _b.locale) != null ? _d : DEFAULT_LOCALE;
|
|
1160
1177
|
const theme = (_h = (_g = (_e = config == null ? void 0 : config.general) == null ? void 0 : _e.theme) != null ? _g : (_f = persisted.general) == null ? void 0 : _f.theme) != null ? _h : defaultAggUiConfig.general.theme;
|
|
1161
1178
|
const formatters = createFormatters(locale);
|
|
@@ -1180,21 +1197,25 @@ var mergeAggUiConfig = (persisted, config) => {
|
|
|
1180
1197
|
enableNotifications: (_B = (_A = config == null ? void 0 : config.features) == null ? void 0 : _A.enableNotifications) != null ? _B : defaultAggUiConfig.features.enableNotifications
|
|
1181
1198
|
},
|
|
1182
1199
|
market: {
|
|
1183
|
-
arbitrageThreshold: (_D = (_C = config == null ? void 0 : config.market) == null ? void 0 : _C.arbitrageThreshold) != null ? _D : defaultAggUiConfig.market.arbitrageThreshold
|
|
1200
|
+
arbitrageThreshold: (_D = (_C = config == null ? void 0 : config.market) == null ? void 0 : _C.arbitrageThreshold) != null ? _D : defaultAggUiConfig.market.arbitrageThreshold,
|
|
1201
|
+
maxMidpointIdsPerRequest: (_F = (_E = config == null ? void 0 : config.market) == null ? void 0 : _E.maxMidpointIdsPerRequest) != null ? _F : defaultAggUiConfig.market.maxMidpointIdsPerRequest
|
|
1184
1202
|
},
|
|
1185
1203
|
chart: {
|
|
1186
|
-
defaultChartTimeRange: (
|
|
1187
|
-
selectedChartTimeRange: (
|
|
1204
|
+
defaultChartTimeRange: (_H = (_G = config == null ? void 0 : config.chart) == null ? void 0 : _G.defaultChartTimeRange) != null ? _H : defaultAggUiConfig.chart.defaultChartTimeRange,
|
|
1205
|
+
selectedChartTimeRange: (_L = (_K = (_I = persisted.chart) == null ? void 0 : _I.selectedChartTimeRange) != null ? _K : (_J = config == null ? void 0 : config.chart) == null ? void 0 : _J.defaultChartTimeRange) != null ? _L : defaultAggUiConfig.chart.defaultChartTimeRange,
|
|
1188
1206
|
setSelectedChartTimeRange: defaultAggUiConfig.chart.setSelectedChartTimeRange
|
|
1189
1207
|
},
|
|
1190
1208
|
formatting: {
|
|
1191
|
-
formatNumber: (
|
|
1192
|
-
formatPercent: (
|
|
1193
|
-
formatCurrency: (
|
|
1194
|
-
formatCompactCurrency: (
|
|
1195
|
-
formatDate: (
|
|
1209
|
+
formatNumber: (_N = (_M = config == null ? void 0 : config.formatting) == null ? void 0 : _M.formatNumber) != null ? _N : formatters.formatNumber,
|
|
1210
|
+
formatPercent: (_P = (_O = config == null ? void 0 : config.formatting) == null ? void 0 : _O.formatPercent) != null ? _P : formatters.formatPercent,
|
|
1211
|
+
formatCurrency: (_R = (_Q = config == null ? void 0 : config.formatting) == null ? void 0 : _Q.formatCurrency) != null ? _R : formatters.formatCurrency,
|
|
1212
|
+
formatCompactCurrency: (_T = (_S = config == null ? void 0 : config.formatting) == null ? void 0 : _S.formatCompactCurrency) != null ? _T : formatters.formatCompactCurrency,
|
|
1213
|
+
formatDate: (_V = (_U = config == null ? void 0 : config.formatting) == null ? void 0 : _U.formatDate) != null ? _V : formatters.formatDate
|
|
1196
1214
|
},
|
|
1197
1215
|
search: mergeAggUiSearchConfig(config == null ? void 0 : config.search),
|
|
1216
|
+
trading: {
|
|
1217
|
+
executionMode: (_X = (_W = config == null ? void 0 : config.trading) == null ? void 0 : _W.executionMode) != null ? _X : defaultAggUiConfig.trading.executionMode
|
|
1218
|
+
},
|
|
1198
1219
|
walletActions: config == null ? void 0 : config.walletActions,
|
|
1199
1220
|
solanaRpcUrl: config == null ? void 0 : config.solanaRpcUrl
|
|
1200
1221
|
};
|
|
@@ -1224,7 +1245,7 @@ var balanceQueryKeys = {
|
|
|
1224
1245
|
execution: () => executionKeys.balances(),
|
|
1225
1246
|
// Kept as an alias for backward compatibility with existing callers.
|
|
1226
1247
|
// The balance provider now uses the same canonical execution balances key.
|
|
1227
|
-
provider: () => executionKeys.balances(),
|
|
1248
|
+
provider: (mode) => executionKeys.balances(mode),
|
|
1228
1249
|
venue: (venuesKey) => ["venue-balances", venuesKey],
|
|
1229
1250
|
venuePrefix: () => ["venue-balances"]
|
|
1230
1251
|
};
|
|
@@ -1310,6 +1331,7 @@ var AggBalanceContext = createContext(null);
|
|
|
1310
1331
|
// src/core/providers/balance-provider.tsx
|
|
1311
1332
|
import { jsx } from "react/jsx-runtime";
|
|
1312
1333
|
var CHAIN_LABELS = {
|
|
1334
|
+
0: "Paper",
|
|
1313
1335
|
1: "Ethereum",
|
|
1314
1336
|
10: "Optimism",
|
|
1315
1337
|
56: "BNB",
|
|
@@ -1341,17 +1363,23 @@ var EMPTY_MANAGED_BALANCES = {
|
|
|
1341
1363
|
function AggBalanceProvider({ children }) {
|
|
1342
1364
|
const client = useContext(AggClientContext);
|
|
1343
1365
|
const authContext = useContext(AggAuthContext);
|
|
1366
|
+
const {
|
|
1367
|
+
trading: { executionMode }
|
|
1368
|
+
} = useContext(AggUiContext);
|
|
1344
1369
|
if (!authContext) {
|
|
1345
1370
|
throw new Error("AggBalanceProvider must be used within an <AggAuthProvider>");
|
|
1346
1371
|
}
|
|
1347
1372
|
const { isAuthenticated } = authContext;
|
|
1373
|
+
const queryExecutionMode = executionMode === "paper" ? "paper" : void 0;
|
|
1348
1374
|
const balancesQuery = useQuery({
|
|
1349
|
-
queryKey: balanceQueryKeys.provider(),
|
|
1375
|
+
queryKey: balanceQueryKeys.provider(queryExecutionMode),
|
|
1350
1376
|
queryFn: () => __async(null, null, function* () {
|
|
1351
1377
|
if (!client || !isAuthenticated) {
|
|
1352
1378
|
return EMPTY_MANAGED_BALANCES;
|
|
1353
1379
|
}
|
|
1354
|
-
return client.getManagedBalances(
|
|
1380
|
+
return client.getManagedBalances(
|
|
1381
|
+
queryExecutionMode ? { mode: queryExecutionMode } : void 0
|
|
1382
|
+
);
|
|
1355
1383
|
}),
|
|
1356
1384
|
enabled: Boolean(client && isAuthenticated),
|
|
1357
1385
|
staleTime: 60 * 1e3,
|
package/dist/deposit.d.mts
CHANGED
|
@@ -185,7 +185,11 @@ interface UseDepositFlowOptions {
|
|
|
185
185
|
*/
|
|
186
186
|
declare function useDepositFlow(options: UseDepositFlowOptions): UseDepositFlowResult;
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Back-compat alias for callers that still want a single default endpoint.
|
|
190
|
+
* New code should prefer the full list and the failover helper.
|
|
191
|
+
*/
|
|
192
|
+
declare const DEFAULT_SOLANA_RPC_ENDPOINT: string;
|
|
189
193
|
declare const SVM_CHAIN_IDS: ReadonlySet<number>;
|
|
190
194
|
|
|
191
195
|
export { DEFAULT_SOLANA_RPC_ENDPOINT, SVM_CHAIN_IDS, type UseDepositFlowOptions, type UseDepositFlowResult, type UseWalletSendTokenParams, type UseWalletTokenBalanceParams, type UseWalletTokenBalanceResult, type UseWalletTransactionStatusParams, type UseWalletTransactionStatusResult, type WalletTransactionStatus, normalizeWalletError, useDepositFlow, useWalletSendToken, useWalletTokenBalance, useWalletTransactionStatus };
|
package/dist/deposit.d.ts
CHANGED
|
@@ -185,7 +185,11 @@ interface UseDepositFlowOptions {
|
|
|
185
185
|
*/
|
|
186
186
|
declare function useDepositFlow(options: UseDepositFlowOptions): UseDepositFlowResult;
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Back-compat alias for callers that still want a single default endpoint.
|
|
190
|
+
* New code should prefer the full list and the failover helper.
|
|
191
|
+
*/
|
|
192
|
+
declare const DEFAULT_SOLANA_RPC_ENDPOINT: string;
|
|
189
193
|
declare const SVM_CHAIN_IDS: ReadonlySet<number>;
|
|
190
194
|
|
|
191
195
|
export { DEFAULT_SOLANA_RPC_ENDPOINT, SVM_CHAIN_IDS, type UseDepositFlowOptions, type UseDepositFlowResult, type UseWalletSendTokenParams, type UseWalletTokenBalanceParams, type UseWalletTokenBalanceResult, type UseWalletTransactionStatusParams, type UseWalletTransactionStatusResult, type WalletTransactionStatus, normalizeWalletError, useDepositFlow, useWalletSendToken, useWalletTokenBalance, useWalletTransactionStatus };
|