@pear-protocol/hyperliquid-sdk 0.0.29 → 0.0.31
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/clients/positions.d.ts +8 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useTwap.d.ts +6 -0
- package/dist/index.d.ts +79 -27
- package/dist/index.js +35 -2
- package/dist/types.d.ts +41 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ApiResponse } from '../types';
|
|
2
|
+
import type { CancelTwapResponseDto } from './orders';
|
|
2
3
|
export type ExecutionType = 'MARKET' | 'LIMIT' | 'TWAP' | 'LADDER' | 'LIMIT_BTCDOM';
|
|
3
4
|
export type TpSlThresholdType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
4
5
|
export interface PairAssetInput {
|
|
@@ -9,6 +10,11 @@ export interface TpSlThresholdInput {
|
|
|
9
10
|
type: TpSlThresholdType;
|
|
10
11
|
value: number;
|
|
11
12
|
}
|
|
13
|
+
export interface LadderConfigInput {
|
|
14
|
+
ratioStart: number;
|
|
15
|
+
ratioEnd: number;
|
|
16
|
+
numberOfLevels: number;
|
|
17
|
+
}
|
|
12
18
|
export interface CreatePositionRequestInput {
|
|
13
19
|
slippage: number;
|
|
14
20
|
executionType: ExecutionType;
|
|
@@ -20,6 +26,7 @@ export interface CreatePositionRequestInput {
|
|
|
20
26
|
direction?: 'MORE_THAN' | 'LESS_THAN';
|
|
21
27
|
twapDuration?: number;
|
|
22
28
|
randomizeExecution?: boolean;
|
|
29
|
+
ladderConfig?: LadderConfigInput;
|
|
23
30
|
takeProfit?: TpSlThresholdInput | null;
|
|
24
31
|
stopLoss?: TpSlThresholdInput | null;
|
|
25
32
|
}
|
|
@@ -87,3 +94,4 @@ export interface AdjustPositionResponseDto {
|
|
|
87
94
|
executedAt: string;
|
|
88
95
|
}
|
|
89
96
|
export declare function adjustPosition(baseUrl: string, accessToken: string, positionId: string, payload: AdjustPositionRequestInput): Promise<ApiResponse<AdjustPositionResponseDto>>;
|
|
97
|
+
export declare function cancelTwap(baseUrl: string, accessToken: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'e
|
|
|
30
30
|
/**
|
|
31
31
|
* WebSocket channels
|
|
32
32
|
*/
|
|
33
|
-
type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'webData2' | 'allMids' | 'activeAssetData';
|
|
33
|
+
type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'webData2' | 'allMids' | 'activeAssetData';
|
|
34
34
|
/**
|
|
35
35
|
* WebSocket subscription message
|
|
36
36
|
*/
|
|
@@ -53,6 +53,46 @@ interface WebSocketDataMessage<T = unknown> {
|
|
|
53
53
|
channel: WebSocketChannel;
|
|
54
54
|
data: T;
|
|
55
55
|
}
|
|
56
|
+
interface ChunkFillDto {
|
|
57
|
+
fillId: string;
|
|
58
|
+
assetName: string;
|
|
59
|
+
price: number;
|
|
60
|
+
size: number;
|
|
61
|
+
executedAt: string;
|
|
62
|
+
}
|
|
63
|
+
type TwapChunkStatus = 'PENDING' | 'SCHEDULED' | 'EXECUTING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
64
|
+
interface TwapChunkStatusDto {
|
|
65
|
+
chunkId: string;
|
|
66
|
+
chunkIndex: number;
|
|
67
|
+
scheduledTime: string;
|
|
68
|
+
executedTime?: string;
|
|
69
|
+
status: TwapChunkStatus;
|
|
70
|
+
chunkSize: number;
|
|
71
|
+
fills: ChunkFillDto[];
|
|
72
|
+
errorMessage?: string;
|
|
73
|
+
}
|
|
74
|
+
type TwapOrderOverallStatus = 'OPEN' | 'EXECUTING' | 'COMPLETED' | 'PARTIALLY_COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
75
|
+
interface TwapMonitoringDto {
|
|
76
|
+
orderId: string;
|
|
77
|
+
positionId?: string;
|
|
78
|
+
address: string;
|
|
79
|
+
orderType: string;
|
|
80
|
+
status: TwapOrderOverallStatus;
|
|
81
|
+
totalUsdValue: number;
|
|
82
|
+
filledUsdValue: number;
|
|
83
|
+
remainingUsdValue: number;
|
|
84
|
+
twapDuration: string;
|
|
85
|
+
randomizeExecution: boolean;
|
|
86
|
+
reduceOnly: boolean;
|
|
87
|
+
chunks: TwapChunkStatusDto[];
|
|
88
|
+
estimatedCompletionTime?: string;
|
|
89
|
+
actualCompletionTime?: string;
|
|
90
|
+
remainingChunks: number;
|
|
91
|
+
longAssets: OrderAssetDto[];
|
|
92
|
+
shortAssets: OrderAssetDto[];
|
|
93
|
+
createdAt: string;
|
|
94
|
+
updatedAt: string;
|
|
95
|
+
}
|
|
56
96
|
/**
|
|
57
97
|
* Trade history asset data
|
|
58
98
|
*/
|
|
@@ -755,6 +795,30 @@ interface AutoSyncFillsState {
|
|
|
755
795
|
*/
|
|
756
796
|
declare function useAutoSyncFills(options: AutoSyncFillsOptions): AutoSyncFillsState;
|
|
757
797
|
|
|
798
|
+
interface AdjustOrderRequestInput {
|
|
799
|
+
limitRatio?: number;
|
|
800
|
+
usdValue?: number;
|
|
801
|
+
}
|
|
802
|
+
interface AdjustOrderResponseDto {
|
|
803
|
+
orderId: string;
|
|
804
|
+
limitRatio: number;
|
|
805
|
+
usdValue: number;
|
|
806
|
+
updatedAt: string;
|
|
807
|
+
}
|
|
808
|
+
declare function adjustOrder(baseUrl: string, accessToken: string, orderId: string, payload: AdjustOrderRequestInput): Promise<ApiResponse<AdjustOrderResponseDto>>;
|
|
809
|
+
interface CancelOrderResponseDto {
|
|
810
|
+
orderId: string;
|
|
811
|
+
status: string;
|
|
812
|
+
cancelledAt: string;
|
|
813
|
+
}
|
|
814
|
+
declare function cancelOrder(baseUrl: string, accessToken: string, orderId: string): Promise<ApiResponse<CancelOrderResponseDto>>;
|
|
815
|
+
interface CancelTwapResponseDto {
|
|
816
|
+
orderId: string;
|
|
817
|
+
status: string;
|
|
818
|
+
cancelledAt: string;
|
|
819
|
+
}
|
|
820
|
+
declare function cancelTwapOrder(baseUrl: string, accessToken: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
821
|
+
|
|
758
822
|
type ExecutionType = 'MARKET' | 'LIMIT' | 'TWAP' | 'LADDER' | 'LIMIT_BTCDOM';
|
|
759
823
|
type TpSlThresholdType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
760
824
|
interface PairAssetInput {
|
|
@@ -765,6 +829,11 @@ interface TpSlThresholdInput {
|
|
|
765
829
|
type: TpSlThresholdType;
|
|
766
830
|
value: number;
|
|
767
831
|
}
|
|
832
|
+
interface LadderConfigInput {
|
|
833
|
+
ratioStart: number;
|
|
834
|
+
ratioEnd: number;
|
|
835
|
+
numberOfLevels: number;
|
|
836
|
+
}
|
|
768
837
|
interface CreatePositionRequestInput {
|
|
769
838
|
slippage: number;
|
|
770
839
|
executionType: ExecutionType;
|
|
@@ -776,6 +845,7 @@ interface CreatePositionRequestInput {
|
|
|
776
845
|
direction?: 'MORE_THAN' | 'LESS_THAN';
|
|
777
846
|
twapDuration?: number;
|
|
778
847
|
randomizeExecution?: boolean;
|
|
848
|
+
ladderConfig?: LadderConfigInput;
|
|
779
849
|
takeProfit?: TpSlThresholdInput | null;
|
|
780
850
|
stopLoss?: TpSlThresholdInput | null;
|
|
781
851
|
}
|
|
@@ -843,6 +913,7 @@ interface AdjustPositionResponseDto {
|
|
|
843
913
|
executedAt: string;
|
|
844
914
|
}
|
|
845
915
|
declare function adjustPosition(baseUrl: string, accessToken: string, positionId: string, payload: AdjustPositionRequestInput): Promise<ApiResponse<AdjustPositionResponseDto>>;
|
|
916
|
+
declare function cancelTwap(baseUrl: string, accessToken: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
846
917
|
|
|
847
918
|
declare function usePosition(): {
|
|
848
919
|
readonly createPosition: (payload: CreatePositionRequestInput) => Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
@@ -853,30 +924,6 @@ declare function usePosition(): {
|
|
|
853
924
|
readonly isLoading: boolean;
|
|
854
925
|
};
|
|
855
926
|
|
|
856
|
-
interface AdjustOrderRequestInput {
|
|
857
|
-
limitRatio?: number;
|
|
858
|
-
usdValue?: number;
|
|
859
|
-
}
|
|
860
|
-
interface AdjustOrderResponseDto {
|
|
861
|
-
orderId: string;
|
|
862
|
-
limitRatio: number;
|
|
863
|
-
usdValue: number;
|
|
864
|
-
updatedAt: string;
|
|
865
|
-
}
|
|
866
|
-
declare function adjustOrder(baseUrl: string, accessToken: string, orderId: string, payload: AdjustOrderRequestInput): Promise<ApiResponse<AdjustOrderResponseDto>>;
|
|
867
|
-
interface CancelOrderResponseDto {
|
|
868
|
-
orderId: string;
|
|
869
|
-
status: string;
|
|
870
|
-
cancelledAt: string;
|
|
871
|
-
}
|
|
872
|
-
declare function cancelOrder(baseUrl: string, accessToken: string, orderId: string): Promise<ApiResponse<CancelOrderResponseDto>>;
|
|
873
|
-
interface CancelTwapResponseDto {
|
|
874
|
-
orderId: string;
|
|
875
|
-
status: string;
|
|
876
|
-
cancelledAt: string;
|
|
877
|
-
}
|
|
878
|
-
declare function cancelTwapOrder(baseUrl: string, accessToken: string, orderId: string): Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
879
|
-
|
|
880
927
|
declare function useOrders(): {
|
|
881
928
|
readonly adjustOrder: (orderId: string, payload: AdjustOrderRequestInput) => Promise<ApiResponse<AdjustOrderResponseDto>>;
|
|
882
929
|
readonly cancelOrder: (orderId: string) => Promise<ApiResponse<CancelOrderResponseDto>>;
|
|
@@ -885,6 +932,11 @@ declare function useOrders(): {
|
|
|
885
932
|
readonly isLoading: boolean;
|
|
886
933
|
};
|
|
887
934
|
|
|
935
|
+
declare function useTwap(): {
|
|
936
|
+
readonly orders: any;
|
|
937
|
+
readonly cancelTwap: (orderId: string) => Promise<ApiResponse<CancelTwapResponseDto>>;
|
|
938
|
+
};
|
|
939
|
+
|
|
888
940
|
interface UseHyperliquidWebSocketProps {
|
|
889
941
|
wsUrl: string;
|
|
890
942
|
address: string | null;
|
|
@@ -1008,5 +1060,5 @@ declare function mapTradingViewIntervalToCandleInterval(interval: string): Candl
|
|
|
1008
1060
|
*/
|
|
1009
1061
|
declare function mapCandleIntervalToTradingViewInterval(interval: CandleInterval): string;
|
|
1010
1062
|
|
|
1011
|
-
export { AccountSummaryCalculator, AuthStatus, ConflictDetector, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateWeightedRatio, cancelOrder, cancelTwapOrder, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, updateRiskParameters, useAccountSummary, useAddress, useAgentWallet, useAuth, useAutoSyncFills, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useOpenOrders, useOrders, usePearAgentWallet, usePearAuth, usePearHyperliquid, usePerformanceOverlays, usePosition, useTokenSelectionMetadata, useTradeHistories, useUserSelection, useWebData };
|
|
1012
|
-
export type { AccountSummaryResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AutoSyncFillsOptions, AutoSyncFillsState, BalanceSummaryDto, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, HLWebSocketResponse, HistoricalRange, MarginSummaryDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetInput, PerformanceOverlay, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAgentWalletOptions, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UsePerformanceOverlaysReturn, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WebData2Response, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|
|
1063
|
+
export { AccountSummaryCalculator, AuthStatus, ConflictDetector, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, updateRiskParameters, useAccountSummary, useAddress, useAgentWallet, useAuth, useAutoSyncFills, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useOpenOrders, useOrders, usePearAgentWallet, usePearAuth, usePearHyperliquid, usePerformanceOverlays, usePosition, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWebData };
|
|
1064
|
+
export type { AccountSummaryResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AutoSyncFillsOptions, AutoSyncFillsState, BalanceSummaryDto, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CreatePositionRequestInput, CreatePositionResponseDto, CrossMarginSummaryDto, CumFundingDto, ExecutionType, HLWebSocketResponse, HistoricalRange, LadderConfigInput, MarginSummaryDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderStatus, PairAssetInput, PerformanceOverlay, PositionAdjustmentType, PositionAssetDetailDto, PositionAssetSummaryDto, PositionResponseStatus, RealtimeBar, RealtimeBarsCallback, TokenConflict, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TpSlThresholdInput, TpSlThresholdType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TwapChunkStatusDto, TwapMonitoringDto, UniverseAsset, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAgentWalletOptions, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UsePerformanceOverlaysReturn, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WebData2Response, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|
package/dist/index.js
CHANGED
|
@@ -2433,20 +2433,23 @@ const useUserData = create((set) => ({
|
|
|
2433
2433
|
rawOpenPositions: null,
|
|
2434
2434
|
openOrders: null,
|
|
2435
2435
|
accountSummary: null,
|
|
2436
|
+
twapDetails: null,
|
|
2436
2437
|
setTradeHistories: (value) => set({ tradeHistories: value }),
|
|
2437
2438
|
setRawOpenPositions: (value) => set({ rawOpenPositions: value }),
|
|
2438
2439
|
setOpenOrders: (value) => set({ openOrders: value }),
|
|
2439
2440
|
setAccountSummary: (value) => set({ accountSummary: value }),
|
|
2441
|
+
setTwapDetails: (value) => set({ twapDetails: value }),
|
|
2440
2442
|
clean: () => set({
|
|
2441
2443
|
tradeHistories: null,
|
|
2442
2444
|
rawOpenPositions: null,
|
|
2443
2445
|
openOrders: null,
|
|
2444
2446
|
accountSummary: null,
|
|
2447
|
+
twapDetails: null,
|
|
2445
2448
|
}),
|
|
2446
2449
|
}));
|
|
2447
2450
|
|
|
2448
2451
|
const useHyperliquidWebSocket = ({ wsUrl, address }) => {
|
|
2449
|
-
const { setTradeHistories, setRawOpenPositions, setOpenOrders, setAccountSummary, clean } = useUserData();
|
|
2452
|
+
const { setTradeHistories, setRawOpenPositions, setOpenOrders, setAccountSummary, setTwapDetails, clean } = useUserData();
|
|
2450
2453
|
const [lastError, setLastError] = useState(null);
|
|
2451
2454
|
const [lastSubscribedAddress, setLastSubscribedAddress] = useState(null);
|
|
2452
2455
|
// WebSocket connection
|
|
@@ -2487,6 +2490,9 @@ const useHyperliquidWebSocket = ({ wsUrl, address }) => {
|
|
|
2487
2490
|
case 'account-summary':
|
|
2488
2491
|
setAccountSummary(dataMessage.data);
|
|
2489
2492
|
break;
|
|
2493
|
+
case 'twap-details':
|
|
2494
|
+
setTwapDetails(dataMessage.data);
|
|
2495
|
+
break;
|
|
2490
2496
|
}
|
|
2491
2497
|
}
|
|
2492
2498
|
}
|
|
@@ -8291,6 +8297,18 @@ async function adjustPosition(baseUrl, accessToken, positionId, payload) {
|
|
|
8291
8297
|
throw toApiError(error);
|
|
8292
8298
|
}
|
|
8293
8299
|
}
|
|
8300
|
+
// ---------------- Cancel TWAP (by orderId) ----------------
|
|
8301
|
+
// Convenience API colocated with position operations
|
|
8302
|
+
async function cancelTwap(baseUrl, accessToken, orderId) {
|
|
8303
|
+
const url = joinUrl(baseUrl, `/orders/${orderId}/twap/cancel`);
|
|
8304
|
+
try {
|
|
8305
|
+
const resp = await axios$1.post(url, {}, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, timeout: 60000 });
|
|
8306
|
+
return { data: resp.data, status: resp.status, headers: resp.headers };
|
|
8307
|
+
}
|
|
8308
|
+
catch (error) {
|
|
8309
|
+
throw toApiError(error);
|
|
8310
|
+
}
|
|
8311
|
+
}
|
|
8294
8312
|
|
|
8295
8313
|
const calculatePositionAsset = (asset, currentPrice, totalInitialPositionSize, leverage, cumFunding, isLong = true) => {
|
|
8296
8314
|
const initialPositionValue = asset.entryPrice * asset.size;
|
|
@@ -8502,6 +8520,21 @@ function useOrders() {
|
|
|
8502
8520
|
return { adjustOrder: adjustOrder$1, cancelOrder: cancelOrder$1, cancelTwapOrder: cancelTwapOrder$1, openOrders: enrichedOpenOrders, isLoading };
|
|
8503
8521
|
}
|
|
8504
8522
|
|
|
8523
|
+
function useTwap() {
|
|
8524
|
+
const twapDetails = useUserData(state => state.twapDetails);
|
|
8525
|
+
const context = useContext(PearHyperliquidContext);
|
|
8526
|
+
if (!context)
|
|
8527
|
+
throw new Error('useTwap must be used within a PearHyperliquidProvider');
|
|
8528
|
+
const { apiBaseUrl, accessToken } = context;
|
|
8529
|
+
const orders = useMemo(() => twapDetails !== null && twapDetails !== void 0 ? twapDetails : [], [twapDetails]);
|
|
8530
|
+
const cancelTwap$1 = async (orderId) => {
|
|
8531
|
+
if (!accessToken)
|
|
8532
|
+
throw new Error('Not authenticated');
|
|
8533
|
+
return cancelTwap(apiBaseUrl, accessToken, orderId);
|
|
8534
|
+
};
|
|
8535
|
+
return { orders, cancelTwap: cancelTwap$1 };
|
|
8536
|
+
}
|
|
8537
|
+
|
|
8505
8538
|
const PearHyperliquidContext = createContext(undefined);
|
|
8506
8539
|
/**
|
|
8507
8540
|
* React Provider for PearHyperliquidClient
|
|
@@ -8800,4 +8833,4 @@ function mapCandleIntervalToTradingViewInterval(interval) {
|
|
|
8800
8833
|
}
|
|
8801
8834
|
}
|
|
8802
8835
|
|
|
8803
|
-
export { AccountSummaryCalculator, AuthStatus, ConflictDetector, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateWeightedRatio, cancelOrder, cancelTwapOrder, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, updateRiskParameters, useAccountSummary, useAddress, useAgentWallet, useAuth, useAutoSyncFills, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useOpenOrders, useOrders, usePearAgentWallet, usePearAuth, usePearHyperliquid, usePerformanceOverlays, usePosition, useTokenSelectionMetadata, useTradeHistories, useUserSelection, useWebData };
|
|
8836
|
+
export { AccountSummaryCalculator, AuthStatus, ConflictDetector, PearHyperliquidProvider, TokenMetadataExtractor, adjustOrder, adjustPosition, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closePosition, computeBasketCandles, createCandleLookups, createPosition, getCompleteTimestamps, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, updateRiskParameters, useAccountSummary, useAddress, useAgentWallet, useAuth, useAutoSyncFills, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidNativeWebSocket, useHyperliquidWebSocket, useOpenOrders, useOrders, usePearAgentWallet, usePearAuth, usePearHyperliquid, usePerformanceOverlays, usePosition, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWebData };
|
package/dist/types.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnecte
|
|
|
51
51
|
/**
|
|
52
52
|
* WebSocket channels
|
|
53
53
|
*/
|
|
54
|
-
export type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'webData2' | 'allMids' | 'activeAssetData';
|
|
54
|
+
export type WebSocketChannel = 'trade-histories' | 'open-positions' | 'open-orders' | 'account-summary' | 'twap-details' | 'webData2' | 'allMids' | 'activeAssetData';
|
|
55
55
|
/**
|
|
56
56
|
* WebSocket subscription message
|
|
57
57
|
*/
|
|
@@ -74,6 +74,46 @@ export interface WebSocketDataMessage<T = unknown> {
|
|
|
74
74
|
channel: WebSocketChannel;
|
|
75
75
|
data: T;
|
|
76
76
|
}
|
|
77
|
+
export interface ChunkFillDto {
|
|
78
|
+
fillId: string;
|
|
79
|
+
assetName: string;
|
|
80
|
+
price: number;
|
|
81
|
+
size: number;
|
|
82
|
+
executedAt: string;
|
|
83
|
+
}
|
|
84
|
+
export type TwapChunkStatus = 'PENDING' | 'SCHEDULED' | 'EXECUTING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
85
|
+
export interface TwapChunkStatusDto {
|
|
86
|
+
chunkId: string;
|
|
87
|
+
chunkIndex: number;
|
|
88
|
+
scheduledTime: string;
|
|
89
|
+
executedTime?: string;
|
|
90
|
+
status: TwapChunkStatus;
|
|
91
|
+
chunkSize: number;
|
|
92
|
+
fills: ChunkFillDto[];
|
|
93
|
+
errorMessage?: string;
|
|
94
|
+
}
|
|
95
|
+
export type TwapOrderOverallStatus = 'OPEN' | 'EXECUTING' | 'COMPLETED' | 'PARTIALLY_COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
96
|
+
export interface TwapMonitoringDto {
|
|
97
|
+
orderId: string;
|
|
98
|
+
positionId?: string;
|
|
99
|
+
address: string;
|
|
100
|
+
orderType: string;
|
|
101
|
+
status: TwapOrderOverallStatus;
|
|
102
|
+
totalUsdValue: number;
|
|
103
|
+
filledUsdValue: number;
|
|
104
|
+
remainingUsdValue: number;
|
|
105
|
+
twapDuration: string;
|
|
106
|
+
randomizeExecution: boolean;
|
|
107
|
+
reduceOnly: boolean;
|
|
108
|
+
chunks: TwapChunkStatusDto[];
|
|
109
|
+
estimatedCompletionTime?: string;
|
|
110
|
+
actualCompletionTime?: string;
|
|
111
|
+
remainingChunks: number;
|
|
112
|
+
longAssets: OrderAssetDto[];
|
|
113
|
+
shortAssets: OrderAssetDto[];
|
|
114
|
+
createdAt: string;
|
|
115
|
+
updatedAt: string;
|
|
116
|
+
}
|
|
77
117
|
/**
|
|
78
118
|
* Trade history asset data
|
|
79
119
|
*/
|