@orderly.network/hooks 0.0.51 → 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 +31 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- 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,
|
|
@@ -1111,16 +1110,10 @@ var usePositionStream = (symbol, options) => {
|
|
|
1111
1110
|
const total = totalCollateral.toNumber();
|
|
1112
1111
|
return formatedPositions[0].filter((item) => item.position_qty !== 0).map((item) => {
|
|
1113
1112
|
const info = symbolInfo == null ? void 0 : symbolInfo[item.symbol];
|
|
1114
|
-
console.log(
|
|
1115
|
-
"info -------",
|
|
1116
|
-
info("base"),
|
|
1117
|
-
accountInfo.imr_factor,
|
|
1118
|
-
accountInfo.imr_factor[info("base")]
|
|
1119
|
-
);
|
|
1120
1113
|
const MMR = positions.MMR({
|
|
1121
1114
|
baseMMR: info("base_mmr"),
|
|
1122
1115
|
baseIMR: info("base_imr"),
|
|
1123
|
-
IMRFactor: accountInfo.imr_factor[
|
|
1116
|
+
IMRFactor: accountInfo.imr_factor[item.symbol],
|
|
1124
1117
|
positionNotional: item.notional,
|
|
1125
1118
|
IMR_factor_power: 4 / 5
|
|
1126
1119
|
});
|
|
@@ -1929,42 +1922,50 @@ var useMarginRatio = () => {
|
|
|
1929
1922
|
return { marginRatio, currentLeverage };
|
|
1930
1923
|
};
|
|
1931
1924
|
var useChains = (networkId, options = {}) => {
|
|
1932
|
-
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);
|
|
1933
1927
|
const field = options == null ? void 0 : options.pick;
|
|
1934
1928
|
const { data } = useSWR(
|
|
1935
|
-
|
|
1929
|
+
// () =>
|
|
1930
|
+
// wooSwapEnabled
|
|
1931
|
+
// ? `${configStore.get("swapSupportApiUrl")}/swap_support`
|
|
1932
|
+
// : null,
|
|
1933
|
+
`${configStore.get("swapSupportApiUrl")}/swap_support`,
|
|
1936
1934
|
(url) => fetch(url).then((res) => res.json()),
|
|
1937
1935
|
__spreadValues({
|
|
1938
1936
|
revalidateOnFocus: false,
|
|
1939
1937
|
revalidateOnReconnect: false
|
|
1940
1938
|
}, swrOptions)
|
|
1941
1939
|
);
|
|
1940
|
+
const { data: orderlyChains } = useQuery("/v1/public/token");
|
|
1942
1941
|
const chains = useMemo(() => {
|
|
1943
|
-
if (!data || !data.data)
|
|
1942
|
+
if (!data || !data.data || !orderlyChains)
|
|
1944
1943
|
return data;
|
|
1945
|
-
let
|
|
1944
|
+
let testnetArr = [];
|
|
1945
|
+
let mainnetArr = [];
|
|
1946
1946
|
Object.keys(data.data).forEach((key) => {
|
|
1947
|
-
const item = data.data[key];
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
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
|
+
}
|
|
1951
1957
|
});
|
|
1952
1958
|
if (networkId === "mainnet") {
|
|
1953
|
-
|
|
1959
|
+
return mainnetArr;
|
|
1954
1960
|
}
|
|
1955
1961
|
if (networkId === "testnet") {
|
|
1956
|
-
|
|
1957
|
-
}
|
|
1958
|
-
if (typeof (options == null ? void 0 : options.filter) === "function") {
|
|
1959
|
-
arr = arr.filter(options.filter);
|
|
1962
|
+
return testnetArr;
|
|
1960
1963
|
}
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
return arr;
|
|
1967
|
-
}, [data, networkId, field, options]);
|
|
1964
|
+
return {
|
|
1965
|
+
testnet: testnetArr,
|
|
1966
|
+
mainnet: mainnetArr
|
|
1967
|
+
};
|
|
1968
|
+
}, [data, networkId, field, options, orderlyChains, wooSwapEnabled]);
|
|
1968
1969
|
const findByChainId = useCallback(
|
|
1969
1970
|
(chainId) => {
|
|
1970
1971
|
if (!data || !data.data)
|