@orderly.network/hooks 0.0.61 → 0.0.63
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 +691 -218
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +694 -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(() => {
|
|
@@ -2560,6 +2964,7 @@ var useChains = (networkId, options = {}) => {
|
|
|
2560
2964
|
name: chain.chain_name ?? "--",
|
|
2561
2965
|
// "public_rpc_url": "https://arb1.arbitrum.io/rpc",
|
|
2562
2966
|
chain_id: chainId,
|
|
2967
|
+
withdrawal_fee: chain.withdrawal_fee,
|
|
2563
2968
|
bridgeless: true
|
|
2564
2969
|
},
|
|
2565
2970
|
token_infos: [
|
|
@@ -2579,35 +2984,46 @@ var useChains = (networkId, options = {}) => {
|
|
|
2579
2984
|
});
|
|
2580
2985
|
});
|
|
2581
2986
|
if (!wooSwapEnabled) {
|
|
2582
|
-
|
|
2987
|
+
let arr = orderlyChainsArr;
|
|
2988
|
+
if (typeof options?.filter === "function") {
|
|
2989
|
+
arr = orderlyChainsArr.filter(options.filter);
|
|
2990
|
+
}
|
|
2991
|
+
if (!!field) {
|
|
2992
|
+
arr = arr.map((item) => item[field]);
|
|
2993
|
+
}
|
|
2994
|
+
return arr;
|
|
2583
2995
|
} else {
|
|
2584
2996
|
if (!data || !data.data)
|
|
2585
2997
|
return data;
|
|
2586
|
-
let testnetArr = [
|
|
2998
|
+
let testnetArr = [
|
|
2999
|
+
//@ts-ignore
|
|
3000
|
+
{
|
|
3001
|
+
network_infos: {
|
|
3002
|
+
name: "Arbitrum Goerli",
|
|
3003
|
+
public_rpc_url: "https://goerli-rollup.arbitrum.io/rpc",
|
|
3004
|
+
chain_id: 421613,
|
|
3005
|
+
currency_symbol: "ETH",
|
|
3006
|
+
bridge_enable: true,
|
|
3007
|
+
mainnet: false,
|
|
3008
|
+
explorer_base_url: "https://goerli.arbiscan.io/",
|
|
3009
|
+
est_txn_mins: null,
|
|
3010
|
+
woofi_dex_cross_chain_router: "",
|
|
3011
|
+
woofi_dex_depositor: ""
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
];
|
|
2587
3015
|
let mainnetArr = [];
|
|
2588
3016
|
Object.keys(data.data).forEach((key) => {
|
|
2589
3017
|
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
|
-
};
|
|
3018
|
+
const item = mergeDeepRight(chain, {
|
|
3019
|
+
name: key,
|
|
3020
|
+
network_infos: {
|
|
3021
|
+
bridgeless: orderlyChainIds.has(chain.network_infos.chain_id)
|
|
3022
|
+
},
|
|
3023
|
+
token_infos: chain.token_infos.filter(
|
|
3024
|
+
(token) => !!token.swap_enable
|
|
3025
|
+
)
|
|
3026
|
+
});
|
|
2611
3027
|
if (item.token_infos?.length === 0)
|
|
2612
3028
|
return;
|
|
2613
3029
|
map.current.set(item.network_infos.chain_id, item);
|
|
@@ -2621,13 +3037,12 @@ var useChains = (networkId, options = {}) => {
|
|
|
2621
3037
|
testnetArr.push(item);
|
|
2622
3038
|
}
|
|
2623
3039
|
});
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
}
|
|
3040
|
+
mainnetArr.sort((a, b) => {
|
|
3041
|
+
return a.network_infos.bridgeless ? -1 : 1;
|
|
3042
|
+
});
|
|
3043
|
+
testnetArr.sort((a, b) => {
|
|
3044
|
+
return a.network_infos.bridgeless ? -1 : 1;
|
|
3045
|
+
});
|
|
2631
3046
|
if (!!field) {
|
|
2632
3047
|
testnetArr = testnetArr.map((item) => item[field]);
|
|
2633
3048
|
mainnetArr = mainnetArr.map((item) => item[field]);
|
|
@@ -2713,19 +3128,28 @@ var useWithdraw = () => {
|
|
|
2713
3128
|
};
|
|
2714
3129
|
var isNativeTokenChecker = (address) => address === nativeTokenAddress;
|
|
2715
3130
|
var useDeposit = (options) => {
|
|
3131
|
+
const { onlyTestnet } = useContext(OrderlyContext);
|
|
2716
3132
|
const [balanceRevalidating, setBalanceRevalidating] = useState(false);
|
|
2717
3133
|
const [allowanceRevalidating, setAllowanceRevalidating] = useState(false);
|
|
3134
|
+
const [_, { findByChainId }] = useChains(void 0, {
|
|
3135
|
+
wooSwapEnabled: true
|
|
3136
|
+
});
|
|
2718
3137
|
const [balance, setBalance] = useState("0");
|
|
2719
3138
|
const [allowance, setAllowance] = useState("0");
|
|
2720
3139
|
const { account: account5, state } = useAccount();
|
|
2721
3140
|
const dst = useMemo(() => {
|
|
3141
|
+
const chain = onlyTestnet ? findByChainId(ARBITRUM_TESTNET_CHAINID) : findByChainId(ARBITRUM_MAINNET_CHAINID);
|
|
3142
|
+
const USDC = chain?.token_infos.find((token) => token.symbol === "USDC");
|
|
3143
|
+
if (!chain) {
|
|
3144
|
+
throw new Error("dst chain not found");
|
|
3145
|
+
}
|
|
2722
3146
|
return {
|
|
2723
3147
|
symbol: "USDC",
|
|
2724
|
-
address:
|
|
2725
|
-
decimals:
|
|
2726
|
-
|
|
2727
|
-
network:
|
|
2728
|
-
chainId: 42161
|
|
3148
|
+
address: USDC?.address,
|
|
3149
|
+
decimals: USDC?.decimals,
|
|
3150
|
+
chainId: chain.network_infos.chain_id,
|
|
3151
|
+
network: chain.network_infos.name
|
|
3152
|
+
// chainId: 42161,
|
|
2729
3153
|
};
|
|
2730
3154
|
}, []);
|
|
2731
3155
|
const isNativeToken = useMemo(
|
|
@@ -2778,8 +3202,9 @@ var useDeposit = (options) => {
|
|
|
2778
3202
|
const balances = await Promise.all(tasks);
|
|
2779
3203
|
console.log("----- get balances from tokens -----", balances);
|
|
2780
3204
|
}, []);
|
|
2781
|
-
const
|
|
2782
|
-
async (address) => {
|
|
3205
|
+
const getAllowance = useCallback(
|
|
3206
|
+
async (address, vaultAddress) => {
|
|
3207
|
+
console.log("getAllowance", address, vaultAddress);
|
|
2783
3208
|
if (!address)
|
|
2784
3209
|
return;
|
|
2785
3210
|
if (address && isNativeTokenChecker(address))
|
|
@@ -2787,7 +3212,10 @@ var useDeposit = (options) => {
|
|
|
2787
3212
|
if (allowanceRevalidating)
|
|
2788
3213
|
return;
|
|
2789
3214
|
setAllowanceRevalidating(true);
|
|
2790
|
-
const allowance2 = await account5.assetsManager.getAllowance(
|
|
3215
|
+
const allowance2 = await account5.assetsManager.getAllowance(
|
|
3216
|
+
address,
|
|
3217
|
+
vaultAddress
|
|
3218
|
+
);
|
|
2791
3219
|
console.log("----- refresh allowance -----", allowance2);
|
|
2792
3220
|
setAllowance(() => allowance2);
|
|
2793
3221
|
setAllowanceRevalidating(false);
|
|
@@ -2796,25 +3224,24 @@ var useDeposit = (options) => {
|
|
|
2796
3224
|
[allowanceRevalidating]
|
|
2797
3225
|
);
|
|
2798
3226
|
useEffect(() => {
|
|
2799
|
-
|
|
2800
|
-
if (state.status < AccountStatusEnum.EnableTrading)
|
|
3227
|
+
if (state.status < AccountStatusEnum.Connected)
|
|
2801
3228
|
return;
|
|
2802
3229
|
fetchBalance(options?.address);
|
|
2803
|
-
|
|
2804
|
-
}, [state.status, options?.address]);
|
|
3230
|
+
getAllowance(options?.address, options?.vaultAddress);
|
|
3231
|
+
}, [state.status, options?.address, options?.vaultAddress, account5.address]);
|
|
2805
3232
|
const approve = useCallback(
|
|
2806
3233
|
(amount) => {
|
|
2807
3234
|
if (!options?.address) {
|
|
2808
3235
|
throw new Error("address is required");
|
|
2809
3236
|
}
|
|
2810
|
-
return account5.assetsManager.approve(options.address, amount).then((result) => {
|
|
3237
|
+
return account5.assetsManager.approve(options.address, amount, options?.vaultAddress).then((result) => {
|
|
2811
3238
|
if (typeof amount !== "undefined") {
|
|
2812
3239
|
setAllowance((value) => new Decimal(value).add(amount).toString());
|
|
2813
3240
|
}
|
|
2814
3241
|
return result;
|
|
2815
3242
|
});
|
|
2816
3243
|
},
|
|
2817
|
-
[account5,
|
|
3244
|
+
[account5, getAllowance, options?.address, options?.vaultAddress]
|
|
2818
3245
|
);
|
|
2819
3246
|
const deposit = useCallback(
|
|
2820
3247
|
(amount) => {
|
|
@@ -2824,7 +3251,7 @@ var useDeposit = (options) => {
|
|
|
2824
3251
|
return res;
|
|
2825
3252
|
});
|
|
2826
3253
|
},
|
|
2827
|
-
[account5, fetchBalance,
|
|
3254
|
+
[account5, fetchBalance, getAllowance]
|
|
2828
3255
|
);
|
|
2829
3256
|
return {
|
|
2830
3257
|
dst,
|
|
@@ -3060,12 +3487,12 @@ var useWooCrossSwapQuery = () => {
|
|
|
3060
3487
|
};
|
|
3061
3488
|
}, [account5]);
|
|
3062
3489
|
const queryDestinationFee = useCallback(
|
|
3063
|
-
async (dst) => {
|
|
3490
|
+
async (crossChainRouteAddress, dst) => {
|
|
3064
3491
|
if (!account5.walletClient) {
|
|
3065
3492
|
throw new Error("walletClient is not ready");
|
|
3066
3493
|
}
|
|
3067
3494
|
const quotoLZFee = await account5.walletClient.call(
|
|
3068
|
-
|
|
3495
|
+
crossChainRouteAddress,
|
|
3069
3496
|
"quoteLayerZeroFee",
|
|
3070
3497
|
[account5.address, dst, dstValutDeposit()],
|
|
3071
3498
|
{
|
|
@@ -3111,12 +3538,12 @@ var useWooCrossSwapQuery = () => {
|
|
|
3111
3538
|
}
|
|
3112
3539
|
throw new Error(data.message);
|
|
3113
3540
|
}).then((swapInfo) => {
|
|
3114
|
-
return queryDestinationFee({
|
|
3541
|
+
return queryDestinationFee(inputs.crossChainRouteAddress, {
|
|
3115
3542
|
chainId: swapInfo.dst_infos.chain_id,
|
|
3116
3543
|
bridgedToken: swapInfo.dst_infos.bridged_token,
|
|
3117
3544
|
toToken: swapInfo.dst_infos.to_token,
|
|
3118
3545
|
minToAmount: BigInt(swapInfo.dst_infos.min_to_amount),
|
|
3119
|
-
|
|
3546
|
+
orderlyNativeFees: 0n
|
|
3120
3547
|
}).then((data) => {
|
|
3121
3548
|
console.log("res::::", data);
|
|
3122
3549
|
return {
|
|
@@ -3187,45 +3614,54 @@ var useCrossSwap = () => {
|
|
|
3187
3614
|
if (!account5.walletClient) {
|
|
3188
3615
|
throw new Error("walletClient is undefined");
|
|
3189
3616
|
}
|
|
3190
|
-
|
|
3617
|
+
if (!account5.address) {
|
|
3618
|
+
throw new Error("account.address is undefined");
|
|
3619
|
+
}
|
|
3620
|
+
if (!inputs.crossChainRouteAddress) {
|
|
3621
|
+
throw new Error("crossChainRouteAddress is undefined");
|
|
3622
|
+
}
|
|
3623
|
+
const { address, src, dst, crossChainRouteAddress } = inputs;
|
|
3191
3624
|
if (loading)
|
|
3192
3625
|
return;
|
|
3193
3626
|
start();
|
|
3194
3627
|
const quotoLZFee = await account5.walletClient.call(
|
|
3195
|
-
|
|
3628
|
+
crossChainRouteAddress,
|
|
3196
3629
|
"quoteLayerZeroFee",
|
|
3197
3630
|
[account5.address, dst, dstValutDeposit()],
|
|
3198
3631
|
{
|
|
3199
3632
|
abi: woofiDexCrossChainRouterAbi
|
|
3200
3633
|
}
|
|
3201
3634
|
);
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
account5.address,
|
|
3207
|
-
src,
|
|
3208
|
-
dst,
|
|
3209
|
-
dstValutDeposit(),
|
|
3635
|
+
try {
|
|
3636
|
+
const result = await account5.walletClient.sendTransaction(
|
|
3637
|
+
crossChainRouteAddress,
|
|
3638
|
+
"crossSwap",
|
|
3210
3639
|
{
|
|
3640
|
+
from: account5.address,
|
|
3641
|
+
to: crossChainRouteAddress,
|
|
3642
|
+
data: [account5.address, src, dst, dstValutDeposit()],
|
|
3211
3643
|
value: quotoLZFee[0]
|
|
3644
|
+
},
|
|
3645
|
+
{
|
|
3646
|
+
abi: woofiDexCrossChainRouterAbi
|
|
3212
3647
|
}
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
(
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
)
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3648
|
+
);
|
|
3649
|
+
account5.walletClient.on(
|
|
3650
|
+
{
|
|
3651
|
+
address: crossChainRouteAddress
|
|
3652
|
+
},
|
|
3653
|
+
(log, event) => {
|
|
3654
|
+
console.log("-------------", log, event);
|
|
3655
|
+
}
|
|
3656
|
+
);
|
|
3657
|
+
stop();
|
|
3658
|
+
checkLayerStatus(result.hash);
|
|
3659
|
+
return pick(["from", "to", "hash", "value"], result);
|
|
3660
|
+
} catch (e) {
|
|
3661
|
+
console.log("swap error:", e);
|
|
3662
|
+
stop();
|
|
3663
|
+
throw new Error(e.errorCode);
|
|
3664
|
+
}
|
|
3229
3665
|
};
|
|
3230
3666
|
return {
|
|
3231
3667
|
swap,
|
|
@@ -3234,15 +3670,15 @@ var useCrossSwap = () => {
|
|
|
3234
3670
|
message: bridgeMessage
|
|
3235
3671
|
};
|
|
3236
3672
|
};
|
|
3237
|
-
var woofiDexDepositor = "0xfD7ed9D3d4fD88595AF6a87f798ffDB42b4D7ccB";
|
|
3238
3673
|
var woofiDexDepositorAbi = [
|
|
3674
|
+
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
3239
3675
|
{
|
|
3676
|
+
anonymous: false,
|
|
3240
3677
|
inputs: [
|
|
3241
|
-
{ internalType: "
|
|
3242
|
-
{ internalType: "address", name: "_wooRouter", type: "address" }
|
|
3678
|
+
{ indexed: false, internalType: "uint8", name: "version", type: "uint8" }
|
|
3243
3679
|
],
|
|
3244
|
-
|
|
3245
|
-
type: "
|
|
3680
|
+
name: "Initialized",
|
|
3681
|
+
type: "event"
|
|
3246
3682
|
},
|
|
3247
3683
|
{
|
|
3248
3684
|
anonymous: false,
|
|
@@ -3329,6 +3765,12 @@ var woofiDexDepositorAbi = [
|
|
|
3329
3765
|
name: "toAmount",
|
|
3330
3766
|
type: "uint256"
|
|
3331
3767
|
},
|
|
3768
|
+
{
|
|
3769
|
+
indexed: false,
|
|
3770
|
+
internalType: "uint256",
|
|
3771
|
+
name: "orderlyNativeFees",
|
|
3772
|
+
type: "uint256"
|
|
3773
|
+
},
|
|
3332
3774
|
{
|
|
3333
3775
|
indexed: false,
|
|
3334
3776
|
internalType: "bytes32",
|
|
@@ -3371,6 +3813,20 @@ var woofiDexDepositorAbi = [
|
|
|
3371
3813
|
stateMutability: "nonpayable",
|
|
3372
3814
|
type: "function"
|
|
3373
3815
|
},
|
|
3816
|
+
{
|
|
3817
|
+
inputs: [{ internalType: "address", name: "_wooRouter", type: "address" }],
|
|
3818
|
+
name: "initialize",
|
|
3819
|
+
outputs: [],
|
|
3820
|
+
stateMutability: "nonpayable",
|
|
3821
|
+
type: "function"
|
|
3822
|
+
},
|
|
3823
|
+
{
|
|
3824
|
+
inputs: [],
|
|
3825
|
+
name: "orderlyFeeToggle",
|
|
3826
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
3827
|
+
stateMutability: "view",
|
|
3828
|
+
type: "function"
|
|
3829
|
+
},
|
|
3374
3830
|
{
|
|
3375
3831
|
inputs: [],
|
|
3376
3832
|
name: "owner",
|
|
@@ -3399,6 +3855,13 @@ var woofiDexDepositorAbi = [
|
|
|
3399
3855
|
stateMutability: "nonpayable",
|
|
3400
3856
|
type: "function"
|
|
3401
3857
|
},
|
|
3858
|
+
{
|
|
3859
|
+
inputs: [{ internalType: "bool", name: "_orderlyFeeToggle", type: "bool" }],
|
|
3860
|
+
name: "setOrderlyFeeToggle",
|
|
3861
|
+
outputs: [],
|
|
3862
|
+
stateMutability: "nonpayable",
|
|
3863
|
+
type: "function"
|
|
3864
|
+
},
|
|
3402
3865
|
{
|
|
3403
3866
|
inputs: [
|
|
3404
3867
|
{ internalType: "address", name: "token", type: "address" },
|
|
@@ -3424,9 +3887,14 @@ var woofiDexDepositorAbi = [
|
|
|
3424
3887
|
{ internalType: "address", name: "fromToken", type: "address" },
|
|
3425
3888
|
{ internalType: "uint256", name: "fromAmount", type: "uint256" },
|
|
3426
3889
|
{ internalType: "address", name: "toToken", type: "address" },
|
|
3427
|
-
{ internalType: "uint256", name: "minToAmount", type: "uint256" }
|
|
3890
|
+
{ internalType: "uint256", name: "minToAmount", type: "uint256" },
|
|
3891
|
+
{
|
|
3892
|
+
internalType: "uint256",
|
|
3893
|
+
name: "orderlyNativeFees",
|
|
3894
|
+
type: "uint256"
|
|
3895
|
+
}
|
|
3428
3896
|
],
|
|
3429
|
-
internalType: "struct
|
|
3897
|
+
internalType: "struct IWOOFiDexDepositor.Infos",
|
|
3430
3898
|
name: "infos",
|
|
3431
3899
|
type: "tuple"
|
|
3432
3900
|
},
|
|
@@ -3436,7 +3904,7 @@ var woofiDexDepositorAbi = [
|
|
|
3436
3904
|
{ internalType: "bytes32", name: "brokerHash", type: "bytes32" },
|
|
3437
3905
|
{ internalType: "bytes32", name: "tokenHash", type: "bytes32" }
|
|
3438
3906
|
],
|
|
3439
|
-
internalType: "struct
|
|
3907
|
+
internalType: "struct IWOOFiDexDepositor.VaultDeposit",
|
|
3440
3908
|
name: "vaultDeposit",
|
|
3441
3909
|
type: "tuple"
|
|
3442
3910
|
}
|
|
@@ -3460,19 +3928,10 @@ var woofiDexDepositorAbi = [
|
|
|
3460
3928
|
stateMutability: "nonpayable",
|
|
3461
3929
|
type: "function"
|
|
3462
3930
|
},
|
|
3463
|
-
{
|
|
3464
|
-
inputs: [],
|
|
3465
|
-
name: "weth",
|
|
3466
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
3467
|
-
stateMutability: "view",
|
|
3468
|
-
type: "function"
|
|
3469
|
-
},
|
|
3470
3931
|
{
|
|
3471
3932
|
inputs: [],
|
|
3472
3933
|
name: "wooRouter",
|
|
3473
|
-
outputs: [
|
|
3474
|
-
{ internalType: "contract IWooRouterV2", name: "", type: "address" }
|
|
3475
|
-
],
|
|
3934
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
3476
3935
|
stateMutability: "view",
|
|
3477
3936
|
type: "function"
|
|
3478
3937
|
},
|
|
@@ -3497,21 +3956,36 @@ var useSwap = () => {
|
|
|
3497
3956
|
};
|
|
3498
3957
|
}, [account5]);
|
|
3499
3958
|
const swap = useCallback(
|
|
3500
|
-
async (inputs) => {
|
|
3959
|
+
async (woofiDexDepositorAdress, inputs) => {
|
|
3960
|
+
if (!account5.walletClient) {
|
|
3961
|
+
throw new Error("walletClient is undefined");
|
|
3962
|
+
}
|
|
3963
|
+
if (!account5.address) {
|
|
3964
|
+
throw new Error("account.address is undefined");
|
|
3965
|
+
}
|
|
3501
3966
|
if (loading)
|
|
3502
3967
|
return;
|
|
3503
3968
|
start();
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3969
|
+
console.log("---------", inputs);
|
|
3970
|
+
try {
|
|
3971
|
+
const result = await account5.walletClient.sendTransaction(
|
|
3972
|
+
woofiDexDepositorAdress,
|
|
3973
|
+
"swap",
|
|
3974
|
+
{
|
|
3975
|
+
from: account5.address,
|
|
3976
|
+
to: woofiDexDepositorAdress,
|
|
3977
|
+
data: [account5.address, inputs, dstValutDeposit()]
|
|
3978
|
+
},
|
|
3979
|
+
{
|
|
3980
|
+
abi: woofiDexDepositorAbi
|
|
3981
|
+
}
|
|
3982
|
+
);
|
|
3983
|
+
stop();
|
|
3984
|
+
return pick(["from", "to", "hash", "value"], result);
|
|
3985
|
+
} catch (e) {
|
|
3986
|
+
console.log("\u8C03\u7528\u5408\u7EA6\u62A5\u9519\uFF1A", e);
|
|
3987
|
+
throw new Error(e.errorCode);
|
|
3988
|
+
}
|
|
3515
3989
|
},
|
|
3516
3990
|
[loading, account5]
|
|
3517
3991
|
);
|
|
@@ -3521,6 +3995,6 @@ var useSwap = () => {
|
|
|
3521
3995
|
};
|
|
3522
3996
|
};
|
|
3523
3997
|
|
|
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,
|
|
3998
|
+
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
3999
|
//# sourceMappingURL=out.js.map
|
|
3526
4000
|
//# sourceMappingURL=index.mjs.map
|