@basedone/core 0.0.6 → 0.0.8

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.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta, PerpDex } from '@nktkas/hyperliquid';
1
+ import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta } from '@nktkas/hyperliquid';
2
+ import { Hex } from '@nktkas/hyperliquid/script/src/types/mod';
2
3
 
3
4
  declare function encodeSlug(slug: string): bigint;
4
5
  declare function decodeSlug(value: bigint): string;
@@ -233,6 +234,18 @@ declare function getNextTierInfo(pupTokenAmount: number, normalizedAirDropAmount
233
234
  declare const USDC_SPOT_TOKEN: SpotToken;
234
235
  declare const TESTNET_USDC_SPOT_TOKEN: SpotToken;
235
236
 
237
+ interface PerpDex {
238
+ /** Short name of the perpetual dex. */
239
+ name: string;
240
+ /** Complete name of the perpetual dex. */
241
+ fullName: string;
242
+ /** Hex address of the dex deployer. */
243
+ deployer: Hex;
244
+ /** Hex address of the oracle updater, or null if not available. */
245
+ oracleUpdater: Hex | null;
246
+ feeRecipient: Hex | null;
247
+ assetToStreamingOiCap: [string, string][];
248
+ }
236
249
  /**
237
250
  * Market information for trading operations
238
251
  */
@@ -242,11 +255,15 @@ interface MarketInfo {
242
255
  szDecimals: number;
243
256
  type: "perps" | "spot" | "hip3";
244
257
  coin: string;
258
+ displayName?: string;
259
+ imageUrl?: string;
245
260
  maxLeverage?: number;
246
261
  baseToken?: SpotToken;
247
262
  quoteToken?: SpotToken;
248
263
  dexName?: string;
249
264
  dexIndex?: number;
265
+ dexDisplayName?: string;
266
+ dexImageUrl?: string;
250
267
  }
251
268
  interface DexInfo {
252
269
  meta: PerpsMeta;
@@ -255,6 +272,9 @@ interface DexInfo {
255
272
  dexName: string;
256
273
  dexIndex: number;
257
274
  collateralTokenSymbol: string;
275
+ displayName?: string;
276
+ imageUrl?: string;
277
+ accountName?: string;
258
278
  }
259
279
  type ExtendedPerpsMeta = PerpsMeta & {
260
280
  collateralToken?: number;
@@ -298,6 +318,7 @@ interface MetadataClientConfig {
298
318
  * - Spot: 10000 + index
299
319
  * - HIP-3: 100000 + perp_dex_index * 10000 + index_in_meta
300
320
  */
321
+ declare const ROOT_DEX = "hyperliquid";
301
322
  declare class MetadataClient {
302
323
  private infoClient;
303
324
  private config;
@@ -305,6 +326,7 @@ declare class MetadataClient {
305
326
  private spotMeta;
306
327
  private perpsMeta;
307
328
  private perpDexs;
329
+ private staticMeta;
308
330
  private hip3DexsMeta;
309
331
  private perpsSymbolToIndex;
310
332
  private spotTokenNameToIndex;
@@ -315,11 +337,17 @@ declare class MetadataClient {
315
337
  private hip3SymbolToMarket;
316
338
  private dexNameToIndex;
317
339
  private initialized;
340
+ private initializing;
318
341
  constructor(config?: MetadataClientConfig);
319
342
  /**
320
343
  * Initialize metadata by fetching from Hyperliquid
321
344
  */
322
345
  initialize(): Promise<void>;
346
+ /**
347
+ * Load staticMeta.json for display overrides
348
+ * This is always loaded regardless of config.useStaticFallback
349
+ */
350
+ private loadStaticMetaOverrides;
323
351
  /**
324
352
  * Load static metadata from bundled JSON files
325
353
  */
@@ -400,6 +428,12 @@ declare class MetadataClient {
400
428
  hip3DexsMeta: {
401
429
  [k: string]: DexInfo;
402
430
  };
431
+ coinToMarket: {
432
+ [k: string]: MarketInfo;
433
+ };
434
+ hip3SymbolToMarket: {
435
+ [k: string]: MarketInfo;
436
+ };
403
437
  };
404
438
  /**
405
439
  * Get network configuration
@@ -459,4 +493,4 @@ declare const formatSizeForOrder: ({ sz, szDecimals, }: {
459
493
  */
460
494
  declare function getPriceDecimals(price: number, szDecimals: number, isSpot: boolean): number;
461
495
 
462
- export { type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PupEligibilityResult, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, type TokenInfo, USDC_SPOT_TOKEN, type UpheavalApiResponse, type UpheavalPosition, type UpheavalSnapshot, type V3LPTokenInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, encodeSlug, formatPriceAndSize, formatPriceForOrder, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getNextTierInfo, getPriceDecimals, getWidgetTypeById, isBasedCloid, isClientCode, isMiniAppCloid, isMiniAppTriggeredCloid, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid };
496
+ export { type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PerpDex, type PupEligibilityResult, ROOT_DEX, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, type TokenInfo, USDC_SPOT_TOKEN, type UpheavalApiResponse, type UpheavalPosition, type UpheavalSnapshot, type V3LPTokenInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, encodeSlug, formatPriceAndSize, formatPriceForOrder, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getNextTierInfo, getPriceDecimals, getWidgetTypeById, isBasedCloid, isClientCode, isMiniAppCloid, isMiniAppTriggeredCloid, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta, PerpDex } from '@nktkas/hyperliquid';
1
+ import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta } from '@nktkas/hyperliquid';
2
+ import { Hex } from '@nktkas/hyperliquid/script/src/types/mod';
2
3
 
3
4
  declare function encodeSlug(slug: string): bigint;
4
5
  declare function decodeSlug(value: bigint): string;
@@ -233,6 +234,18 @@ declare function getNextTierInfo(pupTokenAmount: number, normalizedAirDropAmount
233
234
  declare const USDC_SPOT_TOKEN: SpotToken;
234
235
  declare const TESTNET_USDC_SPOT_TOKEN: SpotToken;
235
236
 
237
+ interface PerpDex {
238
+ /** Short name of the perpetual dex. */
239
+ name: string;
240
+ /** Complete name of the perpetual dex. */
241
+ fullName: string;
242
+ /** Hex address of the dex deployer. */
243
+ deployer: Hex;
244
+ /** Hex address of the oracle updater, or null if not available. */
245
+ oracleUpdater: Hex | null;
246
+ feeRecipient: Hex | null;
247
+ assetToStreamingOiCap: [string, string][];
248
+ }
236
249
  /**
237
250
  * Market information for trading operations
238
251
  */
@@ -242,11 +255,15 @@ interface MarketInfo {
242
255
  szDecimals: number;
243
256
  type: "perps" | "spot" | "hip3";
244
257
  coin: string;
258
+ displayName?: string;
259
+ imageUrl?: string;
245
260
  maxLeverage?: number;
246
261
  baseToken?: SpotToken;
247
262
  quoteToken?: SpotToken;
248
263
  dexName?: string;
249
264
  dexIndex?: number;
265
+ dexDisplayName?: string;
266
+ dexImageUrl?: string;
250
267
  }
251
268
  interface DexInfo {
252
269
  meta: PerpsMeta;
@@ -255,6 +272,9 @@ interface DexInfo {
255
272
  dexName: string;
256
273
  dexIndex: number;
257
274
  collateralTokenSymbol: string;
275
+ displayName?: string;
276
+ imageUrl?: string;
277
+ accountName?: string;
258
278
  }
259
279
  type ExtendedPerpsMeta = PerpsMeta & {
260
280
  collateralToken?: number;
@@ -298,6 +318,7 @@ interface MetadataClientConfig {
298
318
  * - Spot: 10000 + index
299
319
  * - HIP-3: 100000 + perp_dex_index * 10000 + index_in_meta
300
320
  */
321
+ declare const ROOT_DEX = "hyperliquid";
301
322
  declare class MetadataClient {
302
323
  private infoClient;
303
324
  private config;
@@ -305,6 +326,7 @@ declare class MetadataClient {
305
326
  private spotMeta;
306
327
  private perpsMeta;
307
328
  private perpDexs;
329
+ private staticMeta;
308
330
  private hip3DexsMeta;
309
331
  private perpsSymbolToIndex;
310
332
  private spotTokenNameToIndex;
@@ -315,11 +337,17 @@ declare class MetadataClient {
315
337
  private hip3SymbolToMarket;
316
338
  private dexNameToIndex;
317
339
  private initialized;
340
+ private initializing;
318
341
  constructor(config?: MetadataClientConfig);
319
342
  /**
320
343
  * Initialize metadata by fetching from Hyperliquid
321
344
  */
322
345
  initialize(): Promise<void>;
346
+ /**
347
+ * Load staticMeta.json for display overrides
348
+ * This is always loaded regardless of config.useStaticFallback
349
+ */
350
+ private loadStaticMetaOverrides;
323
351
  /**
324
352
  * Load static metadata from bundled JSON files
325
353
  */
@@ -400,6 +428,12 @@ declare class MetadataClient {
400
428
  hip3DexsMeta: {
401
429
  [k: string]: DexInfo;
402
430
  };
431
+ coinToMarket: {
432
+ [k: string]: MarketInfo;
433
+ };
434
+ hip3SymbolToMarket: {
435
+ [k: string]: MarketInfo;
436
+ };
403
437
  };
404
438
  /**
405
439
  * Get network configuration
@@ -459,4 +493,4 @@ declare const formatSizeForOrder: ({ sz, szDecimals, }: {
459
493
  */
460
494
  declare function getPriceDecimals(price: number, szDecimals: number, isSpot: boolean): number;
461
495
 
462
- export { type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PupEligibilityResult, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, type TokenInfo, USDC_SPOT_TOKEN, type UpheavalApiResponse, type UpheavalPosition, type UpheavalSnapshot, type V3LPTokenInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, encodeSlug, formatPriceAndSize, formatPriceForOrder, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getNextTierInfo, getPriceDecimals, getWidgetTypeById, isBasedCloid, isClientCode, isMiniAppCloid, isMiniAppTriggeredCloid, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid };
496
+ export { type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PerpDex, type PupEligibilityResult, ROOT_DEX, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, type TokenInfo, USDC_SPOT_TOKEN, type UpheavalApiResponse, type UpheavalPosition, type UpheavalSnapshot, type V3LPTokenInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, encodeSlug, formatPriceAndSize, formatPriceForOrder, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getNextTierInfo, getPriceDecimals, getWidgetTypeById, isBasedCloid, isClientCode, isMiniAppCloid, isMiniAppTriggeredCloid, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid };
package/dist/index.js CHANGED
@@ -35,6 +35,46 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
35
35
  ));
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
 
38
+ // lib/meta/data/mainnet/staticMeta.json
39
+ var require_staticMeta = __commonJS({
40
+ "lib/meta/data/mainnet/staticMeta.json"(exports2, module2) {
41
+ module2.exports = {
42
+ coins: {
43
+ "xyz:XYZ100": {
44
+ imageUrl: "https://app.based.one/hip3/xyz/xyz100.webp",
45
+ displayName: "Nasdaq-100"
46
+ }
47
+ },
48
+ dexs: {
49
+ xyz: {
50
+ imageUrl: "",
51
+ displayName: "Trade.xyz",
52
+ accountName: "Equities"
53
+ }
54
+ }
55
+ };
56
+ }
57
+ });
58
+
59
+ // lib/meta/data/testnet/staticMeta.json
60
+ var require_staticMeta2 = __commonJS({
61
+ "lib/meta/data/testnet/staticMeta.json"(exports2, module2) {
62
+ module2.exports = {
63
+ coins: {
64
+ "rrrrr:BTC": {
65
+ displayName: "BTCe"
66
+ }
67
+ },
68
+ dexs: {
69
+ rrrrr: {
70
+ displayName: "Hyena",
71
+ accountName: "USDe"
72
+ }
73
+ }
74
+ };
75
+ }
76
+ });
77
+
38
78
  // lib/meta/data/mainnet/spotMeta.json
39
79
  var require_spotMeta = __commonJS({
40
80
  "lib/meta/data/mainnet/spotMeta.json"(exports2, module2) {
@@ -36407,6 +36447,7 @@ __export(index_exports, {
36407
36447
  MetadataClient: () => MetadataClient,
36408
36448
  PUP_TOKEN_ADDRESS: () => PUP_TOKEN_ADDRESS,
36409
36449
  PUP_TOKEN_THRESHOLDS: () => PUP_TOKEN_THRESHOLDS,
36450
+ ROOT_DEX: () => ROOT_DEX,
36410
36451
  TARGET_APPROVED_MAX_BUILDER_FEE: () => TARGET_APPROVED_MAX_BUILDER_FEE,
36411
36452
  TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT: () => TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT,
36412
36453
  TESTNET_USDC_SPOT_TOKEN: () => TESTNET_USDC_SPOT_TOKEN,
@@ -36979,6 +37020,12 @@ function isHip3Symbol(symbol) {
36979
37020
  return symbol.includes(":");
36980
37021
  }
36981
37022
 
37023
+ // import("./data/**/*/staticMeta.json") in lib/meta/metadata.ts
37024
+ var globImport_data_staticMeta_json = __glob({
37025
+ "./data/mainnet/staticMeta.json": () => Promise.resolve().then(() => __toESM(require_staticMeta())),
37026
+ "./data/testnet/staticMeta.json": () => Promise.resolve().then(() => __toESM(require_staticMeta2()))
37027
+ });
37028
+
36982
37029
  // import("./data/**/*/spotMeta.json") in lib/meta/metadata.ts
36983
37030
  var globImport_data_spotMeta_json = __glob({
36984
37031
  "./data/mainnet/spotMeta.json": () => Promise.resolve().then(() => __toESM(require_spotMeta())),
@@ -36998,12 +37045,14 @@ var globImport_data_perpDexs_json = __glob({
36998
37045
  });
36999
37046
 
37000
37047
  // lib/meta/metadata.ts
37048
+ var ROOT_DEX = "hyperliquid";
37001
37049
  var MetadataClient = class {
37002
37050
  constructor(config = {}) {
37003
37051
  // Core metadata
37004
37052
  this.spotMeta = null;
37005
37053
  this.perpsMeta = null;
37006
37054
  this.perpDexs = [];
37055
+ this.staticMeta = null;
37007
37056
  // HIP-3 metadata cache
37008
37057
  this.hip3DexsMeta = /* @__PURE__ */ new Map();
37009
37058
  // Pre-computed lookup maps (populated on initialize)
@@ -37022,12 +37071,14 @@ var MetadataClient = class {
37022
37071
  this.dexNameToIndex = /* @__PURE__ */ new Map();
37023
37072
  // Lazy init flag
37024
37073
  this.initialized = false;
37074
+ this.initializing = null;
37025
37075
  const transport = new import_hyperliquid.HttpTransport({
37026
37076
  isTestnet: config.isTestnet ?? false
37027
37077
  });
37028
37078
  this.infoClient = new import_hyperliquid.InfoClient({ transport });
37029
37079
  this.config = {
37030
37080
  ...config,
37081
+ hip3Dexs: config.hip3Dexs?.filter((dex) => dex !== ROOT_DEX),
37031
37082
  useStaticFallback: config.useStaticFallback ?? true
37032
37083
  };
37033
37084
  this.isTestnet = config.isTestnet ?? false;
@@ -37038,42 +37089,67 @@ var MetadataClient = class {
37038
37089
  */
37039
37090
  async initialize() {
37040
37091
  if (this.initialized) return;
37041
- if (this.config.onlyUseStaticFallback) {
37042
- await this.loadStaticMetadata();
37043
- this.buildLookupMaps();
37044
- if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
37045
- await Promise.all(
37046
- this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
37047
- );
37048
- }
37049
- this.initialized = true;
37050
- return;
37051
- }
37052
- try {
37053
- [this.spotMeta, this.perpsMeta, this.perpDexs] = await Promise.all([
37054
- this.infoClient.spotMeta(),
37055
- this.infoClient.meta(),
37056
- this.infoClient.perpDexs()
37057
- ]);
37058
- this.buildLookupMaps();
37059
- if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
37060
- await Promise.all(
37061
- this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
37062
- );
37063
- }
37064
- this.initialized = true;
37065
- } catch (error) {
37066
- if (this.config.useStaticFallback) {
37067
- console.warn(
37068
- "Failed to fetch metadata from API, using static fallback data",
37069
- error
37070
- );
37092
+ if (this.initializing) return this.initializing;
37093
+ this.initializing = new Promise(async (resolve, reject) => {
37094
+ await this.loadStaticMetaOverrides();
37095
+ if (this.config.onlyUseStaticFallback) {
37071
37096
  await this.loadStaticMetadata();
37072
37097
  this.buildLookupMaps();
37098
+ if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
37099
+ await Promise.all(
37100
+ this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
37101
+ );
37102
+ }
37103
+ resolve();
37104
+ this.initialized = true;
37105
+ return;
37106
+ }
37107
+ try {
37108
+ [this.spotMeta, this.perpsMeta, this.perpDexs] = await Promise.all([
37109
+ this.infoClient.spotMeta(),
37110
+ this.infoClient.meta(),
37111
+ this.infoClient.perpDexs()
37112
+ ]);
37113
+ this.buildLookupMaps();
37114
+ if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
37115
+ await Promise.all(
37116
+ this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
37117
+ );
37118
+ }
37119
+ this.initialized = true;
37120
+ resolve();
37121
+ } catch (error) {
37122
+ if (this.config.useStaticFallback) {
37123
+ console.warn(
37124
+ "Failed to fetch metadata from API, using static fallback data",
37125
+ error
37126
+ );
37127
+ await this.loadStaticMetadata();
37128
+ this.buildLookupMaps();
37129
+ this.initialized = true;
37130
+ resolve();
37131
+ } else {
37132
+ reject(error);
37133
+ }
37134
+ } finally {
37073
37135
  this.initialized = true;
37074
- } else {
37075
- throw error;
37136
+ resolve();
37076
37137
  }
37138
+ });
37139
+ return this.initializing;
37140
+ }
37141
+ /**
37142
+ * Load staticMeta.json for display overrides
37143
+ * This is always loaded regardless of config.useStaticFallback
37144
+ */
37145
+ async loadStaticMetaOverrides() {
37146
+ const network = this.isTestnet ? "testnet" : "mainnet";
37147
+ try {
37148
+ const staticMetaModule = await globImport_data_staticMeta_json(`./data/${network}/staticMeta.json`);
37149
+ this.staticMeta = staticMetaModule.default;
37150
+ } catch (error) {
37151
+ console.warn(`Failed to load staticMeta.json for ${network}:`, error);
37152
+ this.staticMeta = null;
37077
37153
  }
37078
37154
  }
37079
37155
  /**
@@ -37082,14 +37158,21 @@ var MetadataClient = class {
37082
37158
  async loadStaticMetadata() {
37083
37159
  const network = this.isTestnet ? "testnet" : "mainnet";
37084
37160
  try {
37085
- const [spotMetaModule, perpsMetaModule, perpDexsModule] = await Promise.all([
37161
+ const [
37162
+ spotMetaModule,
37163
+ perpsMetaModule,
37164
+ perpDexsModule,
37165
+ staticMetaModule
37166
+ ] = await Promise.all([
37086
37167
  globImport_data_spotMeta_json(`./data/${network}/spotMeta.json`),
37087
37168
  globImport_data_meta_json(`./data/${network}/meta.json`),
37088
- globImport_data_perpDexs_json(`./data/${network}/perpDexs.json`)
37169
+ globImport_data_perpDexs_json(`./data/${network}/perpDexs.json`),
37170
+ globImport_data_staticMeta_json(`./data/${network}/staticMeta.json`)
37089
37171
  ]);
37090
37172
  this.spotMeta = spotMetaModule.default;
37091
37173
  this.perpsMeta = perpsMetaModule.default;
37092
37174
  this.perpDexs = perpDexsModule.default;
37175
+ this.staticMeta = staticMetaModule.default;
37093
37176
  console.warn(`Using static ${network} metadata`);
37094
37177
  } catch (error) {
37095
37178
  console.error(`Failed to load static ${network} metadata:`, error);
@@ -37106,9 +37189,14 @@ var MetadataClient = class {
37106
37189
  this.spotPairToMarket.clear();
37107
37190
  this.baseTokenToMarkets.clear();
37108
37191
  this.coinToMarket.clear();
37109
- this.hip3SymbolToMarket.clear();
37110
37192
  this.dexNameToIndex.clear();
37111
37193
  this.quoteAssets = [];
37194
+ console.info(
37195
+ "[MetadataClient] Building lookup maps",
37196
+ this.perpDexs,
37197
+ this.perpsMeta,
37198
+ this.spotMeta
37199
+ );
37112
37200
  if (this.perpDexs) {
37113
37201
  this.perpDexs.forEach((dex, index) => {
37114
37202
  if (dex && dex.name) {
@@ -37126,6 +37214,15 @@ var MetadataClient = class {
37126
37214
  type: "perps",
37127
37215
  maxLeverage: market.maxLeverage
37128
37216
  };
37217
+ const staticOverrides = this.staticMeta?.coins?.[market.name];
37218
+ if (staticOverrides) {
37219
+ if (staticOverrides.displayName) {
37220
+ marketInfo.displayName = staticOverrides.displayName;
37221
+ }
37222
+ if (staticOverrides.imageUrl) {
37223
+ marketInfo.imageUrl = staticOverrides.imageUrl;
37224
+ }
37225
+ }
37129
37226
  this.perpsSymbolToIndex.set(market.name.toUpperCase(), index);
37130
37227
  this.coinToMarket.set(market.name, marketInfo);
37131
37228
  });
@@ -37150,6 +37247,15 @@ var MetadataClient = class {
37150
37247
  baseToken,
37151
37248
  quoteToken
37152
37249
  };
37250
+ const staticOverrides = this.staticMeta?.coins?.[coin];
37251
+ if (staticOverrides) {
37252
+ if (staticOverrides.displayName) {
37253
+ marketInfo.displayName = staticOverrides.displayName;
37254
+ }
37255
+ if (staticOverrides.imageUrl) {
37256
+ marketInfo.imageUrl = staticOverrides.imageUrl;
37257
+ }
37258
+ }
37153
37259
  const pairKey = `${baseToken.name}/${quoteToken.name}`.toUpperCase();
37154
37260
  this.spotPairToMarket.set(pairKey, marketInfo);
37155
37261
  this.coinToMarket.set(pairKey, marketInfo);
@@ -37189,10 +37295,22 @@ var MetadataClient = class {
37189
37295
  meta,
37190
37296
  assetContext: contexts,
37191
37297
  collateralTokenSymbol,
37192
- dexFullName: dex?.full_name ?? dexName,
37298
+ dexFullName: dex?.fullName ?? dexName,
37193
37299
  dexName: dex?.name ?? dexName,
37194
37300
  dexIndex
37195
37301
  };
37302
+ const staticDexOverrides = this.staticMeta?.dexs?.[dexName];
37303
+ if (staticDexOverrides) {
37304
+ if (staticDexOverrides.displayName) {
37305
+ dexInfo.displayName = staticDexOverrides.displayName;
37306
+ }
37307
+ if (staticDexOverrides.imageUrl) {
37308
+ dexInfo.imageUrl = staticDexOverrides.imageUrl;
37309
+ }
37310
+ if (staticDexOverrides.accountName) {
37311
+ dexInfo.accountName = staticDexOverrides.accountName;
37312
+ }
37313
+ }
37196
37314
  this.hip3DexsMeta.set(dexName, dexInfo);
37197
37315
  this.buildHip3MarketsForDex(dexName, dexInfo);
37198
37316
  return dexInfo;
@@ -37215,8 +37333,20 @@ var MetadataClient = class {
37215
37333
  type: "hip3",
37216
37334
  maxLeverage: market.maxLeverage,
37217
37335
  dexName,
37218
- dexIndex: dexInfo.dexIndex
37336
+ dexIndex: dexInfo.dexIndex,
37337
+ dexDisplayName: dexInfo.displayName,
37338
+ dexImageUrl: dexInfo.imageUrl
37219
37339
  };
37340
+ const staticOverrides = this.staticMeta?.coins?.[symbol];
37341
+ if (staticOverrides) {
37342
+ if (staticOverrides.displayName) {
37343
+ marketInfo.displayName = staticOverrides.displayName;
37344
+ }
37345
+ if (staticOverrides.imageUrl) {
37346
+ marketInfo.imageUrl = staticOverrides.imageUrl;
37347
+ }
37348
+ }
37349
+ console.info("[MetadataClient] caching market", symbol, marketInfo);
37220
37350
  this.coinToMarket.set(symbol, marketInfo);
37221
37351
  this.hip3SymbolToMarket.set(symbol, marketInfo);
37222
37352
  });
@@ -37245,7 +37375,7 @@ var MetadataClient = class {
37245
37375
  }
37246
37376
  let lookupKey = symbol.toUpperCase();
37247
37377
  if (!symbol.includes("/") && !symbol.includes("@")) {
37248
- const perpsMarket = this.coinToMarket.get(lookupKey);
37378
+ const perpsMarket = this.coinToMarket.get(symbol);
37249
37379
  if (perpsMarket?.type === "perps") {
37250
37380
  return perpsMarket;
37251
37381
  }
@@ -37305,6 +37435,7 @@ var MetadataClient = class {
37305
37435
  if (!dexName || !coinName) return null;
37306
37436
  let cachedMarket = this.hip3SymbolToMarket.get(symbol);
37307
37437
  if (cachedMarket) return cachedMarket;
37438
+ console.warn("Missing market", symbol, this.hip3SymbolToMarket);
37308
37439
  const dexMeta = this.hip3DexsMeta.get(dexName);
37309
37440
  if (!dexMeta && this.config.lazyInit) {
37310
37441
  await this.loadHip3Metadata(dexName);
@@ -37363,7 +37494,9 @@ var MetadataClient = class {
37363
37494
  spotMeta: this.spotMeta,
37364
37495
  perpsMeta: this.perpsMeta,
37365
37496
  perpDexs: this.perpDexs,
37366
- hip3DexsMeta: Object.fromEntries(this.hip3DexsMeta)
37497
+ hip3DexsMeta: Object.fromEntries(this.hip3DexsMeta),
37498
+ coinToMarket: Object.fromEntries(this.coinToMarket),
37499
+ hip3SymbolToMarket: Object.fromEntries(this.hip3SymbolToMarket)
37367
37500
  };
37368
37501
  }
37369
37502
  /**
@@ -37430,6 +37563,7 @@ function getPriceDecimals(price, szDecimals, isSpot) {
37430
37563
  MetadataClient,
37431
37564
  PUP_TOKEN_ADDRESS,
37432
37565
  PUP_TOKEN_THRESHOLDS,
37566
+ ROOT_DEX,
37433
37567
  TARGET_APPROVED_MAX_BUILDER_FEE,
37434
37568
  TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT,
37435
37569
  TESTNET_USDC_SPOT_TOKEN,