@orderly.network/hooks 2.0.4 → 2.0.5
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 +6 -10
- package/dist/index.d.ts +6 -10
- package/dist/index.js +18 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import useConstant from 'use-constant';
|
|
|
7
7
|
export { default as useConstant } from 'use-constant';
|
|
8
8
|
import { SimpleDI, Account, EventEmitter, EVENT_NAMES, DefaultConfigStore, LocalStorageStore } from '@orderly.network/core';
|
|
9
9
|
import { zero, getGlobalObject, getTimestamp, Decimal, timeConvertString, isTestnet, getPrecisionByNumber, camelCaseToUnderscoreCase, windowGuard, removeTrailingZeros, commify, todpIfNeed } from '@orderly.network/utils';
|
|
10
|
-
import { OrderType, OrderSide, EnumTrackerKeys, AccountStatusEnum, SDKError, AlgoOrderRootType, OrderStatus, nativeTokenAddress, chainsInfoMap, ARBITRUM_TESTNET_CHAINID, ARBITRUM_MAINNET_CHAINID, isNativeTokenChecker, ChainNamespace, MaxUint256, DEPOSIT_FEE_RATE,
|
|
10
|
+
import { OrderType, OrderSide, EnumTrackerKeys, AccountStatusEnum, SDKError, AlgoOrderRootType, OrderStatus, MONAD_TESTNET_CHAINID, nativeTokenAddress, chainsInfoMap, ARBITRUM_TESTNET_CHAINID, ARBITRUM_MAINNET_CHAINID, isNativeTokenChecker, ChainNamespace, MaxUint256, DEPOSIT_FEE_RATE, TrackerListenerKeyMap, AlgoOrderType, TriggerPriceType } from '@orderly.network/types';
|
|
11
11
|
import useSWRInfinite, { unstable_serialize } from 'swr/infinite';
|
|
12
12
|
import { jsx } from 'react/jsx-runtime';
|
|
13
13
|
import { pathOr, prop, omit, pick, compose, head, mergeDeepRight, min, max, isNil, propOr, path, lensIndex, over } from 'ramda';
|
|
@@ -33,9 +33,9 @@ var __export = (target, all) => {
|
|
|
33
33
|
// src/version.ts
|
|
34
34
|
if (typeof window !== "undefined") {
|
|
35
35
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
36
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.0.
|
|
36
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.0.5";
|
|
37
37
|
}
|
|
38
|
-
var version_default = "2.0.
|
|
38
|
+
var version_default = "2.0.5";
|
|
39
39
|
var fetcher = (url, init2 = {}, queryOptions) => get(url, init2, queryOptions?.formatter);
|
|
40
40
|
var OrderlyContext = createContext({
|
|
41
41
|
// configStore: new MemoryConfigStore(),
|
|
@@ -3715,7 +3715,7 @@ var useMarginRatio = () => {
|
|
|
3715
3715
|
}, [rows, notional]);
|
|
3716
3716
|
return { marginRatio, currentLeverage, mmr };
|
|
3717
3717
|
};
|
|
3718
|
-
var TestNetWhiteList = [421614, 901901901];
|
|
3718
|
+
var TestNetWhiteList = [421614, 901901901, MONAD_TESTNET_CHAINID];
|
|
3719
3719
|
function useChains(networkId, options = {}) {
|
|
3720
3720
|
const { pick: pickField, ...swrOptions } = options;
|
|
3721
3721
|
const {
|
|
@@ -4102,9 +4102,6 @@ var useDeposit = (options) => {
|
|
|
4102
4102
|
return chain;
|
|
4103
4103
|
}, [networkId, findByChainId, options?.srcChainId]);
|
|
4104
4104
|
const dst = useMemo(() => {
|
|
4105
|
-
if (!targetChain) {
|
|
4106
|
-
throw new Error("dst chain not found");
|
|
4107
|
-
}
|
|
4108
4105
|
const USDC = targetChain?.token_infos.find(
|
|
4109
4106
|
(token) => token.symbol === "USDC"
|
|
4110
4107
|
);
|
|
@@ -4112,8 +4109,8 @@ var useDeposit = (options) => {
|
|
|
4112
4109
|
symbol: "USDC",
|
|
4113
4110
|
address: USDC?.address,
|
|
4114
4111
|
decimals: USDC?.decimals,
|
|
4115
|
-
chainId: targetChain
|
|
4116
|
-
network: targetChain
|
|
4112
|
+
chainId: targetChain?.network_infos?.chain_id,
|
|
4113
|
+
network: targetChain?.network_infos?.shortName
|
|
4117
4114
|
};
|
|
4118
4115
|
}, [targetChain]);
|
|
4119
4116
|
const isNativeToken = useMemo(
|
|
@@ -6144,19 +6141,6 @@ function useMaintenanceStatus() {
|
|
|
6144
6141
|
endTime
|
|
6145
6142
|
};
|
|
6146
6143
|
}
|
|
6147
|
-
var useStorageLedgerAddress = () => {
|
|
6148
|
-
const [ledgerWallet, setLedgerWallet] = useLocalStorage(LedgerWalletKey, []);
|
|
6149
|
-
const setLedgerAddress = (address) => {
|
|
6150
|
-
if (!ledgerWallet.includes(address)) {
|
|
6151
|
-
const arr = [...ledgerWallet, address];
|
|
6152
|
-
setLedgerWallet(arr);
|
|
6153
|
-
}
|
|
6154
|
-
};
|
|
6155
|
-
return {
|
|
6156
|
-
setLedgerAddress,
|
|
6157
|
-
ledgerWallet
|
|
6158
|
-
};
|
|
6159
|
-
};
|
|
6160
6144
|
var usePrivateDataObserver = (options) => {
|
|
6161
6145
|
const ws = useWS();
|
|
6162
6146
|
const ee = useEventEmitter();
|
|
@@ -6316,7 +6300,7 @@ var usePrivateDataObserver = (options) => {
|
|
|
6316
6300
|
if (itemIndex >= 0) {
|
|
6317
6301
|
const itemArr = nextPositions.splice(itemIndex, 1);
|
|
6318
6302
|
const item = itemArr[0];
|
|
6319
|
-
if (item.averageOpenPrice === 0) {
|
|
6303
|
+
if (item.averageOpenPrice === 0 && item.positionQty !== 0) {
|
|
6320
6304
|
return row;
|
|
6321
6305
|
}
|
|
6322
6306
|
return object2underscore(item);
|
|
@@ -14247,7 +14231,11 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
14247
14231
|
const markPrice2 = actions.getMarkPriceBySymbol(symbol);
|
|
14248
14232
|
if (!markPrice2 || !accountInfo)
|
|
14249
14233
|
return null;
|
|
14250
|
-
|
|
14234
|
+
const orderQuantity = Number(formattedOrder.order_quantity);
|
|
14235
|
+
if (orderQuantity === 0 || orderQuantity > maxQty) {
|
|
14236
|
+
return null;
|
|
14237
|
+
}
|
|
14238
|
+
const estLiqPrice2 = calcEstLiqPrice(formattedOrder, askAndBid.current[0], {
|
|
14251
14239
|
baseIMR: symbolInfo?.base_imr,
|
|
14252
14240
|
baseMMR: symbolInfo?.base_mmr,
|
|
14253
14241
|
markPrice: markPrice2,
|
|
@@ -14257,14 +14245,19 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
14257
14245
|
symbol,
|
|
14258
14246
|
positions: positions2
|
|
14259
14247
|
});
|
|
14260
|
-
|
|
14248
|
+
return estLiqPrice2;
|
|
14249
|
+
}, [formattedOrder, accountInfo, positions2, totalCollateral, symbol, maxQty]);
|
|
14261
14250
|
const estLeverage = useMemo(() => {
|
|
14251
|
+
const orderQuantity = Number(formattedOrder.order_quantity);
|
|
14252
|
+
if (orderQuantity === 0 || orderQuantity > maxQty) {
|
|
14253
|
+
return null;
|
|
14254
|
+
}
|
|
14262
14255
|
return calcEstLeverage(formattedOrder, askAndBid.current[0], {
|
|
14263
14256
|
totalCollateral,
|
|
14264
14257
|
positions: positions2,
|
|
14265
14258
|
symbol
|
|
14266
14259
|
});
|
|
14267
|
-
}, [formattedOrder, accountInfo, positions2, totalCollateral, symbol]);
|
|
14260
|
+
}, [formattedOrder, accountInfo, positions2, totalCollateral, symbol, maxQty]);
|
|
14268
14261
|
const resetErrors = () => {
|
|
14269
14262
|
setMeta(
|
|
14270
14263
|
produce((draft) => {
|
|
@@ -14555,6 +14548,6 @@ var useRestrictedAreas = (params) => {
|
|
|
14555
14548
|
};
|
|
14556
14549
|
};
|
|
14557
14550
|
|
|
14558
|
-
export { AssetHistoryStatusEnum, DefaultLayoutConfig, DistributionId, ENVType2 as ENVType, ExtendedConfigStore, MarketsStorageKey, MarketsType, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, OrderlyTrackerProvider, StatusContext, StatusProvider, TWType, WalletConnectorContext, WsNetworkStatus, checkNotional, cleanStringStyle, parseJSON, useAccount, useAccountInfo2 as useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useBoolean, useChain, useChains, useCheckReferralCode, useCollateral, useCommission, useConfig, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEventEmitter, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useKeyStore, useLazyQuery, useLeverage, useLocalStorage, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useNetworkInfo, useOrderEntity, useOrderEntry2 as useOrderEntry, useOrderEntry as useOrderEntry_deprecated, useOrderStore2 as useOrderStore, useOrderStream, useOrderbookStream, usePositionActions, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedAreas, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily,
|
|
14551
|
+
export { AssetHistoryStatusEnum, DefaultLayoutConfig, DistributionId, ENVType2 as ENVType, ExtendedConfigStore, MarketsStorageKey, MarketsType, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, OrderlyTrackerProvider, StatusContext, StatusProvider, TWType, WalletConnectorContext, WsNetworkStatus, checkNotional, cleanStringStyle, parseJSON, useAccount, useAccountInfo2 as useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useBoolean, useChain, useChains, useCheckReferralCode, useCollateral, useCommission, useConfig, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEventEmitter, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useKeyStore, useLazyQuery, useLeverage, useLocalStorage, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useNetworkInfo, useOrderEntity, useOrderEntry2 as useOrderEntry, useOrderEntry as useOrderEntry_deprecated, useOrderStore2 as useOrderStore, useOrderStream, useOrderbookStream, usePositionActions, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedAreas, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useTPSLOrder, useTickerStream, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWithdraw, useWsStatus, utils_exports as utils, version_default as version };
|
|
14559
14552
|
//# sourceMappingURL=out.js.map
|
|
14560
14553
|
//# sourceMappingURL=index.mjs.map
|