@orderly.network/hooks 2.5.3-alpha.0 → 2.5.3-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -61,9 +61,9 @@ var __export = (target, all) => {
61
61
  // src/version.ts
62
62
  if (typeof window !== "undefined") {
63
63
  window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
64
- window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.5.3-alpha.0";
64
+ window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.5.3-alpha.1";
65
65
  }
66
- var version_default = "2.5.3-alpha.0";
66
+ var version_default = "2.5.3-alpha.1";
67
67
  var fetcher = (url, init2 = {}, queryOptions) => net.get(url, init2, queryOptions?.formatter);
68
68
  var OrderlyContext = React.createContext({
69
69
  // configStore: new MemoryConfigStore(),
@@ -480,6 +480,11 @@ var useBoolean = (initialValue = false) => {
480
480
  const toggle = React.useCallback(() => setValue((v) => !v), []);
481
481
  return [value, { setTrue, setFalse, toggle }];
482
482
  };
483
+ var useUpdatedRef = (val) => {
484
+ const latestRef = React.useRef(val);
485
+ latestRef.current = val;
486
+ return latestRef;
487
+ };
483
488
  var useMemoizedFn = (fn) => {
484
489
  const fnRef = React.useRef(fn);
485
490
  fnRef.current = React.useMemo(() => fn, [fn]);
@@ -2134,14 +2139,24 @@ var OrderbookService = class _OrderbookService {
2134
2139
  const bidMap = /* @__PURE__ */ new Map();
2135
2140
  rawOrderBook.asks.forEach((ask) => askMap.set(ask[0], ask[1]));
2136
2141
  rawOrderBook.bids.forEach((bid) => bidMap.set(bid[0], bid[1]));
2137
- update.asks.forEach((ask) => ask[1] === 0 ? askMap.delete(ask[0]) : askMap.set(ask[0], ask[1]));
2138
- update.bids.forEach((bid) => bid[1] === 0 ? bidMap.delete(bid[0]) : bidMap.set(bid[0], bid[1]));
2139
- rawOrderBook.asks = Array.from(askMap.entries()).sort((a, b) => a[0] - b[0]);
2140
- rawOrderBook.bids = Array.from(bidMap.entries()).sort((a, b) => b[0] - a[0]);
2142
+ update.asks.forEach(
2143
+ (ask) => ask[1] === 0 ? askMap.delete(ask[0]) : askMap.set(ask[0], ask[1])
2144
+ );
2145
+ update.bids.forEach(
2146
+ (bid) => bid[1] === 0 ? bidMap.delete(bid[0]) : bidMap.set(bid[0], bid[1])
2147
+ );
2148
+ rawOrderBook.asks = Array.from(askMap.entries()).sort(
2149
+ (a, b) => a[0] - b[0]
2150
+ );
2151
+ rawOrderBook.bids = Array.from(bidMap.entries()).sort(
2152
+ (a, b) => b[0] - a[0]
2153
+ );
2141
2154
  rawOrderBook.ts = update.ts;
2142
2155
  }
2143
2156
  applyBufferedUpdatesToRawOrderBooks(symbol) {
2144
- this.bufferedOrderBookUpdates[symbol]?.forEach((update) => this.applyUpdateToRawOrderBook(symbol, update));
2157
+ this.bufferedOrderBookUpdates[symbol]?.forEach(
2158
+ (update) => this.applyUpdateToRawOrderBook(symbol, update)
2159
+ );
2145
2160
  }
2146
2161
  deleteBufferedOrderBookUpdates(symbol) {
2147
2162
  delete this.bufferedOrderBookUpdates[symbol];
@@ -2474,7 +2489,10 @@ var reduceOrderbook = (depth, level, padding, data) => {
2474
2489
  bids
2475
2490
  };
2476
2491
  };
2477
- var INIT_DATA = { asks: [], bids: [] };
2492
+ var INIT_DATA = {
2493
+ asks: [],
2494
+ bids: []
2495
+ };
2478
2496
  var useOrderbookStream = (symbol, initial = INIT_DATA, options) => {
2479
2497
  if (!symbol) {
2480
2498
  throw new types.SDKError("Symbol is required");
@@ -2491,8 +2509,9 @@ var useOrderbookStream = (symbol, initial = INIT_DATA, options) => {
2491
2509
  const prevMiddlePrice = React.useRef(0);
2492
2510
  const depths = React.useMemo(() => {
2493
2511
  const tick = config("quote_tick");
2494
- if (typeof tick === "undefined")
2512
+ if (typeof tick === "undefined") {
2495
2513
  return [];
2514
+ }
2496
2515
  try {
2497
2516
  const base = new utils.Decimal(tick);
2498
2517
  return [
@@ -2600,8 +2619,9 @@ var useOrderbookStream = (symbol, initial = INIT_DATA, options) => {
2600
2619
  if (data.bids.length > 0) {
2601
2620
  bidsFirst = data.bids[0][0];
2602
2621
  }
2603
- if (isNaN(asksFrist) || isNaN(bidsFirst) || !ticker)
2622
+ if (isNaN(asksFrist) || isNaN(bidsFirst) || !ticker) {
2604
2623
  return 0;
2624
+ }
2605
2625
  return [asksFrist, bidsFirst, ticker["24h_close"]].sort()[1];
2606
2626
  }, [ticker?.["24h_close"], data]);
2607
2627
  React.useEffect(() => {
@@ -3280,8 +3300,17 @@ var useMarkPricesStream = () => {
3280
3300
 
3281
3301
  // src/orderly/useIndexPricesStream.ts
3282
3302
  var useIndexPricesStream = () => {
3283
- const data = useIndexPriceStore((state) => state.indexPrices);
3284
- return { data };
3303
+ const indexPrices = useIndexPriceStore((state) => state.indexPrices);
3304
+ const getIndexPrice = (token) => {
3305
+ if (token === "USDC") {
3306
+ return 1;
3307
+ }
3308
+ return indexPrices[`PERP_${token}_USDC`] ?? 0;
3309
+ };
3310
+ return {
3311
+ data: indexPrices,
3312
+ getIndexPrice: useMemoizedFn(getIndexPrice)
3313
+ };
3285
3314
  };
3286
3315
  var generateLeverageLevers = (max3) => {
3287
3316
  const min3 = 1;
@@ -3351,14 +3380,14 @@ var useComputedLTV = (options = {}) => {
3351
3380
  const isUSDC = token?.toUpperCase() === "USDC";
3352
3381
  const tokensInfo = useTokensInfo();
3353
3382
  const { usdc, data: holdingList = [] } = useHoldingStream();
3354
- const { data: indexPrices } = useIndexPricesStream();
3383
+ const { getIndexPrice } = useIndexPricesStream();
3355
3384
  const { unsettledPnL } = useCollateral();
3356
3385
  const usdcBalance = React.useMemo(() => {
3357
3386
  if (isUSDC && input) {
3358
3387
  return new utils.Decimal(usdc?.holding ?? 0).add(input).toNumber();
3359
3388
  }
3360
3389
  return usdc?.holding ?? 0;
3361
- }, [usdc?.holding, input, token, isUSDC]);
3390
+ }, [usdc?.holding, input, isUSDC]);
3362
3391
  const getAdjustedQty = React.useCallback(
3363
3392
  (item) => {
3364
3393
  if (input && item.token === token) {
@@ -3373,19 +3402,20 @@ var useComputedLTV = (options = {}) => {
3373
3402
  usdcBalance,
3374
3403
  upnl: unsettledPnL,
3375
3404
  assets: holdingList.filter((h) => h.token.toUpperCase() !== "USDC").map((item) => {
3376
- const indexPrice = indexPrices[`PERP_${item.token}_USDC`] ?? 0;
3405
+ const indexPrice = getIndexPrice(item.token);
3377
3406
  const findToken = tokensInfo?.find((i) => i.token === item.token);
3378
3407
  const qty = getAdjustedQty(item);
3408
+ const weight = collateralRatio({
3409
+ baseWeight: findToken?.base_weight ?? 0,
3410
+ discountFactor: findToken?.discount_factor ?? 0,
3411
+ collateralCap: findToken?.user_max_qty ?? qty,
3412
+ collateralQty: qty,
3413
+ indexPrice
3414
+ });
3379
3415
  return {
3380
3416
  qty,
3381
3417
  indexPrice,
3382
- weight: collateralRatio({
3383
- baseWeight: findToken?.base_weight ?? 0,
3384
- discountFactor: findToken?.discount_factor ?? 0,
3385
- collateralCap: findToken?.user_max_qty ?? qty,
3386
- collateralQty: qty,
3387
- indexPrice
3388
- })
3418
+ weight: weight.toNumber()
3389
3419
  };
3390
3420
  })
3391
3421
  });
@@ -3393,8 +3423,8 @@ var useComputedLTV = (options = {}) => {
3393
3423
  usdcBalance,
3394
3424
  unsettledPnL,
3395
3425
  holdingList,
3396
- indexPrices,
3397
3426
  tokensInfo,
3427
+ getIndexPrice,
3398
3428
  getAdjustedQty
3399
3429
  ]);
3400
3430
  if (new utils.Decimal(usdcBalance).add(new utils.Decimal(unsettledPnL)).gte(utils.zero)) {
@@ -4585,9 +4615,11 @@ var useHoldingStream = () => {
4585
4615
  // src/orderly/useMaxWithdrawal.ts
4586
4616
  var { maxWithdrawalUSDC, maxWithdrawalOtherCollateral, collateralRatio: collateralRatio2 } = perp.account;
4587
4617
  var useMaxWithdrawal = (token) => {
4588
- const { unsettledPnL, freeCollateral } = useCollateral();
4618
+ const { unsettledPnL } = useCollateral();
4619
+ const { freeCollateral } = useAppStore((state) => state.portfolio);
4589
4620
  const tokenInfo = useTokenInfo(token);
4590
- const { data: indexPrices } = useIndexPricesStream();
4621
+ const { getIndexPrice } = useIndexPricesStream();
4622
+ const indexPriceRef = useUpdatedRef(getIndexPrice(token));
4591
4623
  const { usdc, data: holdings = [] } = useHoldingStream();
4592
4624
  const holding = React.useMemo(() => {
4593
4625
  return holdings.find(
@@ -4595,13 +4627,6 @@ var useMaxWithdrawal = (token) => {
4595
4627
  );
4596
4628
  }, [holdings, token]);
4597
4629
  const usdcBalance = usdc?.holding ?? 0;
4598
- const indexPrice = React.useMemo(() => {
4599
- if (token === "USDC") {
4600
- return 1;
4601
- }
4602
- const symbol = `PERP_${token}_USDC`;
4603
- return indexPrices[symbol] ?? 0;
4604
- }, [token, indexPrices]);
4605
4630
  const memoizedCollateralRatio = React.useMemo(() => {
4606
4631
  const { base_weight = 0, discount_factor = 0 } = tokenInfo || {};
4607
4632
  const holdingQty = holding?.holding ?? 0;
@@ -4610,34 +4635,45 @@ var useMaxWithdrawal = (token) => {
4610
4635
  discountFactor: discount_factor,
4611
4636
  collateralQty: holdingQty,
4612
4637
  collateralCap: tokenInfo?.user_max_qty ?? holdingQty,
4613
- indexPrice
4638
+ indexPrice: indexPriceRef.current
4614
4639
  });
4615
- }, [tokenInfo, indexPrice, holding]);
4640
+ }, [tokenInfo, holding?.holding, indexPriceRef]);
4616
4641
  const maxAmount = React.useMemo(() => {
4617
4642
  if (!token) {
4618
4643
  return 0;
4619
4644
  }
4645
+ let quantity = 0;
4620
4646
  if (token === "USDC") {
4621
- return maxWithdrawalUSDC({
4647
+ quantity = maxWithdrawalUSDC({
4622
4648
  USDCBalance: usdcBalance,
4623
4649
  freeCollateral,
4624
4650
  upnl: unsettledPnL ?? 0
4625
4651
  });
4652
+ } else {
4653
+ quantity = maxWithdrawalOtherCollateral({
4654
+ USDCBalance: usdcBalance,
4655
+ collateralQty: holding?.holding ?? 0,
4656
+ freeCollateral,
4657
+ indexPrice: indexPriceRef.current,
4658
+ weight: memoizedCollateralRatio
4659
+ }).toNumber();
4626
4660
  }
4627
- return maxWithdrawalOtherCollateral({
4628
- collateralQty: holding?.holding ?? 0,
4629
- freeCollateral,
4630
- indexPrice,
4631
- weight: memoizedCollateralRatio
4632
- });
4661
+ if (Number.isNaN(quantity)) {
4662
+ return 0;
4663
+ }
4664
+ if (tokenInfo?.decimals === void 0) {
4665
+ return quantity;
4666
+ }
4667
+ return new utils.Decimal(quantity || 0).todp(tokenInfo.decimals, utils.Decimal.ROUND_DOWN).toNumber();
4633
4668
  }, [
4669
+ token,
4670
+ tokenInfo?.decimals,
4634
4671
  usdcBalance,
4635
4672
  freeCollateral,
4636
4673
  unsettledPnL,
4637
- memoizedCollateralRatio,
4638
- indexPrice,
4639
- token,
4640
- holding
4674
+ holding?.holding,
4675
+ indexPriceRef,
4676
+ memoizedCollateralRatio
4641
4677
  ]);
4642
4678
  return maxAmount;
4643
4679
  };
@@ -5230,6 +5266,74 @@ var useWalletSubscription = (options) => {
5230
5266
  }
5231
5267
  );
5232
5268
  };
5269
+ var useBalanceSubscription = (options) => {
5270
+ const ws = useWS();
5271
+ const { state } = useAccount();
5272
+ return useSWRSubscription__default.default(
5273
+ state.accountId ? ["balance", state.accountId] : null,
5274
+ (_, { next }) => {
5275
+ const unsubscribe = ws.privateSubscribe(
5276
+ {
5277
+ id: "balance",
5278
+ event: "subscribe",
5279
+ topic: "balance",
5280
+ ts: Date.now()
5281
+ },
5282
+ {
5283
+ onMessage: (data) => {
5284
+ options?.onMessage?.(data);
5285
+ next(null, data);
5286
+ }
5287
+ }
5288
+ );
5289
+ return () => unsubscribe();
5290
+ }
5291
+ );
5292
+ };
5293
+ var useWalletTopic = (options) => {
5294
+ const ws = useWS();
5295
+ const { state } = useAccount();
5296
+ React.useEffect(() => {
5297
+ if (!state.accountId)
5298
+ return;
5299
+ const unsubscribe = ws.privateSubscribe(
5300
+ {
5301
+ id: "wallet",
5302
+ event: "subscribe",
5303
+ topic: "wallet",
5304
+ ts: Date.now()
5305
+ },
5306
+ {
5307
+ onMessage: (data) => {
5308
+ options.onMessage(data);
5309
+ }
5310
+ }
5311
+ );
5312
+ return () => unsubscribe?.();
5313
+ }, [state.accountId]);
5314
+ };
5315
+ var useBalanceTopic = (options) => {
5316
+ const ws = useWS();
5317
+ const { state } = useAccount();
5318
+ React.useEffect(() => {
5319
+ if (!state.accountId)
5320
+ return;
5321
+ const unsubscribe = ws.privateSubscribe(
5322
+ {
5323
+ id: "balance",
5324
+ event: "subscribe",
5325
+ topic: "balance",
5326
+ ts: Date.now()
5327
+ },
5328
+ {
5329
+ onMessage: (data) => {
5330
+ options.onMessage(data);
5331
+ }
5332
+ }
5333
+ );
5334
+ return () => unsubscribe?.();
5335
+ }, [state.accountId]);
5336
+ };
5233
5337
  var useSettleSubscription = (options) => {
5234
5338
  const ws = useWS();
5235
5339
  const { state } = useAccount();
@@ -7243,17 +7347,17 @@ function useSubAccountMaxWithdrawal(options) {
7243
7347
  });
7244
7348
  }
7245
7349
  return maxWithdrawalOtherCollateral2({
7350
+ USDCBalance: usdcBalance,
7246
7351
  collateralQty: holding?.holding ?? 0,
7247
7352
  freeCollateral,
7248
7353
  indexPrice,
7249
7354
  weight: memoizedCollateralRatio
7250
- });
7355
+ }).toNumber();
7251
7356
  }, [
7252
7357
  usdcBalance,
7253
7358
  freeCollateral,
7254
7359
  unsettledPnL,
7255
7360
  memoizedCollateralRatio,
7256
- holdings,
7257
7361
  indexPrice,
7258
7362
  token,
7259
7363
  holding
@@ -7759,28 +7863,36 @@ var useSymbolLeverage = (symbol) => {
7759
7863
  }, [maxAccountLeverage, maxSymbolLeverage]);
7760
7864
  return maxLeverage;
7761
7865
  };
7762
- var AssetHistoryStatusEnum = /* @__PURE__ */ ((AssetHistoryStatusEnum2) => {
7763
- AssetHistoryStatusEnum2["NEW"] = "NEW";
7764
- AssetHistoryStatusEnum2["CONFIRM"] = "CONFIRM";
7765
- AssetHistoryStatusEnum2["PROCESSING"] = "PROCESSING";
7766
- AssetHistoryStatusEnum2["COMPLETED"] = "COMPLETED";
7767
- AssetHistoryStatusEnum2["FAILED"] = "FAILED";
7768
- AssetHistoryStatusEnum2["PENDING_REBALANCE"] = "PENDING_REBALANCE";
7769
- return AssetHistoryStatusEnum2;
7770
- })(AssetHistoryStatusEnum || {});
7771
- var useAssetsHistory = (options) => {
7772
- const { page = 1, pageSize = 10 } = options;
7866
+ var useAssetsHistory = (options, config) => {
7773
7867
  const ee = useEventEmitter();
7774
7868
  const getKey = () => {
7869
+ const {
7870
+ page = 1,
7871
+ pageSize = 10,
7872
+ token,
7873
+ side,
7874
+ status,
7875
+ startTime,
7876
+ endTime
7877
+ } = options;
7775
7878
  const searchParams = new URLSearchParams();
7776
7879
  searchParams.set("page", page.toString());
7777
7880
  searchParams.set("size", pageSize.toString());
7778
- if (options.side && options.side !== "All")
7779
- searchParams.set("side", options.side);
7780
- if (options.startTime)
7781
- searchParams.set("start_t", options.startTime);
7782
- if (options.endTime)
7783
- searchParams.set("end_t", options.endTime);
7881
+ if (token) {
7882
+ searchParams.set("token", token);
7883
+ }
7884
+ if (side && side !== "All") {
7885
+ searchParams.set("side", side);
7886
+ }
7887
+ if (status) {
7888
+ searchParams.set("status", status);
7889
+ }
7890
+ if (startTime) {
7891
+ searchParams.set("start_t", startTime.toString());
7892
+ }
7893
+ if (endTime) {
7894
+ searchParams.set("end_t", endTime.toString());
7895
+ }
7784
7896
  return `/v1/asset/history?${searchParams.toString()}`;
7785
7897
  };
7786
7898
  const { data, isLoading, mutate: mutate5 } = usePrivateQuery(
@@ -7793,7 +7905,10 @@ var useAssetsHistory = (options) => {
7793
7905
  );
7794
7906
  const updateList = useDebounce.useDebouncedCallback(
7795
7907
  (data2) => {
7796
- mutate5();
7908
+ const isUpdate = typeof config?.shouldUpdateOnWalletChanged === "function" ? config.shouldUpdateOnWalletChanged(data2) : true;
7909
+ if (isUpdate) {
7910
+ mutate5();
7911
+ }
7797
7912
  },
7798
7913
  // delay in ms
7799
7914
  300
@@ -7805,7 +7920,7 @@ var useAssetsHistory = (options) => {
7805
7920
  };
7806
7921
  }, []);
7807
7922
  return [
7808
- data?.rows || [],
7923
+ data?.rows || types.EMPTY_LIST,
7809
7924
  {
7810
7925
  meta: data?.meta,
7811
7926
  isLoading
@@ -7967,7 +8082,7 @@ var useTransferHistory = (parmas) => {
7967
8082
  }
7968
8083
  return `/v1/internal_transfer_history?${search.toString()}`;
7969
8084
  }, [page, size, fromId, toId, dataRange, main_sub_only]);
7970
- const { data, isLoading } = usePrivateQuery(
8085
+ const { data, isLoading, mutate: mutate5 } = usePrivateQuery(
7971
8086
  memoizedQueryKey,
7972
8087
  {
7973
8088
  // initialSize: 1,
@@ -7982,7 +8097,7 @@ var useTransferHistory = (parmas) => {
7982
8097
  }
7983
8098
  return data.rows;
7984
8099
  }, [data, infos]);
7985
- return [parsedData, { meta: data?.meta, isLoading }];
8100
+ return [parsedData, { meta: data?.meta, isLoading, mutate: mutate5 }];
7986
8101
  };
7987
8102
  var MaintenanceStatus = /* @__PURE__ */ ((MaintenanceStatus2) => {
7988
8103
  MaintenanceStatus2[MaintenanceStatus2["None"] = 0] = "None";
@@ -8308,6 +8423,8 @@ var usePublicDataObserver = () => {
8308
8423
  );
8309
8424
  const { updateMarket } = useMarketStore((state) => state.actions);
8310
8425
  const setTokensInfo = useTokensInfoStore((state) => state.setTokensInfo);
8426
+ const { dataAdapter } = React.useContext(OrderlyContext);
8427
+ const resolveList = typeof dataAdapter?.symbolList === "function" ? dataAdapter.symbolList : (oriVal) => oriVal;
8311
8428
  useQuery(`/v1/public/info`, {
8312
8429
  ...publicQueryOptions,
8313
8430
  onSuccess(data) {
@@ -8358,6 +8475,13 @@ var usePublicDataObserver = () => {
8358
8475
  return [];
8359
8476
  }
8360
8477
  updateMarket(data);
8478
+ },
8479
+ formatter(data) {
8480
+ const rowsData = data.rows;
8481
+ if (Array.isArray(rowsData)) {
8482
+ return resolveList(rowsData);
8483
+ }
8484
+ return resolveList(data);
8361
8485
  }
8362
8486
  });
8363
8487
  useQuery(`/v1/public/token`, {
@@ -8372,8 +8496,9 @@ var usePublicDataObserver = () => {
8372
8496
  });
8373
8497
  };
8374
8498
  function getEstFundingRate(data) {
8375
- if (!data)
8499
+ if (!data) {
8376
8500
  return;
8501
+ }
8377
8502
  const { next_funding_time, est_funding_rate } = data;
8378
8503
  if (Date.now() > next_funding_time) {
8379
8504
  return null;
@@ -8497,7 +8622,8 @@ var OrderlyConfigProvider = (props) => {
8497
8622
  chainFilter,
8498
8623
  customChains,
8499
8624
  enableSwapDeposit = false,
8500
- chainTransformer
8625
+ chainTransformer,
8626
+ dataAdapter
8501
8627
  } = props;
8502
8628
  if (typeof configStore !== "undefined" && !configStore.get("brokerId")) {
8503
8629
  throw new types.SDKError(
@@ -8548,28 +8674,35 @@ var OrderlyConfigProvider = (props) => {
8548
8674
  }
8549
8675
  return chainFilter;
8550
8676
  }, [props.chainFilter, innerConfigStore]);
8677
+ const memoizedValue = React.useMemo(() => {
8678
+ return {
8679
+ configStore: innerConfigStore,
8680
+ keyStore: innerKeyStore,
8681
+ networkId: innerConfigStore.get("networkId") || networkId,
8682
+ filteredChains,
8683
+ walletAdapters: innerWalletAdapters,
8684
+ customChains,
8685
+ enableSwapDeposit,
8686
+ defaultOrderbookTickSizes,
8687
+ chainTransformer,
8688
+ dataAdapter
8689
+ };
8690
+ }, [
8691
+ innerConfigStore,
8692
+ innerKeyStore,
8693
+ networkId,
8694
+ filteredChains,
8695
+ innerWalletAdapters,
8696
+ customChains,
8697
+ enableSwapDeposit,
8698
+ defaultOrderbookTickSizes,
8699
+ dataAdapter,
8700
+ chainTransformer
8701
+ ]);
8551
8702
  if (!account9) {
8552
8703
  return null;
8553
8704
  }
8554
- return /* @__PURE__ */ jsxRuntime.jsx(
8555
- OrderlyProvider,
8556
- {
8557
- value: {
8558
- configStore: innerConfigStore,
8559
- keyStore: innerKeyStore,
8560
- // getWalletAdapter: innerGetWalletAdapter,
8561
- networkId: innerConfigStore.get("networkId") || networkId,
8562
- filteredChains,
8563
- walletAdapters: innerWalletAdapters,
8564
- // apiBaseUrl,
8565
- customChains,
8566
- enableSwapDeposit,
8567
- chainTransformer,
8568
- defaultOrderbookTickSizes
8569
- },
8570
- children: /* @__PURE__ */ jsxRuntime.jsx(StatusProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(DataCenterProvider, { children: props.children }) })
8571
- }
8572
- );
8705
+ return /* @__PURE__ */ jsxRuntime.jsx(OrderlyProvider, { value: memoizedValue, children: /* @__PURE__ */ jsxRuntime.jsx(StatusProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(DataCenterProvider, { children: props.children }) }) });
8573
8706
  };
8574
8707
  var needNumberOnlyFields = [
8575
8708
  "order_quantity",
@@ -9934,6 +10067,7 @@ var utils_exports = {};
9934
10067
  __export(utils_exports, {
9935
10068
  calcTPSL_ROI: () => calcTPSL_ROI,
9936
10069
  cleanStringStyle: () => cleanStringStyle,
10070
+ fetcher: () => fetcher,
9937
10071
  findPositionTPSLFromOrders: () => findPositionTPSLFromOrders,
9938
10072
  findTPSLFromOrder: () => findTPSLFromOrder,
9939
10073
  findTPSLFromOrders: () => findTPSLFromOrders,
@@ -16353,12 +16487,15 @@ var useOrderEntity = (order, options) => {
16353
16487
  symbolInfo
16354
16488
  };
16355
16489
  };
16356
- var canUnblockRegions = ["United States"];
16490
+ var defaultRestrictedIps = [];
16491
+ var defaultRestrictedRegions = [];
16492
+ var defaultUnblockRegions = [];
16357
16493
  var useRestrictedInfo = (options) => {
16358
16494
  const {
16359
16495
  enableDefault = false,
16360
- customRestrictedIps = [],
16361
- customRestrictedRegions = [],
16496
+ customRestrictedIps = defaultRestrictedIps,
16497
+ customRestrictedRegions = defaultRestrictedRegions,
16498
+ customUnblockRegions = defaultUnblockRegions,
16362
16499
  content
16363
16500
  } = options || {};
16364
16501
  const [ip, setIp] = React.useState("");
@@ -16384,7 +16521,7 @@ var useRestrictedInfo = (options) => {
16384
16521
  const combinedInvalidRegions = [
16385
16522
  ...formattedCustomRegions,
16386
16523
  ...enableDefault ? [...invalidCountries, ...invalidCities] : []
16387
- ];
16524
+ ].filter((item) => !!item);
16388
16525
  const allInvalidAreas2 = [
16389
16526
  enableDefault ? invalid_web_country : "",
16390
16527
  enableDefault ? invalid_web_city : "",
@@ -16393,15 +16530,20 @@ var useRestrictedInfo = (options) => {
16393
16530
  const { city, region, ip: ip2 } = ipInfo;
16394
16531
  const formattedCity = formatRegion(city);
16395
16532
  const formattedRegion = formatRegion(region);
16396
- const showRestricted = accessRestricted && (combinedInvalidRegions.includes(formattedCity) || combinedInvalidRegions.includes(formattedRegion) || customRestrictedIps.includes(ip2));
16397
- for (const item of canUnblockRegions) {
16398
- if (formatRegion(item) === formatRegion(region)) {
16399
- setCanUnblock(true);
16533
+ const isRestricted = formattedCity && combinedInvalidRegions.includes(formattedCity) || formattedRegion && combinedInvalidRegions.includes(formattedRegion) || ip2 && customRestrictedIps.includes(ip2);
16534
+ let canUnblock2 = false;
16535
+ if (isRestricted) {
16536
+ for (const item of customUnblockRegions) {
16537
+ if (formatRegion(item) === formatRegion(region)) {
16538
+ canUnblock2 = true;
16539
+ }
16400
16540
  }
16401
16541
  }
16542
+ const restrictedOpen2 = canUnblock2 ? isRestricted && accessRestricted !== false : isRestricted;
16402
16543
  setIp(ip2);
16403
16544
  setAllInvalidAreas(allInvalidAreas2);
16404
- setRestrictedOpen(showRestricted);
16545
+ setRestrictedOpen(!!restrictedOpen2);
16546
+ setCanUnblock(canUnblock2);
16405
16547
  } catch (error) {
16406
16548
  }
16407
16549
  }, [
@@ -16412,6 +16554,7 @@ var useRestrictedInfo = (options) => {
16412
16554
  // it will lead to infinite re-render when these values change, so we don't need to watch these
16413
16555
  // customRestrictedIps,
16414
16556
  // customRestrictedRegions,
16557
+ // customUnblockRegions,
16415
16558
  ]);
16416
16559
  return {
16417
16560
  ip,
@@ -16538,7 +16681,6 @@ Object.defineProperty(exports, "useConstant", {
16538
16681
  enumerable: true,
16539
16682
  get: function () { return useConstant__default.default; }
16540
16683
  });
16541
- exports.AssetHistoryStatusEnum = AssetHistoryStatusEnum;
16542
16684
  exports.DefaultLayoutConfig = DefaultLayoutConfig;
16543
16685
  exports.DistributionId = DistributionId;
16544
16686
  exports.ENVType = ENVType2;
@@ -16567,6 +16709,8 @@ exports.useAccountRewardsHistory = useAccountRewardsHistory;
16567
16709
  exports.useAllBrokers = useAllBrokers;
16568
16710
  exports.useApiKeyManager = useApiKeyManager;
16569
16711
  exports.useAssetsHistory = useAssetsHistory;
16712
+ exports.useBalanceSubscription = useBalanceSubscription;
16713
+ exports.useBalanceTopic = useBalanceTopic;
16570
16714
  exports.useBoolean = useBoolean;
16571
16715
  exports.useChain = useChain;
16572
16716
  exports.useChains = useChains;
@@ -16661,10 +16805,12 @@ exports.useTrackingInstance = useTrackingInstance;
16661
16805
  exports.useTradingRewardsStatus = useTradingRewardsStatus;
16662
16806
  exports.useTransfer = useTransfer;
16663
16807
  exports.useTransferHistory = useTransferHistory;
16808
+ exports.useUpdatedRef = useUpdatedRef;
16664
16809
  exports.useWS = useWS;
16665
16810
  exports.useWalletConnector = useWalletConnector;
16666
16811
  exports.useWalletRewardsHistory = useWalletRewardsHistory;
16667
16812
  exports.useWalletSubscription = useWalletSubscription;
16813
+ exports.useWalletTopic = useWalletTopic;
16668
16814
  exports.useWithdraw = useWithdraw;
16669
16815
  exports.useWsStatus = useWsStatus;
16670
16816
  exports.utils = utils_exports;