@basedone/core 0.0.7 → 0.0.9
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/chunk-KH53SPJC.mjs +13 -0
- package/dist/index.d.mts +37 -3
- package/dist/index.d.ts +37 -3
- package/dist/index.js +143 -44
- package/dist/index.mjs +137 -43
- package/dist/meta-44Z4QO5K.mjs +1474 -0
- package/dist/meta-VES4BWNR.mjs +1355 -0
- package/dist/perpDexs-BE7YAC5W.mjs +17 -0
- package/dist/perpDexs-F3JQZZLH.mjs +537 -0
- package/dist/spotMeta-HRQNZMVY.mjs +6442 -0
- package/dist/spotMeta-SHXGTDWD.mjs +26559 -0
- package/dist/staticMeta-2HYATSVU.mjs +25 -0
- package/dist/staticMeta-D2V74GCG.mjs +23 -0
- package/dist/staticMeta-GM7T3OYL.mjs +23 -0
- package/dist/staticMeta-OKNVBUQ5.mjs +25 -0
- package/dist/staticMeta-PLKPPG23.mjs +23 -0
- package/dist/staticMeta-QV2KMX57.mjs +25 -0
- package/index.ts +1 -0
- package/lib/cloid/cloid.ts +4 -0
- package/lib/hip3/utils.ts +89 -0
- package/lib/meta/data/mainnet/staticMeta.json +2 -1
- package/lib/meta/data/testnet/staticMeta.json +2 -1
- package/lib/meta/metadata.ts +70 -46
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __glob = (map) => (path) => {
|
|
4
|
+
var fn = map[path];
|
|
5
|
+
if (fn) return fn();
|
|
6
|
+
throw new Error("Module not found in bundle: " + path);
|
|
7
|
+
};
|
|
8
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
__glob,
|
|
12
|
+
__publicField
|
|
13
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta } from '@nktkas/hyperliquid';
|
|
2
|
-
import { Hex } from '@nktkas/hyperliquid/
|
|
1
|
+
import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
|
|
2
|
+
import { Hex } from '@nktkas/hyperliquid/types';
|
|
3
3
|
|
|
4
4
|
declare function encodeSlug(slug: string): bigint;
|
|
5
5
|
declare function decodeSlug(value: bigint): string;
|
|
@@ -44,6 +44,7 @@ declare const CloidClientCode: {
|
|
|
44
44
|
readonly Chase: 6;
|
|
45
45
|
readonly Desktop: 7;
|
|
46
46
|
readonly API: 8;
|
|
47
|
+
readonly Stream: 9;
|
|
47
48
|
};
|
|
48
49
|
type ClientCodeType = keyof typeof CloidClientCode;
|
|
49
50
|
type CloidClientCodeId = (typeof CloidClientCode)[ClientCodeType];
|
|
@@ -54,6 +55,7 @@ declare const WidgetType: {
|
|
|
54
55
|
readonly SidePanel: 1;
|
|
55
56
|
readonly Widget: 2;
|
|
56
57
|
readonly FloatingWidget: 3;
|
|
58
|
+
readonly Stream: 4;
|
|
57
59
|
};
|
|
58
60
|
type WidgetType = keyof typeof WidgetType;
|
|
59
61
|
type WidgetTypeId = (typeof WidgetType)[WidgetType];
|
|
@@ -274,6 +276,7 @@ interface DexInfo {
|
|
|
274
276
|
collateralTokenSymbol: string;
|
|
275
277
|
displayName?: string;
|
|
276
278
|
imageUrl?: string;
|
|
279
|
+
accountName?: string;
|
|
277
280
|
}
|
|
278
281
|
type ExtendedPerpsMeta = PerpsMeta & {
|
|
279
282
|
collateralToken?: number;
|
|
@@ -336,6 +339,7 @@ declare class MetadataClient {
|
|
|
336
339
|
private hip3SymbolToMarket;
|
|
337
340
|
private dexNameToIndex;
|
|
338
341
|
private initialized;
|
|
342
|
+
private initializing;
|
|
339
343
|
constructor(config?: MetadataClientConfig);
|
|
340
344
|
/**
|
|
341
345
|
* Initialize metadata by fetching from Hyperliquid
|
|
@@ -426,6 +430,12 @@ declare class MetadataClient {
|
|
|
426
430
|
hip3DexsMeta: {
|
|
427
431
|
[k: string]: DexInfo;
|
|
428
432
|
};
|
|
433
|
+
coinToMarket: {
|
|
434
|
+
[k: string]: MarketInfo;
|
|
435
|
+
};
|
|
436
|
+
hip3SymbolToMarket: {
|
|
437
|
+
[k: string]: MarketInfo;
|
|
438
|
+
};
|
|
429
439
|
};
|
|
430
440
|
/**
|
|
431
441
|
* Get network configuration
|
|
@@ -485,4 +495,28 @@ declare const formatSizeForOrder: ({ sz, szDecimals, }: {
|
|
|
485
495
|
*/
|
|
486
496
|
declare function getPriceDecimals(price: number, szDecimals: number, isSpot: boolean): number;
|
|
487
497
|
|
|
488
|
-
|
|
498
|
+
declare function isHip3Symbol(symbol: string): boolean;
|
|
499
|
+
declare function getHip3Dex(symbol: string): string | null;
|
|
500
|
+
/**
|
|
501
|
+
* Enable HIP-3 DEX abstraction with the current agent wallet
|
|
502
|
+
* @param client Exchange client with agent wallet
|
|
503
|
+
* @returns Promise with success response
|
|
504
|
+
*/
|
|
505
|
+
declare function enableHip3DexAbstractionWithAgent(client: ExchangeClient): Promise<SuccessResponse>;
|
|
506
|
+
declare const UserDexAbstractionTypes: {
|
|
507
|
+
"HyperliquidTransaction:UserDexAbstraction": {
|
|
508
|
+
name: string;
|
|
509
|
+
type: string;
|
|
510
|
+
}[];
|
|
511
|
+
};
|
|
512
|
+
/**
|
|
513
|
+
* Set HIP-3 DEX abstraction for a user
|
|
514
|
+
* @param client Exchange client with owner wallet
|
|
515
|
+
* @param enabled Whether to enable HIP-3 DEX abstraction
|
|
516
|
+
* @param user User address
|
|
517
|
+
* @returns Promise with success response
|
|
518
|
+
*/
|
|
519
|
+
declare function setHip3DexAbstraction(client: ExchangeClient, enabled: boolean, user: string): Promise<SuccessResponse>;
|
|
520
|
+
declare function getHip3DexAbstraction(client: InfoClient, user: string): Promise<boolean | null>;
|
|
521
|
+
|
|
522
|
+
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, UserDexAbstractionTypes, type V3LPTokenInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, formatPriceAndSize, formatPriceForOrder, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getHip3Dex, getHip3DexAbstraction, getNextTierInfo, getPriceDecimals, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta } from '@nktkas/hyperliquid';
|
|
2
|
-
import { Hex } from '@nktkas/hyperliquid/
|
|
1
|
+
import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
|
|
2
|
+
import { Hex } from '@nktkas/hyperliquid/types';
|
|
3
3
|
|
|
4
4
|
declare function encodeSlug(slug: string): bigint;
|
|
5
5
|
declare function decodeSlug(value: bigint): string;
|
|
@@ -44,6 +44,7 @@ declare const CloidClientCode: {
|
|
|
44
44
|
readonly Chase: 6;
|
|
45
45
|
readonly Desktop: 7;
|
|
46
46
|
readonly API: 8;
|
|
47
|
+
readonly Stream: 9;
|
|
47
48
|
};
|
|
48
49
|
type ClientCodeType = keyof typeof CloidClientCode;
|
|
49
50
|
type CloidClientCodeId = (typeof CloidClientCode)[ClientCodeType];
|
|
@@ -54,6 +55,7 @@ declare const WidgetType: {
|
|
|
54
55
|
readonly SidePanel: 1;
|
|
55
56
|
readonly Widget: 2;
|
|
56
57
|
readonly FloatingWidget: 3;
|
|
58
|
+
readonly Stream: 4;
|
|
57
59
|
};
|
|
58
60
|
type WidgetType = keyof typeof WidgetType;
|
|
59
61
|
type WidgetTypeId = (typeof WidgetType)[WidgetType];
|
|
@@ -274,6 +276,7 @@ interface DexInfo {
|
|
|
274
276
|
collateralTokenSymbol: string;
|
|
275
277
|
displayName?: string;
|
|
276
278
|
imageUrl?: string;
|
|
279
|
+
accountName?: string;
|
|
277
280
|
}
|
|
278
281
|
type ExtendedPerpsMeta = PerpsMeta & {
|
|
279
282
|
collateralToken?: number;
|
|
@@ -336,6 +339,7 @@ declare class MetadataClient {
|
|
|
336
339
|
private hip3SymbolToMarket;
|
|
337
340
|
private dexNameToIndex;
|
|
338
341
|
private initialized;
|
|
342
|
+
private initializing;
|
|
339
343
|
constructor(config?: MetadataClientConfig);
|
|
340
344
|
/**
|
|
341
345
|
* Initialize metadata by fetching from Hyperliquid
|
|
@@ -426,6 +430,12 @@ declare class MetadataClient {
|
|
|
426
430
|
hip3DexsMeta: {
|
|
427
431
|
[k: string]: DexInfo;
|
|
428
432
|
};
|
|
433
|
+
coinToMarket: {
|
|
434
|
+
[k: string]: MarketInfo;
|
|
435
|
+
};
|
|
436
|
+
hip3SymbolToMarket: {
|
|
437
|
+
[k: string]: MarketInfo;
|
|
438
|
+
};
|
|
429
439
|
};
|
|
430
440
|
/**
|
|
431
441
|
* Get network configuration
|
|
@@ -485,4 +495,28 @@ declare const formatSizeForOrder: ({ sz, szDecimals, }: {
|
|
|
485
495
|
*/
|
|
486
496
|
declare function getPriceDecimals(price: number, szDecimals: number, isSpot: boolean): number;
|
|
487
497
|
|
|
488
|
-
|
|
498
|
+
declare function isHip3Symbol(symbol: string): boolean;
|
|
499
|
+
declare function getHip3Dex(symbol: string): string | null;
|
|
500
|
+
/**
|
|
501
|
+
* Enable HIP-3 DEX abstraction with the current agent wallet
|
|
502
|
+
* @param client Exchange client with agent wallet
|
|
503
|
+
* @returns Promise with success response
|
|
504
|
+
*/
|
|
505
|
+
declare function enableHip3DexAbstractionWithAgent(client: ExchangeClient): Promise<SuccessResponse>;
|
|
506
|
+
declare const UserDexAbstractionTypes: {
|
|
507
|
+
"HyperliquidTransaction:UserDexAbstraction": {
|
|
508
|
+
name: string;
|
|
509
|
+
type: string;
|
|
510
|
+
}[];
|
|
511
|
+
};
|
|
512
|
+
/**
|
|
513
|
+
* Set HIP-3 DEX abstraction for a user
|
|
514
|
+
* @param client Exchange client with owner wallet
|
|
515
|
+
* @param enabled Whether to enable HIP-3 DEX abstraction
|
|
516
|
+
* @param user User address
|
|
517
|
+
* @returns Promise with success response
|
|
518
|
+
*/
|
|
519
|
+
declare function setHip3DexAbstraction(client: ExchangeClient, enabled: boolean, user: string): Promise<SuccessResponse>;
|
|
520
|
+
declare function getHip3DexAbstraction(client: InfoClient, user: string): Promise<boolean | null>;
|
|
521
|
+
|
|
522
|
+
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, UserDexAbstractionTypes, type V3LPTokenInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, formatPriceAndSize, formatPriceForOrder, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getHip3Dex, getHip3DexAbstraction, getNextTierInfo, getPriceDecimals, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction };
|
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
|
};
|
|
@@ -36450,6 +36452,7 @@ __export(index_exports, {
|
|
|
36450
36452
|
TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT: () => TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT,
|
|
36451
36453
|
TESTNET_USDC_SPOT_TOKEN: () => TESTNET_USDC_SPOT_TOKEN,
|
|
36452
36454
|
USDC_SPOT_TOKEN: () => USDC_SPOT_TOKEN,
|
|
36455
|
+
UserDexAbstractionTypes: () => UserDexAbstractionTypes,
|
|
36453
36456
|
WidgetType: () => WidgetType,
|
|
36454
36457
|
WidgetTypeById: () => WidgetTypeById,
|
|
36455
36458
|
XP_BOOST_PERCENTAGES: () => XP_BOOST_PERCENTAGES,
|
|
@@ -36457,6 +36460,7 @@ __export(index_exports, {
|
|
|
36457
36460
|
calculateBoostPercentage: () => calculateBoostPercentage,
|
|
36458
36461
|
calculateTotalPupAmount: () => calculateTotalPupAmount,
|
|
36459
36462
|
decodeSlug: () => decodeSlug,
|
|
36463
|
+
enableHip3DexAbstractionWithAgent: () => enableHip3DexAbstractionWithAgent,
|
|
36460
36464
|
encodeSlug: () => encodeSlug,
|
|
36461
36465
|
formatPriceAndSize: () => formatPriceAndSize,
|
|
36462
36466
|
formatPriceForOrder: () => formatPriceForOrder,
|
|
@@ -36464,11 +36468,14 @@ __export(index_exports, {
|
|
|
36464
36468
|
getApprovalAmount: () => getApprovalAmount,
|
|
36465
36469
|
getClientCodeNameById: () => getClientCodeNameById,
|
|
36466
36470
|
getCloid: () => getCloid,
|
|
36471
|
+
getHip3Dex: () => getHip3Dex,
|
|
36472
|
+
getHip3DexAbstraction: () => getHip3DexAbstraction,
|
|
36467
36473
|
getNextTierInfo: () => getNextTierInfo,
|
|
36468
36474
|
getPriceDecimals: () => getPriceDecimals,
|
|
36469
36475
|
getWidgetTypeById: () => getWidgetTypeById,
|
|
36470
36476
|
isBasedCloid: () => isBasedCloid,
|
|
36471
36477
|
isClientCode: () => isClientCode,
|
|
36478
|
+
isHip3Symbol: () => isHip3Symbol,
|
|
36472
36479
|
isMiniAppCloid: () => isMiniAppCloid,
|
|
36473
36480
|
isMiniAppTriggeredCloid: () => isMiniAppTriggeredCloid,
|
|
36474
36481
|
isTenantCloid: () => isTenantCloid,
|
|
@@ -36477,7 +36484,8 @@ __export(index_exports, {
|
|
|
36477
36484
|
normaliseSlug: () => normaliseSlug,
|
|
36478
36485
|
normaliseTrackingId: () => normaliseTrackingId,
|
|
36479
36486
|
normalizeAirdropAmount: () => normalizeAirdropAmount,
|
|
36480
|
-
parseCloid: () => parseCloid
|
|
36487
|
+
parseCloid: () => parseCloid,
|
|
36488
|
+
setHip3DexAbstraction: () => setHip3DexAbstraction
|
|
36481
36489
|
});
|
|
36482
36490
|
module.exports = __toCommonJS(index_exports);
|
|
36483
36491
|
|
|
@@ -36687,7 +36695,8 @@ var CloidClientCode = {
|
|
|
36687
36695
|
Grid: 5,
|
|
36688
36696
|
Chase: 6,
|
|
36689
36697
|
Desktop: 7,
|
|
36690
|
-
API: 8
|
|
36698
|
+
API: 8,
|
|
36699
|
+
Stream: 9
|
|
36691
36700
|
};
|
|
36692
36701
|
var CloidClientCodeNameById = {
|
|
36693
36702
|
[CloidClientCode.Unset]: "Unset",
|
|
@@ -36698,7 +36707,8 @@ var CloidClientCodeNameById = {
|
|
|
36698
36707
|
[CloidClientCode.Grid]: "Grid",
|
|
36699
36708
|
[CloidClientCode.Chase]: "Chase",
|
|
36700
36709
|
[CloidClientCode.Desktop]: "Desktop",
|
|
36701
|
-
[CloidClientCode.API]: "API"
|
|
36710
|
+
[CloidClientCode.API]: "API",
|
|
36711
|
+
[CloidClientCode.Stream]: "Stream"
|
|
36702
36712
|
};
|
|
36703
36713
|
function getClientCodeNameById(id) {
|
|
36704
36714
|
return CloidClientCodeNameById[id] ?? `client_${id}`;
|
|
@@ -36708,13 +36718,15 @@ var WidgetType = {
|
|
|
36708
36718
|
// 0x00
|
|
36709
36719
|
SidePanel: 1,
|
|
36710
36720
|
Widget: 2,
|
|
36711
|
-
FloatingWidget: 3
|
|
36721
|
+
FloatingWidget: 3,
|
|
36722
|
+
Stream: 4
|
|
36712
36723
|
};
|
|
36713
36724
|
var WidgetTypeById = {
|
|
36714
36725
|
[WidgetType.Unset]: "Unset",
|
|
36715
36726
|
[WidgetType.SidePanel]: "SidePanel",
|
|
36716
36727
|
[WidgetType.Widget]: "Widget",
|
|
36717
|
-
[WidgetType.FloatingWidget]: "FloatingWidget"
|
|
36728
|
+
[WidgetType.FloatingWidget]: "FloatingWidget",
|
|
36729
|
+
[WidgetType.Stream]: "Stream"
|
|
36718
36730
|
};
|
|
36719
36731
|
function getWidgetTypeById(id) {
|
|
36720
36732
|
return WidgetTypeById[id] ?? `widget_${id}`;
|
|
@@ -37013,10 +37025,68 @@ var TESTNET_USDC_SPOT_TOKEN = {
|
|
|
37013
37025
|
var import_hyperliquid = require("@nktkas/hyperliquid");
|
|
37014
37026
|
|
|
37015
37027
|
// lib/hip3/utils.ts
|
|
37028
|
+
var import_signing = require("@nktkas/hyperliquid/signing");
|
|
37016
37029
|
function isHip3Symbol(symbol) {
|
|
37017
37030
|
if (!symbol) return false;
|
|
37018
37031
|
return symbol.includes(":");
|
|
37019
37032
|
}
|
|
37033
|
+
function getHip3Dex(symbol) {
|
|
37034
|
+
if (!symbol) return null;
|
|
37035
|
+
return symbol.split(":")[0];
|
|
37036
|
+
}
|
|
37037
|
+
async function enableHip3DexAbstractionWithAgent(client) {
|
|
37038
|
+
const nonce = Date.now();
|
|
37039
|
+
const action = {
|
|
37040
|
+
type: "agentEnableDexAbstraction"
|
|
37041
|
+
};
|
|
37042
|
+
const signature = await (0, import_signing.signL1Action)({
|
|
37043
|
+
wallet: client.wallet,
|
|
37044
|
+
action,
|
|
37045
|
+
isTestnet: client.isTestnet,
|
|
37046
|
+
nonce
|
|
37047
|
+
});
|
|
37048
|
+
return await client.transport.request("exchange", {
|
|
37049
|
+
action,
|
|
37050
|
+
signature,
|
|
37051
|
+
nonce
|
|
37052
|
+
});
|
|
37053
|
+
}
|
|
37054
|
+
var UserDexAbstractionTypes = {
|
|
37055
|
+
"HyperliquidTransaction:UserDexAbstraction": [
|
|
37056
|
+
{ name: "hyperliquidChain", type: "string" },
|
|
37057
|
+
{ name: "user", type: "address" },
|
|
37058
|
+
{ name: "enabled", type: "bool" },
|
|
37059
|
+
{ name: "nonce", type: "uint64" }
|
|
37060
|
+
]
|
|
37061
|
+
};
|
|
37062
|
+
async function setHip3DexAbstraction(client, enabled, user) {
|
|
37063
|
+
const nonce = Date.now();
|
|
37064
|
+
const isTestnet = client.isTestnet;
|
|
37065
|
+
const action = {
|
|
37066
|
+
type: "userDexAbstraction",
|
|
37067
|
+
hyperliquidChain: isTestnet ? "Testnet" : "Mainnet",
|
|
37068
|
+
signatureChainId: isTestnet ? "0x66eee" : "0xa4b1",
|
|
37069
|
+
user,
|
|
37070
|
+
enabled,
|
|
37071
|
+
nonce
|
|
37072
|
+
};
|
|
37073
|
+
const signature = await (0, import_signing.signUserSignedAction)({
|
|
37074
|
+
wallet: client.wallet,
|
|
37075
|
+
action,
|
|
37076
|
+
types: UserDexAbstractionTypes
|
|
37077
|
+
});
|
|
37078
|
+
return await client.transport.request("exchange", {
|
|
37079
|
+
action,
|
|
37080
|
+
signature,
|
|
37081
|
+
nonce: action.nonce
|
|
37082
|
+
});
|
|
37083
|
+
}
|
|
37084
|
+
async function getHip3DexAbstraction(client, user) {
|
|
37085
|
+
return await client.transport.request("info", {
|
|
37086
|
+
type: "userDexAbstraction",
|
|
37087
|
+
user
|
|
37088
|
+
});
|
|
37089
|
+
}
|
|
37020
37090
|
|
|
37021
37091
|
// import("./data/**/*/staticMeta.json") in lib/meta/metadata.ts
|
|
37022
37092
|
var globImport_data_staticMeta_json = __glob({
|
|
@@ -37069,6 +37139,7 @@ var MetadataClient = class {
|
|
|
37069
37139
|
this.dexNameToIndex = /* @__PURE__ */ new Map();
|
|
37070
37140
|
// Lazy init flag
|
|
37071
37141
|
this.initialized = false;
|
|
37142
|
+
this.initializing = null;
|
|
37072
37143
|
const transport = new import_hyperliquid.HttpTransport({
|
|
37073
37144
|
isTestnet: config.isTestnet ?? false
|
|
37074
37145
|
});
|
|
@@ -37086,44 +37157,54 @@ var MetadataClient = class {
|
|
|
37086
37157
|
*/
|
|
37087
37158
|
async initialize() {
|
|
37088
37159
|
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
|
-
);
|
|
37160
|
+
if (this.initializing) return this.initializing;
|
|
37161
|
+
this.initializing = new Promise(async (resolve, reject) => {
|
|
37162
|
+
await this.loadStaticMetaOverrides();
|
|
37163
|
+
if (this.config.onlyUseStaticFallback) {
|
|
37120
37164
|
await this.loadStaticMetadata();
|
|
37121
37165
|
this.buildLookupMaps();
|
|
37166
|
+
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
37167
|
+
await Promise.all(
|
|
37168
|
+
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
|
|
37169
|
+
);
|
|
37170
|
+
}
|
|
37171
|
+
resolve();
|
|
37122
37172
|
this.initialized = true;
|
|
37123
|
-
|
|
37124
|
-
throw error;
|
|
37173
|
+
return;
|
|
37125
37174
|
}
|
|
37126
|
-
|
|
37175
|
+
try {
|
|
37176
|
+
[this.spotMeta, this.perpsMeta, this.perpDexs] = await Promise.all([
|
|
37177
|
+
this.infoClient.spotMeta(),
|
|
37178
|
+
this.infoClient.meta(),
|
|
37179
|
+
this.infoClient.perpDexs()
|
|
37180
|
+
]);
|
|
37181
|
+
this.buildLookupMaps();
|
|
37182
|
+
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
37183
|
+
await Promise.all(
|
|
37184
|
+
this.config.hip3Dexs.map((dex) => this.loadHip3Metadata(dex))
|
|
37185
|
+
);
|
|
37186
|
+
}
|
|
37187
|
+
this.initialized = true;
|
|
37188
|
+
resolve();
|
|
37189
|
+
} catch (error) {
|
|
37190
|
+
if (this.config.useStaticFallback) {
|
|
37191
|
+
console.warn(
|
|
37192
|
+
"Failed to fetch metadata from API, using static fallback data",
|
|
37193
|
+
error
|
|
37194
|
+
);
|
|
37195
|
+
await this.loadStaticMetadata();
|
|
37196
|
+
this.buildLookupMaps();
|
|
37197
|
+
this.initialized = true;
|
|
37198
|
+
resolve();
|
|
37199
|
+
} else {
|
|
37200
|
+
reject(error);
|
|
37201
|
+
}
|
|
37202
|
+
} finally {
|
|
37203
|
+
this.initialized = true;
|
|
37204
|
+
resolve();
|
|
37205
|
+
}
|
|
37206
|
+
});
|
|
37207
|
+
return this.initializing;
|
|
37127
37208
|
}
|
|
37128
37209
|
/**
|
|
37129
37210
|
* Load staticMeta.json for display overrides
|
|
@@ -37176,9 +37257,14 @@ var MetadataClient = class {
|
|
|
37176
37257
|
this.spotPairToMarket.clear();
|
|
37177
37258
|
this.baseTokenToMarkets.clear();
|
|
37178
37259
|
this.coinToMarket.clear();
|
|
37179
|
-
this.hip3SymbolToMarket.clear();
|
|
37180
37260
|
this.dexNameToIndex.clear();
|
|
37181
37261
|
this.quoteAssets = [];
|
|
37262
|
+
console.info(
|
|
37263
|
+
"[MetadataClient] Building lookup maps",
|
|
37264
|
+
this.perpDexs,
|
|
37265
|
+
this.perpsMeta,
|
|
37266
|
+
this.spotMeta
|
|
37267
|
+
);
|
|
37182
37268
|
if (this.perpDexs) {
|
|
37183
37269
|
this.perpDexs.forEach((dex, index) => {
|
|
37184
37270
|
if (dex && dex.name) {
|
|
@@ -37289,6 +37375,9 @@ var MetadataClient = class {
|
|
|
37289
37375
|
if (staticDexOverrides.imageUrl) {
|
|
37290
37376
|
dexInfo.imageUrl = staticDexOverrides.imageUrl;
|
|
37291
37377
|
}
|
|
37378
|
+
if (staticDexOverrides.accountName) {
|
|
37379
|
+
dexInfo.accountName = staticDexOverrides.accountName;
|
|
37380
|
+
}
|
|
37292
37381
|
}
|
|
37293
37382
|
this.hip3DexsMeta.set(dexName, dexInfo);
|
|
37294
37383
|
this.buildHip3MarketsForDex(dexName, dexInfo);
|
|
@@ -37325,6 +37414,7 @@ var MetadataClient = class {
|
|
|
37325
37414
|
marketInfo.imageUrl = staticOverrides.imageUrl;
|
|
37326
37415
|
}
|
|
37327
37416
|
}
|
|
37417
|
+
console.info("[MetadataClient] caching market", symbol, marketInfo);
|
|
37328
37418
|
this.coinToMarket.set(symbol, marketInfo);
|
|
37329
37419
|
this.hip3SymbolToMarket.set(symbol, marketInfo);
|
|
37330
37420
|
});
|
|
@@ -37413,6 +37503,7 @@ var MetadataClient = class {
|
|
|
37413
37503
|
if (!dexName || !coinName) return null;
|
|
37414
37504
|
let cachedMarket = this.hip3SymbolToMarket.get(symbol);
|
|
37415
37505
|
if (cachedMarket) return cachedMarket;
|
|
37506
|
+
console.warn("Missing market", symbol, this.hip3SymbolToMarket);
|
|
37416
37507
|
const dexMeta = this.hip3DexsMeta.get(dexName);
|
|
37417
37508
|
if (!dexMeta && this.config.lazyInit) {
|
|
37418
37509
|
await this.loadHip3Metadata(dexName);
|
|
@@ -37471,7 +37562,9 @@ var MetadataClient = class {
|
|
|
37471
37562
|
spotMeta: this.spotMeta,
|
|
37472
37563
|
perpsMeta: this.perpsMeta,
|
|
37473
37564
|
perpDexs: this.perpDexs,
|
|
37474
|
-
hip3DexsMeta: Object.fromEntries(this.hip3DexsMeta)
|
|
37565
|
+
hip3DexsMeta: Object.fromEntries(this.hip3DexsMeta),
|
|
37566
|
+
coinToMarket: Object.fromEntries(this.coinToMarket),
|
|
37567
|
+
hip3SymbolToMarket: Object.fromEntries(this.hip3SymbolToMarket)
|
|
37475
37568
|
};
|
|
37476
37569
|
}
|
|
37477
37570
|
/**
|
|
@@ -37543,6 +37636,7 @@ function getPriceDecimals(price, szDecimals, isSpot) {
|
|
|
37543
37636
|
TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT,
|
|
37544
37637
|
TESTNET_USDC_SPOT_TOKEN,
|
|
37545
37638
|
USDC_SPOT_TOKEN,
|
|
37639
|
+
UserDexAbstractionTypes,
|
|
37546
37640
|
WidgetType,
|
|
37547
37641
|
WidgetTypeById,
|
|
37548
37642
|
XP_BOOST_PERCENTAGES,
|
|
@@ -37550,6 +37644,7 @@ function getPriceDecimals(price, szDecimals, isSpot) {
|
|
|
37550
37644
|
calculateBoostPercentage,
|
|
37551
37645
|
calculateTotalPupAmount,
|
|
37552
37646
|
decodeSlug,
|
|
37647
|
+
enableHip3DexAbstractionWithAgent,
|
|
37553
37648
|
encodeSlug,
|
|
37554
37649
|
formatPriceAndSize,
|
|
37555
37650
|
formatPriceForOrder,
|
|
@@ -37557,11 +37652,14 @@ function getPriceDecimals(price, szDecimals, isSpot) {
|
|
|
37557
37652
|
getApprovalAmount,
|
|
37558
37653
|
getClientCodeNameById,
|
|
37559
37654
|
getCloid,
|
|
37655
|
+
getHip3Dex,
|
|
37656
|
+
getHip3DexAbstraction,
|
|
37560
37657
|
getNextTierInfo,
|
|
37561
37658
|
getPriceDecimals,
|
|
37562
37659
|
getWidgetTypeById,
|
|
37563
37660
|
isBasedCloid,
|
|
37564
37661
|
isClientCode,
|
|
37662
|
+
isHip3Symbol,
|
|
37565
37663
|
isMiniAppCloid,
|
|
37566
37664
|
isMiniAppTriggeredCloid,
|
|
37567
37665
|
isTenantCloid,
|
|
@@ -37570,5 +37668,6 @@ function getPriceDecimals(price, szDecimals, isSpot) {
|
|
|
37570
37668
|
normaliseSlug,
|
|
37571
37669
|
normaliseTrackingId,
|
|
37572
37670
|
normalizeAirdropAmount,
|
|
37573
|
-
parseCloid
|
|
37671
|
+
parseCloid,
|
|
37672
|
+
setHip3DexAbstraction
|
|
37574
37673
|
});
|