@agg-build/hooks 2.1.1 → 2.1.3
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-FYEPQHKO.mjs → chunk-56RISN73.mjs} +408 -16
- package/dist/{chunk-5P53A3NQ.mjs → chunk-NZEXGOFC.mjs} +1 -1
- package/dist/{chunk-AFZD3GIQ.mjs → chunk-SN4AO5D7.mjs} +1 -1
- package/dist/deposit.d.mts +1 -1
- package/dist/deposit.d.ts +1 -1
- package/dist/deposit.js +91 -19
- package/dist/deposit.mjs +32 -10
- package/dist/index.d.mts +175 -37
- package/dist/index.d.ts +175 -37
- package/dist/index.js +813 -104
- package/dist/index.mjs +363 -48
- package/dist/withdraw.js +50 -2
- package/dist/withdraw.mjs +2 -2
- package/package.json +2 -2
|
@@ -662,6 +662,8 @@ var enUsLabels = {
|
|
|
662
662
|
showOutcomeAria: (label) => `Show ${label} outcome`,
|
|
663
663
|
viewResolved: "View resolved",
|
|
664
664
|
hideResolved: "Hide resolved",
|
|
665
|
+
resolvingTitle: "Resolving market\u2026",
|
|
666
|
+
resolvingDescription: "This market has closed. We're waiting for final settlement data and will update the result once it's confirmed on-chain.",
|
|
665
667
|
volumeUnavailable: "Volume unavailable",
|
|
666
668
|
tabs: {
|
|
667
669
|
orderBook: "Order Book",
|
|
@@ -835,6 +837,7 @@ var enUsLabels = {
|
|
|
835
837
|
orderSkip: "Skip",
|
|
836
838
|
orderRetryRemaining: "Retry remaining",
|
|
837
839
|
resolvedEarningsTitle: "Your Earnings",
|
|
840
|
+
resolvedResolutionDateLabel: "Resolution date",
|
|
838
841
|
resolvedSharesLabel: "Shares",
|
|
839
842
|
resolvedTotalPayoutLabel: "Total payout",
|
|
840
843
|
claimWinnings: "Claim Winnings",
|
|
@@ -979,7 +982,51 @@ var enUsLabels = {
|
|
|
979
982
|
winningOutcome: (label) => `Winning outcome: ${label}`,
|
|
980
983
|
resolvedOutcome: (label) => `Resolved: ${label}`,
|
|
981
984
|
marketDetailsAriaByDate: (dateLabel) => `Market details for ${dateLabel}`,
|
|
982
|
-
marketDetailsAriaByQuestion: (question) => `Market details for ${question}
|
|
985
|
+
marketDetailsAriaByQuestion: (question) => `Market details for ${question}`,
|
|
986
|
+
sports: {
|
|
987
|
+
summaryAria: "Sports event summary",
|
|
988
|
+
sectionTabsAria: "Sports market sections",
|
|
989
|
+
lineSelectorAria: (marketTitle) => `Select line for ${marketTitle}`,
|
|
990
|
+
previousLineAria: (marketTitle) => `Show previous lines for ${marketTitle}`,
|
|
991
|
+
nextLineAria: (marketTitle) => `Show next lines for ${marketTitle}`,
|
|
992
|
+
comparisonToggleAria: (marketTitle, expanded) => `${expanded ? "Hide" : "Show"} venue comparison for ${marketTitle}`,
|
|
993
|
+
comparisonTitle: "Venue alternatives",
|
|
994
|
+
compareVenues: (count) => `Compare ${count} venues`,
|
|
995
|
+
marketCount: (count) => `${count} markets`,
|
|
996
|
+
venueCount: (count) => `${count} venues`,
|
|
997
|
+
volumeShort: "Vol.",
|
|
998
|
+
totalVolumeShort: "Total Vol.",
|
|
999
|
+
gameStarts: "Game starts",
|
|
1000
|
+
moreMarketsTitle: "More markets",
|
|
1001
|
+
gameLinesTab: "Game Lines",
|
|
1002
|
+
halvesTab: "Halves",
|
|
1003
|
+
exactScoreTab: "Exact Score",
|
|
1004
|
+
cornersTab: "Corners",
|
|
1005
|
+
goalsTab: "Goals",
|
|
1006
|
+
assistsTab: "Assists",
|
|
1007
|
+
shotsTab: "Shots",
|
|
1008
|
+
otherTab: "Other",
|
|
1009
|
+
moneylineTitle: "Moneyline",
|
|
1010
|
+
spreadTitle: "Spreads",
|
|
1011
|
+
totalTitle: "Totals",
|
|
1012
|
+
fullPeriod: "Regular time",
|
|
1013
|
+
firstHalfPeriod: "1st half",
|
|
1014
|
+
secondHalfPeriod: "2nd half",
|
|
1015
|
+
quarterOnePeriod: "1st quarter",
|
|
1016
|
+
quarterTwoPeriod: "2nd quarter",
|
|
1017
|
+
quarterThreePeriod: "3rd quarter",
|
|
1018
|
+
quarterFourPeriod: "4th quarter",
|
|
1019
|
+
overtimePeriod: "Overtime",
|
|
1020
|
+
otherPeriod: "Other",
|
|
1021
|
+
loadingTitle: "Loading section",
|
|
1022
|
+
loadingDescription: "Fetching the latest markets for this game.",
|
|
1023
|
+
emptyTitle: "No markets available",
|
|
1024
|
+
emptyDescription: (sectionLabel) => `There are no ${sectionLabel} markets yet.`,
|
|
1025
|
+
loadMore: "Load more",
|
|
1026
|
+
loadingMore: "Loading more",
|
|
1027
|
+
bestPriceBadge: "Best price",
|
|
1028
|
+
selectOutcomeAria: (marketTitle, outcomeLabel, priceLabel) => `Select ${outcomeLabel} in ${marketTitle} at ${priceLabel}`
|
|
1029
|
+
}
|
|
983
1030
|
},
|
|
984
1031
|
header: {
|
|
985
1032
|
bannerAria: "Site header",
|
|
@@ -1141,7 +1188,8 @@ var defaultAggUiConfig = {
|
|
|
1141
1188
|
showFeesBreakdown: false,
|
|
1142
1189
|
enableGradients: false,
|
|
1143
1190
|
enableVenueEventDiscoveryFilters: false,
|
|
1144
|
-
enableNotifications: true
|
|
1191
|
+
enableNotifications: true,
|
|
1192
|
+
showSportsMarkets: false
|
|
1145
1193
|
},
|
|
1146
1194
|
market: {
|
|
1147
1195
|
arbitrageThreshold: 0,
|
|
@@ -1172,7 +1220,7 @@ var mergeAggUiSearchConfig = (config) => {
|
|
|
1172
1220
|
};
|
|
1173
1221
|
};
|
|
1174
1222
|
var mergeAggUiConfig = (persisted, config) => {
|
|
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;
|
|
1223
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z;
|
|
1176
1224
|
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;
|
|
1177
1225
|
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;
|
|
1178
1226
|
const formatters = createFormatters(locale);
|
|
@@ -1194,27 +1242,28 @@ var mergeAggUiConfig = (persisted, config) => {
|
|
|
1194
1242
|
showFeesBreakdown: (_v = (_u = config == null ? void 0 : config.features) == null ? void 0 : _u.showFeesBreakdown) != null ? _v : defaultAggUiConfig.features.showFeesBreakdown,
|
|
1195
1243
|
enableGradients: (_x = (_w = config == null ? void 0 : config.features) == null ? void 0 : _w.enableGradients) != null ? _x : defaultAggUiConfig.features.enableGradients,
|
|
1196
1244
|
enableVenueEventDiscoveryFilters: (_z = (_y = config == null ? void 0 : config.features) == null ? void 0 : _y.enableVenueEventDiscoveryFilters) != null ? _z : defaultAggUiConfig.features.enableVenueEventDiscoveryFilters,
|
|
1197
|
-
enableNotifications: (_B = (_A = config == null ? void 0 : config.features) == null ? void 0 : _A.enableNotifications) != null ? _B : defaultAggUiConfig.features.enableNotifications
|
|
1245
|
+
enableNotifications: (_B = (_A = config == null ? void 0 : config.features) == null ? void 0 : _A.enableNotifications) != null ? _B : defaultAggUiConfig.features.enableNotifications,
|
|
1246
|
+
showSportsMarkets: (_D = (_C = config == null ? void 0 : config.features) == null ? void 0 : _C.showSportsMarkets) != null ? _D : defaultAggUiConfig.features.showSportsMarkets
|
|
1198
1247
|
},
|
|
1199
1248
|
market: {
|
|
1200
|
-
arbitrageThreshold: (
|
|
1201
|
-
maxMidpointIdsPerRequest: (
|
|
1249
|
+
arbitrageThreshold: (_F = (_E = config == null ? void 0 : config.market) == null ? void 0 : _E.arbitrageThreshold) != null ? _F : defaultAggUiConfig.market.arbitrageThreshold,
|
|
1250
|
+
maxMidpointIdsPerRequest: (_H = (_G = config == null ? void 0 : config.market) == null ? void 0 : _G.maxMidpointIdsPerRequest) != null ? _H : defaultAggUiConfig.market.maxMidpointIdsPerRequest
|
|
1202
1251
|
},
|
|
1203
1252
|
chart: {
|
|
1204
|
-
defaultChartTimeRange: (
|
|
1205
|
-
selectedChartTimeRange: (
|
|
1253
|
+
defaultChartTimeRange: (_J = (_I = config == null ? void 0 : config.chart) == null ? void 0 : _I.defaultChartTimeRange) != null ? _J : defaultAggUiConfig.chart.defaultChartTimeRange,
|
|
1254
|
+
selectedChartTimeRange: (_N = (_M = (_K = persisted.chart) == null ? void 0 : _K.selectedChartTimeRange) != null ? _M : (_L = config == null ? void 0 : config.chart) == null ? void 0 : _L.defaultChartTimeRange) != null ? _N : defaultAggUiConfig.chart.defaultChartTimeRange,
|
|
1206
1255
|
setSelectedChartTimeRange: defaultAggUiConfig.chart.setSelectedChartTimeRange
|
|
1207
1256
|
},
|
|
1208
1257
|
formatting: {
|
|
1209
|
-
formatNumber: (
|
|
1210
|
-
formatPercent: (
|
|
1211
|
-
formatCurrency: (
|
|
1212
|
-
formatCompactCurrency: (
|
|
1213
|
-
formatDate: (
|
|
1258
|
+
formatNumber: (_P = (_O = config == null ? void 0 : config.formatting) == null ? void 0 : _O.formatNumber) != null ? _P : formatters.formatNumber,
|
|
1259
|
+
formatPercent: (_R = (_Q = config == null ? void 0 : config.formatting) == null ? void 0 : _Q.formatPercent) != null ? _R : formatters.formatPercent,
|
|
1260
|
+
formatCurrency: (_T = (_S = config == null ? void 0 : config.formatting) == null ? void 0 : _S.formatCurrency) != null ? _T : formatters.formatCurrency,
|
|
1261
|
+
formatCompactCurrency: (_V = (_U = config == null ? void 0 : config.formatting) == null ? void 0 : _U.formatCompactCurrency) != null ? _V : formatters.formatCompactCurrency,
|
|
1262
|
+
formatDate: (_X = (_W = config == null ? void 0 : config.formatting) == null ? void 0 : _W.formatDate) != null ? _X : formatters.formatDate
|
|
1214
1263
|
},
|
|
1215
1264
|
search: mergeAggUiSearchConfig(config == null ? void 0 : config.search),
|
|
1216
1265
|
trading: {
|
|
1217
|
-
executionMode: (
|
|
1266
|
+
executionMode: (_Z = (_Y = config == null ? void 0 : config.trading) == null ? void 0 : _Y.executionMode) != null ? _Z : defaultAggUiConfig.trading.executionMode
|
|
1218
1267
|
},
|
|
1219
1268
|
walletActions: config == null ? void 0 : config.walletActions,
|
|
1220
1269
|
solanaRpcUrl: config == null ? void 0 : config.solanaRpcUrl
|
|
@@ -2007,6 +2056,98 @@ var applyOrderbookDepth = (data, depth) => {
|
|
|
2007
2056
|
});
|
|
2008
2057
|
};
|
|
2009
2058
|
|
|
2059
|
+
// src/market-data/market-resolution-cache.ts
|
|
2060
|
+
var isRecord = (value) => {
|
|
2061
|
+
return typeof value === "object" && value !== null;
|
|
2062
|
+
};
|
|
2063
|
+
var NESTED_COLLECTION_FIELDS = ["pages", "data", "markets", "events", "venueMarkets"];
|
|
2064
|
+
var marketContainsOutcomeId = (market, outcomeId) => {
|
|
2065
|
+
if (!isRecord(market)) return false;
|
|
2066
|
+
const outcomes = market.venueMarketOutcomes;
|
|
2067
|
+
if (!Array.isArray(outcomes)) return false;
|
|
2068
|
+
return outcomes.some((outcome) => isRecord(outcome) && outcome.id === outcomeId);
|
|
2069
|
+
};
|
|
2070
|
+
var cachedDataContainsOutcomeId = (data, outcomeId) => {
|
|
2071
|
+
if (Array.isArray(data)) {
|
|
2072
|
+
return data.some((entry) => cachedDataContainsOutcomeId(entry, outcomeId));
|
|
2073
|
+
}
|
|
2074
|
+
if (!isRecord(data)) return false;
|
|
2075
|
+
if (marketContainsOutcomeId(data, outcomeId)) return true;
|
|
2076
|
+
return NESTED_COLLECTION_FIELDS.some((field) => {
|
|
2077
|
+
const value = data[field];
|
|
2078
|
+
return Array.isArray(value) && value.some((entry) => cachedDataContainsOutcomeId(entry, outcomeId));
|
|
2079
|
+
});
|
|
2080
|
+
};
|
|
2081
|
+
var normalizeLabel = (label) => {
|
|
2082
|
+
return typeof label === "string" ? label.trim().toLowerCase() : "";
|
|
2083
|
+
};
|
|
2084
|
+
var findResolvedOutcome = (resolvedOutcomes, outcome) => {
|
|
2085
|
+
var _a;
|
|
2086
|
+
const externalIdentifier = outcome.externalIdentifier;
|
|
2087
|
+
if (typeof externalIdentifier === "string" && externalIdentifier.length > 0) {
|
|
2088
|
+
const matchedByExternalId = resolvedOutcomes.find(
|
|
2089
|
+
(resolved) => resolved.externalIdentifier === externalIdentifier
|
|
2090
|
+
);
|
|
2091
|
+
if (matchedByExternalId) return matchedByExternalId;
|
|
2092
|
+
}
|
|
2093
|
+
const label = normalizeLabel(outcome.label);
|
|
2094
|
+
if (label) {
|
|
2095
|
+
return (_a = resolvedOutcomes.find((resolved) => normalizeLabel(resolved.label) === label)) != null ? _a : null;
|
|
2096
|
+
}
|
|
2097
|
+
return null;
|
|
2098
|
+
};
|
|
2099
|
+
var applyWinnersToOutcomes = (outcomes, resolution) => {
|
|
2100
|
+
let changed = false;
|
|
2101
|
+
const next = outcomes.map((outcome) => {
|
|
2102
|
+
if (!isRecord(outcome)) return outcome;
|
|
2103
|
+
const resolved = findResolvedOutcome(resolution.outcomes, outcome);
|
|
2104
|
+
if (!resolved) return outcome;
|
|
2105
|
+
const nextWinner = resolved.winner === true;
|
|
2106
|
+
if (outcome.winner === nextWinner) return outcome;
|
|
2107
|
+
changed = true;
|
|
2108
|
+
return __spreadProps(__spreadValues({}, outcome), { winner: nextWinner });
|
|
2109
|
+
});
|
|
2110
|
+
return changed ? next : outcomes;
|
|
2111
|
+
};
|
|
2112
|
+
var applyResolutionToMarket = (market, resolution) => {
|
|
2113
|
+
const outcomes = market.venueMarketOutcomes;
|
|
2114
|
+
if (!Array.isArray(outcomes)) return market;
|
|
2115
|
+
if (!outcomes.some((outcome) => isRecord(outcome) && outcome.id === resolution.outcomeId)) {
|
|
2116
|
+
return market;
|
|
2117
|
+
}
|
|
2118
|
+
const nextOutcomes = applyWinnersToOutcomes(outcomes, resolution);
|
|
2119
|
+
const statusChanged = market.status !== resolution.status;
|
|
2120
|
+
if (!statusChanged && nextOutcomes === outcomes) return market;
|
|
2121
|
+
return __spreadProps(__spreadValues({}, market), { status: resolution.status, venueMarketOutcomes: nextOutcomes });
|
|
2122
|
+
};
|
|
2123
|
+
var applyResolutionToCachedData = (data, resolution) => {
|
|
2124
|
+
if (Array.isArray(data)) {
|
|
2125
|
+
let changed2 = false;
|
|
2126
|
+
const next2 = data.map((entry) => {
|
|
2127
|
+
const updated = applyResolutionToCachedData(entry, resolution);
|
|
2128
|
+
if (updated !== entry) changed2 = true;
|
|
2129
|
+
return updated;
|
|
2130
|
+
});
|
|
2131
|
+
return changed2 ? next2 : data;
|
|
2132
|
+
}
|
|
2133
|
+
if (!isRecord(data)) return data;
|
|
2134
|
+
if (Array.isArray(data.venueMarketOutcomes)) {
|
|
2135
|
+
return applyResolutionToMarket(data, resolution);
|
|
2136
|
+
}
|
|
2137
|
+
let changed = false;
|
|
2138
|
+
const next = __spreadValues({}, data);
|
|
2139
|
+
for (const field of NESTED_COLLECTION_FIELDS) {
|
|
2140
|
+
const value = data[field];
|
|
2141
|
+
if (!Array.isArray(value)) continue;
|
|
2142
|
+
const updated = applyResolutionToCachedData(value, resolution);
|
|
2143
|
+
if (updated !== value) {
|
|
2144
|
+
next[field] = updated;
|
|
2145
|
+
changed = true;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
return changed ? next : data;
|
|
2149
|
+
};
|
|
2150
|
+
|
|
2010
2151
|
// src/market-data/query-keys.ts
|
|
2011
2152
|
var marketDataKeys = {
|
|
2012
2153
|
all: () => ["market-data"],
|
|
@@ -2235,6 +2376,62 @@ function AggWebSocketProvider({ children }) {
|
|
|
2235
2376
|
const invalidateActivityCaches = useCallback3(() => {
|
|
2236
2377
|
invalidateUserActivityQueries(queryClient);
|
|
2237
2378
|
}, [queryClient]);
|
|
2379
|
+
const invalidateResolutionCaches = useCallback3(
|
|
2380
|
+
(resolution) => {
|
|
2381
|
+
const { outcomeId } = resolution;
|
|
2382
|
+
syncLiveQuery(outcomeId, (previous) => {
|
|
2383
|
+
if (!previous) return previous;
|
|
2384
|
+
if (previous.orderbook == null && previous.orderbookError == null) return previous;
|
|
2385
|
+
return __spreadProps(__spreadValues({}, previous), {
|
|
2386
|
+
orderbook: null,
|
|
2387
|
+
orderbookError: null,
|
|
2388
|
+
integrity: "ok"
|
|
2389
|
+
});
|
|
2390
|
+
});
|
|
2391
|
+
const affectedQueries = queryClient.getQueryCache().findAll({
|
|
2392
|
+
predicate: (query) => cachedDataContainsOutcomeId(query.state.data, outcomeId)
|
|
2393
|
+
});
|
|
2394
|
+
for (const query of affectedQueries) {
|
|
2395
|
+
queryClient.setQueryData(
|
|
2396
|
+
query.queryKey,
|
|
2397
|
+
(previous) => applyResolutionToCachedData(previous, resolution)
|
|
2398
|
+
);
|
|
2399
|
+
}
|
|
2400
|
+
queryClient.invalidateQueries({
|
|
2401
|
+
queryKey: ["midpoints"],
|
|
2402
|
+
refetchType: "all"
|
|
2403
|
+
});
|
|
2404
|
+
queryClient.invalidateQueries({
|
|
2405
|
+
queryKey: ["venue-market-midpoints"],
|
|
2406
|
+
refetchType: "all"
|
|
2407
|
+
});
|
|
2408
|
+
queryClient.invalidateQueries({
|
|
2409
|
+
queryKey: ["venue-event"],
|
|
2410
|
+
refetchType: "all"
|
|
2411
|
+
});
|
|
2412
|
+
queryClient.invalidateQueries({
|
|
2413
|
+
queryKey: ["venue-markets"],
|
|
2414
|
+
refetchType: "all"
|
|
2415
|
+
});
|
|
2416
|
+
queryClient.invalidateQueries({
|
|
2417
|
+
queryKey: ["events"],
|
|
2418
|
+
refetchType: "all"
|
|
2419
|
+
});
|
|
2420
|
+
queryClient.invalidateQueries({
|
|
2421
|
+
queryKey: ["event-list"],
|
|
2422
|
+
refetchType: "all"
|
|
2423
|
+
});
|
|
2424
|
+
queryClient.invalidateQueries({
|
|
2425
|
+
queryKey: ["search"],
|
|
2426
|
+
refetchType: "all"
|
|
2427
|
+
});
|
|
2428
|
+
queryClient.invalidateQueries({
|
|
2429
|
+
predicate: (query) => cachedDataContainsOutcomeId(query.state.data, outcomeId),
|
|
2430
|
+
refetchType: "all"
|
|
2431
|
+
});
|
|
2432
|
+
},
|
|
2433
|
+
[queryClient, syncLiveQuery]
|
|
2434
|
+
);
|
|
2238
2435
|
const callbacks = useMemo2(
|
|
2239
2436
|
() => ({
|
|
2240
2437
|
onSnapshot: (marketId, book) => {
|
|
@@ -2383,6 +2580,14 @@ function AggWebSocketProvider({ children }) {
|
|
|
2383
2580
|
listener(msg);
|
|
2384
2581
|
}
|
|
2385
2582
|
},
|
|
2583
|
+
onMarketResolved: (msg) => {
|
|
2584
|
+
invalidateResolutionCaches(msg);
|
|
2585
|
+
if (isClientAuthenticated) {
|
|
2586
|
+
invalidateBalanceCaches();
|
|
2587
|
+
invalidatePositionCaches();
|
|
2588
|
+
invalidateActivityCaches();
|
|
2589
|
+
}
|
|
2590
|
+
},
|
|
2386
2591
|
onError: (msg) => {
|
|
2387
2592
|
const outcomeId = resolveSnapshotUnavailableOutcomeId(msg.message);
|
|
2388
2593
|
if (!outcomeId) return;
|
|
@@ -2420,6 +2625,7 @@ function AggWebSocketProvider({ children }) {
|
|
|
2420
2625
|
invalidateActivityCaches,
|
|
2421
2626
|
invalidateBalanceCaches,
|
|
2422
2627
|
invalidatePositionCaches,
|
|
2628
|
+
invalidateResolutionCaches,
|
|
2423
2629
|
isClientAuthenticated,
|
|
2424
2630
|
queryClient,
|
|
2425
2631
|
syncChartQueries,
|
|
@@ -3712,6 +3918,7 @@ function mapOrderStatusToTerminalEvent(status) {
|
|
|
3712
3918
|
}
|
|
3713
3919
|
function useExecutionProgress({
|
|
3714
3920
|
orderIds,
|
|
3921
|
+
quoteId,
|
|
3715
3922
|
enabled,
|
|
3716
3923
|
mode
|
|
3717
3924
|
}) {
|
|
@@ -3887,17 +4094,202 @@ function useExecutionProgress({
|
|
|
3887
4094
|
return;
|
|
3888
4095
|
}
|
|
3889
4096
|
}, []);
|
|
3890
|
-
const
|
|
4097
|
+
const isStatusPolling = enabled && !!quoteId;
|
|
4098
|
+
const isListening = !isStatusPolling && enabled && !!orderIds && orderIds.length > 0;
|
|
3891
4099
|
useOnOrderSubmitted(isListening ? handleOrderSubmitted : null);
|
|
3892
4100
|
useOnBalanceUpdate(isListening ? handleBalanceUpdate : null);
|
|
3893
4101
|
useOnOrderEvent(isListening ? handleOrderEvent : null);
|
|
3894
4102
|
const client = useAggClient();
|
|
3895
4103
|
const terminalOrderIdsRef = useRef5(/* @__PURE__ */ new Set());
|
|
3896
4104
|
const pollInFlightRef = useRef5(false);
|
|
4105
|
+
const buildSubmittedOrdersFromStatus = useCallback7(
|
|
4106
|
+
(orders) => {
|
|
4107
|
+
return orders.map((order) => {
|
|
4108
|
+
var _a, _b;
|
|
4109
|
+
return {
|
|
4110
|
+
type: "order_submitted",
|
|
4111
|
+
venue: order.venue,
|
|
4112
|
+
orderId: order.orderId,
|
|
4113
|
+
side: "",
|
|
4114
|
+
price: Number((_b = (_a = order.executionPriceRaw) != null ? _a : order.quotedPriceRaw) != null ? _b : 0),
|
|
4115
|
+
size: 0,
|
|
4116
|
+
timestamp: new Date(order.updatedAt).getTime() / 1e3
|
|
4117
|
+
};
|
|
4118
|
+
});
|
|
4119
|
+
},
|
|
4120
|
+
[]
|
|
4121
|
+
);
|
|
4122
|
+
const buildTerminalEventsFromStatus = useCallback7(
|
|
4123
|
+
(status, fallbackOrderIds, fallbackTimestamp) => {
|
|
4124
|
+
const terminalEvents = status.orders.map((order) => {
|
|
4125
|
+
var _a, _b;
|
|
4126
|
+
const mappedEvent = (_a = order.event) != null ? _a : mapOrderStatusToTerminalEvent(order.status);
|
|
4127
|
+
if (!mappedEvent) return null;
|
|
4128
|
+
return {
|
|
4129
|
+
orderId: order.orderId,
|
|
4130
|
+
venue: order.venue,
|
|
4131
|
+
event: mappedEvent,
|
|
4132
|
+
filledAmountRaw: order.filledAmountRaw,
|
|
4133
|
+
remainingAmountRaw: order.remainingAmountRaw,
|
|
4134
|
+
actualSharesRaw: order.actualSharesRaw,
|
|
4135
|
+
actualToWinRaw: order.actualToWinRaw,
|
|
4136
|
+
quotedSharesRaw: order.quotedSharesRaw,
|
|
4137
|
+
quotedToWinRaw: order.quotedToWinRaw,
|
|
4138
|
+
executionPriceRaw: order.executionPriceRaw,
|
|
4139
|
+
quotedPriceRaw: order.quotedPriceRaw,
|
|
4140
|
+
errorReason: (_b = order.errorReason) != null ? _b : order.partialFillReason,
|
|
4141
|
+
timestamp: new Date(order.updatedAt).getTime() || fallbackTimestamp
|
|
4142
|
+
};
|
|
4143
|
+
}).filter((order) => order != null);
|
|
4144
|
+
if (!status.terminal || terminalEvents.length > 0 || !["failed", "cancelled", "expired"].includes(status.overallState)) {
|
|
4145
|
+
return terminalEvents;
|
|
4146
|
+
}
|
|
4147
|
+
return fallbackOrderIds.map((orderId) => {
|
|
4148
|
+
var _a;
|
|
4149
|
+
return {
|
|
4150
|
+
orderId,
|
|
4151
|
+
venue: "",
|
|
4152
|
+
event: "failed",
|
|
4153
|
+
errorReason: (_a = status.errorReason) != null ? _a : "Execution failed.",
|
|
4154
|
+
timestamp: fallbackTimestamp
|
|
4155
|
+
};
|
|
4156
|
+
});
|
|
4157
|
+
},
|
|
4158
|
+
[]
|
|
4159
|
+
);
|
|
4160
|
+
const setFatalPollingFailure = useCallback7((message, failedOrderIds) => {
|
|
4161
|
+
setDagProgress((prev) => {
|
|
4162
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4163
|
+
return {
|
|
4164
|
+
dagRunId: (_a = prev == null ? void 0 : prev.dagRunId) != null ? _a : "",
|
|
4165
|
+
totalSteps: (_b = prev == null ? void 0 : prev.totalSteps) != null ? _b : 0,
|
|
4166
|
+
currentSequence: (_c = prev == null ? void 0 : prev.currentSequence) != null ? _c : 0,
|
|
4167
|
+
currentStepType: (_d = prev == null ? void 0 : prev.currentStepType) != null ? _d : null,
|
|
4168
|
+
completedSequences: (_e = prev == null ? void 0 : prev.completedSequences) != null ? _e : [],
|
|
4169
|
+
stepTypes: (_f = prev == null ? void 0 : prev.stepTypes) != null ? _f : {},
|
|
4170
|
+
status: "failed",
|
|
4171
|
+
errorReason: message
|
|
4172
|
+
};
|
|
4173
|
+
});
|
|
4174
|
+
setTerminalOrderEvents((prev) => {
|
|
4175
|
+
const existingByOrderId = new Map(prev.map((event) => [event.orderId, event]));
|
|
4176
|
+
const timestamp = Date.now();
|
|
4177
|
+
for (const orderId of failedOrderIds) {
|
|
4178
|
+
if (existingByOrderId.has(orderId)) continue;
|
|
4179
|
+
existingByOrderId.set(orderId, {
|
|
4180
|
+
orderId,
|
|
4181
|
+
venue: "",
|
|
4182
|
+
event: "failed",
|
|
4183
|
+
errorReason: message,
|
|
4184
|
+
timestamp
|
|
4185
|
+
});
|
|
4186
|
+
}
|
|
4187
|
+
return Array.from(existingByOrderId.values()).sort(
|
|
4188
|
+
(left, right) => left.timestamp - right.timestamp
|
|
4189
|
+
);
|
|
4190
|
+
});
|
|
4191
|
+
}, []);
|
|
3897
4192
|
useEffect5(() => {
|
|
3898
4193
|
terminalOrderIdsRef.current = new Set(terminalOrderEvents.map((e) => e.orderId));
|
|
3899
4194
|
}, [terminalOrderEvents]);
|
|
3900
4195
|
useEffect5(() => {
|
|
4196
|
+
if (!isStatusPolling || !quoteId) return;
|
|
4197
|
+
let cancelled = false;
|
|
4198
|
+
let timeout = null;
|
|
4199
|
+
const stopPolling = () => {
|
|
4200
|
+
if (timeout !== null) {
|
|
4201
|
+
clearTimeout(timeout);
|
|
4202
|
+
timeout = null;
|
|
4203
|
+
}
|
|
4204
|
+
};
|
|
4205
|
+
const scheduleNextPoll = (delayMs) => {
|
|
4206
|
+
if (cancelled) return;
|
|
4207
|
+
timeout = setTimeout(() => {
|
|
4208
|
+
void pollExecutionStatus();
|
|
4209
|
+
}, delayMs != null ? delayMs : ORDER_POLL_INTERVAL_MS);
|
|
4210
|
+
};
|
|
4211
|
+
const pollExecutionStatus = () => __async(null, null, function* () {
|
|
4212
|
+
if (cancelled || pollInFlightRef.current) return;
|
|
4213
|
+
pollInFlightRef.current = true;
|
|
4214
|
+
try {
|
|
4215
|
+
const status = yield client.getExecutionStatus(__spreadValues({
|
|
4216
|
+
quoteId
|
|
4217
|
+
}, mode ? { mode } : {}));
|
|
4218
|
+
if (cancelled) return;
|
|
4219
|
+
const resolvedOrderIds = status.orderIds.length > 0 ? status.orderIds : orderIds != null ? orderIds : [];
|
|
4220
|
+
if (resolvedOrderIds.length > 0) {
|
|
4221
|
+
setPhase("order_submitted");
|
|
4222
|
+
}
|
|
4223
|
+
setSubmittedOrders(buildSubmittedOrdersFromStatus(status.orders));
|
|
4224
|
+
if (status.dagProgress) {
|
|
4225
|
+
setDagProgress(__spreadProps(__spreadValues({}, status.dagProgress), {
|
|
4226
|
+
stepTypes: Object.fromEntries(
|
|
4227
|
+
Object.entries(status.dagProgress.stepTypes).map(([sequence, stepType]) => [
|
|
4228
|
+
Number(sequence),
|
|
4229
|
+
stepType
|
|
4230
|
+
])
|
|
4231
|
+
)
|
|
4232
|
+
}));
|
|
4233
|
+
} else if (status.terminal && ["failed", "cancelled", "expired"].includes(status.overallState)) {
|
|
4234
|
+
setDagProgress((prev) => {
|
|
4235
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4236
|
+
return {
|
|
4237
|
+
dagRunId: (_b = (_a = prev == null ? void 0 : prev.dagRunId) != null ? _a : status.executionId) != null ? _b : "",
|
|
4238
|
+
totalSteps: (_c = prev == null ? void 0 : prev.totalSteps) != null ? _c : status.steps.length,
|
|
4239
|
+
currentSequence: (_d = prev == null ? void 0 : prev.currentSequence) != null ? _d : 0,
|
|
4240
|
+
currentStepType: (_e = prev == null ? void 0 : prev.currentStepType) != null ? _e : null,
|
|
4241
|
+
completedSequences: (_f = prev == null ? void 0 : prev.completedSequences) != null ? _f : [],
|
|
4242
|
+
stepTypes: (_g = prev == null ? void 0 : prev.stepTypes) != null ? _g : {},
|
|
4243
|
+
status: "failed",
|
|
4244
|
+
errorReason: status.errorReason
|
|
4245
|
+
};
|
|
4246
|
+
});
|
|
4247
|
+
}
|
|
4248
|
+
const fallbackTimestamp = Date.now();
|
|
4249
|
+
const nextTerminalEvents = buildTerminalEventsFromStatus(
|
|
4250
|
+
status,
|
|
4251
|
+
resolvedOrderIds,
|
|
4252
|
+
fallbackTimestamp
|
|
4253
|
+
);
|
|
4254
|
+
setTerminalOrderEvents(nextTerminalEvents);
|
|
4255
|
+
if (status.terminal) {
|
|
4256
|
+
stopPolling();
|
|
4257
|
+
return;
|
|
4258
|
+
}
|
|
4259
|
+
scheduleNextPoll(status.pollAfterMs);
|
|
4260
|
+
} catch (error) {
|
|
4261
|
+
if (cancelled) return;
|
|
4262
|
+
const statusCode = typeof error === "object" && error != null && "status" in error && typeof error.status === "number" ? error.status : null;
|
|
4263
|
+
if (statusCode === 400 || statusCode === 401 || statusCode === 403) {
|
|
4264
|
+
setFatalPollingFailure(
|
|
4265
|
+
error instanceof Error ? error.message : "Execution status polling failed.",
|
|
4266
|
+
orderIds != null ? orderIds : []
|
|
4267
|
+
);
|
|
4268
|
+
stopPolling();
|
|
4269
|
+
return;
|
|
4270
|
+
}
|
|
4271
|
+
scheduleNextPoll(ORDER_POLL_INTERVAL_MS);
|
|
4272
|
+
} finally {
|
|
4273
|
+
pollInFlightRef.current = false;
|
|
4274
|
+
}
|
|
4275
|
+
});
|
|
4276
|
+
void pollExecutionStatus();
|
|
4277
|
+
return () => {
|
|
4278
|
+
cancelled = true;
|
|
4279
|
+
stopPolling();
|
|
4280
|
+
};
|
|
4281
|
+
}, [
|
|
4282
|
+
buildSubmittedOrdersFromStatus,
|
|
4283
|
+
buildTerminalEventsFromStatus,
|
|
4284
|
+
client,
|
|
4285
|
+
isStatusPolling,
|
|
4286
|
+
mode,
|
|
4287
|
+
orderIds,
|
|
4288
|
+
quoteId,
|
|
4289
|
+
setFatalPollingFailure
|
|
4290
|
+
]);
|
|
4291
|
+
useEffect5(() => {
|
|
4292
|
+
if (isStatusPolling) return;
|
|
3901
4293
|
if (!isListening || !(orderIds == null ? void 0 : orderIds.length)) return;
|
|
3902
4294
|
let cancelled = false;
|
|
3903
4295
|
let interval = null;
|
|
@@ -3985,7 +4377,7 @@ function useExecutionProgress({
|
|
|
3985
4377
|
cancelled = true;
|
|
3986
4378
|
stopPolling();
|
|
3987
4379
|
};
|
|
3988
|
-
}, [client, isListening, mode, orderIds]);
|
|
4380
|
+
}, [client, isListening, isStatusPolling, mode, orderIds]);
|
|
3989
4381
|
return { phase, submittedOrders, latestBalance, dagProgress, terminalOrderEvents };
|
|
3990
4382
|
}
|
|
3991
4383
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useOnWithdrawalLifecycle,
|
|
12
12
|
useSyncBalances,
|
|
13
13
|
useWithdrawManaged
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-56RISN73.mjs";
|
|
15
15
|
|
|
16
16
|
// src/withdraw/use-withdraw-flow.ts
|
|
17
17
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
package/dist/deposit.d.mts
CHANGED
|
@@ -189,7 +189,7 @@ declare function useDepositFlow(options: UseDepositFlowOptions): UseDepositFlowR
|
|
|
189
189
|
* Back-compat alias for callers that still want a single default endpoint.
|
|
190
190
|
* New code should prefer the full list and the failover helper.
|
|
191
191
|
*/
|
|
192
|
-
declare const DEFAULT_SOLANA_RPC_ENDPOINT
|
|
192
|
+
declare const DEFAULT_SOLANA_RPC_ENDPOINT = "https://solana-rpc.publicnode.com";
|
|
193
193
|
declare const SVM_CHAIN_IDS: ReadonlySet<number>;
|
|
194
194
|
|
|
195
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
|
@@ -189,7 +189,7 @@ declare function useDepositFlow(options: UseDepositFlowOptions): UseDepositFlowR
|
|
|
189
189
|
* Back-compat alias for callers that still want a single default endpoint.
|
|
190
190
|
* New code should prefer the full list and the failover helper.
|
|
191
191
|
*/
|
|
192
|
-
declare const DEFAULT_SOLANA_RPC_ENDPOINT
|
|
192
|
+
declare const DEFAULT_SOLANA_RPC_ENDPOINT = "https://solana-rpc.publicnode.com";
|
|
193
193
|
declare const SVM_CHAIN_IDS: ReadonlySet<number>;
|
|
194
194
|
|
|
195
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 };
|