@orderly.network/hooks 0.0.54 → 0.0.56
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.d.mts +78 -3
- package/dist/index.d.ts +78 -3
- package/dist/index.js +1425 -242
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1416 -245
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -12
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 prop3 in b || (b = {}))
|
|
34
|
-
if (__hasOwnProp.call(b, prop3))
|
|
35
|
-
__defNormalProp(a, prop3, b[prop3]);
|
|
36
|
-
if (__getOwnPropSymbols)
|
|
37
|
-
for (var prop3 of __getOwnPropSymbols(b)) {
|
|
38
|
-
if (__propIsEnum.call(b, prop3))
|
|
39
|
-
__defNormalProp(a, prop3, b[prop3]);
|
|
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 prop3 in source)
|
|
47
|
-
if (__hasOwnProp.call(source, prop3) && exclude.indexOf(prop3) < 0)
|
|
48
|
-
target[prop3] = source[prop3];
|
|
49
|
-
if (source != null && __getOwnPropSymbols)
|
|
50
|
-
for (var prop3 of __getOwnPropSymbols(source)) {
|
|
51
|
-
if (exclude.indexOf(prop3) < 0 && __propIsEnum.call(source, prop3))
|
|
52
|
-
target[prop3] = source[prop3];
|
|
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
|
|
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
|
|
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:
|
|
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) =>
|
|
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 =
|
|
146
|
+
const signature = await signer.sign(payload);
|
|
169
147
|
return trigger({
|
|
170
148
|
data: data2,
|
|
171
149
|
params,
|
|
172
150
|
method,
|
|
173
|
-
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) =>
|
|
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 =
|
|
180
|
+
const signature = await signer.sign(payload);
|
|
202
181
|
return fetcher4(fullUrl, {
|
|
203
|
-
headers:
|
|
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) =>
|
|
228
|
+
async (remember) => {
|
|
249
229
|
return account5.createOrderlyKey(remember ? 365 : 30);
|
|
250
|
-
}
|
|
230
|
+
},
|
|
251
231
|
[account5]
|
|
252
232
|
);
|
|
253
|
-
const createAccount = React2.useCallback(() =>
|
|
233
|
+
const createAccount = React2.useCallback(async () => {
|
|
254
234
|
return account5.createAccount();
|
|
255
|
-
}
|
|
256
|
-
const connect = React2.useCallback(() =>
|
|
257
|
-
return onWalletConnect
|
|
258
|
-
}
|
|
259
|
-
const disconnect = () =>
|
|
260
|
-
return onWalletDisconnect
|
|
261
|
-
}
|
|
262
|
-
const setChain = (chainId) =>
|
|
263
|
-
return onSetChain
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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 = () => {
|
|
@@ -361,8 +348,8 @@ var useEventEmitter = (channel) => {
|
|
|
361
348
|
// src/utils/json.ts
|
|
362
349
|
function parseJSON(value) {
|
|
363
350
|
try {
|
|
364
|
-
return value === "undefined" ? void 0 : JSON.parse(value
|
|
365
|
-
} catch
|
|
351
|
+
return value === "undefined" ? void 0 : JSON.parse(value ?? "");
|
|
352
|
+
} catch {
|
|
366
353
|
console.log("parsing error on", { value });
|
|
367
354
|
return void 0;
|
|
368
355
|
}
|
|
@@ -411,7 +398,7 @@ function useSessionStorage(key, initialValue) {
|
|
|
411
398
|
});
|
|
412
399
|
const handleStorageChange = React2.useCallback(
|
|
413
400
|
(event) => {
|
|
414
|
-
if (
|
|
401
|
+
if (event?.key && event.key !== key) {
|
|
415
402
|
return;
|
|
416
403
|
}
|
|
417
404
|
setStoredValue(readValue());
|
|
@@ -491,12 +478,12 @@ var useWS = () => {
|
|
|
491
478
|
networkId: "testnet",
|
|
492
479
|
publicUrl: configStore.get("publicWsUrl"),
|
|
493
480
|
privateUrl: configStore.get("privateWsUrl"),
|
|
494
|
-
onSigntureRequest: (accountId) =>
|
|
481
|
+
onSigntureRequest: async (accountId) => {
|
|
495
482
|
const signer = account5.signer;
|
|
496
483
|
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
497
|
-
const result =
|
|
498
|
-
return
|
|
499
|
-
}
|
|
484
|
+
const result = await signer.signText(timestamp.toString());
|
|
485
|
+
return { ...result, timestamp };
|
|
486
|
+
}
|
|
500
487
|
});
|
|
501
488
|
account5.on("change:status", (nextState) => {
|
|
502
489
|
if (nextState.status === types.AccountStatusEnum.EnableTrading && nextState.accountId) {
|
|
@@ -544,7 +531,7 @@ var useTickerStream = (symbol) => {
|
|
|
544
531
|
);
|
|
545
532
|
return () => {
|
|
546
533
|
console.log("unsubscribe!!!!!!!");
|
|
547
|
-
unsubscribe
|
|
534
|
+
unsubscribe?.();
|
|
548
535
|
};
|
|
549
536
|
}
|
|
550
537
|
);
|
|
@@ -553,7 +540,7 @@ var useTickerStream = (symbol) => {
|
|
|
553
540
|
return null;
|
|
554
541
|
if (!ticker)
|
|
555
542
|
return info;
|
|
556
|
-
const config =
|
|
543
|
+
const config = { ...info };
|
|
557
544
|
if (ticker.close !== void 0) {
|
|
558
545
|
config["24h_close"] = ticker.close;
|
|
559
546
|
}
|
|
@@ -580,7 +567,7 @@ var useMarkPrice = (symbol) => {
|
|
|
580
567
|
});
|
|
581
568
|
return () => {
|
|
582
569
|
console.log("unsubscribe useMarkPrice !!!!!!!");
|
|
583
|
-
unsubscribe
|
|
570
|
+
unsubscribe?.();
|
|
584
571
|
};
|
|
585
572
|
});
|
|
586
573
|
};
|
|
@@ -591,16 +578,14 @@ function createGetter(data, depth = 2) {
|
|
|
591
578
|
get(target, property, receiver) {
|
|
592
579
|
if (depth === 1) {
|
|
593
580
|
return (defaultValue) => {
|
|
594
|
-
var _a;
|
|
595
581
|
if (!target)
|
|
596
582
|
return defaultValue;
|
|
597
|
-
return
|
|
583
|
+
return target[property] ?? defaultValue;
|
|
598
584
|
};
|
|
599
585
|
}
|
|
600
586
|
return (key, defaultValue) => {
|
|
601
|
-
var _a, _b;
|
|
602
587
|
if (key) {
|
|
603
|
-
return
|
|
588
|
+
return target[property]?.[key] ?? defaultValue;
|
|
604
589
|
} else {
|
|
605
590
|
return target[property];
|
|
606
591
|
}
|
|
@@ -614,8 +599,7 @@ var useSymbolsInfo = () => {
|
|
|
614
599
|
dedupingInterval: 1e3 * 60 * 60 * 24,
|
|
615
600
|
revalidateOnFocus: false,
|
|
616
601
|
formatter(data2) {
|
|
617
|
-
|
|
618
|
-
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) {
|
|
619
603
|
return {};
|
|
620
604
|
}
|
|
621
605
|
const obj = /* @__PURE__ */ Object.create(null);
|
|
@@ -624,14 +608,15 @@ var useSymbolsInfo = () => {
|
|
|
624
608
|
const arr = item.symbol.split("_");
|
|
625
609
|
const base_dp = utils.getPrecisionByNumber(item.base_tick);
|
|
626
610
|
const quote_dp = utils.getPrecisionByNumber(item.quote_tick);
|
|
627
|
-
obj[item.symbol] =
|
|
611
|
+
obj[item.symbol] = {
|
|
612
|
+
...item,
|
|
628
613
|
base_dp,
|
|
629
614
|
quote_dp,
|
|
630
615
|
base: arr[1],
|
|
631
616
|
quote: arr[2],
|
|
632
617
|
type: arr[0],
|
|
633
618
|
name: `${arr[1]}-${arr[0]}`
|
|
634
|
-
}
|
|
619
|
+
};
|
|
635
620
|
}
|
|
636
621
|
return obj;
|
|
637
622
|
}
|
|
@@ -724,10 +709,7 @@ var useOrderbookStream = (symbol, initial = { asks: [], bids: [] }, options) =>
|
|
|
724
709
|
const [requestData, setRequestData] = React2.useState(null);
|
|
725
710
|
const [data, setData] = React2.useState(initial);
|
|
726
711
|
const [isLoading, setIsLoading] = React2.useState(true);
|
|
727
|
-
const [level, setLevel] = React2.useState(() =>
|
|
728
|
-
var _a;
|
|
729
|
-
return (_a = options == null ? void 0 : options.level) != null ? _a : 10;
|
|
730
|
-
});
|
|
712
|
+
const [level, setLevel] = React2.useState(() => options?.level ?? 10);
|
|
731
713
|
const config = useSymbolsInfo()[symbol];
|
|
732
714
|
const [depth, setDepth] = React2.useState();
|
|
733
715
|
const depths = React2.useMemo(() => {
|
|
@@ -785,7 +767,7 @@ var useOrderbookStream = (symbol, initial = { asks: [], bids: [] }, options) =>
|
|
|
785
767
|
}
|
|
786
768
|
);
|
|
787
769
|
return () => {
|
|
788
|
-
subscription
|
|
770
|
+
subscription?.();
|
|
789
771
|
};
|
|
790
772
|
}, [symbol, requestData]);
|
|
791
773
|
const onItemClick = React2.useCallback((item) => {
|
|
@@ -829,9 +811,10 @@ function baseInputHandle(inputs) {
|
|
|
829
811
|
value = value.replace(/[^\d.]/g, "");
|
|
830
812
|
}
|
|
831
813
|
return [
|
|
832
|
-
|
|
814
|
+
{
|
|
815
|
+
...values,
|
|
833
816
|
[input]: value
|
|
834
|
-
}
|
|
817
|
+
},
|
|
835
818
|
input,
|
|
836
819
|
value,
|
|
837
820
|
markPrice,
|
|
@@ -847,7 +830,7 @@ function orderEntityFormatHandle(baseTick, quoteTick) {
|
|
|
847
830
|
function priceInputHandle(inputs) {
|
|
848
831
|
const [values, input, value, markPrice, config] = inputs;
|
|
849
832
|
if (value === "") {
|
|
850
|
-
return [
|
|
833
|
+
return [{ ...values, total: "" }, input, value, markPrice, config];
|
|
851
834
|
}
|
|
852
835
|
const price = new utils.Decimal(value);
|
|
853
836
|
const priceDP = price.dp();
|
|
@@ -860,9 +843,10 @@ function priceInputHandle(inputs) {
|
|
|
860
843
|
}
|
|
861
844
|
const total = price.mul(values.order_quantity);
|
|
862
845
|
return [
|
|
863
|
-
|
|
846
|
+
{
|
|
847
|
+
...values,
|
|
864
848
|
total: total.todp(2).toString()
|
|
865
|
-
}
|
|
849
|
+
},
|
|
866
850
|
input,
|
|
867
851
|
value,
|
|
868
852
|
markPrice,
|
|
@@ -872,7 +856,7 @@ function priceInputHandle(inputs) {
|
|
|
872
856
|
function quantityInputHandle(inputs) {
|
|
873
857
|
const [values, input, value, markPrice, config] = inputs;
|
|
874
858
|
if (value === "") {
|
|
875
|
-
return [
|
|
859
|
+
return [{ ...values, total: "" }, input, value, markPrice, config];
|
|
876
860
|
}
|
|
877
861
|
let quantity = new utils.Decimal(value);
|
|
878
862
|
const quantityDP = quantity.dp();
|
|
@@ -894,7 +878,10 @@ function quantityInputHandle(inputs) {
|
|
|
894
878
|
}
|
|
895
879
|
}
|
|
896
880
|
return [
|
|
897
|
-
|
|
881
|
+
{
|
|
882
|
+
...values
|
|
883
|
+
// total: total.todp(2).toNumber(),
|
|
884
|
+
},
|
|
898
885
|
input,
|
|
899
886
|
value,
|
|
900
887
|
markPrice,
|
|
@@ -904,7 +891,7 @@ function quantityInputHandle(inputs) {
|
|
|
904
891
|
function totalInputHandle(inputs) {
|
|
905
892
|
const [values, input, value, markPrice, config] = inputs;
|
|
906
893
|
if (value === "") {
|
|
907
|
-
return [
|
|
894
|
+
return [{ ...values, order_quantity: "" }, input, value, markPrice, config];
|
|
908
895
|
}
|
|
909
896
|
let price = markPrice;
|
|
910
897
|
if (values.order_type === types.OrderType.LIMIT && !!values.order_price) {
|
|
@@ -918,9 +905,10 @@ function totalInputHandle(inputs) {
|
|
|
918
905
|
}
|
|
919
906
|
const quantity = total.div(price);
|
|
920
907
|
return [
|
|
921
|
-
|
|
908
|
+
{
|
|
909
|
+
...values,
|
|
922
910
|
order_quantity: quantity.toDecimalPlaces(Math.min(config.baseDP, quantity.dp())).toNumber()
|
|
923
|
-
}
|
|
911
|
+
},
|
|
924
912
|
input,
|
|
925
913
|
value,
|
|
926
914
|
markPrice,
|
|
@@ -954,8 +942,7 @@ var useFundingRates = () => {
|
|
|
954
942
|
focusThrottleInterval: 1e3 * 60 * 60 * 24,
|
|
955
943
|
revalidateOnFocus: false,
|
|
956
944
|
formatter(data2) {
|
|
957
|
-
|
|
958
|
-
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) {
|
|
959
946
|
return {};
|
|
960
947
|
}
|
|
961
948
|
const obj = /* @__PURE__ */ Object.create(null);
|
|
@@ -994,7 +981,7 @@ var useMarkPricesStream = () => {
|
|
|
994
981
|
);
|
|
995
982
|
return () => {
|
|
996
983
|
console.log("unsubscribe!!!!!!!");
|
|
997
|
-
unsubscribe
|
|
984
|
+
unsubscribe?.();
|
|
998
985
|
};
|
|
999
986
|
});
|
|
1000
987
|
};
|
|
@@ -1004,13 +991,12 @@ var parseHolding = (holding, markPrices) => {
|
|
|
1004
991
|
const nonUSDC = [];
|
|
1005
992
|
let USDC_holding = 0;
|
|
1006
993
|
holding.forEach((item) => {
|
|
1007
|
-
var _a;
|
|
1008
994
|
if (item.token === "USDC") {
|
|
1009
995
|
USDC_holding = item.holding;
|
|
1010
996
|
} else {
|
|
1011
997
|
nonUSDC.push({
|
|
1012
998
|
holding: item.holding,
|
|
1013
|
-
markPrice:
|
|
999
|
+
markPrice: markPrices[item.token] ?? 0,
|
|
1014
1000
|
// markPrice: 0,
|
|
1015
1001
|
discount: 0
|
|
1016
1002
|
});
|
|
@@ -1019,7 +1005,6 @@ var parseHolding = (holding, markPrices) => {
|
|
|
1019
1005
|
return [USDC_holding, nonUSDC];
|
|
1020
1006
|
};
|
|
1021
1007
|
var usePositionStream = (symbol, options) => {
|
|
1022
|
-
var _a;
|
|
1023
1008
|
const symbolInfo = useSymbolsInfo();
|
|
1024
1009
|
useEventEmitter();
|
|
1025
1010
|
const { data: accountInfo } = usePrivateQuery("/v1/client/info");
|
|
@@ -1036,22 +1021,27 @@ var usePositionStream = (symbol, options) => {
|
|
|
1036
1021
|
data,
|
|
1037
1022
|
error
|
|
1038
1023
|
// mutate: updatePositions,
|
|
1039
|
-
} = usePrivateQuery(`/v1/positions`,
|
|
1024
|
+
} = usePrivateQuery(`/v1/positions`, {
|
|
1025
|
+
// revalidateOnFocus: false,
|
|
1026
|
+
// revalidateOnReconnect: false,
|
|
1027
|
+
// dedupingInterval: 100,
|
|
1028
|
+
// keepPreviousData: false,
|
|
1029
|
+
// revalidateIfStale: true,
|
|
1030
|
+
...options,
|
|
1040
1031
|
formatter: (data2) => data2,
|
|
1041
1032
|
onError: (err) => {
|
|
1042
1033
|
console.log("usePositionStream error", err);
|
|
1043
1034
|
}
|
|
1044
|
-
})
|
|
1035
|
+
});
|
|
1045
1036
|
const { data: markPrices } = useMarkPricesStream();
|
|
1046
1037
|
const formatedPositions = React2.useMemo(() => {
|
|
1047
|
-
if (!
|
|
1038
|
+
if (!data?.rows || !symbolInfo || !accountInfo)
|
|
1048
1039
|
return null;
|
|
1049
1040
|
const filteredData = typeof symbol === "undefined" || symbol === "" ? data.rows : data.rows.filter((item) => {
|
|
1050
1041
|
return item.symbol === symbol;
|
|
1051
1042
|
});
|
|
1052
1043
|
let unrealPnL_total = utils.zero, notional_total = utils.zero, unsettlementPnL_total = utils.zero;
|
|
1053
1044
|
const formatted = filteredData.map((item) => {
|
|
1054
|
-
var _a2;
|
|
1055
1045
|
const price = ramda.propOr(
|
|
1056
1046
|
item.mark_price,
|
|
1057
1047
|
item.symbol,
|
|
@@ -1067,8 +1057,7 @@ var usePositionStream = (symbol, options) => {
|
|
|
1067
1057
|
positionQty: item.position_qty,
|
|
1068
1058
|
markPrice: price,
|
|
1069
1059
|
costPosition: item.cost_position,
|
|
1070
|
-
sumUnitaryFunding:
|
|
1071
|
-
fundingRates,
|
|
1060
|
+
sumUnitaryFunding: fundingRates[item.symbol]?.(
|
|
1072
1061
|
"sum_unitary_funding",
|
|
1073
1062
|
0
|
|
1074
1063
|
),
|
|
@@ -1077,13 +1066,14 @@ var usePositionStream = (symbol, options) => {
|
|
|
1077
1066
|
unrealPnL_total = unrealPnL_total.add(unrealPnl);
|
|
1078
1067
|
notional_total = notional_total.add(notional);
|
|
1079
1068
|
unsettlementPnL_total = unsettlementPnL_total.add(unsettlementPnL);
|
|
1080
|
-
return
|
|
1069
|
+
return {
|
|
1070
|
+
...item,
|
|
1081
1071
|
mark_price: price,
|
|
1082
1072
|
mm: 0,
|
|
1083
1073
|
notional,
|
|
1084
1074
|
unsettlement_pnl: unsettlementPnL,
|
|
1085
1075
|
unrealized_pnl: unrealPnl
|
|
1086
|
-
}
|
|
1076
|
+
};
|
|
1087
1077
|
});
|
|
1088
1078
|
return [
|
|
1089
1079
|
formatted,
|
|
@@ -1093,7 +1083,7 @@ var usePositionStream = (symbol, options) => {
|
|
|
1093
1083
|
unsettledPnL: unsettlementPnL_total.toNumber()
|
|
1094
1084
|
}
|
|
1095
1085
|
];
|
|
1096
|
-
}, [data
|
|
1086
|
+
}, [data?.rows, symbolInfo, accountInfo, markPrices, symbol, holding]);
|
|
1097
1087
|
const [totalCollateral, totalValue, totalUnrealizedROI] = React2.useMemo(() => {
|
|
1098
1088
|
if (!holding || !markPrices) {
|
|
1099
1089
|
return [utils.zero, utils.zero, 0];
|
|
@@ -1124,7 +1114,7 @@ var usePositionStream = (symbol, options) => {
|
|
|
1124
1114
|
return formatedPositions[0];
|
|
1125
1115
|
const total = totalCollateral.toNumber();
|
|
1126
1116
|
return formatedPositions[0].filter((item) => item.position_qty !== 0).map((item) => {
|
|
1127
|
-
const info = symbolInfo
|
|
1117
|
+
const info = symbolInfo?.[item.symbol];
|
|
1128
1118
|
const MMR = futures.positions.MMR({
|
|
1129
1119
|
baseMMR: info("base_mmr"),
|
|
1130
1120
|
baseIMR: info("base_imr"),
|
|
@@ -1132,7 +1122,8 @@ var usePositionStream = (symbol, options) => {
|
|
|
1132
1122
|
positionNotional: item.notional,
|
|
1133
1123
|
IMR_factor_power: 4 / 5
|
|
1134
1124
|
});
|
|
1135
|
-
return
|
|
1125
|
+
return {
|
|
1126
|
+
...item,
|
|
1136
1127
|
mm: futures.positions.maintenanceMargin({
|
|
1137
1128
|
positionQty: item.position_qty,
|
|
1138
1129
|
markPrice: item.mark_price,
|
|
@@ -1145,13 +1136,13 @@ var usePositionStream = (symbol, options) => {
|
|
|
1145
1136
|
MMR
|
|
1146
1137
|
}),
|
|
1147
1138
|
MMR
|
|
1148
|
-
}
|
|
1139
|
+
};
|
|
1149
1140
|
});
|
|
1150
1141
|
}, [formatedPositions, symbolInfo, accountInfo, totalCollateral]);
|
|
1151
1142
|
return [
|
|
1152
1143
|
{
|
|
1153
1144
|
rows: positionsRows,
|
|
1154
|
-
aggregated:
|
|
1145
|
+
aggregated: formatedPositions?.[1] ?? {},
|
|
1155
1146
|
totalCollateral,
|
|
1156
1147
|
totalValue,
|
|
1157
1148
|
totalUnrealizedROI
|
|
@@ -1185,7 +1176,7 @@ var useHoldingStream = () => {
|
|
|
1185
1176
|
}
|
|
1186
1177
|
);
|
|
1187
1178
|
const usdc = React2.useMemo(() => {
|
|
1188
|
-
const usdc2 = data
|
|
1179
|
+
const usdc2 = data?.find((item) => item.token === "USDC");
|
|
1189
1180
|
return usdc2;
|
|
1190
1181
|
}, [data]);
|
|
1191
1182
|
useSWRSubscription__default.default("holding", (_, { next }) => {
|
|
@@ -1198,16 +1189,16 @@ var useHoldingStream = () => {
|
|
|
1198
1189
|
},
|
|
1199
1190
|
{
|
|
1200
1191
|
onMessage: (data2) => {
|
|
1201
|
-
|
|
1202
|
-
const holding = (_a = data2 == null ? void 0 : data2.balances) != null ? _a : {};
|
|
1192
|
+
const holding = data2?.balances ?? {};
|
|
1203
1193
|
if (holding) {
|
|
1204
1194
|
mutate2((prevData) => {
|
|
1205
|
-
return prevData
|
|
1195
|
+
return prevData?.map((item) => {
|
|
1206
1196
|
const token = holding[item.token];
|
|
1207
|
-
return
|
|
1197
|
+
return {
|
|
1198
|
+
...item,
|
|
1208
1199
|
frozen: token.frozen,
|
|
1209
1200
|
holding: token.holding
|
|
1210
|
-
}
|
|
1201
|
+
};
|
|
1211
1202
|
});
|
|
1212
1203
|
});
|
|
1213
1204
|
next(holding);
|
|
@@ -1249,7 +1240,7 @@ var useCollateral = (options = { dp: 6 }) => {
|
|
|
1249
1240
|
}
|
|
1250
1241
|
return futures.account.totalInitialMarginWithOrders({
|
|
1251
1242
|
positions: positionsPath(positions2),
|
|
1252
|
-
orders: orders
|
|
1243
|
+
orders: orders ?? [],
|
|
1253
1244
|
markPrices,
|
|
1254
1245
|
IMR_Factors: accountInfo.imr_factor,
|
|
1255
1246
|
maxLeverage: accountInfo.max_leverage,
|
|
@@ -1263,9 +1254,8 @@ var useCollateral = (options = { dp: 6 }) => {
|
|
|
1263
1254
|
});
|
|
1264
1255
|
}, [totalCollateral, totalInitialMarginWithOrders]);
|
|
1265
1256
|
const availableBalance = React2.useMemo(() => {
|
|
1266
|
-
var _a;
|
|
1267
1257
|
return futures.account.availableBalance({
|
|
1268
|
-
USDCHolding:
|
|
1258
|
+
USDCHolding: usdc?.holding ?? 0,
|
|
1269
1259
|
unsettlementPnL: pathOr_unsettledPnLPathOr(positions2)
|
|
1270
1260
|
});
|
|
1271
1261
|
}, [usdc, pathOr_unsettledPnLPathOr(positions2)]);
|
|
@@ -1430,9 +1420,10 @@ var BaseOrderCreator = class {
|
|
|
1430
1420
|
};
|
|
1431
1421
|
var LimitOrderCreator = class extends BaseOrderCreator {
|
|
1432
1422
|
create(values) {
|
|
1433
|
-
return
|
|
1423
|
+
return {
|
|
1424
|
+
...this.baseOrder(values),
|
|
1434
1425
|
order_price: values.order_price
|
|
1435
|
-
}
|
|
1426
|
+
};
|
|
1436
1427
|
}
|
|
1437
1428
|
validate(values, config) {
|
|
1438
1429
|
return this.baseValidate(values, config).then((errors) => {
|
|
@@ -1472,7 +1463,9 @@ var MarketOrderCreator = class extends BaseOrderCreator {
|
|
|
1472
1463
|
create(values) {
|
|
1473
1464
|
const data = this.baseOrder(values);
|
|
1474
1465
|
delete data["order_price"];
|
|
1475
|
-
return
|
|
1466
|
+
return {
|
|
1467
|
+
...data
|
|
1468
|
+
};
|
|
1476
1469
|
}
|
|
1477
1470
|
validate(values, configs) {
|
|
1478
1471
|
return this.baseValidate(values, configs);
|
|
@@ -1486,10 +1479,11 @@ var IOCOrderCreator = class extends LimitOrderCreator {
|
|
|
1486
1479
|
};
|
|
1487
1480
|
var GeneralOrderCreator = class extends BaseOrderCreator {
|
|
1488
1481
|
create(data) {
|
|
1489
|
-
return
|
|
1482
|
+
return {
|
|
1483
|
+
...this.baseOrder(data),
|
|
1490
1484
|
order_price: data.order_price,
|
|
1491
1485
|
order_quantity: data.order_quantity
|
|
1492
|
-
}
|
|
1486
|
+
};
|
|
1493
1487
|
}
|
|
1494
1488
|
validate(values, configs) {
|
|
1495
1489
|
return super.baseValidate(values, configs);
|
|
@@ -1543,7 +1537,7 @@ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
|
|
|
1543
1537
|
if (!orderCreator) {
|
|
1544
1538
|
return Promise.reject(new Error("orderCreator is null"));
|
|
1545
1539
|
}
|
|
1546
|
-
return orderCreator
|
|
1540
|
+
return orderCreator?.validate(values, {
|
|
1547
1541
|
symbol: symbolInfo[symbol](),
|
|
1548
1542
|
// token: tokenInfo[symbol](),
|
|
1549
1543
|
maxQty,
|
|
@@ -1556,9 +1550,10 @@ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
|
|
|
1556
1550
|
throw new Error("symbol is null");
|
|
1557
1551
|
}
|
|
1558
1552
|
const data = orderCreator.create(values);
|
|
1559
|
-
return doCreateOrder(
|
|
1553
|
+
return doCreateOrder({
|
|
1554
|
+
...data,
|
|
1560
1555
|
symbol
|
|
1561
|
-
})
|
|
1556
|
+
});
|
|
1562
1557
|
});
|
|
1563
1558
|
};
|
|
1564
1559
|
const calculate = React2.useCallback(
|
|
@@ -1577,7 +1572,7 @@ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
|
|
|
1577
1572
|
);
|
|
1578
1573
|
const validator = (values) => {
|
|
1579
1574
|
const creator = OrderFactory.create(values.order_type);
|
|
1580
|
-
return creator
|
|
1575
|
+
return creator?.validate(values, {
|
|
1581
1576
|
symbol: symbolInfo[symbol](),
|
|
1582
1577
|
// token: tokenInfo[symbol](),
|
|
1583
1578
|
maxQty,
|
|
@@ -1642,14 +1637,12 @@ var useTokenInfo = () => {
|
|
|
1642
1637
|
focusThrottleInterval: 1e3 * 60 * 60 * 24,
|
|
1643
1638
|
revalidateOnFocus: false,
|
|
1644
1639
|
formatter(data2) {
|
|
1645
|
-
|
|
1646
|
-
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) {
|
|
1647
1641
|
return {};
|
|
1648
1642
|
}
|
|
1649
1643
|
const obj = /* @__PURE__ */ Object.create(null);
|
|
1650
1644
|
for (let index = 0; index < data2.rows.length; index++) {
|
|
1651
|
-
|
|
1652
|
-
obj[item.token] = item;
|
|
1645
|
+
data2.rows[index];
|
|
1653
1646
|
}
|
|
1654
1647
|
return obj;
|
|
1655
1648
|
}
|
|
@@ -1680,7 +1673,7 @@ var useMarketsStream = () => {
|
|
|
1680
1673
|
);
|
|
1681
1674
|
return () => {
|
|
1682
1675
|
console.log("unsubscribe!!!!!!!");
|
|
1683
|
-
unsubscribe
|
|
1676
|
+
unsubscribe?.();
|
|
1684
1677
|
};
|
|
1685
1678
|
});
|
|
1686
1679
|
const value = React2.useMemo(() => {
|
|
@@ -1693,12 +1686,13 @@ var useMarketsStream = () => {
|
|
|
1693
1686
|
(t) => t.symbol === item.symbol
|
|
1694
1687
|
);
|
|
1695
1688
|
if (ticker) {
|
|
1696
|
-
return
|
|
1689
|
+
return {
|
|
1690
|
+
...item,
|
|
1697
1691
|
["24h_close"]: ticker.close,
|
|
1698
1692
|
["24h_open"]: ticker.open,
|
|
1699
1693
|
["24h_volumn"]: ticker.volume,
|
|
1700
1694
|
change: 0
|
|
1701
|
-
}
|
|
1695
|
+
};
|
|
1702
1696
|
}
|
|
1703
1697
|
return item;
|
|
1704
1698
|
});
|
|
@@ -1716,7 +1710,6 @@ var useLeverage = () => {
|
|
|
1716
1710
|
return [ramda.prop("max_leverage", data), { update: updateLeverage }];
|
|
1717
1711
|
};
|
|
1718
1712
|
var useFundingRate = (symbol) => {
|
|
1719
|
-
var _a;
|
|
1720
1713
|
if (!symbol) {
|
|
1721
1714
|
throw new Error("useFuturesForSymbol requires a symbol");
|
|
1722
1715
|
}
|
|
@@ -1750,22 +1743,23 @@ var useFundingRate = (symbol) => {
|
|
|
1750
1743
|
clearInterval(timer);
|
|
1751
1744
|
};
|
|
1752
1745
|
}, [data]);
|
|
1753
|
-
return
|
|
1754
|
-
|
|
1746
|
+
return {
|
|
1747
|
+
...data,
|
|
1748
|
+
est_funding_rate: (Number(data?.est_funding_rate ?? 0) * 100).toFixed(4),
|
|
1755
1749
|
countDown
|
|
1756
|
-
}
|
|
1750
|
+
};
|
|
1757
1751
|
};
|
|
1758
1752
|
var fetcher3 = (url, init) => net.get(url, init);
|
|
1759
1753
|
var usePrivateInfiniteQuery = (getKey, options) => {
|
|
1760
|
-
var _a;
|
|
1761
1754
|
const account5 = useAccount();
|
|
1762
|
-
const middleware = Array.isArray(options
|
|
1755
|
+
const middleware = Array.isArray(options?.use) ? options?.use ?? [] : [];
|
|
1763
1756
|
const result = useSWRInfinite__default.default(
|
|
1764
1757
|
(pageIndex, previousPageData) => account5.state.status >= types.AccountStatusEnum.EnableTrading ? getKey(pageIndex, previousPageData) : null,
|
|
1765
1758
|
fetcher3,
|
|
1766
|
-
|
|
1759
|
+
{
|
|
1760
|
+
...options,
|
|
1767
1761
|
use: [signatureMiddleware, ...middleware]
|
|
1768
|
-
}
|
|
1762
|
+
}
|
|
1769
1763
|
);
|
|
1770
1764
|
return result;
|
|
1771
1765
|
};
|
|
@@ -1813,15 +1807,14 @@ var useOrderStream = ({
|
|
|
1813
1807
|
}
|
|
1814
1808
|
);
|
|
1815
1809
|
const orders = React2.useMemo(() => {
|
|
1816
|
-
var _a;
|
|
1817
1810
|
if (!ordersResponse.data) {
|
|
1818
1811
|
return null;
|
|
1819
1812
|
}
|
|
1820
|
-
return
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
mark_price:
|
|
1824
|
-
}
|
|
1813
|
+
return ordersResponse.data?.flat().map((item) => {
|
|
1814
|
+
return {
|
|
1815
|
+
...item,
|
|
1816
|
+
mark_price: markPrices[item.symbol] ?? 0
|
|
1817
|
+
};
|
|
1825
1818
|
});
|
|
1826
1819
|
}, [ordersResponse.data, markPrices]);
|
|
1827
1820
|
React2.useEffect(() => {
|
|
@@ -1834,7 +1827,7 @@ var useOrderStream = ({
|
|
|
1834
1827
|
const cancelAllOrders = React2.useCallback(() => {
|
|
1835
1828
|
}, [ordersResponse.data]);
|
|
1836
1829
|
const updateOrder = React2.useCallback((orderId, order2) => {
|
|
1837
|
-
return doUpdateOrder(
|
|
1830
|
+
return doUpdateOrder({ ...order2, order_id: orderId });
|
|
1838
1831
|
}, []);
|
|
1839
1832
|
const cancelOrder = React2.useCallback((orderId, symbol2) => {
|
|
1840
1833
|
return doCancelOrder(null, {
|
|
@@ -1900,7 +1893,7 @@ var useMarketTradeStream = (symbol, options = {}) => {
|
|
|
1900
1893
|
{
|
|
1901
1894
|
onMessage: (data) => {
|
|
1902
1895
|
setTrades((prev) => {
|
|
1903
|
-
const arr = [
|
|
1896
|
+
const arr = [{ ...data, ts: Date.now() }, ...prev];
|
|
1904
1897
|
if (arr.length > limit) {
|
|
1905
1898
|
arr.pop();
|
|
1906
1899
|
}
|
|
@@ -1910,7 +1903,7 @@ var useMarketTradeStream = (symbol, options = {}) => {
|
|
|
1910
1903
|
}
|
|
1911
1904
|
);
|
|
1912
1905
|
return () => {
|
|
1913
|
-
unsubscript
|
|
1906
|
+
unsubscript?.();
|
|
1914
1907
|
};
|
|
1915
1908
|
}, [symbol]);
|
|
1916
1909
|
return { data: trades, isLoading };
|
|
@@ -1926,7 +1919,7 @@ var useMarginRatio = () => {
|
|
|
1926
1919
|
const ratio = futures.account.totalMarginRatio({
|
|
1927
1920
|
totalCollateral,
|
|
1928
1921
|
markPrices,
|
|
1929
|
-
positions: rows
|
|
1922
|
+
positions: rows ?? []
|
|
1930
1923
|
});
|
|
1931
1924
|
return ratio;
|
|
1932
1925
|
}, [rows, markPrices, totalCollateral]);
|
|
@@ -1935,39 +1928,647 @@ var useMarginRatio = () => {
|
|
|
1935
1928
|
}, [marginRatio]);
|
|
1936
1929
|
return { marginRatio, currentLeverage };
|
|
1937
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
|
|
1938
2532
|
var useChains = (networkId, options = {}) => {
|
|
1939
|
-
const
|
|
1940
|
-
const { configStore } = React2.useContext(OrderlyContext);
|
|
1941
|
-
const field = options
|
|
1942
|
-
const map = React2.useRef(
|
|
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
|
+
);
|
|
1943
2539
|
const { data, error: swapSupportError } = useSWR__default.default(
|
|
1944
2540
|
() => wooSwapEnabled ? `${configStore.get("swapSupportApiUrl")}/swap_support` : null,
|
|
1945
2541
|
// `${configStore.get("swapSupportApiUrl")}/swap_support`,
|
|
1946
2542
|
(url) => fetch(url).then((res) => res.json()),
|
|
1947
|
-
|
|
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,
|
|
1948
2554
|
revalidateOnFocus: false,
|
|
1949
2555
|
revalidateOnReconnect: false
|
|
1950
|
-
}
|
|
2556
|
+
}
|
|
1951
2557
|
);
|
|
1952
|
-
const { data: orderlyChains, error: tokenError } = useQuery("/v1/public/token");
|
|
1953
2558
|
const chains = React2.useMemo(() => {
|
|
1954
2559
|
if (!orderlyChains)
|
|
1955
2560
|
return void 0;
|
|
1956
|
-
|
|
2561
|
+
let orderlyChainsArr = [];
|
|
1957
2562
|
const orderlyChainIds = /* @__PURE__ */ new Set();
|
|
1958
2563
|
orderlyChains.forEach((item) => {
|
|
1959
2564
|
item.chain_details.forEach((chain) => {
|
|
1960
|
-
var _a2;
|
|
1961
2565
|
const chainId = Number(chain.chain_id);
|
|
1962
2566
|
orderlyChainIds.add(chainId);
|
|
1963
|
-
const chainInfo = types.chainsMap.get(chainId);
|
|
1964
2567
|
const _chain = {
|
|
1965
2568
|
network_infos: {
|
|
1966
|
-
name:
|
|
2569
|
+
name: chain.chain_name ?? "--",
|
|
1967
2570
|
// "public_rpc_url": "https://arb1.arbitrum.io/rpc",
|
|
1968
2571
|
chain_id: chainId,
|
|
1969
|
-
// decimals: chain.decimals,
|
|
1970
|
-
// contract_address: chain.contract_address,
|
|
1971
2572
|
bridgeless: true
|
|
1972
2573
|
},
|
|
1973
2574
|
token_infos: [
|
|
@@ -1978,12 +2579,12 @@ var useChains = (networkId, options = {}) => {
|
|
|
1978
2579
|
}
|
|
1979
2580
|
]
|
|
1980
2581
|
};
|
|
1981
|
-
if (typeof
|
|
2582
|
+
if (typeof options?.filter === "function") {
|
|
1982
2583
|
if (!options.filter(_chain))
|
|
1983
2584
|
return;
|
|
1984
2585
|
}
|
|
1985
2586
|
map.current.set(chainId, _chain);
|
|
1986
|
-
orderlyChainsArr.push(
|
|
2587
|
+
orderlyChainsArr.push(_chain);
|
|
1987
2588
|
});
|
|
1988
2589
|
});
|
|
1989
2590
|
if (!wooSwapEnabled) {
|
|
@@ -1994,27 +2595,43 @@ var useChains = (networkId, options = {}) => {
|
|
|
1994
2595
|
let testnetArr = [];
|
|
1995
2596
|
let mainnetArr = [];
|
|
1996
2597
|
Object.keys(data.data).forEach((key) => {
|
|
1997
|
-
|
|
1998
|
-
if (orderlyChainIds.has(data.data[key].network_infos.chain_id))
|
|
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
|
+
});
|
|
1999
2606
|
return;
|
|
2000
|
-
|
|
2607
|
+
}
|
|
2608
|
+
const item = {
|
|
2609
|
+
...data.data[key],
|
|
2001
2610
|
name: key
|
|
2002
|
-
}
|
|
2003
|
-
if (
|
|
2611
|
+
};
|
|
2612
|
+
if (item.token_infos?.length === 0)
|
|
2004
2613
|
return;
|
|
2005
2614
|
map.current.set(item.network_infos.chain_id, item);
|
|
2006
|
-
if (typeof
|
|
2615
|
+
if (typeof options?.filter === "function") {
|
|
2007
2616
|
if (!options.filter(item))
|
|
2008
2617
|
return;
|
|
2009
2618
|
}
|
|
2010
2619
|
if (item.network_infos.mainnet) {
|
|
2011
|
-
mainnetArr.push(
|
|
2620
|
+
mainnetArr.push(item);
|
|
2012
2621
|
} else {
|
|
2013
|
-
testnetArr.push(
|
|
2622
|
+
testnetArr.push(item);
|
|
2014
2623
|
}
|
|
2015
2624
|
});
|
|
2016
2625
|
if (orderlyChainIds.size > 0) {
|
|
2017
|
-
|
|
2626
|
+
if (envNetworkId === "testnet") {
|
|
2627
|
+
testnetArr = [...orderlyChainsArr, ...testnetArr];
|
|
2628
|
+
} else {
|
|
2629
|
+
mainnetArr = [...orderlyChainsArr, ...mainnetArr];
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
if (!!field) {
|
|
2633
|
+
testnetArr = testnetArr.map((item) => item[field]);
|
|
2634
|
+
mainnetArr = mainnetArr.map((item) => item[field]);
|
|
2018
2635
|
}
|
|
2019
2636
|
if (networkId === "mainnet") {
|
|
2020
2637
|
return mainnetArr;
|
|
@@ -2031,6 +2648,11 @@ var useChains = (networkId, options = {}) => {
|
|
|
2031
2648
|
const findByChainId = React2.useCallback(
|
|
2032
2649
|
(chainId, field2) => {
|
|
2033
2650
|
const chain = map.current.get(chainId);
|
|
2651
|
+
if (chain) {
|
|
2652
|
+
chain.nativeToken = chain.token_infos?.find(
|
|
2653
|
+
(item) => item.address === nativeTokenAddress
|
|
2654
|
+
);
|
|
2655
|
+
}
|
|
2034
2656
|
if (typeof field2 === "string") {
|
|
2035
2657
|
return ramda.prop(field2, chain);
|
|
2036
2658
|
}
|
|
@@ -2038,7 +2660,15 @@ var useChains = (networkId, options = {}) => {
|
|
|
2038
2660
|
},
|
|
2039
2661
|
[chains, map.current]
|
|
2040
2662
|
);
|
|
2041
|
-
return [
|
|
2663
|
+
return [
|
|
2664
|
+
chains,
|
|
2665
|
+
{
|
|
2666
|
+
findByChainId,
|
|
2667
|
+
// findNativeTokenByChainId,
|
|
2668
|
+
error: swapSupportError || tokenError
|
|
2669
|
+
// nativeToken,
|
|
2670
|
+
}
|
|
2671
|
+
];
|
|
2042
2672
|
};
|
|
2043
2673
|
var useChain = (token) => {
|
|
2044
2674
|
const { data, isLoading } = useQuery("/v1/public/token");
|
|
@@ -2048,11 +2678,11 @@ var useChain = (token) => {
|
|
|
2048
2678
|
let item = data.find((chain) => chain.token === token);
|
|
2049
2679
|
if (item) {
|
|
2050
2680
|
item.chain_details = item.chain_details.map((d) => {
|
|
2051
|
-
var _a;
|
|
2052
2681
|
const chain = types.chainsMap.get(Number(d.chain_id));
|
|
2053
|
-
return
|
|
2054
|
-
|
|
2055
|
-
|
|
2682
|
+
return {
|
|
2683
|
+
...d,
|
|
2684
|
+
chain_name: chain?.chainName ?? "--"
|
|
2685
|
+
};
|
|
2056
2686
|
});
|
|
2057
2687
|
}
|
|
2058
2688
|
return item || null;
|
|
@@ -2074,41 +2704,58 @@ var useWithdraw = () => {
|
|
|
2074
2704
|
);
|
|
2075
2705
|
const { usdc } = useHoldingStream();
|
|
2076
2706
|
const maxAmount = React2.useMemo(() => {
|
|
2077
|
-
var _a;
|
|
2078
2707
|
if (!usdc || !usdc.holding)
|
|
2079
2708
|
return 0;
|
|
2080
2709
|
if (unsettledPnL >= 0)
|
|
2081
|
-
return
|
|
2710
|
+
return usdc?.holding ?? 0;
|
|
2082
2711
|
return new utils.Decimal(usdc.holding).add(unsettledPnL).toNumber();
|
|
2083
2712
|
}, [usdc, unsettledPnL]);
|
|
2084
2713
|
return { withdraw, isLoading, maxAmount, availableBalance, unsettledPnL };
|
|
2085
2714
|
};
|
|
2086
|
-
var
|
|
2087
|
-
var isNativeToken = (address) => address === nativeTokenAddress;
|
|
2715
|
+
var isNativeTokenChecker = (address) => address === nativeTokenAddress;
|
|
2088
2716
|
var useDeposit = (options) => {
|
|
2089
2717
|
const [balanceRevalidating, setBalanceRevalidating] = React2.useState(false);
|
|
2090
2718
|
const [allowanceRevalidating, setAllowanceRevalidating] = React2.useState(false);
|
|
2091
2719
|
const [balance, setBalance] = React2.useState("0");
|
|
2092
2720
|
const [allowance, setAllowance] = React2.useState("0");
|
|
2093
2721
|
const { account: account5, state } = useAccount();
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
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
|
+
);
|
|
2103
2750
|
const fetchBalance = React2.useCallback(
|
|
2104
|
-
(address) =>
|
|
2751
|
+
async (address) => {
|
|
2105
2752
|
if (!address)
|
|
2106
2753
|
return;
|
|
2107
2754
|
try {
|
|
2108
2755
|
if (balanceRevalidating)
|
|
2109
2756
|
return;
|
|
2110
2757
|
setBalanceRevalidating(true);
|
|
2111
|
-
const balance2 =
|
|
2758
|
+
const balance2 = await fetchBalanceHandler(address);
|
|
2112
2759
|
console.log("----- refresh balance -----", balance2);
|
|
2113
2760
|
setBalance(() => balance2);
|
|
2114
2761
|
setBalanceRevalidating(false);
|
|
@@ -2117,54 +2764,58 @@ var useDeposit = (options) => {
|
|
|
2117
2764
|
setBalanceRevalidating(false);
|
|
2118
2765
|
setBalance(() => "0");
|
|
2119
2766
|
}
|
|
2120
|
-
}
|
|
2767
|
+
},
|
|
2121
2768
|
[state, balanceRevalidating]
|
|
2122
2769
|
);
|
|
2123
|
-
const fetchBalances = React2.useCallback((tokens) =>
|
|
2770
|
+
const fetchBalances = React2.useCallback(async (tokens) => {
|
|
2124
2771
|
const tasks = [];
|
|
2125
2772
|
console.log("fetch balances ---->>>>", tokens);
|
|
2126
2773
|
for (const token of tokens) {
|
|
2127
|
-
if (
|
|
2774
|
+
if (isNativeTokenChecker(token.address)) {
|
|
2128
2775
|
continue;
|
|
2129
2776
|
}
|
|
2130
2777
|
tasks.push(account5.assetsManager.getBalanceByAddress(token.address));
|
|
2131
2778
|
}
|
|
2132
|
-
const balances =
|
|
2779
|
+
const balances = await Promise.all(tasks);
|
|
2133
2780
|
console.log("----- get balances from tokens -----", balances);
|
|
2134
|
-
}
|
|
2781
|
+
}, []);
|
|
2135
2782
|
const fetchAllowance = React2.useCallback(
|
|
2136
|
-
(address) =>
|
|
2783
|
+
async (address) => {
|
|
2137
2784
|
if (!address)
|
|
2138
2785
|
return;
|
|
2139
|
-
if (address &&
|
|
2786
|
+
if (address && isNativeTokenChecker(address))
|
|
2140
2787
|
return;
|
|
2141
2788
|
if (allowanceRevalidating)
|
|
2142
2789
|
return;
|
|
2143
2790
|
setAllowanceRevalidating(true);
|
|
2144
|
-
const allowance2 =
|
|
2791
|
+
const allowance2 = await account5.assetsManager.getAllowance(address);
|
|
2145
2792
|
console.log("----- refresh allowance -----", allowance2);
|
|
2146
2793
|
setAllowance(() => allowance2);
|
|
2147
2794
|
setAllowanceRevalidating(false);
|
|
2148
2795
|
return allowance2;
|
|
2149
|
-
}
|
|
2796
|
+
},
|
|
2150
2797
|
[allowanceRevalidating]
|
|
2151
2798
|
);
|
|
2152
2799
|
React2.useEffect(() => {
|
|
2800
|
+
console.log("useDeposit useEffect", state.status, options?.address);
|
|
2153
2801
|
if (state.status < types.AccountStatusEnum.EnableTrading)
|
|
2154
2802
|
return;
|
|
2155
|
-
fetchBalance(options
|
|
2156
|
-
fetchAllowance(options
|
|
2157
|
-
}, [state.status, options
|
|
2803
|
+
fetchBalance(options?.address);
|
|
2804
|
+
fetchAllowance(options?.address);
|
|
2805
|
+
}, [state.status, options?.address]);
|
|
2158
2806
|
const approve = React2.useCallback(
|
|
2159
2807
|
(amount) => {
|
|
2160
|
-
|
|
2808
|
+
if (!options?.address) {
|
|
2809
|
+
throw new Error("address is required");
|
|
2810
|
+
}
|
|
2811
|
+
return account5.assetsManager.approve(options.address, amount).then((result) => {
|
|
2161
2812
|
if (typeof amount !== "undefined") {
|
|
2162
2813
|
setAllowance((value) => new utils.Decimal(value).add(amount).toString());
|
|
2163
2814
|
}
|
|
2164
2815
|
return result;
|
|
2165
2816
|
});
|
|
2166
2817
|
},
|
|
2167
|
-
[account5, fetchAllowance]
|
|
2818
|
+
[account5, fetchAllowance, options?.address]
|
|
2168
2819
|
);
|
|
2169
2820
|
const deposit = React2.useCallback(
|
|
2170
2821
|
(amount) => {
|
|
@@ -2177,8 +2828,10 @@ var useDeposit = (options) => {
|
|
|
2177
2828
|
[account5, fetchBalance, fetchAllowance]
|
|
2178
2829
|
);
|
|
2179
2830
|
return {
|
|
2831
|
+
dst,
|
|
2180
2832
|
balance,
|
|
2181
2833
|
allowance,
|
|
2834
|
+
isNativeToken,
|
|
2182
2835
|
balanceRevalidating,
|
|
2183
2836
|
allowanceRevalidating,
|
|
2184
2837
|
approve,
|
|
@@ -2199,8 +2852,7 @@ var useWalletSubscription = (options) => {
|
|
|
2199
2852
|
},
|
|
2200
2853
|
{
|
|
2201
2854
|
onMessage: (data) => {
|
|
2202
|
-
|
|
2203
|
-
(_a = options == null ? void 0 : options.onMessage) == null ? void 0 : _a.call(options, data);
|
|
2855
|
+
options?.onMessage?.(data);
|
|
2204
2856
|
next(data);
|
|
2205
2857
|
}
|
|
2206
2858
|
}
|
|
@@ -2236,12 +2888,13 @@ var usePrivateDataObserver = () => {
|
|
|
2236
2888
|
}
|
|
2237
2889
|
if (data.status === types.OrderStatus.NEW) {
|
|
2238
2890
|
return [
|
|
2239
|
-
|
|
2891
|
+
{
|
|
2892
|
+
...data,
|
|
2240
2893
|
// average_executed_price:data.ava
|
|
2241
2894
|
created_time: data.timestamp,
|
|
2242
2895
|
order_id: data.orderId
|
|
2243
2896
|
// reduce_only
|
|
2244
|
-
}
|
|
2897
|
+
},
|
|
2245
2898
|
...orders
|
|
2246
2899
|
];
|
|
2247
2900
|
}
|
|
@@ -2258,7 +2911,7 @@ var usePrivateDataObserver = () => {
|
|
|
2258
2911
|
ee.emit("orders:changed");
|
|
2259
2912
|
}
|
|
2260
2913
|
});
|
|
2261
|
-
return () => unsubscribe
|
|
2914
|
+
return () => unsubscribe?.();
|
|
2262
2915
|
}, [state.accountId]);
|
|
2263
2916
|
React2.useEffect(() => {
|
|
2264
2917
|
console.log("subscribe: position: %s", state.accountId);
|
|
@@ -2270,7 +2923,8 @@ var usePrivateDataObserver = () => {
|
|
|
2270
2923
|
const { positions: nextPostions } = data;
|
|
2271
2924
|
mutate2(key, (prevPositions) => {
|
|
2272
2925
|
if (!!prevPositions) {
|
|
2273
|
-
return
|
|
2926
|
+
return {
|
|
2927
|
+
...prevPositions,
|
|
2274
2928
|
rows: prevPositions.rows.map((row) => {
|
|
2275
2929
|
const item = nextPostions.find(
|
|
2276
2930
|
(item2) => item2.symbol === row.symbol
|
|
@@ -2299,14 +2953,14 @@ var usePrivateDataObserver = () => {
|
|
|
2299
2953
|
}
|
|
2300
2954
|
return row;
|
|
2301
2955
|
})
|
|
2302
|
-
}
|
|
2956
|
+
};
|
|
2303
2957
|
}
|
|
2304
2958
|
});
|
|
2305
2959
|
}
|
|
2306
2960
|
});
|
|
2307
2961
|
return () => {
|
|
2308
2962
|
console.log("unsubscribe: private subscription position");
|
|
2309
|
-
unsubscribe
|
|
2963
|
+
unsubscribe?.();
|
|
2310
2964
|
};
|
|
2311
2965
|
}, [state.accountId]);
|
|
2312
2966
|
};
|
|
@@ -2350,6 +3004,523 @@ var useFundingRateBySymbol = (symbol) => {
|
|
|
2350
3004
|
}
|
|
2351
3005
|
return useQuery(`/public/funding_rate/${symbol}`);
|
|
2352
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
|
+
};
|
|
2353
3524
|
|
|
2354
3525
|
Object.defineProperty(exports, 'SWRConfig', {
|
|
2355
3526
|
enumerable: true,
|
|
@@ -2373,16 +3544,19 @@ exports.useAccountInfo = useAccountInfo;
|
|
|
2373
3544
|
exports.useAccountInstance = useAccountInstance;
|
|
2374
3545
|
exports.useAppState = useAppState;
|
|
2375
3546
|
exports.useBalance = useBalance;
|
|
3547
|
+
exports.useBoolean = useBoolean;
|
|
2376
3548
|
exports.useChain = useChain;
|
|
2377
3549
|
exports.useChains = useChains;
|
|
2378
3550
|
exports.useCollateral = useCollateral;
|
|
2379
3551
|
exports.useConfig = useConfig;
|
|
3552
|
+
exports.useCrossSwap = useCrossSwap;
|
|
2380
3553
|
exports.useDeposit = useDeposit;
|
|
2381
3554
|
exports.useEventEmitter = useEventEmitter;
|
|
2382
3555
|
exports.useExecutionReport = useExecutionReport;
|
|
2383
3556
|
exports.useFetures = useFetures;
|
|
2384
3557
|
exports.useFundingRate = useFundingRate;
|
|
2385
3558
|
exports.useHoldingStream = useHoldingStream;
|
|
3559
|
+
exports.useLazyQuery = useLazyQuery;
|
|
2386
3560
|
exports.useLeverage = useLeverage;
|
|
2387
3561
|
exports.useLocalStorage = useLocalStorage;
|
|
2388
3562
|
exports.useMarginRatio = useMarginRatio;
|
|
@@ -2403,6 +3577,7 @@ exports.usePrivateQuery = usePrivateQuery;
|
|
|
2403
3577
|
exports.useQuery = useQuery;
|
|
2404
3578
|
exports.useRunOnce = useRunOnce;
|
|
2405
3579
|
exports.useSessionStorage = useSessionStorage;
|
|
3580
|
+
exports.useSwap = useSwap;
|
|
2406
3581
|
exports.useSymbolsInfo = useSymbolsInfo;
|
|
2407
3582
|
exports.useTickerStream = useTickerStream;
|
|
2408
3583
|
exports.useTokenInfo = useTokenInfo;
|
|
@@ -2411,5 +3586,13 @@ exports.useTradingView = useTradingView;
|
|
|
2411
3586
|
exports.useWS = useWS;
|
|
2412
3587
|
exports.useWalletSubscription = useWalletSubscription;
|
|
2413
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
|
+
});
|
|
2414
3597
|
//# sourceMappingURL=out.js.map
|
|
2415
3598
|
//# sourceMappingURL=index.js.map
|