@orderly.network/hooks 0.0.52 → 0.0.53
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.js +32 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/dist/index.d.mts +0 -367
- package/dist/index.d.ts +0 -367
package/dist/index.mjs
CHANGED
|
@@ -318,11 +318,10 @@ var useAppState = () => {
|
|
|
318
318
|
ready
|
|
319
319
|
};
|
|
320
320
|
};
|
|
321
|
-
|
|
322
|
-
// src/usePreloadData.ts
|
|
323
321
|
var usePreLoadData = (onSuccess) => {
|
|
322
|
+
const { configStore } = useContext(OrderlyContext);
|
|
324
323
|
useSWR(
|
|
325
|
-
"
|
|
324
|
+
`${configStore.get("swapSupportApiUrl")}/swap_support`,
|
|
326
325
|
(url) => fetch(url).then((res) => res.json()),
|
|
327
326
|
{
|
|
328
327
|
revalidateOnFocus: false,
|
|
@@ -1114,7 +1113,7 @@ var usePositionStream = (symbol, options) => {
|
|
|
1114
1113
|
const MMR = positions.MMR({
|
|
1115
1114
|
baseMMR: info("base_mmr"),
|
|
1116
1115
|
baseIMR: info("base_imr"),
|
|
1117
|
-
IMRFactor: accountInfo.imr_factor[
|
|
1116
|
+
IMRFactor: accountInfo.imr_factor[item.symbol],
|
|
1118
1117
|
positionNotional: item.notional,
|
|
1119
1118
|
IMR_factor_power: 4 / 5
|
|
1120
1119
|
});
|
|
@@ -1334,7 +1333,7 @@ var useMaxQty = (symbol, side, reduceOnly = false) => {
|
|
|
1334
1333
|
positionQty,
|
|
1335
1334
|
buyOrdersQty,
|
|
1336
1335
|
sellOrdersQty,
|
|
1337
|
-
IMR_Factor: accountInfo.imr_factor[
|
|
1336
|
+
IMR_Factor: accountInfo.imr_factor[symbol]
|
|
1338
1337
|
});
|
|
1339
1338
|
}, [
|
|
1340
1339
|
orders,
|
|
@@ -1923,42 +1922,50 @@ var useMarginRatio = () => {
|
|
|
1923
1922
|
return { marginRatio, currentLeverage };
|
|
1924
1923
|
};
|
|
1925
1924
|
var useChains = (networkId, options = {}) => {
|
|
1926
|
-
const _a = options, swrOptions = __objRest(_a, ["filter", "pick"]);
|
|
1925
|
+
const _a = options, { filter, pick, crossEnabled, wooSwapEnabled } = _a, swrOptions = __objRest(_a, ["filter", "pick", "crossEnabled", "wooSwapEnabled"]);
|
|
1926
|
+
const { configStore } = useContext(OrderlyContext);
|
|
1927
1927
|
const field = options == null ? void 0 : options.pick;
|
|
1928
1928
|
const { data } = useSWR(
|
|
1929
|
-
|
|
1929
|
+
// () =>
|
|
1930
|
+
// wooSwapEnabled
|
|
1931
|
+
// ? `${configStore.get("swapSupportApiUrl")}/swap_support`
|
|
1932
|
+
// : null,
|
|
1933
|
+
`${configStore.get("swapSupportApiUrl")}/swap_support`,
|
|
1930
1934
|
(url) => fetch(url).then((res) => res.json()),
|
|
1931
1935
|
__spreadValues({
|
|
1932
1936
|
revalidateOnFocus: false,
|
|
1933
1937
|
revalidateOnReconnect: false
|
|
1934
1938
|
}, swrOptions)
|
|
1935
1939
|
);
|
|
1940
|
+
const { data: orderlyChains } = useQuery("/v1/public/token");
|
|
1936
1941
|
const chains = useMemo(() => {
|
|
1937
|
-
if (!data || !data.data)
|
|
1942
|
+
if (!data || !data.data || !orderlyChains)
|
|
1938
1943
|
return data;
|
|
1939
|
-
let
|
|
1944
|
+
let testnetArr = [];
|
|
1945
|
+
let mainnetArr = [];
|
|
1940
1946
|
Object.keys(data.data).forEach((key) => {
|
|
1941
|
-
const item = data.data[key];
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1947
|
+
const item = __spreadProps(__spreadValues({}, data.data[key]), { name: key, priority: 1 });
|
|
1948
|
+
if (typeof (options == null ? void 0 : options.filter) === "function") {
|
|
1949
|
+
if (!options.filter(item))
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
if (item.network_infos.mainnet) {
|
|
1953
|
+
mainnetArr.push(field ? item[field] : item);
|
|
1954
|
+
} else {
|
|
1955
|
+
testnetArr.push(field ? item[field] : item);
|
|
1956
|
+
}
|
|
1945
1957
|
});
|
|
1946
1958
|
if (networkId === "mainnet") {
|
|
1947
|
-
|
|
1959
|
+
return mainnetArr;
|
|
1948
1960
|
}
|
|
1949
1961
|
if (networkId === "testnet") {
|
|
1950
|
-
|
|
1951
|
-
}
|
|
1952
|
-
if (typeof (options == null ? void 0 : options.filter) === "function") {
|
|
1953
|
-
arr = arr.filter(options.filter);
|
|
1962
|
+
return testnetArr;
|
|
1954
1963
|
}
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
return arr;
|
|
1961
|
-
}, [data, networkId, field, options]);
|
|
1964
|
+
return {
|
|
1965
|
+
testnet: testnetArr,
|
|
1966
|
+
mainnet: mainnetArr
|
|
1967
|
+
};
|
|
1968
|
+
}, [data, networkId, field, options, orderlyChains, wooSwapEnabled]);
|
|
1962
1969
|
const findByChainId = useCallback(
|
|
1963
1970
|
(chainId) => {
|
|
1964
1971
|
if (!data || !data.data)
|