@pear-protocol/hyperliquid-sdk 0.1.32 → 0.1.33

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 +21 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -334,21 +334,13 @@ 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.
337
+ // Keys are HL canonical full names (`<market>:<symbol>` or bare `<symbol>`).
338
+ // Values are the display symbol only — the market tag is rendered separately.
345
339
  const SYMBOL_DISPLAY_ALIASES = {
346
- CL: 'WTIOIL',
340
+ 'xyz:CL': 'WTIOIL',
347
341
  };
348
342
  const REVERSE_ALIASES = Object.entries(SYMBOL_DISPLAY_ALIASES).reduce((acc, [hlFullName, displaySymbol]) => {
349
- const market = hlFullName.includes(':')
350
- ? hlFullName.split(':')[0]
351
- : '';
343
+ const market = hlFullName.includes(':') ? hlFullName.split(':')[0] : '';
352
344
  const reverseKey = market
353
345
  ? `${market}:${displaySymbol.toUpperCase()}`
354
346
  : displaySymbol.toUpperCase();
@@ -362,16 +354,24 @@ function toDisplaySymbol(symbol, market = '') {
362
354
  var _a;
363
355
  return (_a = SYMBOL_DISPLAY_ALIASES[aliasKey(symbol, market)]) !== null && _a !== void 0 ? _a : symbol;
364
356
  }
365
- // Reverse lookup. Returns the HL canonical symbol (without prefix); callers
366
- // already know the market from context.
357
+ // With a market hint, returns the bare HL symbol. Without one, walks the map
358
+ // and returns the FULL HL canonical (with prefix if any) so URL slugs like
359
+ // `/trade/hl/wtioil-x` can resolve to `xyz:CL`.
367
360
  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;
361
+ if (market) {
362
+ const fullCanonical = REVERSE_ALIASES[aliasKey(displayOrSymbol.toUpperCase(), market)];
363
+ if (!fullCanonical)
364
+ return displayOrSymbol;
365
+ return fullCanonical.includes(':')
366
+ ? fullCanonical.split(':').slice(1).join(':')
367
+ : fullCanonical;
368
+ }
369
+ const upper = displayOrSymbol.toUpperCase();
370
+ for (const [hlFullName, displaySymbol] of Object.entries(SYMBOL_DISPLAY_ALIASES)) {
371
+ if (displaySymbol.toUpperCase() === upper)
372
+ return hlFullName;
373
+ }
374
+ return displayOrSymbol;
375
375
  }
376
376
  function matchesSymbolOrAlias(symbol, term, market = '') {
377
377
  if (!term)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",