@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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -209,6 +209,7 @@ declare const useMarkPrice: (symbol: string) => swr_subscription.SWRSubscription
|
|
|
209
209
|
|
|
210
210
|
declare const useLeverage: () => ({
|
|
211
211
|
update: (data: any) => any;
|
|
212
|
+
config: any;
|
|
212
213
|
} | undefined)[];
|
|
213
214
|
|
|
214
215
|
declare const useTickerStream: (symbol: string) => any;
|
package/dist/index.d.ts
CHANGED
|
@@ -209,6 +209,7 @@ declare const useMarkPrice: (symbol: string) => swr_subscription.SWRSubscription
|
|
|
209
209
|
|
|
210
210
|
declare const useLeverage: () => ({
|
|
211
211
|
update: (data: any) => any;
|
|
212
|
+
config: any;
|
|
212
213
|
} | undefined)[];
|
|
213
214
|
|
|
214
215
|
declare const useTickerStream: (symbol: string) => any;
|
package/dist/index.js
CHANGED
|
@@ -1684,12 +1684,25 @@ var useMarketsStream = () => {
|
|
|
1684
1684
|
var useLeverage = () => {
|
|
1685
1685
|
const { data, mutate: mutate2 } = usePrivateQuery("/v1/client/info");
|
|
1686
1686
|
const [update] = useMutation("/v1/client/leverage");
|
|
1687
|
+
const { data: config } = useQuery("/v1/public/config");
|
|
1687
1688
|
const updateLeverage = React2.useCallback((data2) => {
|
|
1688
1689
|
return update(data2).then((res) => {
|
|
1689
|
-
|
|
1690
|
+
console.log(res);
|
|
1691
|
+
if (res.success) {
|
|
1692
|
+
return mutate2();
|
|
1693
|
+
} else {
|
|
1694
|
+
throw new Error(res.message);
|
|
1695
|
+
}
|
|
1690
1696
|
});
|
|
1691
1697
|
}, []);
|
|
1692
|
-
return [
|
|
1698
|
+
return [
|
|
1699
|
+
ramda.prop("max_leverage", data),
|
|
1700
|
+
{
|
|
1701
|
+
update: updateLeverage,
|
|
1702
|
+
// config: [1, 2, 3, 4, 5, 10, 15, 20],
|
|
1703
|
+
config: config ? config?.available_futures_leverage?.split(",").map((item) => parseInt(item)) : []
|
|
1704
|
+
}
|
|
1705
|
+
];
|
|
1693
1706
|
};
|
|
1694
1707
|
var useFundingRate = (symbol) => {
|
|
1695
1708
|
if (!symbol) {
|
|
@@ -2937,7 +2950,7 @@ var useChains = (networkId, options = {}) => {
|
|
|
2937
2950
|
const { filter, pick: pick3, crossEnabled, wooSwapEnabled, ...swrOptions } = options;
|
|
2938
2951
|
const { configStore, networkId: envNetworkId } = React2.useContext(OrderlyContext);
|
|
2939
2952
|
const field = options?.pick;
|
|
2940
|
-
const
|
|
2953
|
+
const map2 = React2.useRef(
|
|
2941
2954
|
/* @__PURE__ */ new Map()
|
|
2942
2955
|
);
|
|
2943
2956
|
const { data, error: swapSupportError } = useSWR__default.default(
|
|
@@ -2995,7 +3008,7 @@ var useChains = (networkId, options = {}) => {
|
|
|
2995
3008
|
if (!options.filter(_chain))
|
|
2996
3009
|
return;
|
|
2997
3010
|
}
|
|
2998
|
-
|
|
3011
|
+
map2.current.set(chainId, _chain);
|
|
2999
3012
|
orderlyChainsArr.push(_chain);
|
|
3000
3013
|
});
|
|
3001
3014
|
});
|
|
@@ -3044,7 +3057,7 @@ var useChains = (networkId, options = {}) => {
|
|
|
3044
3057
|
});
|
|
3045
3058
|
if (item.token_infos?.length === 0)
|
|
3046
3059
|
return;
|
|
3047
|
-
|
|
3060
|
+
map2.current.set(item.network_infos.chain_id, item);
|
|
3048
3061
|
if (typeof options?.filter === "function") {
|
|
3049
3062
|
if (!options.filter(item))
|
|
3050
3063
|
return;
|
|
@@ -3079,7 +3092,7 @@ var useChains = (networkId, options = {}) => {
|
|
|
3079
3092
|
}, [data, networkId, field, options, orderlyChains, wooSwapEnabled]);
|
|
3080
3093
|
const findByChainId = React2.useCallback(
|
|
3081
3094
|
(chainId, field2) => {
|
|
3082
|
-
const chain =
|
|
3095
|
+
const chain = map2.current.get(chainId);
|
|
3083
3096
|
if (chain) {
|
|
3084
3097
|
chain.nativeToken = chain.token_infos?.find(
|
|
3085
3098
|
(item) => item.address === nativeTokenAddress
|
|
@@ -3090,7 +3103,7 @@ var useChains = (networkId, options = {}) => {
|
|
|
3090
3103
|
}
|
|
3091
3104
|
return chain;
|
|
3092
3105
|
},
|
|
3093
|
-
[chains,
|
|
3106
|
+
[chains, map2.current]
|
|
3094
3107
|
);
|
|
3095
3108
|
return [
|
|
3096
3109
|
chains,
|