@orderly.network/hooks 0.0.53 → 0.0.55

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.mjs CHANGED
@@ -1,83 +1,35 @@
1
- import React2, { createContext, useContext, useState, useEffect, useCallback, useRef, useMemo } from 'react';
1
+ import React2, { createContext, useContext, useState, useEffect, useCallback, useMemo, useRef } from 'react';
2
2
  import useSWR, { useSWRConfig } from 'swr';
3
3
  export { SWRConfig, default as useSWR } from 'swr';
4
4
  import { WS, get, mutate } from '@orderly.network/net';
5
5
  import useSWRMutation from 'swr/mutation';
6
6
  import useConstant from 'use-constant';
7
7
  export { default as useConstant } from 'use-constant';
8
- import { SimpleDI, Account, EventEmitter } from '@orderly.network/core';
8
+ import { SimpleDI, Account, EventEmitter, utils } from '@orderly.network/core';
9
9
  import { AccountStatusEnum, OrderSide, chainsMap, OrderStatus as OrderStatus$1, OrderType } from '@orderly.network/types';
10
10
  import useSWRSubscription from 'swr/subscription';
11
11
  import { Decimal, zero, getPrecisionByNumber, timeConvertString } from '@orderly.network/utils';
12
- import { pathOr, propOr, compose, head, prop } from 'ramda';
12
+ import { pathOr, propOr, compose, head, prop, mergeDeepLeft, pick } from 'ramda';
13
13
  import { positions, account, order } from '@orderly.network/futures';
14
14
  import useSWRInfinite from 'swr/infinite';
15
+ export * from 'use-debounce';
16
+ import { createClient } from '@layerzerolabs/scan-client';
15
17
 
16
18
  var __defProp = Object.defineProperty;
17
- var __defProps = Object.defineProperties;
18
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
19
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
20
- var __hasOwnProp = Object.prototype.hasOwnProperty;
21
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
22
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
23
- var __spreadValues = (a, b) => {
24
- for (var prop2 in b || (b = {}))
25
- if (__hasOwnProp.call(b, prop2))
26
- __defNormalProp(a, prop2, b[prop2]);
27
- if (__getOwnPropSymbols)
28
- for (var prop2 of __getOwnPropSymbols(b)) {
29
- if (__propIsEnum.call(b, prop2))
30
- __defNormalProp(a, prop2, b[prop2]);
31
- }
32
- return a;
33
- };
34
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
35
- var __objRest = (source, exclude) => {
36
- var target = {};
37
- for (var prop2 in source)
38
- if (__hasOwnProp.call(source, prop2) && exclude.indexOf(prop2) < 0)
39
- target[prop2] = source[prop2];
40
- if (source != null && __getOwnPropSymbols)
41
- for (var prop2 of __getOwnPropSymbols(source)) {
42
- if (exclude.indexOf(prop2) < 0 && __propIsEnum.call(source, prop2))
43
- target[prop2] = source[prop2];
44
- }
45
- return target;
46
- };
47
19
  var __export = (target, all) => {
48
20
  for (var name in all)
49
21
  __defProp(target, name, { get: all[name], enumerable: true });
50
22
  };
51
- var __async = (__this, __arguments, generator) => {
52
- return new Promise((resolve, reject) => {
53
- var fulfilled = (value) => {
54
- try {
55
- step(generator.next(value));
56
- } catch (e) {
57
- reject(e);
58
- }
59
- };
60
- var rejected = (value) => {
61
- try {
62
- step(generator.throw(value));
63
- } catch (e) {
64
- reject(e);
65
- }
66
- };
67
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
68
- step((generator = generator.apply(__this, __arguments)).next());
69
- });
70
- };
71
23
  var OrderlyContext = createContext({
72
24
  // configStore: new MemoryConfigStore(),
73
25
  });
74
26
  var OrderlyProvider = OrderlyContext.Provider;
75
- var fetcher = (url, init = {}, queryOptions) => get(url, init, queryOptions == null ? void 0 : queryOptions.formatter);
27
+ var fetcher = (url, init = {}, queryOptions) => get(url, init, queryOptions?.formatter);
76
28
 
77
29
  // src/useQuery.ts
78
30
  var useQuery = (query, options) => {
79
31
  const { apiBaseUrl } = useContext(OrderlyContext);
80
- const _a = options || {}, { formatter } = _a, swrOptions = __objRest(_a, ["formatter"]);
32
+ const { formatter, ...swrOptions } = options || {};
81
33
  if (typeof apiBaseUrl === "undefined") {
82
34
  throw new Error("please add OrderlyProvider to your app");
83
35
  }
@@ -90,6 +42,30 @@ var useQuery = (query, options) => {
90
42
  swrOptions
91
43
  );
92
44
  };
45
+ var useLazyQuery = (query, options) => {
46
+ const { apiBaseUrl } = useContext(OrderlyContext);
47
+ const { formatter, init, ...swrOptions } = options || {};
48
+ if (typeof apiBaseUrl === "undefined") {
49
+ throw new Error("please add OrderlyProvider to your app");
50
+ }
51
+ return useSWRMutation(
52
+ query,
53
+ (url, options2) => {
54
+ console.log(url, options2);
55
+ url = url.startsWith("http") ? url : `${apiBaseUrl}${url}`;
56
+ if (options2?.arg) {
57
+ const queryString = Object.entries(options2.arg).map(
58
+ ([key, value]) => `${key}=${encodeURIComponent(value)}`
59
+ ).join("&");
60
+ url = `${url}?${queryString}`;
61
+ }
62
+ return fetcher(url, init, {
63
+ formatter
64
+ });
65
+ },
66
+ swrOptions
67
+ );
68
+ };
93
69
  var useAccountInstance = () => {
94
70
  const { configStore, keyStore, contractManager, getWalletAdapter } = useContext(OrderlyContext);
95
71
  if (!configStore)
@@ -120,7 +96,9 @@ var useAccountInstance = () => {
120
96
  var fetcher2 = (url, options) => {
121
97
  const init = {
122
98
  method: options.arg.method,
123
- headers: __spreadValues({}, options.arg.signature)
99
+ headers: {
100
+ ...options.arg.signature
101
+ }
124
102
  };
125
103
  if (options.arg.data) {
126
104
  init.body = JSON.stringify(options.arg.data);
@@ -145,7 +123,7 @@ var useMutation = (url, method = "POST", options) => {
145
123
  fetcher2,
146
124
  options
147
125
  );
148
- const mutation = (data2, params) => __async(void 0, null, function* () {
126
+ const mutation = async (data2, params) => {
149
127
  let newUrl = url;
150
128
  if (typeof params === "object" && Object.keys(params).length) {
151
129
  let search = new URLSearchParams(params);
@@ -156,16 +134,17 @@ var useMutation = (url, method = "POST", options) => {
156
134
  url: newUrl,
157
135
  data: data2
158
136
  };
159
- const signature = yield signer.sign(payload);
137
+ const signature = await signer.sign(payload);
160
138
  return trigger({
161
139
  data: data2,
162
140
  params,
163
141
  method,
164
- signature: __spreadProps(__spreadValues({}, signature), {
142
+ signature: {
143
+ ...signature,
165
144
  "orderly-account-id": account5.accountId
166
- })
145
+ }
167
146
  });
168
- });
147
+ };
169
148
  return [
170
149
  mutation,
171
150
  {
@@ -180,7 +159,7 @@ var signatureMiddleware = (useSWRNext) => {
180
159
  const { apiBaseUrl } = useContext(OrderlyContext);
181
160
  return (key, fetcher4, config) => {
182
161
  try {
183
- const extendedFetcher = (args) => __async(void 0, null, function* () {
162
+ const extendedFetcher = async (args) => {
184
163
  let url = Array.isArray(args) ? args[0] : args;
185
164
  let account5 = SimpleDI.get("account");
186
165
  let fullUrl = `${apiBaseUrl}${url}`;
@@ -189,13 +168,14 @@ var signatureMiddleware = (useSWRNext) => {
189
168
  method: "GET",
190
169
  url
191
170
  };
192
- const signature = yield signer.sign(payload);
171
+ const signature = await signer.sign(payload);
193
172
  return fetcher4(fullUrl, {
194
- headers: __spreadProps(__spreadValues({}, signature), {
173
+ headers: {
174
+ ...signature,
195
175
  "orderly-account-id": account5.accountId
196
- })
176
+ }
197
177
  });
198
- });
178
+ };
199
179
  return useSWRNext(key, extendedFetcher, config);
200
180
  } catch (e) {
201
181
  console.error("signature error:", e);
@@ -236,23 +216,23 @@ var useAccount = () => {
236
216
  [account5]
237
217
  );
238
218
  const createOrderlyKey = useCallback(
239
- (remember) => __async(void 0, null, function* () {
219
+ async (remember) => {
240
220
  return account5.createOrderlyKey(remember ? 365 : 30);
241
- }),
221
+ },
242
222
  [account5]
243
223
  );
244
- const createAccount = useCallback(() => __async(void 0, null, function* () {
224
+ const createAccount = useCallback(async () => {
245
225
  return account5.createAccount();
246
- }), [account5]);
247
- const connect = useCallback(() => __async(void 0, null, function* () {
248
- return onWalletConnect == null ? void 0 : onWalletConnect();
249
- }), [account5]);
250
- const disconnect = () => __async(void 0, null, function* () {
251
- return onWalletDisconnect == null ? void 0 : onWalletDisconnect();
252
- });
253
- const setChain = (chainId) => __async(void 0, null, function* () {
254
- return onSetChain == null ? void 0 : onSetChain(chainId);
255
- });
226
+ }, [account5]);
227
+ const connect = useCallback(async () => {
228
+ return onWalletConnect?.();
229
+ }, [account5]);
230
+ const disconnect = async () => {
231
+ return onWalletDisconnect?.();
232
+ };
233
+ const setChain = async (chainId) => {
234
+ return onSetChain?.(chainId);
235
+ };
256
236
  return {
257
237
  // account: state!,
258
238
  account: account5,
@@ -268,24 +248,31 @@ var useAccount = () => {
268
248
  };
269
249
  };
270
250
  var usePrivateQuery = (query, options) => {
271
- var _b;
272
- const _a = options || {}, { formatter } = _a, swrOptions = __objRest(_a, ["formatter"]);
251
+ const { formatter, ...swrOptions } = options || {};
273
252
  const account5 = useAccount();
274
- const middleware = Array.isArray(options == null ? void 0 : options.use) ? (_b = options == null ? void 0 : options.use) != null ? _b : [] : [];
253
+ const middleware = Array.isArray(options?.use) ? options?.use ?? [] : [];
275
254
  return useSWR(
276
255
  () => account5.state.status >= AccountStatusEnum.EnableTrading ? [query, account5.state.accountId] : null,
277
256
  // query,
278
257
  (url, init) => {
279
258
  return fetcher(url, init, { formatter });
280
259
  },
281
- __spreadProps(__spreadValues({}, swrOptions), {
260
+ {
261
+ ...swrOptions,
282
262
  use: [signatureMiddleware, ...middleware],
283
263
  onError: (err) => {
284
264
  console.log("usePrivateQuery error", err);
285
265
  }
286
- })
266
+ }
287
267
  );
288
268
  };
269
+ var useBoolean = (initialValue = false) => {
270
+ const [value, setValue] = useState(initialValue);
271
+ const setTrue = useCallback(() => setValue(true), []);
272
+ const setFalse = useCallback(() => setValue(false), []);
273
+ const toggle = useCallback(() => setValue((v) => !v), []);
274
+ return [value, { setTrue, setFalse, toggle }];
275
+ };
289
276
 
290
277
  // src/useTradingView.ts
291
278
  var useTradingView = () => {
@@ -312,25 +299,31 @@ var useTopicObserve = (topic) => {
312
299
  };
313
300
  };
314
301
  var useAppState = () => {
315
- const { errors, ready } = useContext(OrderlyContext);
302
+ const { errors } = useContext(OrderlyContext);
316
303
  return {
317
- errors,
318
- ready
304
+ errors
305
+ // ready,
319
306
  };
320
307
  };
321
- var usePreLoadData = (onSuccess) => {
308
+ var usePreLoadData = () => {
322
309
  const { configStore } = useContext(OrderlyContext);
323
- useSWR(
310
+ const { error: swapSupportError, data: swapSupportData } = useSWR(
324
311
  `${configStore.get("swapSupportApiUrl")}/swap_support`,
325
312
  (url) => fetch(url).then((res) => res.json()),
326
313
  {
327
- revalidateOnFocus: false,
328
- // suspense: true,
329
- onSuccess: (data, key, config) => {
330
- onSuccess("chains_fetch");
331
- }
314
+ revalidateOnFocus: false
332
315
  }
333
316
  );
317
+ const { error: tokenError, data: tokenData } = useQuery("/v1/public/token", {
318
+ revalidateOnFocus: false
319
+ });
320
+ const isDone = useMemo(() => {
321
+ return !!swapSupportData && !!tokenData;
322
+ }, [swapSupportData, tokenData]);
323
+ return {
324
+ error: swapSupportError || tokenError,
325
+ done: isDone
326
+ };
334
327
  };
335
328
  var useEventEmitter = (channel) => {
336
329
  return useConstant(() => {
@@ -346,8 +339,8 @@ var useEventEmitter = (channel) => {
346
339
  // src/utils/json.ts
347
340
  function parseJSON(value) {
348
341
  try {
349
- return value === "undefined" ? void 0 : JSON.parse(value != null ? value : "");
350
- } catch (e) {
342
+ return value === "undefined" ? void 0 : JSON.parse(value ?? "");
343
+ } catch {
351
344
  console.log("parsing error on", { value });
352
345
  return void 0;
353
346
  }
@@ -396,7 +389,7 @@ function useSessionStorage(key, initialValue) {
396
389
  });
397
390
  const handleStorageChange = useCallback(
398
391
  (event) => {
399
- if ((event == null ? void 0 : event.key) && event.key !== key) {
392
+ if (event?.key && event.key !== key) {
400
393
  return;
401
394
  }
402
395
  setStoredValue(readValue());
@@ -476,12 +469,12 @@ var useWS = () => {
476
469
  networkId: "testnet",
477
470
  publicUrl: configStore.get("publicWsUrl"),
478
471
  privateUrl: configStore.get("privateWsUrl"),
479
- onSigntureRequest: (accountId) => __async(void 0, null, function* () {
472
+ onSigntureRequest: async (accountId) => {
480
473
  const signer = account5.signer;
481
474
  const timestamp = (/* @__PURE__ */ new Date()).getTime();
482
- const result = yield signer.signText(timestamp.toString());
483
- return __spreadProps(__spreadValues({}, result), { timestamp });
484
- })
475
+ const result = await signer.signText(timestamp.toString());
476
+ return { ...result, timestamp };
477
+ }
485
478
  });
486
479
  account5.on("change:status", (nextState) => {
487
480
  if (nextState.status === AccountStatusEnum.EnableTrading && nextState.accountId) {
@@ -529,7 +522,7 @@ var useTickerStream = (symbol) => {
529
522
  );
530
523
  return () => {
531
524
  console.log("unsubscribe!!!!!!!");
532
- unsubscribe == null ? void 0 : unsubscribe();
525
+ unsubscribe?.();
533
526
  };
534
527
  }
535
528
  );
@@ -538,7 +531,7 @@ var useTickerStream = (symbol) => {
538
531
  return null;
539
532
  if (!ticker)
540
533
  return info;
541
- const config = __spreadValues({}, info);
534
+ const config = { ...info };
542
535
  if (ticker.close !== void 0) {
543
536
  config["24h_close"] = ticker.close;
544
537
  }
@@ -565,7 +558,7 @@ var useMarkPrice = (symbol) => {
565
558
  });
566
559
  return () => {
567
560
  console.log("unsubscribe useMarkPrice !!!!!!!");
568
- unsubscribe == null ? void 0 : unsubscribe();
561
+ unsubscribe?.();
569
562
  };
570
563
  });
571
564
  };
@@ -576,16 +569,14 @@ function createGetter(data, depth = 2) {
576
569
  get(target, property, receiver) {
577
570
  if (depth === 1) {
578
571
  return (defaultValue) => {
579
- var _a;
580
572
  if (!target)
581
573
  return defaultValue;
582
- return (_a = target[property]) != null ? _a : defaultValue;
574
+ return target[property] ?? defaultValue;
583
575
  };
584
576
  }
585
577
  return (key, defaultValue) => {
586
- var _a, _b;
587
578
  if (key) {
588
- return (_b = (_a = target[property]) == null ? void 0 : _a[key]) != null ? _b : defaultValue;
579
+ return target[property]?.[key] ?? defaultValue;
589
580
  } else {
590
581
  return target[property];
591
582
  }
@@ -599,8 +590,7 @@ var useSymbolsInfo = () => {
599
590
  dedupingInterval: 1e3 * 60 * 60 * 24,
600
591
  revalidateOnFocus: false,
601
592
  formatter(data2) {
602
- var _a;
603
- if (!(data2 == null ? void 0 : data2.rows) || !((_a = data2 == null ? void 0 : data2.rows) == null ? void 0 : _a.length)) {
593
+ if (!data2?.rows || !data2?.rows?.length) {
604
594
  return {};
605
595
  }
606
596
  const obj = /* @__PURE__ */ Object.create(null);
@@ -609,14 +599,15 @@ var useSymbolsInfo = () => {
609
599
  const arr = item.symbol.split("_");
610
600
  const base_dp = getPrecisionByNumber(item.base_tick);
611
601
  const quote_dp = getPrecisionByNumber(item.quote_tick);
612
- obj[item.symbol] = __spreadProps(__spreadValues({}, item), {
602
+ obj[item.symbol] = {
603
+ ...item,
613
604
  base_dp,
614
605
  quote_dp,
615
606
  base: arr[1],
616
607
  quote: arr[2],
617
608
  type: arr[0],
618
609
  name: `${arr[1]}-${arr[0]}`
619
- });
610
+ };
620
611
  }
621
612
  return obj;
622
613
  }
@@ -709,10 +700,7 @@ var useOrderbookStream = (symbol, initial = { asks: [], bids: [] }, options) =>
709
700
  const [requestData, setRequestData] = useState(null);
710
701
  const [data, setData] = useState(initial);
711
702
  const [isLoading, setIsLoading] = useState(true);
712
- const [level, setLevel] = useState(() => {
713
- var _a;
714
- return (_a = options == null ? void 0 : options.level) != null ? _a : 10;
715
- });
703
+ const [level, setLevel] = useState(() => options?.level ?? 10);
716
704
  const config = useSymbolsInfo()[symbol];
717
705
  const [depth, setDepth] = useState();
718
706
  const depths = useMemo(() => {
@@ -770,7 +758,7 @@ var useOrderbookStream = (symbol, initial = { asks: [], bids: [] }, options) =>
770
758
  }
771
759
  );
772
760
  return () => {
773
- subscription == null ? void 0 : subscription();
761
+ subscription?.();
774
762
  };
775
763
  }, [symbol, requestData]);
776
764
  const onItemClick = useCallback((item) => {
@@ -814,9 +802,10 @@ function baseInputHandle(inputs) {
814
802
  value = value.replace(/[^\d.]/g, "");
815
803
  }
816
804
  return [
817
- __spreadProps(__spreadValues({}, values), {
805
+ {
806
+ ...values,
818
807
  [input]: value
819
- }),
808
+ },
820
809
  input,
821
810
  value,
822
811
  markPrice,
@@ -832,7 +821,7 @@ function orderEntityFormatHandle(baseTick, quoteTick) {
832
821
  function priceInputHandle(inputs) {
833
822
  const [values, input, value, markPrice, config] = inputs;
834
823
  if (value === "") {
835
- return [__spreadProps(__spreadValues({}, values), { total: "" }), input, value, markPrice, config];
824
+ return [{ ...values, total: "" }, input, value, markPrice, config];
836
825
  }
837
826
  const price = new Decimal(value);
838
827
  const priceDP = price.dp();
@@ -845,9 +834,10 @@ function priceInputHandle(inputs) {
845
834
  }
846
835
  const total = price.mul(values.order_quantity);
847
836
  return [
848
- __spreadProps(__spreadValues({}, values), {
837
+ {
838
+ ...values,
849
839
  total: total.todp(2).toString()
850
- }),
840
+ },
851
841
  input,
852
842
  value,
853
843
  markPrice,
@@ -857,7 +847,7 @@ function priceInputHandle(inputs) {
857
847
  function quantityInputHandle(inputs) {
858
848
  const [values, input, value, markPrice, config] = inputs;
859
849
  if (value === "") {
860
- return [__spreadProps(__spreadValues({}, values), { total: "" }), input, value, markPrice, config];
850
+ return [{ ...values, total: "" }, input, value, markPrice, config];
861
851
  }
862
852
  let quantity = new Decimal(value);
863
853
  const quantityDP = quantity.dp();
@@ -879,7 +869,10 @@ function quantityInputHandle(inputs) {
879
869
  }
880
870
  }
881
871
  return [
882
- __spreadValues({}, values),
872
+ {
873
+ ...values
874
+ // total: total.todp(2).toNumber(),
875
+ },
883
876
  input,
884
877
  value,
885
878
  markPrice,
@@ -889,7 +882,7 @@ function quantityInputHandle(inputs) {
889
882
  function totalInputHandle(inputs) {
890
883
  const [values, input, value, markPrice, config] = inputs;
891
884
  if (value === "") {
892
- return [__spreadProps(__spreadValues({}, values), { order_quantity: "" }), input, value, markPrice, config];
885
+ return [{ ...values, order_quantity: "" }, input, value, markPrice, config];
893
886
  }
894
887
  let price = markPrice;
895
888
  if (values.order_type === OrderType.LIMIT && !!values.order_price) {
@@ -903,9 +896,10 @@ function totalInputHandle(inputs) {
903
896
  }
904
897
  const quantity = total.div(price);
905
898
  return [
906
- __spreadProps(__spreadValues({}, values), {
899
+ {
900
+ ...values,
907
901
  order_quantity: quantity.toDecimalPlaces(Math.min(config.baseDP, quantity.dp())).toNumber()
908
- }),
902
+ },
909
903
  input,
910
904
  value,
911
905
  markPrice,
@@ -939,8 +933,7 @@ var useFundingRates = () => {
939
933
  focusThrottleInterval: 1e3 * 60 * 60 * 24,
940
934
  revalidateOnFocus: false,
941
935
  formatter(data2) {
942
- var _a;
943
- if (!(data2 == null ? void 0 : data2.rows) || !((_a = data2 == null ? void 0 : data2.rows) == null ? void 0 : _a.length)) {
936
+ if (!data2?.rows || !data2?.rows?.length) {
944
937
  return {};
945
938
  }
946
939
  const obj = /* @__PURE__ */ Object.create(null);
@@ -979,7 +972,7 @@ var useMarkPricesStream = () => {
979
972
  );
980
973
  return () => {
981
974
  console.log("unsubscribe!!!!!!!");
982
- unsubscribe == null ? void 0 : unsubscribe();
975
+ unsubscribe?.();
983
976
  };
984
977
  });
985
978
  };
@@ -989,13 +982,12 @@ var parseHolding = (holding, markPrices) => {
989
982
  const nonUSDC = [];
990
983
  let USDC_holding = 0;
991
984
  holding.forEach((item) => {
992
- var _a;
993
985
  if (item.token === "USDC") {
994
986
  USDC_holding = item.holding;
995
987
  } else {
996
988
  nonUSDC.push({
997
989
  holding: item.holding,
998
- markPrice: (_a = markPrices[item.token]) != null ? _a : 0,
990
+ markPrice: markPrices[item.token] ?? 0,
999
991
  // markPrice: 0,
1000
992
  discount: 0
1001
993
  });
@@ -1004,7 +996,6 @@ var parseHolding = (holding, markPrices) => {
1004
996
  return [USDC_holding, nonUSDC];
1005
997
  };
1006
998
  var usePositionStream = (symbol, options) => {
1007
- var _a;
1008
999
  const symbolInfo = useSymbolsInfo();
1009
1000
  useEventEmitter();
1010
1001
  const { data: accountInfo } = usePrivateQuery("/v1/client/info");
@@ -1021,22 +1012,27 @@ var usePositionStream = (symbol, options) => {
1021
1012
  data,
1022
1013
  error
1023
1014
  // mutate: updatePositions,
1024
- } = usePrivateQuery(`/v1/positions`, __spreadProps(__spreadValues({}, options), {
1015
+ } = usePrivateQuery(`/v1/positions`, {
1016
+ // revalidateOnFocus: false,
1017
+ // revalidateOnReconnect: false,
1018
+ // dedupingInterval: 100,
1019
+ // keepPreviousData: false,
1020
+ // revalidateIfStale: true,
1021
+ ...options,
1025
1022
  formatter: (data2) => data2,
1026
1023
  onError: (err) => {
1027
1024
  console.log("usePositionStream error", err);
1028
1025
  }
1029
- }));
1026
+ });
1030
1027
  const { data: markPrices } = useMarkPricesStream();
1031
1028
  const formatedPositions = useMemo(() => {
1032
- if (!(data == null ? void 0 : data.rows) || !symbolInfo || !accountInfo)
1029
+ if (!data?.rows || !symbolInfo || !accountInfo)
1033
1030
  return null;
1034
1031
  const filteredData = typeof symbol === "undefined" || symbol === "" ? data.rows : data.rows.filter((item) => {
1035
1032
  return item.symbol === symbol;
1036
1033
  });
1037
1034
  let unrealPnL_total = zero, notional_total = zero, unsettlementPnL_total = zero;
1038
1035
  const formatted = filteredData.map((item) => {
1039
- var _a2;
1040
1036
  const price = propOr(
1041
1037
  item.mark_price,
1042
1038
  item.symbol,
@@ -1052,8 +1048,7 @@ var usePositionStream = (symbol, options) => {
1052
1048
  positionQty: item.position_qty,
1053
1049
  markPrice: price,
1054
1050
  costPosition: item.cost_position,
1055
- sumUnitaryFunding: (_a2 = fundingRates[item.symbol]) == null ? void 0 : _a2.call(
1056
- fundingRates,
1051
+ sumUnitaryFunding: fundingRates[item.symbol]?.(
1057
1052
  "sum_unitary_funding",
1058
1053
  0
1059
1054
  ),
@@ -1062,13 +1057,14 @@ var usePositionStream = (symbol, options) => {
1062
1057
  unrealPnL_total = unrealPnL_total.add(unrealPnl);
1063
1058
  notional_total = notional_total.add(notional);
1064
1059
  unsettlementPnL_total = unsettlementPnL_total.add(unsettlementPnL);
1065
- return __spreadProps(__spreadValues({}, item), {
1060
+ return {
1061
+ ...item,
1066
1062
  mark_price: price,
1067
1063
  mm: 0,
1068
1064
  notional,
1069
1065
  unsettlement_pnl: unsettlementPnL,
1070
1066
  unrealized_pnl: unrealPnl
1071
- });
1067
+ };
1072
1068
  });
1073
1069
  return [
1074
1070
  formatted,
@@ -1078,7 +1074,7 @@ var usePositionStream = (symbol, options) => {
1078
1074
  unsettledPnL: unsettlementPnL_total.toNumber()
1079
1075
  }
1080
1076
  ];
1081
- }, [data == null ? void 0 : data.rows, symbolInfo, accountInfo, markPrices, symbol, holding]);
1077
+ }, [data?.rows, symbolInfo, accountInfo, markPrices, symbol, holding]);
1082
1078
  const [totalCollateral, totalValue, totalUnrealizedROI] = useMemo(() => {
1083
1079
  if (!holding || !markPrices) {
1084
1080
  return [zero, zero, 0];
@@ -1109,7 +1105,7 @@ var usePositionStream = (symbol, options) => {
1109
1105
  return formatedPositions[0];
1110
1106
  const total = totalCollateral.toNumber();
1111
1107
  return formatedPositions[0].filter((item) => item.position_qty !== 0).map((item) => {
1112
- const info = symbolInfo == null ? void 0 : symbolInfo[item.symbol];
1108
+ const info = symbolInfo?.[item.symbol];
1113
1109
  const MMR = positions.MMR({
1114
1110
  baseMMR: info("base_mmr"),
1115
1111
  baseIMR: info("base_imr"),
@@ -1117,7 +1113,8 @@ var usePositionStream = (symbol, options) => {
1117
1113
  positionNotional: item.notional,
1118
1114
  IMR_factor_power: 4 / 5
1119
1115
  });
1120
- return __spreadProps(__spreadValues({}, item), {
1116
+ return {
1117
+ ...item,
1121
1118
  mm: positions.maintenanceMargin({
1122
1119
  positionQty: item.position_qty,
1123
1120
  markPrice: item.mark_price,
@@ -1130,13 +1127,13 @@ var usePositionStream = (symbol, options) => {
1130
1127
  MMR
1131
1128
  }),
1132
1129
  MMR
1133
- });
1130
+ };
1134
1131
  });
1135
1132
  }, [formatedPositions, symbolInfo, accountInfo, totalCollateral]);
1136
1133
  return [
1137
1134
  {
1138
1135
  rows: positionsRows,
1139
- aggregated: (_a = formatedPositions == null ? void 0 : formatedPositions[1]) != null ? _a : {},
1136
+ aggregated: formatedPositions?.[1] ?? {},
1140
1137
  totalCollateral,
1141
1138
  totalValue,
1142
1139
  totalUnrealizedROI
@@ -1170,7 +1167,7 @@ var useHoldingStream = () => {
1170
1167
  }
1171
1168
  );
1172
1169
  const usdc = useMemo(() => {
1173
- const usdc2 = data == null ? void 0 : data.find((item) => item.token === "USDC");
1170
+ const usdc2 = data?.find((item) => item.token === "USDC");
1174
1171
  return usdc2;
1175
1172
  }, [data]);
1176
1173
  useSWRSubscription("holding", (_, { next }) => {
@@ -1183,16 +1180,16 @@ var useHoldingStream = () => {
1183
1180
  },
1184
1181
  {
1185
1182
  onMessage: (data2) => {
1186
- var _a;
1187
- const holding = (_a = data2 == null ? void 0 : data2.balances) != null ? _a : {};
1183
+ const holding = data2?.balances ?? {};
1188
1184
  if (holding) {
1189
1185
  mutate2((prevData) => {
1190
- return prevData == null ? void 0 : prevData.map((item) => {
1186
+ return prevData?.map((item) => {
1191
1187
  const token = holding[item.token];
1192
- return __spreadProps(__spreadValues({}, item), {
1188
+ return {
1189
+ ...item,
1193
1190
  frozen: token.frozen,
1194
1191
  holding: token.holding
1195
- });
1192
+ };
1196
1193
  });
1197
1194
  });
1198
1195
  next(holding);
@@ -1234,7 +1231,7 @@ var useCollateral = (options = { dp: 6 }) => {
1234
1231
  }
1235
1232
  return account.totalInitialMarginWithOrders({
1236
1233
  positions: positionsPath(positions2),
1237
- orders: orders != null ? orders : [],
1234
+ orders: orders ?? [],
1238
1235
  markPrices,
1239
1236
  IMR_Factors: accountInfo.imr_factor,
1240
1237
  maxLeverage: accountInfo.max_leverage,
@@ -1248,9 +1245,8 @@ var useCollateral = (options = { dp: 6 }) => {
1248
1245
  });
1249
1246
  }, [totalCollateral, totalInitialMarginWithOrders]);
1250
1247
  const availableBalance = useMemo(() => {
1251
- var _a;
1252
1248
  return account.availableBalance({
1253
- USDCHolding: (_a = usdc == null ? void 0 : usdc.holding) != null ? _a : 0,
1249
+ USDCHolding: usdc?.holding ?? 0,
1254
1250
  unsettlementPnL: pathOr_unsettledPnLPathOr(positions2)
1255
1251
  });
1256
1252
  }, [usdc, pathOr_unsettledPnLPathOr(positions2)]);
@@ -1415,9 +1411,10 @@ var BaseOrderCreator = class {
1415
1411
  };
1416
1412
  var LimitOrderCreator = class extends BaseOrderCreator {
1417
1413
  create(values) {
1418
- return __spreadProps(__spreadValues({}, this.baseOrder(values)), {
1414
+ return {
1415
+ ...this.baseOrder(values),
1419
1416
  order_price: values.order_price
1420
- });
1417
+ };
1421
1418
  }
1422
1419
  validate(values, config) {
1423
1420
  return this.baseValidate(values, config).then((errors) => {
@@ -1457,7 +1454,9 @@ var MarketOrderCreator = class extends BaseOrderCreator {
1457
1454
  create(values) {
1458
1455
  const data = this.baseOrder(values);
1459
1456
  delete data["order_price"];
1460
- return __spreadValues({}, data);
1457
+ return {
1458
+ ...data
1459
+ };
1461
1460
  }
1462
1461
  validate(values, configs) {
1463
1462
  return this.baseValidate(values, configs);
@@ -1471,10 +1470,11 @@ var IOCOrderCreator = class extends LimitOrderCreator {
1471
1470
  };
1472
1471
  var GeneralOrderCreator = class extends BaseOrderCreator {
1473
1472
  create(data) {
1474
- return __spreadProps(__spreadValues({}, this.baseOrder(data)), {
1473
+ return {
1474
+ ...this.baseOrder(data),
1475
1475
  order_price: data.order_price,
1476
1476
  order_quantity: data.order_quantity
1477
- });
1477
+ };
1478
1478
  }
1479
1479
  validate(values, configs) {
1480
1480
  return super.baseValidate(values, configs);
@@ -1528,7 +1528,7 @@ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
1528
1528
  if (!orderCreator) {
1529
1529
  return Promise.reject(new Error("orderCreator is null"));
1530
1530
  }
1531
- return orderCreator == null ? void 0 : orderCreator.validate(values, {
1531
+ return orderCreator?.validate(values, {
1532
1532
  symbol: symbolInfo[symbol](),
1533
1533
  // token: tokenInfo[symbol](),
1534
1534
  maxQty,
@@ -1541,9 +1541,10 @@ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
1541
1541
  throw new Error("symbol is null");
1542
1542
  }
1543
1543
  const data = orderCreator.create(values);
1544
- return doCreateOrder(__spreadProps(__spreadValues({}, data), {
1544
+ return doCreateOrder({
1545
+ ...data,
1545
1546
  symbol
1546
- }));
1547
+ });
1547
1548
  });
1548
1549
  };
1549
1550
  const calculate = useCallback(
@@ -1562,7 +1563,7 @@ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
1562
1563
  );
1563
1564
  const validator = (values) => {
1564
1565
  const creator = OrderFactory.create(values.order_type);
1565
- return creator == null ? void 0 : creator.validate(values, {
1566
+ return creator?.validate(values, {
1566
1567
  symbol: symbolInfo[symbol](),
1567
1568
  // token: tokenInfo[symbol](),
1568
1569
  maxQty,
@@ -1627,14 +1628,12 @@ var useTokenInfo = () => {
1627
1628
  focusThrottleInterval: 1e3 * 60 * 60 * 24,
1628
1629
  revalidateOnFocus: false,
1629
1630
  formatter(data2) {
1630
- var _a;
1631
- if (!(data2 == null ? void 0 : data2.rows) || !((_a = data2 == null ? void 0 : data2.rows) == null ? void 0 : _a.length)) {
1631
+ if (!data2?.rows || !data2?.rows?.length) {
1632
1632
  return {};
1633
1633
  }
1634
1634
  const obj = /* @__PURE__ */ Object.create(null);
1635
1635
  for (let index = 0; index < data2.rows.length; index++) {
1636
- const item = data2.rows[index];
1637
- obj[item.token] = item;
1636
+ data2.rows[index];
1638
1637
  }
1639
1638
  return obj;
1640
1639
  }
@@ -1665,7 +1664,7 @@ var useMarketsStream = () => {
1665
1664
  );
1666
1665
  return () => {
1667
1666
  console.log("unsubscribe!!!!!!!");
1668
- unsubscribe == null ? void 0 : unsubscribe();
1667
+ unsubscribe?.();
1669
1668
  };
1670
1669
  });
1671
1670
  const value = useMemo(() => {
@@ -1678,12 +1677,13 @@ var useMarketsStream = () => {
1678
1677
  (t) => t.symbol === item.symbol
1679
1678
  );
1680
1679
  if (ticker) {
1681
- return __spreadProps(__spreadValues({}, item), {
1680
+ return {
1681
+ ...item,
1682
1682
  ["24h_close"]: ticker.close,
1683
1683
  ["24h_open"]: ticker.open,
1684
1684
  ["24h_volumn"]: ticker.volume,
1685
1685
  change: 0
1686
- });
1686
+ };
1687
1687
  }
1688
1688
  return item;
1689
1689
  });
@@ -1701,7 +1701,6 @@ var useLeverage = () => {
1701
1701
  return [prop("max_leverage", data), { update: updateLeverage }];
1702
1702
  };
1703
1703
  var useFundingRate = (symbol) => {
1704
- var _a;
1705
1704
  if (!symbol) {
1706
1705
  throw new Error("useFuturesForSymbol requires a symbol");
1707
1706
  }
@@ -1735,22 +1734,23 @@ var useFundingRate = (symbol) => {
1735
1734
  clearInterval(timer);
1736
1735
  };
1737
1736
  }, [data]);
1738
- return __spreadProps(__spreadValues({}, data), {
1739
- est_funding_rate: (Number((_a = data == null ? void 0 : data.est_funding_rate) != null ? _a : 0) * 100).toFixed(4),
1737
+ return {
1738
+ ...data,
1739
+ est_funding_rate: (Number(data?.est_funding_rate ?? 0) * 100).toFixed(4),
1740
1740
  countDown
1741
- });
1741
+ };
1742
1742
  };
1743
1743
  var fetcher3 = (url, init) => get(url, init);
1744
1744
  var usePrivateInfiniteQuery = (getKey, options) => {
1745
- var _a;
1746
1745
  const account5 = useAccount();
1747
- const middleware = Array.isArray(options == null ? void 0 : options.use) ? (_a = options == null ? void 0 : options.use) != null ? _a : [] : [];
1746
+ const middleware = Array.isArray(options?.use) ? options?.use ?? [] : [];
1748
1747
  const result = useSWRInfinite(
1749
1748
  (pageIndex, previousPageData) => account5.state.status >= AccountStatusEnum.EnableTrading ? getKey(pageIndex, previousPageData) : null,
1750
1749
  fetcher3,
1751
- __spreadProps(__spreadValues({}, options), {
1750
+ {
1751
+ ...options,
1752
1752
  use: [signatureMiddleware, ...middleware]
1753
- })
1753
+ }
1754
1754
  );
1755
1755
  return result;
1756
1756
  };
@@ -1798,15 +1798,14 @@ var useOrderStream = ({
1798
1798
  }
1799
1799
  );
1800
1800
  const orders = useMemo(() => {
1801
- var _a;
1802
1801
  if (!ordersResponse.data) {
1803
1802
  return null;
1804
1803
  }
1805
- return (_a = ordersResponse.data) == null ? void 0 : _a.flat().map((item) => {
1806
- var _a2;
1807
- return __spreadProps(__spreadValues({}, item), {
1808
- mark_price: (_a2 = markPrices[item.symbol]) != null ? _a2 : 0
1809
- });
1804
+ return ordersResponse.data?.flat().map((item) => {
1805
+ return {
1806
+ ...item,
1807
+ mark_price: markPrices[item.symbol] ?? 0
1808
+ };
1810
1809
  });
1811
1810
  }, [ordersResponse.data, markPrices]);
1812
1811
  useEffect(() => {
@@ -1819,7 +1818,7 @@ var useOrderStream = ({
1819
1818
  const cancelAllOrders = useCallback(() => {
1820
1819
  }, [ordersResponse.data]);
1821
1820
  const updateOrder = useCallback((orderId, order2) => {
1822
- return doUpdateOrder(__spreadProps(__spreadValues({}, order2), { order_id: orderId }));
1821
+ return doUpdateOrder({ ...order2, order_id: orderId });
1823
1822
  }, []);
1824
1823
  const cancelOrder = useCallback((orderId, symbol2) => {
1825
1824
  return doCancelOrder(null, {
@@ -1885,7 +1884,7 @@ var useMarketTradeStream = (symbol, options = {}) => {
1885
1884
  {
1886
1885
  onMessage: (data) => {
1887
1886
  setTrades((prev) => {
1888
- const arr = [__spreadProps(__spreadValues({}, data), { ts: Date.now() }), ...prev];
1887
+ const arr = [{ ...data, ts: Date.now() }, ...prev];
1889
1888
  if (arr.length > limit) {
1890
1889
  arr.pop();
1891
1890
  }
@@ -1895,10 +1894,9 @@ var useMarketTradeStream = (symbol, options = {}) => {
1895
1894
  }
1896
1895
  );
1897
1896
  return () => {
1898
- unsubscript == null ? void 0 : unsubscript();
1897
+ unsubscript?.();
1899
1898
  };
1900
1899
  }, [symbol]);
1901
- console.log("trades", trades);
1902
1900
  return { data: trades, isLoading };
1903
1901
  };
1904
1902
  var useMarginRatio = () => {
@@ -1912,7 +1910,7 @@ var useMarginRatio = () => {
1912
1910
  const ratio = account.totalMarginRatio({
1913
1911
  totalCollateral,
1914
1912
  markPrices,
1915
- positions: rows != null ? rows : []
1913
+ positions: rows ?? []
1916
1914
  });
1917
1915
  return ratio;
1918
1916
  }, [rows, markPrices, totalCollateral]);
@@ -1921,60 +1919,747 @@ var useMarginRatio = () => {
1921
1919
  }, [marginRatio]);
1922
1920
  return { marginRatio, currentLeverage };
1923
1921
  };
1922
+
1923
+ // src/woo/constants.ts
1924
+ var woofiDexCrossChainRouterAbi = [
1925
+ {
1926
+ inputs: [
1927
+ { internalType: "address", name: "_weth", type: "address" },
1928
+ { internalType: "address", name: "_nonceCounter", type: "address" },
1929
+ { internalType: "address", name: "_wooRouter", type: "address" },
1930
+ { internalType: "address", name: "_stargateRouter", type: "address" },
1931
+ { internalType: "uint16", name: "_sgChainIdLocal", type: "uint16" }
1932
+ ],
1933
+ stateMutability: "nonpayable",
1934
+ type: "constructor"
1935
+ },
1936
+ {
1937
+ anonymous: false,
1938
+ inputs: [
1939
+ {
1940
+ indexed: true,
1941
+ internalType: "address",
1942
+ name: "previousOwner",
1943
+ type: "address"
1944
+ },
1945
+ {
1946
+ indexed: true,
1947
+ internalType: "address",
1948
+ name: "newOwner",
1949
+ type: "address"
1950
+ }
1951
+ ],
1952
+ name: "OwnershipTransferred",
1953
+ type: "event"
1954
+ },
1955
+ {
1956
+ anonymous: false,
1957
+ inputs: [
1958
+ {
1959
+ indexed: false,
1960
+ internalType: "address",
1961
+ name: "account",
1962
+ type: "address"
1963
+ }
1964
+ ],
1965
+ name: "Paused",
1966
+ type: "event"
1967
+ },
1968
+ {
1969
+ anonymous: false,
1970
+ inputs: [
1971
+ {
1972
+ indexed: false,
1973
+ internalType: "address",
1974
+ name: "account",
1975
+ type: "address"
1976
+ }
1977
+ ],
1978
+ name: "Unpaused",
1979
+ type: "event"
1980
+ },
1981
+ {
1982
+ anonymous: false,
1983
+ inputs: [
1984
+ {
1985
+ indexed: false,
1986
+ internalType: "uint16",
1987
+ name: "srcChainId",
1988
+ type: "uint16"
1989
+ },
1990
+ {
1991
+ indexed: true,
1992
+ internalType: "uint256",
1993
+ name: "nonce",
1994
+ type: "uint256"
1995
+ },
1996
+ {
1997
+ indexed: true,
1998
+ internalType: "address",
1999
+ name: "sender",
2000
+ type: "address"
2001
+ },
2002
+ { indexed: true, internalType: "address", name: "to", type: "address" },
2003
+ {
2004
+ indexed: false,
2005
+ internalType: "address",
2006
+ name: "bridgedToken",
2007
+ type: "address"
2008
+ },
2009
+ {
2010
+ indexed: false,
2011
+ internalType: "uint256",
2012
+ name: "bridgedAmount",
2013
+ type: "uint256"
2014
+ },
2015
+ {
2016
+ indexed: false,
2017
+ internalType: "address",
2018
+ name: "toToken",
2019
+ type: "address"
2020
+ },
2021
+ {
2022
+ indexed: false,
2023
+ internalType: "uint256",
2024
+ name: "minToAmount",
2025
+ type: "uint256"
2026
+ },
2027
+ {
2028
+ indexed: false,
2029
+ internalType: "address",
2030
+ name: "realToToken",
2031
+ type: "address"
2032
+ },
2033
+ {
2034
+ indexed: false,
2035
+ internalType: "uint256",
2036
+ name: "realToAmount",
2037
+ type: "uint256"
2038
+ },
2039
+ {
2040
+ indexed: false,
2041
+ internalType: "bytes32",
2042
+ name: "accountId",
2043
+ type: "bytes32"
2044
+ },
2045
+ {
2046
+ indexed: false,
2047
+ internalType: "bytes32",
2048
+ name: "brokerHash",
2049
+ type: "bytes32"
2050
+ },
2051
+ {
2052
+ indexed: false,
2053
+ internalType: "bytes32",
2054
+ name: "tokenHash",
2055
+ type: "bytes32"
2056
+ },
2057
+ {
2058
+ indexed: false,
2059
+ internalType: "uint128",
2060
+ name: "tokenAmount",
2061
+ type: "uint128"
2062
+ }
2063
+ ],
2064
+ name: "WOOFiDexCrossSwapOnDstChain",
2065
+ type: "event"
2066
+ },
2067
+ {
2068
+ anonymous: false,
2069
+ inputs: [
2070
+ {
2071
+ indexed: false,
2072
+ internalType: "uint16",
2073
+ name: "dstChainId",
2074
+ type: "uint16"
2075
+ },
2076
+ {
2077
+ indexed: true,
2078
+ internalType: "uint256",
2079
+ name: "nonce",
2080
+ type: "uint256"
2081
+ },
2082
+ {
2083
+ indexed: true,
2084
+ internalType: "address",
2085
+ name: "sender",
2086
+ type: "address"
2087
+ },
2088
+ { indexed: true, internalType: "address", name: "to", type: "address" },
2089
+ {
2090
+ indexed: false,
2091
+ internalType: "address",
2092
+ name: "fromToken",
2093
+ type: "address"
2094
+ },
2095
+ {
2096
+ indexed: false,
2097
+ internalType: "uint256",
2098
+ name: "fromAmount",
2099
+ type: "uint256"
2100
+ },
2101
+ {
2102
+ indexed: false,
2103
+ internalType: "address",
2104
+ name: "bridgeToken",
2105
+ type: "address"
2106
+ },
2107
+ {
2108
+ indexed: false,
2109
+ internalType: "uint256",
2110
+ name: "minBridgeAmount",
2111
+ type: "uint256"
2112
+ },
2113
+ {
2114
+ indexed: false,
2115
+ internalType: "uint256",
2116
+ name: "bridgeAmount",
2117
+ type: "uint256"
2118
+ }
2119
+ ],
2120
+ name: "WOOFiDexCrossSwapOnSrcChain",
2121
+ type: "event"
2122
+ },
2123
+ {
2124
+ inputs: [],
2125
+ name: "MAX_BRIDGE_SLIPPAGE",
2126
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2127
+ stateMutability: "view",
2128
+ type: "function"
2129
+ },
2130
+ {
2131
+ inputs: [],
2132
+ name: "NATIVE_PLACEHOLDER",
2133
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2134
+ stateMutability: "view",
2135
+ type: "function"
2136
+ },
2137
+ {
2138
+ inputs: [{ internalType: "address", name: "token", type: "address" }],
2139
+ name: "addDirectBridgeToken",
2140
+ outputs: [],
2141
+ stateMutability: "nonpayable",
2142
+ type: "function"
2143
+ },
2144
+ {
2145
+ inputs: [],
2146
+ name: "allDirectBridgeTokens",
2147
+ outputs: [{ internalType: "address[]", name: "", type: "address[]" }],
2148
+ stateMutability: "view",
2149
+ type: "function"
2150
+ },
2151
+ {
2152
+ inputs: [],
2153
+ name: "allDirectBridgeTokensLength",
2154
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2155
+ stateMutability: "view",
2156
+ type: "function"
2157
+ },
2158
+ {
2159
+ inputs: [],
2160
+ name: "bridgeSlippage",
2161
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2162
+ stateMutability: "view",
2163
+ type: "function"
2164
+ },
2165
+ {
2166
+ inputs: [
2167
+ { internalType: "address payable", name: "to", type: "address" },
2168
+ {
2169
+ components: [
2170
+ { internalType: "address", name: "fromToken", type: "address" },
2171
+ { internalType: "uint256", name: "fromAmount", type: "uint256" },
2172
+ { internalType: "address", name: "bridgeToken", type: "address" },
2173
+ {
2174
+ internalType: "uint256",
2175
+ name: "minBridgeAmount",
2176
+ type: "uint256"
2177
+ }
2178
+ ],
2179
+ internalType: "struct IWOOFiDexCrossChainRouter.SrcInfos",
2180
+ name: "srcInfos",
2181
+ type: "tuple"
2182
+ },
2183
+ {
2184
+ components: [
2185
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2186
+ { internalType: "address", name: "bridgedToken", type: "address" },
2187
+ { internalType: "address", name: "toToken", type: "address" },
2188
+ { internalType: "uint256", name: "minToAmount", type: "uint256" },
2189
+ {
2190
+ internalType: "uint256",
2191
+ name: "airdropNativeAmount",
2192
+ type: "uint256"
2193
+ }
2194
+ ],
2195
+ internalType: "struct IWOOFiDexCrossChainRouter.DstInfos",
2196
+ name: "dstInfos",
2197
+ type: "tuple"
2198
+ },
2199
+ {
2200
+ components: [
2201
+ { internalType: "bytes32", name: "accountId", type: "bytes32" },
2202
+ { internalType: "bytes32", name: "brokerHash", type: "bytes32" },
2203
+ { internalType: "bytes32", name: "tokenHash", type: "bytes32" }
2204
+ ],
2205
+ internalType: "struct IWOOFiDexCrossChainRouter.DstVaultDeposit",
2206
+ name: "dstVaultDeposit",
2207
+ type: "tuple"
2208
+ }
2209
+ ],
2210
+ name: "crossSwap",
2211
+ outputs: [],
2212
+ stateMutability: "payable",
2213
+ type: "function"
2214
+ },
2215
+ {
2216
+ inputs: [],
2217
+ name: "dstGasForNoSwapCall",
2218
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2219
+ stateMutability: "view",
2220
+ type: "function"
2221
+ },
2222
+ {
2223
+ inputs: [],
2224
+ name: "dstGasForSwapCall",
2225
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2226
+ stateMutability: "view",
2227
+ type: "function"
2228
+ },
2229
+ {
2230
+ inputs: [{ internalType: "address", name: "stuckToken", type: "address" }],
2231
+ name: "inCaseTokenGotStuck",
2232
+ outputs: [],
2233
+ stateMutability: "nonpayable",
2234
+ type: "function"
2235
+ },
2236
+ {
2237
+ inputs: [],
2238
+ name: "nonceCounter",
2239
+ outputs: [
2240
+ { internalType: "contract INonceCounter", name: "", type: "address" }
2241
+ ],
2242
+ stateMutability: "view",
2243
+ type: "function"
2244
+ },
2245
+ {
2246
+ inputs: [],
2247
+ name: "owner",
2248
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2249
+ stateMutability: "view",
2250
+ type: "function"
2251
+ },
2252
+ {
2253
+ inputs: [],
2254
+ name: "pause",
2255
+ outputs: [],
2256
+ stateMutability: "nonpayable",
2257
+ type: "function"
2258
+ },
2259
+ {
2260
+ inputs: [],
2261
+ name: "paused",
2262
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
2263
+ stateMutability: "view",
2264
+ type: "function"
2265
+ },
2266
+ {
2267
+ inputs: [
2268
+ { internalType: "address", name: "to", type: "address" },
2269
+ {
2270
+ components: [
2271
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2272
+ { internalType: "address", name: "bridgedToken", type: "address" },
2273
+ { internalType: "address", name: "toToken", type: "address" },
2274
+ { internalType: "uint256", name: "minToAmount", type: "uint256" },
2275
+ {
2276
+ internalType: "uint256",
2277
+ name: "airdropNativeAmount",
2278
+ type: "uint256"
2279
+ }
2280
+ ],
2281
+ internalType: "struct IWOOFiDexCrossChainRouter.DstInfos",
2282
+ name: "dstInfos",
2283
+ type: "tuple"
2284
+ },
2285
+ {
2286
+ components: [
2287
+ { internalType: "bytes32", name: "accountId", type: "bytes32" },
2288
+ { internalType: "bytes32", name: "brokerHash", type: "bytes32" },
2289
+ { internalType: "bytes32", name: "tokenHash", type: "bytes32" }
2290
+ ],
2291
+ internalType: "struct IWOOFiDexCrossChainRouter.DstVaultDeposit",
2292
+ name: "dstVaultDeposit",
2293
+ type: "tuple"
2294
+ }
2295
+ ],
2296
+ name: "quoteLayerZeroFee",
2297
+ outputs: [
2298
+ { internalType: "uint256", name: "nativeAmount", type: "uint256" },
2299
+ { internalType: "uint256", name: "zroAmount", type: "uint256" }
2300
+ ],
2301
+ stateMutability: "view",
2302
+ type: "function"
2303
+ },
2304
+ {
2305
+ inputs: [{ internalType: "address", name: "token", type: "address" }],
2306
+ name: "removeDirectBridgeToken",
2307
+ outputs: [],
2308
+ stateMutability: "nonpayable",
2309
+ type: "function"
2310
+ },
2311
+ {
2312
+ inputs: [],
2313
+ name: "renounceOwnership",
2314
+ outputs: [],
2315
+ stateMutability: "nonpayable",
2316
+ type: "function"
2317
+ },
2318
+ {
2319
+ inputs: [
2320
+ { internalType: "uint256", name: "_bridgeSlippage", type: "uint256" }
2321
+ ],
2322
+ name: "setBridgeSlippage",
2323
+ outputs: [],
2324
+ stateMutability: "nonpayable",
2325
+ type: "function"
2326
+ },
2327
+ {
2328
+ inputs: [
2329
+ {
2330
+ internalType: "uint256",
2331
+ name: "_dstGasForNoSwapCall",
2332
+ type: "uint256"
2333
+ }
2334
+ ],
2335
+ name: "setDstGasForNoSwapCall",
2336
+ outputs: [],
2337
+ stateMutability: "nonpayable",
2338
+ type: "function"
2339
+ },
2340
+ {
2341
+ inputs: [
2342
+ {
2343
+ internalType: "uint256",
2344
+ name: "_dstGasForSwapCall",
2345
+ type: "uint256"
2346
+ }
2347
+ ],
2348
+ name: "setDstGasForSwapCall",
2349
+ outputs: [],
2350
+ stateMutability: "nonpayable",
2351
+ type: "function"
2352
+ },
2353
+ {
2354
+ inputs: [
2355
+ { internalType: "uint16", name: "_sgChainIdLocal", type: "uint16" }
2356
+ ],
2357
+ name: "setSgChainIdLocal",
2358
+ outputs: [],
2359
+ stateMutability: "nonpayable",
2360
+ type: "function"
2361
+ },
2362
+ {
2363
+ inputs: [
2364
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2365
+ { internalType: "address", name: "token", type: "address" }
2366
+ ],
2367
+ name: "setSgETH",
2368
+ outputs: [],
2369
+ stateMutability: "nonpayable",
2370
+ type: "function"
2371
+ },
2372
+ {
2373
+ inputs: [
2374
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2375
+ { internalType: "address", name: "token", type: "address" },
2376
+ { internalType: "uint256", name: "poolId", type: "uint256" }
2377
+ ],
2378
+ name: "setSgPoolId",
2379
+ outputs: [],
2380
+ stateMutability: "nonpayable",
2381
+ type: "function"
2382
+ },
2383
+ {
2384
+ inputs: [
2385
+ { internalType: "address", name: "_stargateRouter", type: "address" }
2386
+ ],
2387
+ name: "setStargateRouter",
2388
+ outputs: [],
2389
+ stateMutability: "nonpayable",
2390
+ type: "function"
2391
+ },
2392
+ {
2393
+ inputs: [
2394
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2395
+ {
2396
+ internalType: "address",
2397
+ name: "woofiDexCrossChainRouter",
2398
+ type: "address"
2399
+ }
2400
+ ],
2401
+ name: "setWOOFiDexCrossChainRouter",
2402
+ outputs: [],
2403
+ stateMutability: "nonpayable",
2404
+ type: "function"
2405
+ },
2406
+ {
2407
+ inputs: [
2408
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2409
+ { internalType: "address", name: "token", type: "address" },
2410
+ { internalType: "address", name: "woofiDexVault", type: "address" }
2411
+ ],
2412
+ name: "setWOOFiDexVault",
2413
+ outputs: [],
2414
+ stateMutability: "nonpayable",
2415
+ type: "function"
2416
+ },
2417
+ {
2418
+ inputs: [{ internalType: "address", name: "_wooRouter", type: "address" }],
2419
+ name: "setWooRouter",
2420
+ outputs: [],
2421
+ stateMutability: "nonpayable",
2422
+ type: "function"
2423
+ },
2424
+ {
2425
+ inputs: [],
2426
+ name: "sgChainIdLocal",
2427
+ outputs: [{ internalType: "uint16", name: "", type: "uint16" }],
2428
+ stateMutability: "view",
2429
+ type: "function"
2430
+ },
2431
+ {
2432
+ inputs: [{ internalType: "uint16", name: "", type: "uint16" }],
2433
+ name: "sgETHs",
2434
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2435
+ stateMutability: "view",
2436
+ type: "function"
2437
+ },
2438
+ {
2439
+ inputs: [
2440
+ { internalType: "uint16", name: "", type: "uint16" },
2441
+ { internalType: "address", name: "", type: "address" }
2442
+ ],
2443
+ name: "sgPoolIds",
2444
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2445
+ stateMutability: "view",
2446
+ type: "function"
2447
+ },
2448
+ {
2449
+ inputs: [
2450
+ { internalType: "uint16", name: "srcChainId", type: "uint16" },
2451
+ { internalType: "bytes", name: "", type: "bytes" },
2452
+ { internalType: "uint256", name: "", type: "uint256" },
2453
+ { internalType: "address", name: "bridgedToken", type: "address" },
2454
+ { internalType: "uint256", name: "bridgedAmount", type: "uint256" },
2455
+ { internalType: "bytes", name: "payload", type: "bytes" }
2456
+ ],
2457
+ name: "sgReceive",
2458
+ outputs: [],
2459
+ stateMutability: "nonpayable",
2460
+ type: "function"
2461
+ },
2462
+ {
2463
+ inputs: [],
2464
+ name: "stargateRouter",
2465
+ outputs: [
2466
+ { internalType: "contract IStargateRouter", name: "", type: "address" }
2467
+ ],
2468
+ stateMutability: "view",
2469
+ type: "function"
2470
+ },
2471
+ {
2472
+ inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
2473
+ name: "transferOwnership",
2474
+ outputs: [],
2475
+ stateMutability: "nonpayable",
2476
+ type: "function"
2477
+ },
2478
+ {
2479
+ inputs: [],
2480
+ name: "unpause",
2481
+ outputs: [],
2482
+ stateMutability: "nonpayable",
2483
+ type: "function"
2484
+ },
2485
+ {
2486
+ inputs: [],
2487
+ name: "weth",
2488
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2489
+ stateMutability: "view",
2490
+ type: "function"
2491
+ },
2492
+ {
2493
+ inputs: [],
2494
+ name: "wooRouter",
2495
+ outputs: [
2496
+ { internalType: "contract IWooRouterV2", name: "", type: "address" }
2497
+ ],
2498
+ stateMutability: "view",
2499
+ type: "function"
2500
+ },
2501
+ {
2502
+ inputs: [{ internalType: "uint16", name: "", type: "uint16" }],
2503
+ name: "woofiDexCrossChainRouters",
2504
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2505
+ stateMutability: "view",
2506
+ type: "function"
2507
+ },
2508
+ {
2509
+ inputs: [
2510
+ { internalType: "uint16", name: "", type: "uint16" },
2511
+ { internalType: "address", name: "", type: "address" }
2512
+ ],
2513
+ name: "woofiDexVaults",
2514
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2515
+ stateMutability: "view",
2516
+ type: "function"
2517
+ },
2518
+ { stateMutability: "payable", type: "receive" }
2519
+ ];
2520
+ var nativeTokenAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
2521
+
2522
+ // src/orderly/useChains.ts
1924
2523
  var useChains = (networkId, options = {}) => {
1925
- const _a = options, { filter, pick, crossEnabled, wooSwapEnabled } = _a, swrOptions = __objRest(_a, ["filter", "pick", "crossEnabled", "wooSwapEnabled"]);
1926
- const { configStore } = useContext(OrderlyContext);
1927
- const field = options == null ? void 0 : options.pick;
1928
- const { data } = useSWR(
1929
- // () =>
1930
- // wooSwapEnabled
1931
- // ? `${configStore.get("swapSupportApiUrl")}/swap_support`
1932
- // : null,
1933
- `${configStore.get("swapSupportApiUrl")}/swap_support`,
2524
+ const { filter, pick: pick3, crossEnabled, wooSwapEnabled, ...swrOptions } = options;
2525
+ const { configStore, networkId: envNetworkId } = useContext(OrderlyContext);
2526
+ const field = options?.pick;
2527
+ const map = useRef(
2528
+ /* @__PURE__ */ new Map()
2529
+ );
2530
+ const { data, error: swapSupportError } = useSWR(
2531
+ () => wooSwapEnabled ? `${configStore.get("swapSupportApiUrl")}/swap_support` : null,
2532
+ // `${configStore.get("swapSupportApiUrl")}/swap_support`,
1934
2533
  (url) => fetch(url).then((res) => res.json()),
1935
- __spreadValues({
2534
+ {
2535
+ revalidateIfStale: false,
2536
+ revalidateOnFocus: false,
2537
+ revalidateOnReconnect: false,
2538
+ ...swrOptions
2539
+ }
2540
+ );
2541
+ const { data: orderlyChains, error: tokenError } = useQuery(
2542
+ "/v1/public/token",
2543
+ {
2544
+ revalidateIfStale: false,
1936
2545
  revalidateOnFocus: false,
1937
2546
  revalidateOnReconnect: false
1938
- }, swrOptions)
2547
+ }
1939
2548
  );
1940
- const { data: orderlyChains } = useQuery("/v1/public/token");
1941
2549
  const chains = useMemo(() => {
1942
- if (!data || !data.data || !orderlyChains)
1943
- return data;
1944
- let testnetArr = [];
1945
- let mainnetArr = [];
1946
- Object.keys(data.data).forEach((key) => {
1947
- const item = __spreadProps(__spreadValues({}, data.data[key]), { name: key, priority: 1 });
1948
- if (typeof (options == null ? void 0 : options.filter) === "function") {
1949
- if (!options.filter(item))
2550
+ if (!orderlyChains)
2551
+ return void 0;
2552
+ let orderlyChainsArr = [];
2553
+ const orderlyChainIds = /* @__PURE__ */ new Set();
2554
+ orderlyChains.forEach((item) => {
2555
+ item.chain_details.forEach((chain) => {
2556
+ const chainId = Number(chain.chain_id);
2557
+ orderlyChainIds.add(chainId);
2558
+ const _chain = {
2559
+ network_infos: {
2560
+ name: chain.chain_name ?? "--",
2561
+ // "public_rpc_url": "https://arb1.arbitrum.io/rpc",
2562
+ chain_id: chainId,
2563
+ bridgeless: true
2564
+ },
2565
+ token_infos: [
2566
+ {
2567
+ symbol: item.token,
2568
+ address: chain.contract_address,
2569
+ decimals: chain.decimals
2570
+ }
2571
+ ]
2572
+ };
2573
+ if (typeof options?.filter === "function") {
2574
+ if (!options.filter(_chain))
2575
+ return;
2576
+ }
2577
+ map.current.set(chainId, _chain);
2578
+ orderlyChainsArr.push(_chain);
2579
+ });
2580
+ });
2581
+ if (!wooSwapEnabled) {
2582
+ return orderlyChainsArr;
2583
+ } else {
2584
+ if (!data || !data.data)
2585
+ return data;
2586
+ let testnetArr = [];
2587
+ let mainnetArr = [];
2588
+ Object.keys(data.data).forEach((key) => {
2589
+ data.data[key];
2590
+ if (orderlyChainIds.has(data.data[key].network_infos.chain_id)) {
2591
+ orderlyChainsArr = orderlyChainsArr.map((item2) => {
2592
+ if (item2.network_infos.chain_id === data.data[key].network_infos.chain_id) {
2593
+ return mergeDeepLeft(item2, data.data[key]);
2594
+ }
2595
+ return item2;
2596
+ });
2597
+ return;
2598
+ }
2599
+ const item = {
2600
+ ...data.data[key],
2601
+ name: key
2602
+ };
2603
+ if (item.token_infos?.length === 0)
1950
2604
  return;
2605
+ map.current.set(item.network_infos.chain_id, item);
2606
+ if (typeof options?.filter === "function") {
2607
+ if (!options.filter(item))
2608
+ return;
2609
+ }
2610
+ if (item.network_infos.mainnet) {
2611
+ mainnetArr.push(item);
2612
+ } else {
2613
+ testnetArr.push(item);
2614
+ }
2615
+ });
2616
+ if (orderlyChainIds.size > 0) {
2617
+ if (envNetworkId === "testnet") {
2618
+ testnetArr = [...orderlyChainsArr, ...testnetArr];
2619
+ } else {
2620
+ mainnetArr = [...orderlyChainsArr, ...mainnetArr];
2621
+ }
1951
2622
  }
1952
- if (item.network_infos.mainnet) {
1953
- mainnetArr.push(field ? item[field] : item);
1954
- } else {
1955
- testnetArr.push(field ? item[field] : item);
2623
+ if (!!field) {
2624
+ testnetArr = testnetArr.map((item) => item[field]);
2625
+ mainnetArr = mainnetArr.map((item) => item[field]);
1956
2626
  }
1957
- });
1958
- if (networkId === "mainnet") {
1959
- return mainnetArr;
1960
- }
1961
- if (networkId === "testnet") {
1962
- return testnetArr;
2627
+ if (networkId === "mainnet") {
2628
+ return mainnetArr;
2629
+ }
2630
+ if (networkId === "testnet") {
2631
+ return testnetArr;
2632
+ }
2633
+ return {
2634
+ testnet: testnetArr,
2635
+ mainnet: mainnetArr
2636
+ };
1963
2637
  }
1964
- return {
1965
- testnet: testnetArr,
1966
- mainnet: mainnetArr
1967
- };
1968
2638
  }, [data, networkId, field, options, orderlyChains, wooSwapEnabled]);
1969
2639
  const findByChainId = useCallback(
1970
- (chainId) => {
1971
- if (!data || !data.data)
1972
- return void 0;
1973
- return data.data[chainId];
2640
+ (chainId, field2) => {
2641
+ const chain = map.current.get(chainId);
2642
+ if (chain) {
2643
+ chain.nativeToken = chain.token_infos?.find(
2644
+ (item) => item.address === nativeTokenAddress
2645
+ );
2646
+ }
2647
+ if (typeof field2 === "string") {
2648
+ return prop(field2, chain);
2649
+ }
2650
+ return chain;
1974
2651
  },
1975
- [data]
2652
+ [chains, map.current]
1976
2653
  );
1977
- return [chains, { findByChainId }];
2654
+ return [
2655
+ chains,
2656
+ {
2657
+ findByChainId,
2658
+ // findNativeTokenByChainId,
2659
+ error: swapSupportError || tokenError
2660
+ // nativeToken,
2661
+ }
2662
+ ];
1978
2663
  };
1979
2664
  var useChain = (token) => {
1980
2665
  const { data, isLoading } = useQuery("/v1/public/token");
@@ -1984,11 +2669,11 @@ var useChain = (token) => {
1984
2669
  let item = data.find((chain) => chain.token === token);
1985
2670
  if (item) {
1986
2671
  item.chain_details = item.chain_details.map((d) => {
1987
- var _a;
1988
2672
  const chain = chainsMap.get(Number(d.chain_id));
1989
- return __spreadProps(__spreadValues({}, d), {
1990
- chain_name: (_a = chain == null ? void 0 : chain.chainName) != null ? _a : "--"
1991
- });
2673
+ return {
2674
+ ...d,
2675
+ chain_name: chain?.chainName ?? "--"
2676
+ };
1992
2677
  });
1993
2678
  }
1994
2679
  return item || null;
@@ -2010,49 +2695,122 @@ var useWithdraw = () => {
2010
2695
  );
2011
2696
  const { usdc } = useHoldingStream();
2012
2697
  const maxAmount = useMemo(() => {
2013
- var _a;
2014
2698
  if (!usdc || !usdc.holding)
2015
2699
  return 0;
2016
2700
  if (unsettledPnL >= 0)
2017
- return (_a = usdc == null ? void 0 : usdc.holding) != null ? _a : 0;
2701
+ return usdc?.holding ?? 0;
2018
2702
  return new Decimal(usdc.holding).add(unsettledPnL).toNumber();
2019
2703
  }, [usdc, unsettledPnL]);
2020
2704
  return { withdraw, isLoading, maxAmount, availableBalance, unsettledPnL };
2021
2705
  };
2022
- var useDeposit = () => {
2706
+ var isNativeTokenChecker = (address) => address === nativeTokenAddress;
2707
+ var useDeposit = (options) => {
2708
+ const [balanceRevalidating, setBalanceRevalidating] = useState(false);
2709
+ const [allowanceRevalidating, setAllowanceRevalidating] = useState(false);
2023
2710
  const [balance, setBalance] = useState("0");
2024
2711
  const [allowance, setAllowance] = useState("0");
2025
2712
  const { account: account5, state } = useAccount();
2026
- const fetchBalance = useCallback(() => __async(void 0, null, function* () {
2027
- const balance2 = yield account5.assetsManager.getBalance();
2028
- setBalance(() => balance2);
2029
- }), [state]);
2030
- const fetchAllowance = useCallback(() => __async(void 0, null, function* () {
2031
- const allowance2 = yield account5.assetsManager.getAllowance();
2032
- setAllowance(() => allowance2);
2033
- return allowance2;
2034
- }), []);
2713
+ const dst = useMemo(() => {
2714
+ return {
2715
+ symbol: "USDC",
2716
+ address: "",
2717
+ decimals: 6,
2718
+ // chainId: 421613,
2719
+ network: "Arbitrum Goerli",
2720
+ chainId: 42161
2721
+ };
2722
+ }, []);
2723
+ const isNativeToken = useMemo(
2724
+ () => isNativeTokenChecker(options?.address || ""),
2725
+ [options?.address]
2726
+ );
2727
+ const fetchBalanceHandler = useCallback(
2728
+ async (address, decimals) => {
2729
+ let balance2;
2730
+ if (!!address && isNativeTokenChecker(address)) {
2731
+ balance2 = await account5.assetsManager.getNativeBalance({
2732
+ decimals
2733
+ });
2734
+ } else {
2735
+ balance2 = await account5.assetsManager.getBalance(address);
2736
+ }
2737
+ return balance2;
2738
+ },
2739
+ []
2740
+ );
2741
+ const fetchBalance = useCallback(
2742
+ async (address) => {
2743
+ if (!address)
2744
+ return;
2745
+ try {
2746
+ if (balanceRevalidating)
2747
+ return;
2748
+ setBalanceRevalidating(true);
2749
+ const balance2 = await fetchBalanceHandler(address);
2750
+ console.log("----- refresh balance -----", balance2);
2751
+ setBalance(() => balance2);
2752
+ setBalanceRevalidating(false);
2753
+ } catch (e) {
2754
+ console.warn("----- refresh balance error -----", e);
2755
+ setBalanceRevalidating(false);
2756
+ setBalance(() => "0");
2757
+ }
2758
+ },
2759
+ [state, balanceRevalidating]
2760
+ );
2761
+ const fetchBalances = useCallback(async (tokens) => {
2762
+ const tasks = [];
2763
+ console.log("fetch balances ---->>>>", tokens);
2764
+ for (const token of tokens) {
2765
+ if (isNativeTokenChecker(token.address)) {
2766
+ continue;
2767
+ }
2768
+ tasks.push(account5.assetsManager.getBalanceByAddress(token.address));
2769
+ }
2770
+ const balances = await Promise.all(tasks);
2771
+ console.log("----- get balances from tokens -----", balances);
2772
+ }, []);
2773
+ const fetchAllowance = useCallback(
2774
+ async (address) => {
2775
+ if (!address)
2776
+ return;
2777
+ if (address && isNativeTokenChecker(address))
2778
+ return;
2779
+ if (allowanceRevalidating)
2780
+ return;
2781
+ setAllowanceRevalidating(true);
2782
+ const allowance2 = await account5.assetsManager.getAllowance(address);
2783
+ console.log("----- refresh allowance -----", allowance2);
2784
+ setAllowance(() => allowance2);
2785
+ setAllowanceRevalidating(false);
2786
+ return allowance2;
2787
+ },
2788
+ [allowanceRevalidating]
2789
+ );
2035
2790
  useEffect(() => {
2791
+ console.log("useDeposit useEffect", state.status, options?.address);
2036
2792
  if (state.status < AccountStatusEnum.EnableTrading)
2037
2793
  return;
2038
- fetchBalance();
2039
- fetchAllowance();
2040
- }, [state]);
2794
+ fetchBalance(options?.address);
2795
+ fetchAllowance(options?.address);
2796
+ }, [state.status, options?.address]);
2041
2797
  const approve = useCallback(
2042
2798
  (amount) => {
2043
- return account5.assetsManager.approve(amount).then((result) => {
2799
+ if (!options?.address) {
2800
+ throw new Error("address is required");
2801
+ }
2802
+ return account5.assetsManager.approve(options.address, amount).then((result) => {
2044
2803
  if (typeof amount !== "undefined") {
2045
2804
  setAllowance((value) => new Decimal(value).add(amount).toString());
2046
2805
  }
2047
2806
  return result;
2048
2807
  });
2049
2808
  },
2050
- [account5, fetchAllowance]
2809
+ [account5, fetchAllowance, options?.address]
2051
2810
  );
2052
2811
  const deposit = useCallback(
2053
2812
  (amount) => {
2054
2813
  return account5.assetsManager.deposit(amount).then((res) => {
2055
- console.log("----- deposit -----", res);
2056
2814
  setAllowance((value) => new Decimal(value).sub(amount).toString());
2057
2815
  setBalance((value) => new Decimal(value).sub(amount).toString());
2058
2816
  return res;
@@ -2061,10 +2819,16 @@ var useDeposit = () => {
2061
2819
  [account5, fetchBalance, fetchAllowance]
2062
2820
  );
2063
2821
  return {
2822
+ dst,
2064
2823
  balance,
2065
2824
  allowance,
2825
+ isNativeToken,
2826
+ balanceRevalidating,
2827
+ allowanceRevalidating,
2066
2828
  approve,
2067
- deposit
2829
+ deposit,
2830
+ fetchBalances,
2831
+ fetchBalance: fetchBalanceHandler
2068
2832
  };
2069
2833
  };
2070
2834
  var useWalletSubscription = (options) => {
@@ -2079,8 +2843,7 @@ var useWalletSubscription = (options) => {
2079
2843
  },
2080
2844
  {
2081
2845
  onMessage: (data) => {
2082
- var _a;
2083
- (_a = options == null ? void 0 : options.onMessage) == null ? void 0 : _a.call(options, data);
2846
+ options?.onMessage?.(data);
2084
2847
  next(data);
2085
2848
  }
2086
2849
  }
@@ -2116,12 +2879,13 @@ var usePrivateDataObserver = () => {
2116
2879
  }
2117
2880
  if (data.status === OrderStatus$1.NEW) {
2118
2881
  return [
2119
- __spreadProps(__spreadValues({}, data), {
2882
+ {
2883
+ ...data,
2120
2884
  // average_executed_price:data.ava
2121
2885
  created_time: data.timestamp,
2122
2886
  order_id: data.orderId
2123
2887
  // reduce_only
2124
- }),
2888
+ },
2125
2889
  ...orders
2126
2890
  ];
2127
2891
  }
@@ -2138,7 +2902,7 @@ var usePrivateDataObserver = () => {
2138
2902
  ee.emit("orders:changed");
2139
2903
  }
2140
2904
  });
2141
- return () => unsubscribe == null ? void 0 : unsubscribe();
2905
+ return () => unsubscribe?.();
2142
2906
  }, [state.accountId]);
2143
2907
  useEffect(() => {
2144
2908
  console.log("subscribe: position: %s", state.accountId);
@@ -2150,7 +2914,8 @@ var usePrivateDataObserver = () => {
2150
2914
  const { positions: nextPostions } = data;
2151
2915
  mutate2(key, (prevPositions) => {
2152
2916
  if (!!prevPositions) {
2153
- return __spreadProps(__spreadValues({}, prevPositions), {
2917
+ return {
2918
+ ...prevPositions,
2154
2919
  rows: prevPositions.rows.map((row) => {
2155
2920
  const item = nextPostions.find(
2156
2921
  (item2) => item2.symbol === row.symbol
@@ -2179,14 +2944,14 @@ var usePrivateDataObserver = () => {
2179
2944
  }
2180
2945
  return row;
2181
2946
  })
2182
- });
2947
+ };
2183
2948
  }
2184
2949
  });
2185
2950
  }
2186
2951
  });
2187
2952
  return () => {
2188
2953
  console.log("unsubscribe: private subscription position");
2189
- unsubscribe == null ? void 0 : unsubscribe();
2954
+ unsubscribe?.();
2190
2955
  };
2191
2956
  }, [state.accountId]);
2192
2957
  };
@@ -2230,7 +2995,524 @@ var useFundingRateBySymbol = (symbol) => {
2230
2995
  }
2231
2996
  return useQuery(`/public/funding_rate/${symbol}`);
2232
2997
  };
2998
+ var useWooSwapQuery = () => {
2999
+ const { configStore } = useContext(OrderlyContext);
3000
+ const account5 = useAccountInstance();
3001
+ const [loading, { setTrue: start, setFalse: stop }] = useBoolean(false);
3002
+ const query = useCallback(
3003
+ (inputs) => {
3004
+ console.log("inputs", inputs);
3005
+ if (loading)
3006
+ return;
3007
+ start();
3008
+ const params = {
3009
+ // src_network: inputs.srcNetwork,
3010
+ network: "arbitrum",
3011
+ from_token: inputs.srcToken,
3012
+ to_token: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
3013
+ //account.assetsManager.usdcAddress,
3014
+ from_amount: inputs.amount,
3015
+ //inputs.amount,
3016
+ slippage: inputs.slippage || 1
3017
+ // to_token:account.assetsManager.usdcAddress,
3018
+ };
3019
+ const queryString = Object.entries(params).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
3020
+ return fetch(
3021
+ `${configStore.get("swapSupportApiUrl")}/woofi_dex/swap?${queryString}`
3022
+ ).then((res) => {
3023
+ if (!res.ok) {
3024
+ return res.json().then((data) => {
3025
+ throw new Error(data.error.message);
3026
+ });
3027
+ }
3028
+ return res.json();
3029
+ }).then((data) => {
3030
+ if (data.status === "ok") {
3031
+ return data.data;
3032
+ }
3033
+ throw new Error(data.message);
3034
+ }).finally(() => stop());
3035
+ },
3036
+ [account5]
3037
+ );
3038
+ return {
3039
+ query,
3040
+ loading: false
3041
+ };
3042
+ };
3043
+ var useWooCrossSwapQuery = () => {
3044
+ const { configStore } = useContext(OrderlyContext);
3045
+ const [loading, { setTrue: start, setFalse: stop }] = useBoolean(false);
3046
+ const account5 = useAccountInstance();
3047
+ const dstValutDeposit = useCallback(() => {
3048
+ return {
3049
+ accountId: account5.accountIdHashStr,
3050
+ brokerHash: utils.parseBrokerHash(configStore.get("brokerId")),
3051
+ tokenHash: utils.parseTokenHash("USDC")
3052
+ };
3053
+ }, [account5]);
3054
+ const queryDestinationFee = useCallback(
3055
+ async (dst) => {
3056
+ if (!account5.walletClient) {
3057
+ throw new Error("walletClient is not ready");
3058
+ }
3059
+ const quotoLZFee = await account5.walletClient.call(
3060
+ "0xC7498b7e7C9845b4B2556f2a4B7Cad2B7F2C0dC4",
3061
+ "quoteLayerZeroFee",
3062
+ [account5.address, dst, dstValutDeposit()],
3063
+ {
3064
+ abi: woofiDexCrossChainRouterAbi
3065
+ }
3066
+ );
3067
+ return utils.formatByUnits(quotoLZFee[0]);
3068
+ },
3069
+ []
3070
+ );
3071
+ const query = useCallback(
3072
+ (inputs) => {
3073
+ if (loading)
3074
+ return;
3075
+ start();
3076
+ const params = {
3077
+ // src_network: inputs.srcNetwork,
3078
+ src_network: "base",
3079
+ dst_network: "arbitrum",
3080
+ src_token: inputs.srcToken,
3081
+ dst_token: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
3082
+ //account.assetsManager.usdcAddress,
3083
+ src_amount: inputs.amount,
3084
+ //inputs.amount,
3085
+ slippage: inputs.slippage || 1
3086
+ // to_token:account.assetsManager.usdcAddress,
3087
+ };
3088
+ const queryString = Object.entries(params).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
3089
+ return fetch(
3090
+ `${configStore.get(
3091
+ "swapSupportApiUrl"
3092
+ )}/woofi_dex/cross_chain_swap?${queryString}`
3093
+ ).then((res) => {
3094
+ if (!res.ok) {
3095
+ return res.json().then((data) => {
3096
+ throw new Error(data.error.message);
3097
+ });
3098
+ }
3099
+ return res.json();
3100
+ }).then((data) => {
3101
+ if (data.status === "ok") {
3102
+ return data.data;
3103
+ }
3104
+ throw new Error(data.message);
3105
+ }).then((swapInfo) => {
3106
+ return queryDestinationFee({
3107
+ chainId: swapInfo.dst_infos.chain_id,
3108
+ bridgedToken: swapInfo.dst_infos.bridged_token,
3109
+ toToken: swapInfo.dst_infos.to_token,
3110
+ minToAmount: BigInt(swapInfo.dst_infos.min_to_amount),
3111
+ airdropNativeAmount: 0n
3112
+ }).then((data) => {
3113
+ console.log("res::::", data);
3114
+ return {
3115
+ ...swapInfo,
3116
+ dst_infos: {
3117
+ ...swapInfo.dst_infos,
3118
+ gas_fee: data
3119
+ }
3120
+ };
3121
+ });
3122
+ }).finally(() => stop());
3123
+ },
3124
+ [loading, account5]
3125
+ );
3126
+ return {
3127
+ query,
3128
+ loading
3129
+ };
3130
+ };
3131
+ var useCrossSwap = () => {
3132
+ const [loading, { setTrue: start, setFalse: stop }] = useBoolean(false);
3133
+ const [layerStatus, setLayerStatus] = useState(
3134
+ "WAITTING" /* INITIALIZING */
3135
+ );
3136
+ const [bridgeMessage, setBridgeMessage] = useState();
3137
+ const account5 = useAccountInstance();
3138
+ const { networkId, configStore } = useContext(OrderlyContext);
3139
+ const client = useRef(createClient(networkId)).current;
3140
+ const timer = useRef();
3141
+ const checkLayerStatus = useCallback((txHash) => {
3142
+ const check = async (txHash2) => {
3143
+ const { messages } = await client.getMessagesBySrcTxHash(txHash2);
3144
+ console.log("messages:", messages);
3145
+ if (messages.length > 0) {
3146
+ const { status } = messages[0];
3147
+ if (status === "INFLIGHT" /* INFLIGHT */) {
3148
+ setTimeout(() => {
3149
+ check(txHash2);
3150
+ }, 1e3);
3151
+ }
3152
+ setLayerStatus(status);
3153
+ if (status === "DELIVERED" /* DELIVERED */) {
3154
+ setBridgeMessage(messages[0]);
3155
+ }
3156
+ } else {
3157
+ setTimeout(() => {
3158
+ check(txHash2);
3159
+ }, 1e3);
3160
+ }
3161
+ };
3162
+ check(txHash);
3163
+ }, []);
3164
+ useEffect(() => {
3165
+ return () => {
3166
+ if (timer.current) {
3167
+ clearTimeout(timer.current);
3168
+ }
3169
+ };
3170
+ }, []);
3171
+ const dstValutDeposit = useCallback(() => {
3172
+ return {
3173
+ accountId: account5.accountIdHashStr,
3174
+ brokerHash: utils.parseBrokerHash(configStore.get("brokerId")),
3175
+ tokenHash: utils.parseTokenHash("USDC")
3176
+ };
3177
+ }, [account5]);
3178
+ const swap = async (inputs) => {
3179
+ if (!account5.walletClient) {
3180
+ throw new Error("walletClient is undefined");
3181
+ }
3182
+ const { address, src, dst } = inputs;
3183
+ if (loading)
3184
+ return;
3185
+ start();
3186
+ const quotoLZFee = await account5.walletClient.call(
3187
+ "0xC7498b7e7C9845b4B2556f2a4B7Cad2B7F2C0dC4",
3188
+ "quoteLayerZeroFee",
3189
+ [account5.address, dst, dstValutDeposit()],
3190
+ {
3191
+ abi: woofiDexCrossChainRouterAbi
3192
+ }
3193
+ );
3194
+ const result = await account5.walletClient.call(
3195
+ "0xC7498b7e7C9845b4B2556f2a4B7Cad2B7F2C0dC4",
3196
+ "crossSwap",
3197
+ [
3198
+ account5.address,
3199
+ src,
3200
+ dst,
3201
+ dstValutDeposit(),
3202
+ {
3203
+ value: quotoLZFee[0]
3204
+ }
3205
+ ],
3206
+ {
3207
+ abi: woofiDexCrossChainRouterAbi
3208
+ }
3209
+ );
3210
+ account5.walletClient.on(
3211
+ {
3212
+ address: "0xC7498b7e7C9845b4B2556f2a4B7Cad2B7F2C0dC4"
3213
+ },
3214
+ (log, event) => {
3215
+ console.log("-------------", log, event);
3216
+ }
3217
+ );
3218
+ stop();
3219
+ checkLayerStatus(result.hash);
3220
+ return pick(["from", "to", "hash", "value"], result);
3221
+ };
3222
+ return {
3223
+ swap,
3224
+ loading,
3225
+ status: layerStatus,
3226
+ message: bridgeMessage
3227
+ };
3228
+ };
3229
+ var woofiDexDepositor = "0xfD7ed9D3d4fD88595AF6a87f798ffDB42b4D7ccB";
3230
+ var woofiDexDepositorAbi = [
3231
+ {
3232
+ inputs: [
3233
+ { internalType: "address", name: "_weth", type: "address" },
3234
+ { internalType: "address", name: "_wooRouter", type: "address" }
3235
+ ],
3236
+ stateMutability: "nonpayable",
3237
+ type: "constructor"
3238
+ },
3239
+ {
3240
+ anonymous: false,
3241
+ inputs: [
3242
+ {
3243
+ indexed: true,
3244
+ internalType: "address",
3245
+ name: "previousOwner",
3246
+ type: "address"
3247
+ },
3248
+ {
3249
+ indexed: true,
3250
+ internalType: "address",
3251
+ name: "newOwner",
3252
+ type: "address"
3253
+ }
3254
+ ],
3255
+ name: "OwnershipTransferred",
3256
+ type: "event"
3257
+ },
3258
+ {
3259
+ anonymous: false,
3260
+ inputs: [
3261
+ {
3262
+ indexed: false,
3263
+ internalType: "address",
3264
+ name: "account",
3265
+ type: "address"
3266
+ }
3267
+ ],
3268
+ name: "Paused",
3269
+ type: "event"
3270
+ },
3271
+ {
3272
+ anonymous: false,
3273
+ inputs: [
3274
+ {
3275
+ indexed: false,
3276
+ internalType: "address",
3277
+ name: "account",
3278
+ type: "address"
3279
+ }
3280
+ ],
3281
+ name: "Unpaused",
3282
+ type: "event"
3283
+ },
3284
+ {
3285
+ anonymous: false,
3286
+ inputs: [
3287
+ {
3288
+ indexed: true,
3289
+ internalType: "address",
3290
+ name: "sender",
3291
+ type: "address"
3292
+ },
3293
+ { indexed: true, internalType: "address", name: "to", type: "address" },
3294
+ {
3295
+ indexed: false,
3296
+ internalType: "address",
3297
+ name: "fromToken",
3298
+ type: "address"
3299
+ },
3300
+ {
3301
+ indexed: false,
3302
+ internalType: "uint256",
3303
+ name: "fromAmount",
3304
+ type: "uint256"
3305
+ },
3306
+ {
3307
+ indexed: false,
3308
+ internalType: "address",
3309
+ name: "toToken",
3310
+ type: "address"
3311
+ },
3312
+ {
3313
+ indexed: false,
3314
+ internalType: "uint256",
3315
+ name: "minToAmount",
3316
+ type: "uint256"
3317
+ },
3318
+ {
3319
+ indexed: false,
3320
+ internalType: "uint256",
3321
+ name: "toAmount",
3322
+ type: "uint256"
3323
+ },
3324
+ {
3325
+ indexed: false,
3326
+ internalType: "bytes32",
3327
+ name: "accountId",
3328
+ type: "bytes32"
3329
+ },
3330
+ {
3331
+ indexed: false,
3332
+ internalType: "bytes32",
3333
+ name: "brokerHash",
3334
+ type: "bytes32"
3335
+ },
3336
+ {
3337
+ indexed: false,
3338
+ internalType: "bytes32",
3339
+ name: "tokenHash",
3340
+ type: "bytes32"
3341
+ },
3342
+ {
3343
+ indexed: false,
3344
+ internalType: "uint128",
3345
+ name: "tokenAmount",
3346
+ type: "uint128"
3347
+ }
3348
+ ],
3349
+ name: "WOOFiDexSwap",
3350
+ type: "event"
3351
+ },
3352
+ {
3353
+ inputs: [],
3354
+ name: "NATIVE_PLACEHOLDER",
3355
+ outputs: [{ internalType: "address", name: "", type: "address" }],
3356
+ stateMutability: "view",
3357
+ type: "function"
3358
+ },
3359
+ {
3360
+ inputs: [{ internalType: "address", name: "stuckToken", type: "address" }],
3361
+ name: "inCaseTokenGotStuck",
3362
+ outputs: [],
3363
+ stateMutability: "nonpayable",
3364
+ type: "function"
3365
+ },
3366
+ {
3367
+ inputs: [],
3368
+ name: "owner",
3369
+ outputs: [{ internalType: "address", name: "", type: "address" }],
3370
+ stateMutability: "view",
3371
+ type: "function"
3372
+ },
3373
+ {
3374
+ inputs: [],
3375
+ name: "pause",
3376
+ outputs: [],
3377
+ stateMutability: "nonpayable",
3378
+ type: "function"
3379
+ },
3380
+ {
3381
+ inputs: [],
3382
+ name: "paused",
3383
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
3384
+ stateMutability: "view",
3385
+ type: "function"
3386
+ },
3387
+ {
3388
+ inputs: [],
3389
+ name: "renounceOwnership",
3390
+ outputs: [],
3391
+ stateMutability: "nonpayable",
3392
+ type: "function"
3393
+ },
3394
+ {
3395
+ inputs: [
3396
+ { internalType: "address", name: "token", type: "address" },
3397
+ { internalType: "address", name: "woofiDexVault", type: "address" }
3398
+ ],
3399
+ name: "setWOOFiDexVault",
3400
+ outputs: [],
3401
+ stateMutability: "nonpayable",
3402
+ type: "function"
3403
+ },
3404
+ {
3405
+ inputs: [{ internalType: "address", name: "_wooRouter", type: "address" }],
3406
+ name: "setWooRouter",
3407
+ outputs: [],
3408
+ stateMutability: "nonpayable",
3409
+ type: "function"
3410
+ },
3411
+ {
3412
+ inputs: [
3413
+ { internalType: "address payable", name: "to", type: "address" },
3414
+ {
3415
+ components: [
3416
+ { internalType: "address", name: "fromToken", type: "address" },
3417
+ { internalType: "uint256", name: "fromAmount", type: "uint256" },
3418
+ { internalType: "address", name: "toToken", type: "address" },
3419
+ { internalType: "uint256", name: "minToAmount", type: "uint256" }
3420
+ ],
3421
+ internalType: "struct IWOOFiDexRouter.Infos",
3422
+ name: "infos",
3423
+ type: "tuple"
3424
+ },
3425
+ {
3426
+ components: [
3427
+ { internalType: "bytes32", name: "accountId", type: "bytes32" },
3428
+ { internalType: "bytes32", name: "brokerHash", type: "bytes32" },
3429
+ { internalType: "bytes32", name: "tokenHash", type: "bytes32" }
3430
+ ],
3431
+ internalType: "struct IWOOFiDexRouter.VaultDeposit",
3432
+ name: "vaultDeposit",
3433
+ type: "tuple"
3434
+ }
3435
+ ],
3436
+ name: "swap",
3437
+ outputs: [],
3438
+ stateMutability: "payable",
3439
+ type: "function"
3440
+ },
3441
+ {
3442
+ inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
3443
+ name: "transferOwnership",
3444
+ outputs: [],
3445
+ stateMutability: "nonpayable",
3446
+ type: "function"
3447
+ },
3448
+ {
3449
+ inputs: [],
3450
+ name: "unpause",
3451
+ outputs: [],
3452
+ stateMutability: "nonpayable",
3453
+ type: "function"
3454
+ },
3455
+ {
3456
+ inputs: [],
3457
+ name: "weth",
3458
+ outputs: [{ internalType: "address", name: "", type: "address" }],
3459
+ stateMutability: "view",
3460
+ type: "function"
3461
+ },
3462
+ {
3463
+ inputs: [],
3464
+ name: "wooRouter",
3465
+ outputs: [
3466
+ { internalType: "contract IWooRouterV2", name: "", type: "address" }
3467
+ ],
3468
+ stateMutability: "view",
3469
+ type: "function"
3470
+ },
3471
+ {
3472
+ inputs: [{ internalType: "address", name: "", type: "address" }],
3473
+ name: "woofiDexVaults",
3474
+ outputs: [{ internalType: "address", name: "", type: "address" }],
3475
+ stateMutability: "view",
3476
+ type: "function"
3477
+ },
3478
+ { stateMutability: "payable", type: "receive" }
3479
+ ];
3480
+ var useSwap = () => {
3481
+ const [loading, { setTrue: start, setFalse: stop }] = useBoolean(false);
3482
+ const account5 = useAccountInstance();
3483
+ const { configStore } = useContext(OrderlyContext);
3484
+ const dstValutDeposit = useCallback(() => {
3485
+ return {
3486
+ accountId: account5.accountIdHashStr,
3487
+ brokerHash: utils.parseBrokerHash(configStore.get("brokerId")),
3488
+ tokenHash: utils.parseTokenHash("USDC")
3489
+ };
3490
+ }, [account5]);
3491
+ const swap = useCallback(
3492
+ async (inputs) => {
3493
+ if (loading)
3494
+ return;
3495
+ start();
3496
+ const result = await account5.walletClient.call(
3497
+ woofiDexDepositor,
3498
+ "swap",
3499
+ [account5.address, inputs, dstValutDeposit()],
3500
+ {
3501
+ abi: woofiDexDepositorAbi
3502
+ }
3503
+ );
3504
+ console.log("swap result::::::", result);
3505
+ stop();
3506
+ return pick(["from", "to", "hash", "value"], result);
3507
+ },
3508
+ [loading, account5]
3509
+ );
3510
+ return {
3511
+ swap,
3512
+ loading
3513
+ };
3514
+ };
2233
3515
 
2234
- export { DataSourceProvider, OrderStatus, OrderlyContext, OrderlyProvider, apis_exports as apis, useAccount, useAccountInfo, useAccountInstance, useAppState, useBalance, useChain, useChains, useCollateral, useConfig, useDeposit, useEventEmitter, useExecutionReport, useFetures, useFundingRate, useHoldingStream, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateObserve, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw };
3516
+ export { DataSourceProvider, OrderStatus, OrderlyContext, OrderlyProvider, apis_exports as apis, useAccount, useAccountInfo, useAccountInstance, useAppState, useBalance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useExecutionReport, useFetures, useFundingRate, useHoldingStream, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateObserve, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSwap, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
2235
3517
  //# sourceMappingURL=out.js.map
2236
3518
  //# sourceMappingURL=index.mjs.map