@pear-protocol/hyperliquid-sdk 0.0.73-beta.6 → 0.0.73-beta.7
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.js +28 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1509,6 +1509,20 @@ const useWebData = () => {
|
|
|
1509
1509
|
};
|
|
1510
1510
|
};
|
|
1511
1511
|
|
|
1512
|
+
/**
|
|
1513
|
+
* Check if two symbols match, handling kPEPE/KPEPE variations
|
|
1514
|
+
* Returns true if symbols match (case-insensitive for k-prefix tokens)
|
|
1515
|
+
*/
|
|
1516
|
+
function symbolsMatch(assetName, searchSymbol) {
|
|
1517
|
+
// Exact match
|
|
1518
|
+
if (assetName === searchSymbol)
|
|
1519
|
+
return true;
|
|
1520
|
+
// Try case-insensitive match for k-prefix tokens (kPEPE vs KPEPE)
|
|
1521
|
+
if (assetName.toUpperCase() === searchSymbol.toUpperCase()) {
|
|
1522
|
+
return true;
|
|
1523
|
+
}
|
|
1524
|
+
return false;
|
|
1525
|
+
}
|
|
1512
1526
|
/**
|
|
1513
1527
|
* Extracts token metadata from aggregated WebData3 contexts and AllMids data
|
|
1514
1528
|
*/
|
|
@@ -1529,8 +1543,9 @@ class TokenMetadataExtractor {
|
|
|
1529
1543
|
}
|
|
1530
1544
|
// Find token index in aggregated universe
|
|
1531
1545
|
// For HIP3 assets, match both name AND marketPrefix
|
|
1546
|
+
// Uses symbolsMatch to handle kPEPE/KPEPE case variations
|
|
1532
1547
|
const universeIndex = perpMetaAssets.findIndex((asset) => {
|
|
1533
|
-
if (asset.name
|
|
1548
|
+
if (!symbolsMatch(asset.name, symbol))
|
|
1534
1549
|
return false;
|
|
1535
1550
|
// If marketPrefix is specified, match it; otherwise match assets without prefix
|
|
1536
1551
|
if (marketPrefix) {
|
|
@@ -1549,15 +1564,20 @@ class TokenMetadataExtractor {
|
|
|
1549
1564
|
}
|
|
1550
1565
|
// Get current price - prefer assetCtx.midPx as it's already index-matched,
|
|
1551
1566
|
// fall back to allMids lookup if midPx is null
|
|
1552
|
-
const
|
|
1567
|
+
const actualSymbol = universeAsset.name; // Use actual symbol from universe (handles kPEPE vs KPEPE)
|
|
1568
|
+
const prefixedKeyColon = marketPrefix
|
|
1569
|
+
? `${marketPrefix}:${actualSymbol}`
|
|
1570
|
+
: null;
|
|
1553
1571
|
let currentPrice = 0;
|
|
1554
1572
|
// Primary source: assetCtx.midPx (already properly indexed)
|
|
1555
1573
|
if (assetCtx.midPx) {
|
|
1556
1574
|
currentPrice = parseFloat(assetCtx.midPx);
|
|
1557
1575
|
}
|
|
1558
1576
|
// Fallback: allMids lookup with multiple key formats for HIP3 markets
|
|
1577
|
+
// Try actual symbol from universe first, then input symbol
|
|
1559
1578
|
if (!currentPrice || isNaN(currentPrice)) {
|
|
1560
1579
|
const currentPriceStr = (prefixedKeyColon && allMids.mids[prefixedKeyColon]) ||
|
|
1580
|
+
allMids.mids[actualSymbol] ||
|
|
1561
1581
|
allMids.mids[symbol];
|
|
1562
1582
|
currentPrice = currentPriceStr ? parseFloat(currentPriceStr) : 0;
|
|
1563
1583
|
}
|
|
@@ -1571,10 +1591,12 @@ class TokenMetadataExtractor {
|
|
|
1571
1591
|
const markPrice = parseFloat(assetCtx.markPx);
|
|
1572
1592
|
const oraclePrice = parseFloat(assetCtx.oraclePx);
|
|
1573
1593
|
// Extract leverage info from activeAssetData if available
|
|
1574
|
-
// Try prefixed key first (e.g., "xyz:TSLA"), then
|
|
1594
|
+
// Try prefixed key first (e.g., "xyz:TSLA"), then actual symbol, then input symbol
|
|
1575
1595
|
const activeDataKey = prefixedKeyColon && (activeAssetData === null || activeAssetData === void 0 ? void 0 : activeAssetData[prefixedKeyColon])
|
|
1576
1596
|
? prefixedKeyColon
|
|
1577
|
-
:
|
|
1597
|
+
: (activeAssetData === null || activeAssetData === void 0 ? void 0 : activeAssetData[actualSymbol])
|
|
1598
|
+
? actualSymbol
|
|
1599
|
+
: symbol;
|
|
1578
1600
|
const tokenActiveData = activeAssetData === null || activeAssetData === void 0 ? void 0 : activeAssetData[activeDataKey];
|
|
1579
1601
|
const leverage = tokenActiveData === null || tokenActiveData === void 0 ? void 0 : tokenActiveData.leverage;
|
|
1580
1602
|
const maxTradeSzs = tokenActiveData === null || tokenActiveData === void 0 ? void 0 : tokenActiveData.maxTradeSzs;
|
|
@@ -1626,7 +1648,7 @@ class TokenMetadataExtractor {
|
|
|
1626
1648
|
static isTokenAvailable(symbol, perpMetaAssets) {
|
|
1627
1649
|
if (!perpMetaAssets)
|
|
1628
1650
|
return false;
|
|
1629
|
-
return perpMetaAssets.some((asset) => asset.name
|
|
1651
|
+
return perpMetaAssets.some((asset) => symbolsMatch(asset.name, symbol));
|
|
1630
1652
|
}
|
|
1631
1653
|
}
|
|
1632
1654
|
|
|
@@ -8174,6 +8196,7 @@ function useAuth() {
|
|
|
8174
8196
|
return;
|
|
8175
8197
|
}
|
|
8176
8198
|
if (address) {
|
|
8199
|
+
refreshTokens();
|
|
8177
8200
|
// If we already have an address in state, use it to load the session
|
|
8178
8201
|
const accessTokenKey = `${address}_accessToken`;
|
|
8179
8202
|
const refreshTokenKey = `${address}_refreshToken`;
|