@basedone/core 0.1.3 → 0.1.5

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
@@ -266,6 +266,7 @@ interface MarketInfo {
266
266
  dexIndex?: number;
267
267
  dexDisplayName?: string;
268
268
  dexImageUrl?: string;
269
+ dexCollateralTokenSymbol?: string;
269
270
  }
270
271
  interface DexInfo {
271
272
  meta: PerpsMeta;
package/dist/index.d.ts CHANGED
@@ -266,6 +266,7 @@ interface MarketInfo {
266
266
  dexIndex?: number;
267
267
  dexDisplayName?: string;
268
268
  dexImageUrl?: string;
269
+ dexCollateralTokenSymbol?: string;
269
270
  }
270
271
  interface DexInfo {
271
272
  meta: PerpsMeta;
package/dist/index.js CHANGED
@@ -37735,6 +37735,9 @@ var MetadataClient = class {
37735
37735
  if (this.initialized) return;
37736
37736
  if (this.initializing) return this.initializing;
37737
37737
  this.initializing = new Promise(async (resolve, reject) => {
37738
+ if (this.config.debug) {
37739
+ console.info("[MetadataClient] Initializing...", this.config);
37740
+ }
37738
37741
  await this.loadStaticMetaOverrides();
37739
37742
  if (this.config.onlyUseStaticFallback) {
37740
37743
  await this.loadStaticMetadata();
@@ -37754,6 +37757,14 @@ var MetadataClient = class {
37754
37757
  this.infoClient.meta(),
37755
37758
  this.infoClient.perpDexs()
37756
37759
  ]);
37760
+ if (this.config.debug) {
37761
+ console.info(
37762
+ "[MetadataClient] Core metadata",
37763
+ this.spotMeta,
37764
+ this.perpsMeta,
37765
+ this.perpDexs
37766
+ );
37767
+ }
37757
37768
  this.buildLookupMaps();
37758
37769
  if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
37759
37770
  await Promise.all(
@@ -37761,6 +37772,9 @@ var MetadataClient = class {
37761
37772
  );
37762
37773
  }
37763
37774
  this.initialized = true;
37775
+ if (this.config.debug) {
37776
+ console.info("[MetadataClient] Initialized");
37777
+ }
37764
37778
  resolve();
37765
37779
  } catch (error) {
37766
37780
  if (this.config.useStaticFallback) {
@@ -37791,6 +37805,12 @@ var MetadataClient = class {
37791
37805
  try {
37792
37806
  const staticMetaModule = await globImport_data_staticMeta_json(`./data/${network}/staticMeta.json`);
37793
37807
  this.staticMeta = staticMetaModule.default;
37808
+ if (this.config.debug) {
37809
+ console.info(
37810
+ "[MetadataClient] Loaded static metadata overrides",
37811
+ this.staticMeta
37812
+ );
37813
+ }
37794
37814
  } catch (error) {
37795
37815
  console.warn(`Failed to load staticMeta.json for ${network}:`, error);
37796
37816
  this.staticMeta = null;
@@ -37817,7 +37837,7 @@ var MetadataClient = class {
37817
37837
  this.perpsMeta = perpsMetaModule.default;
37818
37838
  this.perpDexs = perpDexsModule.default;
37819
37839
  this.staticMeta = staticMetaModule.default;
37820
- console.warn(`Using static ${network} metadata`);
37840
+ console.warn(`[MetadataClient] Using static ${network} metadata`);
37821
37841
  } catch (error) {
37822
37842
  console.error(`Failed to load static ${network} metadata:`, error);
37823
37843
  throw new Error(`Could not load metadata for ${network}`);
@@ -37924,6 +37944,14 @@ var MetadataClient = class {
37924
37944
  const [meta, contexts] = await this.infoClient.metaAndAssetCtxs({
37925
37945
  dex: dexName
37926
37946
  });
37947
+ if (this.config.debug) {
37948
+ console.info(
37949
+ "[MetadataClient] Loaded HIP-3 metadata",
37950
+ dexName,
37951
+ meta,
37952
+ contexts
37953
+ );
37954
+ }
37927
37955
  let dexIndex = this.dexNameToIndex.get(dexName.toLowerCase());
37928
37956
  if (dexIndex === void 0) {
37929
37957
  dexIndex = this.perpDexs.findIndex(
@@ -37981,7 +38009,8 @@ var MetadataClient = class {
37981
38009
  dexName,
37982
38010
  dexIndex: dexInfo.dexIndex,
37983
38011
  dexDisplayName: dexInfo.displayName,
37984
- dexImageUrl: dexInfo.imageUrl
38012
+ dexImageUrl: dexInfo.imageUrl,
38013
+ dexCollateralTokenSymbol: dexInfo.collateralTokenSymbol
37985
38014
  };
37986
38015
  const staticOverrides = this.staticMeta?.coins?.[symbol];
37987
38016
  if (staticOverrides) {
package/dist/index.mjs CHANGED
@@ -678,6 +678,9 @@ var MetadataClient = class {
678
678
  if (this.initialized) return;
679
679
  if (this.initializing) return this.initializing;
680
680
  this.initializing = new Promise(async (resolve, reject) => {
681
+ if (this.config.debug) {
682
+ console.info("[MetadataClient] Initializing...", this.config);
683
+ }
681
684
  await this.loadStaticMetaOverrides();
682
685
  if (this.config.onlyUseStaticFallback) {
683
686
  await this.loadStaticMetadata();
@@ -697,6 +700,14 @@ var MetadataClient = class {
697
700
  this.infoClient.meta(),
698
701
  this.infoClient.perpDexs()
699
702
  ]);
703
+ if (this.config.debug) {
704
+ console.info(
705
+ "[MetadataClient] Core metadata",
706
+ this.spotMeta,
707
+ this.perpsMeta,
708
+ this.perpDexs
709
+ );
710
+ }
700
711
  this.buildLookupMaps();
701
712
  if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
702
713
  await Promise.all(
@@ -704,6 +715,9 @@ var MetadataClient = class {
704
715
  );
705
716
  }
706
717
  this.initialized = true;
718
+ if (this.config.debug) {
719
+ console.info("[MetadataClient] Initialized");
720
+ }
707
721
  resolve();
708
722
  } catch (error) {
709
723
  if (this.config.useStaticFallback) {
@@ -734,6 +748,12 @@ var MetadataClient = class {
734
748
  try {
735
749
  const staticMetaModule = await globImport_data_staticMeta_json(`./data/${network}/staticMeta.json`);
736
750
  this.staticMeta = staticMetaModule.default;
751
+ if (this.config.debug) {
752
+ console.info(
753
+ "[MetadataClient] Loaded static metadata overrides",
754
+ this.staticMeta
755
+ );
756
+ }
737
757
  } catch (error) {
738
758
  console.warn(`Failed to load staticMeta.json for ${network}:`, error);
739
759
  this.staticMeta = null;
@@ -760,7 +780,7 @@ var MetadataClient = class {
760
780
  this.perpsMeta = perpsMetaModule.default;
761
781
  this.perpDexs = perpDexsModule.default;
762
782
  this.staticMeta = staticMetaModule.default;
763
- console.warn(`Using static ${network} metadata`);
783
+ console.warn(`[MetadataClient] Using static ${network} metadata`);
764
784
  } catch (error) {
765
785
  console.error(`Failed to load static ${network} metadata:`, error);
766
786
  throw new Error(`Could not load metadata for ${network}`);
@@ -867,6 +887,14 @@ var MetadataClient = class {
867
887
  const [meta, contexts] = await this.infoClient.metaAndAssetCtxs({
868
888
  dex: dexName
869
889
  });
890
+ if (this.config.debug) {
891
+ console.info(
892
+ "[MetadataClient] Loaded HIP-3 metadata",
893
+ dexName,
894
+ meta,
895
+ contexts
896
+ );
897
+ }
870
898
  let dexIndex = this.dexNameToIndex.get(dexName.toLowerCase());
871
899
  if (dexIndex === void 0) {
872
900
  dexIndex = this.perpDexs.findIndex(
@@ -924,7 +952,8 @@ var MetadataClient = class {
924
952
  dexName,
925
953
  dexIndex: dexInfo.dexIndex,
926
954
  dexDisplayName: dexInfo.displayName,
927
- dexImageUrl: dexInfo.imageUrl
955
+ dexImageUrl: dexInfo.imageUrl,
956
+ dexCollateralTokenSymbol: dexInfo.collateralTokenSymbol
928
957
  };
929
958
  const staticOverrides = this.staticMeta?.coins?.[symbol];
930
959
  if (staticOverrides) {
@@ -47,6 +47,7 @@ export interface MarketInfo {
47
47
  dexIndex?: number; // DEX index for asset ID calculation
48
48
  dexDisplayName?: string; // Display name override for the DEX
49
49
  dexImageUrl?: string; // Image URL override for the DEX
50
+ dexCollateralTokenSymbol?: string; // Collateral token symbol for HIP-3 markets
50
51
  }
51
52
 
52
53
  export interface DexInfo {
@@ -175,6 +176,7 @@ export class MetadataClient {
175
176
  useStaticFallback: config.useStaticFallback ?? true,
176
177
  };
177
178
  this.isTestnet = config.isTestnet ?? false;
179
+
178
180
  this.initialize();
179
181
  }
180
182
 
@@ -185,6 +187,9 @@ export class MetadataClient {
185
187
  if (this.initialized) return;
186
188
  if (this.initializing) return this.initializing;
187
189
  this.initializing = new Promise(async (resolve, reject) => {
190
+ if (this.config.debug) {
191
+ console.info("[MetadataClient] Initializing...", this.config);
192
+ }
188
193
  // Always load staticMeta.json regardless of config.useStaticFallback
189
194
  await this.loadStaticMetaOverrides();
190
195
 
@@ -211,6 +216,15 @@ export class MetadataClient {
211
216
  this.infoClient.perpDexs() as Promise<PerpDex[] | null[]>,
212
217
  ]);
213
218
 
219
+ if (this.config.debug) {
220
+ console.info(
221
+ "[MetadataClient] Core metadata",
222
+ this.spotMeta,
223
+ this.perpsMeta,
224
+ this.perpDexs,
225
+ );
226
+ }
227
+
214
228
  // Build optimized lookup maps
215
229
  this.buildLookupMaps();
216
230
 
@@ -221,6 +235,9 @@ export class MetadataClient {
221
235
  );
222
236
  }
223
237
  this.initialized = true;
238
+ if (this.config.debug) {
239
+ console.info("[MetadataClient] Initialized");
240
+ }
224
241
  resolve();
225
242
  } catch (error) {
226
243
  // Fall back to static data if API fetch fails and fallback is enabled
@@ -256,6 +273,12 @@ export class MetadataClient {
256
273
  `./data/${network}/staticMeta.json`
257
274
  );
258
275
  this.staticMeta = staticMetaModule.default as StaticMetadata;
276
+ if (this.config.debug) {
277
+ console.info(
278
+ "[MetadataClient] Loaded static metadata overrides",
279
+ this.staticMeta,
280
+ );
281
+ }
259
282
  } catch (error) {
260
283
  console.warn(`Failed to load staticMeta.json for ${network}:`, error);
261
284
  this.staticMeta = null;
@@ -287,7 +310,7 @@ export class MetadataClient {
287
310
  this.perpDexs = perpDexsModule.default as (PerpDex | null)[];
288
311
  this.staticMeta = staticMetaModule.default as StaticMetadata;
289
312
 
290
- console.warn(`Using static ${network} metadata`);
313
+ console.warn(`[MetadataClient] Using static ${network} metadata`);
291
314
  } catch (error) {
292
315
  console.error(`Failed to load static ${network} metadata:`, error);
293
316
  throw new Error(`Could not load metadata for ${network}`);
@@ -435,6 +458,15 @@ export class MetadataClient {
435
458
  dex: dexName,
436
459
  });
437
460
 
461
+ if (this.config.debug) {
462
+ console.info(
463
+ "[MetadataClient] Loaded HIP-3 metadata",
464
+ dexName,
465
+ meta,
466
+ contexts,
467
+ );
468
+ }
469
+
438
470
  // O(1) lookup using pre-computed map
439
471
  let dexIndex = this.dexNameToIndex.get(dexName.toLowerCase());
440
472
 
@@ -512,6 +544,7 @@ export class MetadataClient {
512
544
  dexIndex: dexInfo.dexIndex,
513
545
  dexDisplayName: dexInfo.displayName,
514
546
  dexImageUrl: dexInfo.imageUrl,
547
+ dexCollateralTokenSymbol: dexInfo.collateralTokenSymbol,
515
548
  };
516
549
 
517
550
  // Apply static metadata overrides for HIP-3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basedone/core",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Core utilities for Based One",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",