@pear-protocol/hyperliquid-sdk 0.1.0 → 0.1.3
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/hyperliquid.d.ts +8 -1
- 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 +204 -142
- package/dist/index.js +454 -384
- package/dist/store/hyperliquidDataStore.d.ts +8 -2
- package/dist/store/tokenSelectionMetadataStore.d.ts +2 -3
- package/dist/types.d.ts +65 -2
- package/dist/utils/position-validator.d.ts +1 -1
- package/dist/utils/token-metadata-extractor.d.ts +35 -20
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiResponse, CandleInterval, CandleData, ExternalFillDto, AllPerpMetasResponse, ExtraAgent, TwapSliceFillResponseItem } from '../types';
|
|
1
|
+
import type { ApiResponse, CandleInterval, CandleData, ExternalFillDto, AllPerpMetasResponse, ExtraAgent, TwapSliceFillResponseItem, PerpDexsResponse } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Fetch historical candle data from HyperLiquid API
|
|
4
4
|
*/
|
|
@@ -23,3 +23,10 @@ export declare const fetchAllPerpMetas: () => Promise<ApiResponse<AllPerpMetasRe
|
|
|
23
23
|
* Payload: { "type": "extraAgents", "user": "0x..." }
|
|
24
24
|
*/
|
|
25
25
|
export declare const fetchExtraAgents: (user: string) => Promise<ApiResponse<ExtraAgent[]>>;
|
|
26
|
+
/**
|
|
27
|
+
* Fetch perp dexes from HyperLiquid API
|
|
28
|
+
* Endpoint: https://api.hyperliquid.xyz/info
|
|
29
|
+
* Payload: { "type": "perpDexs" }
|
|
30
|
+
* Returns array where index 0 is null (HYPERLIQUID), index 1+ are named DEXes
|
|
31
|
+
*/
|
|
32
|
+
export declare const fetchPerpDexs: () => Promise<ApiResponse<PerpDexsResponse>>;
|
|
@@ -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 };
|