@orderly.network/hooks 0.0.61 → 0.0.62
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 +39 -21
- package/dist/index.d.ts +39 -21
- package/dist/index.js +690 -218
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +693 -220
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -7
package/dist/index.mjs
CHANGED
|
@@ -6,10 +6,10 @@ import useSWRMutation from 'swr/mutation';
|
|
|
6
6
|
import useConstant from 'use-constant';
|
|
7
7
|
export { default as useConstant } from 'use-constant';
|
|
8
8
|
import { SimpleDI, Account, EventEmitter, utils } from '@orderly.network/core';
|
|
9
|
-
import { AccountStatusEnum, OrderSide, chainsMap, OrderStatus as OrderStatus$1, OrderType } from '@orderly.network/types';
|
|
9
|
+
import { AccountStatusEnum, OrderSide, chainsMap, ARBITRUM_TESTNET_CHAINID, ARBITRUM_MAINNET_CHAINID, 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, pick } from 'ramda';
|
|
12
|
+
import { pathOr, propOr, compose, head, prop, mergeDeepRight, pick } from 'ramda';
|
|
13
13
|
import { positions, account, order } from '@orderly.network/futures';
|
|
14
14
|
import useSWRInfinite from 'swr/infinite';
|
|
15
15
|
export * from 'use-debounce';
|
|
@@ -209,12 +209,6 @@ var useAccount = () => {
|
|
|
209
209
|
account5.off("change:status", statusChangeHandler);
|
|
210
210
|
};
|
|
211
211
|
}, []);
|
|
212
|
-
const login = useCallback(
|
|
213
|
-
(address) => {
|
|
214
|
-
account5.login(address);
|
|
215
|
-
},
|
|
216
|
-
[account5]
|
|
217
|
-
);
|
|
218
212
|
const createOrderlyKey = useCallback(
|
|
219
213
|
async (remember) => {
|
|
220
214
|
return account5.createOrderlyKey(remember ? 365 : 30);
|
|
@@ -238,7 +232,7 @@ var useAccount = () => {
|
|
|
238
232
|
account: account5,
|
|
239
233
|
state,
|
|
240
234
|
// info: {},
|
|
241
|
-
login,
|
|
235
|
+
// login,
|
|
242
236
|
createOrderlyKey,
|
|
243
237
|
createAccount,
|
|
244
238
|
disconnect,
|
|
@@ -278,16 +272,6 @@ var useBoolean = (initialValue = false) => {
|
|
|
278
272
|
var useTradingView = () => {
|
|
279
273
|
return {};
|
|
280
274
|
};
|
|
281
|
-
var usePrivateObserve = () => {
|
|
282
|
-
const [data, setData] = useState();
|
|
283
|
-
useEffect(() => {
|
|
284
|
-
return () => {
|
|
285
|
-
};
|
|
286
|
-
}, []);
|
|
287
|
-
return {
|
|
288
|
-
data
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
275
|
var useTopicObserve = (topic) => {
|
|
292
276
|
const [data, setData] = useState();
|
|
293
277
|
useEffect(() => {
|
|
@@ -1923,16 +1907,23 @@ var useMarginRatio = () => {
|
|
|
1923
1907
|
// src/woo/constants.ts
|
|
1924
1908
|
var woofiDexCrossChainRouterAbi = [
|
|
1925
1909
|
{
|
|
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
|
-
],
|
|
1910
|
+
inputs: [],
|
|
1933
1911
|
stateMutability: "nonpayable",
|
|
1934
1912
|
type: "constructor"
|
|
1935
1913
|
},
|
|
1914
|
+
{
|
|
1915
|
+
anonymous: false,
|
|
1916
|
+
inputs: [
|
|
1917
|
+
{
|
|
1918
|
+
indexed: false,
|
|
1919
|
+
internalType: "uint8",
|
|
1920
|
+
name: "version",
|
|
1921
|
+
type: "uint8"
|
|
1922
|
+
}
|
|
1923
|
+
],
|
|
1924
|
+
name: "Initialized",
|
|
1925
|
+
type: "event"
|
|
1926
|
+
},
|
|
1936
1927
|
{
|
|
1937
1928
|
anonymous: false,
|
|
1938
1929
|
inputs: [
|
|
@@ -1999,7 +1990,12 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
1999
1990
|
name: "sender",
|
|
2000
1991
|
type: "address"
|
|
2001
1992
|
},
|
|
2002
|
-
{
|
|
1993
|
+
{
|
|
1994
|
+
indexed: true,
|
|
1995
|
+
internalType: "address",
|
|
1996
|
+
name: "to",
|
|
1997
|
+
type: "address"
|
|
1998
|
+
},
|
|
2003
1999
|
{
|
|
2004
2000
|
indexed: false,
|
|
2005
2001
|
internalType: "address",
|
|
@@ -2036,6 +2032,12 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2036
2032
|
name: "realToAmount",
|
|
2037
2033
|
type: "uint256"
|
|
2038
2034
|
},
|
|
2035
|
+
{
|
|
2036
|
+
indexed: false,
|
|
2037
|
+
internalType: "uint256",
|
|
2038
|
+
name: "orderlyNativeFees",
|
|
2039
|
+
type: "uint256"
|
|
2040
|
+
},
|
|
2039
2041
|
{
|
|
2040
2042
|
indexed: false,
|
|
2041
2043
|
internalType: "bytes32",
|
|
@@ -2085,7 +2087,12 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2085
2087
|
name: "sender",
|
|
2086
2088
|
type: "address"
|
|
2087
2089
|
},
|
|
2088
|
-
{
|
|
2090
|
+
{
|
|
2091
|
+
indexed: true,
|
|
2092
|
+
internalType: "address",
|
|
2093
|
+
name: "to",
|
|
2094
|
+
type: "address"
|
|
2095
|
+
},
|
|
2089
2096
|
{
|
|
2090
2097
|
indexed: false,
|
|
2091
2098
|
internalType: "address",
|
|
@@ -2123,19 +2130,37 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2123
2130
|
{
|
|
2124
2131
|
inputs: [],
|
|
2125
2132
|
name: "MAX_BRIDGE_SLIPPAGE",
|
|
2126
|
-
outputs: [
|
|
2133
|
+
outputs: [
|
|
2134
|
+
{
|
|
2135
|
+
internalType: "uint256",
|
|
2136
|
+
name: "",
|
|
2137
|
+
type: "uint256"
|
|
2138
|
+
}
|
|
2139
|
+
],
|
|
2127
2140
|
stateMutability: "view",
|
|
2128
2141
|
type: "function"
|
|
2129
2142
|
},
|
|
2130
2143
|
{
|
|
2131
2144
|
inputs: [],
|
|
2132
2145
|
name: "NATIVE_PLACEHOLDER",
|
|
2133
|
-
outputs: [
|
|
2146
|
+
outputs: [
|
|
2147
|
+
{
|
|
2148
|
+
internalType: "address",
|
|
2149
|
+
name: "",
|
|
2150
|
+
type: "address"
|
|
2151
|
+
}
|
|
2152
|
+
],
|
|
2134
2153
|
stateMutability: "view",
|
|
2135
2154
|
type: "function"
|
|
2136
2155
|
},
|
|
2137
2156
|
{
|
|
2138
|
-
inputs: [
|
|
2157
|
+
inputs: [
|
|
2158
|
+
{
|
|
2159
|
+
internalType: "address",
|
|
2160
|
+
name: "token",
|
|
2161
|
+
type: "address"
|
|
2162
|
+
}
|
|
2163
|
+
],
|
|
2139
2164
|
name: "addDirectBridgeToken",
|
|
2140
2165
|
outputs: [],
|
|
2141
2166
|
stateMutability: "nonpayable",
|
|
@@ -2144,32 +2169,66 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2144
2169
|
{
|
|
2145
2170
|
inputs: [],
|
|
2146
2171
|
name: "allDirectBridgeTokens",
|
|
2147
|
-
outputs: [
|
|
2172
|
+
outputs: [
|
|
2173
|
+
{
|
|
2174
|
+
internalType: "address[]",
|
|
2175
|
+
name: "",
|
|
2176
|
+
type: "address[]"
|
|
2177
|
+
}
|
|
2178
|
+
],
|
|
2148
2179
|
stateMutability: "view",
|
|
2149
2180
|
type: "function"
|
|
2150
2181
|
},
|
|
2151
2182
|
{
|
|
2152
2183
|
inputs: [],
|
|
2153
2184
|
name: "allDirectBridgeTokensLength",
|
|
2154
|
-
outputs: [
|
|
2185
|
+
outputs: [
|
|
2186
|
+
{
|
|
2187
|
+
internalType: "uint256",
|
|
2188
|
+
name: "",
|
|
2189
|
+
type: "uint256"
|
|
2190
|
+
}
|
|
2191
|
+
],
|
|
2155
2192
|
stateMutability: "view",
|
|
2156
2193
|
type: "function"
|
|
2157
2194
|
},
|
|
2158
2195
|
{
|
|
2159
2196
|
inputs: [],
|
|
2160
2197
|
name: "bridgeSlippage",
|
|
2161
|
-
outputs: [
|
|
2198
|
+
outputs: [
|
|
2199
|
+
{
|
|
2200
|
+
internalType: "uint256",
|
|
2201
|
+
name: "",
|
|
2202
|
+
type: "uint256"
|
|
2203
|
+
}
|
|
2204
|
+
],
|
|
2162
2205
|
stateMutability: "view",
|
|
2163
2206
|
type: "function"
|
|
2164
2207
|
},
|
|
2165
2208
|
{
|
|
2166
2209
|
inputs: [
|
|
2167
|
-
{
|
|
2210
|
+
{
|
|
2211
|
+
internalType: "address payable",
|
|
2212
|
+
name: "to",
|
|
2213
|
+
type: "address"
|
|
2214
|
+
},
|
|
2168
2215
|
{
|
|
2169
2216
|
components: [
|
|
2170
|
-
{
|
|
2171
|
-
|
|
2172
|
-
|
|
2217
|
+
{
|
|
2218
|
+
internalType: "address",
|
|
2219
|
+
name: "fromToken",
|
|
2220
|
+
type: "address"
|
|
2221
|
+
},
|
|
2222
|
+
{
|
|
2223
|
+
internalType: "uint256",
|
|
2224
|
+
name: "fromAmount",
|
|
2225
|
+
type: "uint256"
|
|
2226
|
+
},
|
|
2227
|
+
{
|
|
2228
|
+
internalType: "address",
|
|
2229
|
+
name: "bridgeToken",
|
|
2230
|
+
type: "address"
|
|
2231
|
+
},
|
|
2173
2232
|
{
|
|
2174
2233
|
internalType: "uint256",
|
|
2175
2234
|
name: "minBridgeAmount",
|
|
@@ -2182,13 +2241,29 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2182
2241
|
},
|
|
2183
2242
|
{
|
|
2184
2243
|
components: [
|
|
2185
|
-
{
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2244
|
+
{
|
|
2245
|
+
internalType: "uint16",
|
|
2246
|
+
name: "chainId",
|
|
2247
|
+
type: "uint16"
|
|
2248
|
+
},
|
|
2249
|
+
{
|
|
2250
|
+
internalType: "address",
|
|
2251
|
+
name: "bridgedToken",
|
|
2252
|
+
type: "address"
|
|
2253
|
+
},
|
|
2254
|
+
{
|
|
2255
|
+
internalType: "address",
|
|
2256
|
+
name: "toToken",
|
|
2257
|
+
type: "address"
|
|
2258
|
+
},
|
|
2259
|
+
{
|
|
2260
|
+
internalType: "uint256",
|
|
2261
|
+
name: "minToAmount",
|
|
2262
|
+
type: "uint256"
|
|
2263
|
+
},
|
|
2189
2264
|
{
|
|
2190
2265
|
internalType: "uint256",
|
|
2191
|
-
name: "
|
|
2266
|
+
name: "orderlyNativeFees",
|
|
2192
2267
|
type: "uint256"
|
|
2193
2268
|
}
|
|
2194
2269
|
],
|
|
@@ -2198,9 +2273,21 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2198
2273
|
},
|
|
2199
2274
|
{
|
|
2200
2275
|
components: [
|
|
2201
|
-
{
|
|
2202
|
-
|
|
2203
|
-
|
|
2276
|
+
{
|
|
2277
|
+
internalType: "bytes32",
|
|
2278
|
+
name: "accountId",
|
|
2279
|
+
type: "bytes32"
|
|
2280
|
+
},
|
|
2281
|
+
{
|
|
2282
|
+
internalType: "bytes32",
|
|
2283
|
+
name: "brokerHash",
|
|
2284
|
+
type: "bytes32"
|
|
2285
|
+
},
|
|
2286
|
+
{
|
|
2287
|
+
internalType: "bytes32",
|
|
2288
|
+
name: "tokenHash",
|
|
2289
|
+
type: "bytes32"
|
|
2290
|
+
}
|
|
2204
2291
|
],
|
|
2205
2292
|
internalType: "struct IWOOFiDexCrossChainRouter.DstVaultDeposit",
|
|
2206
2293
|
name: "dstVaultDeposit",
|
|
@@ -2215,29 +2302,97 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2215
2302
|
{
|
|
2216
2303
|
inputs: [],
|
|
2217
2304
|
name: "dstGasForNoSwapCall",
|
|
2218
|
-
outputs: [
|
|
2305
|
+
outputs: [
|
|
2306
|
+
{
|
|
2307
|
+
internalType: "uint256",
|
|
2308
|
+
name: "",
|
|
2309
|
+
type: "uint256"
|
|
2310
|
+
}
|
|
2311
|
+
],
|
|
2219
2312
|
stateMutability: "view",
|
|
2220
2313
|
type: "function"
|
|
2221
2314
|
},
|
|
2222
2315
|
{
|
|
2223
2316
|
inputs: [],
|
|
2224
2317
|
name: "dstGasForSwapCall",
|
|
2225
|
-
outputs: [
|
|
2318
|
+
outputs: [
|
|
2319
|
+
{
|
|
2320
|
+
internalType: "uint256",
|
|
2321
|
+
name: "",
|
|
2322
|
+
type: "uint256"
|
|
2323
|
+
}
|
|
2324
|
+
],
|
|
2226
2325
|
stateMutability: "view",
|
|
2227
2326
|
type: "function"
|
|
2228
2327
|
},
|
|
2229
2328
|
{
|
|
2230
|
-
inputs: [
|
|
2329
|
+
inputs: [
|
|
2330
|
+
{
|
|
2331
|
+
internalType: "address",
|
|
2332
|
+
name: "stuckToken",
|
|
2333
|
+
type: "address"
|
|
2334
|
+
}
|
|
2335
|
+
],
|
|
2231
2336
|
name: "inCaseTokenGotStuck",
|
|
2232
2337
|
outputs: [],
|
|
2233
2338
|
stateMutability: "nonpayable",
|
|
2234
2339
|
type: "function"
|
|
2235
2340
|
},
|
|
2341
|
+
{
|
|
2342
|
+
inputs: [
|
|
2343
|
+
{
|
|
2344
|
+
internalType: "address",
|
|
2345
|
+
name: "_weth",
|
|
2346
|
+
type: "address"
|
|
2347
|
+
},
|
|
2348
|
+
{
|
|
2349
|
+
internalType: "address",
|
|
2350
|
+
name: "_nonceCounter",
|
|
2351
|
+
type: "address"
|
|
2352
|
+
},
|
|
2353
|
+
{
|
|
2354
|
+
internalType: "address",
|
|
2355
|
+
name: "_wooRouter",
|
|
2356
|
+
type: "address"
|
|
2357
|
+
},
|
|
2358
|
+
{
|
|
2359
|
+
internalType: "address",
|
|
2360
|
+
name: "_sgRouter",
|
|
2361
|
+
type: "address"
|
|
2362
|
+
},
|
|
2363
|
+
{
|
|
2364
|
+
internalType: "uint16",
|
|
2365
|
+
name: "_sgChainIdLocal",
|
|
2366
|
+
type: "uint16"
|
|
2367
|
+
}
|
|
2368
|
+
],
|
|
2369
|
+
name: "initialize",
|
|
2370
|
+
outputs: [],
|
|
2371
|
+
stateMutability: "nonpayable",
|
|
2372
|
+
type: "function"
|
|
2373
|
+
},
|
|
2236
2374
|
{
|
|
2237
2375
|
inputs: [],
|
|
2238
2376
|
name: "nonceCounter",
|
|
2239
2377
|
outputs: [
|
|
2240
|
-
{
|
|
2378
|
+
{
|
|
2379
|
+
internalType: "address",
|
|
2380
|
+
name: "",
|
|
2381
|
+
type: "address"
|
|
2382
|
+
}
|
|
2383
|
+
],
|
|
2384
|
+
stateMutability: "view",
|
|
2385
|
+
type: "function"
|
|
2386
|
+
},
|
|
2387
|
+
{
|
|
2388
|
+
inputs: [],
|
|
2389
|
+
name: "orderlyFeeToggle",
|
|
2390
|
+
outputs: [
|
|
2391
|
+
{
|
|
2392
|
+
internalType: "bool",
|
|
2393
|
+
name: "",
|
|
2394
|
+
type: "bool"
|
|
2395
|
+
}
|
|
2241
2396
|
],
|
|
2242
2397
|
stateMutability: "view",
|
|
2243
2398
|
type: "function"
|
|
@@ -2245,7 +2400,13 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2245
2400
|
{
|
|
2246
2401
|
inputs: [],
|
|
2247
2402
|
name: "owner",
|
|
2248
|
-
outputs: [
|
|
2403
|
+
outputs: [
|
|
2404
|
+
{
|
|
2405
|
+
internalType: "address",
|
|
2406
|
+
name: "",
|
|
2407
|
+
type: "address"
|
|
2408
|
+
}
|
|
2409
|
+
],
|
|
2249
2410
|
stateMutability: "view",
|
|
2250
2411
|
type: "function"
|
|
2251
2412
|
},
|
|
@@ -2259,22 +2420,48 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2259
2420
|
{
|
|
2260
2421
|
inputs: [],
|
|
2261
2422
|
name: "paused",
|
|
2262
|
-
outputs: [
|
|
2423
|
+
outputs: [
|
|
2424
|
+
{
|
|
2425
|
+
internalType: "bool",
|
|
2426
|
+
name: "",
|
|
2427
|
+
type: "bool"
|
|
2428
|
+
}
|
|
2429
|
+
],
|
|
2263
2430
|
stateMutability: "view",
|
|
2264
2431
|
type: "function"
|
|
2265
2432
|
},
|
|
2266
2433
|
{
|
|
2267
2434
|
inputs: [
|
|
2268
|
-
{
|
|
2435
|
+
{
|
|
2436
|
+
internalType: "address",
|
|
2437
|
+
name: "to",
|
|
2438
|
+
type: "address"
|
|
2439
|
+
},
|
|
2269
2440
|
{
|
|
2270
2441
|
components: [
|
|
2271
|
-
{
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2442
|
+
{
|
|
2443
|
+
internalType: "uint16",
|
|
2444
|
+
name: "chainId",
|
|
2445
|
+
type: "uint16"
|
|
2446
|
+
},
|
|
2447
|
+
{
|
|
2448
|
+
internalType: "address",
|
|
2449
|
+
name: "bridgedToken",
|
|
2450
|
+
type: "address"
|
|
2451
|
+
},
|
|
2452
|
+
{
|
|
2453
|
+
internalType: "address",
|
|
2454
|
+
name: "toToken",
|
|
2455
|
+
type: "address"
|
|
2456
|
+
},
|
|
2457
|
+
{
|
|
2458
|
+
internalType: "uint256",
|
|
2459
|
+
name: "minToAmount",
|
|
2460
|
+
type: "uint256"
|
|
2461
|
+
},
|
|
2275
2462
|
{
|
|
2276
2463
|
internalType: "uint256",
|
|
2277
|
-
name: "
|
|
2464
|
+
name: "orderlyNativeFees",
|
|
2278
2465
|
type: "uint256"
|
|
2279
2466
|
}
|
|
2280
2467
|
],
|
|
@@ -2284,9 +2471,21 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2284
2471
|
},
|
|
2285
2472
|
{
|
|
2286
2473
|
components: [
|
|
2287
|
-
{
|
|
2288
|
-
|
|
2289
|
-
|
|
2474
|
+
{
|
|
2475
|
+
internalType: "bytes32",
|
|
2476
|
+
name: "accountId",
|
|
2477
|
+
type: "bytes32"
|
|
2478
|
+
},
|
|
2479
|
+
{
|
|
2480
|
+
internalType: "bytes32",
|
|
2481
|
+
name: "brokerHash",
|
|
2482
|
+
type: "bytes32"
|
|
2483
|
+
},
|
|
2484
|
+
{
|
|
2485
|
+
internalType: "bytes32",
|
|
2486
|
+
name: "tokenHash",
|
|
2487
|
+
type: "bytes32"
|
|
2488
|
+
}
|
|
2290
2489
|
],
|
|
2291
2490
|
internalType: "struct IWOOFiDexCrossChainRouter.DstVaultDeposit",
|
|
2292
2491
|
name: "dstVaultDeposit",
|
|
@@ -2295,14 +2494,28 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2295
2494
|
],
|
|
2296
2495
|
name: "quoteLayerZeroFee",
|
|
2297
2496
|
outputs: [
|
|
2298
|
-
{
|
|
2299
|
-
|
|
2497
|
+
{
|
|
2498
|
+
internalType: "uint256",
|
|
2499
|
+
name: "nativeAmount",
|
|
2500
|
+
type: "uint256"
|
|
2501
|
+
},
|
|
2502
|
+
{
|
|
2503
|
+
internalType: "uint256",
|
|
2504
|
+
name: "zroAmount",
|
|
2505
|
+
type: "uint256"
|
|
2506
|
+
}
|
|
2300
2507
|
],
|
|
2301
2508
|
stateMutability: "view",
|
|
2302
2509
|
type: "function"
|
|
2303
2510
|
},
|
|
2304
2511
|
{
|
|
2305
|
-
inputs: [
|
|
2512
|
+
inputs: [
|
|
2513
|
+
{
|
|
2514
|
+
internalType: "address",
|
|
2515
|
+
name: "token",
|
|
2516
|
+
type: "address"
|
|
2517
|
+
}
|
|
2518
|
+
],
|
|
2306
2519
|
name: "removeDirectBridgeToken",
|
|
2307
2520
|
outputs: [],
|
|
2308
2521
|
stateMutability: "nonpayable",
|
|
@@ -2317,7 +2530,11 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2317
2530
|
},
|
|
2318
2531
|
{
|
|
2319
2532
|
inputs: [
|
|
2320
|
-
{
|
|
2533
|
+
{
|
|
2534
|
+
internalType: "uint256",
|
|
2535
|
+
name: "_bridgeSlippage",
|
|
2536
|
+
type: "uint256"
|
|
2537
|
+
}
|
|
2321
2538
|
],
|
|
2322
2539
|
name: "setBridgeSlippage",
|
|
2323
2540
|
outputs: [],
|
|
@@ -2352,62 +2569,132 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2352
2569
|
},
|
|
2353
2570
|
{
|
|
2354
2571
|
inputs: [
|
|
2355
|
-
{
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
type: "function"
|
|
2361
|
-
},
|
|
2362
|
-
{
|
|
2363
|
-
inputs: [
|
|
2364
|
-
{ internalType: "uint16", name: "chainId", type: "uint16" },
|
|
2365
|
-
{ internalType: "address", name: "token", type: "address" }
|
|
2572
|
+
{
|
|
2573
|
+
internalType: "address",
|
|
2574
|
+
name: "_nonceCounter",
|
|
2575
|
+
type: "address"
|
|
2576
|
+
}
|
|
2366
2577
|
],
|
|
2367
|
-
name: "
|
|
2578
|
+
name: "setNonceCounter",
|
|
2368
2579
|
outputs: [],
|
|
2369
2580
|
stateMutability: "nonpayable",
|
|
2370
2581
|
type: "function"
|
|
2371
2582
|
},
|
|
2372
2583
|
{
|
|
2373
2584
|
inputs: [
|
|
2374
|
-
{
|
|
2375
|
-
|
|
2376
|
-
|
|
2585
|
+
{
|
|
2586
|
+
internalType: "bool",
|
|
2587
|
+
name: "_orderlyFeeToggle",
|
|
2588
|
+
type: "bool"
|
|
2589
|
+
}
|
|
2377
2590
|
],
|
|
2378
|
-
name: "
|
|
2591
|
+
name: "setOrderlyFeeToggle",
|
|
2379
2592
|
outputs: [],
|
|
2380
2593
|
stateMutability: "nonpayable",
|
|
2381
2594
|
type: "function"
|
|
2382
2595
|
},
|
|
2383
2596
|
{
|
|
2384
2597
|
inputs: [
|
|
2385
|
-
{
|
|
2598
|
+
{
|
|
2599
|
+
internalType: "uint16",
|
|
2600
|
+
name: "_sgChainIdLocal",
|
|
2601
|
+
type: "uint16"
|
|
2602
|
+
}
|
|
2386
2603
|
],
|
|
2387
|
-
name: "
|
|
2604
|
+
name: "setSgChainIdLocal",
|
|
2388
2605
|
outputs: [],
|
|
2389
2606
|
stateMutability: "nonpayable",
|
|
2390
2607
|
type: "function"
|
|
2391
2608
|
},
|
|
2392
2609
|
{
|
|
2393
2610
|
inputs: [
|
|
2394
|
-
{
|
|
2611
|
+
{
|
|
2612
|
+
internalType: "uint16",
|
|
2613
|
+
name: "chainId",
|
|
2614
|
+
type: "uint16"
|
|
2615
|
+
},
|
|
2395
2616
|
{
|
|
2396
2617
|
internalType: "address",
|
|
2397
|
-
name: "
|
|
2618
|
+
name: "token",
|
|
2398
2619
|
type: "address"
|
|
2399
2620
|
}
|
|
2400
2621
|
],
|
|
2401
|
-
name: "
|
|
2622
|
+
name: "setSgETH",
|
|
2402
2623
|
outputs: [],
|
|
2403
2624
|
stateMutability: "nonpayable",
|
|
2404
2625
|
type: "function"
|
|
2405
2626
|
},
|
|
2406
2627
|
{
|
|
2407
2628
|
inputs: [
|
|
2408
|
-
{
|
|
2409
|
-
|
|
2410
|
-
|
|
2629
|
+
{
|
|
2630
|
+
internalType: "uint16",
|
|
2631
|
+
name: "chainId",
|
|
2632
|
+
type: "uint16"
|
|
2633
|
+
},
|
|
2634
|
+
{
|
|
2635
|
+
internalType: "address",
|
|
2636
|
+
name: "token",
|
|
2637
|
+
type: "address"
|
|
2638
|
+
},
|
|
2639
|
+
{
|
|
2640
|
+
internalType: "uint256",
|
|
2641
|
+
name: "poolId",
|
|
2642
|
+
type: "uint256"
|
|
2643
|
+
}
|
|
2644
|
+
],
|
|
2645
|
+
name: "setSgPoolId",
|
|
2646
|
+
outputs: [],
|
|
2647
|
+
stateMutability: "nonpayable",
|
|
2648
|
+
type: "function"
|
|
2649
|
+
},
|
|
2650
|
+
{
|
|
2651
|
+
inputs: [
|
|
2652
|
+
{
|
|
2653
|
+
internalType: "address",
|
|
2654
|
+
name: "_sgRouter",
|
|
2655
|
+
type: "address"
|
|
2656
|
+
}
|
|
2657
|
+
],
|
|
2658
|
+
name: "setSgRouter",
|
|
2659
|
+
outputs: [],
|
|
2660
|
+
stateMutability: "nonpayable",
|
|
2661
|
+
type: "function"
|
|
2662
|
+
},
|
|
2663
|
+
{
|
|
2664
|
+
inputs: [
|
|
2665
|
+
{
|
|
2666
|
+
internalType: "uint16",
|
|
2667
|
+
name: "chainId",
|
|
2668
|
+
type: "uint16"
|
|
2669
|
+
},
|
|
2670
|
+
{
|
|
2671
|
+
internalType: "address",
|
|
2672
|
+
name: "woofiDexCrossChainRouter",
|
|
2673
|
+
type: "address"
|
|
2674
|
+
}
|
|
2675
|
+
],
|
|
2676
|
+
name: "setWOOFiDexCrossChainRouter",
|
|
2677
|
+
outputs: [],
|
|
2678
|
+
stateMutability: "nonpayable",
|
|
2679
|
+
type: "function"
|
|
2680
|
+
},
|
|
2681
|
+
{
|
|
2682
|
+
inputs: [
|
|
2683
|
+
{
|
|
2684
|
+
internalType: "uint16",
|
|
2685
|
+
name: "chainId",
|
|
2686
|
+
type: "uint16"
|
|
2687
|
+
},
|
|
2688
|
+
{
|
|
2689
|
+
internalType: "address",
|
|
2690
|
+
name: "token",
|
|
2691
|
+
type: "address"
|
|
2692
|
+
},
|
|
2693
|
+
{
|
|
2694
|
+
internalType: "address",
|
|
2695
|
+
name: "woofiDexVault",
|
|
2696
|
+
type: "address"
|
|
2697
|
+
}
|
|
2411
2698
|
],
|
|
2412
2699
|
name: "setWOOFiDexVault",
|
|
2413
2700
|
outputs: [],
|
|
@@ -2415,7 +2702,13 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2415
2702
|
type: "function"
|
|
2416
2703
|
},
|
|
2417
2704
|
{
|
|
2418
|
-
inputs: [
|
|
2705
|
+
inputs: [
|
|
2706
|
+
{
|
|
2707
|
+
internalType: "address",
|
|
2708
|
+
name: "_wooRouter",
|
|
2709
|
+
type: "address"
|
|
2710
|
+
}
|
|
2711
|
+
],
|
|
2419
2712
|
name: "setWooRouter",
|
|
2420
2713
|
outputs: [],
|
|
2421
2714
|
stateMutability: "nonpayable",
|
|
@@ -2424,35 +2717,91 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2424
2717
|
{
|
|
2425
2718
|
inputs: [],
|
|
2426
2719
|
name: "sgChainIdLocal",
|
|
2427
|
-
outputs: [
|
|
2720
|
+
outputs: [
|
|
2721
|
+
{
|
|
2722
|
+
internalType: "uint16",
|
|
2723
|
+
name: "",
|
|
2724
|
+
type: "uint16"
|
|
2725
|
+
}
|
|
2726
|
+
],
|
|
2428
2727
|
stateMutability: "view",
|
|
2429
2728
|
type: "function"
|
|
2430
2729
|
},
|
|
2431
2730
|
{
|
|
2432
|
-
inputs: [
|
|
2731
|
+
inputs: [
|
|
2732
|
+
{
|
|
2733
|
+
internalType: "uint16",
|
|
2734
|
+
name: "",
|
|
2735
|
+
type: "uint16"
|
|
2736
|
+
}
|
|
2737
|
+
],
|
|
2433
2738
|
name: "sgETHs",
|
|
2434
|
-
outputs: [
|
|
2739
|
+
outputs: [
|
|
2740
|
+
{
|
|
2741
|
+
internalType: "address",
|
|
2742
|
+
name: "",
|
|
2743
|
+
type: "address"
|
|
2744
|
+
}
|
|
2745
|
+
],
|
|
2435
2746
|
stateMutability: "view",
|
|
2436
2747
|
type: "function"
|
|
2437
2748
|
},
|
|
2438
2749
|
{
|
|
2439
2750
|
inputs: [
|
|
2440
|
-
{
|
|
2441
|
-
|
|
2751
|
+
{
|
|
2752
|
+
internalType: "uint16",
|
|
2753
|
+
name: "",
|
|
2754
|
+
type: "uint16"
|
|
2755
|
+
},
|
|
2756
|
+
{
|
|
2757
|
+
internalType: "address",
|
|
2758
|
+
name: "",
|
|
2759
|
+
type: "address"
|
|
2760
|
+
}
|
|
2442
2761
|
],
|
|
2443
2762
|
name: "sgPoolIds",
|
|
2444
|
-
outputs: [
|
|
2763
|
+
outputs: [
|
|
2764
|
+
{
|
|
2765
|
+
internalType: "uint256",
|
|
2766
|
+
name: "",
|
|
2767
|
+
type: "uint256"
|
|
2768
|
+
}
|
|
2769
|
+
],
|
|
2445
2770
|
stateMutability: "view",
|
|
2446
2771
|
type: "function"
|
|
2447
2772
|
},
|
|
2448
2773
|
{
|
|
2449
2774
|
inputs: [
|
|
2450
|
-
{
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
{
|
|
2775
|
+
{
|
|
2776
|
+
internalType: "uint16",
|
|
2777
|
+
name: "srcChainId",
|
|
2778
|
+
type: "uint16"
|
|
2779
|
+
},
|
|
2780
|
+
{
|
|
2781
|
+
internalType: "bytes",
|
|
2782
|
+
name: "",
|
|
2783
|
+
type: "bytes"
|
|
2784
|
+
},
|
|
2785
|
+
{
|
|
2786
|
+
internalType: "uint256",
|
|
2787
|
+
name: "",
|
|
2788
|
+
type: "uint256"
|
|
2789
|
+
},
|
|
2790
|
+
{
|
|
2791
|
+
internalType: "address",
|
|
2792
|
+
name: "bridgedToken",
|
|
2793
|
+
type: "address"
|
|
2794
|
+
},
|
|
2795
|
+
{
|
|
2796
|
+
internalType: "uint256",
|
|
2797
|
+
name: "bridgedAmount",
|
|
2798
|
+
type: "uint256"
|
|
2799
|
+
},
|
|
2800
|
+
{
|
|
2801
|
+
internalType: "bytes",
|
|
2802
|
+
name: "payload",
|
|
2803
|
+
type: "bytes"
|
|
2804
|
+
}
|
|
2456
2805
|
],
|
|
2457
2806
|
name: "sgReceive",
|
|
2458
2807
|
outputs: [],
|
|
@@ -2461,15 +2810,25 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2461
2810
|
},
|
|
2462
2811
|
{
|
|
2463
2812
|
inputs: [],
|
|
2464
|
-
name: "
|
|
2813
|
+
name: "sgRouter",
|
|
2465
2814
|
outputs: [
|
|
2466
|
-
{
|
|
2815
|
+
{
|
|
2816
|
+
internalType: "address",
|
|
2817
|
+
name: "",
|
|
2818
|
+
type: "address"
|
|
2819
|
+
}
|
|
2467
2820
|
],
|
|
2468
2821
|
stateMutability: "view",
|
|
2469
2822
|
type: "function"
|
|
2470
2823
|
},
|
|
2471
2824
|
{
|
|
2472
|
-
inputs: [
|
|
2825
|
+
inputs: [
|
|
2826
|
+
{
|
|
2827
|
+
internalType: "address",
|
|
2828
|
+
name: "newOwner",
|
|
2829
|
+
type: "address"
|
|
2830
|
+
}
|
|
2831
|
+
],
|
|
2473
2832
|
name: "transferOwnership",
|
|
2474
2833
|
outputs: [],
|
|
2475
2834
|
stateMutability: "nonpayable",
|
|
@@ -2485,7 +2844,13 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2485
2844
|
{
|
|
2486
2845
|
inputs: [],
|
|
2487
2846
|
name: "weth",
|
|
2488
|
-
outputs: [
|
|
2847
|
+
outputs: [
|
|
2848
|
+
{
|
|
2849
|
+
internalType: "address",
|
|
2850
|
+
name: "",
|
|
2851
|
+
type: "address"
|
|
2852
|
+
}
|
|
2853
|
+
],
|
|
2489
2854
|
stateMutability: "view",
|
|
2490
2855
|
type: "function"
|
|
2491
2856
|
},
|
|
@@ -2493,29 +2858,62 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
2493
2858
|
inputs: [],
|
|
2494
2859
|
name: "wooRouter",
|
|
2495
2860
|
outputs: [
|
|
2496
|
-
{
|
|
2861
|
+
{
|
|
2862
|
+
internalType: "address",
|
|
2863
|
+
name: "",
|
|
2864
|
+
type: "address"
|
|
2865
|
+
}
|
|
2497
2866
|
],
|
|
2498
2867
|
stateMutability: "view",
|
|
2499
2868
|
type: "function"
|
|
2500
2869
|
},
|
|
2501
2870
|
{
|
|
2502
|
-
inputs: [
|
|
2871
|
+
inputs: [
|
|
2872
|
+
{
|
|
2873
|
+
internalType: "uint16",
|
|
2874
|
+
name: "",
|
|
2875
|
+
type: "uint16"
|
|
2876
|
+
}
|
|
2877
|
+
],
|
|
2503
2878
|
name: "woofiDexCrossChainRouters",
|
|
2504
|
-
outputs: [
|
|
2879
|
+
outputs: [
|
|
2880
|
+
{
|
|
2881
|
+
internalType: "address",
|
|
2882
|
+
name: "",
|
|
2883
|
+
type: "address"
|
|
2884
|
+
}
|
|
2885
|
+
],
|
|
2505
2886
|
stateMutability: "view",
|
|
2506
2887
|
type: "function"
|
|
2507
2888
|
},
|
|
2508
2889
|
{
|
|
2509
2890
|
inputs: [
|
|
2510
|
-
{
|
|
2511
|
-
|
|
2891
|
+
{
|
|
2892
|
+
internalType: "uint16",
|
|
2893
|
+
name: "",
|
|
2894
|
+
type: "uint16"
|
|
2895
|
+
},
|
|
2896
|
+
{
|
|
2897
|
+
internalType: "address",
|
|
2898
|
+
name: "",
|
|
2899
|
+
type: "address"
|
|
2900
|
+
}
|
|
2512
2901
|
],
|
|
2513
2902
|
name: "woofiDexVaults",
|
|
2514
|
-
outputs: [
|
|
2903
|
+
outputs: [
|
|
2904
|
+
{
|
|
2905
|
+
internalType: "address",
|
|
2906
|
+
name: "",
|
|
2907
|
+
type: "address"
|
|
2908
|
+
}
|
|
2909
|
+
],
|
|
2515
2910
|
stateMutability: "view",
|
|
2516
2911
|
type: "function"
|
|
2517
2912
|
},
|
|
2518
|
-
{
|
|
2913
|
+
{
|
|
2914
|
+
stateMutability: "payable",
|
|
2915
|
+
type: "receive"
|
|
2916
|
+
}
|
|
2519
2917
|
];
|
|
2520
2918
|
var nativeTokenAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
2521
2919
|
|
|
@@ -2535,6 +2933,10 @@ var useChains = (networkId, options = {}) => {
|
|
|
2535
2933
|
revalidateIfStale: false,
|
|
2536
2934
|
revalidateOnFocus: false,
|
|
2537
2935
|
revalidateOnReconnect: false,
|
|
2936
|
+
revalidateOnMount: true,
|
|
2937
|
+
// If false, undefined data gets cached against the key.
|
|
2938
|
+
dedupingInterval: 36e5,
|
|
2939
|
+
// dont duplicate a request w/ same key for 1hr
|
|
2538
2940
|
...swrOptions
|
|
2539
2941
|
}
|
|
2540
2942
|
);
|
|
@@ -2543,7 +2945,9 @@ var useChains = (networkId, options = {}) => {
|
|
|
2543
2945
|
{
|
|
2544
2946
|
revalidateIfStale: false,
|
|
2545
2947
|
revalidateOnFocus: false,
|
|
2546
|
-
revalidateOnReconnect: false
|
|
2948
|
+
revalidateOnReconnect: false,
|
|
2949
|
+
revalidateOnMount: true,
|
|
2950
|
+
dedupingInterval: 36e5
|
|
2547
2951
|
}
|
|
2548
2952
|
);
|
|
2549
2953
|
const chains = useMemo(() => {
|
|
@@ -2579,35 +2983,46 @@ var useChains = (networkId, options = {}) => {
|
|
|
2579
2983
|
});
|
|
2580
2984
|
});
|
|
2581
2985
|
if (!wooSwapEnabled) {
|
|
2582
|
-
|
|
2986
|
+
let arr = orderlyChainsArr;
|
|
2987
|
+
if (typeof options?.filter === "function") {
|
|
2988
|
+
arr = orderlyChainsArr.filter(options.filter);
|
|
2989
|
+
}
|
|
2990
|
+
if (!!field) {
|
|
2991
|
+
arr = arr.map((item) => item[field]);
|
|
2992
|
+
}
|
|
2993
|
+
return arr;
|
|
2583
2994
|
} else {
|
|
2584
2995
|
if (!data || !data.data)
|
|
2585
2996
|
return data;
|
|
2586
|
-
let testnetArr = [
|
|
2997
|
+
let testnetArr = [
|
|
2998
|
+
//@ts-ignore
|
|
2999
|
+
{
|
|
3000
|
+
network_infos: {
|
|
3001
|
+
name: "Arbitrum Goerli",
|
|
3002
|
+
public_rpc_url: "https://goerli-rollup.arbitrum.io/rpc",
|
|
3003
|
+
chain_id: 421613,
|
|
3004
|
+
currency_symbol: "ETH",
|
|
3005
|
+
bridge_enable: true,
|
|
3006
|
+
mainnet: false,
|
|
3007
|
+
explorer_base_url: "https://goerli.arbiscan.io/",
|
|
3008
|
+
est_txn_mins: null,
|
|
3009
|
+
woofi_dex_cross_chain_router: "",
|
|
3010
|
+
woofi_dex_depositor: ""
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
];
|
|
2587
3014
|
let mainnetArr = [];
|
|
2588
3015
|
Object.keys(data.data).forEach((key) => {
|
|
2589
3016
|
const chain = data.data[key];
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
token_infos: chain.token_infos
|
|
2600
|
-
};
|
|
2601
|
-
map.current.set(chain.network_infos.chain_id, mergedChain);
|
|
2602
|
-
}
|
|
2603
|
-
return item2;
|
|
2604
|
-
});
|
|
2605
|
-
return;
|
|
2606
|
-
}
|
|
2607
|
-
const item = {
|
|
2608
|
-
...chain,
|
|
2609
|
-
name: key
|
|
2610
|
-
};
|
|
3017
|
+
const item = mergeDeepRight(chain, {
|
|
3018
|
+
name: key,
|
|
3019
|
+
network_infos: {
|
|
3020
|
+
bridgeless: orderlyChainIds.has(chain.network_infos.chain_id)
|
|
3021
|
+
},
|
|
3022
|
+
token_infos: chain.token_infos.filter(
|
|
3023
|
+
(token) => !!token.swap_enable
|
|
3024
|
+
)
|
|
3025
|
+
});
|
|
2611
3026
|
if (item.token_infos?.length === 0)
|
|
2612
3027
|
return;
|
|
2613
3028
|
map.current.set(item.network_infos.chain_id, item);
|
|
@@ -2621,13 +3036,12 @@ var useChains = (networkId, options = {}) => {
|
|
|
2621
3036
|
testnetArr.push(item);
|
|
2622
3037
|
}
|
|
2623
3038
|
});
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
}
|
|
3039
|
+
mainnetArr.sort((a, b) => {
|
|
3040
|
+
return a.network_infos.bridgeless ? -1 : 1;
|
|
3041
|
+
});
|
|
3042
|
+
testnetArr.sort((a, b) => {
|
|
3043
|
+
return a.network_infos.bridgeless ? -1 : 1;
|
|
3044
|
+
});
|
|
2631
3045
|
if (!!field) {
|
|
2632
3046
|
testnetArr = testnetArr.map((item) => item[field]);
|
|
2633
3047
|
mainnetArr = mainnetArr.map((item) => item[field]);
|
|
@@ -2713,19 +3127,28 @@ var useWithdraw = () => {
|
|
|
2713
3127
|
};
|
|
2714
3128
|
var isNativeTokenChecker = (address) => address === nativeTokenAddress;
|
|
2715
3129
|
var useDeposit = (options) => {
|
|
3130
|
+
const { onlyTestnet } = useContext(OrderlyContext);
|
|
2716
3131
|
const [balanceRevalidating, setBalanceRevalidating] = useState(false);
|
|
2717
3132
|
const [allowanceRevalidating, setAllowanceRevalidating] = useState(false);
|
|
3133
|
+
const [_, { findByChainId }] = useChains(void 0, {
|
|
3134
|
+
wooSwapEnabled: true
|
|
3135
|
+
});
|
|
2718
3136
|
const [balance, setBalance] = useState("0");
|
|
2719
3137
|
const [allowance, setAllowance] = useState("0");
|
|
2720
3138
|
const { account: account5, state } = useAccount();
|
|
2721
3139
|
const dst = useMemo(() => {
|
|
3140
|
+
const chain = onlyTestnet ? findByChainId(ARBITRUM_TESTNET_CHAINID) : findByChainId(ARBITRUM_MAINNET_CHAINID);
|
|
3141
|
+
const USDC = chain?.token_infos.find((token) => token.symbol === "USDC");
|
|
3142
|
+
if (!chain) {
|
|
3143
|
+
throw new Error("dst chain not found");
|
|
3144
|
+
}
|
|
2722
3145
|
return {
|
|
2723
3146
|
symbol: "USDC",
|
|
2724
|
-
address:
|
|
2725
|
-
decimals:
|
|
2726
|
-
|
|
2727
|
-
network:
|
|
2728
|
-
chainId: 42161
|
|
3147
|
+
address: USDC?.address,
|
|
3148
|
+
decimals: USDC?.decimals,
|
|
3149
|
+
chainId: chain.network_infos.chain_id,
|
|
3150
|
+
network: chain.network_infos.name
|
|
3151
|
+
// chainId: 42161,
|
|
2729
3152
|
};
|
|
2730
3153
|
}, []);
|
|
2731
3154
|
const isNativeToken = useMemo(
|
|
@@ -2778,8 +3201,9 @@ var useDeposit = (options) => {
|
|
|
2778
3201
|
const balances = await Promise.all(tasks);
|
|
2779
3202
|
console.log("----- get balances from tokens -----", balances);
|
|
2780
3203
|
}, []);
|
|
2781
|
-
const
|
|
2782
|
-
async (address) => {
|
|
3204
|
+
const getAllowance = useCallback(
|
|
3205
|
+
async (address, vaultAddress) => {
|
|
3206
|
+
console.log("getAllowance", address, vaultAddress);
|
|
2783
3207
|
if (!address)
|
|
2784
3208
|
return;
|
|
2785
3209
|
if (address && isNativeTokenChecker(address))
|
|
@@ -2787,7 +3211,10 @@ var useDeposit = (options) => {
|
|
|
2787
3211
|
if (allowanceRevalidating)
|
|
2788
3212
|
return;
|
|
2789
3213
|
setAllowanceRevalidating(true);
|
|
2790
|
-
const allowance2 = await account5.assetsManager.getAllowance(
|
|
3214
|
+
const allowance2 = await account5.assetsManager.getAllowance(
|
|
3215
|
+
address,
|
|
3216
|
+
vaultAddress
|
|
3217
|
+
);
|
|
2791
3218
|
console.log("----- refresh allowance -----", allowance2);
|
|
2792
3219
|
setAllowance(() => allowance2);
|
|
2793
3220
|
setAllowanceRevalidating(false);
|
|
@@ -2796,25 +3223,24 @@ var useDeposit = (options) => {
|
|
|
2796
3223
|
[allowanceRevalidating]
|
|
2797
3224
|
);
|
|
2798
3225
|
useEffect(() => {
|
|
2799
|
-
|
|
2800
|
-
if (state.status < AccountStatusEnum.EnableTrading)
|
|
3226
|
+
if (state.status < AccountStatusEnum.Connected)
|
|
2801
3227
|
return;
|
|
2802
3228
|
fetchBalance(options?.address);
|
|
2803
|
-
|
|
2804
|
-
}, [state.status, options?.address]);
|
|
3229
|
+
getAllowance(options?.address, options?.vaultAddress);
|
|
3230
|
+
}, [state.status, options?.address, options?.vaultAddress, account5.address]);
|
|
2805
3231
|
const approve = useCallback(
|
|
2806
3232
|
(amount) => {
|
|
2807
3233
|
if (!options?.address) {
|
|
2808
3234
|
throw new Error("address is required");
|
|
2809
3235
|
}
|
|
2810
|
-
return account5.assetsManager.approve(options.address, amount).then((result) => {
|
|
3236
|
+
return account5.assetsManager.approve(options.address, amount, options?.vaultAddress).then((result) => {
|
|
2811
3237
|
if (typeof amount !== "undefined") {
|
|
2812
3238
|
setAllowance((value) => new Decimal(value).add(amount).toString());
|
|
2813
3239
|
}
|
|
2814
3240
|
return result;
|
|
2815
3241
|
});
|
|
2816
3242
|
},
|
|
2817
|
-
[account5,
|
|
3243
|
+
[account5, getAllowance, options?.address, options?.vaultAddress]
|
|
2818
3244
|
);
|
|
2819
3245
|
const deposit = useCallback(
|
|
2820
3246
|
(amount) => {
|
|
@@ -2824,7 +3250,7 @@ var useDeposit = (options) => {
|
|
|
2824
3250
|
return res;
|
|
2825
3251
|
});
|
|
2826
3252
|
},
|
|
2827
|
-
[account5, fetchBalance,
|
|
3253
|
+
[account5, fetchBalance, getAllowance]
|
|
2828
3254
|
);
|
|
2829
3255
|
return {
|
|
2830
3256
|
dst,
|
|
@@ -3060,12 +3486,12 @@ var useWooCrossSwapQuery = () => {
|
|
|
3060
3486
|
};
|
|
3061
3487
|
}, [account5]);
|
|
3062
3488
|
const queryDestinationFee = useCallback(
|
|
3063
|
-
async (dst) => {
|
|
3489
|
+
async (crossChainRouteAddress, dst) => {
|
|
3064
3490
|
if (!account5.walletClient) {
|
|
3065
3491
|
throw new Error("walletClient is not ready");
|
|
3066
3492
|
}
|
|
3067
3493
|
const quotoLZFee = await account5.walletClient.call(
|
|
3068
|
-
|
|
3494
|
+
crossChainRouteAddress,
|
|
3069
3495
|
"quoteLayerZeroFee",
|
|
3070
3496
|
[account5.address, dst, dstValutDeposit()],
|
|
3071
3497
|
{
|
|
@@ -3111,12 +3537,12 @@ var useWooCrossSwapQuery = () => {
|
|
|
3111
3537
|
}
|
|
3112
3538
|
throw new Error(data.message);
|
|
3113
3539
|
}).then((swapInfo) => {
|
|
3114
|
-
return queryDestinationFee({
|
|
3540
|
+
return queryDestinationFee(inputs.crossChainRouteAddress, {
|
|
3115
3541
|
chainId: swapInfo.dst_infos.chain_id,
|
|
3116
3542
|
bridgedToken: swapInfo.dst_infos.bridged_token,
|
|
3117
3543
|
toToken: swapInfo.dst_infos.to_token,
|
|
3118
3544
|
minToAmount: BigInt(swapInfo.dst_infos.min_to_amount),
|
|
3119
|
-
|
|
3545
|
+
orderlyNativeFees: 0n
|
|
3120
3546
|
}).then((data) => {
|
|
3121
3547
|
console.log("res::::", data);
|
|
3122
3548
|
return {
|
|
@@ -3187,45 +3613,54 @@ var useCrossSwap = () => {
|
|
|
3187
3613
|
if (!account5.walletClient) {
|
|
3188
3614
|
throw new Error("walletClient is undefined");
|
|
3189
3615
|
}
|
|
3190
|
-
|
|
3616
|
+
if (!account5.address) {
|
|
3617
|
+
throw new Error("account.address is undefined");
|
|
3618
|
+
}
|
|
3619
|
+
if (!inputs.crossChainRouteAddress) {
|
|
3620
|
+
throw new Error("crossChainRouteAddress is undefined");
|
|
3621
|
+
}
|
|
3622
|
+
const { address, src, dst, crossChainRouteAddress } = inputs;
|
|
3191
3623
|
if (loading)
|
|
3192
3624
|
return;
|
|
3193
3625
|
start();
|
|
3194
3626
|
const quotoLZFee = await account5.walletClient.call(
|
|
3195
|
-
|
|
3627
|
+
crossChainRouteAddress,
|
|
3196
3628
|
"quoteLayerZeroFee",
|
|
3197
3629
|
[account5.address, dst, dstValutDeposit()],
|
|
3198
3630
|
{
|
|
3199
3631
|
abi: woofiDexCrossChainRouterAbi
|
|
3200
3632
|
}
|
|
3201
3633
|
);
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
account5.address,
|
|
3207
|
-
src,
|
|
3208
|
-
dst,
|
|
3209
|
-
dstValutDeposit(),
|
|
3634
|
+
try {
|
|
3635
|
+
const result = await account5.walletClient.sendTransaction(
|
|
3636
|
+
crossChainRouteAddress,
|
|
3637
|
+
"crossSwap",
|
|
3210
3638
|
{
|
|
3639
|
+
from: account5.address,
|
|
3640
|
+
to: crossChainRouteAddress,
|
|
3641
|
+
data: [account5.address, src, dst, dstValutDeposit()],
|
|
3211
3642
|
value: quotoLZFee[0]
|
|
3643
|
+
},
|
|
3644
|
+
{
|
|
3645
|
+
abi: woofiDexCrossChainRouterAbi
|
|
3212
3646
|
}
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
(
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
)
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3647
|
+
);
|
|
3648
|
+
account5.walletClient.on(
|
|
3649
|
+
{
|
|
3650
|
+
address: crossChainRouteAddress
|
|
3651
|
+
},
|
|
3652
|
+
(log, event) => {
|
|
3653
|
+
console.log("-------------", log, event);
|
|
3654
|
+
}
|
|
3655
|
+
);
|
|
3656
|
+
stop();
|
|
3657
|
+
checkLayerStatus(result.hash);
|
|
3658
|
+
return pick(["from", "to", "hash", "value"], result);
|
|
3659
|
+
} catch (e) {
|
|
3660
|
+
console.log("swap error:", e);
|
|
3661
|
+
stop();
|
|
3662
|
+
throw new Error(e.errorCode);
|
|
3663
|
+
}
|
|
3229
3664
|
};
|
|
3230
3665
|
return {
|
|
3231
3666
|
swap,
|
|
@@ -3234,15 +3669,15 @@ var useCrossSwap = () => {
|
|
|
3234
3669
|
message: bridgeMessage
|
|
3235
3670
|
};
|
|
3236
3671
|
};
|
|
3237
|
-
var woofiDexDepositor = "0xfD7ed9D3d4fD88595AF6a87f798ffDB42b4D7ccB";
|
|
3238
3672
|
var woofiDexDepositorAbi = [
|
|
3673
|
+
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
3239
3674
|
{
|
|
3675
|
+
anonymous: false,
|
|
3240
3676
|
inputs: [
|
|
3241
|
-
{ internalType: "
|
|
3242
|
-
{ internalType: "address", name: "_wooRouter", type: "address" }
|
|
3677
|
+
{ indexed: false, internalType: "uint8", name: "version", type: "uint8" }
|
|
3243
3678
|
],
|
|
3244
|
-
|
|
3245
|
-
type: "
|
|
3679
|
+
name: "Initialized",
|
|
3680
|
+
type: "event"
|
|
3246
3681
|
},
|
|
3247
3682
|
{
|
|
3248
3683
|
anonymous: false,
|
|
@@ -3329,6 +3764,12 @@ var woofiDexDepositorAbi = [
|
|
|
3329
3764
|
name: "toAmount",
|
|
3330
3765
|
type: "uint256"
|
|
3331
3766
|
},
|
|
3767
|
+
{
|
|
3768
|
+
indexed: false,
|
|
3769
|
+
internalType: "uint256",
|
|
3770
|
+
name: "orderlyNativeFees",
|
|
3771
|
+
type: "uint256"
|
|
3772
|
+
},
|
|
3332
3773
|
{
|
|
3333
3774
|
indexed: false,
|
|
3334
3775
|
internalType: "bytes32",
|
|
@@ -3371,6 +3812,20 @@ var woofiDexDepositorAbi = [
|
|
|
3371
3812
|
stateMutability: "nonpayable",
|
|
3372
3813
|
type: "function"
|
|
3373
3814
|
},
|
|
3815
|
+
{
|
|
3816
|
+
inputs: [{ internalType: "address", name: "_wooRouter", type: "address" }],
|
|
3817
|
+
name: "initialize",
|
|
3818
|
+
outputs: [],
|
|
3819
|
+
stateMutability: "nonpayable",
|
|
3820
|
+
type: "function"
|
|
3821
|
+
},
|
|
3822
|
+
{
|
|
3823
|
+
inputs: [],
|
|
3824
|
+
name: "orderlyFeeToggle",
|
|
3825
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
3826
|
+
stateMutability: "view",
|
|
3827
|
+
type: "function"
|
|
3828
|
+
},
|
|
3374
3829
|
{
|
|
3375
3830
|
inputs: [],
|
|
3376
3831
|
name: "owner",
|
|
@@ -3399,6 +3854,13 @@ var woofiDexDepositorAbi = [
|
|
|
3399
3854
|
stateMutability: "nonpayable",
|
|
3400
3855
|
type: "function"
|
|
3401
3856
|
},
|
|
3857
|
+
{
|
|
3858
|
+
inputs: [{ internalType: "bool", name: "_orderlyFeeToggle", type: "bool" }],
|
|
3859
|
+
name: "setOrderlyFeeToggle",
|
|
3860
|
+
outputs: [],
|
|
3861
|
+
stateMutability: "nonpayable",
|
|
3862
|
+
type: "function"
|
|
3863
|
+
},
|
|
3402
3864
|
{
|
|
3403
3865
|
inputs: [
|
|
3404
3866
|
{ internalType: "address", name: "token", type: "address" },
|
|
@@ -3424,9 +3886,14 @@ var woofiDexDepositorAbi = [
|
|
|
3424
3886
|
{ internalType: "address", name: "fromToken", type: "address" },
|
|
3425
3887
|
{ internalType: "uint256", name: "fromAmount", type: "uint256" },
|
|
3426
3888
|
{ internalType: "address", name: "toToken", type: "address" },
|
|
3427
|
-
{ internalType: "uint256", name: "minToAmount", type: "uint256" }
|
|
3889
|
+
{ internalType: "uint256", name: "minToAmount", type: "uint256" },
|
|
3890
|
+
{
|
|
3891
|
+
internalType: "uint256",
|
|
3892
|
+
name: "orderlyNativeFees",
|
|
3893
|
+
type: "uint256"
|
|
3894
|
+
}
|
|
3428
3895
|
],
|
|
3429
|
-
internalType: "struct
|
|
3896
|
+
internalType: "struct IWOOFiDexDepositor.Infos",
|
|
3430
3897
|
name: "infos",
|
|
3431
3898
|
type: "tuple"
|
|
3432
3899
|
},
|
|
@@ -3436,7 +3903,7 @@ var woofiDexDepositorAbi = [
|
|
|
3436
3903
|
{ internalType: "bytes32", name: "brokerHash", type: "bytes32" },
|
|
3437
3904
|
{ internalType: "bytes32", name: "tokenHash", type: "bytes32" }
|
|
3438
3905
|
],
|
|
3439
|
-
internalType: "struct
|
|
3906
|
+
internalType: "struct IWOOFiDexDepositor.VaultDeposit",
|
|
3440
3907
|
name: "vaultDeposit",
|
|
3441
3908
|
type: "tuple"
|
|
3442
3909
|
}
|
|
@@ -3460,19 +3927,10 @@ var woofiDexDepositorAbi = [
|
|
|
3460
3927
|
stateMutability: "nonpayable",
|
|
3461
3928
|
type: "function"
|
|
3462
3929
|
},
|
|
3463
|
-
{
|
|
3464
|
-
inputs: [],
|
|
3465
|
-
name: "weth",
|
|
3466
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
3467
|
-
stateMutability: "view",
|
|
3468
|
-
type: "function"
|
|
3469
|
-
},
|
|
3470
3930
|
{
|
|
3471
3931
|
inputs: [],
|
|
3472
3932
|
name: "wooRouter",
|
|
3473
|
-
outputs: [
|
|
3474
|
-
{ internalType: "contract IWooRouterV2", name: "", type: "address" }
|
|
3475
|
-
],
|
|
3933
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
3476
3934
|
stateMutability: "view",
|
|
3477
3935
|
type: "function"
|
|
3478
3936
|
},
|
|
@@ -3497,21 +3955,36 @@ var useSwap = () => {
|
|
|
3497
3955
|
};
|
|
3498
3956
|
}, [account5]);
|
|
3499
3957
|
const swap = useCallback(
|
|
3500
|
-
async (inputs) => {
|
|
3958
|
+
async (woofiDexDepositorAdress, inputs) => {
|
|
3959
|
+
if (!account5.walletClient) {
|
|
3960
|
+
throw new Error("walletClient is undefined");
|
|
3961
|
+
}
|
|
3962
|
+
if (!account5.address) {
|
|
3963
|
+
throw new Error("account.address is undefined");
|
|
3964
|
+
}
|
|
3501
3965
|
if (loading)
|
|
3502
3966
|
return;
|
|
3503
3967
|
start();
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3968
|
+
console.log("---------", inputs);
|
|
3969
|
+
try {
|
|
3970
|
+
const result = await account5.walletClient.sendTransaction(
|
|
3971
|
+
woofiDexDepositorAdress,
|
|
3972
|
+
"swap",
|
|
3973
|
+
{
|
|
3974
|
+
from: account5.address,
|
|
3975
|
+
to: woofiDexDepositorAdress,
|
|
3976
|
+
data: [account5.address, inputs, dstValutDeposit()]
|
|
3977
|
+
},
|
|
3978
|
+
{
|
|
3979
|
+
abi: woofiDexDepositorAbi
|
|
3980
|
+
}
|
|
3981
|
+
);
|
|
3982
|
+
stop();
|
|
3983
|
+
return pick(["from", "to", "hash", "value"], result);
|
|
3984
|
+
} catch (e) {
|
|
3985
|
+
console.log("\u8C03\u7528\u5408\u7EA6\u62A5\u9519\uFF1A", e);
|
|
3986
|
+
throw new Error(e.errorCode);
|
|
3987
|
+
}
|
|
3515
3988
|
},
|
|
3516
3989
|
[loading, account5]
|
|
3517
3990
|
);
|
|
@@ -3521,6 +3994,6 @@ var useSwap = () => {
|
|
|
3521
3994
|
};
|
|
3522
3995
|
};
|
|
3523
3996
|
|
|
3524
|
-
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,
|
|
3997
|
+
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, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSwap, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
|
3525
3998
|
//# sourceMappingURL=out.js.map
|
|
3526
3999
|
//# sourceMappingURL=index.mjs.map
|