@pear-protocol/hyperliquid-sdk 0.1.30 → 0.1.32
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.ts +7 -1
- package/dist/index.js +50 -1
- package/dist/types.d.ts +1 -0
- package/dist/utils/symbol-aliases.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -812,6 +812,7 @@ interface ActiveAssetData {
|
|
|
812
812
|
interface TokenMetadata {
|
|
813
813
|
assetName: string;
|
|
814
814
|
symbolName: string;
|
|
815
|
+
displayName: string;
|
|
815
816
|
marketName: string;
|
|
816
817
|
isAtOiCaps: boolean;
|
|
817
818
|
currentPrice: number;
|
|
@@ -1877,6 +1878,11 @@ declare function getOrderTrailingInfo(order: OpenLimitOrderDto): {
|
|
|
1877
1878
|
trailingActivationValue?: number;
|
|
1878
1879
|
} | undefined;
|
|
1879
1880
|
|
|
1881
|
+
declare const SYMBOL_DISPLAY_ALIASES: Record<string, string>;
|
|
1882
|
+
declare function toDisplaySymbol(symbol: string, market?: string): string;
|
|
1883
|
+
declare function toHlSymbol(displayOrSymbol: string, market?: string): string;
|
|
1884
|
+
declare function matchesSymbolOrAlias(symbol: string, term: string, market?: string): boolean;
|
|
1885
|
+
|
|
1880
1886
|
interface MarketDataState {
|
|
1881
1887
|
marketData: ActiveAssetsResponse | null;
|
|
1882
1888
|
setMarketData: (value: ActiveAssetsResponse | null) => void;
|
|
@@ -1884,5 +1890,5 @@ interface MarketDataState {
|
|
|
1884
1890
|
}
|
|
1885
1891
|
declare const useMarketData: zustand.UseBoundStore<zustand.StoreApi<MarketDataState>>;
|
|
1886
1892
|
|
|
1887
|
-
export { ClosePositionValidationError, 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, usePnlCalendar, usePnlHeatmap, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWatchlist, validateClosePositionRequest, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
|
|
1893
|
+
export { ClosePositionValidationError, ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, ReadyState, SYMBOL_DISPLAY_ALIASES, 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, matchesSymbolOrAlias, toDisplaySymbol, toHlSymbol, toggleWatchlist, updateLeverage, updateRiskParameters, useAccountSummary, useAgentWallet, useAllUserBalances, useAuth, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidUserFills, useMarket, useMarketData, useMarketDataHook, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePnlCalendar, usePnlHeatmap, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWatchlist, validateClosePositionRequest, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
|
|
1888
1894
|
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, CloseAllExecutionType, CloseAllPositionsRequestInput, CloseAllPositionsResponseDto, CloseAllPositionsResultDto, CloseExecutionType, ClosePositionExecutionType, ClosePositionRequestInput, ClosePositionResponseDto, CloseTriggerType, CollateralToken, CreateAgentWalletResponseDto, CreatePositionRequestInput, CreatePositionResponseDto, CrossAssetPriceTriggerParams, CrossMarginSummaryDto, CumFundingDto, EIP712AuthDetails, EIP712AuthDetailsRequest, ExecutionType, ExternalFillDto, ExternalLiquidationDto, ExtraAgent, GetAgentWalletResponseDto, GetEIP712MessageRequest, 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, PeriodSummary, PerpDex, PerpDexsResponse, PerpMetaAsset, PlatformAccountSummaryResponseDto, PnlCalendarAsset, PnlCalendarDay, PnlCalendarMonth, PnlCalendarOptions, PnlCalendarTimeframe, PnlCalendarTrade, PnlCalendarWeek, PnlHeatmapTimeframe, PnlHeatmapTrade, PortfolioBucketDto, PortfolioInterval, PortfolioIntervalsDto, PortfolioOverallDto, PortfolioResponseDto, PositionAdjustmentType, PositionAssetDetailDto, PredictionMarketOutcomeTriggerParams, PriceRatioTriggerParams, PriceTriggerParams, PrivyAuthDetails, RawAssetDto, RawPositionDto, RealtimeBar, RealtimeBarsCallback, RebalanceAssetPlan, RebalancePlan, 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, UsePnlCalendarResult, UsePnlHeatmapResult, UsePortfolioResult, UseSpotOrderResult, UseTokenSelectionMetadataReturn, UserAbstraction, UserProfile, UserSelectionState, WatchlistAssetDto, WatchlistItemDto, WebData3AssetCtx, WebData3PerpDexState, WebData3Response, WebData3UserState, WebSocketAckResponse, WebSocketChannel, WebSocketConnectionState, WebSocketDataMessage, WebSocketMessage, WebSocketSubscribeMessage, WsAllMidsData };
|
package/dist/index.js
CHANGED
|
@@ -334,6 +334,53 @@ const getMarketInfoFromSymbol = (symbol) => {
|
|
|
334
334
|
return { symbolName: symbol, marketName: '' };
|
|
335
335
|
};
|
|
336
336
|
|
|
337
|
+
// Display-only aliases for HL symbols. Keys are HL canonical full names —
|
|
338
|
+
// `<symbol>` for plain HL perps and `<market>:<symbol>` for HIP-3 markets.
|
|
339
|
+
// The value is the display symbol only (no prefix; the market tag is rendered
|
|
340
|
+
// separately by the UI). Aliases are scoped: `'xyz:TSLA': 'FOO'` will not
|
|
341
|
+
// affect a hypothetical `flx:TSLA`.
|
|
342
|
+
//
|
|
343
|
+
// Use these helpers only at display/URL boundaries — API/asset-index work
|
|
344
|
+
// must keep using the canonical symbol.
|
|
345
|
+
const SYMBOL_DISPLAY_ALIASES = {
|
|
346
|
+
CL: 'WTIOIL',
|
|
347
|
+
};
|
|
348
|
+
const REVERSE_ALIASES = Object.entries(SYMBOL_DISPLAY_ALIASES).reduce((acc, [hlFullName, displaySymbol]) => {
|
|
349
|
+
const market = hlFullName.includes(':')
|
|
350
|
+
? hlFullName.split(':')[0]
|
|
351
|
+
: '';
|
|
352
|
+
const reverseKey = market
|
|
353
|
+
? `${market}:${displaySymbol.toUpperCase()}`
|
|
354
|
+
: displaySymbol.toUpperCase();
|
|
355
|
+
acc[reverseKey] = hlFullName;
|
|
356
|
+
return acc;
|
|
357
|
+
}, {});
|
|
358
|
+
function aliasKey(symbol, market) {
|
|
359
|
+
return market ? `${market}:${symbol}` : symbol;
|
|
360
|
+
}
|
|
361
|
+
function toDisplaySymbol(symbol, market = '') {
|
|
362
|
+
var _a;
|
|
363
|
+
return (_a = SYMBOL_DISPLAY_ALIASES[aliasKey(symbol, market)]) !== null && _a !== void 0 ? _a : symbol;
|
|
364
|
+
}
|
|
365
|
+
// Reverse lookup. Returns the HL canonical symbol (without prefix); callers
|
|
366
|
+
// already know the market from context.
|
|
367
|
+
function toHlSymbol(displayOrSymbol, market = '') {
|
|
368
|
+
const key = aliasKey(displayOrSymbol.toUpperCase(), market);
|
|
369
|
+
const fullCanonical = REVERSE_ALIASES[key];
|
|
370
|
+
if (!fullCanonical)
|
|
371
|
+
return displayOrSymbol;
|
|
372
|
+
return fullCanonical.includes(':')
|
|
373
|
+
? fullCanonical.split(':').slice(1).join(':')
|
|
374
|
+
: fullCanonical;
|
|
375
|
+
}
|
|
376
|
+
function matchesSymbolOrAlias(symbol, term, market = '') {
|
|
377
|
+
if (!term)
|
|
378
|
+
return true;
|
|
379
|
+
const lowerTerm = term.toLowerCase();
|
|
380
|
+
return (symbol.toLowerCase().includes(lowerTerm) ||
|
|
381
|
+
toDisplaySymbol(symbol, market).toLowerCase().includes(lowerTerm));
|
|
382
|
+
}
|
|
383
|
+
|
|
337
384
|
/**
|
|
338
385
|
* Check if two symbols match, handling kPEPE/KPEPE variations
|
|
339
386
|
* Returns true if symbols match (case-insensitive for k-prefix tokens)
|
|
@@ -425,6 +472,7 @@ class TokenMetadataExtractor {
|
|
|
425
472
|
return {
|
|
426
473
|
assetName: foundAsset.name,
|
|
427
474
|
symbolName,
|
|
475
|
+
displayName: toDisplaySymbol(symbolName, marketName),
|
|
428
476
|
marketName,
|
|
429
477
|
isAtOiCaps: finalAtOICaps ? finalAtOICaps.includes(symbol) : false,
|
|
430
478
|
currentPrice,
|
|
@@ -456,6 +504,7 @@ const applyMetadataContext = (symbol, metadata, oiCapSet) => {
|
|
|
456
504
|
return {
|
|
457
505
|
...metadata,
|
|
458
506
|
symbolName,
|
|
507
|
+
displayName: toDisplaySymbol(symbolName, marketName),
|
|
459
508
|
marketName,
|
|
460
509
|
isAtOiCaps: isAtOiCaps(symbol, oiCapSet),
|
|
461
510
|
};
|
|
@@ -9430,4 +9479,4 @@ function getOrderTrailingInfo(order) {
|
|
|
9430
9479
|
return undefined;
|
|
9431
9480
|
}
|
|
9432
9481
|
|
|
9433
|
-
export { ClosePositionValidationError, ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, 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, usePnlCalendar, usePnlHeatmap, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWatchlist, validateClosePositionRequest, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
|
|
9482
|
+
export { ClosePositionValidationError, ConflictDetector, MAX_ASSETS_PER_LEG, MINIMUM_ASSET_USD_VALUE, MaxAssetsPerLegError, MinimumPositionSizeError, PearHyperliquidProvider, SYMBOL_DISPLAY_ALIASES, 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, matchesSymbolOrAlias, toDisplaySymbol, toHlSymbol, toggleWatchlist, updateLeverage, updateRiskParameters, useAccountSummary, useAgentWallet, useAllUserBalances, useAuth, useBasketCandles, useHistoricalPriceData, useHistoricalPriceDataStore, useHyperliquidUserFills, useMarket, useMarketData, useMarketDataHook, useNotifications, useOpenOrders, useOrders, usePearHyperliquid, usePerformanceOverlays, usePnlCalendar, usePnlHeatmap, usePortfolio, usePosition, useSpotOrder, useTokenSelectionMetadata, useTradeHistories, useTwap, useUserSelection, useWatchlist, validateClosePositionRequest, validateMaxAssetsPerLeg, validateMinimumAssetSize, validatePositionSize };
|
package/dist/types.d.ts
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const SYMBOL_DISPLAY_ALIASES: Record<string, string>;
|
|
2
|
+
export declare function toDisplaySymbol(symbol: string, market?: string): string;
|
|
3
|
+
export declare function toHlSymbol(displayOrSymbol: string, market?: string): string;
|
|
4
|
+
export declare function matchesSymbolOrAlias(symbol: string, term: string, market?: string): boolean;
|