@lifi/perps-sdk-provider-hyperliquid 4.2.0 → 4.3.0
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/cjs/utils/assetLogo.d.ts +5 -0
- package/dist/cjs/utils/assetLogo.d.ts.map +1 -0
- package/dist/cjs/utils/assetLogo.js +47 -0
- package/dist/cjs/utils/assetLogo.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.d.ts.map +1 -1
- package/dist/cjs/utils/index.js +5 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/marketDisplay.d.ts.map +1 -1
- package/dist/cjs/utils/marketDisplay.js +5 -2
- package/dist/cjs/utils/marketDisplay.js.map +1 -1
- package/dist/cjs/utils/spotBalance.d.ts.map +1 -1
- package/dist/cjs/utils/spotBalance.js +2 -0
- package/dist/cjs/utils/spotBalance.js.map +1 -1
- package/dist/esm/utils/assetLogo.d.ts +20 -0
- package/dist/esm/utils/assetLogo.d.ts.map +1 -0
- package/dist/esm/utils/assetLogo.js +74 -0
- package/dist/esm/utils/assetLogo.js.map +1 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/marketDisplay.d.ts +5 -4
- package/dist/esm/utils/marketDisplay.d.ts.map +1 -1
- package/dist/esm/utils/marketDisplay.js +10 -6
- package/dist/esm/utils/marketDisplay.js.map +1 -1
- package/dist/esm/utils/spotBalance.d.ts +3 -1
- package/dist/esm/utils/spotBalance.d.ts.map +1 -1
- package/dist/esm/utils/spotBalance.js +5 -1
- package/dist/esm/utils/spotBalance.js.map +1 -1
- package/dist/types/utils/assetLogo.d.ts +20 -0
- package/dist/types/utils/assetLogo.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/marketDisplay.d.ts +5 -4
- package/dist/types/utils/marketDisplay.d.ts.map +1 -1
- package/dist/types/utils/spotBalance.d.ts +3 -1
- package/dist/types/utils/spotBalance.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/utils/assetLogo.ts +85 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/marketDisplay.ts +15 -10
- package/src/utils/spotBalance.ts +5 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Asset } from '@lifi/perps-types';
|
|
2
|
+
export declare const UNIT_TOKEN_NAMES: ReadonlySet<string>;
|
|
3
|
+
export declare const applyLogoOverride: (asset: Asset) => Asset;
|
|
4
|
+
export declare const spotLogoURI: (name: string, fullName?: string | null) => string;
|
|
5
|
+
//# sourceMappingURL=assetLogo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetLogo.d.ts","sourceRoot":"","sources":["../../../src/utils/assetLogo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAkD9C,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAEhD,CAAA;AASD,eAAO,MAAM,iBAAiB,GAAI,OAAO,KAAK,KAAG,KAGhD,CAAA;AAeD,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,WAAW,MAAM,GAAG,IAAI,KAAG,MAKpE,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.spotLogoURI = exports.applyLogoOverride = exports.UNIT_TOKEN_NAMES = void 0;
|
|
4
|
+
const HL_COIN_CDN = 'https://app.hyperliquid.xyz/coins';
|
|
5
|
+
const HYPE_LOGO_URI = 'https://static.debank.com/image/hyper_token/logo_url/hyper/0b3e288cfe418e9ce69eef4c96374583.png';
|
|
6
|
+
const BASE_ASSET_LOGO_OVERRIDES = {
|
|
7
|
+
HYPE: HYPE_LOGO_URI,
|
|
8
|
+
USDC: `${HL_COIN_CDN}/USDC.svg`,
|
|
9
|
+
USDT0: `${HL_COIN_CDN}/USDT.svg`,
|
|
10
|
+
};
|
|
11
|
+
const UNIT_UNDERLYING_SYMBOL = {
|
|
12
|
+
UBTC: 'BTC',
|
|
13
|
+
UETH: 'ETH',
|
|
14
|
+
USOL: 'SOL',
|
|
15
|
+
UFART: 'FARTCOIN',
|
|
16
|
+
UPUMP: 'PUMP',
|
|
17
|
+
UUUSPX: 'SPX',
|
|
18
|
+
UVIRT: 'VIRTUAL',
|
|
19
|
+
UBONK: 'BONK',
|
|
20
|
+
UDOGE: 'DOGE',
|
|
21
|
+
UZEC: 'ZEC',
|
|
22
|
+
UMON: 'MON',
|
|
23
|
+
UWLD: 'WLD',
|
|
24
|
+
UENA: 'ENA',
|
|
25
|
+
UXPL: 'XPL',
|
|
26
|
+
UAVAX: 'AVAX',
|
|
27
|
+
UMEGA: 'MEGA',
|
|
28
|
+
UANSEM: 'ANSEM',
|
|
29
|
+
};
|
|
30
|
+
exports.UNIT_TOKEN_NAMES = new Set(Object.keys(UNIT_UNDERLYING_SYMBOL));
|
|
31
|
+
const unitSpotLogoURI = (name) => {
|
|
32
|
+
const underlying = UNIT_UNDERLYING_SYMBOL[name];
|
|
33
|
+
return underlying === undefined ? '' : `${HL_COIN_CDN}/${underlying}.svg`;
|
|
34
|
+
};
|
|
35
|
+
const applyLogoOverride = (asset) => {
|
|
36
|
+
const override = BASE_ASSET_LOGO_OVERRIDES[asset.displaySymbol];
|
|
37
|
+
return override === undefined ? asset : { ...asset, logoURI: override };
|
|
38
|
+
};
|
|
39
|
+
exports.applyLogoOverride = applyLogoOverride;
|
|
40
|
+
const spotLogoURI = (name, fullName) => {
|
|
41
|
+
const base = fullName?.startsWith('Unit')
|
|
42
|
+
? unitSpotLogoURI(name)
|
|
43
|
+
: `${HL_COIN_CDN}/${name}_spot.svg`;
|
|
44
|
+
return BASE_ASSET_LOGO_OVERRIDES[name] ?? base;
|
|
45
|
+
};
|
|
46
|
+
exports.spotLogoURI = spotLogoURI;
|
|
47
|
+
//# sourceMappingURL=assetLogo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetLogo.js","sourceRoot":"","sources":["../../../src/utils/assetLogo.ts"],"names":[],"mappings":";;;AAEA,MAAM,WAAW,GAAG,mCAAmC,CAAA;AAEvD,MAAM,aAAa,GACjB,iGAAiG,CAAA;AAMnG,MAAM,yBAAyB,GAAqC;IAElE,IAAI,EAAE,aAAa;IAGnB,IAAI,EAAE,GAAG,WAAW,WAAW;IAG/B,KAAK,EAAE,GAAG,WAAW,WAAW;CACjC,CAAA;AASD,MAAM,sBAAsB,GAAqC;IAC/D,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,OAAO;CAChB,CAAA;AAGY,QAAA,gBAAgB,GAAwB,IAAI,GAAG,CAC1D,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CACpC,CAAA;AAGD,MAAM,eAAe,GAAG,CAAC,IAAY,EAAU,EAAE;IAC/C,MAAM,UAAU,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAA;IAC/C,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,UAAU,MAAM,CAAA;AAC3E,CAAC,CAAA;AAGM,MAAM,iBAAiB,GAAG,CAAC,KAAY,EAAS,EAAE;IACvD,MAAM,QAAQ,GAAG,yBAAyB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAC/D,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAA;AACzE,CAAC,CAAA;AAHY,QAAA,iBAAiB,qBAG7B;AAeM,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,QAAwB,EAAU,EAAE;IAC5E,MAAM,IAAI,GAAG,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC;QACvC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC;QACvB,CAAC,CAAC,GAAG,WAAW,IAAI,IAAI,WAAW,CAAA;IACrC,OAAO,yBAAyB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAA;AAChD,CAAC,CAAA;AALY,QAAA,WAAW,eAKvB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { assetIsSpot, calculateAssetId, getProviderIndex } from './assetId.js';
|
|
2
|
+
export { applyLogoOverride, spotLogoURI, UNIT_TOKEN_NAMES, } from './assetLogo.js';
|
|
2
3
|
export { decodeCompressedJson, decodeFastAssetCtxs, } from './decodeFastAssetCtxs.js';
|
|
3
4
|
export type { InfoRequestOptions } from './infoClient.js';
|
|
4
5
|
export { hlInfoOptions, infoRequest } from './infoClient.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,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AAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EACL,cAAc,EACd,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,qBAAqB,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.partitionSpotBalances = exports.spotPriceById = exports.spotBalance = exports.spotAssetFromToken = exports.priceStepToAggregation = exports.getMaxPriceDecimals = exports.formatOrderSize = exports.formatOrderPrice = exports.perpsDexNames = exports.coinAsset = exports.mapPosition = exports.isOpenAssetPosition = exports.mapTriggerOrder = exports.mapStatusReason = exports.mapOrderType = exports.mapOrderStatus = exports.mapOrder = exports.mapOpenOrder = exports.isTriggerType = exports.isTriggerOrder = exports.mapMarketContext = exports.mapMarket = exports.mapFill = exports.classifyFillFromPosition = exports.mapLedgerEntry = exports.mapFundingActivity = exports.calculateMaintenanceMarginRate = exports.calculateLiquidationPrice = exports.infoRequest = exports.hlInfoOptions = exports.decodeFastAssetCtxs = exports.decodeCompressedJson = exports.getProviderIndex = exports.calculateAssetId = exports.assetIsSpot = void 0;
|
|
3
|
+
exports.partitionSpotBalances = exports.spotPriceById = exports.spotBalance = exports.spotAssetFromToken = exports.priceStepToAggregation = exports.getMaxPriceDecimals = exports.formatOrderSize = exports.formatOrderPrice = exports.perpsDexNames = exports.coinAsset = exports.mapPosition = exports.isOpenAssetPosition = exports.mapTriggerOrder = exports.mapStatusReason = exports.mapOrderType = exports.mapOrderStatus = exports.mapOrder = exports.mapOpenOrder = exports.isTriggerType = exports.isTriggerOrder = exports.mapMarketContext = exports.mapMarket = exports.mapFill = exports.classifyFillFromPosition = exports.mapLedgerEntry = exports.mapFundingActivity = exports.calculateMaintenanceMarginRate = exports.calculateLiquidationPrice = exports.infoRequest = exports.hlInfoOptions = exports.decodeFastAssetCtxs = exports.decodeCompressedJson = exports.UNIT_TOKEN_NAMES = exports.spotLogoURI = exports.applyLogoOverride = exports.getProviderIndex = exports.calculateAssetId = exports.assetIsSpot = void 0;
|
|
4
4
|
var assetId_js_1 = require("./assetId.js");
|
|
5
5
|
Object.defineProperty(exports, "assetIsSpot", { enumerable: true, get: function () { return assetId_js_1.assetIsSpot; } });
|
|
6
6
|
Object.defineProperty(exports, "calculateAssetId", { enumerable: true, get: function () { return assetId_js_1.calculateAssetId; } });
|
|
7
7
|
Object.defineProperty(exports, "getProviderIndex", { enumerable: true, get: function () { return assetId_js_1.getProviderIndex; } });
|
|
8
|
+
var assetLogo_js_1 = require("./assetLogo.js");
|
|
9
|
+
Object.defineProperty(exports, "applyLogoOverride", { enumerable: true, get: function () { return assetLogo_js_1.applyLogoOverride; } });
|
|
10
|
+
Object.defineProperty(exports, "spotLogoURI", { enumerable: true, get: function () { return assetLogo_js_1.spotLogoURI; } });
|
|
11
|
+
Object.defineProperty(exports, "UNIT_TOKEN_NAMES", { enumerable: true, get: function () { return assetLogo_js_1.UNIT_TOKEN_NAMES; } });
|
|
8
12
|
var decodeFastAssetCtxs_js_1 = require("./decodeFastAssetCtxs.js");
|
|
9
13
|
Object.defineProperty(exports, "decodeCompressedJson", { enumerable: true, get: function () { return decodeFastAssetCtxs_js_1.decodeCompressedJson; } });
|
|
10
14
|
Object.defineProperty(exports, "decodeFastAssetCtxs", { enumerable: true, get: function () { return decodeFastAssetCtxs_js_1.decodeFastAssetCtxs; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAIA,2CAA8E;AAArE,yGAAA,WAAW,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACxD,mEAGiC;AAF/B,8HAAA,oBAAoB,OAAA;AACpB,6HAAA,mBAAmB,OAAA;AAGrB,iDAA4D;AAAnD,8GAAA,aAAa,OAAA;AAAE,4GAAA,WAAW,OAAA;AACnC,mDAGyB;AAFvB,2HAAA,yBAAyB,OAAA;AACzB,gIAAA,8BAA8B,OAAA;AAEhC,mDAAqE;AAA5D,oHAAA,kBAAkB,OAAA;AAAE,gHAAA,cAAc,OAAA;AAC3C,2CAAgE;AAAvD,sHAAA,wBAAwB,OAAA;AAAE,qGAAA,OAAO,OAAA;AAC1C,+CAA0C;AAAjC,yGAAA,SAAS,OAAA;AAClB,6DAAwD;AAA/C,uHAAA,gBAAgB,OAAA;AACzB,6CASsB;AARpB,6GAAA,cAAc,OAAA;AACd,4GAAA,aAAa,OAAA;AACb,2GAAA,YAAY,OAAA;AACZ,uGAAA,QAAQ,OAAA;AACR,6GAAA,cAAc,OAAA;AACd,2GAAA,YAAY,OAAA;AACZ,8GAAA,eAAe,OAAA;AACf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A,QAAQ,OAAA;AACR,6GAAA,cAAc,OAAA;AACd,2GAAA,YAAY,OAAA;AACZ,8GAAA,eAAe,OAAA;AACf,8GAAA,eAAe,OAAA;AAEjB,mDAAmE;AAA1D,qHAAA,mBAAmB,OAAA;AAAE,6GAAA,WAAW,OAAA;AACzC,uDAA6D;AAApD,6GAAA,SAAS,OAAA;AAAE,iHAAA,aAAa,OAAA;AACjC,2DAI6B;AAH3B,sHAAA,gBAAgB,OAAA;AAChB,qHAAA,eAAe,OAAA;AACf,yHAAA,mBAAmB,OAAA;AAErB,yEAAoE;AAA3D,mIAAA,sBAAsB,OAAA;AAC/B,mDAIyB;AAHvB,oHAAA,kBAAkB,OAAA;AAClB,6GAAA,WAAW,OAAA;AACX,+GAAA,aAAa,OAAA;AAEf,yDAA+E;AAAtE,0HAAA,qBAAqB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketDisplay.d.ts","sourceRoot":"","sources":["../../../src/utils/marketDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"marketDisplay.d.ts","sourceRoot":"","sources":["../../../src/utils/marketDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAiBtD,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,KAQrC,CAAA;AAQJ,eAAO,MAAM,aAAa,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,MAAM,EAShE,CAAA"}
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.perpsDexNames = exports.coinAsset = void 0;
|
|
4
4
|
const constants_js_1 = require("../constants.js");
|
|
5
|
-
const
|
|
5
|
+
const assetLogo_js_1 = require("./assetLogo.js");
|
|
6
|
+
const coinAsset = (coin) => (0, assetLogo_js_1.applyLogoOverride)({
|
|
6
7
|
providerId: constants_js_1.PROVIDER_KEY,
|
|
7
8
|
id: coin,
|
|
8
|
-
displaySymbol: coin.includes(':')
|
|
9
|
+
displaySymbol: coin.includes(':')
|
|
10
|
+
? coin.slice(coin.indexOf(':') + 1)
|
|
11
|
+
: coin,
|
|
9
12
|
logoURI: `https://app.hyperliquid.xyz/coins/${coin}.svg`,
|
|
10
13
|
});
|
|
11
14
|
exports.coinAsset = coinAsset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketDisplay.js","sourceRoot":"","sources":["../../../src/utils/marketDisplay.ts"],"names":[],"mappings":";;;AACA,kDAKwB;
|
|
1
|
+
{"version":3,"file":"marketDisplay.js","sourceRoot":"","sources":["../../../src/utils/marketDisplay.ts"],"names":[],"mappings":";;;AACA,kDAKwB;AACxB,iDAAkD;AAU3C,MAAM,SAAS,GAAG,CAAC,IAAY,EAAS,EAAE,CAC/C,IAAA,gCAAiB,EAAC;IAChB,UAAU,EAAE,2BAAY;IACxB,EAAE,EAAE,IAAI;IACR,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC/B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC,CAAC,IAAI;IACR,OAAO,EAAE,qCAAqC,IAAI,MAAM;CACzD,CAAC,CAAA;AARS,QAAA,SAAS,aAQlB;AAQG,MAAM,aAAa,GAAG,CAAC,OAA0B,EAAY,EAAE;IACpE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAC/B,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,UAAU,KAAK,6BAAc,EAAE,CAAC;YACpC,SAAQ;QACV,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,KAAK,6BAAc,CAAC,CAAC,CAAC,4BAAa,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;IAC3E,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAA;AACnB,CAAC,CAAA;AATY,QAAA,aAAa,iBASzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotBalance.d.ts","sourceRoot":"","sources":["../../../src/utils/spotBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"spotBalance.d.ts","sourceRoot":"","sources":["../../../src/utils/spotBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAUtD,eAAO,MAAM,aAAa,GACxB,SAAS,SAAS,MAAM,EAAE,EAC1B,iBAAiB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KAC3C,GAAG,CAAC,MAAM,EAAE,MAAM,CAapB,CAAA;AASD,eAAO,MAAM,kBAAkB,GAAI,GAAG,aAAa,KAAG,KAIpD,CAAA;AAGF,eAAO,MAAM,WAAW,GACtB,OAAO,KAAK,EACZ,OAAO,MAAM,EACb,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAC7B,OAKD,CAAA"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.spotBalance = exports.spotAssetFromToken = exports.spotPriceById = void 0;
|
|
4
4
|
const perps_sdk_1 = require("@lifi/perps-sdk");
|
|
5
5
|
const constants_js_1 = require("../constants.js");
|
|
6
|
+
const assetLogo_js_1 = require("./assetLogo.js");
|
|
6
7
|
const marketDisplay_js_1 = require("./marketDisplay.js");
|
|
7
8
|
const spotPriceById = (markets, priceByMarketId) => {
|
|
8
9
|
const map = new Map();
|
|
@@ -22,6 +23,7 @@ exports.spotPriceById = spotPriceById;
|
|
|
22
23
|
const spotAssetFromToken = (b) => ({
|
|
23
24
|
...(0, marketDisplay_js_1.coinAsset)(b.coin),
|
|
24
25
|
id: String(b.token),
|
|
26
|
+
logoURI: (0, assetLogo_js_1.spotLogoURI)(b.coin),
|
|
25
27
|
});
|
|
26
28
|
exports.spotAssetFromToken = spotAssetFromToken;
|
|
27
29
|
const spotBalance = (asset, total, priceById) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotBalance.js","sourceRoot":"","sources":["../../../src/utils/spotBalance.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAE/C,kDAAgD;AAEhD,yDAA8C;AAQvC,MAAM,aAAa,GAAG,CAC3B,OAA0B,EAC1B,eAA4C,EACvB,EAAE;IACvB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAA;IACrC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,UAAU,KAAK,6BAAc,EAAE,CAAC;YACpC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;YAC9B,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAhBY,QAAA,aAAa,iBAgBzB;
|
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;IAC1B,KAAK;IACL,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,CAAC,IAAA,yBAAa,EAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC7E,CAAC,CAAA;AATW,QAAA,WAAW,eAStB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Asset } from '@lifi/perps-types';
|
|
2
|
+
/** Token `name`s of the Unit-bridged HL spot assets. */
|
|
3
|
+
export declare const UNIT_TOKEN_NAMES: ReadonlySet<string>;
|
|
4
|
+
/** Return `asset` with its `logoURI` replaced when a display-symbol override exists. */
|
|
5
|
+
export declare const applyLogoOverride: (asset: Asset) => Asset;
|
|
6
|
+
/**
|
|
7
|
+
* Override-aware logo URI for a Hyperliquid spot token. Base rule is
|
|
8
|
+
* `coins/${name}_spot.svg`; a Unit-bridged token (`fullName` starts with
|
|
9
|
+
* "Unit") resolves to its underlying's icon instead; the override table wins
|
|
10
|
+
* over both.
|
|
11
|
+
*
|
|
12
|
+
* When `fullName` is absent — spot *balances* (`HlSpotBalance`) carry no
|
|
13
|
+
* `fullName` and this issue deliberately does not fetch `spotMeta` on the
|
|
14
|
+
* account path — the derivation degrades to the symbol-keyed override + base
|
|
15
|
+
* `_spot` rule, so a Unit-bridged balance uses the base rule rather than its
|
|
16
|
+
* underlying's icon. The registry path (which has `fullName`) keeps full Unit
|
|
17
|
+
* resolution.
|
|
18
|
+
*/
|
|
19
|
+
export declare const spotLogoURI: (name: string, fullName?: string | null) => string;
|
|
20
|
+
//# sourceMappingURL=assetLogo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetLogo.d.ts","sourceRoot":"","sources":["../../../src/utils/assetLogo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAiD9C,wDAAwD;AACxD,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAEhD,CAAA;AAQD,wFAAwF;AACxF,eAAO,MAAM,iBAAiB,GAAI,OAAO,KAAK,KAAG,KAGhD,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,WAAW,MAAM,GAAG,IAAI,KAAG,MAKpE,CAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const HL_COIN_CDN = 'https://app.hyperliquid.xyz/coins';
|
|
2
|
+
const HYPE_LOGO_URI = 'https://static.debank.com/image/hyper_token/logo_url/hyper/0b3e288cfe418e9ce69eef4c96374583.png';
|
|
3
|
+
/**
|
|
4
|
+
* Per-symbol logo overrides applied on top of the derived HL CDN URL, keyed by
|
|
5
|
+
* `Asset.displaySymbol`. Each entry notes why the default URL is wrong.
|
|
6
|
+
*/
|
|
7
|
+
const BASE_ASSET_LOGO_OVERRIDES = {
|
|
8
|
+
// coins/HYPE.svg is low quality; the debank hyper_token PNG is the canonical icon.
|
|
9
|
+
HYPE: HYPE_LOGO_URI,
|
|
10
|
+
// coins/USDC_spot.svg doesn't exist — HL's app 200s with its SPA shell HTML
|
|
11
|
+
// instead of a 404, so the collateral asset needs the non-suffixed path.
|
|
12
|
+
USDC: `${HL_COIN_CDN}/USDC.svg`,
|
|
13
|
+
// Neither coins/USDT0.svg nor coins/USDT0_spot.svg serves an image (both 200
|
|
14
|
+
// with the SPA shell); USDT0 is HL's USDT deployment, so reuse USDT's icon.
|
|
15
|
+
USDT0: `${HL_COIN_CDN}/USDT.svg`,
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Underlying spot symbol for each Unit-bridged token (`fullName` starts with
|
|
19
|
+
* "Unit"), keyed by the token `name`. Hand-verified that `coins/<symbol>.svg`
|
|
20
|
+
* serves a real image; the Unit-suffixed `NAME_spot.svg` path 200s with HTML
|
|
21
|
+
* instead. Unit tokens absent here have no working HL icon and intentionally
|
|
22
|
+
* resolve to '' (client letter avatar).
|
|
23
|
+
*/
|
|
24
|
+
const UNIT_UNDERLYING_SYMBOL = {
|
|
25
|
+
UBTC: 'BTC',
|
|
26
|
+
UETH: 'ETH',
|
|
27
|
+
USOL: 'SOL',
|
|
28
|
+
UFART: 'FARTCOIN',
|
|
29
|
+
UPUMP: 'PUMP',
|
|
30
|
+
UUUSPX: 'SPX',
|
|
31
|
+
UVIRT: 'VIRTUAL',
|
|
32
|
+
UBONK: 'BONK',
|
|
33
|
+
UDOGE: 'DOGE',
|
|
34
|
+
UZEC: 'ZEC',
|
|
35
|
+
UMON: 'MON',
|
|
36
|
+
UWLD: 'WLD',
|
|
37
|
+
UENA: 'ENA',
|
|
38
|
+
UXPL: 'XPL',
|
|
39
|
+
UAVAX: 'AVAX',
|
|
40
|
+
UMEGA: 'MEGA',
|
|
41
|
+
UANSEM: 'ANSEM',
|
|
42
|
+
};
|
|
43
|
+
/** Token `name`s of the Unit-bridged HL spot assets. */
|
|
44
|
+
export const UNIT_TOKEN_NAMES = new Set(Object.keys(UNIT_UNDERLYING_SYMBOL));
|
|
45
|
+
/** Logo URI for a Unit-bridged spot token; '' when the underlying is unmapped. */
|
|
46
|
+
const unitSpotLogoURI = (name) => {
|
|
47
|
+
const underlying = UNIT_UNDERLYING_SYMBOL[name];
|
|
48
|
+
return underlying === undefined ? '' : `${HL_COIN_CDN}/${underlying}.svg`;
|
|
49
|
+
};
|
|
50
|
+
/** Return `asset` with its `logoURI` replaced when a display-symbol override exists. */
|
|
51
|
+
export const applyLogoOverride = (asset) => {
|
|
52
|
+
const override = BASE_ASSET_LOGO_OVERRIDES[asset.displaySymbol];
|
|
53
|
+
return override === undefined ? asset : { ...asset, logoURI: override };
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Override-aware logo URI for a Hyperliquid spot token. Base rule is
|
|
57
|
+
* `coins/${name}_spot.svg`; a Unit-bridged token (`fullName` starts with
|
|
58
|
+
* "Unit") resolves to its underlying's icon instead; the override table wins
|
|
59
|
+
* over both.
|
|
60
|
+
*
|
|
61
|
+
* When `fullName` is absent — spot *balances* (`HlSpotBalance`) carry no
|
|
62
|
+
* `fullName` and this issue deliberately does not fetch `spotMeta` on the
|
|
63
|
+
* account path — the derivation degrades to the symbol-keyed override + base
|
|
64
|
+
* `_spot` rule, so a Unit-bridged balance uses the base rule rather than its
|
|
65
|
+
* underlying's icon. The registry path (which has `fullName`) keeps full Unit
|
|
66
|
+
* resolution.
|
|
67
|
+
*/
|
|
68
|
+
export const spotLogoURI = (name, fullName) => {
|
|
69
|
+
const base = fullName?.startsWith('Unit')
|
|
70
|
+
? unitSpotLogoURI(name)
|
|
71
|
+
: `${HL_COIN_CDN}/${name}_spot.svg`;
|
|
72
|
+
return BASE_ASSET_LOGO_OVERRIDES[name] ?? base;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=assetLogo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetLogo.js","sourceRoot":"","sources":["../../../src/utils/assetLogo.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAG,mCAAmC,CAAA;AAEvD,MAAM,aAAa,GACjB,iGAAiG,CAAA;AAEnG;;;GAGG;AACH,MAAM,yBAAyB,GAAqC;IAClE,mFAAmF;IACnF,IAAI,EAAE,aAAa;IACnB,4EAA4E;IAC5E,yEAAyE;IACzE,IAAI,EAAE,GAAG,WAAW,WAAW;IAC/B,6EAA6E;IAC7E,4EAA4E;IAC5E,KAAK,EAAE,GAAG,WAAW,WAAW;CACjC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,sBAAsB,GAAqC;IAC/D,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,MAA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export { assetIsSpot, calculateAssetId, getProviderIndex } from './assetId.js';
|
|
2
|
+
export { applyLogoOverride, spotLogoURI, UNIT_TOKEN_NAMES, } from './assetLogo.js';
|
|
2
3
|
export { decodeCompressedJson, decodeFastAssetCtxs, } from './decodeFastAssetCtxs.js';
|
|
3
4
|
export type { InfoRequestOptions } from './infoClient.js';
|
|
4
5
|
export { hlInfoOptions, infoRequest } from './infoClient.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EACL,cAAc,EACd,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,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f,mBAAmB,GACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,qBAAqB,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// for the package's utility surface. Internal modules import per-file paths
|
|
3
3
|
// (e.g. `./assetId.js`, `./mapFill.js`) directly.
|
|
4
4
|
export { assetIsSpot, calculateAssetId, getProviderIndex } from './assetId.js';
|
|
5
|
+
export { applyLogoOverride, spotLogoURI, UNIT_TOKEN_NAMES, } from './assetLogo.js';
|
|
5
6
|
export { decodeCompressedJson, decodeFastAssetCtxs, } from './decodeFastAssetCtxs.js';
|
|
6
7
|
export { hlInfoOptions, infoRequest } from './infoClient.js';
|
|
7
8
|
export { calculateLiquidationPrice, calculateMaintenanceMarginRate, } from './liquidation.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,4EAA4E;AAC5E,kDAAkD;AAElD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,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E,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EACL,cAAc,EACd,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,qBAAqB,EAAsB,MAAM,qBAAqB,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Asset, Market } from '@lifi/perps-types';
|
|
2
2
|
/**
|
|
3
|
-
* Synthesise the {@link Asset} for a Hyperliquid wire coin. `id`
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Synthesise the {@link Asset} for a Hyperliquid wire coin. `id` keeps the raw
|
|
4
|
+
* coin — the logo CDN is keyed by it, HIP-3 `dex:` prefix included.
|
|
5
|
+
* `displaySymbol` drops the prefix: the category is carried by `categoryId`,
|
|
6
|
+
* never by the display string. `logoURI` is the CDN URL corrected by the
|
|
7
|
+
* shared override table (see {@link applyLogoOverride}).
|
|
7
8
|
* @public
|
|
8
9
|
*/
|
|
9
10
|
export declare const coinAsset: (coin: string) => Asset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketDisplay.d.ts","sourceRoot":"","sources":["../../../src/utils/marketDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"marketDisplay.d.ts","sourceRoot":"","sources":["../../../src/utils/marketDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAStD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,KAQrC,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,MAAM,EAShE,CAAA"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { MAIN_DEX_NAME, MAIN_MARKET_ID, PROVIDER_KEY, SPOT_MARKET_ID, } from '../constants.js';
|
|
2
|
+
import { applyLogoOverride } from './assetLogo.js';
|
|
2
3
|
/**
|
|
3
|
-
* Synthesise the {@link Asset} for a Hyperliquid wire coin. `id`
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Synthesise the {@link Asset} for a Hyperliquid wire coin. `id` keeps the raw
|
|
5
|
+
* coin — the logo CDN is keyed by it, HIP-3 `dex:` prefix included.
|
|
6
|
+
* `displaySymbol` drops the prefix: the category is carried by `categoryId`,
|
|
7
|
+
* never by the display string. `logoURI` is the CDN URL corrected by the
|
|
8
|
+
* shared override table (see {@link applyLogoOverride}).
|
|
7
9
|
* @public
|
|
8
10
|
*/
|
|
9
|
-
export const coinAsset = (coin) => ({
|
|
11
|
+
export const coinAsset = (coin) => applyLogoOverride({
|
|
10
12
|
providerId: PROVIDER_KEY,
|
|
11
13
|
id: coin,
|
|
12
|
-
displaySymbol: coin.includes(':')
|
|
14
|
+
displaySymbol: coin.includes(':')
|
|
15
|
+
? coin.slice(coin.indexOf(':') + 1)
|
|
16
|
+
: coin,
|
|
13
17
|
logoURI: `https://app.hyperliquid.xyz/coins/${coin}.svg`,
|
|
14
18
|
});
|
|
15
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketDisplay.js","sourceRoot":"","sources":["../../../src/utils/marketDisplay.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,GACf,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"marketDisplay.js","sourceRoot":"","sources":["../../../src/utils/marketDisplay.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAS,EAAE,CAC/C,iBAAiB,CAAC;IAChB,UAAU,EAAE,YAAY;IACxB,EAAE,EAAE,IAAI;IACR,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC/B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC,CAAC,IAAI;IACR,OAAO,EAAE,qCAAqC,IAAI,MAAM;CACzD,CAAC,CAAA;AAEJ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAA0B,EAAY,EAAE;IACpE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAC/B,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,UAAU,KAAK,cAAc,EAAE,CAAC;YACpC,SAAQ;QACV,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,KAAK,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;IAC3E,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAA;AACnB,CAAC,CAAA"}
|
|
@@ -10,7 +10,9 @@ export declare const spotPriceById: (markets: readonly Market[], priceByMarketId
|
|
|
10
10
|
/**
|
|
11
11
|
* The held spot {@link Asset} for an HL balance: the venue token index
|
|
12
12
|
* (`b.token`) as `Asset.id` — equal to that token's spot `Market.baseAsset.id`
|
|
13
|
-
* — with display fields derived from the coin.
|
|
13
|
+
* — with display fields derived from the coin and the override-aware spot logo.
|
|
14
|
+
* `HlSpotBalance` carries no `fullName`, so Unit-bridged balances take the base
|
|
15
|
+
* `_spot` rule (see {@link spotLogoURI}).
|
|
14
16
|
*/
|
|
15
17
|
export declare const spotAssetFromToken: (b: HlSpotBalance) => Asset;
|
|
16
18
|
/** Assemble a typed spot {@link Balance} from its resolved asset and raw size. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotBalance.d.ts","sourceRoot":"","sources":["../../../src/utils/spotBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"spotBalance.d.ts","sourceRoot":"","sources":["../../../src/utils/spotBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAItD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,SAAS,MAAM,EAAE,EAC1B,iBAAiB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KAC3C,GAAG,CAAC,MAAM,EAAE,MAAM,CAapB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,GAAG,aAAa,KAAG,KAIpD,CAAA;AAEF,kFAAkF;AAClF,eAAO,MAAM,WAAW,GACtB,OAAO,KAAK,EACZ,OAAO,MAAM,EACb,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAC7B,OAKD,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stringToFloat } from '@lifi/perps-sdk';
|
|
2
2
|
import { SPOT_MARKET_ID } from '../constants.js';
|
|
3
|
+
import { spotLogoURI } from './assetLogo.js';
|
|
3
4
|
import { coinAsset } from './marketDisplay.js';
|
|
4
5
|
/**
|
|
5
6
|
* USD price keyed by spot token index: each spot market's live USD price
|
|
@@ -24,11 +25,14 @@ export const spotPriceById = (markets, priceByMarketId) => {
|
|
|
24
25
|
/**
|
|
25
26
|
* The held spot {@link Asset} for an HL balance: the venue token index
|
|
26
27
|
* (`b.token`) as `Asset.id` — equal to that token's spot `Market.baseAsset.id`
|
|
27
|
-
* — with display fields derived from the coin.
|
|
28
|
+
* — with display fields derived from the coin and the override-aware spot logo.
|
|
29
|
+
* `HlSpotBalance` carries no `fullName`, so Unit-bridged balances take the base
|
|
30
|
+
* `_spot` rule (see {@link spotLogoURI}).
|
|
28
31
|
*/
|
|
29
32
|
export const spotAssetFromToken = (b) => ({
|
|
30
33
|
...coinAsset(b.coin),
|
|
31
34
|
id: String(b.token),
|
|
35
|
+
logoURI: spotLogoURI(b.coin),
|
|
32
36
|
});
|
|
33
37
|
/** Assemble a typed spot {@link Balance} from its resolved asset and raw size. */
|
|
34
38
|
export const spotBalance = (asset, total, priceById) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotBalance.js","sourceRoot":"","sources":["../../../src/utils/spotBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA0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AE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;YAC9B,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAgB,EAAS,EAAE,CAAC,CAAC;IAC9D,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;CAC7B,CAAC,CAAA;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAY,EACZ,KAAa,EACb,SAA8B,EACrB,EAAE,CAAC,CAAC;IACb,UAAU,EAAE,cAAc;IAC1B,KAAK;IACL,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC7E,CAAC,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Asset } from '@lifi/perps-types';
|
|
2
|
+
/** Token `name`s of the Unit-bridged HL spot assets. */
|
|
3
|
+
export declare const UNIT_TOKEN_NAMES: ReadonlySet<string>;
|
|
4
|
+
/** Return `asset` with its `logoURI` replaced when a display-symbol override exists. */
|
|
5
|
+
export declare const applyLogoOverride: (asset: Asset) => Asset;
|
|
6
|
+
/**
|
|
7
|
+
* Override-aware logo URI for a Hyperliquid spot token. Base rule is
|
|
8
|
+
* `coins/${name}_spot.svg`; a Unit-bridged token (`fullName` starts with
|
|
9
|
+
* "Unit") resolves to its underlying's icon instead; the override table wins
|
|
10
|
+
* over both.
|
|
11
|
+
*
|
|
12
|
+
* When `fullName` is absent — spot *balances* (`HlSpotBalance`) carry no
|
|
13
|
+
* `fullName` and this issue deliberately does not fetch `spotMeta` on the
|
|
14
|
+
* account path — the derivation degrades to the symbol-keyed override + base
|
|
15
|
+
* `_spot` rule, so a Unit-bridged balance uses the base rule rather than its
|
|
16
|
+
* underlying's icon. The registry path (which has `fullName`) keeps full Unit
|
|
17
|
+
* resolution.
|
|
18
|
+
*/
|
|
19
|
+
export declare const spotLogoURI: (name: string, fullName?: string | null) => string;
|
|
20
|
+
//# sourceMappingURL=assetLogo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetLogo.d.ts","sourceRoot":"","sources":["../../../src/utils/assetLogo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAiD9C,wDAAwD;AACxD,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAEhD,CAAA;AAQD,wFAAwF;AACxF,eAAO,MAAM,iBAAiB,GAAI,OAAO,KAAK,KAAG,KAGhD,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,WAAW,MAAM,GAAG,IAAI,KAAG,MAKpE,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { assetIsSpot, calculateAssetId, getProviderIndex } from './assetId.js';
|
|
2
|
+
export { applyLogoOverride, spotLogoURI, UNIT_TOKEN_NAMES, } from './assetLogo.js';
|
|
2
3
|
export { decodeCompressedJson, decodeFastAssetCtxs, } from './decodeFastAssetCtxs.js';
|
|
3
4
|
export type { InfoRequestOptions } from './infoClient.js';
|
|
4
5
|
export { hlInfoOptions, infoRequest } from './infoClient.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EACL,cAAc,EACd,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,qBAAqB,EAAE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AE,qBAAqB,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Asset, Market } from '@lifi/perps-types';
|
|
2
2
|
/**
|
|
3
|
-
* Synthesise the {@link Asset} for a Hyperliquid wire coin. `id`
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Synthesise the {@link Asset} for a Hyperliquid wire coin. `id` keeps the raw
|
|
4
|
+
* coin — the logo CDN is keyed by it, HIP-3 `dex:` prefix included.
|
|
5
|
+
* `displaySymbol` drops the prefix: the category is carried by `categoryId`,
|
|
6
|
+
* never by the display string. `logoURI` is the CDN URL corrected by the
|
|
7
|
+
* shared override table (see {@link applyLogoOverride}).
|
|
7
8
|
* @public
|
|
8
9
|
*/
|
|
9
10
|
export declare const coinAsset: (coin: string) => Asset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketDisplay.d.ts","sourceRoot":"","sources":["../../../src/utils/marketDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"marketDisplay.d.ts","sourceRoot":"","sources":["../../../src/utils/marketDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAStD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,KAQrC,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,SAAS,MAAM,EAAE,KAAG,MAAM,EAShE,CAAA"}
|
|
@@ -10,7 +10,9 @@ export declare const spotPriceById: (markets: readonly Market[], priceByMarketId
|
|
|
10
10
|
/**
|
|
11
11
|
* The held spot {@link Asset} for an HL balance: the venue token index
|
|
12
12
|
* (`b.token`) as `Asset.id` — equal to that token's spot `Market.baseAsset.id`
|
|
13
|
-
* — with display fields derived from the coin.
|
|
13
|
+
* — with display fields derived from the coin and the override-aware spot logo.
|
|
14
|
+
* `HlSpotBalance` carries no `fullName`, so Unit-bridged balances take the base
|
|
15
|
+
* `_spot` rule (see {@link spotLogoURI}).
|
|
14
16
|
*/
|
|
15
17
|
export declare const spotAssetFromToken: (b: HlSpotBalance) => Asset;
|
|
16
18
|
/** Assemble a typed spot {@link Balance} from its resolved asset and raw size. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotBalance.d.ts","sourceRoot":"","sources":["../../../src/utils/spotBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"spotBalance.d.ts","sourceRoot":"","sources":["../../../src/utils/spotBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAItD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,SAAS,MAAM,EAAE,EAC1B,iBAAiB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KAC3C,GAAG,CAAC,MAAM,EAAE,MAAM,CAapB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,GAAG,aAAa,KAAG,KAIpD,CAAA;AAEF,kFAAkF;AAClF,eAAO,MAAM,WAAW,GACtB,OAAO,KAAK,EACZ,OAAO,MAAM,EACb,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAC7B,OAKD,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/perps-sdk-provider-hyperliquid",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "Hyperliquid provider plugin for @lifi/perps-sdk",
|
|
5
5
|
"homepage": "https://github.com/lifinance/perps-sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"big.js": "^7.0.1",
|
|
50
50
|
"viem": "^2.48.8",
|
|
51
|
-
"@lifi/perps-types": "^3.
|
|
51
|
+
"@lifi/perps-types": "^3.2.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@lifi/perps-sdk": "^4.
|
|
54
|
+
"@lifi/perps-sdk": "^4.3.0"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Asset } from '@lifi/perps-types'
|
|
2
|
+
|
|
3
|
+
const HL_COIN_CDN = 'https://app.hyperliquid.xyz/coins'
|
|
4
|
+
|
|
5
|
+
const HYPE_LOGO_URI =
|
|
6
|
+
'https://static.debank.com/image/hyper_token/logo_url/hyper/0b3e288cfe418e9ce69eef4c96374583.png'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Per-symbol logo overrides applied on top of the derived HL CDN URL, keyed by
|
|
10
|
+
* `Asset.displaySymbol`. Each entry notes why the default URL is wrong.
|
|
11
|
+
*/
|
|
12
|
+
const BASE_ASSET_LOGO_OVERRIDES: Readonly<Record<string, string>> = {
|
|
13
|
+
// coins/HYPE.svg is low quality; the debank hyper_token PNG is the canonical icon.
|
|
14
|
+
HYPE: HYPE_LOGO_URI,
|
|
15
|
+
// coins/USDC_spot.svg doesn't exist — HL's app 200s with its SPA shell HTML
|
|
16
|
+
// instead of a 404, so the collateral asset needs the non-suffixed path.
|
|
17
|
+
USDC: `${HL_COIN_CDN}/USDC.svg`,
|
|
18
|
+
// Neither coins/USDT0.svg nor coins/USDT0_spot.svg serves an image (both 200
|
|
19
|
+
// with the SPA shell); USDT0 is HL's USDT deployment, so reuse USDT's icon.
|
|
20
|
+
USDT0: `${HL_COIN_CDN}/USDT.svg`,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Underlying spot symbol for each Unit-bridged token (`fullName` starts with
|
|
25
|
+
* "Unit"), keyed by the token `name`. Hand-verified that `coins/<symbol>.svg`
|
|
26
|
+
* serves a real image; the Unit-suffixed `NAME_spot.svg` path 200s with HTML
|
|
27
|
+
* instead. Unit tokens absent here have no working HL icon and intentionally
|
|
28
|
+
* resolve to '' (client letter avatar).
|
|
29
|
+
*/
|
|
30
|
+
const UNIT_UNDERLYING_SYMBOL: Readonly<Record<string, string>> = {
|
|
31
|
+
UBTC: 'BTC',
|
|
32
|
+
UETH: 'ETH',
|
|
33
|
+
USOL: 'SOL',
|
|
34
|
+
UFART: 'FARTCOIN',
|
|
35
|
+
UPUMP: 'PUMP',
|
|
36
|
+
UUUSPX: 'SPX',
|
|
37
|
+
UVIRT: 'VIRTUAL',
|
|
38
|
+
UBONK: 'BONK',
|
|
39
|
+
UDOGE: 'DOGE',
|
|
40
|
+
UZEC: 'ZEC',
|
|
41
|
+
UMON: 'MON',
|
|
42
|
+
UWLD: 'WLD',
|
|
43
|
+
UENA: 'ENA',
|
|
44
|
+
UXPL: 'XPL',
|
|
45
|
+
UAVAX: 'AVAX',
|
|
46
|
+
UMEGA: 'MEGA',
|
|
47
|
+
UANSEM: 'ANSEM',
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Token `name`s of the Unit-bridged HL spot assets. */
|
|
51
|
+
export const UNIT_TOKEN_NAMES: ReadonlySet<string> = new Set(
|
|
52
|
+
Object.keys(UNIT_UNDERLYING_SYMBOL)
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
/** Logo URI for a Unit-bridged spot token; '' when the underlying is unmapped. */
|
|
56
|
+
const unitSpotLogoURI = (name: string): string => {
|
|
57
|
+
const underlying = UNIT_UNDERLYING_SYMBOL[name]
|
|
58
|
+
return underlying === undefined ? '' : `${HL_COIN_CDN}/${underlying}.svg`
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Return `asset` with its `logoURI` replaced when a display-symbol override exists. */
|
|
62
|
+
export const applyLogoOverride = (asset: Asset): Asset => {
|
|
63
|
+
const override = BASE_ASSET_LOGO_OVERRIDES[asset.displaySymbol]
|
|
64
|
+
return override === undefined ? asset : { ...asset, logoURI: override }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Override-aware logo URI for a Hyperliquid spot token. Base rule is
|
|
69
|
+
* `coins/${name}_spot.svg`; a Unit-bridged token (`fullName` starts with
|
|
70
|
+
* "Unit") resolves to its underlying's icon instead; the override table wins
|
|
71
|
+
* over both.
|
|
72
|
+
*
|
|
73
|
+
* When `fullName` is absent — spot *balances* (`HlSpotBalance`) carry no
|
|
74
|
+
* `fullName` and this issue deliberately does not fetch `spotMeta` on the
|
|
75
|
+
* account path — the derivation degrades to the symbol-keyed override + base
|
|
76
|
+
* `_spot` rule, so a Unit-bridged balance uses the base rule rather than its
|
|
77
|
+
* underlying's icon. The registry path (which has `fullName`) keeps full Unit
|
|
78
|
+
* resolution.
|
|
79
|
+
*/
|
|
80
|
+
export const spotLogoURI = (name: string, fullName?: string | null): string => {
|
|
81
|
+
const base = fullName?.startsWith('Unit')
|
|
82
|
+
? unitSpotLogoURI(name)
|
|
83
|
+
: `${HL_COIN_CDN}/${name}_spot.svg`
|
|
84
|
+
return BASE_ASSET_LOGO_OVERRIDES[name] ?? base
|
|
85
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
// (e.g. `./assetId.js`, `./mapFill.js`) directly.
|
|
4
4
|
|
|
5
5
|
export { assetIsSpot, calculateAssetId, getProviderIndex } from './assetId.js'
|
|
6
|
+
export {
|
|
7
|
+
applyLogoOverride,
|
|
8
|
+
spotLogoURI,
|
|
9
|
+
UNIT_TOKEN_NAMES,
|
|
10
|
+
} from './assetLogo.js'
|
|
6
11
|
export {
|
|
7
12
|
decodeCompressedJson,
|
|
8
13
|
decodeFastAssetCtxs,
|
|
@@ -5,20 +5,25 @@ import {
|
|
|
5
5
|
PROVIDER_KEY,
|
|
6
6
|
SPOT_MARKET_ID,
|
|
7
7
|
} from '../constants.js'
|
|
8
|
+
import { applyLogoOverride } from './assetLogo.js'
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* Synthesise the {@link Asset} for a Hyperliquid wire coin. `id`
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Synthesise the {@link Asset} for a Hyperliquid wire coin. `id` keeps the raw
|
|
12
|
+
* coin — the logo CDN is keyed by it, HIP-3 `dex:` prefix included.
|
|
13
|
+
* `displaySymbol` drops the prefix: the category is carried by `categoryId`,
|
|
14
|
+
* never by the display string. `logoURI` is the CDN URL corrected by the
|
|
15
|
+
* shared override table (see {@link applyLogoOverride}).
|
|
14
16
|
* @public
|
|
15
17
|
*/
|
|
16
|
-
export const coinAsset = (coin: string): Asset =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export const coinAsset = (coin: string): Asset =>
|
|
19
|
+
applyLogoOverride({
|
|
20
|
+
providerId: PROVIDER_KEY,
|
|
21
|
+
id: coin,
|
|
22
|
+
displaySymbol: coin.includes(':')
|
|
23
|
+
? coin.slice(coin.indexOf(':') + 1)
|
|
24
|
+
: coin,
|
|
25
|
+
logoURI: `https://app.hyperliquid.xyz/coins/${coin}.svg`,
|
|
26
|
+
})
|
|
22
27
|
|
|
23
28
|
/**
|
|
24
29
|
* Distinct wire `dex` names to fan `clearinghouseState` / `frontendOpenOrders`
|
package/src/utils/spotBalance.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { stringToFloat } from '@lifi/perps-sdk'
|
|
|
2
2
|
import type { Asset, Balance, Market } from '@lifi/perps-types'
|
|
3
3
|
import { SPOT_MARKET_ID } from '../constants.js'
|
|
4
4
|
import type { HlSpotBalance } from '../types/index.js'
|
|
5
|
+
import { spotLogoURI } from './assetLogo.js'
|
|
5
6
|
import { coinAsset } from './marketDisplay.js'
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -31,11 +32,14 @@ export const spotPriceById = (
|
|
|
31
32
|
/**
|
|
32
33
|
* The held spot {@link Asset} for an HL balance: the venue token index
|
|
33
34
|
* (`b.token`) as `Asset.id` — equal to that token's spot `Market.baseAsset.id`
|
|
34
|
-
* — with display fields derived from the coin.
|
|
35
|
+
* — with display fields derived from the coin and the override-aware spot logo.
|
|
36
|
+
* `HlSpotBalance` carries no `fullName`, so Unit-bridged balances take the base
|
|
37
|
+
* `_spot` rule (see {@link spotLogoURI}).
|
|
35
38
|
*/
|
|
36
39
|
export const spotAssetFromToken = (b: HlSpotBalance): Asset => ({
|
|
37
40
|
...coinAsset(b.coin),
|
|
38
41
|
id: String(b.token),
|
|
42
|
+
logoURI: spotLogoURI(b.coin),
|
|
39
43
|
})
|
|
40
44
|
|
|
41
45
|
/** Assemble a typed spot {@link Balance} from its resolved asset and raw size. */
|