@orderly.network/hooks 2.8.12 → 2.8.13-alpha.0

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 CHANGED
@@ -37,7 +37,7 @@ declare global {
37
37
  };
38
38
  }
39
39
  }
40
- declare const _default: "2.8.12";
40
+ declare const _default: "2.8.13-alpha.0";
41
41
 
42
42
  declare const fetcher: (url: string, init: RequestInit | undefined, queryOptions: useQueryOptions<any>) => Promise<any>;
43
43
  type useQueryOptions<T> = SWRConfiguration & {
@@ -2689,6 +2689,14 @@ type OrderEntryReturn = {
2689
2689
  * The estimated liquidation price.
2690
2690
  */
2691
2691
  estLiqPrice: number | null;
2692
+ /**
2693
+ * Current position quantity for the symbol (signed: positive=Long, negative=Short).
2694
+ */
2695
+ currentPosition: number;
2696
+ /**
2697
+ * The estimated liquidation price distance.
2698
+ */
2699
+ estLiqPriceDistance: number | null;
2692
2700
  /**
2693
2701
  * The estimated leverage after order creation.
2694
2702
  */
@@ -2918,6 +2926,10 @@ type TpslPriceParams = {
2918
2926
  slPrice?: string;
2919
2927
  liqPrice: number | null;
2920
2928
  side?: OrderSide;
2929
+ /** Current position qty (signed: positive=Long, negative=Short). If missing, treated as is_reducing=true, skip liq check. */
2930
+ currentPosition?: number;
2931
+ /** Order quantity (non-negative, sign derived from side). If missing or 0, treated as is_reducing=true, skip liq check. */
2932
+ orderQuantity?: number;
2921
2933
  };
2922
2934
  declare const useTpslPriceChecker: (params: TpslPriceParams) => OrderValidationResult | null;
2923
2935
 
@@ -2928,4 +2940,10 @@ declare const ERROR_MSG_CODES: {
2928
2940
 
2929
2941
  declare const useEstLiqPriceBySymbol: (symbol: string) => number | undefined;
2930
2942
 
2931
- export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, type Brokers, type Chain, type ChainFilter, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, ERROR_MSG_CODES, type EpochInfoItem, type EpochInfoType, EpochStatus, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, type FilteredChains, type FundingRates, MaintenanceStatus, type MarginRatioReturn, type MarketsItem, MarketsStorageKey, type MarketsStore, MarketsType, type NewListing, ORDERLY_ORDERBOOK_DEPTH_KEY, type OrderBookItem, type OrderEntryReturn, type OrderMetadata, type OrderMetadataConfig, type OrderParams, type OrderValidationItem, type OrderValidationResult, type OrderbookData, type OrderbookOptions, type OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, type PosterLayoutConfig, type PriceMode, type Recent, RefferalAPI, type RestrictedInfoOptions, type RestrictedInfoReturns, type RwaSymbolResult, type RwaSymbolsInfo, ScopeType, type StatusInfo, StatusProvider, type SymbolsInfo, TWType, type UseChainsOptions, type UseChainsReturnObject, type UseOrderEntryMetaState, WalletConnectorContext, type WalletConnectorContextState, type WalletRewards, type WalletRewardsHistoryReturns, type WalletRewardsItem, type WalletState, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, indexedDBManager, initializeAppDatabase, isCurrentlyClosed, isCurrentlyTrading, noCacheConfig, parseJSON, persistIndexedDB, resetTimestampOffsetState, timestampWaitingMiddleware, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAppStore, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEstLiqPriceBySymbol, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateBySymbol, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useGetRwaSymbolCloseTimeInterval, useGetRwaSymbolInfo, useGetRwaSymbolOpenStatus, useGetRwaSymbolOpenTimeInterval, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInitRwaSymbolsRuntime, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMainTokenStore, useMainnetChainsStore, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry, useOrderEntry$1 as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, type useQueryOptions, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useRwaSymbolsInfo, useRwaSymbolsInfoStore, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountAlgoOrderStream, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSwapSupportStore, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTestTokenStore, useTestnetChainsStore, useTickerStream, useTokenInfo, useTokensInfo, useTpslPriceChecker, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, index as utils, _default as version };
2943
+ declare const useGetEstLiqPrice: (props: {
2944
+ estLiqPrice: number | null;
2945
+ symbol: string;
2946
+ side: OrderSide;
2947
+ }) => number | null;
2948
+
2949
+ export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, type Brokers, type Chain, type ChainFilter, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, ERROR_MSG_CODES, type EpochInfoItem, type EpochInfoType, EpochStatus, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, type FilteredChains, type FundingRates, MaintenanceStatus, type MarginRatioReturn, type MarketsItem, MarketsStorageKey, type MarketsStore, MarketsType, type NewListing, ORDERLY_ORDERBOOK_DEPTH_KEY, type OrderBookItem, type OrderEntryReturn, type OrderMetadata, type OrderMetadataConfig, type OrderParams, type OrderValidationItem, type OrderValidationResult, type OrderbookData, type OrderbookOptions, type OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, type PosterLayoutConfig, type PriceMode, type Recent, RefferalAPI, type RestrictedInfoOptions, type RestrictedInfoReturns, type RwaSymbolResult, type RwaSymbolsInfo, ScopeType, type StatusInfo, StatusProvider, type SymbolsInfo, TWType, type UseChainsOptions, type UseChainsReturnObject, type UseOrderEntryMetaState, WalletConnectorContext, type WalletConnectorContextState, type WalletRewards, type WalletRewardsHistoryReturns, type WalletRewardsItem, type WalletState, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, indexedDBManager, initializeAppDatabase, isCurrentlyClosed, isCurrentlyTrading, noCacheConfig, parseJSON, persistIndexedDB, resetTimestampOffsetState, timestampWaitingMiddleware, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAppStore, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEstLiqPriceBySymbol, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateBySymbol, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetEstLiqPrice, useGetReferralCode, useGetRwaSymbolCloseTimeInterval, useGetRwaSymbolInfo, useGetRwaSymbolOpenStatus, useGetRwaSymbolOpenTimeInterval, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInitRwaSymbolsRuntime, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMainTokenStore, useMainnetChainsStore, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry, useOrderEntry$1 as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, type useQueryOptions, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useRwaSymbolsInfo, useRwaSymbolsInfoStore, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountAlgoOrderStream, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSwapSupportStore, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTestTokenStore, useTestnetChainsStore, useTickerStream, useTokenInfo, useTokensInfo, useTpslPriceChecker, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, index as utils, _default as version };
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ declare global {
37
37
  };
38
38
  }
39
39
  }
40
- declare const _default: "2.8.12";
40
+ declare const _default: "2.8.13-alpha.0";
41
41
 
42
42
  declare const fetcher: (url: string, init: RequestInit | undefined, queryOptions: useQueryOptions<any>) => Promise<any>;
43
43
  type useQueryOptions<T> = SWRConfiguration & {
@@ -2689,6 +2689,14 @@ type OrderEntryReturn = {
2689
2689
  * The estimated liquidation price.
2690
2690
  */
2691
2691
  estLiqPrice: number | null;
2692
+ /**
2693
+ * Current position quantity for the symbol (signed: positive=Long, negative=Short).
2694
+ */
2695
+ currentPosition: number;
2696
+ /**
2697
+ * The estimated liquidation price distance.
2698
+ */
2699
+ estLiqPriceDistance: number | null;
2692
2700
  /**
2693
2701
  * The estimated leverage after order creation.
2694
2702
  */
@@ -2918,6 +2926,10 @@ type TpslPriceParams = {
2918
2926
  slPrice?: string;
2919
2927
  liqPrice: number | null;
2920
2928
  side?: OrderSide;
2929
+ /** Current position qty (signed: positive=Long, negative=Short). If missing, treated as is_reducing=true, skip liq check. */
2930
+ currentPosition?: number;
2931
+ /** Order quantity (non-negative, sign derived from side). If missing or 0, treated as is_reducing=true, skip liq check. */
2932
+ orderQuantity?: number;
2921
2933
  };
2922
2934
  declare const useTpslPriceChecker: (params: TpslPriceParams) => OrderValidationResult | null;
2923
2935
 
@@ -2928,4 +2940,10 @@ declare const ERROR_MSG_CODES: {
2928
2940
 
2929
2941
  declare const useEstLiqPriceBySymbol: (symbol: string) => number | undefined;
2930
2942
 
2931
- export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, type Brokers, type Chain, type ChainFilter, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, ERROR_MSG_CODES, type EpochInfoItem, type EpochInfoType, EpochStatus, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, type FilteredChains, type FundingRates, MaintenanceStatus, type MarginRatioReturn, type MarketsItem, MarketsStorageKey, type MarketsStore, MarketsType, type NewListing, ORDERLY_ORDERBOOK_DEPTH_KEY, type OrderBookItem, type OrderEntryReturn, type OrderMetadata, type OrderMetadataConfig, type OrderParams, type OrderValidationItem, type OrderValidationResult, type OrderbookData, type OrderbookOptions, type OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, type PosterLayoutConfig, type PriceMode, type Recent, RefferalAPI, type RestrictedInfoOptions, type RestrictedInfoReturns, type RwaSymbolResult, type RwaSymbolsInfo, ScopeType, type StatusInfo, StatusProvider, type SymbolsInfo, TWType, type UseChainsOptions, type UseChainsReturnObject, type UseOrderEntryMetaState, WalletConnectorContext, type WalletConnectorContextState, type WalletRewards, type WalletRewardsHistoryReturns, type WalletRewardsItem, type WalletState, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, indexedDBManager, initializeAppDatabase, isCurrentlyClosed, isCurrentlyTrading, noCacheConfig, parseJSON, persistIndexedDB, resetTimestampOffsetState, timestampWaitingMiddleware, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAppStore, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEstLiqPriceBySymbol, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateBySymbol, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useGetRwaSymbolCloseTimeInterval, useGetRwaSymbolInfo, useGetRwaSymbolOpenStatus, useGetRwaSymbolOpenTimeInterval, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInitRwaSymbolsRuntime, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMainTokenStore, useMainnetChainsStore, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry, useOrderEntry$1 as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, type useQueryOptions, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useRwaSymbolsInfo, useRwaSymbolsInfoStore, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountAlgoOrderStream, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSwapSupportStore, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTestTokenStore, useTestnetChainsStore, useTickerStream, useTokenInfo, useTokensInfo, useTpslPriceChecker, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, index as utils, _default as version };
2943
+ declare const useGetEstLiqPrice: (props: {
2944
+ estLiqPrice: number | null;
2945
+ symbol: string;
2946
+ side: OrderSide;
2947
+ }) => number | null;
2948
+
2949
+ export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, type Brokers, type Chain, type ChainFilter, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, ERROR_MSG_CODES, type EpochInfoItem, type EpochInfoType, EpochStatus, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, type FilteredChains, type FundingRates, MaintenanceStatus, type MarginRatioReturn, type MarketsItem, MarketsStorageKey, type MarketsStore, MarketsType, type NewListing, ORDERLY_ORDERBOOK_DEPTH_KEY, type OrderBookItem, type OrderEntryReturn, type OrderMetadata, type OrderMetadataConfig, type OrderParams, type OrderValidationItem, type OrderValidationResult, type OrderbookData, type OrderbookOptions, type OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, type PosterLayoutConfig, type PriceMode, type Recent, RefferalAPI, type RestrictedInfoOptions, type RestrictedInfoReturns, type RwaSymbolResult, type RwaSymbolsInfo, ScopeType, type StatusInfo, StatusProvider, type SymbolsInfo, TWType, type UseChainsOptions, type UseChainsReturnObject, type UseOrderEntryMetaState, WalletConnectorContext, type WalletConnectorContextState, type WalletRewards, type WalletRewardsHistoryReturns, type WalletRewardsItem, type WalletState, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, indexedDBManager, initializeAppDatabase, isCurrentlyClosed, isCurrentlyTrading, noCacheConfig, parseJSON, persistIndexedDB, resetTimestampOffsetState, timestampWaitingMiddleware, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAppStore, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEstLiqPriceBySymbol, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateBySymbol, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetEstLiqPrice, useGetReferralCode, useGetRwaSymbolCloseTimeInterval, useGetRwaSymbolInfo, useGetRwaSymbolOpenStatus, useGetRwaSymbolOpenTimeInterval, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInitRwaSymbolsRuntime, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMainTokenStore, useMainnetChainsStore, useMaintenanceStatus, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry, useOrderEntry$1 as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, type useQueryOptions, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useRwaSymbolsInfo, useRwaSymbolsInfoStore, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountAlgoOrderStream, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSwapSupportStore, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTestTokenStore, useTestnetChainsStore, useTickerStream, useTokenInfo, useTokensInfo, useTpslPriceChecker, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, index as utils, _default as version };
package/dist/index.js CHANGED
@@ -64,9 +64,9 @@ var __export = (target, all) => {
64
64
  // src/version.ts
65
65
  if (typeof window !== "undefined") {
66
66
  window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
67
- window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.8.12";
67
+ window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.8.13-alpha.0";
68
68
  }
69
- var version_default = "2.8.12";
69
+ var version_default = "2.8.13-alpha.0";
70
70
  var fetcher = (url, init2 = {}, queryOptions) => net.get(url, init2, queryOptions?.formatter);
71
71
  var noCacheConfig = {
72
72
  dedupingInterval: 0,
@@ -7101,12 +7101,18 @@ var useLeverageBySymbol = (symbol) => {
7101
7101
  const res = data2?.accountDetail?.symbolLeverage || {};
7102
7102
  if (res.symbol === symbol) {
7103
7103
  const key = [`/v1/client/leverage?symbol=${symbol}`, state.accountId];
7104
- useSWR.mutate(key, (prevData) => {
7105
- return {
7106
- ...prevData,
7107
- leverage: res.leverage
7108
- };
7109
- });
7104
+ useSWR.mutate(
7105
+ key,
7106
+ (prevData) => {
7107
+ return {
7108
+ ...prevData,
7109
+ leverage: res.leverage
7110
+ };
7111
+ },
7112
+ {
7113
+ revalidate: false
7114
+ }
7115
+ );
7110
7116
  }
7111
7117
  }
7112
7118
  });
@@ -18382,6 +18388,13 @@ var useOrderEntry2 = (symbol, options = {}) => {
18382
18388
  );
18383
18389
  };
18384
18390
  const { freeCollateral, totalCollateral } = useCollateral();
18391
+ const currentPosition = React2.useMemo(() => {
18392
+ const rows = positions3 ?? [];
18393
+ const p = Array.isArray(rows) ? rows.find(
18394
+ (r) => r.symbol === symbol
18395
+ ) : null;
18396
+ return p?.position_qty ?? 0;
18397
+ }, [positions3, symbol]);
18385
18398
  const estLiqPrice = React2.useMemo(() => {
18386
18399
  const markPrice2 = actions.getMarkPriceBySymbol(symbol);
18387
18400
  if (!markPrice2 || !accountInfo || !symbolInfo) {
@@ -18406,6 +18419,12 @@ var useOrderEntry2 = (symbol, options = {}) => {
18406
18419
  maxQty,
18407
18420
  symbolInfo
18408
18421
  ]);
18422
+ const estLiqPriceDistance = React2.useMemo(() => {
18423
+ if (!estLiqPrice) {
18424
+ return null;
18425
+ }
18426
+ return new utils.Decimal(estLiqPrice).minus(markPrice).abs().div(markPrice).toNumber();
18427
+ }, [estLiqPrice, markPrice]);
18409
18428
  const estLeverage = React2.useMemo(() => {
18410
18429
  if (!symbolInfo) {
18411
18430
  return null;
@@ -18522,6 +18541,8 @@ var useOrderEntry2 = (symbol, options = {}) => {
18522
18541
  formattedOrder,
18523
18542
  maxQty,
18524
18543
  estLiqPrice,
18544
+ estLiqPriceDistance,
18545
+ currentPosition,
18525
18546
  estLeverage,
18526
18547
  estSlippage,
18527
18548
  helper: {
@@ -18869,9 +18890,85 @@ var isEqual = (a, b) => {
18869
18890
  if (aItem === void 0 || bItem === void 0) return false;
18870
18891
  return aItem.type === bItem.type && aItem.message === bItem.message;
18871
18892
  };
18893
+ function calculateDistanceRatio(slPriceDecimal, liqPriceDecimal, side) {
18894
+ return side === types.OrderSide.BUY ? slPriceDecimal.minus(liqPriceDecimal).div(liqPriceDecimal) : liqPriceDecimal.minus(slPriceDecimal).div(liqPriceDecimal);
18895
+ }
18896
+ function checkDistanceAndReturnResult(distance_ratio, warning_threshold) {
18897
+ if (distance_ratio.gt(warning_threshold)) {
18898
+ return null;
18899
+ }
18900
+ if (distance_ratio.gt(0) && distance_ratio.lte(warning_threshold)) {
18901
+ return {
18902
+ sl_trigger_price: {
18903
+ type: ERROR_MSG_CODES.SL_PRICE_WARNING,
18904
+ message: "Stop losses set near the liq. price may not trigger. Note: the liq. price can change with position notional."
18905
+ }
18906
+ };
18907
+ }
18908
+ return {
18909
+ sl_trigger_price: {
18910
+ type: ERROR_MSG_CODES.SL_PRICE_ERROR,
18911
+ message: "Stop loss crosses the liq. price. Please adjust your SL."
18912
+ }
18913
+ };
18914
+ }
18872
18915
  var useTpslPriceChecker = (params) => {
18873
- const { warning_threshold = 0.01, slPrice, liqPrice, side } = params;
18916
+ const {
18917
+ warning_threshold = 0.01,
18918
+ slPrice,
18919
+ liqPrice,
18920
+ side,
18921
+ currentPosition,
18922
+ orderQuantity
18923
+ } = params;
18874
18924
  const prevResultRef = React2.useRef(null);
18925
+ function validateSlPriceBasic(slPriceDecimal, liqPriceDecimal) {
18926
+ if (!side) return null;
18927
+ const distance_ratio = calculateDistanceRatio(
18928
+ slPriceDecimal,
18929
+ liqPriceDecimal,
18930
+ side
18931
+ );
18932
+ return checkDistanceAndReturnResult(distance_ratio, warning_threshold);
18933
+ }
18934
+ function validateSlPriceWithPosition(slPriceDecimal, liqPriceDecimal, currentPosition2, orderQuantity2) {
18935
+ if (!side) return null;
18936
+ const canComputeIsReducing = currentPosition2 !== void 0 && orderQuantity2 !== void 0 && orderQuantity2 > 0;
18937
+ if (!canComputeIsReducing) {
18938
+ return null;
18939
+ }
18940
+ const orderQty = side === types.OrderSide.SELL ? -(orderQuantity2 || 0) : orderQuantity2 || 0;
18941
+ const cur = currentPosition2 ?? 0;
18942
+ const net = new utils.Decimal(cur).plus(orderQty).toNumber();
18943
+ const is_reducing = new utils.Decimal(Math.abs(net)).lt(Math.abs(cur));
18944
+ const posSide = currentPosition2 > 0 ? types.OrderSide.BUY : types.OrderSide.SELL;
18945
+ const isSameSide = posSide === side;
18946
+ if (is_reducing && isSameSide) {
18947
+ return null;
18948
+ }
18949
+ if (net > 0 && slPriceDecimal.lte(liqPriceDecimal)) {
18950
+ return {
18951
+ sl_trigger_price: {
18952
+ type: ERROR_MSG_CODES.SL_PRICE_ERROR,
18953
+ message: "Stop loss crosses the liq. price. Please adjust your SL."
18954
+ }
18955
+ };
18956
+ }
18957
+ if (net < 0 && slPriceDecimal.gte(liqPriceDecimal)) {
18958
+ return {
18959
+ sl_trigger_price: {
18960
+ type: ERROR_MSG_CODES.SL_PRICE_ERROR,
18961
+ message: "Stop loss crosses the liq. price. Please adjust your SL."
18962
+ }
18963
+ };
18964
+ }
18965
+ const distance_ratio = calculateDistanceRatio(
18966
+ slPriceDecimal,
18967
+ liqPriceDecimal,
18968
+ side
18969
+ );
18970
+ return checkDistanceAndReturnResult(distance_ratio, warning_threshold);
18971
+ }
18875
18972
  const currentResult = React2.useMemo(() => {
18876
18973
  if (slPrice === void 0 || liqPrice === void 0 || side === void 0 || liqPrice === null) {
18877
18974
  return null;
@@ -18889,25 +18986,23 @@ var useTpslPriceChecker = (params) => {
18889
18986
  if (Number.isNaN(slPriceNum) || Number.isNaN(liqPriceNum) || !Number.isFinite(slPriceNum) || !Number.isFinite(liqPriceNum) || liqPriceDecimal.isZero() || slPriceDecimal.isZero()) {
18890
18987
  return null;
18891
18988
  }
18892
- const distance_ratio = side === types.OrderSide.BUY ? slPriceDecimal.minus(liqPriceDecimal).div(liqPriceDecimal) : liqPriceDecimal.minus(slPriceDecimal).div(liqPriceDecimal);
18893
- if (distance_ratio.gt(warning_threshold)) {
18894
- return null;
18895
- }
18896
- if (distance_ratio.gt(0) && distance_ratio.lte(warning_threshold)) {
18897
- return {
18898
- sl_trigger_price: {
18899
- type: ERROR_MSG_CODES.SL_PRICE_WARNING,
18900
- message: "Stop losses set near the liq. price may not trigger. Note: the liq. price can change with position notional."
18901
- }
18902
- };
18989
+ if (currentPosition !== void 0 && orderQuantity !== void 0 && orderQuantity > 0) {
18990
+ return validateSlPriceWithPosition(
18991
+ slPriceDecimal,
18992
+ liqPriceDecimal,
18993
+ currentPosition,
18994
+ orderQuantity
18995
+ );
18903
18996
  }
18904
- return {
18905
- sl_trigger_price: {
18906
- type: ERROR_MSG_CODES.SL_PRICE_ERROR,
18907
- message: "Stop loss crosses the liq. price. Please adjust your SL."
18908
- }
18909
- };
18910
- }, [slPrice, liqPrice, side, warning_threshold]);
18997
+ return validateSlPriceBasic(slPriceDecimal, liqPriceDecimal);
18998
+ }, [
18999
+ slPrice,
19000
+ liqPrice,
19001
+ side,
19002
+ warning_threshold,
19003
+ currentPosition,
19004
+ orderQuantity
19005
+ ]);
18911
19006
  if (isEqual(prevResultRef.current, currentResult)) {
18912
19007
  return prevResultRef.current;
18913
19008
  }
@@ -18921,6 +19016,22 @@ var useEstLiqPriceBySymbol = (symbol) => {
18921
19016
  return position?.est_liq_price ?? void 0;
18922
19017
  }, [position]);
18923
19018
  };
19019
+ var useGetEstLiqPrice = (props) => {
19020
+ const { estLiqPrice, symbol, side } = props;
19021
+ const { data: markPrice } = useMarkPrice(symbol);
19022
+ return React2.useMemo(() => {
19023
+ if (!estLiqPrice || !markPrice) {
19024
+ return null;
19025
+ }
19026
+ if (side === types.OrderSide.BUY && estLiqPrice > markPrice) {
19027
+ return null;
19028
+ }
19029
+ if (side === types.OrderSide.SELL && estLiqPrice < markPrice) {
19030
+ return null;
19031
+ }
19032
+ return estLiqPrice;
19033
+ }, [estLiqPrice, markPrice, side]);
19034
+ };
18924
19035
 
18925
19036
  exports.swr = useSWR__namespace;
18926
19037
  Object.defineProperty(exports, "unstable_serialize", {
@@ -19012,6 +19123,7 @@ exports.useFundingRates = useFundingRates;
19012
19123
  exports.useFundingRatesStore = useFundingRatesStore;
19013
19124
  exports.useGetClaimed = useGetClaimed;
19014
19125
  exports.useGetEnv = useGetEnv;
19126
+ exports.useGetEstLiqPrice = useGetEstLiqPrice;
19015
19127
  exports.useGetReferralCode = useGetReferralCode;
19016
19128
  exports.useGetRwaSymbolCloseTimeInterval = useGetRwaSymbolCloseTimeInterval;
19017
19129
  exports.useGetRwaSymbolInfo = useGetRwaSymbolInfo;