@basedone/core 0.0.7 → 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 +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +63 -38
- package/dist/index.mjs +61 -38
- package/dist/staticMeta-D2V74GCG.mjs +23 -0
- package/dist/staticMeta-GM7T3OYL.mjs +23 -0
- package/dist/staticMeta-OKNVBUQ5.mjs +25 -0
- package/dist/staticMeta-QV2KMX57.mjs +25 -0
- package/lib/meta/data/mainnet/staticMeta.json +2 -1
- package/lib/meta/data/testnet/staticMeta.json +2 -1
- package/lib/meta/metadata.ts +69 -45
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -274,6 +274,7 @@ interface DexInfo {
|
|
|
274
274
|
collateralTokenSymbol: string;
|
|
275
275
|
displayName?: string;
|
|
276
276
|
imageUrl?: string;
|
|
277
|
+
accountName?: string;
|
|
277
278
|
}
|
|
278
279
|
type ExtendedPerpsMeta = PerpsMeta & {
|
|
279
280
|
collateralToken?: number;
|
|
@@ -336,6 +337,7 @@ declare class MetadataClient {
|
|
|
336
337
|
private hip3SymbolToMarket;
|
|
337
338
|
private dexNameToIndex;
|
|
338
339
|
private initialized;
|
|
340
|
+
private initializing;
|
|
339
341
|
constructor(config?: MetadataClientConfig);
|
|
340
342
|
/**
|
|
341
343
|
* Initialize metadata by fetching from Hyperliquid
|
|
@@ -426,6 +428,12 @@ declare class MetadataClient {
|
|
|
426
428
|
hip3DexsMeta: {
|
|
427
429
|
[k: string]: DexInfo;
|
|
428
430
|
};
|
|
431
|
+
coinToMarket: {
|
|
432
|
+
[k: string]: MarketInfo;
|
|
433
|
+
};
|
|
434
|
+
hip3SymbolToMarket: {
|
|
435
|
+
[k: string]: MarketInfo;
|
|
436
|
+
};
|
|
429
437
|
};
|
|
430
438
|
/**
|
|
431
439
|
* Get network configuration
|
package/dist/index.d.ts
CHANGED
|
@@ -274,6 +274,7 @@ interface DexInfo {
|
|
|
274
274
|
collateralTokenSymbol: string;
|
|
275
275
|
displayName?: string;
|
|
276
276
|
imageUrl?: string;
|
|
277
|
+
accountName?: string;
|
|
277
278
|
}
|
|
278
279
|
type ExtendedPerpsMeta = PerpsMeta & {
|
|
279
280
|
collateralToken?: number;
|
|
@@ -336,6 +337,7 @@ declare class MetadataClient {
|
|
|
336
337
|
private hip3SymbolToMarket;
|
|
337
338
|
private dexNameToIndex;
|
|
338
339
|
private initialized;
|
|
340
|
+
private initializing;
|
|
339
341
|
constructor(config?: MetadataClientConfig);
|
|
340
342
|
/**
|
|
341
343
|
* Initialize metadata by fetching from Hyperliquid
|
|
@@ -426,6 +428,12 @@ declare class MetadataClient {
|
|
|
426
428
|
hip3DexsMeta: {
|
|
427
429
|
[k: string]: DexInfo;
|
|
428
430
|
};
|
|
431
|
+
coinToMarket: {
|
|
432
|
+
[k: string]: MarketInfo;
|
|
433
|
+
};
|
|
434
|
+
hip3SymbolToMarket: {
|
|
435
|
+
[k: string]: MarketInfo;
|
|
436
|
+
};
|
|
429
437
|
};
|
|
430
438
|
/**
|
|
431
439
|
* Get network configuration
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,8 @@ var require_staticMeta = __commonJS({
|
|
|
48
48
|
dexs: {
|
|
49
49
|
xyz: {
|
|
50
50
|
imageUrl: "",
|
|
51
|
-
displayName: "
|
|
51
|
+
displayName: "Trade.xyz",
|
|
52
|
+
accountName: "Equities"
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
};
|
|
@@ -66,7 +67,8 @@ var require_staticMeta2 = __commonJS({
|
|
|
66
67
|
},
|
|
67
68
|
dexs: {
|
|
68
69
|
rrrrr: {
|
|
69
|
-
displayName: "Hyena"
|
|
70
|
+
displayName: "Hyena",
|
|
71
|
+
accountName: "USDe"
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
};
|
|
@@ -37069,6 +37071,7 @@ var MetadataClient = class {
|
|
|
37069
37071
|
this.dexNameToIndex = /* @__PURE__ */ new Map();
|
|
37070
37072
|
// Lazy init flag
|
|
37071
37073
|
this.initialized = false;
|
|
37074
|
+
this.initializing = null;
|
|
37072
37075
|
const transport = new import_hyperliquid.HttpTransport({
|
|
37073
37076
|
isTestnet: config.isTestnet ?? false
|
|
37074
37077
|
});
|
|
@@ -37086,44 +37089,54 @@ var MetadataClient = class {
|
|
|
37086
37089
|
*/
|
|
37087
37090
|
async initialize() {
|
|
37088
37091
|
if (this.initialized) return;
|
|
37089
|
-
|
|
37090
|
-
|
|
37091
|
-
await this.
|
|
37092
|
-
this.
|
|
37093
|
-
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
37094
|
-
await Promise.all(
|
|
37095
|
-
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
|
|
37096
|
-
);
|
|
37097
|
-
}
|
|
37098
|
-
this.initialized = true;
|
|
37099
|
-
return;
|
|
37100
|
-
}
|
|
37101
|
-
try {
|
|
37102
|
-
[this.spotMeta, this.perpsMeta, this.perpDexs] = await Promise.all([
|
|
37103
|
-
this.infoClient.spotMeta(),
|
|
37104
|
-
this.infoClient.meta(),
|
|
37105
|
-
this.infoClient.perpDexs()
|
|
37106
|
-
]);
|
|
37107
|
-
this.buildLookupMaps();
|
|
37108
|
-
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
37109
|
-
await Promise.all(
|
|
37110
|
-
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
|
|
37111
|
-
);
|
|
37112
|
-
}
|
|
37113
|
-
this.initialized = true;
|
|
37114
|
-
} catch (error) {
|
|
37115
|
-
if (this.config.useStaticFallback) {
|
|
37116
|
-
console.warn(
|
|
37117
|
-
"Failed to fetch metadata from API, using static fallback data",
|
|
37118
|
-
error
|
|
37119
|
-
);
|
|
37092
|
+
if (this.initializing) return this.initializing;
|
|
37093
|
+
this.initializing = new Promise(async (resolve, reject) => {
|
|
37094
|
+
await this.loadStaticMetaOverrides();
|
|
37095
|
+
if (this.config.onlyUseStaticFallback) {
|
|
37120
37096
|
await this.loadStaticMetadata();
|
|
37121
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 {
|
|
37122
37135
|
this.initialized = true;
|
|
37123
|
-
|
|
37124
|
-
throw error;
|
|
37136
|
+
resolve();
|
|
37125
37137
|
}
|
|
37126
|
-
}
|
|
37138
|
+
});
|
|
37139
|
+
return this.initializing;
|
|
37127
37140
|
}
|
|
37128
37141
|
/**
|
|
37129
37142
|
* Load staticMeta.json for display overrides
|
|
@@ -37176,9 +37189,14 @@ var MetadataClient = class {
|
|
|
37176
37189
|
this.spotPairToMarket.clear();
|
|
37177
37190
|
this.baseTokenToMarkets.clear();
|
|
37178
37191
|
this.coinToMarket.clear();
|
|
37179
|
-
this.hip3SymbolToMarket.clear();
|
|
37180
37192
|
this.dexNameToIndex.clear();
|
|
37181
37193
|
this.quoteAssets = [];
|
|
37194
|
+
console.info(
|
|
37195
|
+
"[MetadataClient] Building lookup maps",
|
|
37196
|
+
this.perpDexs,
|
|
37197
|
+
this.perpsMeta,
|
|
37198
|
+
this.spotMeta
|
|
37199
|
+
);
|
|
37182
37200
|
if (this.perpDexs) {
|
|
37183
37201
|
this.perpDexs.forEach((dex, index) => {
|
|
37184
37202
|
if (dex && dex.name) {
|
|
@@ -37289,6 +37307,9 @@ var MetadataClient = class {
|
|
|
37289
37307
|
if (staticDexOverrides.imageUrl) {
|
|
37290
37308
|
dexInfo.imageUrl = staticDexOverrides.imageUrl;
|
|
37291
37309
|
}
|
|
37310
|
+
if (staticDexOverrides.accountName) {
|
|
37311
|
+
dexInfo.accountName = staticDexOverrides.accountName;
|
|
37312
|
+
}
|
|
37292
37313
|
}
|
|
37293
37314
|
this.hip3DexsMeta.set(dexName, dexInfo);
|
|
37294
37315
|
this.buildHip3MarketsForDex(dexName, dexInfo);
|
|
@@ -37325,6 +37346,7 @@ var MetadataClient = class {
|
|
|
37325
37346
|
marketInfo.imageUrl = staticOverrides.imageUrl;
|
|
37326
37347
|
}
|
|
37327
37348
|
}
|
|
37349
|
+
console.info("[MetadataClient] caching market", symbol, marketInfo);
|
|
37328
37350
|
this.coinToMarket.set(symbol, marketInfo);
|
|
37329
37351
|
this.hip3SymbolToMarket.set(symbol, marketInfo);
|
|
37330
37352
|
});
|
|
@@ -37413,6 +37435,7 @@ var MetadataClient = class {
|
|
|
37413
37435
|
if (!dexName || !coinName) return null;
|
|
37414
37436
|
let cachedMarket = this.hip3SymbolToMarket.get(symbol);
|
|
37415
37437
|
if (cachedMarket) return cachedMarket;
|
|
37438
|
+
console.warn("Missing market", symbol, this.hip3SymbolToMarket);
|
|
37416
37439
|
const dexMeta = this.hip3DexsMeta.get(dexName);
|
|
37417
37440
|
if (!dexMeta && this.config.lazyInit) {
|
|
37418
37441
|
await this.loadHip3Metadata(dexName);
|
|
@@ -37471,7 +37494,9 @@ var MetadataClient = class {
|
|
|
37471
37494
|
spotMeta: this.spotMeta,
|
|
37472
37495
|
perpsMeta: this.perpsMeta,
|
|
37473
37496
|
perpDexs: this.perpDexs,
|
|
37474
|
-
hip3DexsMeta: Object.fromEntries(this.hip3DexsMeta)
|
|
37497
|
+
hip3DexsMeta: Object.fromEntries(this.hip3DexsMeta),
|
|
37498
|
+
coinToMarket: Object.fromEntries(this.coinToMarket),
|
|
37499
|
+
hip3SymbolToMarket: Object.fromEntries(this.hip3SymbolToMarket)
|
|
37475
37500
|
};
|
|
37476
37501
|
}
|
|
37477
37502
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -544,8 +544,8 @@ function isHip3Symbol(symbol) {
|
|
|
544
544
|
|
|
545
545
|
// import("./data/**/*/staticMeta.json") in lib/meta/metadata.ts
|
|
546
546
|
var globImport_data_staticMeta_json = __glob({
|
|
547
|
-
"./data/mainnet/staticMeta.json": () => import("./staticMeta-
|
|
548
|
-
"./data/testnet/staticMeta.json": () => import("./staticMeta-
|
|
547
|
+
"./data/mainnet/staticMeta.json": () => import("./staticMeta-QV2KMX57.mjs"),
|
|
548
|
+
"./data/testnet/staticMeta.json": () => import("./staticMeta-GM7T3OYL.mjs")
|
|
549
549
|
});
|
|
550
550
|
|
|
551
551
|
// import("./data/**/*/spotMeta.json") in lib/meta/metadata.ts
|
|
@@ -593,6 +593,7 @@ var MetadataClient = class {
|
|
|
593
593
|
this.dexNameToIndex = /* @__PURE__ */ new Map();
|
|
594
594
|
// Lazy init flag
|
|
595
595
|
this.initialized = false;
|
|
596
|
+
this.initializing = null;
|
|
596
597
|
const transport = new HttpTransport({
|
|
597
598
|
isTestnet: config.isTestnet ?? false
|
|
598
599
|
});
|
|
@@ -610,44 +611,54 @@ var MetadataClient = class {
|
|
|
610
611
|
*/
|
|
611
612
|
async initialize() {
|
|
612
613
|
if (this.initialized) return;
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
await this.
|
|
616
|
-
this.
|
|
617
|
-
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
618
|
-
await Promise.all(
|
|
619
|
-
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
|
|
620
|
-
);
|
|
621
|
-
}
|
|
622
|
-
this.initialized = true;
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
try {
|
|
626
|
-
[this.spotMeta, this.perpsMeta, this.perpDexs] = await Promise.all([
|
|
627
|
-
this.infoClient.spotMeta(),
|
|
628
|
-
this.infoClient.meta(),
|
|
629
|
-
this.infoClient.perpDexs()
|
|
630
|
-
]);
|
|
631
|
-
this.buildLookupMaps();
|
|
632
|
-
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
633
|
-
await Promise.all(
|
|
634
|
-
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
|
|
635
|
-
);
|
|
636
|
-
}
|
|
637
|
-
this.initialized = true;
|
|
638
|
-
} catch (error) {
|
|
639
|
-
if (this.config.useStaticFallback) {
|
|
640
|
-
console.warn(
|
|
641
|
-
"Failed to fetch metadata from API, using static fallback data",
|
|
642
|
-
error
|
|
643
|
-
);
|
|
614
|
+
if (this.initializing) return this.initializing;
|
|
615
|
+
this.initializing = new Promise(async (resolve, reject) => {
|
|
616
|
+
await this.loadStaticMetaOverrides();
|
|
617
|
+
if (this.config.onlyUseStaticFallback) {
|
|
644
618
|
await this.loadStaticMetadata();
|
|
645
619
|
this.buildLookupMaps();
|
|
620
|
+
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
621
|
+
await Promise.all(
|
|
622
|
+
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
resolve();
|
|
626
|
+
this.initialized = true;
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
try {
|
|
630
|
+
[this.spotMeta, this.perpsMeta, this.perpDexs] = await Promise.all([
|
|
631
|
+
this.infoClient.spotMeta(),
|
|
632
|
+
this.infoClient.meta(),
|
|
633
|
+
this.infoClient.perpDexs()
|
|
634
|
+
]);
|
|
635
|
+
this.buildLookupMaps();
|
|
636
|
+
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
637
|
+
await Promise.all(
|
|
638
|
+
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
this.initialized = true;
|
|
642
|
+
resolve();
|
|
643
|
+
} catch (error) {
|
|
644
|
+
if (this.config.useStaticFallback) {
|
|
645
|
+
console.warn(
|
|
646
|
+
"Failed to fetch metadata from API, using static fallback data",
|
|
647
|
+
error
|
|
648
|
+
);
|
|
649
|
+
await this.loadStaticMetadata();
|
|
650
|
+
this.buildLookupMaps();
|
|
651
|
+
this.initialized = true;
|
|
652
|
+
resolve();
|
|
653
|
+
} else {
|
|
654
|
+
reject(error);
|
|
655
|
+
}
|
|
656
|
+
} finally {
|
|
646
657
|
this.initialized = true;
|
|
647
|
-
|
|
648
|
-
throw error;
|
|
658
|
+
resolve();
|
|
649
659
|
}
|
|
650
|
-
}
|
|
660
|
+
});
|
|
661
|
+
return this.initializing;
|
|
651
662
|
}
|
|
652
663
|
/**
|
|
653
664
|
* Load staticMeta.json for display overrides
|
|
@@ -700,9 +711,14 @@ var MetadataClient = class {
|
|
|
700
711
|
this.spotPairToMarket.clear();
|
|
701
712
|
this.baseTokenToMarkets.clear();
|
|
702
713
|
this.coinToMarket.clear();
|
|
703
|
-
this.hip3SymbolToMarket.clear();
|
|
704
714
|
this.dexNameToIndex.clear();
|
|
705
715
|
this.quoteAssets = [];
|
|
716
|
+
console.info(
|
|
717
|
+
"[MetadataClient] Building lookup maps",
|
|
718
|
+
this.perpDexs,
|
|
719
|
+
this.perpsMeta,
|
|
720
|
+
this.spotMeta
|
|
721
|
+
);
|
|
706
722
|
if (this.perpDexs) {
|
|
707
723
|
this.perpDexs.forEach((dex, index) => {
|
|
708
724
|
if (dex && dex.name) {
|
|
@@ -813,6 +829,9 @@ var MetadataClient = class {
|
|
|
813
829
|
if (staticDexOverrides.imageUrl) {
|
|
814
830
|
dexInfo.imageUrl = staticDexOverrides.imageUrl;
|
|
815
831
|
}
|
|
832
|
+
if (staticDexOverrides.accountName) {
|
|
833
|
+
dexInfo.accountName = staticDexOverrides.accountName;
|
|
834
|
+
}
|
|
816
835
|
}
|
|
817
836
|
this.hip3DexsMeta.set(dexName, dexInfo);
|
|
818
837
|
this.buildHip3MarketsForDex(dexName, dexInfo);
|
|
@@ -849,6 +868,7 @@ var MetadataClient = class {
|
|
|
849
868
|
marketInfo.imageUrl = staticOverrides.imageUrl;
|
|
850
869
|
}
|
|
851
870
|
}
|
|
871
|
+
console.info("[MetadataClient] caching market", symbol, marketInfo);
|
|
852
872
|
this.coinToMarket.set(symbol, marketInfo);
|
|
853
873
|
this.hip3SymbolToMarket.set(symbol, marketInfo);
|
|
854
874
|
});
|
|
@@ -937,6 +957,7 @@ var MetadataClient = class {
|
|
|
937
957
|
if (!dexName || !coinName) return null;
|
|
938
958
|
let cachedMarket = this.hip3SymbolToMarket.get(symbol);
|
|
939
959
|
if (cachedMarket) return cachedMarket;
|
|
960
|
+
console.warn("Missing market", symbol, this.hip3SymbolToMarket);
|
|
940
961
|
const dexMeta = this.hip3DexsMeta.get(dexName);
|
|
941
962
|
if (!dexMeta && this.config.lazyInit) {
|
|
942
963
|
await this.loadHip3Metadata(dexName);
|
|
@@ -995,7 +1016,9 @@ var MetadataClient = class {
|
|
|
995
1016
|
spotMeta: this.spotMeta,
|
|
996
1017
|
perpsMeta: this.perpsMeta,
|
|
997
1018
|
perpDexs: this.perpDexs,
|
|
998
|
-
hip3DexsMeta: Object.fromEntries(this.hip3DexsMeta)
|
|
1019
|
+
hip3DexsMeta: Object.fromEntries(this.hip3DexsMeta),
|
|
1020
|
+
coinToMarket: Object.fromEntries(this.coinToMarket),
|
|
1021
|
+
hip3SymbolToMarket: Object.fromEntries(this.hip3SymbolToMarket)
|
|
999
1022
|
};
|
|
1000
1023
|
}
|
|
1001
1024
|
/**
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./chunk-4UEJOM6W.mjs";
|
|
2
|
+
|
|
3
|
+
// lib/meta/data/testnet/staticMeta.json
|
|
4
|
+
var coins = {
|
|
5
|
+
"rrrrr:BTC": {
|
|
6
|
+
displayName: "BTCe"
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
var dexs = {
|
|
10
|
+
rrrrr: {
|
|
11
|
+
displayName: "Hyena",
|
|
12
|
+
accountName: "USDe Perps"
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var staticMeta_default = {
|
|
16
|
+
coins,
|
|
17
|
+
dexs
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
coins,
|
|
21
|
+
staticMeta_default as default,
|
|
22
|
+
dexs
|
|
23
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./chunk-4UEJOM6W.mjs";
|
|
2
|
+
|
|
3
|
+
// lib/meta/data/testnet/staticMeta.json
|
|
4
|
+
var coins = {
|
|
5
|
+
"rrrrr:BTC": {
|
|
6
|
+
displayName: "BTCe"
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
var dexs = {
|
|
10
|
+
rrrrr: {
|
|
11
|
+
displayName: "Hyena",
|
|
12
|
+
accountName: "USDe"
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var staticMeta_default = {
|
|
16
|
+
coins,
|
|
17
|
+
dexs
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
coins,
|
|
21
|
+
staticMeta_default as default,
|
|
22
|
+
dexs
|
|
23
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "./chunk-4UEJOM6W.mjs";
|
|
2
|
+
|
|
3
|
+
// lib/meta/data/mainnet/staticMeta.json
|
|
4
|
+
var coins = {
|
|
5
|
+
"xyz:XYZ100": {
|
|
6
|
+
imageUrl: "https://app.based.one/hip3/xyz/xyz100.webp",
|
|
7
|
+
displayName: "Nasdaq-100"
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var dexs = {
|
|
11
|
+
xyz: {
|
|
12
|
+
imageUrl: "",
|
|
13
|
+
displayName: "Trade.xyz",
|
|
14
|
+
tags: ["Equities"]
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var staticMeta_default = {
|
|
18
|
+
coins,
|
|
19
|
+
dexs
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
coins,
|
|
23
|
+
staticMeta_default as default,
|
|
24
|
+
dexs
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "./chunk-4UEJOM6W.mjs";
|
|
2
|
+
|
|
3
|
+
// lib/meta/data/mainnet/staticMeta.json
|
|
4
|
+
var coins = {
|
|
5
|
+
"xyz:XYZ100": {
|
|
6
|
+
imageUrl: "https://app.based.one/hip3/xyz/xyz100.webp",
|
|
7
|
+
displayName: "Nasdaq-100"
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var dexs = {
|
|
11
|
+
xyz: {
|
|
12
|
+
imageUrl: "",
|
|
13
|
+
displayName: "Trade.xyz",
|
|
14
|
+
accountName: "Equities"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var staticMeta_default = {
|
|
18
|
+
coins,
|
|
19
|
+
dexs
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
coins,
|
|
23
|
+
staticMeta_default as default,
|
|
24
|
+
dexs
|
|
25
|
+
};
|
package/lib/meta/metadata.ts
CHANGED
|
@@ -58,6 +58,7 @@ export interface DexInfo {
|
|
|
58
58
|
collateralTokenSymbol: string;
|
|
59
59
|
displayName?: string; // Display name override for the DEX
|
|
60
60
|
imageUrl?: string; // Image URL override for the DEX
|
|
61
|
+
accountName?: string; // Account name override for the DEX
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
export type ExtendedPerpsMeta = PerpsMeta & {
|
|
@@ -89,6 +90,7 @@ interface StaticMetadata {
|
|
|
89
90
|
[dexName: string]: {
|
|
90
91
|
displayName?: string;
|
|
91
92
|
imageUrl?: string;
|
|
93
|
+
accountName?: string;
|
|
92
94
|
};
|
|
93
95
|
};
|
|
94
96
|
}
|
|
@@ -158,6 +160,7 @@ export class MetadataClient {
|
|
|
158
160
|
|
|
159
161
|
// Lazy init flag
|
|
160
162
|
private initialized: boolean = false;
|
|
163
|
+
private initializing: Promise<void> | null = null;
|
|
161
164
|
|
|
162
165
|
constructor(config: MetadataClientConfig = {}) {
|
|
163
166
|
const transport = new HttpTransport({
|
|
@@ -178,58 +181,65 @@ export class MetadataClient {
|
|
|
178
181
|
*/
|
|
179
182
|
async initialize(): Promise<void> {
|
|
180
183
|
if (this.initialized) return;
|
|
184
|
+
if (this.initializing) return this.initializing;
|
|
185
|
+
this.initializing = new Promise(async (resolve, reject) => {
|
|
186
|
+
// Always load staticMeta.json regardless of config.useStaticFallback
|
|
187
|
+
await this.loadStaticMetaOverrides();
|
|
181
188
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (this.config.onlyUseStaticFallback) {
|
|
186
|
-
await this.loadStaticMetadata();
|
|
187
|
-
this.buildLookupMaps();
|
|
189
|
+
if (this.config.onlyUseStaticFallback) {
|
|
190
|
+
await this.loadStaticMetadata();
|
|
191
|
+
this.buildLookupMaps();
|
|
188
192
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
// Fetch HIP-3 metadata if configured
|
|
194
|
+
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
195
|
+
await Promise.all(
|
|
196
|
+
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex)),
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
resolve();
|
|
200
|
+
this.initialized = true;
|
|
201
|
+
return;
|
|
194
202
|
}
|
|
195
203
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.infoClient.spotMeta(),
|
|
204
|
-
this.infoClient.meta(),
|
|
205
|
-
this.infoClient.perpDexs() as Promise<PerpDex[] | null[]>,
|
|
206
|
-
]);
|
|
207
|
-
|
|
208
|
-
// Build optimized lookup maps
|
|
209
|
-
this.buildLookupMaps();
|
|
210
|
-
|
|
211
|
-
// Fetch HIP-3 metadata if configured
|
|
212
|
-
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
213
|
-
await Promise.all(
|
|
214
|
-
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex)),
|
|
215
|
-
);
|
|
216
|
-
}
|
|
204
|
+
try {
|
|
205
|
+
// Fetch core metadata from API
|
|
206
|
+
[this.spotMeta, this.perpsMeta, this.perpDexs] = await Promise.all([
|
|
207
|
+
this.infoClient.spotMeta(),
|
|
208
|
+
this.infoClient.meta(),
|
|
209
|
+
this.infoClient.perpDexs() as Promise<PerpDex[] | null[]>,
|
|
210
|
+
]);
|
|
217
211
|
|
|
218
|
-
|
|
219
|
-
} catch (error) {
|
|
220
|
-
// Fall back to static data if API fetch fails and fallback is enabled
|
|
221
|
-
if (this.config.useStaticFallback) {
|
|
222
|
-
console.warn(
|
|
223
|
-
"Failed to fetch metadata from API, using static fallback data",
|
|
224
|
-
error,
|
|
225
|
-
);
|
|
226
|
-
await this.loadStaticMetadata();
|
|
212
|
+
// Build optimized lookup maps
|
|
227
213
|
this.buildLookupMaps();
|
|
214
|
+
|
|
215
|
+
// Fetch HIP-3 metadata if configured
|
|
216
|
+
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
217
|
+
await Promise.all(
|
|
218
|
+
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex)),
|
|
219
|
+
);
|
|
220
|
+
}
|
|
228
221
|
this.initialized = true;
|
|
229
|
-
|
|
230
|
-
|
|
222
|
+
resolve();
|
|
223
|
+
} catch (error) {
|
|
224
|
+
// Fall back to static data if API fetch fails and fallback is enabled
|
|
225
|
+
if (this.config.useStaticFallback) {
|
|
226
|
+
console.warn(
|
|
227
|
+
"Failed to fetch metadata from API, using static fallback data",
|
|
228
|
+
error,
|
|
229
|
+
);
|
|
230
|
+
await this.loadStaticMetadata();
|
|
231
|
+
this.buildLookupMaps();
|
|
232
|
+
this.initialized = true;
|
|
233
|
+
resolve();
|
|
234
|
+
} else {
|
|
235
|
+
reject(error);
|
|
236
|
+
}
|
|
237
|
+
} finally {
|
|
238
|
+
this.initialized = true;
|
|
239
|
+
resolve();
|
|
231
240
|
}
|
|
232
|
-
}
|
|
241
|
+
});
|
|
242
|
+
return this.initializing;
|
|
233
243
|
}
|
|
234
244
|
|
|
235
245
|
/**
|
|
@@ -293,10 +303,16 @@ export class MetadataClient {
|
|
|
293
303
|
this.spotPairToMarket.clear();
|
|
294
304
|
this.baseTokenToMarkets.clear();
|
|
295
305
|
this.coinToMarket.clear();
|
|
296
|
-
this.hip3SymbolToMarket.clear();
|
|
297
306
|
this.dexNameToIndex.clear();
|
|
298
307
|
this.quoteAssets = [];
|
|
299
308
|
|
|
309
|
+
console.info(
|
|
310
|
+
"[MetadataClient] Building lookup maps",
|
|
311
|
+
this.perpDexs,
|
|
312
|
+
this.perpsMeta,
|
|
313
|
+
this.spotMeta,
|
|
314
|
+
);
|
|
315
|
+
|
|
300
316
|
// Build dex name to index map
|
|
301
317
|
if (this.perpDexs) {
|
|
302
318
|
this.perpDexs.forEach((dex, index) => {
|
|
@@ -457,6 +473,9 @@ export class MetadataClient {
|
|
|
457
473
|
if (staticDexOverrides.imageUrl) {
|
|
458
474
|
dexInfo.imageUrl = staticDexOverrides.imageUrl;
|
|
459
475
|
}
|
|
476
|
+
if (staticDexOverrides.accountName) {
|
|
477
|
+
dexInfo.accountName = staticDexOverrides.accountName;
|
|
478
|
+
}
|
|
460
479
|
}
|
|
461
480
|
|
|
462
481
|
this.hip3DexsMeta.set(dexName, dexInfo);
|
|
@@ -502,6 +521,8 @@ export class MetadataClient {
|
|
|
502
521
|
}
|
|
503
522
|
}
|
|
504
523
|
|
|
524
|
+
console.info("[MetadataClient] caching market", symbol, marketInfo);
|
|
525
|
+
|
|
505
526
|
this.coinToMarket.set(symbol, marketInfo);
|
|
506
527
|
this.hip3SymbolToMarket.set(symbol, marketInfo);
|
|
507
528
|
});
|
|
@@ -624,6 +645,7 @@ export class MetadataClient {
|
|
|
624
645
|
// Try O(1) lookup first (if DEX metadata already loaded)
|
|
625
646
|
let cachedMarket = this.hip3SymbolToMarket.get(symbol);
|
|
626
647
|
if (cachedMarket) return cachedMarket;
|
|
648
|
+
console.warn("Missing market", symbol, this.hip3SymbolToMarket);
|
|
627
649
|
|
|
628
650
|
// If not found, check if we need to load DEX metadata
|
|
629
651
|
const dexMeta = this.hip3DexsMeta.get(dexName);
|
|
@@ -701,6 +723,8 @@ export class MetadataClient {
|
|
|
701
723
|
perpsMeta: this.perpsMeta,
|
|
702
724
|
perpDexs: this.perpDexs,
|
|
703
725
|
hip3DexsMeta: Object.fromEntries(this.hip3DexsMeta),
|
|
726
|
+
coinToMarket: Object.fromEntries(this.coinToMarket),
|
|
727
|
+
hip3SymbolToMarket: Object.fromEntries(this.hip3SymbolToMarket),
|
|
704
728
|
};
|
|
705
729
|
}
|
|
706
730
|
|