@kodiak-finance/orderly-hooks 2.8.11 → 2.8.12-rc.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 +46 -2
- package/dist/index.d.ts +46 -2
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -22,9 +22,9 @@ import { SolanaWalletProvider } from '@kodiak-finance/orderly-default-solana-ada
|
|
|
22
22
|
import * as swr_subscription from 'swr/subscription';
|
|
23
23
|
import * as _kodiak_finance_orderly_utils from '@kodiak-finance/orderly-utils';
|
|
24
24
|
import { Decimal } from '@kodiak-finance/orderly-utils';
|
|
25
|
-
export * from 'use-debounce';
|
|
26
25
|
import * as immer from 'immer';
|
|
27
26
|
import * as zustand from 'zustand';
|
|
27
|
+
export * from 'use-debounce';
|
|
28
28
|
|
|
29
29
|
declare global {
|
|
30
30
|
interface Window {
|
|
@@ -1498,6 +1498,30 @@ declare const useSymbolLeverage: (symbol?: string) => {
|
|
|
1498
1498
|
*/
|
|
1499
1499
|
declare const useLeverageBySymbol: (symbol?: string) => number | undefined;
|
|
1500
1500
|
|
|
1501
|
+
type UseEffectiveLeverageInputs = {
|
|
1502
|
+
symbol: string;
|
|
1503
|
+
positionQty?: number;
|
|
1504
|
+
positionPrice?: number;
|
|
1505
|
+
orderQty?: number;
|
|
1506
|
+
orderPrice?: number;
|
|
1507
|
+
selectedLeverage?: number;
|
|
1508
|
+
};
|
|
1509
|
+
type EffectiveLeverageResult = {
|
|
1510
|
+
selectedLeverage: number;
|
|
1511
|
+
effectiveLeverage: number;
|
|
1512
|
+
displayLeverage: number;
|
|
1513
|
+
imr: number;
|
|
1514
|
+
isConstrained: boolean;
|
|
1515
|
+
constraintMessage?: string;
|
|
1516
|
+
};
|
|
1517
|
+
/**
|
|
1518
|
+
* Calculates effective leverage based on position/order size and margin requirements.
|
|
1519
|
+
* Returns selected, effective, and display leverage values.
|
|
1520
|
+
*
|
|
1521
|
+
* Formula: EffectiveLeverage = 1 / IMR where IMR constrains based on notional size
|
|
1522
|
+
*/
|
|
1523
|
+
declare const useEffectiveLeverage: (inputs: UseEffectiveLeverageInputs) => EffectiveLeverageResult;
|
|
1524
|
+
|
|
1501
1525
|
type AssetHistoryOptions = {
|
|
1502
1526
|
/** token name you want to search */
|
|
1503
1527
|
token?: string;
|
|
@@ -1633,11 +1657,31 @@ declare const useMaintenanceStatus: () => {
|
|
|
1633
1657
|
|
|
1634
1658
|
declare const useMarkPriceBySymbol: (symbol: string) => number;
|
|
1635
1659
|
|
|
1660
|
+
type EmptyPosition = Omit<API.PositionsTPSLExt, "rows"> & {
|
|
1661
|
+
rows: API.PositionsTPSLExt["rows"] | null;
|
|
1662
|
+
};
|
|
1663
|
+
type PositionState = {
|
|
1664
|
+
positions: {
|
|
1665
|
+
all: EmptyPosition;
|
|
1666
|
+
[key: string]: EmptyPosition;
|
|
1667
|
+
};
|
|
1668
|
+
};
|
|
1636
1669
|
type PositionActions = {
|
|
1637
1670
|
setPositions: (key: string, positions: API.PositionsTPSLExt) => void;
|
|
1638
1671
|
clearAll: () => void;
|
|
1639
1672
|
closePosition: (symbol: string) => void;
|
|
1640
1673
|
};
|
|
1674
|
+
declare const usePositionStore: zustand.UseBoundStore<Omit<zustand.StoreApi<PositionState & {
|
|
1675
|
+
actions: PositionActions;
|
|
1676
|
+
}>, "setState"> & {
|
|
1677
|
+
setState(nextStateOrUpdater: (PositionState & {
|
|
1678
|
+
actions: PositionActions;
|
|
1679
|
+
}) | Partial<PositionState & {
|
|
1680
|
+
actions: PositionActions;
|
|
1681
|
+
}> | ((state: immer.WritableDraft<PositionState & {
|
|
1682
|
+
actions: PositionActions;
|
|
1683
|
+
}>) => void), shouldReplace?: boolean | undefined): void;
|
|
1684
|
+
}>;
|
|
1641
1685
|
declare const usePositionActions: () => PositionActions;
|
|
1642
1686
|
|
|
1643
1687
|
declare const useStorageLedgerAddress: () => {
|
|
@@ -2424,4 +2468,4 @@ declare const usePositionClose: (options: PositionCloseOptions) => {
|
|
|
2424
2468
|
declare const useMarketList: () => API.MarketInfoExt[];
|
|
2425
2469
|
declare const useMarketMap: () => Record<string, API.MarketInfoExt> | null;
|
|
2426
2470
|
|
|
2427
|
-
export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, type Brokers, type Chain, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, type EpochInfoItem, type EpochInfoType, EpochStatus, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, 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, 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, type chainFilter, type chainFilterFunc, checkNotional, cleanStringStyle, fetcher, type filteredChains$1 as filteredChains, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, noCacheConfig, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, 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, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTickerStream, useTokenInfo, useTokensInfo, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, index as utils, _default as version };
|
|
2471
|
+
export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, type Brokers, type Chain, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, type EffectiveLeverageResult, type EpochInfoItem, type EpochInfoType, EpochStatus, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, 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, ScopeType, type StatusInfo, StatusProvider, type SymbolsInfo, TWType, type UseChainsOptions, type UseChainsReturnObject, type UseEffectiveLeverageInputs, type UseOrderEntryMetaState, WalletConnectorContext, type WalletConnectorContextState, type WalletRewards, type WalletRewardsHistoryReturns, type WalletRewardsItem, type WalletState, WsNetworkStatus, type chainFilter, type chainFilterFunc, checkNotional, cleanStringStyle, fetcher, type filteredChains$1 as filteredChains, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, noCacheConfig, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEffectiveLeverage, useEpochInfo, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, 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, usePositionStore, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, type useQueryOptions, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTickerStream, useTokenInfo, useTokensInfo, 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
|
@@ -22,9 +22,9 @@ import { SolanaWalletProvider } from '@kodiak-finance/orderly-default-solana-ada
|
|
|
22
22
|
import * as swr_subscription from 'swr/subscription';
|
|
23
23
|
import * as _kodiak_finance_orderly_utils from '@kodiak-finance/orderly-utils';
|
|
24
24
|
import { Decimal } from '@kodiak-finance/orderly-utils';
|
|
25
|
-
export * from 'use-debounce';
|
|
26
25
|
import * as immer from 'immer';
|
|
27
26
|
import * as zustand from 'zustand';
|
|
27
|
+
export * from 'use-debounce';
|
|
28
28
|
|
|
29
29
|
declare global {
|
|
30
30
|
interface Window {
|
|
@@ -1498,6 +1498,30 @@ declare const useSymbolLeverage: (symbol?: string) => {
|
|
|
1498
1498
|
*/
|
|
1499
1499
|
declare const useLeverageBySymbol: (symbol?: string) => number | undefined;
|
|
1500
1500
|
|
|
1501
|
+
type UseEffectiveLeverageInputs = {
|
|
1502
|
+
symbol: string;
|
|
1503
|
+
positionQty?: number;
|
|
1504
|
+
positionPrice?: number;
|
|
1505
|
+
orderQty?: number;
|
|
1506
|
+
orderPrice?: number;
|
|
1507
|
+
selectedLeverage?: number;
|
|
1508
|
+
};
|
|
1509
|
+
type EffectiveLeverageResult = {
|
|
1510
|
+
selectedLeverage: number;
|
|
1511
|
+
effectiveLeverage: number;
|
|
1512
|
+
displayLeverage: number;
|
|
1513
|
+
imr: number;
|
|
1514
|
+
isConstrained: boolean;
|
|
1515
|
+
constraintMessage?: string;
|
|
1516
|
+
};
|
|
1517
|
+
/**
|
|
1518
|
+
* Calculates effective leverage based on position/order size and margin requirements.
|
|
1519
|
+
* Returns selected, effective, and display leverage values.
|
|
1520
|
+
*
|
|
1521
|
+
* Formula: EffectiveLeverage = 1 / IMR where IMR constrains based on notional size
|
|
1522
|
+
*/
|
|
1523
|
+
declare const useEffectiveLeverage: (inputs: UseEffectiveLeverageInputs) => EffectiveLeverageResult;
|
|
1524
|
+
|
|
1501
1525
|
type AssetHistoryOptions = {
|
|
1502
1526
|
/** token name you want to search */
|
|
1503
1527
|
token?: string;
|
|
@@ -1633,11 +1657,31 @@ declare const useMaintenanceStatus: () => {
|
|
|
1633
1657
|
|
|
1634
1658
|
declare const useMarkPriceBySymbol: (symbol: string) => number;
|
|
1635
1659
|
|
|
1660
|
+
type EmptyPosition = Omit<API.PositionsTPSLExt, "rows"> & {
|
|
1661
|
+
rows: API.PositionsTPSLExt["rows"] | null;
|
|
1662
|
+
};
|
|
1663
|
+
type PositionState = {
|
|
1664
|
+
positions: {
|
|
1665
|
+
all: EmptyPosition;
|
|
1666
|
+
[key: string]: EmptyPosition;
|
|
1667
|
+
};
|
|
1668
|
+
};
|
|
1636
1669
|
type PositionActions = {
|
|
1637
1670
|
setPositions: (key: string, positions: API.PositionsTPSLExt) => void;
|
|
1638
1671
|
clearAll: () => void;
|
|
1639
1672
|
closePosition: (symbol: string) => void;
|
|
1640
1673
|
};
|
|
1674
|
+
declare const usePositionStore: zustand.UseBoundStore<Omit<zustand.StoreApi<PositionState & {
|
|
1675
|
+
actions: PositionActions;
|
|
1676
|
+
}>, "setState"> & {
|
|
1677
|
+
setState(nextStateOrUpdater: (PositionState & {
|
|
1678
|
+
actions: PositionActions;
|
|
1679
|
+
}) | Partial<PositionState & {
|
|
1680
|
+
actions: PositionActions;
|
|
1681
|
+
}> | ((state: immer.WritableDraft<PositionState & {
|
|
1682
|
+
actions: PositionActions;
|
|
1683
|
+
}>) => void), shouldReplace?: boolean | undefined): void;
|
|
1684
|
+
}>;
|
|
1641
1685
|
declare const usePositionActions: () => PositionActions;
|
|
1642
1686
|
|
|
1643
1687
|
declare const useStorageLedgerAddress: () => {
|
|
@@ -2424,4 +2468,4 @@ declare const usePositionClose: (options: PositionCloseOptions) => {
|
|
|
2424
2468
|
declare const useMarketList: () => API.MarketInfoExt[];
|
|
2425
2469
|
declare const useMarketMap: () => Record<string, API.MarketInfoExt> | null;
|
|
2426
2470
|
|
|
2427
|
-
export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, type Brokers, type Chain, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, type EpochInfoItem, type EpochInfoType, EpochStatus, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, 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, 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, type chainFilter, type chainFilterFunc, checkNotional, cleanStringStyle, fetcher, type filteredChains$1 as filteredChains, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, noCacheConfig, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, 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, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTickerStream, useTokenInfo, useTokensInfo, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, index as utils, _default as version };
|
|
2471
|
+
export { type APIKeyItem, type AccountRewardsHistory, type AccountRewardsHistoryRow, type Brokers, type Chain, type Chains, type CheckReferralCodeReturns, type CollateralOutputs, type ComputedAlgoOrder, type ConfigProviderProps, type ConnectedChain, type CurrentEpochEstimate, DefaultLayoutConfig, DistributionId, type DrawOptions, ENVType, type EffectiveLeverageResult, type EpochInfoItem, type EpochInfoType, EpochStatus, type ExclusiveConfigProviderProps, ExtendedConfigStore, type Favorite, type FavoriteTab, 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, ScopeType, type StatusInfo, StatusProvider, type SymbolsInfo, TWType, type UseChainsOptions, type UseChainsReturnObject, type UseEffectiveLeverageInputs, type UseOrderEntryMetaState, WalletConnectorContext, type WalletConnectorContextState, type WalletRewards, type WalletRewardsHistoryReturns, type WalletRewardsItem, type WalletState, WsNetworkStatus, type chainFilter, type chainFilterFunc, checkNotional, cleanStringStyle, fetcher, type filteredChains$1 as filteredChains, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, noCacheConfig, parseJSON, useAccount, useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEffectiveLeverage, useEpochInfo, useEventEmitter, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetReferralCode, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, 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, usePositionStore, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, type useQueryOptions, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSymbolInfo, useSymbolLeverage, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTickerStream, useTokenInfo, useTokensInfo, 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
|
@@ -9635,6 +9635,81 @@ var useSymbolLeverage = (symbol) => {
|
|
|
9635
9635
|
isLoading: isMutating
|
|
9636
9636
|
};
|
|
9637
9637
|
};
|
|
9638
|
+
var useEffectiveLeverage = (inputs) => {
|
|
9639
|
+
const {
|
|
9640
|
+
symbol,
|
|
9641
|
+
positionQty = 0,
|
|
9642
|
+
positionPrice,
|
|
9643
|
+
orderQty = 0,
|
|
9644
|
+
orderPrice,
|
|
9645
|
+
selectedLeverage: inputSelectedLeverage
|
|
9646
|
+
} = inputs;
|
|
9647
|
+
const accountInfo = useAccountInfo2();
|
|
9648
|
+
const symbolsInfo = useSymbolsInfo();
|
|
9649
|
+
const maxLeverage = useMaxLeverage(symbol);
|
|
9650
|
+
const markPriceData = useMarkPrice(symbol);
|
|
9651
|
+
const markPrice = markPriceData?.data ?? 0;
|
|
9652
|
+
return React2.useMemo(() => {
|
|
9653
|
+
const effectivePositionPrice = positionPrice ?? markPrice;
|
|
9654
|
+
const effectiveOrderPrice = orderPrice ?? markPrice;
|
|
9655
|
+
const positionNotional = Math.abs(
|
|
9656
|
+
new orderlyUtils.Decimal(positionQty).mul(effectivePositionPrice).toNumber()
|
|
9657
|
+
);
|
|
9658
|
+
const orderNotional = Math.abs(
|
|
9659
|
+
new orderlyUtils.Decimal(orderQty).mul(effectiveOrderPrice).toNumber()
|
|
9660
|
+
);
|
|
9661
|
+
const symbolInfo = symbolsInfo[symbol];
|
|
9662
|
+
const baseIMR = symbolInfo("base_imr");
|
|
9663
|
+
const selectedLeverage = inputSelectedLeverage ?? maxLeverage;
|
|
9664
|
+
if (baseIMR === void 0 || baseIMR === null) {
|
|
9665
|
+
return {
|
|
9666
|
+
selectedLeverage,
|
|
9667
|
+
effectiveLeverage: maxLeverage,
|
|
9668
|
+
displayLeverage: Math.min(selectedLeverage, maxLeverage),
|
|
9669
|
+
imr: 1 / maxLeverage,
|
|
9670
|
+
isConstrained: false,
|
|
9671
|
+
constraintMessage: void 0
|
|
9672
|
+
};
|
|
9673
|
+
}
|
|
9674
|
+
const imrFactor = accountInfo?.imr_factor?.[symbol] ?? 0;
|
|
9675
|
+
const totalNotional = Math.abs(
|
|
9676
|
+
new orderlyUtils.Decimal(positionNotional).add(orderNotional).toNumber()
|
|
9677
|
+
);
|
|
9678
|
+
const positionBasedIMR = Math.max(
|
|
9679
|
+
baseIMR,
|
|
9680
|
+
new orderlyUtils.Decimal(imrFactor).mul(new orderlyUtils.Decimal(totalNotional).toPower(4 / 5)).toNumber()
|
|
9681
|
+
);
|
|
9682
|
+
const effectiveLeverage = positionBasedIMR > 0 ? 1 / positionBasedIMR : maxLeverage;
|
|
9683
|
+
const displayLeverage = Math.min(selectedLeverage, effectiveLeverage);
|
|
9684
|
+
const isConstrained = effectiveLeverage < selectedLeverage;
|
|
9685
|
+
let constraintMessage;
|
|
9686
|
+
if (isConstrained) {
|
|
9687
|
+
const totalNotional2 = new orderlyUtils.Decimal(positionNotional).add(orderNotional);
|
|
9688
|
+
constraintMessage = `For this position size ($${totalNotional2.toFixed(
|
|
9689
|
+
2
|
|
9690
|
+
)}), the maximum effective leverage is ${Math.floor(effectiveLeverage)}x`;
|
|
9691
|
+
}
|
|
9692
|
+
return {
|
|
9693
|
+
selectedLeverage,
|
|
9694
|
+
effectiveLeverage,
|
|
9695
|
+
displayLeverage,
|
|
9696
|
+
imr: positionBasedIMR,
|
|
9697
|
+
isConstrained,
|
|
9698
|
+
constraintMessage
|
|
9699
|
+
};
|
|
9700
|
+
}, [
|
|
9701
|
+
symbol,
|
|
9702
|
+
symbolsInfo,
|
|
9703
|
+
accountInfo,
|
|
9704
|
+
positionQty,
|
|
9705
|
+
positionPrice,
|
|
9706
|
+
orderQty,
|
|
9707
|
+
orderPrice,
|
|
9708
|
+
markPrice,
|
|
9709
|
+
inputSelectedLeverage,
|
|
9710
|
+
maxLeverage
|
|
9711
|
+
]);
|
|
9712
|
+
};
|
|
9638
9713
|
var useAssetsHistory = (options, config) => {
|
|
9639
9714
|
const ee = useEventEmitter();
|
|
9640
9715
|
const getKey = () => {
|
|
@@ -17888,6 +17963,7 @@ exports.useDaily = useDaily;
|
|
|
17888
17963
|
exports.useDeposit = useDeposit;
|
|
17889
17964
|
exports.useDistribution = useDistribution;
|
|
17890
17965
|
exports.useDistributionHistory = useDistributionHistory;
|
|
17966
|
+
exports.useEffectiveLeverage = useEffectiveLeverage;
|
|
17891
17967
|
exports.useEpochInfo = useEpochInfo;
|
|
17892
17968
|
exports.useEventEmitter = useEventEmitter;
|
|
17893
17969
|
exports.useFeeState = useFeeState;
|
|
@@ -17940,6 +18016,7 @@ exports.useOrderlyContext = useOrderlyContext;
|
|
|
17940
18016
|
exports.usePortfolio = usePortfolio;
|
|
17941
18017
|
exports.usePositionActions = usePositionActions;
|
|
17942
18018
|
exports.usePositionClose = usePositionClose;
|
|
18019
|
+
exports.usePositionStore = usePositionStore;
|
|
17943
18020
|
exports.usePositionStream = usePositionStream;
|
|
17944
18021
|
exports.usePoster = usePoster;
|
|
17945
18022
|
exports.usePreLoadData = usePreLoadData;
|