@orderly.network/hooks 1.1.4-alpha.0 → 1.1.4-alpha.10
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 +117 -4
- package/dist/index.d.ts +117 -4
- package/dist/index.js +507 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +509 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -25,7 +25,7 @@ declare global {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
declare const _default: "1.1.4-alpha.
|
|
28
|
+
declare const _default: "1.1.4-alpha.10";
|
|
29
29
|
|
|
30
30
|
type useQueryOptions<T> = SWRConfiguration & {
|
|
31
31
|
formatter?: (data: any) => T;
|
|
@@ -96,6 +96,8 @@ declare function useSessionStorage<T>(key: string, initialValue: T): [T, (data:
|
|
|
96
96
|
|
|
97
97
|
declare function useLocalStorage<T>(key: string, initialValue: T): [any, (value: T) => void];
|
|
98
98
|
|
|
99
|
+
declare function parseJSON<T>(value: string | null): T | undefined;
|
|
100
|
+
|
|
99
101
|
declare const useWS: () => WS;
|
|
100
102
|
|
|
101
103
|
declare const useConfig: <T>(key?: ConfigKey, defaultValue?: T | undefined) => ConfigStore | T;
|
|
@@ -179,8 +181,15 @@ type OrderbookData = {
|
|
|
179
181
|
asks: OrderBookItem[];
|
|
180
182
|
bids: OrderBookItem[];
|
|
181
183
|
};
|
|
184
|
+
/**
|
|
185
|
+
* Configuration for the Order Book
|
|
186
|
+
* @level Indicates the number of data entries to return for ask/bid, default is 10
|
|
187
|
+
* @padding Whether to fill in when the actual data entries are less than the level. If filled, it will add [nan, nan, nan, nan]
|
|
188
|
+
* default is true
|
|
189
|
+
*/
|
|
182
190
|
type OrderbookOptions = {
|
|
183
191
|
level?: number;
|
|
192
|
+
padding?: boolean;
|
|
184
193
|
};
|
|
185
194
|
/**
|
|
186
195
|
* @name useOrderbookStream
|
|
@@ -244,21 +253,30 @@ type UseOrderEntryReturn = {
|
|
|
244
253
|
metaState: UseOrderEntryMetaState;
|
|
245
254
|
symbolConfig: API.SymbolExt;
|
|
246
255
|
};
|
|
247
|
-
type OrderParams = Required<Pick<OrderEntity, "side" | "order_type" | "symbol">> & Partial<Omit<OrderEntity, "side" | "symbol" | "order_type"
|
|
256
|
+
type OrderParams = Required<Pick<OrderEntity, "side" | "order_type" | "symbol">> & Partial<Omit<OrderEntity, "side" | "symbol" | "order_type">>;
|
|
248
257
|
/**
|
|
249
258
|
* Create Order
|
|
250
259
|
* @example
|
|
251
260
|
* ```tsx
|
|
261
|
+
* import { useOrderEntry } from "@orderly.network/hooks";
|
|
262
|
+
* import {OrderSide, OrderType} from '@orderly.network/types';
|
|
263
|
+
*
|
|
252
264
|
* const { formattedOrder, onSubmit, helper } = useOrderEntry({
|
|
253
265
|
* symbol: "PERP_ETH_USDC",
|
|
254
266
|
* side: OrderSide.BUY,
|
|
255
267
|
* order_type: OrderType.LIMIT,
|
|
256
268
|
* order_price: 10000,
|
|
257
269
|
* order_quantity: 1,
|
|
270
|
+
* },{
|
|
271
|
+
* // **Note:** it's required
|
|
272
|
+
* watchOrderbook: true,
|
|
258
273
|
* });
|
|
259
274
|
* ```
|
|
260
275
|
*/
|
|
261
276
|
declare function useOrderEntry(order: OrderParams, options?: UseOrderEntryOptions): UseOrderEntryReturn;
|
|
277
|
+
/**
|
|
278
|
+
* @deprecated
|
|
279
|
+
*/
|
|
262
280
|
declare function useOrderEntry(symbol: string, side: OrderSide, reduceOnly: boolean): UseOrderEntryReturn;
|
|
263
281
|
|
|
264
282
|
declare const useSymbolsInfo: () => Record<string, any>;
|
|
@@ -475,7 +493,7 @@ declare const useDeposit: (options?: useDepositOptions) => {
|
|
|
475
493
|
depositFee: bigint;
|
|
476
494
|
/** enquiring depositFee status on chain */
|
|
477
495
|
depositFeeRevalidating: boolean;
|
|
478
|
-
approve: (amount?: string) => Promise<
|
|
496
|
+
approve: (amount?: string) => Promise<void | undefined>;
|
|
479
497
|
deposit: () => Promise<any>;
|
|
480
498
|
fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
|
|
481
499
|
fetchBalance: (address: string, decimals?: number) => Promise<string>;
|
|
@@ -518,6 +536,101 @@ declare const useSymbolPriceRange: (symbol: string, side: "BUY" | "SELL", price?
|
|
|
518
536
|
|
|
519
537
|
declare function useMediaQuery(query: string): boolean;
|
|
520
538
|
|
|
539
|
+
type posterDataSource = {
|
|
540
|
+
message?: string;
|
|
541
|
+
position: {
|
|
542
|
+
symbol: string;
|
|
543
|
+
side: "LONG" | "SHORT";
|
|
544
|
+
/**
|
|
545
|
+
* The leverage of the position
|
|
546
|
+
*/
|
|
547
|
+
leverage: number;
|
|
548
|
+
/**
|
|
549
|
+
* The unrealized PnL of the position
|
|
550
|
+
*/
|
|
551
|
+
pnl: number;
|
|
552
|
+
/**
|
|
553
|
+
* The return on investment of the position
|
|
554
|
+
*/
|
|
555
|
+
ROI: number;
|
|
556
|
+
/**
|
|
557
|
+
* The informations of the position, such as open price, opened at, mark price, quantity
|
|
558
|
+
*/
|
|
559
|
+
informations: {
|
|
560
|
+
title: string;
|
|
561
|
+
value: string;
|
|
562
|
+
}[];
|
|
563
|
+
/**
|
|
564
|
+
* The quote currency of the position
|
|
565
|
+
*/
|
|
566
|
+
currency: string;
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* The domain of the application
|
|
570
|
+
*/
|
|
571
|
+
domain: string;
|
|
572
|
+
/**
|
|
573
|
+
* The update time of the position
|
|
574
|
+
*/
|
|
575
|
+
updateTime: string;
|
|
576
|
+
};
|
|
577
|
+
type layoutInfo = {
|
|
578
|
+
width?: number;
|
|
579
|
+
height?: number;
|
|
580
|
+
fontSize?: number;
|
|
581
|
+
color?: string;
|
|
582
|
+
textAlign?: CanvasTextAlign;
|
|
583
|
+
textBaseline?: CanvasTextBaseline;
|
|
584
|
+
position: Partial<{
|
|
585
|
+
left: number;
|
|
586
|
+
right: number;
|
|
587
|
+
top: number;
|
|
588
|
+
bottom: number;
|
|
589
|
+
}>;
|
|
590
|
+
};
|
|
591
|
+
type posterLayoutConfig = {
|
|
592
|
+
message?: layoutInfo;
|
|
593
|
+
domain?: layoutInfo;
|
|
594
|
+
position?: layoutInfo;
|
|
595
|
+
unrealizedPnl?: layoutInfo;
|
|
596
|
+
informations?: layoutInfo;
|
|
597
|
+
updateTime?: layoutInfo;
|
|
598
|
+
};
|
|
599
|
+
type drawOptions = {
|
|
600
|
+
/**
|
|
601
|
+
* Color of common text
|
|
602
|
+
*/
|
|
603
|
+
color?: string;
|
|
604
|
+
/**
|
|
605
|
+
* Lose color
|
|
606
|
+
*/
|
|
607
|
+
loseColor?: string;
|
|
608
|
+
/**
|
|
609
|
+
* Profit color
|
|
610
|
+
*/
|
|
611
|
+
profitColor?: string;
|
|
612
|
+
/**
|
|
613
|
+
* The brand color of the application
|
|
614
|
+
*/
|
|
615
|
+
brandColor?: string;
|
|
616
|
+
backgroundColor?: string;
|
|
617
|
+
backgroundImg?: string;
|
|
618
|
+
data?: posterDataSource;
|
|
619
|
+
layout?: posterLayoutConfig;
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Generates a poster image based on position information. You can set the size, background color, font color, font size, and content position of the poster.
|
|
624
|
+
* @returns
|
|
625
|
+
*/
|
|
626
|
+
declare const usePoster: (trage: HTMLCanvasElement, options: drawOptions) => {
|
|
627
|
+
readonly error: Error | null;
|
|
628
|
+
/**
|
|
629
|
+
* Converts the poster to a data URL
|
|
630
|
+
*/
|
|
631
|
+
readonly toDataURL: (type?: string, encoderOptions?: number) => string;
|
|
632
|
+
};
|
|
633
|
+
|
|
521
634
|
declare const cleanStringStyle: (str: string | number) => string;
|
|
522
635
|
|
|
523
636
|
/** @hidden */
|
|
@@ -545,4 +658,4 @@ declare const useCrossSwap: () => any;
|
|
|
545
658
|
/** @hidden */
|
|
546
659
|
declare const useSwap: () => any;
|
|
547
660
|
|
|
548
|
-
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderParams, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, StatusContext, StatusContextState, StatusProvider, UseOrderEntryMetaState, WalletConnectorContext, WsNetworkStatus, cleanStringStyle, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarkets, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolPriceRange, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, useWsStatus, _default as version };
|
|
661
|
+
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderParams, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, StatusContext, StatusContextState, StatusProvider, UseOrderEntryMetaState, WalletConnectorContext, WsNetworkStatus, cleanStringStyle, drawOptions, parseJSON, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarkets, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolPriceRange, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, useWsStatus, _default as version };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ declare global {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
declare const _default: "1.1.4-alpha.
|
|
28
|
+
declare const _default: "1.1.4-alpha.10";
|
|
29
29
|
|
|
30
30
|
type useQueryOptions<T> = SWRConfiguration & {
|
|
31
31
|
formatter?: (data: any) => T;
|
|
@@ -96,6 +96,8 @@ declare function useSessionStorage<T>(key: string, initialValue: T): [T, (data:
|
|
|
96
96
|
|
|
97
97
|
declare function useLocalStorage<T>(key: string, initialValue: T): [any, (value: T) => void];
|
|
98
98
|
|
|
99
|
+
declare function parseJSON<T>(value: string | null): T | undefined;
|
|
100
|
+
|
|
99
101
|
declare const useWS: () => WS;
|
|
100
102
|
|
|
101
103
|
declare const useConfig: <T>(key?: ConfigKey, defaultValue?: T | undefined) => ConfigStore | T;
|
|
@@ -179,8 +181,15 @@ type OrderbookData = {
|
|
|
179
181
|
asks: OrderBookItem[];
|
|
180
182
|
bids: OrderBookItem[];
|
|
181
183
|
};
|
|
184
|
+
/**
|
|
185
|
+
* Configuration for the Order Book
|
|
186
|
+
* @level Indicates the number of data entries to return for ask/bid, default is 10
|
|
187
|
+
* @padding Whether to fill in when the actual data entries are less than the level. If filled, it will add [nan, nan, nan, nan]
|
|
188
|
+
* default is true
|
|
189
|
+
*/
|
|
182
190
|
type OrderbookOptions = {
|
|
183
191
|
level?: number;
|
|
192
|
+
padding?: boolean;
|
|
184
193
|
};
|
|
185
194
|
/**
|
|
186
195
|
* @name useOrderbookStream
|
|
@@ -244,21 +253,30 @@ type UseOrderEntryReturn = {
|
|
|
244
253
|
metaState: UseOrderEntryMetaState;
|
|
245
254
|
symbolConfig: API.SymbolExt;
|
|
246
255
|
};
|
|
247
|
-
type OrderParams = Required<Pick<OrderEntity, "side" | "order_type" | "symbol">> & Partial<Omit<OrderEntity, "side" | "symbol" | "order_type"
|
|
256
|
+
type OrderParams = Required<Pick<OrderEntity, "side" | "order_type" | "symbol">> & Partial<Omit<OrderEntity, "side" | "symbol" | "order_type">>;
|
|
248
257
|
/**
|
|
249
258
|
* Create Order
|
|
250
259
|
* @example
|
|
251
260
|
* ```tsx
|
|
261
|
+
* import { useOrderEntry } from "@orderly.network/hooks";
|
|
262
|
+
* import {OrderSide, OrderType} from '@orderly.network/types';
|
|
263
|
+
*
|
|
252
264
|
* const { formattedOrder, onSubmit, helper } = useOrderEntry({
|
|
253
265
|
* symbol: "PERP_ETH_USDC",
|
|
254
266
|
* side: OrderSide.BUY,
|
|
255
267
|
* order_type: OrderType.LIMIT,
|
|
256
268
|
* order_price: 10000,
|
|
257
269
|
* order_quantity: 1,
|
|
270
|
+
* },{
|
|
271
|
+
* // **Note:** it's required
|
|
272
|
+
* watchOrderbook: true,
|
|
258
273
|
* });
|
|
259
274
|
* ```
|
|
260
275
|
*/
|
|
261
276
|
declare function useOrderEntry(order: OrderParams, options?: UseOrderEntryOptions): UseOrderEntryReturn;
|
|
277
|
+
/**
|
|
278
|
+
* @deprecated
|
|
279
|
+
*/
|
|
262
280
|
declare function useOrderEntry(symbol: string, side: OrderSide, reduceOnly: boolean): UseOrderEntryReturn;
|
|
263
281
|
|
|
264
282
|
declare const useSymbolsInfo: () => Record<string, any>;
|
|
@@ -475,7 +493,7 @@ declare const useDeposit: (options?: useDepositOptions) => {
|
|
|
475
493
|
depositFee: bigint;
|
|
476
494
|
/** enquiring depositFee status on chain */
|
|
477
495
|
depositFeeRevalidating: boolean;
|
|
478
|
-
approve: (amount?: string) => Promise<
|
|
496
|
+
approve: (amount?: string) => Promise<void | undefined>;
|
|
479
497
|
deposit: () => Promise<any>;
|
|
480
498
|
fetchBalances: (tokens: API.TokenInfo[]) => Promise<void>;
|
|
481
499
|
fetchBalance: (address: string, decimals?: number) => Promise<string>;
|
|
@@ -518,6 +536,101 @@ declare const useSymbolPriceRange: (symbol: string, side: "BUY" | "SELL", price?
|
|
|
518
536
|
|
|
519
537
|
declare function useMediaQuery(query: string): boolean;
|
|
520
538
|
|
|
539
|
+
type posterDataSource = {
|
|
540
|
+
message?: string;
|
|
541
|
+
position: {
|
|
542
|
+
symbol: string;
|
|
543
|
+
side: "LONG" | "SHORT";
|
|
544
|
+
/**
|
|
545
|
+
* The leverage of the position
|
|
546
|
+
*/
|
|
547
|
+
leverage: number;
|
|
548
|
+
/**
|
|
549
|
+
* The unrealized PnL of the position
|
|
550
|
+
*/
|
|
551
|
+
pnl: number;
|
|
552
|
+
/**
|
|
553
|
+
* The return on investment of the position
|
|
554
|
+
*/
|
|
555
|
+
ROI: number;
|
|
556
|
+
/**
|
|
557
|
+
* The informations of the position, such as open price, opened at, mark price, quantity
|
|
558
|
+
*/
|
|
559
|
+
informations: {
|
|
560
|
+
title: string;
|
|
561
|
+
value: string;
|
|
562
|
+
}[];
|
|
563
|
+
/**
|
|
564
|
+
* The quote currency of the position
|
|
565
|
+
*/
|
|
566
|
+
currency: string;
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* The domain of the application
|
|
570
|
+
*/
|
|
571
|
+
domain: string;
|
|
572
|
+
/**
|
|
573
|
+
* The update time of the position
|
|
574
|
+
*/
|
|
575
|
+
updateTime: string;
|
|
576
|
+
};
|
|
577
|
+
type layoutInfo = {
|
|
578
|
+
width?: number;
|
|
579
|
+
height?: number;
|
|
580
|
+
fontSize?: number;
|
|
581
|
+
color?: string;
|
|
582
|
+
textAlign?: CanvasTextAlign;
|
|
583
|
+
textBaseline?: CanvasTextBaseline;
|
|
584
|
+
position: Partial<{
|
|
585
|
+
left: number;
|
|
586
|
+
right: number;
|
|
587
|
+
top: number;
|
|
588
|
+
bottom: number;
|
|
589
|
+
}>;
|
|
590
|
+
};
|
|
591
|
+
type posterLayoutConfig = {
|
|
592
|
+
message?: layoutInfo;
|
|
593
|
+
domain?: layoutInfo;
|
|
594
|
+
position?: layoutInfo;
|
|
595
|
+
unrealizedPnl?: layoutInfo;
|
|
596
|
+
informations?: layoutInfo;
|
|
597
|
+
updateTime?: layoutInfo;
|
|
598
|
+
};
|
|
599
|
+
type drawOptions = {
|
|
600
|
+
/**
|
|
601
|
+
* Color of common text
|
|
602
|
+
*/
|
|
603
|
+
color?: string;
|
|
604
|
+
/**
|
|
605
|
+
* Lose color
|
|
606
|
+
*/
|
|
607
|
+
loseColor?: string;
|
|
608
|
+
/**
|
|
609
|
+
* Profit color
|
|
610
|
+
*/
|
|
611
|
+
profitColor?: string;
|
|
612
|
+
/**
|
|
613
|
+
* The brand color of the application
|
|
614
|
+
*/
|
|
615
|
+
brandColor?: string;
|
|
616
|
+
backgroundColor?: string;
|
|
617
|
+
backgroundImg?: string;
|
|
618
|
+
data?: posterDataSource;
|
|
619
|
+
layout?: posterLayoutConfig;
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Generates a poster image based on position information. You can set the size, background color, font color, font size, and content position of the poster.
|
|
624
|
+
* @returns
|
|
625
|
+
*/
|
|
626
|
+
declare const usePoster: (trage: HTMLCanvasElement, options: drawOptions) => {
|
|
627
|
+
readonly error: Error | null;
|
|
628
|
+
/**
|
|
629
|
+
* Converts the poster to a data URL
|
|
630
|
+
*/
|
|
631
|
+
readonly toDataURL: (type?: string, encoderOptions?: number) => string;
|
|
632
|
+
};
|
|
633
|
+
|
|
521
634
|
declare const cleanStringStyle: (str: string | number) => string;
|
|
522
635
|
|
|
523
636
|
/** @hidden */
|
|
@@ -545,4 +658,4 @@ declare const useCrossSwap: () => any;
|
|
|
545
658
|
/** @hidden */
|
|
546
659
|
declare const useSwap: () => any;
|
|
547
660
|
|
|
548
|
-
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderParams, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, StatusContext, StatusContextState, StatusProvider, UseOrderEntryMetaState, WalletConnectorContext, WsNetworkStatus, cleanStringStyle, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarkets, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolPriceRange, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, useWsStatus, _default as version };
|
|
661
|
+
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderParams, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, StatusContext, StatusContextState, StatusProvider, UseOrderEntryMetaState, WalletConnectorContext, WsNetworkStatus, cleanStringStyle, drawOptions, parseJSON, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarkets, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolPriceRange, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, useWsStatus, _default as version };
|