@basedone/core 0.2.7 → 0.3.0

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.
Files changed (41) hide show
  1. package/dist/{chunk-L63E7FZC.mjs → chunk-35WGIB5F.mjs} +165 -1
  2. package/dist/{client-CgmiTuEX.d.mts → client-BQzYwHDY.d.mts} +5 -2
  3. package/dist/{client-CgmiTuEX.d.ts → client-BQzYwHDY.d.ts} +5 -2
  4. package/dist/ecommerce.d.mts +195 -2
  5. package/dist/ecommerce.d.ts +195 -2
  6. package/dist/ecommerce.js +176 -0
  7. package/dist/ecommerce.mjs +1 -2
  8. package/dist/index.d.mts +114 -160
  9. package/dist/index.d.ts +114 -160
  10. package/dist/index.js +462 -41454
  11. package/dist/index.mjs +246 -639
  12. package/dist/react.d.mts +1 -1
  13. package/dist/react.d.ts +1 -1
  14. package/dist/react.mjs +0 -1
  15. package/index.ts +3 -0
  16. package/lib/abstraction/api.ts +106 -0
  17. package/lib/abstraction/index.ts +3 -0
  18. package/lib/abstraction/ratio.ts +61 -0
  19. package/lib/abstraction/types.ts +73 -0
  20. package/lib/constants/admin.ts +30 -0
  21. package/lib/ecommerce/client/customer.ts +42 -0
  22. package/lib/ecommerce/index.ts +14 -0
  23. package/lib/ecommerce/types/entities.ts +70 -0
  24. package/lib/ecommerce/types/enums.ts +37 -1
  25. package/lib/ecommerce/types/requests.ts +2 -0
  26. package/lib/ecommerce/types/responses.ts +28 -0
  27. package/lib/ecommerce/utils/orderStateMachine.ts +197 -0
  28. package/lib/hip3/market-info.ts +5 -1
  29. package/lib/hip3/utils.ts +2 -0
  30. package/lib/meta/metadata.ts +0 -666
  31. package/lib/types.ts +29 -0
  32. package/package.json +1 -1
  33. package/dist/chunk-4UEJOM6W.mjs +0 -7
  34. package/dist/meta-JB5ITE27.mjs +0 -1390
  35. package/dist/meta-UOGUG3OW.mjs +0 -1504
  36. package/dist/perpDexs-3LRJ5ZHM.mjs +0 -288
  37. package/dist/perpDexs-4ISLD7NX.mjs +0 -2975
  38. package/dist/spotMeta-GHXX7C5M.mjs +0 -6968
  39. package/dist/spotMeta-IBBUP2SG.mjs +0 -27592
  40. package/dist/staticMeta-GM7T3OYL.mjs +0 -20
  41. package/dist/staticMeta-QV2KMX57.mjs +0 -22
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
- import { SpotToken, MarginTables, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
2
- import { Hex } from '@nktkas/hyperliquid/types';
3
- export { A as AllPerpsMeta, d as AssetIdUtils, B as BaseInstrument, I as InstrumentClient, M as MarketInstrument, c as PerpsInstrument, P as PerpsMeta, a as PerpsMetaAndAssetCtxs, b as PerpsUniverse, S as SpotInstrument, g as getAllPerpsMeta } from './client-CgmiTuEX.mjs';
4
- export { ActiveFlashSalesResponse, AnalyticsOverview, ApiResponse, AppliedDiscount, Banner, BannerResponse, BannerType, BaseEcommerceClient, BaseEntity, BrowsingLocation, CalculateCartDiscountsRequest, CalculateCartDiscountsResponse, CalculateShippingRequest, CalculateShippingResponse, CalculateTaxRequest, CalculateTaxResponse, CartItem, CashAccountBalanceResponse, ConfirmEscrowDepositResponse, Coupon, CouponResponse, CouponUsage, CreateBannerRequest, CreateCouponRequest, CreateFlashSaleRequest, CreateOrderEventRequest, CreateOrderEventResponse, CreateOrderRequest, CreateOrderResponse, CreateProductRequest, CreateProductVariantRequest, CreateReviewRequest, CreateShippingMethodRequest, CreateShippingRateRequest, CreateShippingZoneRequest, CreateTaxNexusRequest, CreateTaxRuleRequest, CustomerEcommerceClient, CustomerMessagesResponse, CustomerSummary, DeleteBrowsingLocationResponse, DeliveryAddressResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, ExpiringGemBatch, FlashSale, FlashSaleAllowanceInfo, FlashSaleItem, FlashSaleItemInput, FollowActionResponse, FollowStatusResponse, FollowedMerchantSummary, GemHistoryItem, GemHistoryType, GemHistoryTypeFilter, GemSource, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetBrowsingLocationResponse, GetCouponResponse, GetExpiringGemsParams, GetExpiringGemsResponse, GetFlashSaleAllowanceParams, GetFlashSaleAllowanceResponse, GetGemBalanceResponse, GetGemHistoryParams, GetGemHistoryResponse, GetOrderResponse, GetPaymentMethodsResponse, GetProductMetricsResponse, GetProductResponse, GetTaxReportResponse, InventoryAuditAction, InventoryAuditEntry, ListActiveBannersParams, ListActiveFlashSalesParams, ListBannersResponse, ListCouponsResponse, ListCustomersParams, ListCustomersResponse, ListFollowingParams, ListFollowingResponse, ListInventoryAuditResponse, ListMediaAssetsResponse, ListMerchantProductsParams, ListMessagesResponse, ListOrdersParams, ListOrdersResponse, ListProductVariantsResponse, ListProductsParams, ListProductsResponse, ListReturnsResponse, ListReviewsParams, ListReviewsResponse, ListShipmentsResponse, ListShippingAddressesResponse, ListShippingMethodsResponse, ListShippingRatesResponse, ListShippingZonesResponse, ListTaxNexusResponse, ListTaxReportsParams, ListTaxReportsResponse, ListTaxRulesResponse, MediaAsset, MediaAssetResponse, Merchant, MerchantEcommerceClient, MerchantProductsResponse, MerchantProfileRequest, MerchantProfileResponse, MerchantShippingSettings, MerchantStatus, Message, MessageResponse, MessageStatsResponse, Order, OrderEvent, OrderItem, OrderReceiptResponse, OrderStatus, OrdersByStatus, PaginatedResponse, PaginationParams, Payment, PaymentMethod, PaymentMethodInfo, PaymentStatus, ProcessPaymentRequest, ProcessPaymentResponse, Product, ProductDimensions, ProductDiscountsResponse, ProductMetrics, ProductResponse, ProductReview, ProductSortBy, ProductVariant, ProductVariantResponse, PublicMerchantProfile, PublicMerchantProfileResponse, RecentOrderSummary, RespondToReviewRequest, Return, ReturnItem, ReturnResponse, ReturnStatus, RevenueByDay, ReviewResponse, ReviewSortBy, ReviewStatus, SaveBrowsingLocationRequest, SaveBrowsingLocationResponse, SendMessageRequest, Settlement, Shipment, ShipmentResponse, ShipmentStatus, ShippingAddress, ShippingAddressRequest, ShippingAddressResponse, ShippingMethod, ShippingMethodResponse, ShippingOption, ShippingRate, ShippingRateResponse, ShippingSettingsResponse, ShippingZone, ShippingZoneResponse, SortOrder, SuccessResponse, TaxBehavior, TaxBreakdownItem, TaxNexus, TaxNexusResponse, TaxReport, TaxReportDetails, TaxReportPeriodType, TaxReportResponse, TaxReportStatus, TaxRule, TaxRuleResponse, TaxSettings, TaxSettingsResponse, TaxType, TopProduct, TrackBannerRequest, UpdateBannerRequest, UpdateCouponRequest, UpdateFlashSaleRequest, UpdateOrderResponse, UpdateOrderStatusRequest, UpdateProductRequest, UpdateProductVariantRequest, UpdateShipmentRequest, UpdateShippingMethodRequest, UpdateShippingRateRequest, UpdateShippingSettingsRequest, UpdateShippingZoneRequest, UpdateTaxNexusRequest, UpdateTaxReportStatusRequest, UpdateTaxRuleRequest, UpdateTaxSettingsRequest, UserShippingAddress, ValidateDiscountRequest, ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './ecommerce.mjs';
1
+ import { SpotToken, MarginTables, PerpsAssetCtx, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
2
+ export { A as AllPerpsMeta, a as AssetIdUtils, B as BaseInstrument, I as InstrumentClient, M as MarketInstrument, P as PerpDex, b as PerpsInstrument, c as PerpsMeta, d as PerpsMetaAndAssetCtxs, e as PerpsUniverse, S as SpotInstrument, g as getAllPerpsMeta } from './client-BQzYwHDY.mjs';
3
+ export { ActiveFlashSalesResponse, AnalyticsOverview, ApiResponse, AppliedDiscount, Banner, BannerResponse, BannerType, BaseEcommerceClient, BaseEntity, BrowsingLocation, CalculateCartDiscountsRequest, CalculateCartDiscountsResponse, CalculateShippingRequest, CalculateShippingResponse, CalculateTaxRequest, CalculateTaxResponse, CartItem, CashAccountBalanceResponse, ConfirmEscrowDepositResponse, Coupon, CouponResponse, CouponUsage, CreateBannerRequest, CreateCouponRequest, CreateFlashSaleRequest, CreateOrderEventRequest, CreateOrderEventResponse, CreateOrderRequest, CreateOrderResponse, CreateProductRequest, CreateProductVariantRequest, CreateReviewRequest, CreateShippingMethodRequest, CreateShippingRateRequest, CreateShippingZoneRequest, CreateTaxNexusRequest, CreateTaxRuleRequest, CustomerEcommerceClient, CustomerMessagesResponse, CustomerNotification, CustomerNotificationsResponse, CustomerSummary, DeleteBrowsingLocationResponse, DeliveryAddressResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, ExpiringGemBatch, FlashSale, FlashSaleAllowanceInfo, FlashSaleItem, FlashSaleItemInput, FollowActionResponse, FollowStatusResponse, FollowedMerchantSummary, GemHistoryItem, GemHistoryType, GemHistoryTypeFilter, GemSource, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetBrowsingLocationResponse, GetCouponResponse, GetExpiringGemsParams, GetExpiringGemsResponse, GetFlashSaleAllowanceParams, GetFlashSaleAllowanceResponse, GetGemBalanceResponse, GetGemHistoryParams, GetGemHistoryResponse, GetOrderResponse, GetPaymentMethodsResponse, GetProductMetricsResponse, GetProductResponse, GetTaxReportResponse, InventoryAuditAction, InventoryAuditEntry, ListActiveBannersParams, ListActiveFlashSalesParams, ListBannersResponse, ListCouponsResponse, ListCustomersParams, ListCustomersResponse, ListFollowingParams, ListFollowingResponse, ListInventoryAuditResponse, ListMediaAssetsResponse, ListMerchantProductsParams, ListMessagesResponse, ListOrdersParams, ListOrdersResponse, ListProductVariantsResponse, ListProductsParams, ListProductsResponse, ListReturnsResponse, ListReviewsParams, ListReviewsResponse, ListShipmentsResponse, ListShippingAddressesResponse, ListShippingMethodsResponse, ListShippingRatesResponse, ListShippingZonesResponse, ListTaxNexusResponse, ListTaxReportsParams, ListTaxReportsResponse, ListTaxRulesResponse, MarkNotificationsReadResponse, MediaAsset, MediaAssetResponse, Merchant, MerchantBusinessType, MerchantEcommerceClient, MerchantProductsResponse, MerchantProfileRequest, MerchantProfileResponse, MerchantReturnPolicyType, MerchantShippingSettings, MerchantSocialLinks, MerchantStatus, Message, MessageResponse, MessageStatsResponse, ORDER_STATUS_TRANSITIONS, Order, OrderEvent, OrderItem, OrderReceiptResponse, OrderStatus, OrdersByStatus, PaginatedResponse, PaginationParams, Payment, PaymentMethod, PaymentMethodInfo, PaymentStatus, ProcessPaymentRequest, ProcessPaymentResponse, Product, ProductDimensions, ProductDiscountsResponse, ProductMetrics, ProductResponse, ProductReview, ProductSortBy, ProductVariant, ProductVariantResponse, PublicMerchantProfile, PublicMerchantProfileResponse, RecentOrderSummary, RespondToReviewRequest, Return, ReturnItem, ReturnResponse, ReturnStatus, RevenueByDay, ReviewResponse, ReviewSortBy, ReviewStatus, SaveBrowsingLocationRequest, SaveBrowsingLocationResponse, SendMessageRequest, Settlement, Shipment, ShipmentResponse, ShipmentStatus, ShippingAddress, ShippingAddressRequest, ShippingAddressResponse, ShippingMethod, ShippingMethodResponse, ShippingOption, ShippingRate, ShippingRateResponse, ShippingSettingsResponse, ShippingZone, ShippingZoneResponse, SortOrder, SuccessResponse, TaxBehavior, TaxBreakdownItem, TaxNexus, TaxNexusResponse, TaxReport, TaxReportDetails, TaxReportPeriodType, TaxReportResponse, TaxReportStatus, TaxRule, TaxRuleResponse, TaxSettings, TaxSettingsResponse, TaxType, TopProduct, TrackBannerRequest, UpdateBannerRequest, UpdateCouponRequest, UpdateFlashSaleRequest, UpdateOrderResponse, UpdateOrderStatusRequest, UpdateProductRequest, UpdateProductVariantRequest, UpdateShipmentRequest, UpdateShippingMethodRequest, UpdateShippingRateRequest, UpdateShippingSettingsRequest, UpdateShippingZoneRequest, UpdateTaxNexusRequest, UpdateTaxReportStatusRequest, UpdateTaxRuleRequest, UpdateTaxSettingsRequest, UserShippingAddress, ValidateDiscountRequest, ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, canCancelOrder, formatPrice, getBackoffDelay, getNextStatuses, getStatusColor, getStatusLabel, getStatusProgress, isPickupOrder, isRetryableError, isValidAddress, isValidEmail, parseError, requiresTrackingInfo, retryWithBackoff, shouldNotifyCustomer, sleep, truncateAddress, validateStatusTransition } from './ecommerce.mjs';
5
4
  import 'axios';
6
5
 
7
6
  declare function encodeSlug(slug: string): bigint;
@@ -242,6 +241,9 @@ declare function getNextTierInfo(pupTokenAmount: number, normalizedAirDropAmount
242
241
  declare const USDC_SPOT_TOKEN: SpotToken;
243
242
  declare const TESTNET_USDC_SPOT_TOKEN: SpotToken;
244
243
 
244
+ declare const ADMINS: string[];
245
+ declare const ADMIN_WALLETS: string[];
246
+
245
247
  interface PerpsMeta {
246
248
  /** Trading universes available for perpetual trading. */
247
249
  universe: PerpsUniverse[];
@@ -270,18 +272,6 @@ interface PerpsUniverse {
270
272
  marginMode?: "strictIsolated" | "noCross";
271
273
  }
272
274
 
273
- interface PerpDex {
274
- /** Short name of the perpetual dex. */
275
- name: string;
276
- /** Complete name of the perpetual dex. */
277
- fullName: string;
278
- /** Hex address of the dex deployer. */
279
- deployer: Hex;
280
- /** Hex address of the oracle updater, or null if not available. */
281
- oracleUpdater: Hex | null;
282
- feeRecipient: Hex | null;
283
- assetToStreamingOiCap: [string, string][];
284
- }
285
275
  /**
286
276
  * Market information for trading operations
287
277
  */
@@ -327,23 +317,6 @@ interface TokenInfo {
327
317
  weiDecimals: number;
328
318
  tokenId: string;
329
319
  }
330
- /**
331
- * Configuration for MetadataClient
332
- */
333
- interface MetadataClientConfig {
334
- /** List of HIP-3 DEX names to load metadata for */
335
- hip3Dexs?: string[];
336
- /** Whether to lazily initialize (fetch metadata on first use) */
337
- lazyInit?: boolean;
338
- /** Whether to use testnet (default: false for mainnet) */
339
- isTestnet?: boolean;
340
- /** Use static fallback data only, no API fetch */
341
- onlyUseStaticFallback?: boolean;
342
- /** Whether to use static fallback data if API fetch fails (default: true) */
343
- useStaticFallback?: boolean;
344
- /** Whether to enable debug logs (default: false) */
345
- debug?: boolean;
346
- }
347
320
  /**
348
321
  * MetadataClient - Handles Hyperliquid metadata for trading operations
349
322
  *
@@ -359,132 +332,6 @@ interface MetadataClientConfig {
359
332
  * - HIP-3: 100000 + perp_dex_index * 10000 + index_in_meta
360
333
  */
361
334
  declare const ROOT_DEX = "hyperliquid";
362
- /**@deprecated use react sdk instead */
363
- declare class MetadataClient {
364
- private infoClient;
365
- private config;
366
- private isTestnet;
367
- private spotMeta;
368
- private perpsMeta;
369
- private perpDexs;
370
- private staticMeta;
371
- private hip3DexsMeta;
372
- private perpsSymbolToIndex;
373
- private spotTokenNameToIndex;
374
- private spotPairToMarket;
375
- private baseTokenToMarkets;
376
- private quoteAssets;
377
- private coinToMarket;
378
- private hip3SymbolToMarket;
379
- private dexNameToIndex;
380
- private initialized;
381
- private initializing;
382
- constructor(config?: MetadataClientConfig);
383
- /**
384
- * Initialize metadata by fetching from Hyperliquid
385
- */
386
- initialize(): Promise<void>;
387
- /**
388
- * Load staticMeta.json for display overrides
389
- * This is always loaded regardless of config.useStaticFallback
390
- */
391
- private loadStaticMetaOverrides;
392
- /**
393
- * Load static metadata from bundled JSON files
394
- */
395
- private loadStaticMetadata;
396
- /**
397
- * Build optimized lookup maps from raw metadata
398
- * Called after metadata is loaded (from API or static files)
399
- */
400
- private buildLookupMaps;
401
- /**
402
- * Load metadata for a specific HIP-3 DEX
403
- * Also builds optimized lookups for this DEX's markets
404
- */
405
- loadHip3Metadata(dexName: string): Promise<DexInfo>;
406
- /**
407
- * Build optimized lookups for HIP-3 markets of a specific DEX
408
- */
409
- private buildHip3MarketsForDex;
410
- /**
411
- * Ensure metadata is loaded (for lazy init)
412
- */
413
- private ensureInitialized;
414
- /**
415
- * Get market information by symbol
416
- * Optimized: O(1) direct map lookup for most cases
417
- * Lazily initialize hip-3 metadata if not already initialized
418
- *
419
- * @param symbol - Market symbol (e.g., "BTC", "PURR/USDC", "vntls:ABC")
420
- * @param quoteAsset - Quote asset for spot markets (default: "USDC")
421
- * @returns Market information or null if not found
422
- */
423
- getMarketBySymbolAsync(symbol: string, quoteAsset?: string): Promise<MarketInfo | null>;
424
- getMarketByCoin(coin: string): MarketInfo | null;
425
- /**
426
- * Get perpetuals market information
427
- * Optimized: O(1) map lookup instead of O(n) array search
428
- */
429
- getPerpsMarket(symbol: string): MarketInfo | null;
430
- /**
431
- * Get spot market information
432
- * Optimized: O(1) map lookup instead of O(n) array searches
433
- *
434
- * @param baseSymbol - Base token symbol (e.g., "PURR", "UHYPE")
435
- * @param quoteSymbol - Quote token symbol (default: "USDC")
436
- */
437
- getSpotMarket(baseSymbol: string, quoteSymbol?: string): MarketInfo | null;
438
- /**
439
- * Get HIP-3 market information
440
- * Optimized: O(1) map lookup after DEX metadata is loaded
441
- *
442
- * @param symbol - HIP-3 market symbol (format: "dex:coin")
443
- */
444
- getHip3Market(symbol: string): Promise<MarketInfo | null>;
445
- getHip3Dex(dexName: string): Promise<DexInfo | null>;
446
- /**
447
- * Get all available markets for a base token
448
- * Optimized: O(1) map lookup instead of O(n) filter + map
449
- * Useful for showing all quote asset options
450
- */
451
- getAllMarketsForBase(baseSymbol: string): MarketInfo[];
452
- /**
453
- * Get spot token information
454
- * Optimized: O(1) map lookup instead of O(n) array search
455
- */
456
- getSpotTokenInfo(tokenSymbol: string): TokenInfo | null;
457
- /**
458
- * Get all available quote assets
459
- * Optimized: O(1) pre-computed array instead of O(n) computation
460
- */
461
- getAvailableQuoteAssets(): string[];
462
- /**
463
- * Get raw metadata (for advanced use cases)
464
- */
465
- getRawMetadata(): {
466
- spotMeta: SpotMeta | null;
467
- perpsMeta: PerpsMeta | null;
468
- perpDexs: (PerpDex | null)[];
469
- hip3DexsMeta: {
470
- [k: string]: DexInfo;
471
- };
472
- coinToMarket: {
473
- [k: string]: MarketInfo;
474
- };
475
- hip3SymbolToMarket: {
476
- [k: string]: MarketInfo;
477
- };
478
- };
479
- /**
480
- * Get network configuration
481
- */
482
- getNetworkInfo(): {
483
- isTestnet: boolean;
484
- useStaticFallback: boolean | undefined;
485
- initialized: boolean;
486
- };
487
- }
488
335
 
489
336
  declare const formatPriceAndSize: ({ px, sz, szDecimals, isSpot, }: {
490
337
  px: number;
@@ -652,4 +499,111 @@ declare function isStableQuoteToken(coin: string): boolean;
652
499
  declare function getDisplayMarketSymbol(coin: string | undefined, showCollateralTokenSymbol?: boolean, collateralTokenSymbol?: string): string | undefined;
653
500
  declare function getDexFromCollateralTokenSymbol(collateralTokenSymbol: string): string | undefined;
654
501
 
655
- export { type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, DayOfWeek, 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, type WeekInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getLatestCompletedWeek, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWeekInfoFromNumber, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, makeUtcRounder, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };
502
+ /**
503
+ * User abstraction modes for controlling how spot and perps balances interact.
504
+ *
505
+ * - `disabled` (Standard): Separate perp and spot balances, separate DEX balances.
506
+ * - `unifiedAccount`: Single balance per asset collateralizing all cross margin positions.
507
+ * - `portfolioMargin`: Single portfolio unifying all eligible assets (pre-alpha).
508
+ * - `dexAbstraction`: Legacy mode (to be discontinued).
509
+ * - `default`: Server default (equivalent to standard/disabled for most users).
510
+ */
511
+ type UserAbstractionMode = "unifiedAccount" | "portfolioMargin" | "disabled" | "default" | "dexAbstraction";
512
+ /**
513
+ * Shorthand codes used with agent-based abstraction setting.
514
+ * - `i` = disabled (standard)
515
+ * - `u` = unifiedAccount
516
+ * - `p` = portfolioMargin
517
+ */
518
+ type AgentAbstractionCode = "i" | "u" | "p";
519
+ /**
520
+ * Settable abstraction modes (excludes read-only states like "default" and "dexAbstraction").
521
+ */
522
+ type SettableAbstractionMode = "disabled" | "unifiedAccount" | "portfolioMargin";
523
+ declare const ABSTRACTION_MODE_TO_AGENT_CODE: Record<SettableAbstractionMode, AgentAbstractionCode>;
524
+ declare const AGENT_CODE_TO_ABSTRACTION_MODE: Record<AgentAbstractionCode, SettableAbstractionMode>;
525
+ interface MultiverseMeta {
526
+ index: number;
527
+ collateralToken: number;
528
+ }
529
+ interface PerpDexAssetPosition {
530
+ position: {
531
+ leverage: {
532
+ type: string;
533
+ };
534
+ marginUsed: number;
535
+ };
536
+ }
537
+ interface PerpDexClearinghouseState {
538
+ clearinghouseState: {
539
+ crossMaintenanceMarginUsed: number;
540
+ assetPositions: PerpDexAssetPosition[];
541
+ };
542
+ }
543
+ interface SpotBalance {
544
+ token: number;
545
+ total: number;
546
+ }
547
+
548
+ declare const UserSetAbstractionTypes: {
549
+ "HyperliquidTransaction:UserSetAbstraction": {
550
+ name: string;
551
+ type: string;
552
+ }[];
553
+ };
554
+ /**
555
+ * Query a user's current account abstraction mode.
556
+ */
557
+ declare function getUserAbstraction(client: InfoClient, user: string): Promise<UserAbstractionMode>;
558
+ /**
559
+ * Set account abstraction mode using the owner wallet (user-signed action).
560
+ *
561
+ * Requires EIP-712 signature from the account owner.
562
+ */
563
+ declare function setUserAbstraction(client: ExchangeClient, abstraction: SettableAbstractionMode, user: string): Promise<SuccessResponse>;
564
+ /**
565
+ * Set account abstraction mode using an agent wallet.
566
+ *
567
+ * Uses shorthand codes: "i" (disabled), "u" (unifiedAccount), "p" (portfolioMargin).
568
+ */
569
+ declare function agentSetAbstraction(client: ExchangeClient, abstraction: SettableAbstractionMode): Promise<SuccessResponse>;
570
+
571
+ /**
572
+ * Compute the unified account ratio for monitoring liquidation risk.
573
+ *
574
+ * The ratio represents cross maintenance margin used / available balance
575
+ * for the most leveraged collateral token. A higher ratio means closer
576
+ * to liquidation.
577
+ *
578
+ * @param multiverse - Map of DEX name to its metadata (index and collateral token)
579
+ * @param perpDexStates - Array of per-DEX clearinghouse states
580
+ * @param spotBalances - Array of spot balances per token
581
+ * @returns The maximum ratio across all collateral tokens (0 if no margin used)
582
+ */
583
+ declare function computeUnifiedAccountRatio(multiverse: Record<string, MultiverseMeta>, perpDexStates: PerpDexClearinghouseState[], spotBalances: SpotBalance[]): number;
584
+
585
+ interface PerpDexState {
586
+ totalVaultEquity: number;
587
+ perpsAtOpenInterestCap?: Array<string>;
588
+ leadingVaults?: Array<LeadingVault>;
589
+ }
590
+ interface WsWebData3 {
591
+ userState: {
592
+ abstraction: UserAbstractionMode;
593
+ agentAddress: string | null;
594
+ agentValidUntil: number | null;
595
+ serverTime: number;
596
+ cumLedger: number;
597
+ isVault: boolean;
598
+ user: string;
599
+ optOutOfSpotDusting?: boolean;
600
+ dexAbstractionEnabled?: boolean;
601
+ };
602
+ perpDexStates: Array<PerpDexState>;
603
+ }
604
+ interface LeadingVault {
605
+ address: string;
606
+ name: string;
607
+ }
608
+
609
+ export { ABSTRACTION_MODE_TO_AGENT_CODE, ADMINS, ADMIN_WALLETS, AGENT_CODE_TO_ABSTRACTION_MODE, type AgentAbstractionCode, type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, DayOfWeek, type DexInfo, type ExtendedPerpsMeta, type LeadingVault, type MarketInfo, type MultiverseMeta, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PerpDexAssetPosition, type PerpDexClearinghouseState, type PerpDexState, type PupEligibilityResult, ROOT_DEX, type SettableAbstractionMode, type SpotBalance, 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 UserAbstractionMode, UserDexAbstractionTypes, UserSetAbstractionTypes, type V3LPTokenInfo, type WeekInfo, WidgetType, WidgetTypeById, type WidgetTypeId, type WsWebData3, XP_BOOST_PERCENTAGES, agentSetAbstraction, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, computeUnifiedAccountRatio, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getLatestCompletedWeek, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getUserAbstraction, getWeekInfoFromNumber, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, makeUtcRounder, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, setUserAbstraction, stableQuoteTokens };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { SpotToken, MarginTables, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
2
- import { Hex } from '@nktkas/hyperliquid/types';
3
- export { A as AllPerpsMeta, d as AssetIdUtils, B as BaseInstrument, I as InstrumentClient, M as MarketInstrument, c as PerpsInstrument, P as PerpsMeta, a as PerpsMetaAndAssetCtxs, b as PerpsUniverse, S as SpotInstrument, g as getAllPerpsMeta } from './client-CgmiTuEX.js';
4
- export { ActiveFlashSalesResponse, AnalyticsOverview, ApiResponse, AppliedDiscount, Banner, BannerResponse, BannerType, BaseEcommerceClient, BaseEntity, BrowsingLocation, CalculateCartDiscountsRequest, CalculateCartDiscountsResponse, CalculateShippingRequest, CalculateShippingResponse, CalculateTaxRequest, CalculateTaxResponse, CartItem, CashAccountBalanceResponse, ConfirmEscrowDepositResponse, Coupon, CouponResponse, CouponUsage, CreateBannerRequest, CreateCouponRequest, CreateFlashSaleRequest, CreateOrderEventRequest, CreateOrderEventResponse, CreateOrderRequest, CreateOrderResponse, CreateProductRequest, CreateProductVariantRequest, CreateReviewRequest, CreateShippingMethodRequest, CreateShippingRateRequest, CreateShippingZoneRequest, CreateTaxNexusRequest, CreateTaxRuleRequest, CustomerEcommerceClient, CustomerMessagesResponse, CustomerSummary, DeleteBrowsingLocationResponse, DeliveryAddressResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, ExpiringGemBatch, FlashSale, FlashSaleAllowanceInfo, FlashSaleItem, FlashSaleItemInput, FollowActionResponse, FollowStatusResponse, FollowedMerchantSummary, GemHistoryItem, GemHistoryType, GemHistoryTypeFilter, GemSource, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetBrowsingLocationResponse, GetCouponResponse, GetExpiringGemsParams, GetExpiringGemsResponse, GetFlashSaleAllowanceParams, GetFlashSaleAllowanceResponse, GetGemBalanceResponse, GetGemHistoryParams, GetGemHistoryResponse, GetOrderResponse, GetPaymentMethodsResponse, GetProductMetricsResponse, GetProductResponse, GetTaxReportResponse, InventoryAuditAction, InventoryAuditEntry, ListActiveBannersParams, ListActiveFlashSalesParams, ListBannersResponse, ListCouponsResponse, ListCustomersParams, ListCustomersResponse, ListFollowingParams, ListFollowingResponse, ListInventoryAuditResponse, ListMediaAssetsResponse, ListMerchantProductsParams, ListMessagesResponse, ListOrdersParams, ListOrdersResponse, ListProductVariantsResponse, ListProductsParams, ListProductsResponse, ListReturnsResponse, ListReviewsParams, ListReviewsResponse, ListShipmentsResponse, ListShippingAddressesResponse, ListShippingMethodsResponse, ListShippingRatesResponse, ListShippingZonesResponse, ListTaxNexusResponse, ListTaxReportsParams, ListTaxReportsResponse, ListTaxRulesResponse, MediaAsset, MediaAssetResponse, Merchant, MerchantEcommerceClient, MerchantProductsResponse, MerchantProfileRequest, MerchantProfileResponse, MerchantShippingSettings, MerchantStatus, Message, MessageResponse, MessageStatsResponse, Order, OrderEvent, OrderItem, OrderReceiptResponse, OrderStatus, OrdersByStatus, PaginatedResponse, PaginationParams, Payment, PaymentMethod, PaymentMethodInfo, PaymentStatus, ProcessPaymentRequest, ProcessPaymentResponse, Product, ProductDimensions, ProductDiscountsResponse, ProductMetrics, ProductResponse, ProductReview, ProductSortBy, ProductVariant, ProductVariantResponse, PublicMerchantProfile, PublicMerchantProfileResponse, RecentOrderSummary, RespondToReviewRequest, Return, ReturnItem, ReturnResponse, ReturnStatus, RevenueByDay, ReviewResponse, ReviewSortBy, ReviewStatus, SaveBrowsingLocationRequest, SaveBrowsingLocationResponse, SendMessageRequest, Settlement, Shipment, ShipmentResponse, ShipmentStatus, ShippingAddress, ShippingAddressRequest, ShippingAddressResponse, ShippingMethod, ShippingMethodResponse, ShippingOption, ShippingRate, ShippingRateResponse, ShippingSettingsResponse, ShippingZone, ShippingZoneResponse, SortOrder, SuccessResponse, TaxBehavior, TaxBreakdownItem, TaxNexus, TaxNexusResponse, TaxReport, TaxReportDetails, TaxReportPeriodType, TaxReportResponse, TaxReportStatus, TaxRule, TaxRuleResponse, TaxSettings, TaxSettingsResponse, TaxType, TopProduct, TrackBannerRequest, UpdateBannerRequest, UpdateCouponRequest, UpdateFlashSaleRequest, UpdateOrderResponse, UpdateOrderStatusRequest, UpdateProductRequest, UpdateProductVariantRequest, UpdateShipmentRequest, UpdateShippingMethodRequest, UpdateShippingRateRequest, UpdateShippingSettingsRequest, UpdateShippingZoneRequest, UpdateTaxNexusRequest, UpdateTaxReportStatusRequest, UpdateTaxRuleRequest, UpdateTaxSettingsRequest, UserShippingAddress, ValidateDiscountRequest, ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './ecommerce.js';
1
+ import { SpotToken, MarginTables, PerpsAssetCtx, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
2
+ export { A as AllPerpsMeta, a as AssetIdUtils, B as BaseInstrument, I as InstrumentClient, M as MarketInstrument, P as PerpDex, b as PerpsInstrument, c as PerpsMeta, d as PerpsMetaAndAssetCtxs, e as PerpsUniverse, S as SpotInstrument, g as getAllPerpsMeta } from './client-BQzYwHDY.js';
3
+ export { ActiveFlashSalesResponse, AnalyticsOverview, ApiResponse, AppliedDiscount, Banner, BannerResponse, BannerType, BaseEcommerceClient, BaseEntity, BrowsingLocation, CalculateCartDiscountsRequest, CalculateCartDiscountsResponse, CalculateShippingRequest, CalculateShippingResponse, CalculateTaxRequest, CalculateTaxResponse, CartItem, CashAccountBalanceResponse, ConfirmEscrowDepositResponse, Coupon, CouponResponse, CouponUsage, CreateBannerRequest, CreateCouponRequest, CreateFlashSaleRequest, CreateOrderEventRequest, CreateOrderEventResponse, CreateOrderRequest, CreateOrderResponse, CreateProductRequest, CreateProductVariantRequest, CreateReviewRequest, CreateShippingMethodRequest, CreateShippingRateRequest, CreateShippingZoneRequest, CreateTaxNexusRequest, CreateTaxRuleRequest, CustomerEcommerceClient, CustomerMessagesResponse, CustomerNotification, CustomerNotificationsResponse, CustomerSummary, DeleteBrowsingLocationResponse, DeliveryAddressResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, ExpiringGemBatch, FlashSale, FlashSaleAllowanceInfo, FlashSaleItem, FlashSaleItemInput, FollowActionResponse, FollowStatusResponse, FollowedMerchantSummary, GemHistoryItem, GemHistoryType, GemHistoryTypeFilter, GemSource, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetBrowsingLocationResponse, GetCouponResponse, GetExpiringGemsParams, GetExpiringGemsResponse, GetFlashSaleAllowanceParams, GetFlashSaleAllowanceResponse, GetGemBalanceResponse, GetGemHistoryParams, GetGemHistoryResponse, GetOrderResponse, GetPaymentMethodsResponse, GetProductMetricsResponse, GetProductResponse, GetTaxReportResponse, InventoryAuditAction, InventoryAuditEntry, ListActiveBannersParams, ListActiveFlashSalesParams, ListBannersResponse, ListCouponsResponse, ListCustomersParams, ListCustomersResponse, ListFollowingParams, ListFollowingResponse, ListInventoryAuditResponse, ListMediaAssetsResponse, ListMerchantProductsParams, ListMessagesResponse, ListOrdersParams, ListOrdersResponse, ListProductVariantsResponse, ListProductsParams, ListProductsResponse, ListReturnsResponse, ListReviewsParams, ListReviewsResponse, ListShipmentsResponse, ListShippingAddressesResponse, ListShippingMethodsResponse, ListShippingRatesResponse, ListShippingZonesResponse, ListTaxNexusResponse, ListTaxReportsParams, ListTaxReportsResponse, ListTaxRulesResponse, MarkNotificationsReadResponse, MediaAsset, MediaAssetResponse, Merchant, MerchantBusinessType, MerchantEcommerceClient, MerchantProductsResponse, MerchantProfileRequest, MerchantProfileResponse, MerchantReturnPolicyType, MerchantShippingSettings, MerchantSocialLinks, MerchantStatus, Message, MessageResponse, MessageStatsResponse, ORDER_STATUS_TRANSITIONS, Order, OrderEvent, OrderItem, OrderReceiptResponse, OrderStatus, OrdersByStatus, PaginatedResponse, PaginationParams, Payment, PaymentMethod, PaymentMethodInfo, PaymentStatus, ProcessPaymentRequest, ProcessPaymentResponse, Product, ProductDimensions, ProductDiscountsResponse, ProductMetrics, ProductResponse, ProductReview, ProductSortBy, ProductVariant, ProductVariantResponse, PublicMerchantProfile, PublicMerchantProfileResponse, RecentOrderSummary, RespondToReviewRequest, Return, ReturnItem, ReturnResponse, ReturnStatus, RevenueByDay, ReviewResponse, ReviewSortBy, ReviewStatus, SaveBrowsingLocationRequest, SaveBrowsingLocationResponse, SendMessageRequest, Settlement, Shipment, ShipmentResponse, ShipmentStatus, ShippingAddress, ShippingAddressRequest, ShippingAddressResponse, ShippingMethod, ShippingMethodResponse, ShippingOption, ShippingRate, ShippingRateResponse, ShippingSettingsResponse, ShippingZone, ShippingZoneResponse, SortOrder, SuccessResponse, TaxBehavior, TaxBreakdownItem, TaxNexus, TaxNexusResponse, TaxReport, TaxReportDetails, TaxReportPeriodType, TaxReportResponse, TaxReportStatus, TaxRule, TaxRuleResponse, TaxSettings, TaxSettingsResponse, TaxType, TopProduct, TrackBannerRequest, UpdateBannerRequest, UpdateCouponRequest, UpdateFlashSaleRequest, UpdateOrderResponse, UpdateOrderStatusRequest, UpdateProductRequest, UpdateProductVariantRequest, UpdateShipmentRequest, UpdateShippingMethodRequest, UpdateShippingRateRequest, UpdateShippingSettingsRequest, UpdateShippingZoneRequest, UpdateTaxNexusRequest, UpdateTaxReportStatusRequest, UpdateTaxRuleRequest, UpdateTaxSettingsRequest, UserShippingAddress, ValidateDiscountRequest, ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, canCancelOrder, formatPrice, getBackoffDelay, getNextStatuses, getStatusColor, getStatusLabel, getStatusProgress, isPickupOrder, isRetryableError, isValidAddress, isValidEmail, parseError, requiresTrackingInfo, retryWithBackoff, shouldNotifyCustomer, sleep, truncateAddress, validateStatusTransition } from './ecommerce.js';
5
4
  import 'axios';
6
5
 
7
6
  declare function encodeSlug(slug: string): bigint;
@@ -242,6 +241,9 @@ declare function getNextTierInfo(pupTokenAmount: number, normalizedAirDropAmount
242
241
  declare const USDC_SPOT_TOKEN: SpotToken;
243
242
  declare const TESTNET_USDC_SPOT_TOKEN: SpotToken;
244
243
 
244
+ declare const ADMINS: string[];
245
+ declare const ADMIN_WALLETS: string[];
246
+
245
247
  interface PerpsMeta {
246
248
  /** Trading universes available for perpetual trading. */
247
249
  universe: PerpsUniverse[];
@@ -270,18 +272,6 @@ interface PerpsUniverse {
270
272
  marginMode?: "strictIsolated" | "noCross";
271
273
  }
272
274
 
273
- interface PerpDex {
274
- /** Short name of the perpetual dex. */
275
- name: string;
276
- /** Complete name of the perpetual dex. */
277
- fullName: string;
278
- /** Hex address of the dex deployer. */
279
- deployer: Hex;
280
- /** Hex address of the oracle updater, or null if not available. */
281
- oracleUpdater: Hex | null;
282
- feeRecipient: Hex | null;
283
- assetToStreamingOiCap: [string, string][];
284
- }
285
275
  /**
286
276
  * Market information for trading operations
287
277
  */
@@ -327,23 +317,6 @@ interface TokenInfo {
327
317
  weiDecimals: number;
328
318
  tokenId: string;
329
319
  }
330
- /**
331
- * Configuration for MetadataClient
332
- */
333
- interface MetadataClientConfig {
334
- /** List of HIP-3 DEX names to load metadata for */
335
- hip3Dexs?: string[];
336
- /** Whether to lazily initialize (fetch metadata on first use) */
337
- lazyInit?: boolean;
338
- /** Whether to use testnet (default: false for mainnet) */
339
- isTestnet?: boolean;
340
- /** Use static fallback data only, no API fetch */
341
- onlyUseStaticFallback?: boolean;
342
- /** Whether to use static fallback data if API fetch fails (default: true) */
343
- useStaticFallback?: boolean;
344
- /** Whether to enable debug logs (default: false) */
345
- debug?: boolean;
346
- }
347
320
  /**
348
321
  * MetadataClient - Handles Hyperliquid metadata for trading operations
349
322
  *
@@ -359,132 +332,6 @@ interface MetadataClientConfig {
359
332
  * - HIP-3: 100000 + perp_dex_index * 10000 + index_in_meta
360
333
  */
361
334
  declare const ROOT_DEX = "hyperliquid";
362
- /**@deprecated use react sdk instead */
363
- declare class MetadataClient {
364
- private infoClient;
365
- private config;
366
- private isTestnet;
367
- private spotMeta;
368
- private perpsMeta;
369
- private perpDexs;
370
- private staticMeta;
371
- private hip3DexsMeta;
372
- private perpsSymbolToIndex;
373
- private spotTokenNameToIndex;
374
- private spotPairToMarket;
375
- private baseTokenToMarkets;
376
- private quoteAssets;
377
- private coinToMarket;
378
- private hip3SymbolToMarket;
379
- private dexNameToIndex;
380
- private initialized;
381
- private initializing;
382
- constructor(config?: MetadataClientConfig);
383
- /**
384
- * Initialize metadata by fetching from Hyperliquid
385
- */
386
- initialize(): Promise<void>;
387
- /**
388
- * Load staticMeta.json for display overrides
389
- * This is always loaded regardless of config.useStaticFallback
390
- */
391
- private loadStaticMetaOverrides;
392
- /**
393
- * Load static metadata from bundled JSON files
394
- */
395
- private loadStaticMetadata;
396
- /**
397
- * Build optimized lookup maps from raw metadata
398
- * Called after metadata is loaded (from API or static files)
399
- */
400
- private buildLookupMaps;
401
- /**
402
- * Load metadata for a specific HIP-3 DEX
403
- * Also builds optimized lookups for this DEX's markets
404
- */
405
- loadHip3Metadata(dexName: string): Promise<DexInfo>;
406
- /**
407
- * Build optimized lookups for HIP-3 markets of a specific DEX
408
- */
409
- private buildHip3MarketsForDex;
410
- /**
411
- * Ensure metadata is loaded (for lazy init)
412
- */
413
- private ensureInitialized;
414
- /**
415
- * Get market information by symbol
416
- * Optimized: O(1) direct map lookup for most cases
417
- * Lazily initialize hip-3 metadata if not already initialized
418
- *
419
- * @param symbol - Market symbol (e.g., "BTC", "PURR/USDC", "vntls:ABC")
420
- * @param quoteAsset - Quote asset for spot markets (default: "USDC")
421
- * @returns Market information or null if not found
422
- */
423
- getMarketBySymbolAsync(symbol: string, quoteAsset?: string): Promise<MarketInfo | null>;
424
- getMarketByCoin(coin: string): MarketInfo | null;
425
- /**
426
- * Get perpetuals market information
427
- * Optimized: O(1) map lookup instead of O(n) array search
428
- */
429
- getPerpsMarket(symbol: string): MarketInfo | null;
430
- /**
431
- * Get spot market information
432
- * Optimized: O(1) map lookup instead of O(n) array searches
433
- *
434
- * @param baseSymbol - Base token symbol (e.g., "PURR", "UHYPE")
435
- * @param quoteSymbol - Quote token symbol (default: "USDC")
436
- */
437
- getSpotMarket(baseSymbol: string, quoteSymbol?: string): MarketInfo | null;
438
- /**
439
- * Get HIP-3 market information
440
- * Optimized: O(1) map lookup after DEX metadata is loaded
441
- *
442
- * @param symbol - HIP-3 market symbol (format: "dex:coin")
443
- */
444
- getHip3Market(symbol: string): Promise<MarketInfo | null>;
445
- getHip3Dex(dexName: string): Promise<DexInfo | null>;
446
- /**
447
- * Get all available markets for a base token
448
- * Optimized: O(1) map lookup instead of O(n) filter + map
449
- * Useful for showing all quote asset options
450
- */
451
- getAllMarketsForBase(baseSymbol: string): MarketInfo[];
452
- /**
453
- * Get spot token information
454
- * Optimized: O(1) map lookup instead of O(n) array search
455
- */
456
- getSpotTokenInfo(tokenSymbol: string): TokenInfo | null;
457
- /**
458
- * Get all available quote assets
459
- * Optimized: O(1) pre-computed array instead of O(n) computation
460
- */
461
- getAvailableQuoteAssets(): string[];
462
- /**
463
- * Get raw metadata (for advanced use cases)
464
- */
465
- getRawMetadata(): {
466
- spotMeta: SpotMeta | null;
467
- perpsMeta: PerpsMeta | null;
468
- perpDexs: (PerpDex | null)[];
469
- hip3DexsMeta: {
470
- [k: string]: DexInfo;
471
- };
472
- coinToMarket: {
473
- [k: string]: MarketInfo;
474
- };
475
- hip3SymbolToMarket: {
476
- [k: string]: MarketInfo;
477
- };
478
- };
479
- /**
480
- * Get network configuration
481
- */
482
- getNetworkInfo(): {
483
- isTestnet: boolean;
484
- useStaticFallback: boolean | undefined;
485
- initialized: boolean;
486
- };
487
- }
488
335
 
489
336
  declare const formatPriceAndSize: ({ px, sz, szDecimals, isSpot, }: {
490
337
  px: number;
@@ -652,4 +499,111 @@ declare function isStableQuoteToken(coin: string): boolean;
652
499
  declare function getDisplayMarketSymbol(coin: string | undefined, showCollateralTokenSymbol?: boolean, collateralTokenSymbol?: string): string | undefined;
653
500
  declare function getDexFromCollateralTokenSymbol(collateralTokenSymbol: string): string | undefined;
654
501
 
655
- export { type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, DayOfWeek, 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, type WeekInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getLatestCompletedWeek, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWeekInfoFromNumber, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, makeUtcRounder, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };
502
+ /**
503
+ * User abstraction modes for controlling how spot and perps balances interact.
504
+ *
505
+ * - `disabled` (Standard): Separate perp and spot balances, separate DEX balances.
506
+ * - `unifiedAccount`: Single balance per asset collateralizing all cross margin positions.
507
+ * - `portfolioMargin`: Single portfolio unifying all eligible assets (pre-alpha).
508
+ * - `dexAbstraction`: Legacy mode (to be discontinued).
509
+ * - `default`: Server default (equivalent to standard/disabled for most users).
510
+ */
511
+ type UserAbstractionMode = "unifiedAccount" | "portfolioMargin" | "disabled" | "default" | "dexAbstraction";
512
+ /**
513
+ * Shorthand codes used with agent-based abstraction setting.
514
+ * - `i` = disabled (standard)
515
+ * - `u` = unifiedAccount
516
+ * - `p` = portfolioMargin
517
+ */
518
+ type AgentAbstractionCode = "i" | "u" | "p";
519
+ /**
520
+ * Settable abstraction modes (excludes read-only states like "default" and "dexAbstraction").
521
+ */
522
+ type SettableAbstractionMode = "disabled" | "unifiedAccount" | "portfolioMargin";
523
+ declare const ABSTRACTION_MODE_TO_AGENT_CODE: Record<SettableAbstractionMode, AgentAbstractionCode>;
524
+ declare const AGENT_CODE_TO_ABSTRACTION_MODE: Record<AgentAbstractionCode, SettableAbstractionMode>;
525
+ interface MultiverseMeta {
526
+ index: number;
527
+ collateralToken: number;
528
+ }
529
+ interface PerpDexAssetPosition {
530
+ position: {
531
+ leverage: {
532
+ type: string;
533
+ };
534
+ marginUsed: number;
535
+ };
536
+ }
537
+ interface PerpDexClearinghouseState {
538
+ clearinghouseState: {
539
+ crossMaintenanceMarginUsed: number;
540
+ assetPositions: PerpDexAssetPosition[];
541
+ };
542
+ }
543
+ interface SpotBalance {
544
+ token: number;
545
+ total: number;
546
+ }
547
+
548
+ declare const UserSetAbstractionTypes: {
549
+ "HyperliquidTransaction:UserSetAbstraction": {
550
+ name: string;
551
+ type: string;
552
+ }[];
553
+ };
554
+ /**
555
+ * Query a user's current account abstraction mode.
556
+ */
557
+ declare function getUserAbstraction(client: InfoClient, user: string): Promise<UserAbstractionMode>;
558
+ /**
559
+ * Set account abstraction mode using the owner wallet (user-signed action).
560
+ *
561
+ * Requires EIP-712 signature from the account owner.
562
+ */
563
+ declare function setUserAbstraction(client: ExchangeClient, abstraction: SettableAbstractionMode, user: string): Promise<SuccessResponse>;
564
+ /**
565
+ * Set account abstraction mode using an agent wallet.
566
+ *
567
+ * Uses shorthand codes: "i" (disabled), "u" (unifiedAccount), "p" (portfolioMargin).
568
+ */
569
+ declare function agentSetAbstraction(client: ExchangeClient, abstraction: SettableAbstractionMode): Promise<SuccessResponse>;
570
+
571
+ /**
572
+ * Compute the unified account ratio for monitoring liquidation risk.
573
+ *
574
+ * The ratio represents cross maintenance margin used / available balance
575
+ * for the most leveraged collateral token. A higher ratio means closer
576
+ * to liquidation.
577
+ *
578
+ * @param multiverse - Map of DEX name to its metadata (index and collateral token)
579
+ * @param perpDexStates - Array of per-DEX clearinghouse states
580
+ * @param spotBalances - Array of spot balances per token
581
+ * @returns The maximum ratio across all collateral tokens (0 if no margin used)
582
+ */
583
+ declare function computeUnifiedAccountRatio(multiverse: Record<string, MultiverseMeta>, perpDexStates: PerpDexClearinghouseState[], spotBalances: SpotBalance[]): number;
584
+
585
+ interface PerpDexState {
586
+ totalVaultEquity: number;
587
+ perpsAtOpenInterestCap?: Array<string>;
588
+ leadingVaults?: Array<LeadingVault>;
589
+ }
590
+ interface WsWebData3 {
591
+ userState: {
592
+ abstraction: UserAbstractionMode;
593
+ agentAddress: string | null;
594
+ agentValidUntil: number | null;
595
+ serverTime: number;
596
+ cumLedger: number;
597
+ isVault: boolean;
598
+ user: string;
599
+ optOutOfSpotDusting?: boolean;
600
+ dexAbstractionEnabled?: boolean;
601
+ };
602
+ perpDexStates: Array<PerpDexState>;
603
+ }
604
+ interface LeadingVault {
605
+ address: string;
606
+ name: string;
607
+ }
608
+
609
+ export { ABSTRACTION_MODE_TO_AGENT_CODE, ADMINS, ADMIN_WALLETS, AGENT_CODE_TO_ABSTRACTION_MODE, type AgentAbstractionCode, type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, DayOfWeek, type DexInfo, type ExtendedPerpsMeta, type LeadingVault, type MarketInfo, type MultiverseMeta, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PerpDexAssetPosition, type PerpDexClearinghouseState, type PerpDexState, type PupEligibilityResult, ROOT_DEX, type SettableAbstractionMode, type SpotBalance, 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 UserAbstractionMode, UserDexAbstractionTypes, UserSetAbstractionTypes, type V3LPTokenInfo, type WeekInfo, WidgetType, WidgetTypeById, type WidgetTypeId, type WsWebData3, XP_BOOST_PERCENTAGES, agentSetAbstraction, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, computeUnifiedAccountRatio, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getLatestCompletedWeek, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getUserAbstraction, getWeekInfoFromNumber, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, makeUtcRounder, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, setUserAbstraction, stableQuoteTokens };