@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.js CHANGED
@@ -12,6 +12,8 @@ var utils = require('@orderly.network/utils');
12
12
  var ramda = require('ramda');
13
13
  var futures = require('@orderly.network/futures');
14
14
  var useSWRInfinite = require('swr/infinite');
15
+ var useDebounce = require('use-debounce');
16
+ var scanClient = require('@layerzerolabs/scan-client');
15
17
 
16
18
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
17
19
 
@@ -23,70 +25,20 @@ var useSWRSubscription__default = /*#__PURE__*/_interopDefault(useSWRSubscriptio
23
25
  var useSWRInfinite__default = /*#__PURE__*/_interopDefault(useSWRInfinite);
24
26
 
25
27
  var __defProp = Object.defineProperty;
26
- var __defProps = Object.defineProperties;
27
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
28
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
29
- var __hasOwnProp = Object.prototype.hasOwnProperty;
30
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
31
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
32
- var __spreadValues = (a, b) => {
33
- for (var prop2 in b || (b = {}))
34
- if (__hasOwnProp.call(b, prop2))
35
- __defNormalProp(a, prop2, b[prop2]);
36
- if (__getOwnPropSymbols)
37
- for (var prop2 of __getOwnPropSymbols(b)) {
38
- if (__propIsEnum.call(b, prop2))
39
- __defNormalProp(a, prop2, b[prop2]);
40
- }
41
- return a;
42
- };
43
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
44
- var __objRest = (source, exclude) => {
45
- var target = {};
46
- for (var prop2 in source)
47
- if (__hasOwnProp.call(source, prop2) && exclude.indexOf(prop2) < 0)
48
- target[prop2] = source[prop2];
49
- if (source != null && __getOwnPropSymbols)
50
- for (var prop2 of __getOwnPropSymbols(source)) {
51
- if (exclude.indexOf(prop2) < 0 && __propIsEnum.call(source, prop2))
52
- target[prop2] = source[prop2];
53
- }
54
- return target;
55
- };
56
28
  var __export = (target, all) => {
57
29
  for (var name in all)
58
30
  __defProp(target, name, { get: all[name], enumerable: true });
59
31
  };
60
- var __async = (__this, __arguments, generator) => {
61
- return new Promise((resolve, reject) => {
62
- var fulfilled = (value) => {
63
- try {
64
- step(generator.next(value));
65
- } catch (e) {
66
- reject(e);
67
- }
68
- };
69
- var rejected = (value) => {
70
- try {
71
- step(generator.throw(value));
72
- } catch (e) {
73
- reject(e);
74
- }
75
- };
76
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
77
- step((generator = generator.apply(__this, __arguments)).next());
78
- });
79
- };
80
32
  var OrderlyContext = React2.createContext({
81
33
  // configStore: new MemoryConfigStore(),
82
34
  });
83
35
  var OrderlyProvider = OrderlyContext.Provider;
84
- var fetcher = (url, init = {}, queryOptions) => net.get(url, init, queryOptions == null ? void 0 : queryOptions.formatter);
36
+ var fetcher = (url, init = {}, queryOptions) => net.get(url, init, queryOptions?.formatter);
85
37
 
86
38
  // src/useQuery.ts
87
39
  var useQuery = (query, options) => {
88
40
  const { apiBaseUrl } = React2.useContext(OrderlyContext);
89
- const _a = options || {}, { formatter } = _a, swrOptions = __objRest(_a, ["formatter"]);
41
+ const { formatter, ...swrOptions } = options || {};
90
42
  if (typeof apiBaseUrl === "undefined") {
91
43
  throw new Error("please add OrderlyProvider to your app");
92
44
  }
@@ -99,6 +51,30 @@ var useQuery = (query, options) => {
99
51
  swrOptions
100
52
  );
101
53
  };
54
+ var useLazyQuery = (query, options) => {
55
+ const { apiBaseUrl } = React2.useContext(OrderlyContext);
56
+ const { formatter, init, ...swrOptions } = options || {};
57
+ if (typeof apiBaseUrl === "undefined") {
58
+ throw new Error("please add OrderlyProvider to your app");
59
+ }
60
+ return useSWRMutation__default.default(
61
+ query,
62
+ (url, options2) => {
63
+ console.log(url, options2);
64
+ url = url.startsWith("http") ? url : `${apiBaseUrl}${url}`;
65
+ if (options2?.arg) {
66
+ const queryString = Object.entries(options2.arg).map(
67
+ ([key, value]) => `${key}=${encodeURIComponent(value)}`
68
+ ).join("&");
69
+ url = `${url}?${queryString}`;
70
+ }
71
+ return fetcher(url, init, {
72
+ formatter
73
+ });
74
+ },
75
+ swrOptions
76
+ );
77
+ };
102
78
  var useAccountInstance = () => {
103
79
  const { configStore, keyStore, contractManager, getWalletAdapter } = React2.useContext(OrderlyContext);
104
80
  if (!configStore)
@@ -129,7 +105,9 @@ var useAccountInstance = () => {
129
105
  var fetcher2 = (url, options) => {
130
106
  const init = {
131
107
  method: options.arg.method,
132
- headers: __spreadValues({}, options.arg.signature)
108
+ headers: {
109
+ ...options.arg.signature
110
+ }
133
111
  };
134
112
  if (options.arg.data) {
135
113
  init.body = JSON.stringify(options.arg.data);
@@ -154,7 +132,7 @@ var useMutation = (url, method = "POST", options) => {
154
132
  fetcher2,
155
133
  options
156
134
  );
157
- const mutation = (data2, params) => __async(void 0, null, function* () {
135
+ const mutation = async (data2, params) => {
158
136
  let newUrl = url;
159
137
  if (typeof params === "object" && Object.keys(params).length) {
160
138
  let search = new URLSearchParams(params);
@@ -165,16 +143,17 @@ var useMutation = (url, method = "POST", options) => {
165
143
  url: newUrl,
166
144
  data: data2
167
145
  };
168
- const signature = yield signer.sign(payload);
146
+ const signature = await signer.sign(payload);
169
147
  return trigger({
170
148
  data: data2,
171
149
  params,
172
150
  method,
173
- signature: __spreadProps(__spreadValues({}, signature), {
151
+ signature: {
152
+ ...signature,
174
153
  "orderly-account-id": account5.accountId
175
- })
154
+ }
176
155
  });
177
- });
156
+ };
178
157
  return [
179
158
  mutation,
180
159
  {
@@ -189,7 +168,7 @@ var signatureMiddleware = (useSWRNext) => {
189
168
  const { apiBaseUrl } = React2.useContext(OrderlyContext);
190
169
  return (key, fetcher4, config) => {
191
170
  try {
192
- const extendedFetcher = (args) => __async(void 0, null, function* () {
171
+ const extendedFetcher = async (args) => {
193
172
  let url = Array.isArray(args) ? args[0] : args;
194
173
  let account5 = core.SimpleDI.get("account");
195
174
  let fullUrl = `${apiBaseUrl}${url}`;
@@ -198,13 +177,14 @@ var signatureMiddleware = (useSWRNext) => {
198
177
  method: "GET",
199
178
  url
200
179
  };
201
- const signature = yield signer.sign(payload);
180
+ const signature = await signer.sign(payload);
202
181
  return fetcher4(fullUrl, {
203
- headers: __spreadProps(__spreadValues({}, signature), {
182
+ headers: {
183
+ ...signature,
204
184
  "orderly-account-id": account5.accountId
205
- })
185
+ }
206
186
  });
207
- });
187
+ };
208
188
  return useSWRNext(key, extendedFetcher, config);
209
189
  } catch (e) {
210
190
  console.error("signature error:", e);
@@ -245,23 +225,23 @@ var useAccount = () => {
245
225
  [account5]
246
226
  );
247
227
  const createOrderlyKey = React2.useCallback(
248
- (remember) => __async(void 0, null, function* () {
228
+ async (remember) => {
249
229
  return account5.createOrderlyKey(remember ? 365 : 30);
250
- }),
230
+ },
251
231
  [account5]
252
232
  );
253
- const createAccount = React2.useCallback(() => __async(void 0, null, function* () {
233
+ const createAccount = React2.useCallback(async () => {
254
234
  return account5.createAccount();
255
- }), [account5]);
256
- const connect = React2.useCallback(() => __async(void 0, null, function* () {
257
- return onWalletConnect == null ? void 0 : onWalletConnect();
258
- }), [account5]);
259
- const disconnect = () => __async(void 0, null, function* () {
260
- return onWalletDisconnect == null ? void 0 : onWalletDisconnect();
261
- });
262
- const setChain = (chainId) => __async(void 0, null, function* () {
263
- return onSetChain == null ? void 0 : onSetChain(chainId);
264
- });
235
+ }, [account5]);
236
+ const connect = React2.useCallback(async () => {
237
+ return onWalletConnect?.();
238
+ }, [account5]);
239
+ const disconnect = async () => {
240
+ return onWalletDisconnect?.();
241
+ };
242
+ const setChain = async (chainId) => {
243
+ return onSetChain?.(chainId);
244
+ };
265
245
  return {
266
246
  // account: state!,
267
247
  account: account5,
@@ -277,24 +257,31 @@ var useAccount = () => {
277
257
  };
278
258
  };
279
259
  var usePrivateQuery = (query, options) => {
280
- var _b;
281
- const _a = options || {}, { formatter } = _a, swrOptions = __objRest(_a, ["formatter"]);
260
+ const { formatter, ...swrOptions } = options || {};
282
261
  const account5 = useAccount();
283
- const middleware = Array.isArray(options == null ? void 0 : options.use) ? (_b = options == null ? void 0 : options.use) != null ? _b : [] : [];
262
+ const middleware = Array.isArray(options?.use) ? options?.use ?? [] : [];
284
263
  return useSWR__default.default(
285
264
  () => account5.state.status >= types.AccountStatusEnum.EnableTrading ? [query, account5.state.accountId] : null,
286
265
  // query,
287
266
  (url, init) => {
288
267
  return fetcher(url, init, { formatter });
289
268
  },
290
- __spreadProps(__spreadValues({}, swrOptions), {
269
+ {
270
+ ...swrOptions,
291
271
  use: [signatureMiddleware, ...middleware],
292
272
  onError: (err) => {
293
273
  console.log("usePrivateQuery error", err);
294
274
  }
295
- })
275
+ }
296
276
  );
297
277
  };
278
+ var useBoolean = (initialValue = false) => {
279
+ const [value, setValue] = React2.useState(initialValue);
280
+ const setTrue = React2.useCallback(() => setValue(true), []);
281
+ const setFalse = React2.useCallback(() => setValue(false), []);
282
+ const toggle = React2.useCallback(() => setValue((v) => !v), []);
283
+ return [value, { setTrue, setFalse, toggle }];
284
+ };
298
285
 
299
286
  // src/useTradingView.ts
300
287
  var useTradingView = () => {
@@ -321,25 +308,31 @@ var useTopicObserve = (topic) => {
321
308
  };
322
309
  };
323
310
  var useAppState = () => {
324
- const { errors, ready } = React2.useContext(OrderlyContext);
311
+ const { errors } = React2.useContext(OrderlyContext);
325
312
  return {
326
- errors,
327
- ready
313
+ errors
314
+ // ready,
328
315
  };
329
316
  };
330
- var usePreLoadData = (onSuccess) => {
317
+ var usePreLoadData = () => {
331
318
  const { configStore } = React2.useContext(OrderlyContext);
332
- useSWR__default.default(
319
+ const { error: swapSupportError, data: swapSupportData } = useSWR__default.default(
333
320
  `${configStore.get("swapSupportApiUrl")}/swap_support`,
334
321
  (url) => fetch(url).then((res) => res.json()),
335
322
  {
336
- revalidateOnFocus: false,
337
- // suspense: true,
338
- onSuccess: (data, key, config) => {
339
- onSuccess("chains_fetch");
340
- }
323
+ revalidateOnFocus: false
341
324
  }
342
325
  );
326
+ const { error: tokenError, data: tokenData } = useQuery("/v1/public/token", {
327
+ revalidateOnFocus: false
328
+ });
329
+ const isDone = React2.useMemo(() => {
330
+ return !!swapSupportData && !!tokenData;
331
+ }, [swapSupportData, tokenData]);
332
+ return {
333
+ error: swapSupportError || tokenError,
334
+ done: isDone
335
+ };
343
336
  };
344
337
  var useEventEmitter = (channel) => {
345
338
  return useConstant__default.default(() => {
@@ -355,8 +348,8 @@ var useEventEmitter = (channel) => {
355
348
  // src/utils/json.ts
356
349
  function parseJSON(value) {
357
350
  try {
358
- return value === "undefined" ? void 0 : JSON.parse(value != null ? value : "");
359
- } catch (e) {
351
+ return value === "undefined" ? void 0 : JSON.parse(value ?? "");
352
+ } catch {
360
353
  console.log("parsing error on", { value });
361
354
  return void 0;
362
355
  }
@@ -405,7 +398,7 @@ function useSessionStorage(key, initialValue) {
405
398
  });
406
399
  const handleStorageChange = React2.useCallback(
407
400
  (event) => {
408
- if ((event == null ? void 0 : event.key) && event.key !== key) {
401
+ if (event?.key && event.key !== key) {
409
402
  return;
410
403
  }
411
404
  setStoredValue(readValue());
@@ -485,12 +478,12 @@ var useWS = () => {
485
478
  networkId: "testnet",
486
479
  publicUrl: configStore.get("publicWsUrl"),
487
480
  privateUrl: configStore.get("privateWsUrl"),
488
- onSigntureRequest: (accountId) => __async(void 0, null, function* () {
481
+ onSigntureRequest: async (accountId) => {
489
482
  const signer = account5.signer;
490
483
  const timestamp = (/* @__PURE__ */ new Date()).getTime();
491
- const result = yield signer.signText(timestamp.toString());
492
- return __spreadProps(__spreadValues({}, result), { timestamp });
493
- })
484
+ const result = await signer.signText(timestamp.toString());
485
+ return { ...result, timestamp };
486
+ }
494
487
  });
495
488
  account5.on("change:status", (nextState) => {
496
489
  if (nextState.status === types.AccountStatusEnum.EnableTrading && nextState.accountId) {
@@ -538,7 +531,7 @@ var useTickerStream = (symbol) => {
538
531
  );
539
532
  return () => {
540
533
  console.log("unsubscribe!!!!!!!");
541
- unsubscribe == null ? void 0 : unsubscribe();
534
+ unsubscribe?.();
542
535
  };
543
536
  }
544
537
  );
@@ -547,7 +540,7 @@ var useTickerStream = (symbol) => {
547
540
  return null;
548
541
  if (!ticker)
549
542
  return info;
550
- const config = __spreadValues({}, info);
543
+ const config = { ...info };
551
544
  if (ticker.close !== void 0) {
552
545
  config["24h_close"] = ticker.close;
553
546
  }
@@ -574,7 +567,7 @@ var useMarkPrice = (symbol) => {
574
567
  });
575
568
  return () => {
576
569
  console.log("unsubscribe useMarkPrice !!!!!!!");
577
- unsubscribe == null ? void 0 : unsubscribe();
570
+ unsubscribe?.();
578
571
  };
579
572
  });
580
573
  };
@@ -585,16 +578,14 @@ function createGetter(data, depth = 2) {
585
578
  get(target, property, receiver) {
586
579
  if (depth === 1) {
587
580
  return (defaultValue) => {
588
- var _a;
589
581
  if (!target)
590
582
  return defaultValue;
591
- return (_a = target[property]) != null ? _a : defaultValue;
583
+ return target[property] ?? defaultValue;
592
584
  };
593
585
  }
594
586
  return (key, defaultValue) => {
595
- var _a, _b;
596
587
  if (key) {
597
- return (_b = (_a = target[property]) == null ? void 0 : _a[key]) != null ? _b : defaultValue;
588
+ return target[property]?.[key] ?? defaultValue;
598
589
  } else {
599
590
  return target[property];
600
591
  }
@@ -608,8 +599,7 @@ var useSymbolsInfo = () => {
608
599
  dedupingInterval: 1e3 * 60 * 60 * 24,
609
600
  revalidateOnFocus: false,
610
601
  formatter(data2) {
611
- var _a;
612
- if (!(data2 == null ? void 0 : data2.rows) || !((_a = data2 == null ? void 0 : data2.rows) == null ? void 0 : _a.length)) {
602
+ if (!data2?.rows || !data2?.rows?.length) {
613
603
  return {};
614
604
  }
615
605
  const obj = /* @__PURE__ */ Object.create(null);
@@ -618,14 +608,15 @@ var useSymbolsInfo = () => {
618
608
  const arr = item.symbol.split("_");
619
609
  const base_dp = utils.getPrecisionByNumber(item.base_tick);
620
610
  const quote_dp = utils.getPrecisionByNumber(item.quote_tick);
621
- obj[item.symbol] = __spreadProps(__spreadValues({}, item), {
611
+ obj[item.symbol] = {
612
+ ...item,
622
613
  base_dp,
623
614
  quote_dp,
624
615
  base: arr[1],
625
616
  quote: arr[2],
626
617
  type: arr[0],
627
618
  name: `${arr[1]}-${arr[0]}`
628
- });
619
+ };
629
620
  }
630
621
  return obj;
631
622
  }
@@ -718,10 +709,7 @@ var useOrderbookStream = (symbol, initial = { asks: [], bids: [] }, options) =>
718
709
  const [requestData, setRequestData] = React2.useState(null);
719
710
  const [data, setData] = React2.useState(initial);
720
711
  const [isLoading, setIsLoading] = React2.useState(true);
721
- const [level, setLevel] = React2.useState(() => {
722
- var _a;
723
- return (_a = options == null ? void 0 : options.level) != null ? _a : 10;
724
- });
712
+ const [level, setLevel] = React2.useState(() => options?.level ?? 10);
725
713
  const config = useSymbolsInfo()[symbol];
726
714
  const [depth, setDepth] = React2.useState();
727
715
  const depths = React2.useMemo(() => {
@@ -779,7 +767,7 @@ var useOrderbookStream = (symbol, initial = { asks: [], bids: [] }, options) =>
779
767
  }
780
768
  );
781
769
  return () => {
782
- subscription == null ? void 0 : subscription();
770
+ subscription?.();
783
771
  };
784
772
  }, [symbol, requestData]);
785
773
  const onItemClick = React2.useCallback((item) => {
@@ -823,9 +811,10 @@ function baseInputHandle(inputs) {
823
811
  value = value.replace(/[^\d.]/g, "");
824
812
  }
825
813
  return [
826
- __spreadProps(__spreadValues({}, values), {
814
+ {
815
+ ...values,
827
816
  [input]: value
828
- }),
817
+ },
829
818
  input,
830
819
  value,
831
820
  markPrice,
@@ -841,7 +830,7 @@ function orderEntityFormatHandle(baseTick, quoteTick) {
841
830
  function priceInputHandle(inputs) {
842
831
  const [values, input, value, markPrice, config] = inputs;
843
832
  if (value === "") {
844
- return [__spreadProps(__spreadValues({}, values), { total: "" }), input, value, markPrice, config];
833
+ return [{ ...values, total: "" }, input, value, markPrice, config];
845
834
  }
846
835
  const price = new utils.Decimal(value);
847
836
  const priceDP = price.dp();
@@ -854,9 +843,10 @@ function priceInputHandle(inputs) {
854
843
  }
855
844
  const total = price.mul(values.order_quantity);
856
845
  return [
857
- __spreadProps(__spreadValues({}, values), {
846
+ {
847
+ ...values,
858
848
  total: total.todp(2).toString()
859
- }),
849
+ },
860
850
  input,
861
851
  value,
862
852
  markPrice,
@@ -866,7 +856,7 @@ function priceInputHandle(inputs) {
866
856
  function quantityInputHandle(inputs) {
867
857
  const [values, input, value, markPrice, config] = inputs;
868
858
  if (value === "") {
869
- return [__spreadProps(__spreadValues({}, values), { total: "" }), input, value, markPrice, config];
859
+ return [{ ...values, total: "" }, input, value, markPrice, config];
870
860
  }
871
861
  let quantity = new utils.Decimal(value);
872
862
  const quantityDP = quantity.dp();
@@ -888,7 +878,10 @@ function quantityInputHandle(inputs) {
888
878
  }
889
879
  }
890
880
  return [
891
- __spreadValues({}, values),
881
+ {
882
+ ...values
883
+ // total: total.todp(2).toNumber(),
884
+ },
892
885
  input,
893
886
  value,
894
887
  markPrice,
@@ -898,7 +891,7 @@ function quantityInputHandle(inputs) {
898
891
  function totalInputHandle(inputs) {
899
892
  const [values, input, value, markPrice, config] = inputs;
900
893
  if (value === "") {
901
- return [__spreadProps(__spreadValues({}, values), { order_quantity: "" }), input, value, markPrice, config];
894
+ return [{ ...values, order_quantity: "" }, input, value, markPrice, config];
902
895
  }
903
896
  let price = markPrice;
904
897
  if (values.order_type === types.OrderType.LIMIT && !!values.order_price) {
@@ -912,9 +905,10 @@ function totalInputHandle(inputs) {
912
905
  }
913
906
  const quantity = total.div(price);
914
907
  return [
915
- __spreadProps(__spreadValues({}, values), {
908
+ {
909
+ ...values,
916
910
  order_quantity: quantity.toDecimalPlaces(Math.min(config.baseDP, quantity.dp())).toNumber()
917
- }),
911
+ },
918
912
  input,
919
913
  value,
920
914
  markPrice,
@@ -948,8 +942,7 @@ var useFundingRates = () => {
948
942
  focusThrottleInterval: 1e3 * 60 * 60 * 24,
949
943
  revalidateOnFocus: false,
950
944
  formatter(data2) {
951
- var _a;
952
- if (!(data2 == null ? void 0 : data2.rows) || !((_a = data2 == null ? void 0 : data2.rows) == null ? void 0 : _a.length)) {
945
+ if (!data2?.rows || !data2?.rows?.length) {
953
946
  return {};
954
947
  }
955
948
  const obj = /* @__PURE__ */ Object.create(null);
@@ -988,7 +981,7 @@ var useMarkPricesStream = () => {
988
981
  );
989
982
  return () => {
990
983
  console.log("unsubscribe!!!!!!!");
991
- unsubscribe == null ? void 0 : unsubscribe();
984
+ unsubscribe?.();
992
985
  };
993
986
  });
994
987
  };
@@ -998,13 +991,12 @@ var parseHolding = (holding, markPrices) => {
998
991
  const nonUSDC = [];
999
992
  let USDC_holding = 0;
1000
993
  holding.forEach((item) => {
1001
- var _a;
1002
994
  if (item.token === "USDC") {
1003
995
  USDC_holding = item.holding;
1004
996
  } else {
1005
997
  nonUSDC.push({
1006
998
  holding: item.holding,
1007
- markPrice: (_a = markPrices[item.token]) != null ? _a : 0,
999
+ markPrice: markPrices[item.token] ?? 0,
1008
1000
  // markPrice: 0,
1009
1001
  discount: 0
1010
1002
  });
@@ -1013,7 +1005,6 @@ var parseHolding = (holding, markPrices) => {
1013
1005
  return [USDC_holding, nonUSDC];
1014
1006
  };
1015
1007
  var usePositionStream = (symbol, options) => {
1016
- var _a;
1017
1008
  const symbolInfo = useSymbolsInfo();
1018
1009
  useEventEmitter();
1019
1010
  const { data: accountInfo } = usePrivateQuery("/v1/client/info");
@@ -1030,22 +1021,27 @@ var usePositionStream = (symbol, options) => {
1030
1021
  data,
1031
1022
  error
1032
1023
  // mutate: updatePositions,
1033
- } = usePrivateQuery(`/v1/positions`, __spreadProps(__spreadValues({}, options), {
1024
+ } = usePrivateQuery(`/v1/positions`, {
1025
+ // revalidateOnFocus: false,
1026
+ // revalidateOnReconnect: false,
1027
+ // dedupingInterval: 100,
1028
+ // keepPreviousData: false,
1029
+ // revalidateIfStale: true,
1030
+ ...options,
1034
1031
  formatter: (data2) => data2,
1035
1032
  onError: (err) => {
1036
1033
  console.log("usePositionStream error", err);
1037
1034
  }
1038
- }));
1035
+ });
1039
1036
  const { data: markPrices } = useMarkPricesStream();
1040
1037
  const formatedPositions = React2.useMemo(() => {
1041
- if (!(data == null ? void 0 : data.rows) || !symbolInfo || !accountInfo)
1038
+ if (!data?.rows || !symbolInfo || !accountInfo)
1042
1039
  return null;
1043
1040
  const filteredData = typeof symbol === "undefined" || symbol === "" ? data.rows : data.rows.filter((item) => {
1044
1041
  return item.symbol === symbol;
1045
1042
  });
1046
1043
  let unrealPnL_total = utils.zero, notional_total = utils.zero, unsettlementPnL_total = utils.zero;
1047
1044
  const formatted = filteredData.map((item) => {
1048
- var _a2;
1049
1045
  const price = ramda.propOr(
1050
1046
  item.mark_price,
1051
1047
  item.symbol,
@@ -1061,8 +1057,7 @@ var usePositionStream = (symbol, options) => {
1061
1057
  positionQty: item.position_qty,
1062
1058
  markPrice: price,
1063
1059
  costPosition: item.cost_position,
1064
- sumUnitaryFunding: (_a2 = fundingRates[item.symbol]) == null ? void 0 : _a2.call(
1065
- fundingRates,
1060
+ sumUnitaryFunding: fundingRates[item.symbol]?.(
1066
1061
  "sum_unitary_funding",
1067
1062
  0
1068
1063
  ),
@@ -1071,13 +1066,14 @@ var usePositionStream = (symbol, options) => {
1071
1066
  unrealPnL_total = unrealPnL_total.add(unrealPnl);
1072
1067
  notional_total = notional_total.add(notional);
1073
1068
  unsettlementPnL_total = unsettlementPnL_total.add(unsettlementPnL);
1074
- return __spreadProps(__spreadValues({}, item), {
1069
+ return {
1070
+ ...item,
1075
1071
  mark_price: price,
1076
1072
  mm: 0,
1077
1073
  notional,
1078
1074
  unsettlement_pnl: unsettlementPnL,
1079
1075
  unrealized_pnl: unrealPnl
1080
- });
1076
+ };
1081
1077
  });
1082
1078
  return [
1083
1079
  formatted,
@@ -1087,7 +1083,7 @@ var usePositionStream = (symbol, options) => {
1087
1083
  unsettledPnL: unsettlementPnL_total.toNumber()
1088
1084
  }
1089
1085
  ];
1090
- }, [data == null ? void 0 : data.rows, symbolInfo, accountInfo, markPrices, symbol, holding]);
1086
+ }, [data?.rows, symbolInfo, accountInfo, markPrices, symbol, holding]);
1091
1087
  const [totalCollateral, totalValue, totalUnrealizedROI] = React2.useMemo(() => {
1092
1088
  if (!holding || !markPrices) {
1093
1089
  return [utils.zero, utils.zero, 0];
@@ -1118,7 +1114,7 @@ var usePositionStream = (symbol, options) => {
1118
1114
  return formatedPositions[0];
1119
1115
  const total = totalCollateral.toNumber();
1120
1116
  return formatedPositions[0].filter((item) => item.position_qty !== 0).map((item) => {
1121
- const info = symbolInfo == null ? void 0 : symbolInfo[item.symbol];
1117
+ const info = symbolInfo?.[item.symbol];
1122
1118
  const MMR = futures.positions.MMR({
1123
1119
  baseMMR: info("base_mmr"),
1124
1120
  baseIMR: info("base_imr"),
@@ -1126,7 +1122,8 @@ var usePositionStream = (symbol, options) => {
1126
1122
  positionNotional: item.notional,
1127
1123
  IMR_factor_power: 4 / 5
1128
1124
  });
1129
- return __spreadProps(__spreadValues({}, item), {
1125
+ return {
1126
+ ...item,
1130
1127
  mm: futures.positions.maintenanceMargin({
1131
1128
  positionQty: item.position_qty,
1132
1129
  markPrice: item.mark_price,
@@ -1139,13 +1136,13 @@ var usePositionStream = (symbol, options) => {
1139
1136
  MMR
1140
1137
  }),
1141
1138
  MMR
1142
- });
1139
+ };
1143
1140
  });
1144
1141
  }, [formatedPositions, symbolInfo, accountInfo, totalCollateral]);
1145
1142
  return [
1146
1143
  {
1147
1144
  rows: positionsRows,
1148
- aggregated: (_a = formatedPositions == null ? void 0 : formatedPositions[1]) != null ? _a : {},
1145
+ aggregated: formatedPositions?.[1] ?? {},
1149
1146
  totalCollateral,
1150
1147
  totalValue,
1151
1148
  totalUnrealizedROI
@@ -1179,7 +1176,7 @@ var useHoldingStream = () => {
1179
1176
  }
1180
1177
  );
1181
1178
  const usdc = React2.useMemo(() => {
1182
- const usdc2 = data == null ? void 0 : data.find((item) => item.token === "USDC");
1179
+ const usdc2 = data?.find((item) => item.token === "USDC");
1183
1180
  return usdc2;
1184
1181
  }, [data]);
1185
1182
  useSWRSubscription__default.default("holding", (_, { next }) => {
@@ -1192,16 +1189,16 @@ var useHoldingStream = () => {
1192
1189
  },
1193
1190
  {
1194
1191
  onMessage: (data2) => {
1195
- var _a;
1196
- const holding = (_a = data2 == null ? void 0 : data2.balances) != null ? _a : {};
1192
+ const holding = data2?.balances ?? {};
1197
1193
  if (holding) {
1198
1194
  mutate2((prevData) => {
1199
- return prevData == null ? void 0 : prevData.map((item) => {
1195
+ return prevData?.map((item) => {
1200
1196
  const token = holding[item.token];
1201
- return __spreadProps(__spreadValues({}, item), {
1197
+ return {
1198
+ ...item,
1202
1199
  frozen: token.frozen,
1203
1200
  holding: token.holding
1204
- });
1201
+ };
1205
1202
  });
1206
1203
  });
1207
1204
  next(holding);
@@ -1243,7 +1240,7 @@ var useCollateral = (options = { dp: 6 }) => {
1243
1240
  }
1244
1241
  return futures.account.totalInitialMarginWithOrders({
1245
1242
  positions: positionsPath(positions2),
1246
- orders: orders != null ? orders : [],
1243
+ orders: orders ?? [],
1247
1244
  markPrices,
1248
1245
  IMR_Factors: accountInfo.imr_factor,
1249
1246
  maxLeverage: accountInfo.max_leverage,
@@ -1257,9 +1254,8 @@ var useCollateral = (options = { dp: 6 }) => {
1257
1254
  });
1258
1255
  }, [totalCollateral, totalInitialMarginWithOrders]);
1259
1256
  const availableBalance = React2.useMemo(() => {
1260
- var _a;
1261
1257
  return futures.account.availableBalance({
1262
- USDCHolding: (_a = usdc == null ? void 0 : usdc.holding) != null ? _a : 0,
1258
+ USDCHolding: usdc?.holding ?? 0,
1263
1259
  unsettlementPnL: pathOr_unsettledPnLPathOr(positions2)
1264
1260
  });
1265
1261
  }, [usdc, pathOr_unsettledPnLPathOr(positions2)]);
@@ -1424,9 +1420,10 @@ var BaseOrderCreator = class {
1424
1420
  };
1425
1421
  var LimitOrderCreator = class extends BaseOrderCreator {
1426
1422
  create(values) {
1427
- return __spreadProps(__spreadValues({}, this.baseOrder(values)), {
1423
+ return {
1424
+ ...this.baseOrder(values),
1428
1425
  order_price: values.order_price
1429
- });
1426
+ };
1430
1427
  }
1431
1428
  validate(values, config) {
1432
1429
  return this.baseValidate(values, config).then((errors) => {
@@ -1466,7 +1463,9 @@ var MarketOrderCreator = class extends BaseOrderCreator {
1466
1463
  create(values) {
1467
1464
  const data = this.baseOrder(values);
1468
1465
  delete data["order_price"];
1469
- return __spreadValues({}, data);
1466
+ return {
1467
+ ...data
1468
+ };
1470
1469
  }
1471
1470
  validate(values, configs) {
1472
1471
  return this.baseValidate(values, configs);
@@ -1480,10 +1479,11 @@ var IOCOrderCreator = class extends LimitOrderCreator {
1480
1479
  };
1481
1480
  var GeneralOrderCreator = class extends BaseOrderCreator {
1482
1481
  create(data) {
1483
- return __spreadProps(__spreadValues({}, this.baseOrder(data)), {
1482
+ return {
1483
+ ...this.baseOrder(data),
1484
1484
  order_price: data.order_price,
1485
1485
  order_quantity: data.order_quantity
1486
- });
1486
+ };
1487
1487
  }
1488
1488
  validate(values, configs) {
1489
1489
  return super.baseValidate(values, configs);
@@ -1537,7 +1537,7 @@ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
1537
1537
  if (!orderCreator) {
1538
1538
  return Promise.reject(new Error("orderCreator is null"));
1539
1539
  }
1540
- return orderCreator == null ? void 0 : orderCreator.validate(values, {
1540
+ return orderCreator?.validate(values, {
1541
1541
  symbol: symbolInfo[symbol](),
1542
1542
  // token: tokenInfo[symbol](),
1543
1543
  maxQty,
@@ -1550,9 +1550,10 @@ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
1550
1550
  throw new Error("symbol is null");
1551
1551
  }
1552
1552
  const data = orderCreator.create(values);
1553
- return doCreateOrder(__spreadProps(__spreadValues({}, data), {
1553
+ return doCreateOrder({
1554
+ ...data,
1554
1555
  symbol
1555
- }));
1556
+ });
1556
1557
  });
1557
1558
  };
1558
1559
  const calculate = React2.useCallback(
@@ -1571,7 +1572,7 @@ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
1571
1572
  );
1572
1573
  const validator = (values) => {
1573
1574
  const creator = OrderFactory.create(values.order_type);
1574
- return creator == null ? void 0 : creator.validate(values, {
1575
+ return creator?.validate(values, {
1575
1576
  symbol: symbolInfo[symbol](),
1576
1577
  // token: tokenInfo[symbol](),
1577
1578
  maxQty,
@@ -1636,14 +1637,12 @@ var useTokenInfo = () => {
1636
1637
  focusThrottleInterval: 1e3 * 60 * 60 * 24,
1637
1638
  revalidateOnFocus: false,
1638
1639
  formatter(data2) {
1639
- var _a;
1640
- if (!(data2 == null ? void 0 : data2.rows) || !((_a = data2 == null ? void 0 : data2.rows) == null ? void 0 : _a.length)) {
1640
+ if (!data2?.rows || !data2?.rows?.length) {
1641
1641
  return {};
1642
1642
  }
1643
1643
  const obj = /* @__PURE__ */ Object.create(null);
1644
1644
  for (let index = 0; index < data2.rows.length; index++) {
1645
- const item = data2.rows[index];
1646
- obj[item.token] = item;
1645
+ data2.rows[index];
1647
1646
  }
1648
1647
  return obj;
1649
1648
  }
@@ -1674,7 +1673,7 @@ var useMarketsStream = () => {
1674
1673
  );
1675
1674
  return () => {
1676
1675
  console.log("unsubscribe!!!!!!!");
1677
- unsubscribe == null ? void 0 : unsubscribe();
1676
+ unsubscribe?.();
1678
1677
  };
1679
1678
  });
1680
1679
  const value = React2.useMemo(() => {
@@ -1687,12 +1686,13 @@ var useMarketsStream = () => {
1687
1686
  (t) => t.symbol === item.symbol
1688
1687
  );
1689
1688
  if (ticker) {
1690
- return __spreadProps(__spreadValues({}, item), {
1689
+ return {
1690
+ ...item,
1691
1691
  ["24h_close"]: ticker.close,
1692
1692
  ["24h_open"]: ticker.open,
1693
1693
  ["24h_volumn"]: ticker.volume,
1694
1694
  change: 0
1695
- });
1695
+ };
1696
1696
  }
1697
1697
  return item;
1698
1698
  });
@@ -1710,7 +1710,6 @@ var useLeverage = () => {
1710
1710
  return [ramda.prop("max_leverage", data), { update: updateLeverage }];
1711
1711
  };
1712
1712
  var useFundingRate = (symbol) => {
1713
- var _a;
1714
1713
  if (!symbol) {
1715
1714
  throw new Error("useFuturesForSymbol requires a symbol");
1716
1715
  }
@@ -1744,22 +1743,23 @@ var useFundingRate = (symbol) => {
1744
1743
  clearInterval(timer);
1745
1744
  };
1746
1745
  }, [data]);
1747
- return __spreadProps(__spreadValues({}, data), {
1748
- est_funding_rate: (Number((_a = data == null ? void 0 : data.est_funding_rate) != null ? _a : 0) * 100).toFixed(4),
1746
+ return {
1747
+ ...data,
1748
+ est_funding_rate: (Number(data?.est_funding_rate ?? 0) * 100).toFixed(4),
1749
1749
  countDown
1750
- });
1750
+ };
1751
1751
  };
1752
1752
  var fetcher3 = (url, init) => net.get(url, init);
1753
1753
  var usePrivateInfiniteQuery = (getKey, options) => {
1754
- var _a;
1755
1754
  const account5 = useAccount();
1756
- const middleware = Array.isArray(options == null ? void 0 : options.use) ? (_a = options == null ? void 0 : options.use) != null ? _a : [] : [];
1755
+ const middleware = Array.isArray(options?.use) ? options?.use ?? [] : [];
1757
1756
  const result = useSWRInfinite__default.default(
1758
1757
  (pageIndex, previousPageData) => account5.state.status >= types.AccountStatusEnum.EnableTrading ? getKey(pageIndex, previousPageData) : null,
1759
1758
  fetcher3,
1760
- __spreadProps(__spreadValues({}, options), {
1759
+ {
1760
+ ...options,
1761
1761
  use: [signatureMiddleware, ...middleware]
1762
- })
1762
+ }
1763
1763
  );
1764
1764
  return result;
1765
1765
  };
@@ -1807,15 +1807,14 @@ var useOrderStream = ({
1807
1807
  }
1808
1808
  );
1809
1809
  const orders = React2.useMemo(() => {
1810
- var _a;
1811
1810
  if (!ordersResponse.data) {
1812
1811
  return null;
1813
1812
  }
1814
- return (_a = ordersResponse.data) == null ? void 0 : _a.flat().map((item) => {
1815
- var _a2;
1816
- return __spreadProps(__spreadValues({}, item), {
1817
- mark_price: (_a2 = markPrices[item.symbol]) != null ? _a2 : 0
1818
- });
1813
+ return ordersResponse.data?.flat().map((item) => {
1814
+ return {
1815
+ ...item,
1816
+ mark_price: markPrices[item.symbol] ?? 0
1817
+ };
1819
1818
  });
1820
1819
  }, [ordersResponse.data, markPrices]);
1821
1820
  React2.useEffect(() => {
@@ -1828,7 +1827,7 @@ var useOrderStream = ({
1828
1827
  const cancelAllOrders = React2.useCallback(() => {
1829
1828
  }, [ordersResponse.data]);
1830
1829
  const updateOrder = React2.useCallback((orderId, order2) => {
1831
- return doUpdateOrder(__spreadProps(__spreadValues({}, order2), { order_id: orderId }));
1830
+ return doUpdateOrder({ ...order2, order_id: orderId });
1832
1831
  }, []);
1833
1832
  const cancelOrder = React2.useCallback((orderId, symbol2) => {
1834
1833
  return doCancelOrder(null, {
@@ -1894,7 +1893,7 @@ var useMarketTradeStream = (symbol, options = {}) => {
1894
1893
  {
1895
1894
  onMessage: (data) => {
1896
1895
  setTrades((prev) => {
1897
- const arr = [__spreadProps(__spreadValues({}, data), { ts: Date.now() }), ...prev];
1896
+ const arr = [{ ...data, ts: Date.now() }, ...prev];
1898
1897
  if (arr.length > limit) {
1899
1898
  arr.pop();
1900
1899
  }
@@ -1904,10 +1903,9 @@ var useMarketTradeStream = (symbol, options = {}) => {
1904
1903
  }
1905
1904
  );
1906
1905
  return () => {
1907
- unsubscript == null ? void 0 : unsubscript();
1906
+ unsubscript?.();
1908
1907
  };
1909
1908
  }, [symbol]);
1910
- console.log("trades", trades);
1911
1909
  return { data: trades, isLoading };
1912
1910
  };
1913
1911
  var useMarginRatio = () => {
@@ -1921,7 +1919,7 @@ var useMarginRatio = () => {
1921
1919
  const ratio = futures.account.totalMarginRatio({
1922
1920
  totalCollateral,
1923
1921
  markPrices,
1924
- positions: rows != null ? rows : []
1922
+ positions: rows ?? []
1925
1923
  });
1926
1924
  return ratio;
1927
1925
  }, [rows, markPrices, totalCollateral]);
@@ -1930,60 +1928,747 @@ var useMarginRatio = () => {
1930
1928
  }, [marginRatio]);
1931
1929
  return { marginRatio, currentLeverage };
1932
1930
  };
1931
+
1932
+ // src/woo/constants.ts
1933
+ var woofiDexCrossChainRouterAbi = [
1934
+ {
1935
+ inputs: [
1936
+ { internalType: "address", name: "_weth", type: "address" },
1937
+ { internalType: "address", name: "_nonceCounter", type: "address" },
1938
+ { internalType: "address", name: "_wooRouter", type: "address" },
1939
+ { internalType: "address", name: "_stargateRouter", type: "address" },
1940
+ { internalType: "uint16", name: "_sgChainIdLocal", type: "uint16" }
1941
+ ],
1942
+ stateMutability: "nonpayable",
1943
+ type: "constructor"
1944
+ },
1945
+ {
1946
+ anonymous: false,
1947
+ inputs: [
1948
+ {
1949
+ indexed: true,
1950
+ internalType: "address",
1951
+ name: "previousOwner",
1952
+ type: "address"
1953
+ },
1954
+ {
1955
+ indexed: true,
1956
+ internalType: "address",
1957
+ name: "newOwner",
1958
+ type: "address"
1959
+ }
1960
+ ],
1961
+ name: "OwnershipTransferred",
1962
+ type: "event"
1963
+ },
1964
+ {
1965
+ anonymous: false,
1966
+ inputs: [
1967
+ {
1968
+ indexed: false,
1969
+ internalType: "address",
1970
+ name: "account",
1971
+ type: "address"
1972
+ }
1973
+ ],
1974
+ name: "Paused",
1975
+ type: "event"
1976
+ },
1977
+ {
1978
+ anonymous: false,
1979
+ inputs: [
1980
+ {
1981
+ indexed: false,
1982
+ internalType: "address",
1983
+ name: "account",
1984
+ type: "address"
1985
+ }
1986
+ ],
1987
+ name: "Unpaused",
1988
+ type: "event"
1989
+ },
1990
+ {
1991
+ anonymous: false,
1992
+ inputs: [
1993
+ {
1994
+ indexed: false,
1995
+ internalType: "uint16",
1996
+ name: "srcChainId",
1997
+ type: "uint16"
1998
+ },
1999
+ {
2000
+ indexed: true,
2001
+ internalType: "uint256",
2002
+ name: "nonce",
2003
+ type: "uint256"
2004
+ },
2005
+ {
2006
+ indexed: true,
2007
+ internalType: "address",
2008
+ name: "sender",
2009
+ type: "address"
2010
+ },
2011
+ { indexed: true, internalType: "address", name: "to", type: "address" },
2012
+ {
2013
+ indexed: false,
2014
+ internalType: "address",
2015
+ name: "bridgedToken",
2016
+ type: "address"
2017
+ },
2018
+ {
2019
+ indexed: false,
2020
+ internalType: "uint256",
2021
+ name: "bridgedAmount",
2022
+ type: "uint256"
2023
+ },
2024
+ {
2025
+ indexed: false,
2026
+ internalType: "address",
2027
+ name: "toToken",
2028
+ type: "address"
2029
+ },
2030
+ {
2031
+ indexed: false,
2032
+ internalType: "uint256",
2033
+ name: "minToAmount",
2034
+ type: "uint256"
2035
+ },
2036
+ {
2037
+ indexed: false,
2038
+ internalType: "address",
2039
+ name: "realToToken",
2040
+ type: "address"
2041
+ },
2042
+ {
2043
+ indexed: false,
2044
+ internalType: "uint256",
2045
+ name: "realToAmount",
2046
+ type: "uint256"
2047
+ },
2048
+ {
2049
+ indexed: false,
2050
+ internalType: "bytes32",
2051
+ name: "accountId",
2052
+ type: "bytes32"
2053
+ },
2054
+ {
2055
+ indexed: false,
2056
+ internalType: "bytes32",
2057
+ name: "brokerHash",
2058
+ type: "bytes32"
2059
+ },
2060
+ {
2061
+ indexed: false,
2062
+ internalType: "bytes32",
2063
+ name: "tokenHash",
2064
+ type: "bytes32"
2065
+ },
2066
+ {
2067
+ indexed: false,
2068
+ internalType: "uint128",
2069
+ name: "tokenAmount",
2070
+ type: "uint128"
2071
+ }
2072
+ ],
2073
+ name: "WOOFiDexCrossSwapOnDstChain",
2074
+ type: "event"
2075
+ },
2076
+ {
2077
+ anonymous: false,
2078
+ inputs: [
2079
+ {
2080
+ indexed: false,
2081
+ internalType: "uint16",
2082
+ name: "dstChainId",
2083
+ type: "uint16"
2084
+ },
2085
+ {
2086
+ indexed: true,
2087
+ internalType: "uint256",
2088
+ name: "nonce",
2089
+ type: "uint256"
2090
+ },
2091
+ {
2092
+ indexed: true,
2093
+ internalType: "address",
2094
+ name: "sender",
2095
+ type: "address"
2096
+ },
2097
+ { indexed: true, internalType: "address", name: "to", type: "address" },
2098
+ {
2099
+ indexed: false,
2100
+ internalType: "address",
2101
+ name: "fromToken",
2102
+ type: "address"
2103
+ },
2104
+ {
2105
+ indexed: false,
2106
+ internalType: "uint256",
2107
+ name: "fromAmount",
2108
+ type: "uint256"
2109
+ },
2110
+ {
2111
+ indexed: false,
2112
+ internalType: "address",
2113
+ name: "bridgeToken",
2114
+ type: "address"
2115
+ },
2116
+ {
2117
+ indexed: false,
2118
+ internalType: "uint256",
2119
+ name: "minBridgeAmount",
2120
+ type: "uint256"
2121
+ },
2122
+ {
2123
+ indexed: false,
2124
+ internalType: "uint256",
2125
+ name: "bridgeAmount",
2126
+ type: "uint256"
2127
+ }
2128
+ ],
2129
+ name: "WOOFiDexCrossSwapOnSrcChain",
2130
+ type: "event"
2131
+ },
2132
+ {
2133
+ inputs: [],
2134
+ name: "MAX_BRIDGE_SLIPPAGE",
2135
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2136
+ stateMutability: "view",
2137
+ type: "function"
2138
+ },
2139
+ {
2140
+ inputs: [],
2141
+ name: "NATIVE_PLACEHOLDER",
2142
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2143
+ stateMutability: "view",
2144
+ type: "function"
2145
+ },
2146
+ {
2147
+ inputs: [{ internalType: "address", name: "token", type: "address" }],
2148
+ name: "addDirectBridgeToken",
2149
+ outputs: [],
2150
+ stateMutability: "nonpayable",
2151
+ type: "function"
2152
+ },
2153
+ {
2154
+ inputs: [],
2155
+ name: "allDirectBridgeTokens",
2156
+ outputs: [{ internalType: "address[]", name: "", type: "address[]" }],
2157
+ stateMutability: "view",
2158
+ type: "function"
2159
+ },
2160
+ {
2161
+ inputs: [],
2162
+ name: "allDirectBridgeTokensLength",
2163
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2164
+ stateMutability: "view",
2165
+ type: "function"
2166
+ },
2167
+ {
2168
+ inputs: [],
2169
+ name: "bridgeSlippage",
2170
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2171
+ stateMutability: "view",
2172
+ type: "function"
2173
+ },
2174
+ {
2175
+ inputs: [
2176
+ { internalType: "address payable", name: "to", type: "address" },
2177
+ {
2178
+ components: [
2179
+ { internalType: "address", name: "fromToken", type: "address" },
2180
+ { internalType: "uint256", name: "fromAmount", type: "uint256" },
2181
+ { internalType: "address", name: "bridgeToken", type: "address" },
2182
+ {
2183
+ internalType: "uint256",
2184
+ name: "minBridgeAmount",
2185
+ type: "uint256"
2186
+ }
2187
+ ],
2188
+ internalType: "struct IWOOFiDexCrossChainRouter.SrcInfos",
2189
+ name: "srcInfos",
2190
+ type: "tuple"
2191
+ },
2192
+ {
2193
+ components: [
2194
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2195
+ { internalType: "address", name: "bridgedToken", type: "address" },
2196
+ { internalType: "address", name: "toToken", type: "address" },
2197
+ { internalType: "uint256", name: "minToAmount", type: "uint256" },
2198
+ {
2199
+ internalType: "uint256",
2200
+ name: "airdropNativeAmount",
2201
+ type: "uint256"
2202
+ }
2203
+ ],
2204
+ internalType: "struct IWOOFiDexCrossChainRouter.DstInfos",
2205
+ name: "dstInfos",
2206
+ type: "tuple"
2207
+ },
2208
+ {
2209
+ components: [
2210
+ { internalType: "bytes32", name: "accountId", type: "bytes32" },
2211
+ { internalType: "bytes32", name: "brokerHash", type: "bytes32" },
2212
+ { internalType: "bytes32", name: "tokenHash", type: "bytes32" }
2213
+ ],
2214
+ internalType: "struct IWOOFiDexCrossChainRouter.DstVaultDeposit",
2215
+ name: "dstVaultDeposit",
2216
+ type: "tuple"
2217
+ }
2218
+ ],
2219
+ name: "crossSwap",
2220
+ outputs: [],
2221
+ stateMutability: "payable",
2222
+ type: "function"
2223
+ },
2224
+ {
2225
+ inputs: [],
2226
+ name: "dstGasForNoSwapCall",
2227
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2228
+ stateMutability: "view",
2229
+ type: "function"
2230
+ },
2231
+ {
2232
+ inputs: [],
2233
+ name: "dstGasForSwapCall",
2234
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2235
+ stateMutability: "view",
2236
+ type: "function"
2237
+ },
2238
+ {
2239
+ inputs: [{ internalType: "address", name: "stuckToken", type: "address" }],
2240
+ name: "inCaseTokenGotStuck",
2241
+ outputs: [],
2242
+ stateMutability: "nonpayable",
2243
+ type: "function"
2244
+ },
2245
+ {
2246
+ inputs: [],
2247
+ name: "nonceCounter",
2248
+ outputs: [
2249
+ { internalType: "contract INonceCounter", name: "", type: "address" }
2250
+ ],
2251
+ stateMutability: "view",
2252
+ type: "function"
2253
+ },
2254
+ {
2255
+ inputs: [],
2256
+ name: "owner",
2257
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2258
+ stateMutability: "view",
2259
+ type: "function"
2260
+ },
2261
+ {
2262
+ inputs: [],
2263
+ name: "pause",
2264
+ outputs: [],
2265
+ stateMutability: "nonpayable",
2266
+ type: "function"
2267
+ },
2268
+ {
2269
+ inputs: [],
2270
+ name: "paused",
2271
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
2272
+ stateMutability: "view",
2273
+ type: "function"
2274
+ },
2275
+ {
2276
+ inputs: [
2277
+ { internalType: "address", name: "to", type: "address" },
2278
+ {
2279
+ components: [
2280
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2281
+ { internalType: "address", name: "bridgedToken", type: "address" },
2282
+ { internalType: "address", name: "toToken", type: "address" },
2283
+ { internalType: "uint256", name: "minToAmount", type: "uint256" },
2284
+ {
2285
+ internalType: "uint256",
2286
+ name: "airdropNativeAmount",
2287
+ type: "uint256"
2288
+ }
2289
+ ],
2290
+ internalType: "struct IWOOFiDexCrossChainRouter.DstInfos",
2291
+ name: "dstInfos",
2292
+ type: "tuple"
2293
+ },
2294
+ {
2295
+ components: [
2296
+ { internalType: "bytes32", name: "accountId", type: "bytes32" },
2297
+ { internalType: "bytes32", name: "brokerHash", type: "bytes32" },
2298
+ { internalType: "bytes32", name: "tokenHash", type: "bytes32" }
2299
+ ],
2300
+ internalType: "struct IWOOFiDexCrossChainRouter.DstVaultDeposit",
2301
+ name: "dstVaultDeposit",
2302
+ type: "tuple"
2303
+ }
2304
+ ],
2305
+ name: "quoteLayerZeroFee",
2306
+ outputs: [
2307
+ { internalType: "uint256", name: "nativeAmount", type: "uint256" },
2308
+ { internalType: "uint256", name: "zroAmount", type: "uint256" }
2309
+ ],
2310
+ stateMutability: "view",
2311
+ type: "function"
2312
+ },
2313
+ {
2314
+ inputs: [{ internalType: "address", name: "token", type: "address" }],
2315
+ name: "removeDirectBridgeToken",
2316
+ outputs: [],
2317
+ stateMutability: "nonpayable",
2318
+ type: "function"
2319
+ },
2320
+ {
2321
+ inputs: [],
2322
+ name: "renounceOwnership",
2323
+ outputs: [],
2324
+ stateMutability: "nonpayable",
2325
+ type: "function"
2326
+ },
2327
+ {
2328
+ inputs: [
2329
+ { internalType: "uint256", name: "_bridgeSlippage", type: "uint256" }
2330
+ ],
2331
+ name: "setBridgeSlippage",
2332
+ outputs: [],
2333
+ stateMutability: "nonpayable",
2334
+ type: "function"
2335
+ },
2336
+ {
2337
+ inputs: [
2338
+ {
2339
+ internalType: "uint256",
2340
+ name: "_dstGasForNoSwapCall",
2341
+ type: "uint256"
2342
+ }
2343
+ ],
2344
+ name: "setDstGasForNoSwapCall",
2345
+ outputs: [],
2346
+ stateMutability: "nonpayable",
2347
+ type: "function"
2348
+ },
2349
+ {
2350
+ inputs: [
2351
+ {
2352
+ internalType: "uint256",
2353
+ name: "_dstGasForSwapCall",
2354
+ type: "uint256"
2355
+ }
2356
+ ],
2357
+ name: "setDstGasForSwapCall",
2358
+ outputs: [],
2359
+ stateMutability: "nonpayable",
2360
+ type: "function"
2361
+ },
2362
+ {
2363
+ inputs: [
2364
+ { internalType: "uint16", name: "_sgChainIdLocal", type: "uint16" }
2365
+ ],
2366
+ name: "setSgChainIdLocal",
2367
+ outputs: [],
2368
+ stateMutability: "nonpayable",
2369
+ type: "function"
2370
+ },
2371
+ {
2372
+ inputs: [
2373
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2374
+ { internalType: "address", name: "token", type: "address" }
2375
+ ],
2376
+ name: "setSgETH",
2377
+ outputs: [],
2378
+ stateMutability: "nonpayable",
2379
+ type: "function"
2380
+ },
2381
+ {
2382
+ inputs: [
2383
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2384
+ { internalType: "address", name: "token", type: "address" },
2385
+ { internalType: "uint256", name: "poolId", type: "uint256" }
2386
+ ],
2387
+ name: "setSgPoolId",
2388
+ outputs: [],
2389
+ stateMutability: "nonpayable",
2390
+ type: "function"
2391
+ },
2392
+ {
2393
+ inputs: [
2394
+ { internalType: "address", name: "_stargateRouter", type: "address" }
2395
+ ],
2396
+ name: "setStargateRouter",
2397
+ outputs: [],
2398
+ stateMutability: "nonpayable",
2399
+ type: "function"
2400
+ },
2401
+ {
2402
+ inputs: [
2403
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2404
+ {
2405
+ internalType: "address",
2406
+ name: "woofiDexCrossChainRouter",
2407
+ type: "address"
2408
+ }
2409
+ ],
2410
+ name: "setWOOFiDexCrossChainRouter",
2411
+ outputs: [],
2412
+ stateMutability: "nonpayable",
2413
+ type: "function"
2414
+ },
2415
+ {
2416
+ inputs: [
2417
+ { internalType: "uint16", name: "chainId", type: "uint16" },
2418
+ { internalType: "address", name: "token", type: "address" },
2419
+ { internalType: "address", name: "woofiDexVault", type: "address" }
2420
+ ],
2421
+ name: "setWOOFiDexVault",
2422
+ outputs: [],
2423
+ stateMutability: "nonpayable",
2424
+ type: "function"
2425
+ },
2426
+ {
2427
+ inputs: [{ internalType: "address", name: "_wooRouter", type: "address" }],
2428
+ name: "setWooRouter",
2429
+ outputs: [],
2430
+ stateMutability: "nonpayable",
2431
+ type: "function"
2432
+ },
2433
+ {
2434
+ inputs: [],
2435
+ name: "sgChainIdLocal",
2436
+ outputs: [{ internalType: "uint16", name: "", type: "uint16" }],
2437
+ stateMutability: "view",
2438
+ type: "function"
2439
+ },
2440
+ {
2441
+ inputs: [{ internalType: "uint16", name: "", type: "uint16" }],
2442
+ name: "sgETHs",
2443
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2444
+ stateMutability: "view",
2445
+ type: "function"
2446
+ },
2447
+ {
2448
+ inputs: [
2449
+ { internalType: "uint16", name: "", type: "uint16" },
2450
+ { internalType: "address", name: "", type: "address" }
2451
+ ],
2452
+ name: "sgPoolIds",
2453
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
2454
+ stateMutability: "view",
2455
+ type: "function"
2456
+ },
2457
+ {
2458
+ inputs: [
2459
+ { internalType: "uint16", name: "srcChainId", type: "uint16" },
2460
+ { internalType: "bytes", name: "", type: "bytes" },
2461
+ { internalType: "uint256", name: "", type: "uint256" },
2462
+ { internalType: "address", name: "bridgedToken", type: "address" },
2463
+ { internalType: "uint256", name: "bridgedAmount", type: "uint256" },
2464
+ { internalType: "bytes", name: "payload", type: "bytes" }
2465
+ ],
2466
+ name: "sgReceive",
2467
+ outputs: [],
2468
+ stateMutability: "nonpayable",
2469
+ type: "function"
2470
+ },
2471
+ {
2472
+ inputs: [],
2473
+ name: "stargateRouter",
2474
+ outputs: [
2475
+ { internalType: "contract IStargateRouter", name: "", type: "address" }
2476
+ ],
2477
+ stateMutability: "view",
2478
+ type: "function"
2479
+ },
2480
+ {
2481
+ inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
2482
+ name: "transferOwnership",
2483
+ outputs: [],
2484
+ stateMutability: "nonpayable",
2485
+ type: "function"
2486
+ },
2487
+ {
2488
+ inputs: [],
2489
+ name: "unpause",
2490
+ outputs: [],
2491
+ stateMutability: "nonpayable",
2492
+ type: "function"
2493
+ },
2494
+ {
2495
+ inputs: [],
2496
+ name: "weth",
2497
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2498
+ stateMutability: "view",
2499
+ type: "function"
2500
+ },
2501
+ {
2502
+ inputs: [],
2503
+ name: "wooRouter",
2504
+ outputs: [
2505
+ { internalType: "contract IWooRouterV2", name: "", type: "address" }
2506
+ ],
2507
+ stateMutability: "view",
2508
+ type: "function"
2509
+ },
2510
+ {
2511
+ inputs: [{ internalType: "uint16", name: "", type: "uint16" }],
2512
+ name: "woofiDexCrossChainRouters",
2513
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2514
+ stateMutability: "view",
2515
+ type: "function"
2516
+ },
2517
+ {
2518
+ inputs: [
2519
+ { internalType: "uint16", name: "", type: "uint16" },
2520
+ { internalType: "address", name: "", type: "address" }
2521
+ ],
2522
+ name: "woofiDexVaults",
2523
+ outputs: [{ internalType: "address", name: "", type: "address" }],
2524
+ stateMutability: "view",
2525
+ type: "function"
2526
+ },
2527
+ { stateMutability: "payable", type: "receive" }
2528
+ ];
2529
+ var nativeTokenAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
2530
+
2531
+ // src/orderly/useChains.ts
1933
2532
  var useChains = (networkId, options = {}) => {
1934
- const _a = options, { filter, pick, crossEnabled, wooSwapEnabled } = _a, swrOptions = __objRest(_a, ["filter", "pick", "crossEnabled", "wooSwapEnabled"]);
1935
- const { configStore } = React2.useContext(OrderlyContext);
1936
- const field = options == null ? void 0 : options.pick;
1937
- const { data } = useSWR__default.default(
1938
- // () =>
1939
- // wooSwapEnabled
1940
- // ? `${configStore.get("swapSupportApiUrl")}/swap_support`
1941
- // : null,
1942
- `${configStore.get("swapSupportApiUrl")}/swap_support`,
2533
+ const { filter, pick: pick3, crossEnabled, wooSwapEnabled, ...swrOptions } = options;
2534
+ const { configStore, networkId: envNetworkId } = React2.useContext(OrderlyContext);
2535
+ const field = options?.pick;
2536
+ const map = React2.useRef(
2537
+ /* @__PURE__ */ new Map()
2538
+ );
2539
+ const { data, error: swapSupportError } = useSWR__default.default(
2540
+ () => wooSwapEnabled ? `${configStore.get("swapSupportApiUrl")}/swap_support` : null,
2541
+ // `${configStore.get("swapSupportApiUrl")}/swap_support`,
1943
2542
  (url) => fetch(url).then((res) => res.json()),
1944
- __spreadValues({
2543
+ {
2544
+ revalidateIfStale: false,
2545
+ revalidateOnFocus: false,
2546
+ revalidateOnReconnect: false,
2547
+ ...swrOptions
2548
+ }
2549
+ );
2550
+ const { data: orderlyChains, error: tokenError } = useQuery(
2551
+ "/v1/public/token",
2552
+ {
2553
+ revalidateIfStale: false,
1945
2554
  revalidateOnFocus: false,
1946
2555
  revalidateOnReconnect: false
1947
- }, swrOptions)
2556
+ }
1948
2557
  );
1949
- const { data: orderlyChains } = useQuery("/v1/public/token");
1950
2558
  const chains = React2.useMemo(() => {
1951
- if (!data || !data.data || !orderlyChains)
1952
- return data;
1953
- let testnetArr = [];
1954
- let mainnetArr = [];
1955
- Object.keys(data.data).forEach((key) => {
1956
- const item = __spreadProps(__spreadValues({}, data.data[key]), { name: key, priority: 1 });
1957
- if (typeof (options == null ? void 0 : options.filter) === "function") {
1958
- if (!options.filter(item))
2559
+ if (!orderlyChains)
2560
+ return void 0;
2561
+ let orderlyChainsArr = [];
2562
+ const orderlyChainIds = /* @__PURE__ */ new Set();
2563
+ orderlyChains.forEach((item) => {
2564
+ item.chain_details.forEach((chain) => {
2565
+ const chainId = Number(chain.chain_id);
2566
+ orderlyChainIds.add(chainId);
2567
+ const _chain = {
2568
+ network_infos: {
2569
+ name: chain.chain_name ?? "--",
2570
+ // "public_rpc_url": "https://arb1.arbitrum.io/rpc",
2571
+ chain_id: chainId,
2572
+ bridgeless: true
2573
+ },
2574
+ token_infos: [
2575
+ {
2576
+ symbol: item.token,
2577
+ address: chain.contract_address,
2578
+ decimals: chain.decimals
2579
+ }
2580
+ ]
2581
+ };
2582
+ if (typeof options?.filter === "function") {
2583
+ if (!options.filter(_chain))
2584
+ return;
2585
+ }
2586
+ map.current.set(chainId, _chain);
2587
+ orderlyChainsArr.push(_chain);
2588
+ });
2589
+ });
2590
+ if (!wooSwapEnabled) {
2591
+ return orderlyChainsArr;
2592
+ } else {
2593
+ if (!data || !data.data)
2594
+ return data;
2595
+ let testnetArr = [];
2596
+ let mainnetArr = [];
2597
+ Object.keys(data.data).forEach((key) => {
2598
+ data.data[key];
2599
+ if (orderlyChainIds.has(data.data[key].network_infos.chain_id)) {
2600
+ orderlyChainsArr = orderlyChainsArr.map((item2) => {
2601
+ if (item2.network_infos.chain_id === data.data[key].network_infos.chain_id) {
2602
+ return ramda.mergeDeepLeft(item2, data.data[key]);
2603
+ }
2604
+ return item2;
2605
+ });
1959
2606
  return;
2607
+ }
2608
+ const item = {
2609
+ ...data.data[key],
2610
+ name: key
2611
+ };
2612
+ if (item.token_infos?.length === 0)
2613
+ return;
2614
+ map.current.set(item.network_infos.chain_id, item);
2615
+ if (typeof options?.filter === "function") {
2616
+ if (!options.filter(item))
2617
+ return;
2618
+ }
2619
+ if (item.network_infos.mainnet) {
2620
+ mainnetArr.push(item);
2621
+ } else {
2622
+ testnetArr.push(item);
2623
+ }
2624
+ });
2625
+ if (orderlyChainIds.size > 0) {
2626
+ if (envNetworkId === "testnet") {
2627
+ testnetArr = [...orderlyChainsArr, ...testnetArr];
2628
+ } else {
2629
+ mainnetArr = [...orderlyChainsArr, ...mainnetArr];
2630
+ }
1960
2631
  }
1961
- if (item.network_infos.mainnet) {
1962
- mainnetArr.push(field ? item[field] : item);
1963
- } else {
1964
- testnetArr.push(field ? item[field] : item);
2632
+ if (!!field) {
2633
+ testnetArr = testnetArr.map((item) => item[field]);
2634
+ mainnetArr = mainnetArr.map((item) => item[field]);
1965
2635
  }
1966
- });
1967
- if (networkId === "mainnet") {
1968
- return mainnetArr;
1969
- }
1970
- if (networkId === "testnet") {
1971
- return testnetArr;
2636
+ if (networkId === "mainnet") {
2637
+ return mainnetArr;
2638
+ }
2639
+ if (networkId === "testnet") {
2640
+ return testnetArr;
2641
+ }
2642
+ return {
2643
+ testnet: testnetArr,
2644
+ mainnet: mainnetArr
2645
+ };
1972
2646
  }
1973
- return {
1974
- testnet: testnetArr,
1975
- mainnet: mainnetArr
1976
- };
1977
2647
  }, [data, networkId, field, options, orderlyChains, wooSwapEnabled]);
1978
2648
  const findByChainId = React2.useCallback(
1979
- (chainId) => {
1980
- if (!data || !data.data)
1981
- return void 0;
1982
- return data.data[chainId];
2649
+ (chainId, field2) => {
2650
+ const chain = map.current.get(chainId);
2651
+ if (chain) {
2652
+ chain.nativeToken = chain.token_infos?.find(
2653
+ (item) => item.address === nativeTokenAddress
2654
+ );
2655
+ }
2656
+ if (typeof field2 === "string") {
2657
+ return ramda.prop(field2, chain);
2658
+ }
2659
+ return chain;
1983
2660
  },
1984
- [data]
2661
+ [chains, map.current]
1985
2662
  );
1986
- return [chains, { findByChainId }];
2663
+ return [
2664
+ chains,
2665
+ {
2666
+ findByChainId,
2667
+ // findNativeTokenByChainId,
2668
+ error: swapSupportError || tokenError
2669
+ // nativeToken,
2670
+ }
2671
+ ];
1987
2672
  };
1988
2673
  var useChain = (token) => {
1989
2674
  const { data, isLoading } = useQuery("/v1/public/token");
@@ -1993,11 +2678,11 @@ var useChain = (token) => {
1993
2678
  let item = data.find((chain) => chain.token === token);
1994
2679
  if (item) {
1995
2680
  item.chain_details = item.chain_details.map((d) => {
1996
- var _a;
1997
2681
  const chain = types.chainsMap.get(Number(d.chain_id));
1998
- return __spreadProps(__spreadValues({}, d), {
1999
- chain_name: (_a = chain == null ? void 0 : chain.chainName) != null ? _a : "--"
2000
- });
2682
+ return {
2683
+ ...d,
2684
+ chain_name: chain?.chainName ?? "--"
2685
+ };
2001
2686
  });
2002
2687
  }
2003
2688
  return item || null;
@@ -2019,49 +2704,122 @@ var useWithdraw = () => {
2019
2704
  );
2020
2705
  const { usdc } = useHoldingStream();
2021
2706
  const maxAmount = React2.useMemo(() => {
2022
- var _a;
2023
2707
  if (!usdc || !usdc.holding)
2024
2708
  return 0;
2025
2709
  if (unsettledPnL >= 0)
2026
- return (_a = usdc == null ? void 0 : usdc.holding) != null ? _a : 0;
2710
+ return usdc?.holding ?? 0;
2027
2711
  return new utils.Decimal(usdc.holding).add(unsettledPnL).toNumber();
2028
2712
  }, [usdc, unsettledPnL]);
2029
2713
  return { withdraw, isLoading, maxAmount, availableBalance, unsettledPnL };
2030
2714
  };
2031
- var useDeposit = () => {
2715
+ var isNativeTokenChecker = (address) => address === nativeTokenAddress;
2716
+ var useDeposit = (options) => {
2717
+ const [balanceRevalidating, setBalanceRevalidating] = React2.useState(false);
2718
+ const [allowanceRevalidating, setAllowanceRevalidating] = React2.useState(false);
2032
2719
  const [balance, setBalance] = React2.useState("0");
2033
2720
  const [allowance, setAllowance] = React2.useState("0");
2034
2721
  const { account: account5, state } = useAccount();
2035
- const fetchBalance = React2.useCallback(() => __async(void 0, null, function* () {
2036
- const balance2 = yield account5.assetsManager.getBalance();
2037
- setBalance(() => balance2);
2038
- }), [state]);
2039
- const fetchAllowance = React2.useCallback(() => __async(void 0, null, function* () {
2040
- const allowance2 = yield account5.assetsManager.getAllowance();
2041
- setAllowance(() => allowance2);
2042
- return allowance2;
2043
- }), []);
2722
+ const dst = React2.useMemo(() => {
2723
+ return {
2724
+ symbol: "USDC",
2725
+ address: "",
2726
+ decimals: 6,
2727
+ // chainId: 421613,
2728
+ network: "Arbitrum Goerli",
2729
+ chainId: 42161
2730
+ };
2731
+ }, []);
2732
+ const isNativeToken = React2.useMemo(
2733
+ () => isNativeTokenChecker(options?.address || ""),
2734
+ [options?.address]
2735
+ );
2736
+ const fetchBalanceHandler = React2.useCallback(
2737
+ async (address, decimals) => {
2738
+ let balance2;
2739
+ if (!!address && isNativeTokenChecker(address)) {
2740
+ balance2 = await account5.assetsManager.getNativeBalance({
2741
+ decimals
2742
+ });
2743
+ } else {
2744
+ balance2 = await account5.assetsManager.getBalance(address);
2745
+ }
2746
+ return balance2;
2747
+ },
2748
+ []
2749
+ );
2750
+ const fetchBalance = React2.useCallback(
2751
+ async (address) => {
2752
+ if (!address)
2753
+ return;
2754
+ try {
2755
+ if (balanceRevalidating)
2756
+ return;
2757
+ setBalanceRevalidating(true);
2758
+ const balance2 = await fetchBalanceHandler(address);
2759
+ console.log("----- refresh balance -----", balance2);
2760
+ setBalance(() => balance2);
2761
+ setBalanceRevalidating(false);
2762
+ } catch (e) {
2763
+ console.warn("----- refresh balance error -----", e);
2764
+ setBalanceRevalidating(false);
2765
+ setBalance(() => "0");
2766
+ }
2767
+ },
2768
+ [state, balanceRevalidating]
2769
+ );
2770
+ const fetchBalances = React2.useCallback(async (tokens) => {
2771
+ const tasks = [];
2772
+ console.log("fetch balances ---->>>>", tokens);
2773
+ for (const token of tokens) {
2774
+ if (isNativeTokenChecker(token.address)) {
2775
+ continue;
2776
+ }
2777
+ tasks.push(account5.assetsManager.getBalanceByAddress(token.address));
2778
+ }
2779
+ const balances = await Promise.all(tasks);
2780
+ console.log("----- get balances from tokens -----", balances);
2781
+ }, []);
2782
+ const fetchAllowance = React2.useCallback(
2783
+ async (address) => {
2784
+ if (!address)
2785
+ return;
2786
+ if (address && isNativeTokenChecker(address))
2787
+ return;
2788
+ if (allowanceRevalidating)
2789
+ return;
2790
+ setAllowanceRevalidating(true);
2791
+ const allowance2 = await account5.assetsManager.getAllowance(address);
2792
+ console.log("----- refresh allowance -----", allowance2);
2793
+ setAllowance(() => allowance2);
2794
+ setAllowanceRevalidating(false);
2795
+ return allowance2;
2796
+ },
2797
+ [allowanceRevalidating]
2798
+ );
2044
2799
  React2.useEffect(() => {
2800
+ console.log("useDeposit useEffect", state.status, options?.address);
2045
2801
  if (state.status < types.AccountStatusEnum.EnableTrading)
2046
2802
  return;
2047
- fetchBalance();
2048
- fetchAllowance();
2049
- }, [state]);
2803
+ fetchBalance(options?.address);
2804
+ fetchAllowance(options?.address);
2805
+ }, [state.status, options?.address]);
2050
2806
  const approve = React2.useCallback(
2051
2807
  (amount) => {
2052
- return account5.assetsManager.approve(amount).then((result) => {
2808
+ if (!options?.address) {
2809
+ throw new Error("address is required");
2810
+ }
2811
+ return account5.assetsManager.approve(options.address, amount).then((result) => {
2053
2812
  if (typeof amount !== "undefined") {
2054
2813
  setAllowance((value) => new utils.Decimal(value).add(amount).toString());
2055
2814
  }
2056
2815
  return result;
2057
2816
  });
2058
2817
  },
2059
- [account5, fetchAllowance]
2818
+ [account5, fetchAllowance, options?.address]
2060
2819
  );
2061
2820
  const deposit = React2.useCallback(
2062
2821
  (amount) => {
2063
2822
  return account5.assetsManager.deposit(amount).then((res) => {
2064
- console.log("----- deposit -----", res);
2065
2823
  setAllowance((value) => new utils.Decimal(value).sub(amount).toString());
2066
2824
  setBalance((value) => new utils.Decimal(value).sub(amount).toString());
2067
2825
  return res;
@@ -2070,10 +2828,16 @@ var useDeposit = () => {
2070
2828
  [account5, fetchBalance, fetchAllowance]
2071
2829
  );
2072
2830
  return {
2831
+ dst,
2073
2832
  balance,
2074
2833
  allowance,
2834
+ isNativeToken,
2835
+ balanceRevalidating,
2836
+ allowanceRevalidating,
2075
2837
  approve,
2076
- deposit
2838
+ deposit,
2839
+ fetchBalances,
2840
+ fetchBalance: fetchBalanceHandler
2077
2841
  };
2078
2842
  };
2079
2843
  var useWalletSubscription = (options) => {
@@ -2088,8 +2852,7 @@ var useWalletSubscription = (options) => {
2088
2852
  },
2089
2853
  {
2090
2854
  onMessage: (data) => {
2091
- var _a;
2092
- (_a = options == null ? void 0 : options.onMessage) == null ? void 0 : _a.call(options, data);
2855
+ options?.onMessage?.(data);
2093
2856
  next(data);
2094
2857
  }
2095
2858
  }
@@ -2125,12 +2888,13 @@ var usePrivateDataObserver = () => {
2125
2888
  }
2126
2889
  if (data.status === types.OrderStatus.NEW) {
2127
2890
  return [
2128
- __spreadProps(__spreadValues({}, data), {
2891
+ {
2892
+ ...data,
2129
2893
  // average_executed_price:data.ava
2130
2894
  created_time: data.timestamp,
2131
2895
  order_id: data.orderId
2132
2896
  // reduce_only
2133
- }),
2897
+ },
2134
2898
  ...orders
2135
2899
  ];
2136
2900
  }
@@ -2147,7 +2911,7 @@ var usePrivateDataObserver = () => {
2147
2911
  ee.emit("orders:changed");
2148
2912
  }
2149
2913
  });
2150
- return () => unsubscribe == null ? void 0 : unsubscribe();
2914
+ return () => unsubscribe?.();
2151
2915
  }, [state.accountId]);
2152
2916
  React2.useEffect(() => {
2153
2917
  console.log("subscribe: position: %s", state.accountId);
@@ -2159,7 +2923,8 @@ var usePrivateDataObserver = () => {
2159
2923
  const { positions: nextPostions } = data;
2160
2924
  mutate2(key, (prevPositions) => {
2161
2925
  if (!!prevPositions) {
2162
- return __spreadProps(__spreadValues({}, prevPositions), {
2926
+ return {
2927
+ ...prevPositions,
2163
2928
  rows: prevPositions.rows.map((row) => {
2164
2929
  const item = nextPostions.find(
2165
2930
  (item2) => item2.symbol === row.symbol
@@ -2188,14 +2953,14 @@ var usePrivateDataObserver = () => {
2188
2953
  }
2189
2954
  return row;
2190
2955
  })
2191
- });
2956
+ };
2192
2957
  }
2193
2958
  });
2194
2959
  }
2195
2960
  });
2196
2961
  return () => {
2197
2962
  console.log("unsubscribe: private subscription position");
2198
- unsubscribe == null ? void 0 : unsubscribe();
2963
+ unsubscribe?.();
2199
2964
  };
2200
2965
  }, [state.accountId]);
2201
2966
  };
@@ -2239,6 +3004,523 @@ var useFundingRateBySymbol = (symbol) => {
2239
3004
  }
2240
3005
  return useQuery(`/public/funding_rate/${symbol}`);
2241
3006
  };
3007
+ var useWooSwapQuery = () => {
3008
+ const { configStore } = React2.useContext(OrderlyContext);
3009
+ const account5 = useAccountInstance();
3010
+ const [loading, { setTrue: start, setFalse: stop }] = useBoolean(false);
3011
+ const query = React2.useCallback(
3012
+ (inputs) => {
3013
+ console.log("inputs", inputs);
3014
+ if (loading)
3015
+ return;
3016
+ start();
3017
+ const params = {
3018
+ // src_network: inputs.srcNetwork,
3019
+ network: "arbitrum",
3020
+ from_token: inputs.srcToken,
3021
+ to_token: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
3022
+ //account.assetsManager.usdcAddress,
3023
+ from_amount: inputs.amount,
3024
+ //inputs.amount,
3025
+ slippage: inputs.slippage || 1
3026
+ // to_token:account.assetsManager.usdcAddress,
3027
+ };
3028
+ const queryString = Object.entries(params).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
3029
+ return fetch(
3030
+ `${configStore.get("swapSupportApiUrl")}/woofi_dex/swap?${queryString}`
3031
+ ).then((res) => {
3032
+ if (!res.ok) {
3033
+ return res.json().then((data) => {
3034
+ throw new Error(data.error.message);
3035
+ });
3036
+ }
3037
+ return res.json();
3038
+ }).then((data) => {
3039
+ if (data.status === "ok") {
3040
+ return data.data;
3041
+ }
3042
+ throw new Error(data.message);
3043
+ }).finally(() => stop());
3044
+ },
3045
+ [account5]
3046
+ );
3047
+ return {
3048
+ query,
3049
+ loading: false
3050
+ };
3051
+ };
3052
+ var useWooCrossSwapQuery = () => {
3053
+ const { configStore } = React2.useContext(OrderlyContext);
3054
+ const [loading, { setTrue: start, setFalse: stop }] = useBoolean(false);
3055
+ const account5 = useAccountInstance();
3056
+ const dstValutDeposit = React2.useCallback(() => {
3057
+ return {
3058
+ accountId: account5.accountIdHashStr,
3059
+ brokerHash: core.utils.parseBrokerHash(configStore.get("brokerId")),
3060
+ tokenHash: core.utils.parseTokenHash("USDC")
3061
+ };
3062
+ }, [account5]);
3063
+ const queryDestinationFee = React2.useCallback(
3064
+ async (dst) => {
3065
+ if (!account5.walletClient) {
3066
+ throw new Error("walletClient is not ready");
3067
+ }
3068
+ const quotoLZFee = await account5.walletClient.call(
3069
+ "0xC7498b7e7C9845b4B2556f2a4B7Cad2B7F2C0dC4",
3070
+ "quoteLayerZeroFee",
3071
+ [account5.address, dst, dstValutDeposit()],
3072
+ {
3073
+ abi: woofiDexCrossChainRouterAbi
3074
+ }
3075
+ );
3076
+ return core.utils.formatByUnits(quotoLZFee[0]);
3077
+ },
3078
+ []
3079
+ );
3080
+ const query = React2.useCallback(
3081
+ (inputs) => {
3082
+ if (loading)
3083
+ return;
3084
+ start();
3085
+ const params = {
3086
+ // src_network: inputs.srcNetwork,
3087
+ src_network: "base",
3088
+ dst_network: "arbitrum",
3089
+ src_token: inputs.srcToken,
3090
+ dst_token: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
3091
+ //account.assetsManager.usdcAddress,
3092
+ src_amount: inputs.amount,
3093
+ //inputs.amount,
3094
+ slippage: inputs.slippage || 1
3095
+ // to_token:account.assetsManager.usdcAddress,
3096
+ };
3097
+ const queryString = Object.entries(params).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&");
3098
+ return fetch(
3099
+ `${configStore.get(
3100
+ "swapSupportApiUrl"
3101
+ )}/woofi_dex/cross_chain_swap?${queryString}`
3102
+ ).then((res) => {
3103
+ if (!res.ok) {
3104
+ return res.json().then((data) => {
3105
+ throw new Error(data.error.message);
3106
+ });
3107
+ }
3108
+ return res.json();
3109
+ }).then((data) => {
3110
+ if (data.status === "ok") {
3111
+ return data.data;
3112
+ }
3113
+ throw new Error(data.message);
3114
+ }).then((swapInfo) => {
3115
+ return queryDestinationFee({
3116
+ chainId: swapInfo.dst_infos.chain_id,
3117
+ bridgedToken: swapInfo.dst_infos.bridged_token,
3118
+ toToken: swapInfo.dst_infos.to_token,
3119
+ minToAmount: BigInt(swapInfo.dst_infos.min_to_amount),
3120
+ airdropNativeAmount: 0n
3121
+ }).then((data) => {
3122
+ console.log("res::::", data);
3123
+ return {
3124
+ ...swapInfo,
3125
+ dst_infos: {
3126
+ ...swapInfo.dst_infos,
3127
+ gas_fee: data
3128
+ }
3129
+ };
3130
+ });
3131
+ }).finally(() => stop());
3132
+ },
3133
+ [loading, account5]
3134
+ );
3135
+ return {
3136
+ query,
3137
+ loading
3138
+ };
3139
+ };
3140
+ var useCrossSwap = () => {
3141
+ const [loading, { setTrue: start, setFalse: stop }] = useBoolean(false);
3142
+ const [layerStatus, setLayerStatus] = React2.useState(
3143
+ "WAITTING" /* INITIALIZING */
3144
+ );
3145
+ const [bridgeMessage, setBridgeMessage] = React2.useState();
3146
+ const account5 = useAccountInstance();
3147
+ const { networkId, configStore } = React2.useContext(OrderlyContext);
3148
+ const client = React2.useRef(scanClient.createClient(networkId)).current;
3149
+ const timer = React2.useRef();
3150
+ const checkLayerStatus = React2.useCallback((txHash) => {
3151
+ const check = async (txHash2) => {
3152
+ const { messages } = await client.getMessagesBySrcTxHash(txHash2);
3153
+ console.log("messages:", messages);
3154
+ if (messages.length > 0) {
3155
+ const { status } = messages[0];
3156
+ if (status === "INFLIGHT" /* INFLIGHT */) {
3157
+ setTimeout(() => {
3158
+ check(txHash2);
3159
+ }, 1e3);
3160
+ }
3161
+ setLayerStatus(status);
3162
+ if (status === "DELIVERED" /* DELIVERED */) {
3163
+ setBridgeMessage(messages[0]);
3164
+ }
3165
+ } else {
3166
+ setTimeout(() => {
3167
+ check(txHash2);
3168
+ }, 1e3);
3169
+ }
3170
+ };
3171
+ check(txHash);
3172
+ }, []);
3173
+ React2.useEffect(() => {
3174
+ return () => {
3175
+ if (timer.current) {
3176
+ clearTimeout(timer.current);
3177
+ }
3178
+ };
3179
+ }, []);
3180
+ const dstValutDeposit = React2.useCallback(() => {
3181
+ return {
3182
+ accountId: account5.accountIdHashStr,
3183
+ brokerHash: core.utils.parseBrokerHash(configStore.get("brokerId")),
3184
+ tokenHash: core.utils.parseTokenHash("USDC")
3185
+ };
3186
+ }, [account5]);
3187
+ const swap = async (inputs) => {
3188
+ if (!account5.walletClient) {
3189
+ throw new Error("walletClient is undefined");
3190
+ }
3191
+ const { address, src, dst } = inputs;
3192
+ if (loading)
3193
+ return;
3194
+ start();
3195
+ const quotoLZFee = await account5.walletClient.call(
3196
+ "0xC7498b7e7C9845b4B2556f2a4B7Cad2B7F2C0dC4",
3197
+ "quoteLayerZeroFee",
3198
+ [account5.address, dst, dstValutDeposit()],
3199
+ {
3200
+ abi: woofiDexCrossChainRouterAbi
3201
+ }
3202
+ );
3203
+ const result = await account5.walletClient.call(
3204
+ "0xC7498b7e7C9845b4B2556f2a4B7Cad2B7F2C0dC4",
3205
+ "crossSwap",
3206
+ [
3207
+ account5.address,
3208
+ src,
3209
+ dst,
3210
+ dstValutDeposit(),
3211
+ {
3212
+ value: quotoLZFee[0]
3213
+ }
3214
+ ],
3215
+ {
3216
+ abi: woofiDexCrossChainRouterAbi
3217
+ }
3218
+ );
3219
+ account5.walletClient.on(
3220
+ {
3221
+ address: "0xC7498b7e7C9845b4B2556f2a4B7Cad2B7F2C0dC4"
3222
+ },
3223
+ (log, event) => {
3224
+ console.log("-------------", log, event);
3225
+ }
3226
+ );
3227
+ stop();
3228
+ checkLayerStatus(result.hash);
3229
+ return ramda.pick(["from", "to", "hash", "value"], result);
3230
+ };
3231
+ return {
3232
+ swap,
3233
+ loading,
3234
+ status: layerStatus,
3235
+ message: bridgeMessage
3236
+ };
3237
+ };
3238
+ var woofiDexDepositor = "0xfD7ed9D3d4fD88595AF6a87f798ffDB42b4D7ccB";
3239
+ var woofiDexDepositorAbi = [
3240
+ {
3241
+ inputs: [
3242
+ { internalType: "address", name: "_weth", type: "address" },
3243
+ { internalType: "address", name: "_wooRouter", type: "address" }
3244
+ ],
3245
+ stateMutability: "nonpayable",
3246
+ type: "constructor"
3247
+ },
3248
+ {
3249
+ anonymous: false,
3250
+ inputs: [
3251
+ {
3252
+ indexed: true,
3253
+ internalType: "address",
3254
+ name: "previousOwner",
3255
+ type: "address"
3256
+ },
3257
+ {
3258
+ indexed: true,
3259
+ internalType: "address",
3260
+ name: "newOwner",
3261
+ type: "address"
3262
+ }
3263
+ ],
3264
+ name: "OwnershipTransferred",
3265
+ type: "event"
3266
+ },
3267
+ {
3268
+ anonymous: false,
3269
+ inputs: [
3270
+ {
3271
+ indexed: false,
3272
+ internalType: "address",
3273
+ name: "account",
3274
+ type: "address"
3275
+ }
3276
+ ],
3277
+ name: "Paused",
3278
+ type: "event"
3279
+ },
3280
+ {
3281
+ anonymous: false,
3282
+ inputs: [
3283
+ {
3284
+ indexed: false,
3285
+ internalType: "address",
3286
+ name: "account",
3287
+ type: "address"
3288
+ }
3289
+ ],
3290
+ name: "Unpaused",
3291
+ type: "event"
3292
+ },
3293
+ {
3294
+ anonymous: false,
3295
+ inputs: [
3296
+ {
3297
+ indexed: true,
3298
+ internalType: "address",
3299
+ name: "sender",
3300
+ type: "address"
3301
+ },
3302
+ { indexed: true, internalType: "address", name: "to", type: "address" },
3303
+ {
3304
+ indexed: false,
3305
+ internalType: "address",
3306
+ name: "fromToken",
3307
+ type: "address"
3308
+ },
3309
+ {
3310
+ indexed: false,
3311
+ internalType: "uint256",
3312
+ name: "fromAmount",
3313
+ type: "uint256"
3314
+ },
3315
+ {
3316
+ indexed: false,
3317
+ internalType: "address",
3318
+ name: "toToken",
3319
+ type: "address"
3320
+ },
3321
+ {
3322
+ indexed: false,
3323
+ internalType: "uint256",
3324
+ name: "minToAmount",
3325
+ type: "uint256"
3326
+ },
3327
+ {
3328
+ indexed: false,
3329
+ internalType: "uint256",
3330
+ name: "toAmount",
3331
+ type: "uint256"
3332
+ },
3333
+ {
3334
+ indexed: false,
3335
+ internalType: "bytes32",
3336
+ name: "accountId",
3337
+ type: "bytes32"
3338
+ },
3339
+ {
3340
+ indexed: false,
3341
+ internalType: "bytes32",
3342
+ name: "brokerHash",
3343
+ type: "bytes32"
3344
+ },
3345
+ {
3346
+ indexed: false,
3347
+ internalType: "bytes32",
3348
+ name: "tokenHash",
3349
+ type: "bytes32"
3350
+ },
3351
+ {
3352
+ indexed: false,
3353
+ internalType: "uint128",
3354
+ name: "tokenAmount",
3355
+ type: "uint128"
3356
+ }
3357
+ ],
3358
+ name: "WOOFiDexSwap",
3359
+ type: "event"
3360
+ },
3361
+ {
3362
+ inputs: [],
3363
+ name: "NATIVE_PLACEHOLDER",
3364
+ outputs: [{ internalType: "address", name: "", type: "address" }],
3365
+ stateMutability: "view",
3366
+ type: "function"
3367
+ },
3368
+ {
3369
+ inputs: [{ internalType: "address", name: "stuckToken", type: "address" }],
3370
+ name: "inCaseTokenGotStuck",
3371
+ outputs: [],
3372
+ stateMutability: "nonpayable",
3373
+ type: "function"
3374
+ },
3375
+ {
3376
+ inputs: [],
3377
+ name: "owner",
3378
+ outputs: [{ internalType: "address", name: "", type: "address" }],
3379
+ stateMutability: "view",
3380
+ type: "function"
3381
+ },
3382
+ {
3383
+ inputs: [],
3384
+ name: "pause",
3385
+ outputs: [],
3386
+ stateMutability: "nonpayable",
3387
+ type: "function"
3388
+ },
3389
+ {
3390
+ inputs: [],
3391
+ name: "paused",
3392
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
3393
+ stateMutability: "view",
3394
+ type: "function"
3395
+ },
3396
+ {
3397
+ inputs: [],
3398
+ name: "renounceOwnership",
3399
+ outputs: [],
3400
+ stateMutability: "nonpayable",
3401
+ type: "function"
3402
+ },
3403
+ {
3404
+ inputs: [
3405
+ { internalType: "address", name: "token", type: "address" },
3406
+ { internalType: "address", name: "woofiDexVault", type: "address" }
3407
+ ],
3408
+ name: "setWOOFiDexVault",
3409
+ outputs: [],
3410
+ stateMutability: "nonpayable",
3411
+ type: "function"
3412
+ },
3413
+ {
3414
+ inputs: [{ internalType: "address", name: "_wooRouter", type: "address" }],
3415
+ name: "setWooRouter",
3416
+ outputs: [],
3417
+ stateMutability: "nonpayable",
3418
+ type: "function"
3419
+ },
3420
+ {
3421
+ inputs: [
3422
+ { internalType: "address payable", name: "to", type: "address" },
3423
+ {
3424
+ components: [
3425
+ { internalType: "address", name: "fromToken", type: "address" },
3426
+ { internalType: "uint256", name: "fromAmount", type: "uint256" },
3427
+ { internalType: "address", name: "toToken", type: "address" },
3428
+ { internalType: "uint256", name: "minToAmount", type: "uint256" }
3429
+ ],
3430
+ internalType: "struct IWOOFiDexRouter.Infos",
3431
+ name: "infos",
3432
+ type: "tuple"
3433
+ },
3434
+ {
3435
+ components: [
3436
+ { internalType: "bytes32", name: "accountId", type: "bytes32" },
3437
+ { internalType: "bytes32", name: "brokerHash", type: "bytes32" },
3438
+ { internalType: "bytes32", name: "tokenHash", type: "bytes32" }
3439
+ ],
3440
+ internalType: "struct IWOOFiDexRouter.VaultDeposit",
3441
+ name: "vaultDeposit",
3442
+ type: "tuple"
3443
+ }
3444
+ ],
3445
+ name: "swap",
3446
+ outputs: [],
3447
+ stateMutability: "payable",
3448
+ type: "function"
3449
+ },
3450
+ {
3451
+ inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
3452
+ name: "transferOwnership",
3453
+ outputs: [],
3454
+ stateMutability: "nonpayable",
3455
+ type: "function"
3456
+ },
3457
+ {
3458
+ inputs: [],
3459
+ name: "unpause",
3460
+ outputs: [],
3461
+ stateMutability: "nonpayable",
3462
+ type: "function"
3463
+ },
3464
+ {
3465
+ inputs: [],
3466
+ name: "weth",
3467
+ outputs: [{ internalType: "address", name: "", type: "address" }],
3468
+ stateMutability: "view",
3469
+ type: "function"
3470
+ },
3471
+ {
3472
+ inputs: [],
3473
+ name: "wooRouter",
3474
+ outputs: [
3475
+ { internalType: "contract IWooRouterV2", name: "", type: "address" }
3476
+ ],
3477
+ stateMutability: "view",
3478
+ type: "function"
3479
+ },
3480
+ {
3481
+ inputs: [{ internalType: "address", name: "", type: "address" }],
3482
+ name: "woofiDexVaults",
3483
+ outputs: [{ internalType: "address", name: "", type: "address" }],
3484
+ stateMutability: "view",
3485
+ type: "function"
3486
+ },
3487
+ { stateMutability: "payable", type: "receive" }
3488
+ ];
3489
+ var useSwap = () => {
3490
+ const [loading, { setTrue: start, setFalse: stop }] = useBoolean(false);
3491
+ const account5 = useAccountInstance();
3492
+ const { configStore } = React2.useContext(OrderlyContext);
3493
+ const dstValutDeposit = React2.useCallback(() => {
3494
+ return {
3495
+ accountId: account5.accountIdHashStr,
3496
+ brokerHash: core.utils.parseBrokerHash(configStore.get("brokerId")),
3497
+ tokenHash: core.utils.parseTokenHash("USDC")
3498
+ };
3499
+ }, [account5]);
3500
+ const swap = React2.useCallback(
3501
+ async (inputs) => {
3502
+ if (loading)
3503
+ return;
3504
+ start();
3505
+ const result = await account5.walletClient.call(
3506
+ woofiDexDepositor,
3507
+ "swap",
3508
+ [account5.address, inputs, dstValutDeposit()],
3509
+ {
3510
+ abi: woofiDexDepositorAbi
3511
+ }
3512
+ );
3513
+ console.log("swap result::::::", result);
3514
+ stop();
3515
+ return ramda.pick(["from", "to", "hash", "value"], result);
3516
+ },
3517
+ [loading, account5]
3518
+ );
3519
+ return {
3520
+ swap,
3521
+ loading
3522
+ };
3523
+ };
2242
3524
 
2243
3525
  Object.defineProperty(exports, 'SWRConfig', {
2244
3526
  enumerable: true,
@@ -2262,16 +3544,19 @@ exports.useAccountInfo = useAccountInfo;
2262
3544
  exports.useAccountInstance = useAccountInstance;
2263
3545
  exports.useAppState = useAppState;
2264
3546
  exports.useBalance = useBalance;
3547
+ exports.useBoolean = useBoolean;
2265
3548
  exports.useChain = useChain;
2266
3549
  exports.useChains = useChains;
2267
3550
  exports.useCollateral = useCollateral;
2268
3551
  exports.useConfig = useConfig;
3552
+ exports.useCrossSwap = useCrossSwap;
2269
3553
  exports.useDeposit = useDeposit;
2270
3554
  exports.useEventEmitter = useEventEmitter;
2271
3555
  exports.useExecutionReport = useExecutionReport;
2272
3556
  exports.useFetures = useFetures;
2273
3557
  exports.useFundingRate = useFundingRate;
2274
3558
  exports.useHoldingStream = useHoldingStream;
3559
+ exports.useLazyQuery = useLazyQuery;
2275
3560
  exports.useLeverage = useLeverage;
2276
3561
  exports.useLocalStorage = useLocalStorage;
2277
3562
  exports.useMarginRatio = useMarginRatio;
@@ -2292,6 +3577,7 @@ exports.usePrivateQuery = usePrivateQuery;
2292
3577
  exports.useQuery = useQuery;
2293
3578
  exports.useRunOnce = useRunOnce;
2294
3579
  exports.useSessionStorage = useSessionStorage;
3580
+ exports.useSwap = useSwap;
2295
3581
  exports.useSymbolsInfo = useSymbolsInfo;
2296
3582
  exports.useTickerStream = useTickerStream;
2297
3583
  exports.useTokenInfo = useTokenInfo;
@@ -2300,5 +3586,13 @@ exports.useTradingView = useTradingView;
2300
3586
  exports.useWS = useWS;
2301
3587
  exports.useWalletSubscription = useWalletSubscription;
2302
3588
  exports.useWithdraw = useWithdraw;
3589
+ exports.useWooCrossSwapQuery = useWooCrossSwapQuery;
3590
+ exports.useWooSwapQuery = useWooSwapQuery;
3591
+ Object.keys(useDebounce).forEach(function (k) {
3592
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
3593
+ enumerable: true,
3594
+ get: function () { return useDebounce[k]; }
3595
+ });
3596
+ });
2303
3597
  //# sourceMappingURL=out.js.map
2304
3598
  //# sourceMappingURL=index.js.map