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