@orderly.network/hooks 0.0.80 → 0.0.81

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.mjs CHANGED
@@ -1675,12 +1675,25 @@ var useMarketsStream = () => {
1675
1675
  var useLeverage = () => {
1676
1676
  const { data, mutate: mutate2 } = usePrivateQuery("/v1/client/info");
1677
1677
  const [update] = useMutation("/v1/client/leverage");
1678
+ const { data: config } = useQuery("/v1/public/config");
1678
1679
  const updateLeverage = useCallback((data2) => {
1679
1680
  return update(data2).then((res) => {
1680
- return mutate2();
1681
+ console.log(res);
1682
+ if (res.success) {
1683
+ return mutate2();
1684
+ } else {
1685
+ throw new Error(res.message);
1686
+ }
1681
1687
  });
1682
1688
  }, []);
1683
- return [prop("max_leverage", data), { update: updateLeverage }];
1689
+ return [
1690
+ prop("max_leverage", data),
1691
+ {
1692
+ update: updateLeverage,
1693
+ // config: [1, 2, 3, 4, 5, 10, 15, 20],
1694
+ config: config ? config?.available_futures_leverage?.split(",").map((item) => parseInt(item)) : []
1695
+ }
1696
+ ];
1684
1697
  };
1685
1698
  var useFundingRate = (symbol) => {
1686
1699
  if (!symbol) {
@@ -2928,7 +2941,7 @@ var useChains = (networkId, options = {}) => {
2928
2941
  const { filter, pick: pick3, crossEnabled, wooSwapEnabled, ...swrOptions } = options;
2929
2942
  const { configStore, networkId: envNetworkId } = useContext(OrderlyContext);
2930
2943
  const field = options?.pick;
2931
- const map = useRef(
2944
+ const map2 = useRef(
2932
2945
  /* @__PURE__ */ new Map()
2933
2946
  );
2934
2947
  const { data, error: swapSupportError } = useSWR(
@@ -2986,7 +2999,7 @@ var useChains = (networkId, options = {}) => {
2986
2999
  if (!options.filter(_chain))
2987
3000
  return;
2988
3001
  }
2989
- map.current.set(chainId, _chain);
3002
+ map2.current.set(chainId, _chain);
2990
3003
  orderlyChainsArr.push(_chain);
2991
3004
  });
2992
3005
  });
@@ -3035,7 +3048,7 @@ var useChains = (networkId, options = {}) => {
3035
3048
  });
3036
3049
  if (item.token_infos?.length === 0)
3037
3050
  return;
3038
- map.current.set(item.network_infos.chain_id, item);
3051
+ map2.current.set(item.network_infos.chain_id, item);
3039
3052
  if (typeof options?.filter === "function") {
3040
3053
  if (!options.filter(item))
3041
3054
  return;
@@ -3070,7 +3083,7 @@ var useChains = (networkId, options = {}) => {
3070
3083
  }, [data, networkId, field, options, orderlyChains, wooSwapEnabled]);
3071
3084
  const findByChainId = useCallback(
3072
3085
  (chainId, field2) => {
3073
- const chain = map.current.get(chainId);
3086
+ const chain = map2.current.get(chainId);
3074
3087
  if (chain) {
3075
3088
  chain.nativeToken = chain.token_infos?.find(
3076
3089
  (item) => item.address === nativeTokenAddress
@@ -3081,7 +3094,7 @@ var useChains = (networkId, options = {}) => {
3081
3094
  }
3082
3095
  return chain;
3083
3096
  },
3084
- [chains, map.current]
3097
+ [chains, map2.current]
3085
3098
  );
3086
3099
  return [
3087
3100
  chains,