@orderly.network/hooks 1.0.28-alpha.11 → 1.0.28-alpha.13
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,9 +28,9 @@ var useSWRSubscription__default = /*#__PURE__*/_interopDefault(useSWRSubscriptio
|
|
|
28
28
|
// src/version.ts
|
|
29
29
|
if (typeof window !== "undefined") {
|
|
30
30
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
31
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.0.28-alpha.
|
|
31
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.0.28-alpha.13";
|
|
32
32
|
}
|
|
33
|
-
var version_default = "1.0.28-alpha.
|
|
33
|
+
var version_default = "1.0.28-alpha.13";
|
|
34
34
|
var fetcher = (url, init = {}, queryOptions) => net.get(url, init, queryOptions?.formatter);
|
|
35
35
|
var OrderlyContext = React.createContext({
|
|
36
36
|
// configStore: new MemoryConfigStore(),
|
|
@@ -1968,10 +1968,14 @@ var useMarkets = (type) => {
|
|
|
1968
1968
|
if (jsonStr) {
|
|
1969
1969
|
configStore.set(marketsKey, JSON.parse(jsonStr));
|
|
1970
1970
|
} else {
|
|
1971
|
+
const defaultTab = { name: "Popular", id: 1 };
|
|
1971
1972
|
configStore.set(marketsKey, {
|
|
1972
1973
|
recent: [],
|
|
1973
|
-
favorites: [
|
|
1974
|
-
|
|
1974
|
+
favorites: [
|
|
1975
|
+
{ name: "PERP_ETH_USDC", tabs: [{ ...defaultTab }] },
|
|
1976
|
+
{ name: "PERP_BTC_USDC", tabs: [{ ...defaultTab }] }
|
|
1977
|
+
],
|
|
1978
|
+
favoriteTabs: [{ ...defaultTab }]
|
|
1975
1979
|
});
|
|
1976
1980
|
}
|
|
1977
1981
|
}
|
|
@@ -1991,7 +1995,6 @@ var useMarkets = (type) => {
|
|
|
1991
1995
|
}
|
|
1992
1996
|
}
|
|
1993
1997
|
configStore.set(marketsKey, { ...configStore.getOr(marketsKey, {}), favorites: result });
|
|
1994
|
-
localStorage.setItem(marketsKey, JSON.stringify(configStore.get(marketsKey)));
|
|
1995
1998
|
return result;
|
|
1996
1999
|
}, [configStore]);
|
|
1997
2000
|
const getRecent = React.useMemo(() => {
|
|
@@ -2008,7 +2011,6 @@ var useMarkets = (type) => {
|
|
|
2008
2011
|
...configStore.getOr(marketsKey, {}),
|
|
2009
2012
|
"favoriteTabs": tabs3
|
|
2010
2013
|
});
|
|
2011
|
-
localStorage.setItem(marketsKey, JSON.stringify(configStore.get(marketsKey)));
|
|
2012
2014
|
};
|
|
2013
2015
|
if (Array.isArray(tab)) {
|
|
2014
2016
|
saveTabs(tab);
|
|
@@ -2040,7 +2042,6 @@ var useMarkets = (type) => {
|
|
|
2040
2042
|
...configStore.getOr(marketsKey, {}),
|
|
2041
2043
|
"recent": curData
|
|
2042
2044
|
});
|
|
2043
|
-
localStorage.setItem(marketsKey, JSON.stringify(configStore.get(marketsKey)));
|
|
2044
2045
|
setRecent(curData);
|
|
2045
2046
|
};
|
|
2046
2047
|
const setFavoritesData = (symbol, tab, remove = false) => {
|
|
@@ -2083,7 +2084,6 @@ var useMarkets = (type) => {
|
|
|
2083
2084
|
...configStore.getOr(marketsKey, {}),
|
|
2084
2085
|
"favorites": curData
|
|
2085
2086
|
});
|
|
2086
|
-
localStorage.setItem(marketsKey, JSON.stringify(configStore.get(marketsKey)));
|
|
2087
2087
|
setFavorites(() => curData);
|
|
2088
2088
|
};
|
|
2089
2089
|
const getData = (type2) => {
|
|
@@ -2126,7 +2126,6 @@ var useMarkets = (type) => {
|
|
|
2126
2126
|
...configStore.getOr(marketsKey, {}),
|
|
2127
2127
|
"favorites": list
|
|
2128
2128
|
});
|
|
2129
|
-
localStorage.setItem(marketsKey, JSON.stringify(configStore.get(marketsKey)));
|
|
2130
2129
|
setFavorites(list);
|
|
2131
2130
|
}
|
|
2132
2131
|
};
|
|
@@ -3302,9 +3301,11 @@ var isNativeTokenChecker = (address) => address === nativeTokenAddress;
|
|
|
3302
3301
|
|
|
3303
3302
|
// src/orderly/useChains.ts
|
|
3304
3303
|
var useChains = (networkId, options = {}) => {
|
|
3305
|
-
const {
|
|
3304
|
+
const { pick: pick3, crossEnabled, wooSwapEnabled, ...swrOptions } = options;
|
|
3306
3305
|
const { configStore, networkId: networkEnv } = React.useContext(OrderlyContext);
|
|
3307
3306
|
const field = options?.pick;
|
|
3307
|
+
const filterFun = React.useRef(options?.filter);
|
|
3308
|
+
filterFun.current = options?.filter;
|
|
3308
3309
|
const map = React.useRef(
|
|
3309
3310
|
/* @__PURE__ */ new Map()
|
|
3310
3311
|
);
|
|
@@ -3371,8 +3372,8 @@ var useChains = (networkId, options = {}) => {
|
|
|
3371
3372
|
}
|
|
3372
3373
|
]
|
|
3373
3374
|
};
|
|
3374
|
-
if (typeof
|
|
3375
|
-
if (!
|
|
3375
|
+
if (typeof filterFun.current === "function") {
|
|
3376
|
+
if (!filterFun.current(_chain))
|
|
3376
3377
|
return;
|
|
3377
3378
|
}
|
|
3378
3379
|
if (_chain.chain_id === 421613) {
|
|
@@ -3414,25 +3415,6 @@ var useChains = (networkId, options = {}) => {
|
|
|
3414
3415
|
]
|
|
3415
3416
|
}
|
|
3416
3417
|
];
|
|
3417
|
-
if (networkEnv === "testnet") {
|
|
3418
|
-
const opGoerli = {
|
|
3419
|
-
network_infos: {
|
|
3420
|
-
name: "Optimism Goerli",
|
|
3421
|
-
shortName: "Optimism Goerli",
|
|
3422
|
-
public_rpc_url: "https://optimism-goerli.gateway.tenderly.co",
|
|
3423
|
-
chain_id: 420,
|
|
3424
|
-
currency_symbol: "ETH",
|
|
3425
|
-
bridge_enable: true,
|
|
3426
|
-
mainnet: false,
|
|
3427
|
-
explorer_base_url: "https://goerli-optimism.etherscan.io",
|
|
3428
|
-
est_txn_mins: null,
|
|
3429
|
-
woofi_dex_cross_chain_router: "",
|
|
3430
|
-
woofi_dex_depositor: ""
|
|
3431
|
-
}
|
|
3432
|
-
};
|
|
3433
|
-
testnetArr.push(opGoerli);
|
|
3434
|
-
map.current.set(420, opGoerli);
|
|
3435
|
-
}
|
|
3436
3418
|
let mainnetArr = [];
|
|
3437
3419
|
map.current.set(421613, testnetArr[0]);
|
|
3438
3420
|
if (wooSwapEnabled) {
|
|
@@ -3453,8 +3435,8 @@ var useChains = (networkId, options = {}) => {
|
|
|
3453
3435
|
if (item.token_infos?.length === 0)
|
|
3454
3436
|
return;
|
|
3455
3437
|
map.current.set(item.network_infos.chain_id, item);
|
|
3456
|
-
if (typeof
|
|
3457
|
-
if (!
|
|
3438
|
+
if (typeof filterFun.current === "function") {
|
|
3439
|
+
if (!filterFun.current(item))
|
|
3458
3440
|
return;
|
|
3459
3441
|
}
|
|
3460
3442
|
if (item.network_infos.mainnet) {
|
|
@@ -3500,16 +3482,8 @@ var useChains = (networkId, options = {}) => {
|
|
|
3500
3482
|
testnetArr[index] = _chain;
|
|
3501
3483
|
}
|
|
3502
3484
|
}
|
|
3503
|
-
if (
|
|
3504
|
-
|
|
3505
|
-
(item) => item.network_infos.chain_id === 420
|
|
3506
|
-
);
|
|
3507
|
-
if (index > -1) {
|
|
3508
|
-
testnetArr[index] = _chain;
|
|
3509
|
-
}
|
|
3510
|
-
}
|
|
3511
|
-
if (typeof options?.filter === "function") {
|
|
3512
|
-
if (!options.filter(_chain))
|
|
3485
|
+
if (typeof filterFun.current === "function") {
|
|
3486
|
+
if (!filterFun.current(_chain))
|
|
3513
3487
|
return;
|
|
3514
3488
|
}
|
|
3515
3489
|
mainnetArr.push(_chain);
|
|
@@ -3535,15 +3509,7 @@ var useChains = (networkId, options = {}) => {
|
|
|
3535
3509
|
testnet: testnetArr,
|
|
3536
3510
|
mainnet: mainnetArr
|
|
3537
3511
|
};
|
|
3538
|
-
}, [
|
|
3539
|
-
data,
|
|
3540
|
-
networkId,
|
|
3541
|
-
field,
|
|
3542
|
-
options,
|
|
3543
|
-
orderlyChains,
|
|
3544
|
-
wooSwapEnabled,
|
|
3545
|
-
chainInfos
|
|
3546
|
-
]);
|
|
3512
|
+
}, [data, networkId, field, orderlyChains, wooSwapEnabled, chainInfos]);
|
|
3547
3513
|
const findByChainId = React.useCallback(
|
|
3548
3514
|
(chainId, field2) => {
|
|
3549
3515
|
const chain = map.current.get(chainId);
|
|
@@ -3773,7 +3739,9 @@ var useDeposit = (options) => {
|
|
|
3773
3739
|
const vaultAddress = getVaultAddress();
|
|
3774
3740
|
return account5.assetsManager.approve(options.address, amount, vaultAddress).then((result) => {
|
|
3775
3741
|
if (typeof amount !== "undefined") {
|
|
3776
|
-
setAllowance(
|
|
3742
|
+
setAllowance(
|
|
3743
|
+
(value) => new utils.Decimal(value).add(amount || types.MaxUint256.toString()).toString()
|
|
3744
|
+
);
|
|
3777
3745
|
}
|
|
3778
3746
|
return result;
|
|
3779
3747
|
});
|
|
@@ -3807,7 +3775,13 @@ var useDeposit = (options) => {
|
|
|
3807
3775
|
},
|
|
3808
3776
|
[account5, targetChain]
|
|
3809
3777
|
);
|
|
3810
|
-
const enquiryDepositFee =
|
|
3778
|
+
const enquiryDepositFee = React.useCallback(() => {
|
|
3779
|
+
if (isNaN(Number(quantity)) || !quantity) {
|
|
3780
|
+
setDepositFee(0n);
|
|
3781
|
+
setDepositFeeRevalidating(false);
|
|
3782
|
+
return;
|
|
3783
|
+
}
|
|
3784
|
+
setDepositFeeRevalidating(true);
|
|
3811
3785
|
getDepositFee(quantity).then((res = 0n) => {
|
|
3812
3786
|
const fee = BigInt(
|
|
3813
3787
|
new utils.Decimal(res.toString()).mul(types.DEPOSIT_FEE_RATE).toFixed(0, utils.Decimal.ROUND_UP).toString()
|
|
@@ -3817,14 +3791,8 @@ var useDeposit = (options) => {
|
|
|
3817
3791
|
}).finally(() => {
|
|
3818
3792
|
setDepositFeeRevalidating(false);
|
|
3819
3793
|
});
|
|
3820
|
-
},
|
|
3794
|
+
}, [quantity]);
|
|
3821
3795
|
React.useEffect(() => {
|
|
3822
|
-
if (isNaN(Number(quantity)) || !quantity) {
|
|
3823
|
-
setDepositFee(0n);
|
|
3824
|
-
setDepositFeeRevalidating(false);
|
|
3825
|
-
return;
|
|
3826
|
-
}
|
|
3827
|
-
setDepositFeeRevalidating(true);
|
|
3828
3796
|
enquiryDepositFee();
|
|
3829
3797
|
}, [quantity]);
|
|
3830
3798
|
React.useEffect(() => {
|