@orderly.network/hooks 2.8.1 → 2.8.2

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/index.js CHANGED
@@ -4,22 +4,24 @@ var net = require('@orderly.network/net');
4
4
  var useSWR = require('swr');
5
5
  var types = require('@orderly.network/types');
6
6
  var React2 = require('react');
7
- var useSWRMutation = require('swr/mutation');
8
7
  var utils = require('@orderly.network/utils');
8
+ var useSWRMutation = require('swr/mutation');
9
9
  var useConstant = require('use-constant');
10
10
  var core = require('@orderly.network/core');
11
11
  var lodash = require('lodash');
12
12
  var useSWRInfinite = require('swr/infinite');
13
13
  var ramda = require('ramda');
14
14
  var perp = require('@orderly.network/perp');
15
+ var zustand = require('zustand');
16
+ var immer = require('zustand/middleware/immer');
17
+ var pathOr = require('ramda/es/pathOr');
18
+ var middleware = require('zustand/middleware');
15
19
  var useSWRSubscription = require('swr/subscription');
16
20
  var amplitude = require('@amplitude/analytics-browser');
17
21
  var jsxRuntime = require('react/jsx-runtime');
18
22
  var defaultEvmAdapter = require('@orderly.network/default-evm-adapter');
19
23
  var defaultSolanaAdapter = require('@orderly.network/default-solana-adapter');
20
24
  var web3ProviderEthers = require('@orderly.network/web3-provider-ethers');
21
- var zustand = require('zustand');
22
- var immer = require('zustand/middleware/immer');
23
25
  var useDebounce = require('use-debounce');
24
26
  var immer$1 = require('immer');
25
27
  var qr = require('@akamfoad/qr');
@@ -49,6 +51,7 @@ var React2__default = /*#__PURE__*/_interopDefault(React2);
49
51
  var useSWRMutation__default = /*#__PURE__*/_interopDefault(useSWRMutation);
50
52
  var useConstant__default = /*#__PURE__*/_interopDefault(useConstant);
51
53
  var useSWRInfinite__default = /*#__PURE__*/_interopDefault(useSWRInfinite);
54
+ var pathOr__default = /*#__PURE__*/_interopDefault(pathOr);
52
55
  var useSWRSubscription__default = /*#__PURE__*/_interopDefault(useSWRSubscription);
53
56
  var amplitude__namespace = /*#__PURE__*/_interopNamespace(amplitude);
54
57
 
@@ -61,9 +64,9 @@ var __export = (target, all) => {
61
64
  // src/version.ts
62
65
  if (typeof window !== "undefined") {
63
66
  window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
64
- window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.8.1";
67
+ window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.8.2";
65
68
  }
66
- var version_default = "2.8.1";
69
+ var version_default = "2.8.2";
67
70
  var fetcher = (url, init2 = {}, queryOptions) => net.get(url, init2, queryOptions?.formatter);
68
71
  var noCacheConfig = {
69
72
  dedupingInterval: 0,
@@ -110,6 +113,69 @@ var useQuery = (query, options) => {
110
113
  swrOptions
111
114
  );
112
115
  };
116
+ var timestampOffsetPromise = null;
117
+ var timestampOffsetReady = false;
118
+ var timestampWaitingMiddleware = (useSWRNext) => {
119
+ return (key, fetcher4, config) => {
120
+ if (!fetcher4) {
121
+ return useSWRNext(key, fetcher4, config);
122
+ }
123
+ const wrappedFetcher = async (...args) => {
124
+ await getTimestampOffsetPromise();
125
+ return fetcher4(...args);
126
+ };
127
+ return useSWRNext(key, wrappedFetcher, config);
128
+ };
129
+ };
130
+ function getTimestampOffsetPromise() {
131
+ if (timestampOffsetReady) {
132
+ return Promise.resolve();
133
+ }
134
+ if (timestampOffsetPromise) {
135
+ return timestampOffsetPromise;
136
+ }
137
+ timestampOffsetPromise = waitForTimestampOffset();
138
+ timestampOffsetPromise.then(() => {
139
+ timestampOffsetReady = true;
140
+ }).catch(() => {
141
+ timestampOffsetPromise = null;
142
+ });
143
+ return timestampOffsetPromise;
144
+ }
145
+ async function waitForTimestampOffset(maxWaitTime = 3e4) {
146
+ let globalObj;
147
+ try {
148
+ globalObj = utils.getGlobalObject();
149
+ } catch {
150
+ throw new Error("Failed to access global object");
151
+ }
152
+ const checkTimestampOffset = () => {
153
+ return typeof globalObj.__ORDERLY_timestamp_offset === "number";
154
+ };
155
+ if (checkTimestampOffset()) {
156
+ return;
157
+ }
158
+ return new Promise((resolve, reject) => {
159
+ let attempts = 0;
160
+ const maxAttempts = maxWaitTime / 100;
161
+ const pollInterval = setInterval(() => {
162
+ attempts++;
163
+ if (checkTimestampOffset()) {
164
+ clearInterval(pollInterval);
165
+ resolve();
166
+ } else if (attempts >= maxAttempts) {
167
+ clearInterval(pollInterval);
168
+ reject(
169
+ new Error("Timeout waiting for timestamp offset initialization")
170
+ );
171
+ }
172
+ }, 100);
173
+ });
174
+ }
175
+ function resetTimestampOffsetState() {
176
+ timestampOffsetPromise = null;
177
+ timestampOffsetReady = false;
178
+ }
113
179
  var useLazyQuery = (query, options) => {
114
180
  const apiBaseUrl = useConfig("apiBaseUrl");
115
181
  const { formatter, init: init2, ...swrOptions } = options || {};
@@ -2061,90 +2127,710 @@ var useReferralInfo = () => {
2061
2127
  getFirstRefCode
2062
2128
  };
2063
2129
  };
2064
- var usePreLoadData = () => {
2065
- const [timestampOffsetInitialized, setTimestampOffsetInitialized] = React2.useState(false);
2066
- const { error: tokenError, data: tokenData } = useQuery(
2067
- "https://api.orderly.org/v1/public/token",
2068
- {
2069
- revalidateOnFocus: false
2070
- }
2071
- );
2072
- const apiBaseUrl = useConfig("apiBaseUrl");
2073
- const { data: systemInfo } = useSWR__namespace.default(
2074
- "/v1/public/system_info",
2075
- async (url, init2) => {
2076
- const data = await fetch(
2077
- url.startsWith("http") ? url : `${apiBaseUrl}${url}`,
2078
- init2
2079
- );
2080
- return await data.json();
2130
+ var useAppStore = zustand.create()(
2131
+ immer.immer((set) => ({
2132
+ // accountInfo: null,
2133
+ portfolio: {
2134
+ totalCollateral: utils.zero,
2135
+ totalValue: null,
2136
+ freeCollateral: utils.zero,
2137
+ availableBalance: 0,
2138
+ unsettledPnL: 0,
2139
+ totalUnrealizedROI: 0
2081
2140
  },
2082
- {
2083
- errorRetryCount: 3,
2084
- errorRetryInterval: 500
2085
- }
2086
- );
2087
- React2.useEffect(() => {
2088
- if (timestampOffsetInitialized)
2089
- return;
2090
- if (typeof systemInfo !== "undefined") {
2091
- const sd = systemInfo.timestamp;
2092
- const ld = Date.now();
2093
- const diff = sd - ld;
2094
- if (isNaN(diff)) {
2095
- return;
2141
+ appState: {
2142
+ positionsLoading: false,
2143
+ ordersLoading: false,
2144
+ fundingRatesLoading: false,
2145
+ ready: false
2146
+ },
2147
+ actions: {
2148
+ setTokensInfo: (tokensInfo) => {
2149
+ set((state) => {
2150
+ state.tokensInfo = tokensInfo;
2151
+ }, false);
2152
+ },
2153
+ cleanAll: () => {
2154
+ set((state) => {
2155
+ state.accountInfo = void 0;
2156
+ state.portfolio = {
2157
+ totalCollateral: utils.zero,
2158
+ totalValue: null,
2159
+ freeCollateral: utils.zero,
2160
+ availableBalance: 0,
2161
+ unsettledPnL: 0,
2162
+ totalUnrealizedROI: 0
2163
+ };
2164
+ }, false);
2165
+ },
2166
+ setAccountInfo: (accountInfo) => {
2167
+ set(
2168
+ (state) => {
2169
+ state.accountInfo = accountInfo;
2170
+ },
2171
+ false
2172
+ // "setAccountInfo"
2173
+ );
2174
+ },
2175
+ setSymbolsInfo: (symbolsInfo) => {
2176
+ set(
2177
+ (state) => {
2178
+ state.symbolsInfo = symbolsInfo;
2179
+ },
2180
+ false
2181
+ // "setSymbolsInfo"
2182
+ );
2183
+ },
2184
+ setRwaSymbolsInfo: (rwaSymbolsInfo) => {
2185
+ set(
2186
+ (state) => {
2187
+ state.rwaSymbolsInfo = rwaSymbolsInfo;
2188
+ },
2189
+ false
2190
+ // "setRwaSymbolsInfo"
2191
+ );
2192
+ },
2193
+ setFundingRates: (fundingRates) => {
2194
+ set(
2195
+ (state) => {
2196
+ state.fundingRates = fundingRates;
2197
+ },
2198
+ false
2199
+ // "setFundingRates"
2200
+ );
2201
+ },
2202
+ updateAppStatus: (key, value) => {
2203
+ set(
2204
+ (state) => {
2205
+ state.appState[key] = value;
2206
+ },
2207
+ false
2208
+ // "updateAppStatus"
2209
+ );
2210
+ },
2211
+ updatePortfolio: (key, value) => {
2212
+ set(
2213
+ (state) => {
2214
+ state.portfolio[key] = value;
2215
+ },
2216
+ false
2217
+ // "updatePortfolio"
2218
+ );
2219
+ },
2220
+ batchUpdateForPortfolio: (data) => {
2221
+ set(
2222
+ (state) => {
2223
+ state.portfolio = { ...state.portfolio, ...data };
2224
+ },
2225
+ false
2226
+ // "batchUpdateForPortfolio"
2227
+ );
2228
+ },
2229
+ restoreHolding: (holding) => {
2230
+ set(
2231
+ (state) => {
2232
+ state.portfolio.holding = holding;
2233
+ },
2234
+ false
2235
+ // "updateHolding"
2236
+ );
2237
+ },
2238
+ updateHolding(msg) {
2239
+ set(
2240
+ (state) => {
2241
+ if (state.portfolio.holding && state.portfolio.holding.length) {
2242
+ for (const key in msg) {
2243
+ const holding = state.portfolio.holding.find(
2244
+ (item) => item.token === key
2245
+ );
2246
+ if (holding) {
2247
+ holding.holding = msg[key].holding;
2248
+ holding.frozen = msg[key].frozen;
2249
+ }
2250
+ }
2251
+ }
2252
+ },
2253
+ false
2254
+ // "updateHolding"
2255
+ );
2096
2256
  }
2097
- utils.getGlobalObject().__ORDERLY_timestamp_offset = diff;
2098
- setTimestampOffsetInitialized(true);
2099
2257
  }
2100
- }, [systemInfo, timestampOffsetInitialized]);
2101
- const isDone = React2.useMemo(() => {
2102
- return !!tokenData && timestampOffsetInitialized;
2103
- }, [timestampOffsetInitialized, tokenData]);
2104
- return {
2105
- error: tokenError,
2106
- done: isDone
2107
- };
2258
+ }))
2259
+ );
2260
+ var useAccountInfo = () => useAppStore((state) => state.accountInfo);
2261
+ var usePortfolio = () => useAppStore((state) => state.portfolio);
2262
+ var useFundingRateBySymbol = (symbol) => useAppStore((state) => state.fundingRates?.[symbol]);
2263
+
2264
+ // src/middleware/indexedDBManager.ts
2265
+ var ORDERLY_SYMBOLS = {
2266
+ name: "ORDERLY_SYMBOLS",
2267
+ keyPath: "symbol",
2268
+ autoIncrement: false
2108
2269
  };
2109
- function useSessionStorage(key, initialValue) {
2110
- const readValue = React2.useCallback(() => {
2111
- if (typeof window === "undefined") {
2112
- return initialValue;
2270
+ var ORDERLY_MAIN_CHAIN_INFO = {
2271
+ name: "ORDERLY_MAIN_CHAIN_INFO",
2272
+ keyPath: "chain_id",
2273
+ autoIncrement: false
2274
+ };
2275
+ var ORDERLY_TEST_CHAIN_INFO = {
2276
+ name: "ORDERLY_TEST_CHAIN_INFO",
2277
+ keyPath: "chain_id",
2278
+ autoIncrement: false
2279
+ };
2280
+ var ORDERLY_MAIN_TOKEN = {
2281
+ name: "ORDERLY_MAIN_TOKEN",
2282
+ keyPath: "token",
2283
+ autoIncrement: false
2284
+ };
2285
+ var ORDERLY_TEST_TOKEN = {
2286
+ name: "ORDERLY_TEST_TOKEN",
2287
+ keyPath: "token",
2288
+ autoIncrement: false
2289
+ };
2290
+ var DEFAULT_DATABASE_CONFIG = {
2291
+ name: "ORDERLY_STORE",
2292
+ version: 4,
2293
+ stores: [
2294
+ ORDERLY_MAIN_CHAIN_INFO,
2295
+ ORDERLY_TEST_CHAIN_INFO,
2296
+ ORDERLY_MAIN_TOKEN,
2297
+ ORDERLY_SYMBOLS,
2298
+ ORDERLY_TEST_TOKEN
2299
+ ]
2300
+ };
2301
+ var IndexedDBManager = class _IndexedDBManager {
2302
+ constructor() {
2303
+ this.connections = /* @__PURE__ */ new Map();
2304
+ this.databaseConfig = null;
2305
+ /** Promise that resolves when database initialization is complete */
2306
+ this.initializationPromise = null;
2307
+ }
2308
+ static getInstance() {
2309
+ if (!_IndexedDBManager.instance) {
2310
+ _IndexedDBManager.instance = new _IndexedDBManager();
2113
2311
  }
2114
- try {
2115
- const item = window.sessionStorage.getItem(key);
2116
- return item ? parseJSON(item) : initialValue;
2117
- } catch (error) {
2118
- return initialValue;
2312
+ return _IndexedDBManager.instance;
2313
+ }
2314
+ async initializeDatabase(config) {
2315
+ if (this.initializationPromise) {
2316
+ return this.initializationPromise;
2119
2317
  }
2120
- }, [initialValue, key]);
2121
- const [storedValue, setStoredValue] = React2.useState(readValue);
2122
- const setValue = (value) => {
2123
- try {
2124
- const newValue = value instanceof Function ? value(storedValue) : value;
2125
- window.sessionStorage.setItem(key, JSON.stringify(newValue));
2126
- setStoredValue(newValue);
2127
- } catch (error) {
2318
+ this.initializationPromise = this._performInitialization(config);
2319
+ return this.initializationPromise;
2320
+ }
2321
+ /**
2322
+ * Performs the actual database initialization
2323
+ * Now keeps the connection open for better performance
2324
+ */
2325
+ async _performInitialization(config) {
2326
+ this.databaseConfig = config;
2327
+ return new Promise((resolve, reject) => {
2328
+ const request = indexedDB.open(config.name, config.version);
2329
+ request.onupgradeneeded = (event) => {
2330
+ const db = event.target.result;
2331
+ config.stores.forEach((storeConfig) => {
2332
+ if (!db.objectStoreNames.contains(storeConfig.name)) {
2333
+ db.createObjectStore(storeConfig.name, {
2334
+ keyPath: storeConfig.keyPath,
2335
+ autoIncrement: storeConfig.autoIncrement ?? true
2336
+ });
2337
+ }
2338
+ });
2339
+ };
2340
+ request.onsuccess = () => {
2341
+ const db = request.result;
2342
+ this.connections.set(config.name, db);
2343
+ db.addEventListener("close", () => {
2344
+ this.connections.delete(config.name);
2345
+ });
2346
+ resolve();
2347
+ };
2348
+ request.onerror = () => {
2349
+ this._handleInitializationError(config.name, request.error);
2350
+ reject(request.error);
2351
+ };
2352
+ request.onblocked = () => {
2353
+ const error = new Error(
2354
+ `Database '${config.name}' is blocked by another connection`
2355
+ );
2356
+ this._handleInitializationError(config.name, error);
2357
+ reject(error);
2358
+ };
2359
+ });
2360
+ }
2361
+ /**
2362
+ * Handles initialization errors consistently
2363
+ */
2364
+ _handleInitializationError(dbName, error) {
2365
+ this.initializationPromise = null;
2366
+ }
2367
+ async getConnection(dbName, storeName) {
2368
+ await this.ensureInitialized();
2369
+ if (this.connections.has(dbName)) {
2370
+ const existingConnection = this.connections.get(dbName);
2371
+ try {
2372
+ if (existingConnection.objectStoreNames.contains(storeName)) {
2373
+ return existingConnection;
2374
+ }
2375
+ } catch {
2376
+ this.connections.delete(dbName);
2377
+ }
2128
2378
  }
2129
- };
2130
- React2.useEffect(() => {
2131
- setStoredValue(readValue());
2132
- }, []);
2133
- React2.useEffect(() => {
2134
- if (typeof window == "undefined") {
2135
- return;
2379
+ const db = await this.createConnection(dbName);
2380
+ this.connections.set(dbName, db);
2381
+ db.addEventListener("close", () => {
2382
+ this.connections.delete(dbName);
2383
+ });
2384
+ return db;
2385
+ }
2386
+ /**
2387
+ * Ensures database is initialized, initializes if not already done
2388
+ */
2389
+ async ensureInitialized() {
2390
+ if (this.initializationPromise) {
2391
+ return this.initializationPromise;
2136
2392
  }
2137
- window.addEventListener?.("storage", handleStorageChange);
2138
- return () => {
2139
- window.removeEventListener?.("storage", handleStorageChange);
2140
- };
2141
- });
2142
- const handleStorageChange = React2.useCallback(
2143
- (event) => {
2144
- if (event?.key && event.key !== key) {
2145
- return;
2146
- }
2147
- setStoredValue(readValue());
2393
+ if (!this.databaseConfig) {
2394
+ return this.initializeDatabase(DEFAULT_DATABASE_CONFIG);
2395
+ }
2396
+ const isActuallyInitialized = await this._checkDatabaseExists();
2397
+ if (!isActuallyInitialized) {
2398
+ this.initializationPromise = null;
2399
+ return this.initializeDatabase(this.databaseConfig);
2400
+ }
2401
+ this.initializationPromise = Promise.resolve();
2402
+ return this.initializationPromise;
2403
+ }
2404
+ /**
2405
+ * Creates a new database connection
2406
+ */
2407
+ async createConnection(dbName) {
2408
+ const config = this.databaseConfig;
2409
+ if (!config) {
2410
+ throw new Error(
2411
+ "Database not initialized. Call initializeDatabase() first."
2412
+ );
2413
+ }
2414
+ return new Promise((resolve, reject) => {
2415
+ const request = indexedDB.open(dbName, config.version);
2416
+ request.onsuccess = () => {
2417
+ resolve(request.result);
2418
+ };
2419
+ request.onerror = () => {
2420
+ reject(request.error);
2421
+ };
2422
+ });
2423
+ }
2424
+ /**
2425
+ * Checks if database and all required stores exist
2426
+ */
2427
+ async _checkDatabaseExists() {
2428
+ if (!this.databaseConfig) {
2429
+ return false;
2430
+ }
2431
+ try {
2432
+ return new Promise((resolve) => {
2433
+ const config = this.databaseConfig;
2434
+ const request = indexedDB.open(config.name, config.version);
2435
+ request.onsuccess = () => {
2436
+ const db = request.result;
2437
+ const config2 = this.databaseConfig;
2438
+ const allStoresExist = config2.stores.every(
2439
+ (store) => db.objectStoreNames.contains(store.name)
2440
+ );
2441
+ db.close();
2442
+ resolve(allStoresExist);
2443
+ };
2444
+ request.onerror = () => resolve(false);
2445
+ });
2446
+ } catch {
2447
+ return false;
2448
+ }
2449
+ }
2450
+ };
2451
+ var indexedDBManager = IndexedDBManager.getInstance();
2452
+ var initializeAppDatabase = async (config) => {
2453
+ try {
2454
+ await indexedDBManager.initializeDatabase(config);
2455
+ } catch (error) {
2456
+ throw error;
2457
+ }
2458
+ };
2459
+ var createIndexedDBStorage = (config) => {
2460
+ const { dbName, storeName } = config;
2461
+ const getDB = async () => {
2462
+ return indexedDBManager.getConnection(dbName, storeName);
2463
+ };
2464
+ const executeTransaction = async (operation, mode = "readwrite") => {
2465
+ const dbInstance = await getDB();
2466
+ const transaction = dbInstance.transaction(storeName, mode);
2467
+ const store = transaction.objectStore(storeName);
2468
+ return new Promise((resolve, reject) => {
2469
+ const result = operation(store);
2470
+ transaction.oncomplete = () => resolve(result);
2471
+ transaction.onerror = () => {
2472
+ reject(transaction.error);
2473
+ };
2474
+ transaction.onabort = () => {
2475
+ reject(new Error("Transaction was aborted"));
2476
+ };
2477
+ });
2478
+ };
2479
+ const getItem = async () => {
2480
+ try {
2481
+ const allValues = await executeTransaction((store) => {
2482
+ return new Promise((resolve, reject) => {
2483
+ const request = store.getAll();
2484
+ request.onsuccess = () => {
2485
+ const result = request.result;
2486
+ resolve(result.length > 0 ? result : []);
2487
+ };
2488
+ request.onerror = () => reject(request.error);
2489
+ });
2490
+ }, "readonly");
2491
+ return allValues.length > 0 ? allValues : null;
2492
+ } catch (error) {
2493
+ return null;
2494
+ }
2495
+ };
2496
+ const setItem = async (value) => {
2497
+ try {
2498
+ await executeTransaction((store) => {
2499
+ store.clear();
2500
+ value.forEach((item) => store.put(item));
2501
+ return void 0;
2502
+ }, "readwrite");
2503
+ } catch (error) {
2504
+ throw error;
2505
+ }
2506
+ };
2507
+ const removeItem = async () => {
2508
+ try {
2509
+ await executeTransaction((store) => {
2510
+ store.clear();
2511
+ return void 0;
2512
+ }, "readwrite");
2513
+ } catch (error) {
2514
+ throw error;
2515
+ }
2516
+ };
2517
+ return {
2518
+ getItem,
2519
+ setItem,
2520
+ removeItem
2521
+ };
2522
+ };
2523
+ var adaptToStateStorage = (indexedDBStorage) => ({
2524
+ getItem: async () => {
2525
+ try {
2526
+ const result = await indexedDBStorage.getItem();
2527
+ return result && Array.isArray(result) && result.length > 0 ? JSON.stringify({
2528
+ state: result,
2529
+ version: 0
2530
+ }) : null;
2531
+ } catch (error) {
2532
+ return null;
2533
+ }
2534
+ },
2535
+ setItem: async (_name, value) => {
2536
+ try {
2537
+ const parsed = JSON.parse(value);
2538
+ const stateData = pathOr__default.default([], ["state"], parsed);
2539
+ if (Array.isArray(stateData) && stateData.length > 0) {
2540
+ await indexedDBStorage.setItem(stateData);
2541
+ }
2542
+ } catch (error) {
2543
+ }
2544
+ },
2545
+ removeItem: async () => {
2546
+ try {
2547
+ await indexedDBStorage.removeItem();
2548
+ } catch (error) {
2549
+ }
2550
+ }
2551
+ });
2552
+ var persistIndexedDB = (initializer, options) => {
2553
+ const { indexedDBConfig, ...rest } = options;
2554
+ const indexedDBStorage = createIndexedDBStorage(indexedDBConfig);
2555
+ const jsonStorage = middleware.createJSONStorage(
2556
+ () => adaptToStateStorage(indexedDBStorage)
2557
+ );
2558
+ return middleware.persist(initializer, {
2559
+ ...rest,
2560
+ storage: jsonStorage
2561
+ });
2562
+ };
2563
+
2564
+ // src/provider/store/createDataStore.ts
2565
+ var createDataStore = (config) => {
2566
+ const {
2567
+ name,
2568
+ dbName,
2569
+ storeName,
2570
+ keyPath,
2571
+ endpoint,
2572
+ baseUrl,
2573
+ formatter = (data) => pathOr__default.default([], ["rows"], data),
2574
+ initData
2575
+ // brokerId,
2576
+ } = config;
2577
+ return zustand.create(
2578
+ persistIndexedDB(
2579
+ (set) => ({
2580
+ name: storeName,
2581
+ data: typeof initData === "undefined" ? [] : initData,
2582
+ loading: false,
2583
+ error: null,
2584
+ fetchData: async (dynamicBaseUrl, options) => {
2585
+ try {
2586
+ set({ loading: true });
2587
+ const brokerIdQuery = typeof options?.brokerId === "string" && options?.brokerId !== "orderly" ? `?broker_id=${options?.brokerId}` : "";
2588
+ const url = `${dynamicBaseUrl || baseUrl || ""}${endpoint}${brokerIdQuery}`;
2589
+ const data = await fetcher(url, {}, { formatter });
2590
+ const dataWithBrokerId = data.map((item) => ({
2591
+ ...item,
2592
+ broker_id: options?.brokerId
2593
+ }));
2594
+ set({
2595
+ data: dataWithBrokerId,
2596
+ loading: false,
2597
+ error: null
2598
+ });
2599
+ return dataWithBrokerId;
2600
+ } catch (error) {
2601
+ set({ error, loading: false });
2602
+ return null;
2603
+ }
2604
+ }
2605
+ }),
2606
+ {
2607
+ name,
2608
+ indexedDBConfig: {
2609
+ dbName,
2610
+ storeName
2611
+ },
2612
+ //@ts-ignore
2613
+ partialize: (state) => state.data,
2614
+ merge: (persisted, current) => {
2615
+ return {
2616
+ ...current,
2617
+ data: persisted
2618
+ };
2619
+ }
2620
+ }
2621
+ )
2622
+ );
2623
+ };
2624
+
2625
+ // src/provider/store/chainInfoMainStore.ts
2626
+ var useMainnetChainsStore = createDataStore({
2627
+ name: "orderly-main-chain-info",
2628
+ dbName: "ORDERLY_STORE",
2629
+ storeName: ORDERLY_MAIN_CHAIN_INFO.name,
2630
+ keyPath: ORDERLY_MAIN_CHAIN_INFO.keyPath,
2631
+ endpoint: "/v1/public/chain_info",
2632
+ baseUrl: "https://api.orderly.org",
2633
+ initData: null
2634
+ });
2635
+ var testnetChainFallback = [types.ArbitrumSepoliaChainInfo, types.SolanaDevnetChainInfo];
2636
+ var useTestnetChainsStore = createDataStore({
2637
+ name: "orderly-test-chain-info",
2638
+ dbName: "ORDERLY_STORE",
2639
+ storeName: ORDERLY_TEST_CHAIN_INFO.name,
2640
+ keyPath: ORDERLY_TEST_CHAIN_INFO.keyPath,
2641
+ endpoint: "/v1/public/chain_info",
2642
+ baseUrl: "https://testnet-api.orderly.org",
2643
+ initData: testnetChainFallback
2644
+ });
2645
+
2646
+ // src/provider/store/mainTokenStore.ts
2647
+ var useMainTokenStore = createDataStore({
2648
+ name: "orderly-main-token",
2649
+ dbName: "ORDERLY_STORE",
2650
+ storeName: ORDERLY_MAIN_TOKEN.name,
2651
+ keyPath: ORDERLY_MAIN_TOKEN.keyPath,
2652
+ endpoint: "/v1/public/token",
2653
+ baseUrl: "https://api.orderly.org"
2654
+ });
2655
+ var useSwapSupportStore = zustand.create()(
2656
+ middleware.persist(
2657
+ (set) => ({
2658
+ data: null,
2659
+ loading: false,
2660
+ error: null,
2661
+ fetchData: async () => {
2662
+ try {
2663
+ set({ loading: true, error: null });
2664
+ const res = await fetch("https://fi-api.woo.org/swap_support");
2665
+ const data = await res.json();
2666
+ if (data.status === "ok") {
2667
+ set({ data: data.data, loading: false, error: null });
2668
+ return data.data;
2669
+ }
2670
+ set((state) => ({
2671
+ data: state.data ?? {},
2672
+ error: new Error(data.message),
2673
+ loading: false
2674
+ }));
2675
+ return null;
2676
+ } catch (error) {
2677
+ set((state) => ({
2678
+ data: state.data ?? {},
2679
+ error,
2680
+ loading: false
2681
+ }));
2682
+ return null;
2683
+ }
2684
+ }
2685
+ }),
2686
+ {
2687
+ name: "orderly-swap-support",
2688
+ // Key for localStorage persistence
2689
+ partialize: (state) => ({ data: state.data })
2690
+ // Only persist data field
2691
+ }
2692
+ )
2693
+ );
2694
+
2695
+ // src/provider/store/symbolStore.ts
2696
+ var useSymbolStore = createDataStore({
2697
+ name: "orderly-main-symbols",
2698
+ dbName: "ORDERLY_STORE",
2699
+ storeName: ORDERLY_SYMBOLS.name,
2700
+ keyPath: ORDERLY_SYMBOLS.keyPath,
2701
+ endpoint: "/v1/public/info"
2702
+ });
2703
+ var testnetTokenFallback = types.TesnetTokenFallback([
2704
+ types.ArbitrumSepoliaTokenInfo,
2705
+ types.SolanaDevnetTokenInfo
2706
+ ]);
2707
+ var useTestTokenStore = createDataStore({
2708
+ name: "orderly-main-token",
2709
+ dbName: "ORDERLY_STORE",
2710
+ storeName: ORDERLY_TEST_TOKEN.name,
2711
+ keyPath: ORDERLY_TEST_TOKEN.keyPath,
2712
+ endpoint: "/v1/public/token",
2713
+ initData: testnetTokenFallback
2714
+ });
2715
+
2716
+ // src/usePreloadData.ts
2717
+ var usePreLoadData = () => {
2718
+ const [timestampOffsetInitialized, setTimestampOffsetInitialized] = React2.useState(false);
2719
+ const { configStore, enableSwapDeposit } = React2.useContext(OrderlyContext);
2720
+ const env = configStore.get("env");
2721
+ const apiBaseUrl = configStore.get("apiBaseUrl");
2722
+ const urlPrefix = env === "prod" ? "https://testnet-api.orderly.org" : configStore.get("apiBaseUrl");
2723
+ const fetchMainTokens = useMainTokenStore((state) => state.fetchData);
2724
+ const fetchTestTokens = useTestTokenStore((state) => state.fetchData);
2725
+ const fetchMainChains = useMainnetChainsStore((state) => state.fetchData);
2726
+ const fetchTestChains = useTestnetChainsStore((state) => state.fetchData);
2727
+ const fetchSymbols = useSymbolStore((state) => state.fetchData);
2728
+ const fetchSwapSupport = useSwapSupportStore((state) => state.fetchData);
2729
+ const setTokensInfo = useAppStore((state) => state.actions.setTokensInfo);
2730
+ const mainTokenInfo = useMainTokenStore((state) => state.data);
2731
+ const testTokenInfo = useTestTokenStore((state) => state.data);
2732
+ const swapSupportInfo = useSwapSupportStore((state) => state.data);
2733
+ React2.useEffect(() => {
2734
+ fetchMainTokens();
2735
+ fetchSymbols(apiBaseUrl).then((symbols) => {
2736
+ });
2737
+ fetchMainChains(void 0, {
2738
+ brokerId: configStore.get("brokerId")
2739
+ });
2740
+ }, []);
2741
+ React2.useEffect(() => {
2742
+ if (!urlPrefix)
2743
+ return;
2744
+ fetchTestTokens(urlPrefix);
2745
+ fetchTestChains(urlPrefix, {
2746
+ brokerId: configStore.get("brokerId")
2747
+ });
2748
+ }, [urlPrefix]);
2749
+ React2.useEffect(() => {
2750
+ if (!mainTokenInfo || !testTokenInfo)
2751
+ return;
2752
+ setTokensInfo(env === "prod" ? mainTokenInfo : testTokenInfo);
2753
+ }, [mainTokenInfo, testTokenInfo]);
2754
+ React2.useEffect(() => {
2755
+ if (swapSupportInfo || !enableSwapDeposit)
2756
+ return;
2757
+ fetchSwapSupport();
2758
+ }, [swapSupportInfo, enableSwapDeposit]);
2759
+ const { data: systemInfo } = useSWR__namespace.default(
2760
+ "/v1/public/system_info",
2761
+ async (url, init2) => {
2762
+ const data = await fetch(
2763
+ url.startsWith("http") ? url : `${apiBaseUrl}${url}`,
2764
+ init2
2765
+ );
2766
+ return await data.json();
2767
+ },
2768
+ {
2769
+ errorRetryCount: 3,
2770
+ errorRetryInterval: 500
2771
+ }
2772
+ );
2773
+ React2.useEffect(() => {
2774
+ if (timestampOffsetInitialized)
2775
+ return;
2776
+ if (typeof systemInfo !== "undefined") {
2777
+ const serverTimestamp = systemInfo.timestamp;
2778
+ const localTimestamp = Date.now();
2779
+ const timestampOffset = serverTimestamp - localTimestamp;
2780
+ if (isNaN(timestampOffset)) {
2781
+ return;
2782
+ }
2783
+ utils.getGlobalObject().__ORDERLY_timestamp_offset = timestampOffset;
2784
+ setTimestampOffsetInitialized(true);
2785
+ }
2786
+ }, [systemInfo, timestampOffsetInitialized]);
2787
+ const isDone = React2.useMemo(() => {
2788
+ return timestampOffsetInitialized;
2789
+ }, [timestampOffsetInitialized]);
2790
+ return {
2791
+ error: null,
2792
+ done: isDone
2793
+ };
2794
+ };
2795
+ function useSessionStorage(key, initialValue) {
2796
+ const readValue = React2.useCallback(() => {
2797
+ if (typeof window === "undefined") {
2798
+ return initialValue;
2799
+ }
2800
+ try {
2801
+ const item = window.sessionStorage.getItem(key);
2802
+ return item ? parseJSON(item) : initialValue;
2803
+ } catch (error) {
2804
+ return initialValue;
2805
+ }
2806
+ }, [initialValue, key]);
2807
+ const [storedValue, setStoredValue] = React2.useState(readValue);
2808
+ const setValue = (value) => {
2809
+ try {
2810
+ const newValue = value instanceof Function ? value(storedValue) : value;
2811
+ window.sessionStorage.setItem(key, JSON.stringify(newValue));
2812
+ setStoredValue(newValue);
2813
+ } catch (error) {
2814
+ }
2815
+ };
2816
+ React2.useEffect(() => {
2817
+ setStoredValue(readValue());
2818
+ }, []);
2819
+ React2.useEffect(() => {
2820
+ if (typeof window == "undefined") {
2821
+ return;
2822
+ }
2823
+ window.addEventListener?.("storage", handleStorageChange);
2824
+ return () => {
2825
+ window.removeEventListener?.("storage", handleStorageChange);
2826
+ };
2827
+ });
2828
+ const handleStorageChange = React2.useCallback(
2829
+ (event) => {
2830
+ if (event?.key && event.key !== key) {
2831
+ return;
2832
+ }
2833
+ setStoredValue(readValue());
2148
2834
  },
2149
2835
  [key, readValue]
2150
2836
  );
@@ -2167,7 +2853,7 @@ var useNetworkInfo = (networkId) => {
2167
2853
  };
2168
2854
 
2169
2855
  // src/orderly/useAccountInfo.ts
2170
- var useAccountInfo = () => {
2856
+ var useAccountInfo2 = () => {
2171
2857
  return usePrivateQuery("/v1/client/info", {
2172
2858
  revalidateOnFocus: false
2173
2859
  });
@@ -2185,7 +2871,7 @@ var computeEffectiveFromBps = (userBps, orderlyBps, rebate) => {
2185
2871
  return effective;
2186
2872
  };
2187
2873
  var useFeeState = () => {
2188
- const { data: accountInfo, isLoading: isAccountLoading } = useAccountInfo();
2874
+ const { data: accountInfo, isLoading: isAccountLoading } = useAccountInfo2();
2189
2875
  const { data: referralData, isLoading: isReferralLoading } = usePrivateQuery("/v1/referral/info", {
2190
2876
  revalidateOnFocus: true,
2191
2877
  errorRetryCount: 3,
@@ -2537,215 +3223,87 @@ var useMarketsStream = () => {
2537
3223
  });
2538
3224
  const topic = "tickers";
2539
3225
  const { data: tickers } = useSWRSubscription__default.default("tickers", (_, { next }) => {
2540
- const unsubscribe = ws.subscribe(
2541
- // { event: "subscribe", topic: "markprices" },
2542
- topic,
2543
- {
2544
- onMessage: (message) => {
2545
- next(null, message);
2546
- }
2547
- // onUnsubscribe: () => {
2548
- // return "markprices";
2549
- // },
2550
- // onError: (error: any) => {
2551
- //
2552
- // },
2553
- }
2554
- );
2555
- return () => {
2556
- unsubscribe?.();
2557
- };
2558
- });
2559
- const value = React2.useMemo(() => {
2560
- if (!futures)
2561
- return null;
2562
- if (!tickers)
2563
- return futures;
2564
- return futures.map((item) => {
2565
- const ticker = tickers.find(
2566
- (t) => t.symbol === item.symbol
2567
- );
2568
- if (ticker) {
2569
- const data = {
2570
- ...item,
2571
- ["24h_close"]: ticker.close,
2572
- ["24h_open"]: ticker.open,
2573
- /**
2574
- * @deprecated
2575
- * spelling mistake, use 24h_volume to instead, will be remove next version
2576
- */
2577
- ["24h_volumn"]: ticker.volume,
2578
- ["24h_volume"]: ticker.volume,
2579
- ["24h_amount"]: ticker.amount,
2580
- change: 0
2581
- };
2582
- if (ticker.close !== void 0 && ticker.open !== void 0) {
2583
- data["change"] = new utils.Decimal(ticker.close).minus(ticker.open).div(ticker.open).toNumber();
2584
- }
2585
- return data;
2586
- }
2587
- return item;
2588
- });
2589
- }, [futures, tickers]);
2590
- return { data: value };
2591
- };
2592
- function createGetter(data, depth = 2) {
2593
- const getValue = (value, defaultValue) => {
2594
- if (defaultValue === void 0) {
2595
- return value;
2596
- }
2597
- return value ?? defaultValue;
2598
- };
2599
- return new Proxy(data || {}, {
2600
- get(target, property, receiver) {
2601
- if (property === "isNil") {
2602
- return ramda.isNil(data);
2603
- }
2604
- if (depth === 1) {
2605
- return (defaultValue) => {
2606
- if (!target)
2607
- return defaultValue;
2608
- return getValue(target[property], defaultValue);
2609
- };
2610
- }
2611
- return (key, defaultValue) => {
2612
- if (key) {
2613
- return getValue(target[property]?.[key], defaultValue);
2614
- } else {
2615
- return getValue(target[property], defaultValue);
2616
- }
2617
- };
2618
- }
2619
- });
2620
- }
2621
- var useAppStore = zustand.create()(
2622
- immer.immer((set) => ({
2623
- // accountInfo: null,
2624
- portfolio: {
2625
- totalCollateral: utils.zero,
2626
- totalValue: null,
2627
- freeCollateral: utils.zero,
2628
- availableBalance: 0,
2629
- unsettledPnL: 0,
2630
- totalUnrealizedROI: 0
2631
- },
2632
- appState: {
2633
- positionsLoading: false,
2634
- ordersLoading: false,
2635
- fundingRatesLoading: false,
2636
- ready: false
2637
- },
2638
- actions: {
2639
- cleanAll: () => {
2640
- set((state) => {
2641
- state.accountInfo = void 0;
2642
- state.portfolio = {
2643
- totalCollateral: utils.zero,
2644
- totalValue: null,
2645
- freeCollateral: utils.zero,
2646
- availableBalance: 0,
2647
- unsettledPnL: 0,
2648
- totalUnrealizedROI: 0
2649
- };
2650
- }, false);
2651
- },
2652
- setAccountInfo: (accountInfo) => {
2653
- set(
2654
- (state) => {
2655
- state.accountInfo = accountInfo;
2656
- },
2657
- false
2658
- // "setAccountInfo"
2659
- );
2660
- },
2661
- setSymbolsInfo: (symbolsInfo) => {
2662
- set(
2663
- (state) => {
2664
- state.symbolsInfo = symbolsInfo;
2665
- },
2666
- false
2667
- // "setSymbolsInfo"
2668
- );
2669
- },
2670
- setRwaSymbolsInfo: (rwaSymbolsInfo) => {
2671
- set(
2672
- (state) => {
2673
- state.rwaSymbolsInfo = rwaSymbolsInfo;
2674
- },
2675
- false
2676
- // "setRwaSymbolsInfo"
2677
- );
2678
- },
2679
- setFundingRates: (fundingRates) => {
2680
- set(
2681
- (state) => {
2682
- state.fundingRates = fundingRates;
2683
- },
2684
- false
2685
- // "setFundingRates"
2686
- );
2687
- },
2688
- updateAppStatus: (key, value) => {
2689
- set(
2690
- (state) => {
2691
- state.appState[key] = value;
2692
- },
2693
- false
2694
- // "updateAppStatus"
2695
- );
2696
- },
2697
- updatePortfolio: (key, value) => {
2698
- set(
2699
- (state) => {
2700
- state.portfolio[key] = value;
2701
- },
2702
- false
2703
- // "updatePortfolio"
2704
- );
2705
- },
2706
- batchUpdateForPortfolio: (data) => {
2707
- set(
2708
- (state) => {
2709
- state.portfolio = { ...state.portfolio, ...data };
2710
- },
2711
- false
2712
- // "batchUpdateForPortfolio"
2713
- );
2714
- },
2715
- restoreHolding: (holding) => {
2716
- set(
2717
- (state) => {
2718
- state.portfolio.holding = holding;
2719
- },
2720
- false
2721
- // "updateHolding"
2722
- );
2723
- },
2724
- updateHolding(msg) {
2725
- set(
2726
- (state) => {
2727
- if (state.portfolio.holding && state.portfolio.holding.length) {
2728
- for (const key in msg) {
2729
- const holding = state.portfolio.holding.find(
2730
- (item) => item.token === key
2731
- );
2732
- if (holding) {
2733
- holding.holding = msg[key].holding;
2734
- holding.frozen = msg[key].frozen;
2735
- }
2736
- }
2737
- }
2738
- },
2739
- false
2740
- // "updateHolding"
2741
- );
3226
+ const unsubscribe = ws.subscribe(
3227
+ // { event: "subscribe", topic: "markprices" },
3228
+ topic,
3229
+ {
3230
+ onMessage: (message) => {
3231
+ next(null, message);
3232
+ }
3233
+ // onUnsubscribe: () => {
3234
+ // return "markprices";
3235
+ // },
3236
+ // onError: (error: any) => {
3237
+ //
3238
+ // },
3239
+ }
3240
+ );
3241
+ return () => {
3242
+ unsubscribe?.();
3243
+ };
3244
+ });
3245
+ const value = React2.useMemo(() => {
3246
+ if (!futures)
3247
+ return null;
3248
+ if (!tickers)
3249
+ return futures;
3250
+ return futures.map((item) => {
3251
+ const ticker = tickers.find(
3252
+ (t) => t.symbol === item.symbol
3253
+ );
3254
+ if (ticker) {
3255
+ const data = {
3256
+ ...item,
3257
+ ["24h_close"]: ticker.close,
3258
+ ["24h_open"]: ticker.open,
3259
+ /**
3260
+ * @deprecated
3261
+ * spelling mistake, use 24h_volume to instead, will be remove next version
3262
+ */
3263
+ ["24h_volumn"]: ticker.volume,
3264
+ ["24h_volume"]: ticker.volume,
3265
+ ["24h_amount"]: ticker.amount,
3266
+ change: 0
3267
+ };
3268
+ if (ticker.close !== void 0 && ticker.open !== void 0) {
3269
+ data["change"] = new utils.Decimal(ticker.close).minus(ticker.open).div(ticker.open).toNumber();
3270
+ }
3271
+ return data;
2742
3272
  }
3273
+ return item;
3274
+ });
3275
+ }, [futures, tickers]);
3276
+ return { data: value };
3277
+ };
3278
+ function createGetter(data, depth = 2) {
3279
+ const getValue = (value, defaultValue) => {
3280
+ if (defaultValue === void 0) {
3281
+ return value;
2743
3282
  }
2744
- }))
2745
- );
2746
- var useAccountInfo2 = () => useAppStore((state) => state.accountInfo);
2747
- var usePortfolio = () => useAppStore((state) => state.portfolio);
2748
- var useFundingRateBySymbol = (symbol) => useAppStore((state) => state.fundingRates?.[symbol]);
3283
+ return value ?? defaultValue;
3284
+ };
3285
+ return new Proxy(data || {}, {
3286
+ get(target, property, receiver) {
3287
+ if (property === "isNil") {
3288
+ return ramda.isNil(data);
3289
+ }
3290
+ if (depth === 1) {
3291
+ return (defaultValue) => {
3292
+ if (!target)
3293
+ return defaultValue;
3294
+ return getValue(target[property], defaultValue);
3295
+ };
3296
+ }
3297
+ return (key, defaultValue) => {
3298
+ if (key) {
3299
+ return getValue(target[property]?.[key], defaultValue);
3300
+ } else {
3301
+ return getValue(target[property], defaultValue);
3302
+ }
3303
+ };
3304
+ }
3305
+ });
3306
+ }
2749
3307
 
2750
3308
  // src/orderly/useRwaSymbolsInfo.ts
2751
3309
  var isCurrentlyTrading = (nextClose, status, currentTime = Date.now()) => {
@@ -3427,9 +3985,15 @@ var orderbook_service_default = orderBookService;
3427
3985
  var useMarkPrice = (symbol) => {
3428
3986
  const ws = useWS();
3429
3987
  const [price, setPrice] = React2.useState(0);
3988
+ const symbolRef = React2.useRef(symbol);
3989
+ symbolRef.current = symbol;
3430
3990
  React2.useEffect(() => {
3431
3991
  const unsubscribe = ws.subscribe(`${symbol}@markprice`, {
3432
3992
  onMessage: (message) => {
3993
+ if (message.symbol !== symbolRef.current) {
3994
+ unsubscribe?.();
3995
+ return;
3996
+ }
3433
3997
  setPrice(message.price);
3434
3998
  }
3435
3999
  });
@@ -3439,33 +4003,6 @@ var useMarkPrice = (symbol) => {
3439
4003
  }, [symbol]);
3440
4004
  return { data: price };
3441
4005
  };
3442
- var useIndexPrice = (symbol) => {
3443
- symbol = symbol.replace("PERP", "SPOT");
3444
- const ws = useWS();
3445
- return useSWRSubscription__default.default(`${symbol}@indexprice`, (key, { next }) => {
3446
- const unsubscribe = ws.subscribe(`${symbol}@indexprice`, {
3447
- onMessage: (message) => {
3448
- next(null, message.price);
3449
- }
3450
- });
3451
- return () => {
3452
- unsubscribe?.();
3453
- };
3454
- });
3455
- };
3456
- var useOpenInterest = (symbol) => {
3457
- const ws = useWS();
3458
- return useSWRSubscription__default.default(`${symbol}@openinterest`, (key, { next }) => {
3459
- const unsubscribe = ws.subscribe(`${symbol}@openinterest`, {
3460
- onMessage: (message) => {
3461
- next(null, message.openInterest);
3462
- }
3463
- });
3464
- return () => {
3465
- unsubscribe?.();
3466
- };
3467
- });
3468
- };
3469
4006
  var useFutures = () => {
3470
4007
  const { data, isLoading, error } = useQuery(
3471
4008
  `/v1/public/futures`,
@@ -3497,6 +4034,45 @@ var useFutures = () => {
3497
4034
  error
3498
4035
  };
3499
4036
  };
4037
+ var useIndexPrice = (symbol) => {
4038
+ symbol = symbol.replace("PERP", "SPOT");
4039
+ const symbolRef = React2.useRef(symbol);
4040
+ symbolRef.current = symbol;
4041
+ const ws = useWS();
4042
+ return useSWRSubscription__default.default(`${symbol}@indexprice`, (key, { next }) => {
4043
+ const unsubscribe = ws.subscribe(`${symbol}@indexprice`, {
4044
+ onMessage: (message) => {
4045
+ if (message.symbol !== symbolRef.current) {
4046
+ unsubscribe?.();
4047
+ return;
4048
+ }
4049
+ next(null, message.price);
4050
+ }
4051
+ });
4052
+ return () => {
4053
+ unsubscribe?.();
4054
+ };
4055
+ });
4056
+ };
4057
+ var useOpenInterest = (symbol) => {
4058
+ const ws = useWS();
4059
+ const symbolRef = React2.useRef(symbol);
4060
+ symbolRef.current = symbol;
4061
+ return useSWRSubscription__default.default(`${symbol}@openinterest`, (key, { next }) => {
4062
+ const unsubscribe = ws.subscribe(`${symbol}@openinterest`, {
4063
+ onMessage: (message) => {
4064
+ if (message.symbol !== symbolRef.current) {
4065
+ unsubscribe?.();
4066
+ return;
4067
+ }
4068
+ next(null, message.openInterest);
4069
+ }
4070
+ });
4071
+ return () => {
4072
+ unsubscribe?.();
4073
+ };
4074
+ });
4075
+ };
3500
4076
 
3501
4077
  // src/orderly/useTickerStream.ts
3502
4078
  var useTickerStream = (symbol) => {
@@ -3510,6 +4086,8 @@ var useTickerStream = (symbol) => {
3510
4086
  }
3511
4087
  );
3512
4088
  const [ticker, setTicker] = React2.useState();
4089
+ const symbolRef = React2.useRef(symbol);
4090
+ symbolRef.current = symbol;
3513
4091
  const ws = useWS();
3514
4092
  React2.useEffect(() => {
3515
4093
  const unsubscribe = ws.subscribe(
@@ -3517,16 +4095,12 @@ var useTickerStream = (symbol) => {
3517
4095
  `${symbol}@ticker`,
3518
4096
  {
3519
4097
  onMessage: (message) => {
3520
- if (message.symbol !== symbol)
4098
+ if (message.symbol !== symbolRef.current) {
4099
+ unsubscribe?.();
3521
4100
  return;
4101
+ }
3522
4102
  setTicker(message);
3523
4103
  }
3524
- // onUnsubscribe: () => {
3525
- // return "markprices";
3526
- // },
3527
- // onError: (error: any) => {
3528
- //
3529
- // },
3530
4104
  }
3531
4105
  );
3532
4106
  return () => {
@@ -4225,31 +4799,11 @@ var useLeverage = () => {
4225
4799
  var useOdosQuote = () => {
4226
4800
  return useMutation(`https://api.odos.xyz/sor/quote/v2`);
4227
4801
  };
4228
- var useTokensInfoStore = zustand.create(
4229
- (set) => ({
4230
- tokensInfo: [],
4231
- setTokensInfo(data) {
4232
- set({ tokensInfo: data });
4233
- }
4234
- })
4235
- );
4236
- var useTokensInfo = () => {
4237
- const tokensInfo = useTokensInfoStore((state) => state.tokensInfo);
4238
- return tokensInfo;
4239
- };
4240
- var useTokenInfo = (token) => {
4241
- const tokensInfo = useTokensInfo();
4242
- return React2.useMemo(() => {
4243
- return tokensInfo?.find((item) => item.token === token);
4244
- }, [tokensInfo, token]);
4245
- };
4246
-
4247
- // src/orderly/useComputedLTV.ts
4248
4802
  var { LTV, collateralRatio } = perp.account;
4249
4803
  var useComputedLTV = (options = {}) => {
4250
4804
  const { input, token } = options;
4251
4805
  const isUSDC = token?.toUpperCase() === "USDC";
4252
- const tokensInfo = useTokensInfo();
4806
+ const tokensInfo = useAppStore((state) => state.tokensInfo);
4253
4807
  const { usdc, data: holdingList = [] } = useHoldingStream();
4254
4808
  const { getIndexPrice } = useIndexPricesStream();
4255
4809
  const { unsettledPnL } = useCollateral();
@@ -4501,7 +5055,7 @@ var CalculatorContext = class _CalculatorContext {
4501
5055
  this.accountInfo = useAppStore.getState().accountInfo;
4502
5056
  this.symbolsInfo = useAppStore.getState().symbolsInfo;
4503
5057
  this.fundingRates = useAppStore.getState().fundingRates;
4504
- this.tokensInfo = useTokensInfoStore.getState().tokensInfo;
5058
+ this.tokensInfo = useAppStore.getState().tokensInfo || [];
4505
5059
  }
4506
5060
  get(fn) {
4507
5061
  return fn(this.output);
@@ -5300,7 +5854,6 @@ var usePositionStream = (symbol = "all", options) => {
5300
5854
  ...rust,
5301
5855
  unrealized_pnl: unrealized_pnl_index ?? 0,
5302
5856
  unsettled_pnl_ROI: unrealized_pnl_ROI_index ?? 0
5303
- // mark_price: item.last_price,
5304
5857
  };
5305
5858
  });
5306
5859
  }
@@ -5312,9 +5865,6 @@ var usePositionStream = (symbol = "all", options) => {
5312
5865
  const partial_tp_sl = partialPossitionOrder ? findTPSLFromOrder(partialPossitionOrder) : void 0;
5313
5866
  return {
5314
5867
  ...item,
5315
- // tp_trigger_price: tp_sl_pricer?.tp_trigger_price,
5316
- // sl_trigger_price: tp_sl_pricer?.sl_trigger_price,
5317
- // algo_order: related_order,
5318
5868
  full_tp_sl: {
5319
5869
  tp_trigger_price: full_tp_sl?.tp_trigger_price,
5320
5870
  sl_trigger_price: full_tp_sl?.sl_trigger_price,
@@ -5325,7 +5875,6 @@ var usePositionStream = (symbol = "all", options) => {
5325
5875
  tp_trigger_price: partial_tp_sl?.tp_trigger_price,
5326
5876
  sl_trigger_price: partial_tp_sl?.sl_trigger_price,
5327
5877
  algo_order: partialPossitionOrder
5328
- // algo_order: partialPositionOrders,
5329
5878
  }
5330
5879
  };
5331
5880
  });
@@ -5338,11 +5887,14 @@ var usePositionStream = (symbol = "all", options) => {
5338
5887
  return [
5339
5888
  {
5340
5889
  rows,
5341
- // rows: formattedPositions[0],
5890
+ // Processed position rows with TP/SL data
5342
5891
  aggregated: formattedPositions?.[1] ?? types.EMPTY_OBJECT,
5343
5892
  totalCollateral,
5893
+ // Portfolio-wide collateral
5344
5894
  totalValue,
5895
+ // Total portfolio value
5345
5896
  totalUnrealizedROI
5897
+ // Total unrealized ROI across all positions
5346
5898
  },
5347
5899
  positionInfoGetter,
5348
5900
  {
@@ -5672,6 +6224,8 @@ var useMarketTradeStream = (symbol, options = {}) => {
5672
6224
  }
5673
6225
  const [trades, setTrades] = React2.useState([]);
5674
6226
  const [isLoading, setIsLoading] = React2.useState(false);
6227
+ const symbolRef = React2.useRef(symbol);
6228
+ symbolRef.current = symbol;
5675
6229
  const { limit = 50 } = options;
5676
6230
  const ws = useWS();
5677
6231
  React2.useEffect(() => {
@@ -5696,7 +6250,7 @@ var useMarketTradeStream = (symbol, options = {}) => {
5696
6250
  );
5697
6251
  }, [symbol]);
5698
6252
  React2.useEffect(() => {
5699
- const unsubscript = ws.subscribe(
6253
+ const unsubscribe = ws.subscribe(
5700
6254
  {
5701
6255
  id: `${symbol}@trade`,
5702
6256
  event: "subscribe",
@@ -5705,6 +6259,10 @@ var useMarketTradeStream = (symbol, options = {}) => {
5705
6259
  },
5706
6260
  {
5707
6261
  onMessage: (data) => {
6262
+ if (data.symbol !== symbolRef.current) {
6263
+ unsubscribe?.();
6264
+ return;
6265
+ }
5708
6266
  setTrades((prev) => {
5709
6267
  const arr = [{ ...data, ts: utils.getTimestamp() }, ...prev];
5710
6268
  if (arr.length > limit) {
@@ -5716,7 +6274,7 @@ var useMarketTradeStream = (symbol, options = {}) => {
5716
6274
  }
5717
6275
  );
5718
6276
  return () => {
5719
- unsubscript?.();
6277
+ unsubscribe?.();
5720
6278
  };
5721
6279
  }, [symbol]);
5722
6280
  return { data: trades, isLoading };
@@ -5780,7 +6338,7 @@ var useLeverageBySymbol = (symbol) => {
5780
6338
  // src/orderly/useMaxQty.ts
5781
6339
  var useMaxQty = (symbol, side, reduceOnly = false) => {
5782
6340
  const positions3 = usePositions();
5783
- const accountInfo = useAccountInfo2();
6341
+ const accountInfo = useAccountInfo();
5784
6342
  const symbolInfo = useSymbolsInfo();
5785
6343
  const { totalCollateral } = useCollateral();
5786
6344
  const { data: markPrices } = useMarkPricesStream();
@@ -5899,11 +6457,6 @@ var TestNetWhiteList = [
5899
6457
  types.ABSTRACT_TESTNET_CHAINID,
5900
6458
  types.BSC_TESTNET_CHAINID
5901
6459
  ];
5902
- var testnetTokenFallback = types.TesntTokenFallback([
5903
- types.ArbitrumSepoliaTokenInfo,
5904
- types.SolanaDevnetTokenInfo
5905
- ]);
5906
- var testnetChainFallback = [types.ArbitrumSepoliaChainInfo, types.SolanaDevnetChainInfo];
5907
6460
  function useChains(networkId, options = {}) {
5908
6461
  const { pick: pickField, ...swrOptions } = options;
5909
6462
  const {
@@ -5915,47 +6468,16 @@ function useChains(networkId, options = {}) {
5915
6468
  const filterFun = React2.useRef(options?.filter);
5916
6469
  filterFun.current = options?.filter;
5917
6470
  const chainsMap = React2.useRef(/* @__PURE__ */ new Map());
5918
- const brokerId = configStore.get("brokerId");
5919
- const env = configStore.get("env");
5920
- const brokerIdQuery = brokerId !== "orderly" ? `?broker_id=${brokerId}` : "";
5921
- const urlPrefix = env === "prod" ? "https://testnet-api.orderly.org" : "";
5922
6471
  const needFetchFromAPI = options.forceAPI || !customChains;
5923
- const commonSwrOpts = {
5924
- revalidateIfStale: false,
5925
- revalidateOnFocus: false,
5926
- revalidateOnReconnect: false,
5927
- // If false, undefined data gets cached against the key.
5928
- revalidateOnMount: true,
5929
- // don't duplicate a request with the same key for 1hr
5930
- dedupingInterval: 36e5,
5931
- ...swrOptions
5932
- };
5933
- const { data: tokenChainsRes, error: tokenError } = useQuery(
5934
- "https://api.orderly.org/v1/public/token",
5935
- { ...commonSwrOpts }
5936
- );
5937
- const { data: testTokenChainsRes } = useQuery(
5938
- `${urlPrefix}/v1/public/token`,
5939
- {
5940
- ...commonSwrOpts,
5941
- fallbackData: testnetTokenFallback
5942
- }
5943
- );
5944
- const { data: chainInfos, error: chainInfoErr } = useQuery(
5945
- needFetchFromAPI ? `https://api.orderly.org/v1/public/chain_info${brokerIdQuery}` : null,
5946
- { ...commonSwrOpts }
5947
- );
5948
- const { data: testChainInfos, error: testChainInfoError } = useQuery(
5949
- needFetchFromAPI ? `${urlPrefix}/v1/public/chain_info${brokerIdQuery}` : null,
5950
- {
5951
- ...commonSwrOpts,
5952
- fallbackData: testnetChainFallback,
5953
- onError: (error) => {
5954
- }
5955
- }
5956
- );
6472
+ const { data: tokenChainsRes, error: tokenError } = useMainTokenStore();
6473
+ const testTokenChainsRes = useTestTokenStore((state) => state.data);
6474
+ const chainInfos = useMainnetChainsStore((state) => state.data);
6475
+ const testChainInfos = useTestnetChainsStore((state) => state.data);
5957
6476
  const { swapChains, swapChainsError } = useSwapChains();
5958
6477
  const chains = React2.useMemo(() => {
6478
+ if (!tokenChainsRes || !testTokenChainsRes || !chainInfos || !testChainInfos) {
6479
+ return [];
6480
+ }
5959
6481
  const mainnetChains = formatChains({
5960
6482
  tokenChains: tokenChainsRes,
5961
6483
  chainInfos,
@@ -6063,19 +6585,7 @@ function filterByAllowedChains(chains, allowedChains) {
6063
6585
  }
6064
6586
  function useSwapChains() {
6065
6587
  const { enableSwapDeposit } = React2.useContext(OrderlyContext);
6066
- const { data: swapChainsRes, error: swapChainsError } = useSWR__namespace.default(
6067
- () => enableSwapDeposit ? "https://fi-api.woo.org/swap_support" : null,
6068
- (url) => fetch(url).then((res) => res.json()),
6069
- {
6070
- revalidateIfStale: false,
6071
- revalidateOnFocus: false,
6072
- revalidateOnReconnect: false,
6073
- // If false, undefined data gets cached against the key.
6074
- revalidateOnMount: true,
6075
- // dont duplicate a request w/ same key for 1hr
6076
- dedupingInterval: 36e5
6077
- }
6078
- );
6588
+ const { data: swapChainsRes, error: swapChainsError } = useSwapSupportStore();
6079
6589
  const swapChains = React2.useMemo(() => {
6080
6590
  if (!enableSwapDeposit || !swapChainsRes || !swapChainsRes.data) {
6081
6591
  return [];
@@ -6503,7 +7013,7 @@ var useDeposit = (options) => {
6503
7013
  [options.address]
6504
7014
  );
6505
7015
  const fetchBalanceHandler = React2.useCallback(
6506
- async (address, decimals) => {
7016
+ async (address, decimals, token) => {
6507
7017
  let balance2;
6508
7018
  try {
6509
7019
  if (address && types.isNativeTokenChecker(address)) {
@@ -6517,7 +7027,8 @@ var useDeposit = (options) => {
6517
7027
  }
6518
7028
  } catch (err) {
6519
7029
  if (ignoreBalanceError({
6520
- token: options.srcToken,
7030
+ // TODO: use token params instead of options.srcToken
7031
+ token: token || options.srcToken,
6521
7032
  chainNamespace: account9.walletAdapter?.chainNamespace,
6522
7033
  err
6523
7034
  })) {
@@ -6532,16 +7043,17 @@ var useDeposit = (options) => {
6532
7043
  const fetchBalances = React2.useCallback(async (tokens) => {
6533
7044
  const tasks = [];
6534
7045
  for (const token of tokens) {
6535
- if (types.isNativeTokenChecker(token.address)) {
6536
- continue;
6537
- }
6538
7046
  tasks.push(
6539
- account9.assetsManager.getBalance(token.address, {
6540
- decimals: token?.decimals
6541
- })
7047
+ fetchBalanceHandler(token.address, token?.decimals, token.symbol)
6542
7048
  );
6543
7049
  }
6544
- const balances = await Promise.all(tasks);
7050
+ const results = await Promise.allSettled(tasks);
7051
+ const balances = {};
7052
+ for (const [index, balance2] of results.entries()) {
7053
+ if (balance2.status === "fulfilled") {
7054
+ balances[tokens[index].symbol] = balance2.value;
7055
+ }
7056
+ }
6545
7057
  return balances;
6546
7058
  }, []);
6547
7059
  const getAllowance = async (inputs) => {
@@ -9541,7 +10053,7 @@ var useSubAccountDataObserver = (accountId) => {
9541
10053
  const { data: indexPrices } = useIndexPricesStream();
9542
10054
  const symbolsInfo = useSymbolsInfo();
9543
10055
  const fundingRates = useFundingRatesStore();
9544
- const tokensInfo = useTokensInfo();
10056
+ const tokensInfo = useAppStore((state) => state.tokensInfo);
9545
10057
  const [holding, setHolding] = React2.useState([]);
9546
10058
  const [positions3, setPositions] = React2.useState(
9547
10059
  POSITION_EMPTY
@@ -9696,7 +10208,9 @@ var useSubAccountDataObserver = (accountId) => {
9696
10208
  var { maxWithdrawalUSDC: maxWithdrawalUSDC2, maxWithdrawalOtherCollateral: maxWithdrawalOtherCollateral2, collateralRatio: collateralRatio3 } = perp.account;
9697
10209
  function useSubAccountMaxWithdrawal(options) {
9698
10210
  const { token, unsettledPnL, freeCollateral, holdings } = options;
9699
- const tokenInfo = useTokenInfo(token);
10211
+ const tokenInfo = useAppStore(
10212
+ (state) => state.tokensInfo?.find((item) => item.token === token)
10213
+ );
9700
10214
  const { data: indexPrices } = useIndexPricesStream();
9701
10215
  const usdc = React2.useMemo(() => {
9702
10216
  const usdc2 = holdings?.find((item) => item.token === "USDC");
@@ -10054,7 +10568,7 @@ var useTPSLOrder = (position, options) => {
10054
10568
  };
10055
10569
  var useMaxLeverage = (symbol) => {
10056
10570
  const symbolsInfo = useSymbolsInfo();
10057
- const accountInfo = useAccountInfo2();
10571
+ const accountInfo = useAccountInfo();
10058
10572
  const maxAccountLeverage = accountInfo?.max_leverage;
10059
10573
  const maxSymbolLeverage = React2.useMemo(() => {
10060
10574
  const symbolInfo = symbolsInfo[symbol];
@@ -10423,6 +10937,16 @@ var useStorageLedgerAddress = () => {
10423
10937
  ledgerWallet
10424
10938
  };
10425
10939
  };
10940
+ var useTokensInfo = () => {
10941
+ const tokensInfo = useAppStore((state) => state.tokensInfo);
10942
+ return tokensInfo;
10943
+ };
10944
+ var useTokenInfo = (token) => {
10945
+ const tokensInfo = useAppStore((state) => state.tokensInfo);
10946
+ return React2.useMemo(() => {
10947
+ return tokensInfo?.find((item) => item.token === token);
10948
+ }, [tokensInfo, token]);
10949
+ };
10426
10950
  var useMarketStore = zustand.create(
10427
10951
  (set, get3) => ({
10428
10952
  market: [],
@@ -10468,34 +10992,31 @@ var usePublicDataObserver = () => {
10468
10992
  (state) => state.actions
10469
10993
  );
10470
10994
  const { updateMarket } = useMarketStore((state) => state.actions);
10471
- const setTokensInfo = useTokensInfoStore((state) => state.setTokensInfo);
10995
+ const symbols = useSymbolStore((state) => state.data);
10472
10996
  const { dataAdapter } = useOrderlyContext();
10473
10997
  const resolveList = typeof dataAdapter?.symbolList === "function" ? dataAdapter.symbolList : (oriVal) => oriVal;
10474
- useQuery(`/v1/public/info`, {
10475
- ...publicQueryOptions,
10476
- onSuccess(data) {
10477
- if (!data || !data?.length) {
10478
- return {};
10479
- }
10480
- const obj = {};
10481
- for (let index = 0; index < data.length; index++) {
10482
- const item = data[index];
10483
- const arr = item.symbol.split("_");
10484
- const base_dp = utils.getPrecisionByNumber(item.base_tick);
10485
- const quote_dp = utils.getPrecisionByNumber(item.quote_tick);
10486
- obj[item.symbol] = {
10487
- ...item,
10488
- base_dp,
10489
- quote_dp,
10490
- base: arr[1],
10491
- quote: arr[2],
10492
- type: arr[0],
10493
- name: `${arr[1]}-${arr[0]}`
10494
- };
10495
- }
10496
- setSymbolsInfo(obj);
10998
+ React2.useEffect(() => {
10999
+ if (!symbols || !symbols?.length) {
11000
+ return;
10497
11001
  }
10498
- });
11002
+ const obj = {};
11003
+ for (let index = 0; index < symbols.length; index++) {
11004
+ const item = symbols[index];
11005
+ const arr = item.symbol.split("_");
11006
+ const base_dp = utils.getPrecisionByNumber(item.base_tick);
11007
+ const quote_dp = utils.getPrecisionByNumber(item.quote_tick);
11008
+ obj[item.symbol] = {
11009
+ ...item,
11010
+ base_dp,
11011
+ quote_dp,
11012
+ base: arr[1],
11013
+ quote: arr[2],
11014
+ type: arr[0],
11015
+ name: `${arr[1]}-${arr[0]}`
11016
+ };
11017
+ }
11018
+ setSymbolsInfo(obj);
11019
+ }, [symbols]);
10499
11020
  useQuery(`/v1/public/rwa/info`, {
10500
11021
  ...publicQueryOptions,
10501
11022
  onSuccess(data) {
@@ -10551,16 +11072,6 @@ var usePublicDataObserver = () => {
10551
11072
  return resolveList(data);
10552
11073
  }
10553
11074
  });
10554
- useQuery(`/v1/public/token`, {
10555
- // revalidateOnFocus: false,
10556
- ...publicQueryOptions,
10557
- onSuccess(data) {
10558
- if (!data || !data.length) {
10559
- return [];
10560
- }
10561
- setTokensInfo(data);
10562
- }
10563
- });
10564
11075
  };
10565
11076
  function getEstFundingRate(data) {
10566
11077
  if (!data) {
@@ -10572,9 +11083,26 @@ function getEstFundingRate(data) {
10572
11083
  }
10573
11084
  return est_funding_rate;
10574
11085
  }
11086
+ var useDatabaseInitialization = () => {
11087
+ const [isInitialized, setIsInitialized] = React2.useState(false);
11088
+ const [error, setError] = React2.useState(null);
11089
+ React2.useEffect(() => {
11090
+ const initialize = async () => {
11091
+ try {
11092
+ await initializeAppDatabase(DEFAULT_DATABASE_CONFIG);
11093
+ setIsInitialized(true);
11094
+ } catch (err) {
11095
+ setError(err);
11096
+ }
11097
+ };
11098
+ initialize();
11099
+ }, []);
11100
+ return { isInitialized, error };
11101
+ };
10575
11102
  var DataCenterProvider = ({
10576
11103
  children
10577
11104
  }) => {
11105
+ useDatabaseInitialization();
10578
11106
  const { error, done } = usePreLoadData();
10579
11107
  useInitRwaSymbolsRuntime();
10580
11108
  const calculatorService = useCalculatorService();
@@ -10599,9 +11127,6 @@ var DataCenterProvider = ({
10599
11127
  if (error) {
10600
11128
  return /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Data load failed" });
10601
11129
  }
10602
- if (!done) {
10603
- return null;
10604
- }
10605
11130
  return /* @__PURE__ */ jsxRuntime.jsx(DataCenterContext.Provider, { value: memoizedValue, children });
10606
11131
  };
10607
11132
  var OrderlyConfigProvider = (props) => {
@@ -17329,7 +17854,7 @@ var useOrderEntry2 = (symbol, options = {}) => {
17329
17854
  });
17330
17855
  const actions = useMarkPriceActions();
17331
17856
  const symbolConfig = useSymbolsInfo();
17332
- const accountInfo = useAccountInfo2();
17857
+ const accountInfo = useAccountInfo();
17333
17858
  const positions3 = usePositions();
17334
17859
  const symbolLeverage = useLeverageBySymbol(symbol);
17335
17860
  const symbolInfo = symbolConfig[symbol]();
@@ -18077,16 +18602,22 @@ exports.findTPSLFromOrder = findTPSLFromOrder;
18077
18602
  exports.findTPSLOrderPriceFromOrder = findTPSLOrderPriceFromOrder;
18078
18603
  exports.getMinNotional = getMinNotional;
18079
18604
  exports.getPriceKey = getPriceKey;
18605
+ exports.indexedDBManager = indexedDBManager;
18606
+ exports.initializeAppDatabase = initializeAppDatabase;
18080
18607
  exports.isCurrentlyClosed = isCurrentlyClosed;
18081
18608
  exports.isCurrentlyTrading = isCurrentlyTrading;
18082
18609
  exports.noCacheConfig = noCacheConfig;
18083
18610
  exports.parseJSON = parseJSON;
18611
+ exports.persistIndexedDB = persistIndexedDB;
18612
+ exports.resetTimestampOffsetState = resetTimestampOffsetState;
18613
+ exports.timestampWaitingMiddleware = timestampWaitingMiddleware;
18084
18614
  exports.useAccount = useAccount;
18085
- exports.useAccountInfo = useAccountInfo;
18615
+ exports.useAccountInfo = useAccountInfo2;
18086
18616
  exports.useAccountInstance = useAccountInstance;
18087
18617
  exports.useAccountRewardsHistory = useAccountRewardsHistory;
18088
18618
  exports.useAllBrokers = useAllBrokers;
18089
18619
  exports.useApiKeyManager = useApiKeyManager;
18620
+ exports.useAppStore = useAppStore;
18090
18621
  exports.useAssetsHistory = useAssetsHistory;
18091
18622
  exports.useAudioPlayer = useAudioPlayer;
18092
18623
  exports.useBalanceSubscription = useBalanceSubscription;
@@ -18134,6 +18665,8 @@ exports.useLazyQuery = useLazyQuery;
18134
18665
  exports.useLeverage = useLeverage;
18135
18666
  exports.useLeverageBySymbol = useLeverageBySymbol;
18136
18667
  exports.useLocalStorage = useLocalStorage;
18668
+ exports.useMainTokenStore = useMainTokenStore;
18669
+ exports.useMainnetChainsStore = useMainnetChainsStore;
18137
18670
  exports.useMaintenanceStatus = useMaintenanceStatus;
18138
18671
  exports.useMarginRatio = useMarginRatio;
18139
18672
  exports.useMarkPrice = useMarkPrice;
@@ -18190,12 +18723,15 @@ exports.useSubAccountMaxWithdrawal = useSubAccountMaxWithdrawal;
18190
18723
  exports.useSubAccountMutation = useSubAccountMutation;
18191
18724
  exports.useSubAccountQuery = useSubAccountQuery;
18192
18725
  exports.useSubAccountWS = useSubAccountWS;
18726
+ exports.useSwapSupportStore = useSwapSupportStore;
18193
18727
  exports.useSymbolInfo = useSymbolInfo;
18194
18728
  exports.useSymbolLeverage = useSymbolLeverage;
18195
18729
  exports.useSymbolPriceRange = useSymbolPriceRange;
18196
18730
  exports.useSymbolsInfo = useSymbolsInfo;
18197
18731
  exports.useSymbolsInfoStore = useSymbolsInfoStore;
18198
18732
  exports.useTPSLOrder = useTPSLOrder;
18733
+ exports.useTestTokenStore = useTestTokenStore;
18734
+ exports.useTestnetChainsStore = useTestnetChainsStore;
18199
18735
  exports.useTickerStream = useTickerStream;
18200
18736
  exports.useTokenInfo = useTokenInfo;
18201
18737
  exports.useTokensInfo = useTokensInfo;