@basedone/core 0.1.6 → 0.1.10

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,4 @@
1
- import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
1
+ import { SpotToken, MarginTables, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
2
2
  import { Hex } from '@nktkas/hyperliquid/types';
3
3
 
4
4
  declare function encodeSlug(slug: string): bigint;
@@ -45,6 +45,7 @@ declare const CloidClientCode: {
45
45
  readonly Desktop: 7;
46
46
  readonly API: 8;
47
47
  readonly Stream: 9;
48
+ readonly Pal: 10;
48
49
  };
49
50
  type ClientCodeType = keyof typeof CloidClientCode;
50
51
  type CloidClientCodeId = (typeof CloidClientCode)[ClientCodeType];
@@ -82,17 +83,19 @@ declare const TARGET_APPROVED_MAX_BUILDER_FEE: number;
82
83
  declare const TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT = "0.1%";
83
84
  /**
84
85
  * Get the amount of builder fee to approve for
85
- * @param perpetualTradingFee - Perp fee in percentage
86
- * @param spotTradingFee - Spot fee in percentage
86
+ * @param perpetualTradingFee - Perp fee in percentage (0.025 means 0.025% perp fee)
87
+ * @param spotTradingFee - Spot fee in percentage (0.01 means 0.01% spot fee)
88
+ * @param feeDiscount - Discount fee in percentage (0.9 means 90% discount)
87
89
  * @returns {
88
90
  * amount: number; - The amount of builder fee to approve in 1/10 of a basis point
89
91
  * percent: string; - eg. String input to approve fee, "0.1%"
90
92
  * }
91
93
  */
92
- declare const getApprovalAmount: ({ customFeeEnabled, perpetualTradingFee, spotTradingFee, }: {
94
+ declare const getApprovalAmount: ({ customFeeEnabled, perpetualTradingFee, spotTradingFee, feeDiscount, }: {
93
95
  customFeeEnabled: boolean;
94
96
  perpetualTradingFee?: number;
95
97
  spotTradingFee?: number;
98
+ feeDiscount?: number;
96
99
  }) => {
97
100
  approvalAmount: number;
98
101
  approvalPercent: `${string}%`;
@@ -236,6 +239,34 @@ declare function getNextTierInfo(pupTokenAmount: number, normalizedAirDropAmount
236
239
  declare const USDC_SPOT_TOKEN: SpotToken;
237
240
  declare const TESTNET_USDC_SPOT_TOKEN: SpotToken;
238
241
 
242
+ interface PerpsMeta$1 {
243
+ /** Trading universes available for perpetual trading. */
244
+ universe: PerpsUniverse$1[];
245
+ /** Margin requirement tables for different leverage tiers. */
246
+ marginTables: MarginTables;
247
+ /** Collateral token index. */
248
+ collateralToken?: number;
249
+ }
250
+ /** Trading universe parameters for perpetual assets. */
251
+ interface PerpsUniverse$1 {
252
+ /** Minimum decimal places for order sizes. */
253
+ szDecimals: number;
254
+ /** Name of the universe. */
255
+ name: string;
256
+ /** Maximum allowed leverage. */
257
+ maxLeverage: number;
258
+ /** Unique identifier for the margin requirements table. */
259
+ marginTableId: number;
260
+ /** Indicates if only isolated margin trading is allowed. */
261
+ onlyIsolated?: true;
262
+ /** Indicates if the universe is delisted. */
263
+ isDelisted?: true;
264
+ /** Indicates if the universe is in growth mode, eligible for discounted fees */
265
+ growthMode?: "enabled";
266
+ /** Margin mode for the universe. */
267
+ marginMode?: "strictIsolated" | "noCross";
268
+ }
269
+
239
270
  interface PerpDex {
240
271
  /** Short name of the perpetual dex. */
241
272
  name: string;
@@ -267,9 +298,10 @@ interface MarketInfo {
267
298
  dexDisplayName?: string;
268
299
  dexImageUrl?: string;
269
300
  dexCollateralTokenSymbol?: string;
301
+ growthMode: boolean;
270
302
  }
271
303
  interface DexInfo {
272
- meta: PerpsMeta;
304
+ meta: PerpsMeta$1;
273
305
  assetContext: PerpsAssetCtx[];
274
306
  dexFullName: string;
275
307
  dexName: string;
@@ -279,7 +311,7 @@ interface DexInfo {
279
311
  imageUrl?: string;
280
312
  accountName?: string;
281
313
  }
282
- type ExtendedPerpsMeta = PerpsMeta & {
314
+ type ExtendedPerpsMeta = PerpsMeta$1 & {
283
315
  collateralToken?: number;
284
316
  };
285
317
  /**
@@ -324,6 +356,7 @@ interface MetadataClientConfig {
324
356
  * - HIP-3: 100000 + perp_dex_index * 10000 + index_in_meta
325
357
  */
326
358
  declare const ROOT_DEX = "hyperliquid";
359
+ /**@deprecated use react sdk instead */
327
360
  declare class MetadataClient {
328
361
  private infoClient;
329
362
  private config;
@@ -428,7 +461,7 @@ declare class MetadataClient {
428
461
  */
429
462
  getRawMetadata(): {
430
463
  spotMeta: SpotMeta | null;
431
- perpsMeta: PerpsMeta | null;
464
+ perpsMeta: PerpsMeta$1 | null;
432
465
  perpDexs: (PerpDex | null)[];
433
466
  hip3DexsMeta: {
434
467
  [k: string]: DexInfo;
@@ -552,6 +585,8 @@ declare function getStaticCollateralTokenByDex(dex: string): string;
552
585
  * @returns The collateral token symbol for the given coin
553
586
  */
554
587
  declare function getStaticCollateralTokenSymbol(coin: string | undefined): string;
588
+ declare const stableQuoteTokens: string[];
589
+ declare function isStableQuoteToken(coin: string): boolean;
555
590
  /**
556
591
  * Get display market symbol for a given coin
557
592
  * @param coin - The coin symbol to get the display market symbol for eg. xyz:XYZ100
@@ -564,4 +599,40 @@ declare function getStaticCollateralTokenSymbol(coin: string | undefined): strin
564
599
  declare function getDisplayMarketSymbol(coin: string | undefined, showCollateralTokenSymbol?: boolean, collateralTokenSymbol?: string): string | undefined;
565
600
  declare function getDexFromCollateralTokenSymbol(collateralTokenSymbol: string): string | undefined;
566
601
 
567
- 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, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction };
602
+ interface PerpsMeta {
603
+ collateralToken: number;
604
+ /** Trading universes available for perpetual trading. */
605
+ universe: PerpsUniverse[];
606
+ /** Margin requirement tables for different leverage tiers. */
607
+ marginTables: MarginTables;
608
+ }
609
+ /** Metadata and context for perpetual assets. */
610
+ type PerpsMetaAndAssetCtxs = [
611
+ /** Metadata for assets. */
612
+ PerpsMeta,
613
+ /** Context for each perpetual asset. */
614
+ PerpsAssetCtx[]
615
+ ];
616
+ /** Trading universe parameters for perpetual assets. */
617
+ interface PerpsUniverse {
618
+ /** Minimum decimal places for order sizes. */
619
+ szDecimals: number;
620
+ /** Name of the universe. */
621
+ name: string;
622
+ /** Maximum allowed leverage. */
623
+ maxLeverage: number;
624
+ /** Unique identifier for the margin requirements table. */
625
+ marginTableId: number;
626
+ /** Indicates if only isolated margin trading is allowed. */
627
+ onlyIsolated?: true;
628
+ /** Indicates if the universe is delisted. */
629
+ isDelisted?: true;
630
+ /** Indicates if the universe is in growth mode, eligible for discounted fees */
631
+ growthMode?: true;
632
+ /** Margin mode for the universe. */
633
+ marginMode?: "strictIsolated" | "noCross";
634
+ }
635
+ type AllPerpsMeta = PerpsMeta[];
636
+ declare function getAllPerpsMeta(infoClient: InfoClient): Promise<AllPerpsMeta>;
637
+
638
+ export { type AirdropAllocationData, type AllPerpsMeta, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PerpDex, type PerpsMeta, type PerpsMetaAndAssetCtxs, type PerpsUniverse, 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, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getAllPerpsMeta, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SpotToken, PerpsMeta, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
1
+ import { SpotToken, MarginTables, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
2
2
  import { Hex } from '@nktkas/hyperliquid/types';
3
3
 
4
4
  declare function encodeSlug(slug: string): bigint;
@@ -45,6 +45,7 @@ declare const CloidClientCode: {
45
45
  readonly Desktop: 7;
46
46
  readonly API: 8;
47
47
  readonly Stream: 9;
48
+ readonly Pal: 10;
48
49
  };
49
50
  type ClientCodeType = keyof typeof CloidClientCode;
50
51
  type CloidClientCodeId = (typeof CloidClientCode)[ClientCodeType];
@@ -82,17 +83,19 @@ declare const TARGET_APPROVED_MAX_BUILDER_FEE: number;
82
83
  declare const TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT = "0.1%";
83
84
  /**
84
85
  * Get the amount of builder fee to approve for
85
- * @param perpetualTradingFee - Perp fee in percentage
86
- * @param spotTradingFee - Spot fee in percentage
86
+ * @param perpetualTradingFee - Perp fee in percentage (0.025 means 0.025% perp fee)
87
+ * @param spotTradingFee - Spot fee in percentage (0.01 means 0.01% spot fee)
88
+ * @param feeDiscount - Discount fee in percentage (0.9 means 90% discount)
87
89
  * @returns {
88
90
  * amount: number; - The amount of builder fee to approve in 1/10 of a basis point
89
91
  * percent: string; - eg. String input to approve fee, "0.1%"
90
92
  * }
91
93
  */
92
- declare const getApprovalAmount: ({ customFeeEnabled, perpetualTradingFee, spotTradingFee, }: {
94
+ declare const getApprovalAmount: ({ customFeeEnabled, perpetualTradingFee, spotTradingFee, feeDiscount, }: {
93
95
  customFeeEnabled: boolean;
94
96
  perpetualTradingFee?: number;
95
97
  spotTradingFee?: number;
98
+ feeDiscount?: number;
96
99
  }) => {
97
100
  approvalAmount: number;
98
101
  approvalPercent: `${string}%`;
@@ -236,6 +239,34 @@ declare function getNextTierInfo(pupTokenAmount: number, normalizedAirDropAmount
236
239
  declare const USDC_SPOT_TOKEN: SpotToken;
237
240
  declare const TESTNET_USDC_SPOT_TOKEN: SpotToken;
238
241
 
242
+ interface PerpsMeta$1 {
243
+ /** Trading universes available for perpetual trading. */
244
+ universe: PerpsUniverse$1[];
245
+ /** Margin requirement tables for different leverage tiers. */
246
+ marginTables: MarginTables;
247
+ /** Collateral token index. */
248
+ collateralToken?: number;
249
+ }
250
+ /** Trading universe parameters for perpetual assets. */
251
+ interface PerpsUniverse$1 {
252
+ /** Minimum decimal places for order sizes. */
253
+ szDecimals: number;
254
+ /** Name of the universe. */
255
+ name: string;
256
+ /** Maximum allowed leverage. */
257
+ maxLeverage: number;
258
+ /** Unique identifier for the margin requirements table. */
259
+ marginTableId: number;
260
+ /** Indicates if only isolated margin trading is allowed. */
261
+ onlyIsolated?: true;
262
+ /** Indicates if the universe is delisted. */
263
+ isDelisted?: true;
264
+ /** Indicates if the universe is in growth mode, eligible for discounted fees */
265
+ growthMode?: "enabled";
266
+ /** Margin mode for the universe. */
267
+ marginMode?: "strictIsolated" | "noCross";
268
+ }
269
+
239
270
  interface PerpDex {
240
271
  /** Short name of the perpetual dex. */
241
272
  name: string;
@@ -267,9 +298,10 @@ interface MarketInfo {
267
298
  dexDisplayName?: string;
268
299
  dexImageUrl?: string;
269
300
  dexCollateralTokenSymbol?: string;
301
+ growthMode: boolean;
270
302
  }
271
303
  interface DexInfo {
272
- meta: PerpsMeta;
304
+ meta: PerpsMeta$1;
273
305
  assetContext: PerpsAssetCtx[];
274
306
  dexFullName: string;
275
307
  dexName: string;
@@ -279,7 +311,7 @@ interface DexInfo {
279
311
  imageUrl?: string;
280
312
  accountName?: string;
281
313
  }
282
- type ExtendedPerpsMeta = PerpsMeta & {
314
+ type ExtendedPerpsMeta = PerpsMeta$1 & {
283
315
  collateralToken?: number;
284
316
  };
285
317
  /**
@@ -324,6 +356,7 @@ interface MetadataClientConfig {
324
356
  * - HIP-3: 100000 + perp_dex_index * 10000 + index_in_meta
325
357
  */
326
358
  declare const ROOT_DEX = "hyperliquid";
359
+ /**@deprecated use react sdk instead */
327
360
  declare class MetadataClient {
328
361
  private infoClient;
329
362
  private config;
@@ -428,7 +461,7 @@ declare class MetadataClient {
428
461
  */
429
462
  getRawMetadata(): {
430
463
  spotMeta: SpotMeta | null;
431
- perpsMeta: PerpsMeta | null;
464
+ perpsMeta: PerpsMeta$1 | null;
432
465
  perpDexs: (PerpDex | null)[];
433
466
  hip3DexsMeta: {
434
467
  [k: string]: DexInfo;
@@ -552,6 +585,8 @@ declare function getStaticCollateralTokenByDex(dex: string): string;
552
585
  * @returns The collateral token symbol for the given coin
553
586
  */
554
587
  declare function getStaticCollateralTokenSymbol(coin: string | undefined): string;
588
+ declare const stableQuoteTokens: string[];
589
+ declare function isStableQuoteToken(coin: string): boolean;
555
590
  /**
556
591
  * Get display market symbol for a given coin
557
592
  * @param coin - The coin symbol to get the display market symbol for eg. xyz:XYZ100
@@ -564,4 +599,40 @@ declare function getStaticCollateralTokenSymbol(coin: string | undefined): strin
564
599
  declare function getDisplayMarketSymbol(coin: string | undefined, showCollateralTokenSymbol?: boolean, collateralTokenSymbol?: string): string | undefined;
565
600
  declare function getDexFromCollateralTokenSymbol(collateralTokenSymbol: string): string | undefined;
566
601
 
567
- 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, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction };
602
+ interface PerpsMeta {
603
+ collateralToken: number;
604
+ /** Trading universes available for perpetual trading. */
605
+ universe: PerpsUniverse[];
606
+ /** Margin requirement tables for different leverage tiers. */
607
+ marginTables: MarginTables;
608
+ }
609
+ /** Metadata and context for perpetual assets. */
610
+ type PerpsMetaAndAssetCtxs = [
611
+ /** Metadata for assets. */
612
+ PerpsMeta,
613
+ /** Context for each perpetual asset. */
614
+ PerpsAssetCtx[]
615
+ ];
616
+ /** Trading universe parameters for perpetual assets. */
617
+ interface PerpsUniverse {
618
+ /** Minimum decimal places for order sizes. */
619
+ szDecimals: number;
620
+ /** Name of the universe. */
621
+ name: string;
622
+ /** Maximum allowed leverage. */
623
+ maxLeverage: number;
624
+ /** Unique identifier for the margin requirements table. */
625
+ marginTableId: number;
626
+ /** Indicates if only isolated margin trading is allowed. */
627
+ onlyIsolated?: true;
628
+ /** Indicates if the universe is delisted. */
629
+ isDelisted?: true;
630
+ /** Indicates if the universe is in growth mode, eligible for discounted fees */
631
+ growthMode?: true;
632
+ /** Margin mode for the universe. */
633
+ marginMode?: "strictIsolated" | "noCross";
634
+ }
635
+ type AllPerpsMeta = PerpsMeta[];
636
+ declare function getAllPerpsMeta(infoClient: InfoClient): Promise<AllPerpsMeta>;
637
+
638
+ export { type AirdropAllocationData, type AllPerpsMeta, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PerpDex, type PerpsMeta, type PerpsMetaAndAssetCtxs, type PerpsUniverse, 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, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getAllPerpsMeta, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };