@pear-protocol/hyperliquid-sdk 0.1.2 → 0.1.4
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 +1 -44
- package/dist/hooks/useAgentWallet.d.ts +1 -1
- package/dist/hooks/useAllUserBalances.d.ts +20 -6
- package/dist/hooks/useMarketData.d.ts +14 -8
- package/dist/hooks/usePosition.d.ts +2 -2
- package/dist/hooks/useTokenSelectionMetadata.d.ts +1 -1
- package/dist/hooks/useUserSelection.d.ts +16 -1
- package/dist/index.d.ts +203 -134
- package/dist/index.js +265 -214
- package/dist/store/tokenSelectionMetadataStore.d.ts +2 -3
- package/dist/types.d.ts +51 -3
- package/dist/utils/position-validator.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,48 +1,5 @@
|
|
|
1
|
-
import type { ApiResponse,
|
|
1
|
+
import type { ApiResponse, CreatePositionRequestInput, CreatePositionResponseDto, TpSlThresholdInput } from "../types";
|
|
2
2
|
import type { CancelTwapResponseDto } from "./orders";
|
|
3
|
-
export type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
|
|
4
|
-
export type TriggerType = "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO" | "BTC_DOM" | "CROSS_ASSET_PRICE" | "PREDICTION_MARKET_OUTCOME";
|
|
5
|
-
export type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
|
|
6
|
-
export interface PairAssetInput {
|
|
7
|
-
asset: string;
|
|
8
|
-
weight?: number;
|
|
9
|
-
}
|
|
10
|
-
export interface TpSlThresholdInput {
|
|
11
|
-
type: TpSlThresholdType;
|
|
12
|
-
value?: number;
|
|
13
|
-
isTrailing?: boolean;
|
|
14
|
-
trailingDeltaValue?: number;
|
|
15
|
-
trailingActivationValue?: number;
|
|
16
|
-
}
|
|
17
|
-
export interface LadderConfigInput {
|
|
18
|
-
ratioStart: number;
|
|
19
|
-
ratioEnd: number;
|
|
20
|
-
numberOfLevels: number;
|
|
21
|
-
}
|
|
22
|
-
export interface CreatePositionRequestInput {
|
|
23
|
-
slippage: number;
|
|
24
|
-
executionType: ExecutionType;
|
|
25
|
-
leverage: number;
|
|
26
|
-
usdValue: number;
|
|
27
|
-
longAssets?: PairAssetInput[];
|
|
28
|
-
shortAssets?: PairAssetInput[];
|
|
29
|
-
triggerValue?: string | number;
|
|
30
|
-
triggerType?: TriggerType;
|
|
31
|
-
direction?: "MORE_THAN" | "LESS_THAN";
|
|
32
|
-
assetName?: string;
|
|
33
|
-
marketCode?: string;
|
|
34
|
-
twapDuration?: number;
|
|
35
|
-
twapIntervalSeconds?: number;
|
|
36
|
-
randomizeExecution?: boolean;
|
|
37
|
-
referralCode?: string;
|
|
38
|
-
ladderConfig?: LadderConfigInput;
|
|
39
|
-
takeProfit?: TpSlThresholdInput | null;
|
|
40
|
-
stopLoss?: TpSlThresholdInput | null;
|
|
41
|
-
}
|
|
42
|
-
export interface CreatePositionResponseDto {
|
|
43
|
-
orderId: string;
|
|
44
|
-
fills?: ExternalFillDto[];
|
|
45
|
-
}
|
|
46
3
|
/**
|
|
47
4
|
* Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
|
|
48
5
|
* Authorization is derived from headers (Axios defaults or browser localStorage fallback)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function useAgentWallet(): {
|
|
2
2
|
readonly refreshAgentWalletStatus: () => Promise<void>;
|
|
3
|
-
readonly createAgentWallet: () => Promise<import("
|
|
3
|
+
readonly createAgentWallet: () => Promise<import("..").CreateAgentWalletResponseDto>;
|
|
4
4
|
readonly notifyAgentWalletApproved: () => Promise<void>;
|
|
5
5
|
};
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { AvailableToTrades, SpotBalances, CollateralToken } from '../types';
|
|
2
|
+
export interface MarginRequiredPerCollateral {
|
|
3
|
+
collateral: CollateralToken;
|
|
4
|
+
marginRequired: number;
|
|
5
|
+
availableBalance: number;
|
|
6
|
+
hasEnough: boolean;
|
|
7
|
+
shortfall: number;
|
|
8
|
+
}
|
|
9
|
+
export interface MarginRequiredResult {
|
|
10
|
+
totalMarginRequired: number;
|
|
11
|
+
orderValue: number;
|
|
12
|
+
perCollateral: MarginRequiredPerCollateral[];
|
|
13
|
+
hasEnoughTotal: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface AllUserBalancesResult {
|
|
16
|
+
spotBalances: SpotBalances;
|
|
17
|
+
availableToTrades: AvailableToTrades;
|
|
6
18
|
isLoading: boolean;
|
|
19
|
+
getMarginRequired: (assetsLeverage: Record<string, number>, size: number) => MarginRequiredResult;
|
|
20
|
+
getMaxSize: (assetsLeverage: Record<string, number>) => number;
|
|
7
21
|
}
|
|
8
|
-
export declare const useAllUserBalances: () =>
|
|
22
|
+
export declare const useAllUserBalances: () => AllUserBalancesResult;
|
|
9
23
|
export {};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { ActiveAssetGroupItem, ActiveAssetsResponse } from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
interface UseMarketDataHookOptions {
|
|
3
|
+
topGainersLimit?: number;
|
|
4
|
+
topLosersLimit?: number;
|
|
5
|
+
}
|
|
6
|
+
interface UseMarketDataHookResult {
|
|
7
|
+
marketData: ActiveAssetsResponse | null;
|
|
8
|
+
activeBaskets: ActiveAssetGroupItem[];
|
|
9
|
+
topGainers: ActiveAssetGroupItem[];
|
|
10
|
+
topLosers: ActiveAssetGroupItem[];
|
|
11
|
+
highlightedBaskets: ActiveAssetGroupItem[];
|
|
12
|
+
watchlistBaskets: ActiveAssetGroupItem[];
|
|
13
|
+
}
|
|
14
|
+
export declare const useMarketDataHook: (options?: UseMarketDataHookOptions) => UseMarketDataHookResult;
|
|
15
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { ApiResponse, OpenPositionDto } from '../types';
|
|
1
|
+
import { type UpdateRiskParametersRequestInput, type UpdateRiskParametersResponseDto, type ClosePositionRequestInput, type ClosePositionResponseDto, type CloseAllPositionsResponseDto, type AdjustPositionRequestInput, type AdjustPositionResponseDto, type AdjustAdvanceItemInput, type AdjustAdvanceResponseDto, type UpdateLeverageResponseDto } from '../clients/positions';
|
|
2
|
+
import type { ApiResponse, CreatePositionRequestInput, CreatePositionResponseDto, OpenPositionDto } from '../types';
|
|
3
3
|
export declare function usePosition(): {
|
|
4
4
|
readonly createPosition: (payload: CreatePositionRequestInput) => Promise<ApiResponse<CreatePositionResponseDto>>;
|
|
5
5
|
readonly updateRiskParameters: (positionId: string, payload: UpdateRiskParametersRequestInput) => Promise<ApiResponse<UpdateRiskParametersResponseDto>>;
|
|
@@ -12,7 +12,7 @@ export interface UseTokenSelectionMetadataReturn {
|
|
|
12
12
|
volume: string;
|
|
13
13
|
sumNetFunding: number;
|
|
14
14
|
maxLeverage: number;
|
|
15
|
-
minMargin: number;
|
|
16
15
|
leverageMatched: boolean;
|
|
16
|
+
minSize: Record<string, number>;
|
|
17
17
|
}
|
|
18
18
|
export declare const useTokenSelectionMetadata: () => UseTokenSelectionMetadataReturn;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
import type { UserSelectionState } from "../store/userSelection";
|
|
2
|
-
export declare const useUserSelection: () =>
|
|
2
|
+
export declare const useUserSelection: () => {
|
|
3
|
+
longTokens: import("..").TokenSelection[];
|
|
4
|
+
shortTokens: import("..").TokenSelection[];
|
|
5
|
+
candleInterval: import("..").CandleInterval;
|
|
6
|
+
openTokenSelector: boolean;
|
|
7
|
+
selectorConfig: import("..").TokenSelectorConfig | null;
|
|
8
|
+
openConflictModal: boolean;
|
|
9
|
+
setLongTokens: (tokens: import("..").TokenSelection[]) => void;
|
|
10
|
+
setShortTokens: (tokens: import("..").TokenSelection[]) => void;
|
|
11
|
+
setCandleInterval: (interval: import("..").CandleInterval) => void;
|
|
12
|
+
setTokenSelections: (longTokens: import("..").TokenSelection[], shortTokens: import("..").TokenSelection[]) => void;
|
|
13
|
+
setOpenTokenSelector: (open: boolean) => void;
|
|
14
|
+
setSelectorConfig: (config: import("..").TokenSelectorConfig | null) => void;
|
|
15
|
+
setOpenConflictModal: (open: boolean) => void;
|
|
16
|
+
addToken: (isLong: boolean) => boolean;
|
|
17
|
+
};
|
|
3
18
|
export type { UserSelectionState };
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,11 @@ interface ExternalFillDto {
|
|
|
60
60
|
feeToken?: string | null;
|
|
61
61
|
liquidation?: ExternalLiquidationDto | null;
|
|
62
62
|
}
|
|
63
|
+
interface SyncFillsRequestDto {
|
|
64
|
+
user: string;
|
|
65
|
+
fills: ExternalFillDto[];
|
|
66
|
+
assetPositions?: AssetPosition[];
|
|
67
|
+
}
|
|
63
68
|
interface SyncFillsResponseDto {
|
|
64
69
|
insertedFills: number;
|
|
65
70
|
skippedDuplicates: number;
|
|
@@ -76,6 +81,12 @@ interface TwapSliceFillResponseItem {
|
|
|
76
81
|
* WebSocket connection states
|
|
77
82
|
*/
|
|
78
83
|
type WebSocketConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
84
|
+
declare enum ReadyState {
|
|
85
|
+
CONNECTING = 0,
|
|
86
|
+
OPEN = 1,
|
|
87
|
+
CLOSING = 2,
|
|
88
|
+
CLOSED = 3
|
|
89
|
+
}
|
|
79
90
|
/**
|
|
80
91
|
* WebSocket channels
|
|
81
92
|
*/
|
|
@@ -327,7 +338,7 @@ type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE' | 'PRICE' | 'P
|
|
|
327
338
|
/**
|
|
328
339
|
* Trigger type for trigger orders
|
|
329
340
|
*/
|
|
330
|
-
type TriggerType
|
|
341
|
+
type TriggerType = 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'BTC_DOM' | 'CROSS_ASSET_PRICE' | 'PREDICTION_MARKET_OUTCOME';
|
|
331
342
|
type OrderDirection = 'MORE_THAN' | 'LESS_THAN';
|
|
332
343
|
/**
|
|
333
344
|
* Market order parameters
|
|
@@ -343,7 +354,7 @@ interface MarketOrderParameters {
|
|
|
343
354
|
interface TriggerOrderParameters {
|
|
344
355
|
leverage: number;
|
|
345
356
|
usdValue: number;
|
|
346
|
-
triggerType: TriggerType
|
|
357
|
+
triggerType: TriggerType;
|
|
347
358
|
triggerValue: number;
|
|
348
359
|
direction: OrderDirection;
|
|
349
360
|
reduceOnly?: boolean;
|
|
@@ -455,6 +466,15 @@ interface AccountSummaryResponseDto {
|
|
|
455
466
|
platformAccountSummary: PlatformAccountSummaryResponseDto | null;
|
|
456
467
|
agentWallet?: AgentWalletDto;
|
|
457
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* Address management state
|
|
471
|
+
*/
|
|
472
|
+
interface AddressState {
|
|
473
|
+
currentAddress: string | null;
|
|
474
|
+
isLoggedIn: boolean;
|
|
475
|
+
autoConnect: boolean;
|
|
476
|
+
previousAddresses: string[];
|
|
477
|
+
}
|
|
458
478
|
interface UseAuthOptions {
|
|
459
479
|
baseUrl: string;
|
|
460
480
|
clientId: string;
|
|
@@ -481,13 +501,50 @@ interface EIP712AuthDetails {
|
|
|
481
501
|
}
|
|
482
502
|
interface GetEIP712MessageResponse extends EIP712AuthDetails {
|
|
483
503
|
}
|
|
504
|
+
interface PrivyAuthDetails {
|
|
505
|
+
appId: string;
|
|
506
|
+
accessToken: string;
|
|
507
|
+
}
|
|
508
|
+
interface AuthenticateRequest {
|
|
509
|
+
method: 'eip712' | 'api_key' | 'privy_access_token';
|
|
510
|
+
address: string;
|
|
511
|
+
clientId: string;
|
|
512
|
+
details: {
|
|
513
|
+
signature: string;
|
|
514
|
+
timestamp: number;
|
|
515
|
+
} | {
|
|
516
|
+
apiKey: string;
|
|
517
|
+
} | PrivyAuthDetails;
|
|
518
|
+
}
|
|
519
|
+
interface AuthenticateResponse {
|
|
520
|
+
accessToken: string;
|
|
521
|
+
refreshToken: string;
|
|
522
|
+
tokenType: string;
|
|
523
|
+
expiresIn: number;
|
|
524
|
+
address: string;
|
|
525
|
+
clientId: string;
|
|
526
|
+
}
|
|
527
|
+
interface RefreshTokenRequest {
|
|
528
|
+
refreshToken: string;
|
|
529
|
+
}
|
|
484
530
|
interface RefreshTokenResponse {
|
|
485
531
|
accessToken: string;
|
|
486
532
|
refreshToken: string;
|
|
487
533
|
tokenType: string;
|
|
488
534
|
expiresIn: number;
|
|
489
535
|
}
|
|
536
|
+
interface LogoutRequest {
|
|
537
|
+
refreshToken: string;
|
|
538
|
+
}
|
|
539
|
+
interface LogoutResponse {
|
|
540
|
+
message: string;
|
|
541
|
+
}
|
|
490
542
|
type AgentWalletStatus = 'ACTIVE' | 'EXPIRED' | 'NOT_FOUND';
|
|
543
|
+
interface GetAgentWalletResponseDto {
|
|
544
|
+
agentWalletAddress?: string;
|
|
545
|
+
agentName: string;
|
|
546
|
+
status: AgentWalletStatus;
|
|
547
|
+
}
|
|
491
548
|
interface CreateAgentWalletResponseDto {
|
|
492
549
|
agentWalletAddress: string;
|
|
493
550
|
message: string;
|
|
@@ -600,9 +657,9 @@ interface AssetCtx {
|
|
|
600
657
|
* 0 = USDC
|
|
601
658
|
* 360 = USDH
|
|
602
659
|
* 235 = USDE
|
|
603
|
-
* 268 =
|
|
660
|
+
* 268 = USDT0
|
|
604
661
|
*/
|
|
605
|
-
type CollateralToken = 'USDC' | 'USDH' | 'USDE' | '
|
|
662
|
+
type CollateralToken = 'USDC' | 'USDH' | 'USDE' | 'USDT0';
|
|
606
663
|
/**
|
|
607
664
|
* Universe asset metadata
|
|
608
665
|
*/
|
|
@@ -614,6 +671,24 @@ interface UniverseAsset {
|
|
|
614
671
|
isDelisted?: boolean;
|
|
615
672
|
collateralToken: CollateralToken;
|
|
616
673
|
}
|
|
674
|
+
interface PerpMetaAsset extends UniverseAsset {
|
|
675
|
+
marginTableId: number;
|
|
676
|
+
}
|
|
677
|
+
interface MarginTier {
|
|
678
|
+
lowerBound: string;
|
|
679
|
+
maxLeverage: number;
|
|
680
|
+
}
|
|
681
|
+
interface MarginTableDef {
|
|
682
|
+
description: string;
|
|
683
|
+
marginTiers: MarginTier[];
|
|
684
|
+
}
|
|
685
|
+
type MarginTablesEntry = [number, MarginTableDef];
|
|
686
|
+
interface AllPerpMetasItem {
|
|
687
|
+
universe: PerpMetaAsset[];
|
|
688
|
+
marginTables: MarginTablesEntry[];
|
|
689
|
+
collateralToken: number;
|
|
690
|
+
}
|
|
691
|
+
type AllPerpMetasResponse = AllPerpMetasItem[];
|
|
617
692
|
interface ClearinghouseState {
|
|
618
693
|
assetPositions: AssetPosition[];
|
|
619
694
|
crossMaintenanceMarginUsed: string;
|
|
@@ -759,6 +834,7 @@ interface AssetMarketData {
|
|
|
759
834
|
interface PairAssetDto {
|
|
760
835
|
asset: string;
|
|
761
836
|
weight: number;
|
|
837
|
+
metadata?: TokenMetadata | null;
|
|
762
838
|
}
|
|
763
839
|
interface ActiveAssetGroupItem {
|
|
764
840
|
longAssets: PairAssetDto[];
|
|
@@ -772,7 +848,6 @@ interface ActiveAssetGroupItem {
|
|
|
772
848
|
weightedRatio?: string;
|
|
773
849
|
weightedPrevRatio?: string;
|
|
774
850
|
weightedChange24h?: string;
|
|
775
|
-
collateralType: 'USDC' | 'USDH' | 'MIXED';
|
|
776
851
|
}
|
|
777
852
|
interface ActiveAssetsResponse {
|
|
778
853
|
active: ActiveAssetGroupItem[];
|
|
@@ -781,6 +856,12 @@ interface ActiveAssetsResponse {
|
|
|
781
856
|
highlighted: ActiveAssetGroupItem[];
|
|
782
857
|
watchlist: ActiveAssetGroupItem[];
|
|
783
858
|
}
|
|
859
|
+
interface ActiveAssetsAllResponse {
|
|
860
|
+
active: ActiveAssetGroupItem[];
|
|
861
|
+
all: ActiveAssetGroupItem[];
|
|
862
|
+
highlighted: ActiveAssetGroupItem[];
|
|
863
|
+
watchlist: ActiveAssetGroupItem[];
|
|
864
|
+
}
|
|
784
865
|
/**
|
|
785
866
|
* Candle interval options
|
|
786
867
|
*/
|
|
@@ -829,6 +910,71 @@ interface SpotState {
|
|
|
829
910
|
user: string;
|
|
830
911
|
balances: SpotBalance[];
|
|
831
912
|
}
|
|
913
|
+
interface TokenEntry {
|
|
914
|
+
symbol: string;
|
|
915
|
+
data: AssetMarketData;
|
|
916
|
+
}
|
|
917
|
+
interface PerpDex {
|
|
918
|
+
name: string;
|
|
919
|
+
fullName: string;
|
|
920
|
+
deployer: string;
|
|
921
|
+
oracleUpdater: string | null;
|
|
922
|
+
feeRecipient: string | null;
|
|
923
|
+
deployerFeeScale: string;
|
|
924
|
+
assetToStreamingOiCap: [string, string][];
|
|
925
|
+
assetToFundingMultiplier: [string, string][];
|
|
926
|
+
subDeployers: [string, string[]][];
|
|
927
|
+
lastDeployerFeeScaleChangeTime: string;
|
|
928
|
+
}
|
|
929
|
+
type PerpDexsResponse = (PerpDex | null)[];
|
|
930
|
+
interface SpotBalances {
|
|
931
|
+
[coin: string]: number;
|
|
932
|
+
}
|
|
933
|
+
interface AvailableToTrades {
|
|
934
|
+
[collateralCoin: string]: number;
|
|
935
|
+
}
|
|
936
|
+
type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
|
|
937
|
+
type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
|
|
938
|
+
interface PairAssetInput {
|
|
939
|
+
asset: string;
|
|
940
|
+
weight?: number;
|
|
941
|
+
}
|
|
942
|
+
interface TpSlThresholdInput {
|
|
943
|
+
type: TpSlThresholdType;
|
|
944
|
+
value?: number;
|
|
945
|
+
isTrailing?: boolean;
|
|
946
|
+
trailingDeltaValue?: number;
|
|
947
|
+
trailingActivationValue?: number;
|
|
948
|
+
}
|
|
949
|
+
interface LadderConfigInput {
|
|
950
|
+
ratioStart: number;
|
|
951
|
+
ratioEnd: number;
|
|
952
|
+
numberOfLevels: number;
|
|
953
|
+
}
|
|
954
|
+
interface CreatePositionRequestInput {
|
|
955
|
+
slippage: number;
|
|
956
|
+
executionType: ExecutionType;
|
|
957
|
+
leverage: number;
|
|
958
|
+
usdValue: number;
|
|
959
|
+
longAssets?: PairAssetInput[];
|
|
960
|
+
shortAssets?: PairAssetInput[];
|
|
961
|
+
triggerValue?: string | number;
|
|
962
|
+
triggerType?: TriggerType;
|
|
963
|
+
direction?: "MORE_THAN" | "LESS_THAN";
|
|
964
|
+
assetName?: string;
|
|
965
|
+
marketCode?: string;
|
|
966
|
+
twapDuration?: number;
|
|
967
|
+
twapIntervalSeconds?: number;
|
|
968
|
+
randomizeExecution?: boolean;
|
|
969
|
+
referralCode?: string;
|
|
970
|
+
ladderConfig?: LadderConfigInput;
|
|
971
|
+
takeProfit?: TpSlThresholdInput | null;
|
|
972
|
+
stopLoss?: TpSlThresholdInput | null;
|
|
973
|
+
}
|
|
974
|
+
interface CreatePositionResponseDto {
|
|
975
|
+
orderId: string;
|
|
976
|
+
fills?: ExternalFillDto[];
|
|
977
|
+
}
|
|
832
978
|
|
|
833
979
|
declare const useAccountSummary: () => {
|
|
834
980
|
data: AccountSummaryResponseDto | null;
|
|
@@ -869,7 +1015,22 @@ interface UserSelectionState {
|
|
|
869
1015
|
resetToDefaults: () => void;
|
|
870
1016
|
}
|
|
871
1017
|
|
|
872
|
-
declare const useUserSelection: () =>
|
|
1018
|
+
declare const useUserSelection: () => {
|
|
1019
|
+
longTokens: TokenSelection[];
|
|
1020
|
+
shortTokens: TokenSelection[];
|
|
1021
|
+
candleInterval: CandleInterval;
|
|
1022
|
+
openTokenSelector: boolean;
|
|
1023
|
+
selectorConfig: TokenSelectorConfig | null;
|
|
1024
|
+
openConflictModal: boolean;
|
|
1025
|
+
setLongTokens: (tokens: TokenSelection[]) => void;
|
|
1026
|
+
setShortTokens: (tokens: TokenSelection[]) => void;
|
|
1027
|
+
setCandleInterval: (interval: CandleInterval) => void;
|
|
1028
|
+
setTokenSelections: (longTokens: TokenSelection[], shortTokens: TokenSelection[]) => void;
|
|
1029
|
+
setOpenTokenSelector: (open: boolean) => void;
|
|
1030
|
+
setSelectorConfig: (config: TokenSelectorConfig | null) => void;
|
|
1031
|
+
setOpenConflictModal: (open: boolean) => void;
|
|
1032
|
+
addToken: (isLong: boolean) => boolean;
|
|
1033
|
+
};
|
|
873
1034
|
|
|
874
1035
|
/**
|
|
875
1036
|
* Hook to access webData
|
|
@@ -892,8 +1053,8 @@ interface UseTokenSelectionMetadataReturn {
|
|
|
892
1053
|
volume: string;
|
|
893
1054
|
sumNetFunding: number;
|
|
894
1055
|
maxLeverage: number;
|
|
895
|
-
minMargin: number;
|
|
896
1056
|
leverageMatched: boolean;
|
|
1057
|
+
minSize: Record<string, number>;
|
|
897
1058
|
}
|
|
898
1059
|
declare const useTokenSelectionMetadata: () => UseTokenSelectionMetadataReturn;
|
|
899
1060
|
|
|
@@ -1042,49 +1203,6 @@ interface SpotOrderResponseDto {
|
|
|
1042
1203
|
*/
|
|
1043
1204
|
declare function executeSpotOrder(baseUrl: string, payload: SpotOrderRequestInput): Promise<ApiResponse<SpotOrderResponseDto>>;
|
|
1044
1205
|
|
|
1045
|
-
type ExecutionType = "MARKET" | "TRIGGER" | "TWAP" | "LADDER" | "TP" | "SL" | "SPOT_MARKET" | "SPOT_LIMIT" | "SPOT_TWAP";
|
|
1046
|
-
type TriggerType = "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO" | "BTC_DOM" | "CROSS_ASSET_PRICE" | "PREDICTION_MARKET_OUTCOME";
|
|
1047
|
-
type TpSlThresholdType = "PERCENTAGE" | "DOLLAR" | "POSITION_VALUE" | "PRICE" | "PRICE_RATIO" | "WEIGHTED_RATIO";
|
|
1048
|
-
interface PairAssetInput {
|
|
1049
|
-
asset: string;
|
|
1050
|
-
weight?: number;
|
|
1051
|
-
}
|
|
1052
|
-
interface TpSlThresholdInput {
|
|
1053
|
-
type: TpSlThresholdType;
|
|
1054
|
-
value?: number;
|
|
1055
|
-
isTrailing?: boolean;
|
|
1056
|
-
trailingDeltaValue?: number;
|
|
1057
|
-
trailingActivationValue?: number;
|
|
1058
|
-
}
|
|
1059
|
-
interface LadderConfigInput {
|
|
1060
|
-
ratioStart: number;
|
|
1061
|
-
ratioEnd: number;
|
|
1062
|
-
numberOfLevels: number;
|
|
1063
|
-
}
|
|
1064
|
-
interface CreatePositionRequestInput {
|
|
1065
|
-
slippage: number;
|
|
1066
|
-
executionType: ExecutionType;
|
|
1067
|
-
leverage: number;
|
|
1068
|
-
usdValue: number;
|
|
1069
|
-
longAssets?: PairAssetInput[];
|
|
1070
|
-
shortAssets?: PairAssetInput[];
|
|
1071
|
-
triggerValue?: string | number;
|
|
1072
|
-
triggerType?: TriggerType;
|
|
1073
|
-
direction?: "MORE_THAN" | "LESS_THAN";
|
|
1074
|
-
assetName?: string;
|
|
1075
|
-
marketCode?: string;
|
|
1076
|
-
twapDuration?: number;
|
|
1077
|
-
twapIntervalSeconds?: number;
|
|
1078
|
-
randomizeExecution?: boolean;
|
|
1079
|
-
referralCode?: string;
|
|
1080
|
-
ladderConfig?: LadderConfigInput;
|
|
1081
|
-
takeProfit?: TpSlThresholdInput | null;
|
|
1082
|
-
stopLoss?: TpSlThresholdInput | null;
|
|
1083
|
-
}
|
|
1084
|
-
interface CreatePositionResponseDto {
|
|
1085
|
-
orderId: string;
|
|
1086
|
-
fills?: ExternalFillDto[];
|
|
1087
|
-
}
|
|
1088
1206
|
/**
|
|
1089
1207
|
* Create a position (MARKET/LIMIT/TWAP) using Pear Hyperliquid service
|
|
1090
1208
|
* Authorization is derived from headers (Axios defaults or browser localStorage fallback)
|
|
@@ -1221,14 +1339,19 @@ interface UseNotificationsResult {
|
|
|
1221
1339
|
*/
|
|
1222
1340
|
declare function useNotifications(): UseNotificationsResult;
|
|
1223
1341
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1342
|
+
interface UseMarketDataHookOptions {
|
|
1343
|
+
topGainersLimit?: number;
|
|
1344
|
+
topLosersLimit?: number;
|
|
1345
|
+
}
|
|
1346
|
+
interface UseMarketDataHookResult {
|
|
1347
|
+
marketData: ActiveAssetsResponse | null;
|
|
1348
|
+
activeBaskets: ActiveAssetGroupItem[];
|
|
1349
|
+
topGainers: ActiveAssetGroupItem[];
|
|
1350
|
+
topLosers: ActiveAssetGroupItem[];
|
|
1351
|
+
highlightedBaskets: ActiveAssetGroupItem[];
|
|
1352
|
+
watchlistBaskets: ActiveAssetGroupItem[];
|
|
1353
|
+
}
|
|
1354
|
+
declare const useMarketDataHook: (options?: UseMarketDataHookOptions) => UseMarketDataHookResult;
|
|
1232
1355
|
|
|
1233
1356
|
declare function useWatchlist(): {
|
|
1234
1357
|
readonly watchlists: ActiveAssetGroupItem[] | null;
|
|
@@ -1300,14 +1423,27 @@ declare function useAuth(): {
|
|
|
1300
1423
|
readonly logout: () => Promise<void>;
|
|
1301
1424
|
};
|
|
1302
1425
|
|
|
1303
|
-
interface
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1426
|
+
interface MarginRequiredPerCollateral {
|
|
1427
|
+
collateral: CollateralToken;
|
|
1428
|
+
marginRequired: number;
|
|
1429
|
+
availableBalance: number;
|
|
1430
|
+
hasEnough: boolean;
|
|
1431
|
+
shortfall: number;
|
|
1432
|
+
}
|
|
1433
|
+
interface MarginRequiredResult {
|
|
1434
|
+
totalMarginRequired: number;
|
|
1435
|
+
orderValue: number;
|
|
1436
|
+
perCollateral: MarginRequiredPerCollateral[];
|
|
1437
|
+
hasEnoughTotal: boolean;
|
|
1438
|
+
}
|
|
1439
|
+
interface AllUserBalancesResult {
|
|
1440
|
+
spotBalances: SpotBalances;
|
|
1441
|
+
availableToTrades: AvailableToTrades;
|
|
1308
1442
|
isLoading: boolean;
|
|
1443
|
+
getMarginRequired: (assetsLeverage: Record<string, number>, size: number) => MarginRequiredResult;
|
|
1444
|
+
getMaxSize: (assetsLeverage: Record<string, number>) => number;
|
|
1309
1445
|
}
|
|
1310
|
-
declare const useAllUserBalances: () =>
|
|
1446
|
+
declare const useAllUserBalances: () => AllUserBalancesResult;
|
|
1311
1447
|
|
|
1312
1448
|
interface UseHyperliquidUserFillsOptions {
|
|
1313
1449
|
baseUrl: string;
|
|
@@ -1326,28 +1462,6 @@ interface UseHyperliquidUserFillsState {
|
|
|
1326
1462
|
*/
|
|
1327
1463
|
declare function useHyperliquidUserFills(options: UseHyperliquidUserFillsOptions): UseHyperliquidUserFillsState;
|
|
1328
1464
|
|
|
1329
|
-
interface UseHyperliquidWebSocketProps {
|
|
1330
|
-
wsUrl: string;
|
|
1331
|
-
address: string | null;
|
|
1332
|
-
enabled?: boolean;
|
|
1333
|
-
}
|
|
1334
|
-
declare const useHyperliquidWebSocket: ({ wsUrl, address, enabled, }: UseHyperliquidWebSocketProps) => {
|
|
1335
|
-
isConnected: boolean;
|
|
1336
|
-
lastError: string | null;
|
|
1337
|
-
};
|
|
1338
|
-
|
|
1339
|
-
interface UseHyperliquidNativeWebSocketProps {
|
|
1340
|
-
address: string | null;
|
|
1341
|
-
tokens?: string[];
|
|
1342
|
-
enabled?: boolean;
|
|
1343
|
-
onUserFills?: () => void | Promise<void>;
|
|
1344
|
-
}
|
|
1345
|
-
interface UseHyperliquidNativeWebSocketReturn {
|
|
1346
|
-
isConnected: boolean;
|
|
1347
|
-
lastError: string | null;
|
|
1348
|
-
}
|
|
1349
|
-
declare const useHyperliquidNativeWebSocket: ({ address, enabled, onUserFills, }: UseHyperliquidNativeWebSocketProps) => UseHyperliquidNativeWebSocketReturn;
|
|
1350
|
-
|
|
1351
1465
|
/**
|
|
1352
1466
|
* Mark notifications as read up to a given timestamp (ms)
|
|
1353
1467
|
*/
|
|
@@ -1450,23 +1564,6 @@ interface GetKalshiMarketsParams {
|
|
|
1450
1564
|
}
|
|
1451
1565
|
declare function getKalshiMarkets(params?: GetKalshiMarketsParams): Promise<ApiResponse<KalshiMarketsResponse>>;
|
|
1452
1566
|
|
|
1453
|
-
/**
|
|
1454
|
-
* Account summary calculation utility class
|
|
1455
|
-
*/
|
|
1456
|
-
declare class AccountSummaryCalculator {
|
|
1457
|
-
private clearinghouseState;
|
|
1458
|
-
constructor(clearinghouseState: ClearinghouseState | null);
|
|
1459
|
-
/**
|
|
1460
|
-
* Calculate account summary from real-time clearinghouse state and platform orders
|
|
1461
|
-
*/
|
|
1462
|
-
calculateAccountSummary(platformAccountSummary: PlatformAccountSummaryResponseDto | null, registeredAgentWallets: ExtraAgent[]): AccountSummaryResponseDto | null;
|
|
1463
|
-
getClearinghouseState(): ClearinghouseState | null;
|
|
1464
|
-
/**
|
|
1465
|
-
* Check if real-time data is available
|
|
1466
|
-
*/
|
|
1467
|
-
hasRealTimeData(): boolean;
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
1567
|
/**
|
|
1471
1568
|
* Detects conflicts between selected tokens and existing positions
|
|
1472
1569
|
*/
|
|
@@ -1481,34 +1578,6 @@ declare class ConflictDetector {
|
|
|
1481
1578
|
static detectConflicts(longTokens: TokenSelection[], shortTokens: TokenSelection[], openPositions: RawPositionDto[] | null): TokenConflict[];
|
|
1482
1579
|
}
|
|
1483
1580
|
|
|
1484
|
-
/**
|
|
1485
|
-
* Extracts token metadata from aggregated WebData3 contexts and AllMids data
|
|
1486
|
-
*/
|
|
1487
|
-
declare class TokenMetadataExtractor {
|
|
1488
|
-
/**
|
|
1489
|
-
* Checks if token data is available in aggregated universe assets
|
|
1490
|
-
* @param symbol - Token symbol
|
|
1491
|
-
* @param perpMetaAssets - Aggregated universe assets
|
|
1492
|
-
* @returns boolean indicating if token exists in universe
|
|
1493
|
-
*/
|
|
1494
|
-
static isTokenAvailable(symbol: string, perpMetaAssets: UniverseAsset[] | null): boolean;
|
|
1495
|
-
/**
|
|
1496
|
-
* Extracts token metadata using DEX-aware lookup (correctly matches perpMetas to assetContexts)
|
|
1497
|
-
* @param symbol - Token symbol (e.g., "BTC", "TSLA")
|
|
1498
|
-
* @param perpMetasByDex - Map of DEX name to UniverseAsset[]
|
|
1499
|
-
* @param assetContextsByDex - Map of DEX name to WebData3AssetCtx[]
|
|
1500
|
-
* @param allMids - AllMids data containing current prices
|
|
1501
|
-
* @param activeAssetData - Optional active asset data containing leverage information
|
|
1502
|
-
* @param finalAtOICaps - Optional array of symbols at OI caps
|
|
1503
|
-
* @returns TokenMetadata or null if token not found
|
|
1504
|
-
*/
|
|
1505
|
-
static extractTokenMetadataByDex(symbol: string, perpMetasByDex: Map<string, UniverseAsset[]>, assetContextsByDex: Map<string, WebData3AssetCtx[]>, allMids: WsAllMidsData, activeAssetData?: Record<string, ActiveAssetData> | null, finalAtOICaps?: string[] | null): TokenMetadata | null;
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
type TokenMetadataBySymbol = Record<string, TokenMetadata | null>;
|
|
1509
|
-
declare const selectTokenMetadataBySymbols: (tokenMetadata: TokenMetadataBySymbol, symbols: string[]) => TokenMetadataBySymbol;
|
|
1510
|
-
declare const getAssetByName: (tokenMetadata: TokenMetadataBySymbol, symbol: string) => TokenMetadata | null;
|
|
1511
|
-
|
|
1512
1581
|
/**
|
|
1513
1582
|
* Create efficient timestamp-based lookup maps for candle data
|
|
1514
1583
|
*/
|
|
@@ -1626,7 +1695,7 @@ declare function getOrderTpSlTriggerType(order: OpenLimitOrderDto): TpSlTriggerT
|
|
|
1626
1695
|
/**
|
|
1627
1696
|
* Get trigger type from order parameters (for Trigger orders)
|
|
1628
1697
|
*/
|
|
1629
|
-
declare function getOrderTriggerType(order: OpenLimitOrderDto): TriggerType
|
|
1698
|
+
declare function getOrderTriggerType(order: OpenLimitOrderDto): TriggerType | undefined;
|
|
1630
1699
|
/**
|
|
1631
1700
|
* Get order direction from order parameters (for Trigger orders)
|
|
1632
1701
|
*/
|
|
@@ -1667,5 +1736,5 @@ interface MarketDataState {
|
|
|
1667
1736
|
}
|
|
1668
1737
|
declare const useMarketData: zustand.UseBoundStore<zustand.StoreApi<MarketDataState>>;
|
|
1669
1738
|
|
|
1670
|
-
export {
|
|
1671
|
-
export type { AccountSummaryResponseDto, ActiveAssetGroupItem, ActiveAssetsResponse, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, BalanceSummaryDto, BaseTriggerOrderNotificationParams, BtcDomTriggerParams, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto,
|
|
1739
|
+
export { ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, ReadyState, adjustAdvancePosition, adjustOrder, adjustPosition, calculateMinimumPositionValue, calculateWeightedRatio, cancelOrder, cancelTwap, cancelTwapOrder, closeAllPositions, closePosition, computeBasketCandles, createCandleLookups, createPosition, executeSpotOrder, getCompleteTimestamps, getKalshiMarkets, getOrderDirection, getOrderLadderConfig, getOrderLeverage, getOrderReduceOnly, getOrderTpSlTriggerType, getOrderTrailingInfo, getOrderTriggerType, getOrderTriggerValue, getOrderTwapDuration, getOrderUsdValue, getPortfolio, isBtcDomOrder, mapCandleIntervalToTradingViewInterval, mapTradingViewIntervalToCandleInterval, markNotificationReadById, markNotificationsRead, toggleWatchlist, updateLeverage, updateRiskParameters, useAccountSummary, useAgentWallet, useAllUserBalances, useAuth, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidUserFills, useMarket, useMarketData, useMarketDataHook, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWatchlist, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
|
|
1740
|
+
export type { AccountSummaryResponseDto, ActiveAssetData, ActiveAssetGroupItem, ActiveAssetsAllResponse, ActiveAssetsResponse, AddressState, AdjustAdvanceAssetInput, AdjustAdvanceItemInput, AdjustAdvanceResponseDto, AdjustExecutionType, AdjustOrderRequestInput, AdjustOrderResponseDto, AdjustPositionRequestInput, AdjustPositionResponseDto, AgentWalletDto, AgentWalletState, AgentWalletStatus, AllDexsAssetCtxsData, AllDexsClearinghouseStateData, AllPerpMetasItem, AllPerpMetasResponse, ApiErrorResponse, ApiResponse, AssetCtx, AssetInformationDetail, AssetMarketData, AssetPosition, AuthenticateRequest, AuthenticateResponse, AvailableToTrades, BalanceSummaryDto, BaseTriggerOrderNotificationParams, BtcDomTriggerParams, CancelOrderResponseDto, CancelTwapResponseDto, CandleChartData, CandleData, CandleInterval, CandleSnapshotRequest, ChunkFillDto, ClearinghouseState, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CollateralToken, CreateAgentWalletResponseDto, CreatePositionRequestInput, CreatePositionResponseDto, CrossAssetPriceTriggerParams, CrossMarginSummaryDto, CumFundingDto, EIP712AuthDetails, ExecutionType, ExternalFillDto, ExternalLiquidationDto, ExtraAgent, GetAgentWalletResponseDto, GetEIP712MessageResponse, GetKalshiMarketsParams, HLChannel, HLChannelDataMap, HLWebSocketResponse, HistoricalRange, KalshiMarket, KalshiMarketsResponse, KalshiMveLeg, KalshiPriceRange, LadderConfigInput, LadderOrderParameters, LeverageInfo, LogoutRequest, LogoutResponse, MarginRequiredPerCollateral, MarginRequiredResult, MarginSummaryDto, MarginTableDef, MarginTablesEntry, MarginTier, MarketOrderParameters, NotificationCategory, NotificationDto, OpenLimitOrderDto, OpenPositionDto, OrderAssetDto, OrderDirection, OrderParameters, OrderStatus, OrderType, PairAssetDto, PairAssetInput, PerformanceOverlay, PerpDex, PerpDexsResponse, PerpMetaAsset, PlatformAccountSummaryResponseDto, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PredictionMarketOutcomeTriggerParams, PriceRatioTriggerParams, PriceTriggerParams, PrivyAuthDetails, RawAssetDto, RawPositionDto, RealtimeBar, RealtimeBarsCallback, RefreshTokenRequest, RefreshTokenResponse, SpotBalance, SpotBalances, SpotOrderFilledStatus, SpotOrderHyperliquidData, SpotOrderHyperliquidResult, SpotOrderRequestInput, SpotOrderResponseDto, SpotState, SyncFillsRequestDto, SyncFillsResponseDto, ToggleWatchlistResponseDto, TokenConflict, TokenEntry, TokenHistoricalPriceData, TokenMetadata, TokenSelection, TokenSelectorConfig, TpSlOrderParameters, TpSlThreshold, TpSlThresholdInput, TpSlThresholdType, TpSlTriggerType, TradeHistoryAssetDataDto, TradeHistoryDataDto, TriggerOrderNotificationAsset, TriggerOrderNotificationParams, TriggerOrderNotificationType, TriggerOrderParameters, TriggerType, TwapChunkStatus, TwapChunkStatusDto, TwapMonitoringDto, TwapOrderOverallStatus, TwapOrderParameters, TwapSliceFillResponseItem, UniverseAsset, UpdateLeverageRequestInput, UpdateLeverageResponseDto, UpdateRiskParametersRequestInput, UpdateRiskParametersResponseDto, UseAuthOptions, UseBasketCandlesReturn, UseHistoricalPriceDataReturn, UseHyperliquidUserFillsOptions, UseHyperliquidUserFillsState, UseNotificationsResult, UsePerformanceOverlaysReturn, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserProfile, UserSelectionState, WatchlistAssetDto, WatchlistItemDto, WebData3AssetCtx, WebData3PerpDexState, WebData3Response, WebData3UserState, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|