@pear-protocol/hyperliquid-sdk 0.0.77 → 0.0.79

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -114,7 +114,7 @@ const useMarketData = create((set) => ({
114
114
  * Convert a full/prefixed symbol (e.g., "xyz:XYZ100") to a display symbol (e.g., "XYZ100").
115
115
  */
116
116
  function toDisplaySymbol(symbol) {
117
- const parts = symbol.split(':');
117
+ const parts = symbol.split(":");
118
118
  return parts.length > 1 ? parts.slice(-1)[0] : symbol;
119
119
  }
120
120
  /**
@@ -125,6 +125,8 @@ function toDisplaySymbol(symbol) {
125
125
  * @param hip3Assets map of display -> all full market names (e.g., "TSLA" -> ["xyz:TSLA", "flx:TSLA"])
126
126
  */
127
127
  function toBackendSymbol(displaySymbol, hip3Assets) {
128
+ if (displaySymbol === "BTC")
129
+ return "BTC";
128
130
  const markets = hip3Assets.get(displaySymbol);
129
131
  // Return first market if available, otherwise return original symbol
130
132
  return markets && markets.length > 0 ? markets[0] : displaySymbol;
@@ -169,7 +171,7 @@ function getAvailableMarkets(displaySymbol, hip3Assets) {
169
171
  * @returns The prefix (e.g., "xyz") or undefined if no prefix
170
172
  */
171
173
  function getMarketPrefix(fullSymbol) {
172
- const parts = fullSymbol.split(':');
174
+ const parts = fullSymbol.split(":");
173
175
  return parts.length > 1 ? parts[0] : undefined;
174
176
  }
175
177
  /**
@@ -178,7 +180,7 @@ function getMarketPrefix(fullSymbol) {
178
180
  * @returns true if the symbol has a market prefix
179
181
  */
180
182
  function isHip3Market(symbol) {
181
- return symbol.includes(':');
183
+ return symbol.includes(":");
182
184
  }
183
185
 
184
186
  const useHyperliquidWebSocket = ({ wsUrl, address, enabled = true, }) => {
@@ -779,6 +781,7 @@ const useHyperliquidNativeWebSocket = ({ address, enabled = true, onUserFills, }
779
781
  const { setAllMids, setActiveAssetData, upsertActiveAssetData, setCandleData, deleteCandleSymbol, deleteActiveAssetData, addCandleData, setFinalAssetContexts, setFinalAtOICaps, setAggregatedClearingHouseState, setRawClearinghouseStates, } = useHyperliquidData();
780
782
  const { setSpotState } = useUserData();
781
783
  const { candleInterval } = useUserSelection$1();
784
+ const userSummary = useUserData((state) => state.accountSummary);
782
785
  const longTokens = useUserSelection$1((s) => s.longTokens);
783
786
  const shortTokens = useUserSelection$1((s) => s.shortTokens);
784
787
  const selectedTokenSymbols = useMemo(() => [...longTokens, ...shortTokens].map((t) => t.symbol), [longTokens, shortTokens]);
@@ -1153,9 +1156,8 @@ const useHyperliquidNativeWebSocket = ({ address, enabled = true, onUserFills, }
1153
1156
  setRawClearinghouseStates,
1154
1157
  setSpotState,
1155
1158
  ]);
1156
- // Subscribe to userFills only after allDexsClearinghouseState data is received
1157
1159
  useEffect(() => {
1158
- if (!isConnected || !subscribedAddress || !clearinghouseStateReceived)
1160
+ if (!isConnected || !subscribedAddress || !clearinghouseStateReceived || !userSummary)
1159
1161
  return;
1160
1162
  const subscribeUserFills = {
1161
1163
  method: 'subscribe',
@@ -1165,7 +1167,7 @@ const useHyperliquidNativeWebSocket = ({ address, enabled = true, onUserFills, }
1165
1167
  },
1166
1168
  };
1167
1169
  sendJsonMessage(subscribeUserFills);
1168
- }, [isConnected, subscribedAddress, clearinghouseStateReceived, sendJsonMessage]);
1170
+ }, [isConnected, subscribedAddress, clearinghouseStateReceived, userSummary, sendJsonMessage]);
1169
1171
  // Handle token subscriptions for activeAssetData
1170
1172
  useEffect(() => {
1171
1173
  if (!isConnected || !address)
@@ -8345,7 +8347,7 @@ function useHyperliquidUserFills(options) {
8345
8347
  if (!userState.accountSummary)
8346
8348
  return;
8347
8349
  const clearinghouseState = useHyperliquidData.getState().aggregatedClearingHouseState;
8348
- if (!(clearinghouseState === null || clearinghouseState === void 0 ? void 0 : clearinghouseState.assetPositions))
8350
+ if (!clearinghouseState)
8349
8351
  return;
8350
8352
  setIsSyncing(true);
8351
8353
  setError(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.77",
3
+ "version": "0.0.79",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",