@orderly.network/hooks 2.7.3 → 2.7.4-alpha.1
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 +23 -16
- package/dist/index.d.ts +23 -16
- package/dist/index.js +67 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ import { SWRInfiniteKeyLoader, SWRInfiniteConfiguration } from 'swr/infinite';
|
|
|
9
9
|
import * as react from 'react';
|
|
10
10
|
import react__default, { PropsWithChildren, FC, ReactNode } from 'react';
|
|
11
11
|
import * as _orderly_network_types from '@orderly.network/types';
|
|
12
|
-
import { NetworkId, TrackerEventName, API,
|
|
12
|
+
import { NetworkId, TrackerEventName, API, OrderlyOrder, ChainNamespace, WSMessage, OrderType, OrderStatus, OrderSide, AlgoOrderRootType, OrderEntity, PositionType, AlgoOrderEntity, AssetHistoryStatusEnum, AlgoOrderType, RequireKeys } from '@orderly.network/types';
|
|
13
13
|
import * as _orderly_network_core from '@orderly.network/core';
|
|
14
14
|
import { AccountState, Account, EventEmitter, ConfigStore, ConfigKey, SimpleDI, OrderlyKeyStore, WalletAdapter, IContract, DefaultConfigStore } from '@orderly.network/core';
|
|
15
15
|
export { SubAccount, WalletAdapter } from '@orderly.network/core';
|
|
@@ -33,7 +33,7 @@ declare global {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
declare const _default: "2.7.
|
|
36
|
+
declare const _default: "2.7.4-alpha.1";
|
|
37
37
|
|
|
38
38
|
declare const fetcher: (url: string, init: RequestInit | undefined, queryOptions: useQueryOptions<any>) => Promise<any>;
|
|
39
39
|
type useQueryOptions<T> = SWRConfiguration & {
|
|
@@ -454,12 +454,14 @@ declare function useChains<T extends NetworkId | undefined, K extends UseChainsO
|
|
|
454
454
|
UseChainsReturnObject
|
|
455
455
|
];
|
|
456
456
|
|
|
457
|
-
type
|
|
458
|
-
mainnet?:
|
|
459
|
-
|
|
457
|
+
type FilteredChains = {
|
|
458
|
+
mainnet?: {
|
|
459
|
+
id: number;
|
|
460
|
+
}[];
|
|
461
|
+
testnet?: {
|
|
462
|
+
id: number;
|
|
463
|
+
}[];
|
|
460
464
|
};
|
|
461
|
-
type chainFilterFunc = (config: ConfigStore) => filteredChains$1;
|
|
462
|
-
type chainFilter = filteredChains$1 | chainFilterFunc;
|
|
463
465
|
interface OrderlyConfigContextState {
|
|
464
466
|
fetcher?: (url: string, init: RequestInit) => Promise<any>;
|
|
465
467
|
configStore: ConfigStore;
|
|
@@ -470,7 +472,7 @@ interface OrderlyConfigContextState {
|
|
|
470
472
|
* @hidden
|
|
471
473
|
*/
|
|
472
474
|
onlyTestnet?: boolean;
|
|
473
|
-
filteredChains?:
|
|
475
|
+
filteredChains?: FilteredChains;
|
|
474
476
|
customChains?: Chains<undefined, undefined>;
|
|
475
477
|
chainTransformer?: (params: {
|
|
476
478
|
chains: API.Chain[];
|
|
@@ -511,6 +513,11 @@ interface OrderlyConfigContextState {
|
|
|
511
513
|
* @default false
|
|
512
514
|
*/
|
|
513
515
|
defaultOpen?: boolean;
|
|
516
|
+
/**
|
|
517
|
+
* Whether to display the notification in the order entry.
|
|
518
|
+
* @default true
|
|
519
|
+
*/
|
|
520
|
+
displayInOrderEntry?: boolean;
|
|
514
521
|
};
|
|
515
522
|
};
|
|
516
523
|
amplitudeConfig?: {
|
|
@@ -537,16 +544,13 @@ declare enum WsNetworkStatus {
|
|
|
537
544
|
}
|
|
538
545
|
declare function useWsStatus(): WsNetworkStatus;
|
|
539
546
|
|
|
540
|
-
type
|
|
541
|
-
|
|
542
|
-
testnet?: Chain$1[];
|
|
543
|
-
};
|
|
544
|
-
type filterChainsFunc = (config: ConfigStore) => filteredChains;
|
|
547
|
+
type ChainFilterFunc = (config: ConfigStore) => FilteredChains;
|
|
548
|
+
type ChainFilter = FilteredChains | ChainFilterFunc;
|
|
545
549
|
type BaseConfigProviderProps = {
|
|
546
550
|
keyStore?: OrderlyKeyStore;
|
|
547
551
|
contracts?: IContract;
|
|
548
552
|
walletAdapters?: WalletAdapter[];
|
|
549
|
-
chainFilter?:
|
|
553
|
+
chainFilter?: ChainFilter;
|
|
550
554
|
/**
|
|
551
555
|
* Custom orderbook default tick sizes.
|
|
552
556
|
*/
|
|
@@ -1926,6 +1930,7 @@ declare function priceToPnl(inputs: {
|
|
|
1926
1930
|
}, options?: {
|
|
1927
1931
|
symbol?: Pick<API.SymbolExt, "quote_dp">;
|
|
1928
1932
|
}): number;
|
|
1933
|
+
/** @deprecated use priceToROI instead */
|
|
1929
1934
|
declare function calcTPSL_ROI(inputs: {
|
|
1930
1935
|
pnl: number | string;
|
|
1931
1936
|
qty: number | string;
|
|
@@ -2155,6 +2160,7 @@ declare const useOrderEntryNextInternal: (symbol: string, options?: {
|
|
|
2155
2160
|
*/
|
|
2156
2161
|
initialOrder?: Omit<Partial<FullOrderState>, "symbol">;
|
|
2157
2162
|
symbolInfo?: API.SymbolExt;
|
|
2163
|
+
symbolLeverage?: number;
|
|
2158
2164
|
}) => {
|
|
2159
2165
|
readonly formattedOrder: Required<Pick<OrderlyOrder, "symbol" | "side" | "order_type">> & Partial<Omit<OrderlyOrder, "symbol" | "side" | "order_type">>;
|
|
2160
2166
|
readonly setValue: (key: keyof FullOrderState, value: any, additional?: {
|
|
@@ -2244,7 +2250,8 @@ type OrderEntryReturn = {
|
|
|
2244
2250
|
* Indicates if a mutation (order creation) is in progress.
|
|
2245
2251
|
*/
|
|
2246
2252
|
isMutating: boolean;
|
|
2247
|
-
markPrice
|
|
2253
|
+
markPrice?: number;
|
|
2254
|
+
symbolLeverage?: number;
|
|
2248
2255
|
};
|
|
2249
2256
|
/**
|
|
2250
2257
|
* Custom hook for managing order entry in the Orderly application.
|
|
@@ -2424,4 +2431,4 @@ declare const usePositionClose: (options: PositionCloseOptions) => {
|
|
|
2424
2431
|
declare const useMarketList: () => API.MarketInfoExt[];
|
|
2425
2432
|
declare const useMarketMap: () => Record<string, API.MarketInfoExt> | null;
|
|
2426
2433
|
|
|
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,
|
|
2434
|
+
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, 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, 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, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { SWRInfiniteKeyLoader, SWRInfiniteConfiguration } from 'swr/infinite';
|
|
|
9
9
|
import * as react from 'react';
|
|
10
10
|
import react__default, { PropsWithChildren, FC, ReactNode } from 'react';
|
|
11
11
|
import * as _orderly_network_types from '@orderly.network/types';
|
|
12
|
-
import { NetworkId, TrackerEventName, API,
|
|
12
|
+
import { NetworkId, TrackerEventName, API, OrderlyOrder, ChainNamespace, WSMessage, OrderType, OrderStatus, OrderSide, AlgoOrderRootType, OrderEntity, PositionType, AlgoOrderEntity, AssetHistoryStatusEnum, AlgoOrderType, RequireKeys } from '@orderly.network/types';
|
|
13
13
|
import * as _orderly_network_core from '@orderly.network/core';
|
|
14
14
|
import { AccountState, Account, EventEmitter, ConfigStore, ConfigKey, SimpleDI, OrderlyKeyStore, WalletAdapter, IContract, DefaultConfigStore } from '@orderly.network/core';
|
|
15
15
|
export { SubAccount, WalletAdapter } from '@orderly.network/core';
|
|
@@ -33,7 +33,7 @@ declare global {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
declare const _default: "2.7.
|
|
36
|
+
declare const _default: "2.7.4-alpha.1";
|
|
37
37
|
|
|
38
38
|
declare const fetcher: (url: string, init: RequestInit | undefined, queryOptions: useQueryOptions<any>) => Promise<any>;
|
|
39
39
|
type useQueryOptions<T> = SWRConfiguration & {
|
|
@@ -454,12 +454,14 @@ declare function useChains<T extends NetworkId | undefined, K extends UseChainsO
|
|
|
454
454
|
UseChainsReturnObject
|
|
455
455
|
];
|
|
456
456
|
|
|
457
|
-
type
|
|
458
|
-
mainnet?:
|
|
459
|
-
|
|
457
|
+
type FilteredChains = {
|
|
458
|
+
mainnet?: {
|
|
459
|
+
id: number;
|
|
460
|
+
}[];
|
|
461
|
+
testnet?: {
|
|
462
|
+
id: number;
|
|
463
|
+
}[];
|
|
460
464
|
};
|
|
461
|
-
type chainFilterFunc = (config: ConfigStore) => filteredChains$1;
|
|
462
|
-
type chainFilter = filteredChains$1 | chainFilterFunc;
|
|
463
465
|
interface OrderlyConfigContextState {
|
|
464
466
|
fetcher?: (url: string, init: RequestInit) => Promise<any>;
|
|
465
467
|
configStore: ConfigStore;
|
|
@@ -470,7 +472,7 @@ interface OrderlyConfigContextState {
|
|
|
470
472
|
* @hidden
|
|
471
473
|
*/
|
|
472
474
|
onlyTestnet?: boolean;
|
|
473
|
-
filteredChains?:
|
|
475
|
+
filteredChains?: FilteredChains;
|
|
474
476
|
customChains?: Chains<undefined, undefined>;
|
|
475
477
|
chainTransformer?: (params: {
|
|
476
478
|
chains: API.Chain[];
|
|
@@ -511,6 +513,11 @@ interface OrderlyConfigContextState {
|
|
|
511
513
|
* @default false
|
|
512
514
|
*/
|
|
513
515
|
defaultOpen?: boolean;
|
|
516
|
+
/**
|
|
517
|
+
* Whether to display the notification in the order entry.
|
|
518
|
+
* @default true
|
|
519
|
+
*/
|
|
520
|
+
displayInOrderEntry?: boolean;
|
|
514
521
|
};
|
|
515
522
|
};
|
|
516
523
|
amplitudeConfig?: {
|
|
@@ -537,16 +544,13 @@ declare enum WsNetworkStatus {
|
|
|
537
544
|
}
|
|
538
545
|
declare function useWsStatus(): WsNetworkStatus;
|
|
539
546
|
|
|
540
|
-
type
|
|
541
|
-
|
|
542
|
-
testnet?: Chain$1[];
|
|
543
|
-
};
|
|
544
|
-
type filterChainsFunc = (config: ConfigStore) => filteredChains;
|
|
547
|
+
type ChainFilterFunc = (config: ConfigStore) => FilteredChains;
|
|
548
|
+
type ChainFilter = FilteredChains | ChainFilterFunc;
|
|
545
549
|
type BaseConfigProviderProps = {
|
|
546
550
|
keyStore?: OrderlyKeyStore;
|
|
547
551
|
contracts?: IContract;
|
|
548
552
|
walletAdapters?: WalletAdapter[];
|
|
549
|
-
chainFilter?:
|
|
553
|
+
chainFilter?: ChainFilter;
|
|
550
554
|
/**
|
|
551
555
|
* Custom orderbook default tick sizes.
|
|
552
556
|
*/
|
|
@@ -1926,6 +1930,7 @@ declare function priceToPnl(inputs: {
|
|
|
1926
1930
|
}, options?: {
|
|
1927
1931
|
symbol?: Pick<API.SymbolExt, "quote_dp">;
|
|
1928
1932
|
}): number;
|
|
1933
|
+
/** @deprecated use priceToROI instead */
|
|
1929
1934
|
declare function calcTPSL_ROI(inputs: {
|
|
1930
1935
|
pnl: number | string;
|
|
1931
1936
|
qty: number | string;
|
|
@@ -2155,6 +2160,7 @@ declare const useOrderEntryNextInternal: (symbol: string, options?: {
|
|
|
2155
2160
|
*/
|
|
2156
2161
|
initialOrder?: Omit<Partial<FullOrderState>, "symbol">;
|
|
2157
2162
|
symbolInfo?: API.SymbolExt;
|
|
2163
|
+
symbolLeverage?: number;
|
|
2158
2164
|
}) => {
|
|
2159
2165
|
readonly formattedOrder: Required<Pick<OrderlyOrder, "symbol" | "side" | "order_type">> & Partial<Omit<OrderlyOrder, "symbol" | "side" | "order_type">>;
|
|
2160
2166
|
readonly setValue: (key: keyof FullOrderState, value: any, additional?: {
|
|
@@ -2244,7 +2250,8 @@ type OrderEntryReturn = {
|
|
|
2244
2250
|
* Indicates if a mutation (order creation) is in progress.
|
|
2245
2251
|
*/
|
|
2246
2252
|
isMutating: boolean;
|
|
2247
|
-
markPrice
|
|
2253
|
+
markPrice?: number;
|
|
2254
|
+
symbolLeverage?: number;
|
|
2248
2255
|
};
|
|
2249
2256
|
/**
|
|
2250
2257
|
* Custom hook for managing order entry in the Orderly application.
|
|
@@ -2424,4 +2431,4 @@ declare const usePositionClose: (options: PositionCloseOptions) => {
|
|
|
2424
2431
|
declare const useMarketList: () => API.MarketInfoExt[];
|
|
2425
2432
|
declare const useMarketMap: () => Record<string, API.MarketInfoExt> | null;
|
|
2426
2433
|
|
|
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,
|
|
2434
|
+
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, 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, 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, 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 };
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var core = require('@orderly.network/core');
|
|
|
11
11
|
var lodash = require('lodash');
|
|
12
12
|
var useSWRInfinite = require('swr/infinite');
|
|
13
13
|
var ramda = require('ramda');
|
|
14
|
+
var perp = require('@orderly.network/perp');
|
|
14
15
|
var amplitude = require('@amplitude/analytics-browser');
|
|
15
16
|
var jsxRuntime = require('react/jsx-runtime');
|
|
16
17
|
var defaultEvmAdapter = require('@orderly.network/default-evm-adapter');
|
|
@@ -19,7 +20,6 @@ var web3ProviderEthers = require('@orderly.network/web3-provider-ethers');
|
|
|
19
20
|
var useSWRSubscription = require('swr/subscription');
|
|
20
21
|
var zustand = require('zustand');
|
|
21
22
|
var immer = require('zustand/middleware/immer');
|
|
22
|
-
var perp = require('@orderly.network/perp');
|
|
23
23
|
var useDebounce = require('use-debounce');
|
|
24
24
|
var immer$1 = require('immer');
|
|
25
25
|
var qr = require('@akamfoad/qr');
|
|
@@ -61,9 +61,9 @@ var __export = (target, all) => {
|
|
|
61
61
|
// src/version.ts
|
|
62
62
|
if (typeof window !== "undefined") {
|
|
63
63
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
64
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.7.
|
|
64
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.7.4-alpha.1";
|
|
65
65
|
}
|
|
66
|
-
var version_default = "2.7.
|
|
66
|
+
var version_default = "2.7.4-alpha.1";
|
|
67
67
|
var fetcher = (url, init2 = {}, queryOptions) => net.get(url, init2, queryOptions?.formatter);
|
|
68
68
|
var noCacheConfig = {
|
|
69
69
|
dedupingInterval: 0,
|
|
@@ -426,7 +426,7 @@ var usePrivateQuery = (query, options) => {
|
|
|
426
426
|
const { state } = useAccount();
|
|
427
427
|
const middleware = Array.isArray(options?.use) ? options?.use ?? [] : [];
|
|
428
428
|
return useSWR__namespace.default(
|
|
429
|
-
() => state.status >= types.AccountStatusEnum.EnableTrading || state.status === types.AccountStatusEnum.EnableTradingWithoutConnected ? [query, state.accountId] : null,
|
|
429
|
+
() => query && (state.status >= types.AccountStatusEnum.EnableTrading || state.status === types.AccountStatusEnum.EnableTradingWithoutConnected) ? [query, state.accountId] : null,
|
|
430
430
|
(url, init2) => {
|
|
431
431
|
return fetcher(url, init2, { formatter });
|
|
432
432
|
},
|
|
@@ -1199,6 +1199,42 @@ function priceToPnl(inputs, options = {}) {
|
|
|
1199
1199
|
}
|
|
1200
1200
|
return decimal.toNumber();
|
|
1201
1201
|
}
|
|
1202
|
+
function priceToROI(inputs) {
|
|
1203
|
+
const { values, markPrice, symbolLeverage } = inputs;
|
|
1204
|
+
const orderPrice = values.order_type === types.OrderType.MARKET ? markPrice : Number(values.order_price);
|
|
1205
|
+
if (symbolLeverage && orderPrice) {
|
|
1206
|
+
let tp_ROI;
|
|
1207
|
+
let sl_ROI;
|
|
1208
|
+
const tpTriggerPrice = Number(values.tp_trigger_price);
|
|
1209
|
+
if (values.tp_pnl && values.tp_trigger_price && tpTriggerPrice > 0) {
|
|
1210
|
+
tp_ROI = perp.order.tpslROI({
|
|
1211
|
+
side: values.side,
|
|
1212
|
+
type: "tp",
|
|
1213
|
+
closePrice: tpTriggerPrice,
|
|
1214
|
+
orderPrice,
|
|
1215
|
+
leverage: symbolLeverage
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
const slTriggerPrice = Number(values.sl_trigger_price);
|
|
1219
|
+
if (values.sl_pnl && values.sl_trigger_price && slTriggerPrice > 0) {
|
|
1220
|
+
sl_ROI = perp.order.tpslROI({
|
|
1221
|
+
side: values.side,
|
|
1222
|
+
type: "sl",
|
|
1223
|
+
closePrice: slTriggerPrice,
|
|
1224
|
+
orderPrice,
|
|
1225
|
+
leverage: symbolLeverage
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
return {
|
|
1229
|
+
tp_ROI: tp_ROI?.toString(),
|
|
1230
|
+
sl_ROI: sl_ROI?.toString()
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
return {
|
|
1234
|
+
tp_ROI: void 0,
|
|
1235
|
+
sl_ROI: void 0
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1202
1238
|
function calcTPSL_ROI(inputs) {
|
|
1203
1239
|
const qtyNum = Number(inputs.qty);
|
|
1204
1240
|
const priceNum = Number(inputs.price);
|
|
@@ -16851,7 +16887,7 @@ var useOrderStore = (initialOrder) => {
|
|
|
16851
16887
|
|
|
16852
16888
|
// src/next/useOrderEntry/useOrderEntry.internal.ts
|
|
16853
16889
|
var useOrderEntryNextInternal = (symbol, options = {}) => {
|
|
16854
|
-
const { symbolInfo } = options;
|
|
16890
|
+
const { symbolInfo, symbolLeverage } = options;
|
|
16855
16891
|
const initialOrder = {
|
|
16856
16892
|
side: types.OrderSide.BUY,
|
|
16857
16893
|
order_type: types.OrderType.LIMIT,
|
|
@@ -16903,21 +16939,16 @@ var useOrderEntryNextInternal = (symbol, options = {}) => {
|
|
|
16903
16939
|
if ((key === "order_quantity" || key === "order_price") && hasTPSL(newValues)) {
|
|
16904
16940
|
newValues = calculateTPSL(key, newValues, markPrice, symbolInfo);
|
|
16905
16941
|
}
|
|
16906
|
-
{
|
|
16907
|
-
|
|
16908
|
-
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
16912
|
-
|
|
16913
|
-
|
|
16914
|
-
|
|
16915
|
-
|
|
16916
|
-
qty: newValues.order_quantity,
|
|
16917
|
-
price: newValues.order_price || markPrice,
|
|
16918
|
-
pnl: newValues.sl_pnl
|
|
16919
|
-
});
|
|
16920
|
-
}
|
|
16942
|
+
const { tp_ROI, sl_ROI } = priceToROI({
|
|
16943
|
+
values: newValues,
|
|
16944
|
+
symbolLeverage,
|
|
16945
|
+
markPrice
|
|
16946
|
+
});
|
|
16947
|
+
if (tp_ROI) {
|
|
16948
|
+
newValues.tp_ROI = tp_ROI;
|
|
16949
|
+
}
|
|
16950
|
+
if (sl_ROI) {
|
|
16951
|
+
newValues.sl_ROI = sl_ROI;
|
|
16921
16952
|
}
|
|
16922
16953
|
orderEntryActions.updateOrder(newValues);
|
|
16923
16954
|
return newValues;
|
|
@@ -17007,19 +17038,16 @@ var useOrderEntryNextInternal = (symbol, options = {}) => {
|
|
|
17007
17038
|
});
|
|
17008
17039
|
}
|
|
17009
17040
|
if (hasTPSL(newValues)) {
|
|
17010
|
-
|
|
17011
|
-
newValues
|
|
17012
|
-
|
|
17013
|
-
|
|
17014
|
-
|
|
17015
|
-
|
|
17041
|
+
const { tp_ROI, sl_ROI } = priceToROI({
|
|
17042
|
+
values: newValues,
|
|
17043
|
+
symbolLeverage,
|
|
17044
|
+
markPrice
|
|
17045
|
+
});
|
|
17046
|
+
if (tp_ROI) {
|
|
17047
|
+
newValues.tp_ROI = tp_ROI;
|
|
17016
17048
|
}
|
|
17017
|
-
if (
|
|
17018
|
-
newValues.sl_ROI =
|
|
17019
|
-
qty: newValues.order_quantity,
|
|
17020
|
-
price: newValues.order_price || markPrice,
|
|
17021
|
-
pnl: newValues.sl_pnl
|
|
17022
|
-
});
|
|
17049
|
+
if (sl_ROI) {
|
|
17050
|
+
newValues.sl_ROI = sl_ROI;
|
|
17023
17051
|
}
|
|
17024
17052
|
}
|
|
17025
17053
|
orderEntryActions.updateOrder(newValues);
|
|
@@ -17081,6 +17109,7 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
17081
17109
|
const symbolConfig = useSymbolsInfo();
|
|
17082
17110
|
const accountInfo = useAccountInfo2();
|
|
17083
17111
|
const positions3 = usePositions();
|
|
17112
|
+
const symbolLeverage = useLeverageBySymbol(symbol);
|
|
17084
17113
|
const symbolInfo = symbolConfig[symbol]();
|
|
17085
17114
|
const markPrice = actions.getMarkPriceBySymbol(symbol);
|
|
17086
17115
|
const { orderMetadata } = useOrderlyContext();
|
|
@@ -17095,7 +17124,8 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
17095
17124
|
...orderEntryActions
|
|
17096
17125
|
} = useOrderEntryNextInternal(symbol, {
|
|
17097
17126
|
...options,
|
|
17098
|
-
symbolInfo
|
|
17127
|
+
symbolInfo,
|
|
17128
|
+
symbolLeverage
|
|
17099
17129
|
});
|
|
17100
17130
|
const [estSlippage, setEstSlippage] = React2.useState(null);
|
|
17101
17131
|
const [doCreateOrder, { isMutating }] = useMutation(
|
|
@@ -17166,8 +17196,8 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
17166
17196
|
}, utils.zero);
|
|
17167
17197
|
avgExecutionPrice = sumPrice.div(order_quantity);
|
|
17168
17198
|
}
|
|
17169
|
-
|
|
17170
|
-
|
|
17199
|
+
const bestPrice = book[0][0];
|
|
17200
|
+
if (avgExecutionPrice && bestPrice) {
|
|
17171
17201
|
const estSlippage2 = avgExecutionPrice.minus(bestPrice).abs().div(bestPrice).toNumber();
|
|
17172
17202
|
setEstSlippage(estSlippage2);
|
|
17173
17203
|
}
|
|
@@ -17470,7 +17500,8 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
17470
17500
|
symbolInfo: symbolInfo || types.EMPTY_OBJECT,
|
|
17471
17501
|
metaState: meta,
|
|
17472
17502
|
isMutating,
|
|
17473
|
-
markPrice
|
|
17503
|
+
markPrice,
|
|
17504
|
+
symbolLeverage
|
|
17474
17505
|
};
|
|
17475
17506
|
};
|
|
17476
17507
|
var initialOrderState2 = {
|