@basedone/core 0.2.8 → 0.3.1

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.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SpotToken, MarginTables, PerpsAssetCtx, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
2
- export { A as AllPerpsMeta, e as AssetIdUtils, B as BaseInstrument, I as InstrumentClient, M as MarketInstrument, c as PerpDex, d as PerpsInstrument, P as PerpsMeta, a as PerpsMetaAndAssetCtxs, b as PerpsUniverse, S as SpotInstrument, g as getAllPerpsMeta } from './client-DMVXX1Gw.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, 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, MerchantBusinessType, MerchantEcommerceClient, MerchantProductsResponse, MerchantProfileRequest, MerchantProfileResponse, MerchantReturnPolicyType, MerchantShippingSettings, MerchantSocialLinks, 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';
2
+ export { A as AllPerpsMeta, a as AssetIdUtils, B as BaseInstrument, I as InstrumentClient, M as MarketInstrument, P as PerpConciseAnnotationMeta, b as PerpConciseAnnotations, c as PerpDex, d as PerpsInstrument, e as PerpsMeta, f as PerpsMetaAndAssetCtxs, g as PerpsUniverse, S as SpotInstrument, h as enrichAllPerpsMetaWithAnnotations, i as getAllPerpsMeta, j as getPerpConciseAnnotations } from './client-1sWFpTpK.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';
4
4
  import 'axios';
5
5
 
6
6
  declare function encodeSlug(slug: string): bigint;
@@ -241,6 +241,11 @@ declare function getNextTierInfo(pupTokenAmount: number, normalizedAirDropAmount
241
241
  declare const USDC_SPOT_TOKEN: SpotToken;
242
242
  declare const TESTNET_USDC_SPOT_TOKEN: SpotToken;
243
243
 
244
+ declare const SUPER_ADMINS: string[];
245
+ declare const ADMINS: string[];
246
+ declare const ALL_ADMINS: string[];
247
+ declare const ADMIN_WALLETS: string[];
248
+
244
249
  interface PerpsMeta {
245
250
  /** Trading universes available for perpetual trading. */
246
251
  universe: PerpsUniverse[];
@@ -267,6 +272,10 @@ interface PerpsUniverse {
267
272
  growthMode?: "enabled";
268
273
  /** Margin mode for the universe. */
269
274
  marginMode?: "strictIsolated" | "noCross";
275
+ /** From Hyperliquid `perpConciseAnnotations` when merged into meta. */
276
+ category?: string;
277
+ displayName?: string;
278
+ keywords?: string[];
270
279
  }
271
280
 
272
281
  /**
@@ -496,4 +505,111 @@ declare function isStableQuoteToken(coin: string): boolean;
496
505
  declare function getDisplayMarketSymbol(coin: string | undefined, showCollateralTokenSymbol?: boolean, collateralTokenSymbol?: string): string | undefined;
497
506
  declare function getDexFromCollateralTokenSymbol(collateralTokenSymbol: string): string | undefined;
498
507
 
499
- export { type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, DayOfWeek, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, 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 };
508
+ /**
509
+ * User abstraction modes for controlling how spot and perps balances interact.
510
+ *
511
+ * - `disabled` (Standard): Separate perp and spot balances, separate DEX balances.
512
+ * - `unifiedAccount`: Single balance per asset collateralizing all cross margin positions.
513
+ * - `portfolioMargin`: Single portfolio unifying all eligible assets (pre-alpha).
514
+ * - `dexAbstraction`: Legacy mode (to be discontinued).
515
+ * - `default`: Server default (equivalent to standard/disabled for most users).
516
+ */
517
+ type UserAbstractionMode = "unifiedAccount" | "portfolioMargin" | "disabled" | "default" | "dexAbstraction";
518
+ /**
519
+ * Shorthand codes used with agent-based abstraction setting.
520
+ * - `i` = disabled (standard)
521
+ * - `u` = unifiedAccount
522
+ * - `p` = portfolioMargin
523
+ */
524
+ type AgentAbstractionCode = "i" | "u" | "p";
525
+ /**
526
+ * Settable abstraction modes (excludes read-only states like "default" and "dexAbstraction").
527
+ */
528
+ type SettableAbstractionMode = "disabled" | "unifiedAccount" | "portfolioMargin";
529
+ declare const ABSTRACTION_MODE_TO_AGENT_CODE: Record<SettableAbstractionMode, AgentAbstractionCode>;
530
+ declare const AGENT_CODE_TO_ABSTRACTION_MODE: Record<AgentAbstractionCode, SettableAbstractionMode>;
531
+ interface MultiverseMeta {
532
+ index: number;
533
+ collateralToken: number;
534
+ }
535
+ interface PerpDexAssetPosition {
536
+ position: {
537
+ leverage: {
538
+ type: string;
539
+ };
540
+ marginUsed: number;
541
+ };
542
+ }
543
+ interface PerpDexClearinghouseState {
544
+ clearinghouseState: {
545
+ crossMaintenanceMarginUsed: number;
546
+ assetPositions: PerpDexAssetPosition[];
547
+ };
548
+ }
549
+ interface SpotBalance {
550
+ token: number;
551
+ total: number;
552
+ }
553
+
554
+ declare const UserSetAbstractionTypes: {
555
+ "HyperliquidTransaction:UserSetAbstraction": {
556
+ name: string;
557
+ type: string;
558
+ }[];
559
+ };
560
+ /**
561
+ * Query a user's current account abstraction mode.
562
+ */
563
+ declare function getUserAbstraction(client: InfoClient, user: string): Promise<UserAbstractionMode>;
564
+ /**
565
+ * Set account abstraction mode using the owner wallet (user-signed action).
566
+ *
567
+ * Requires EIP-712 signature from the account owner.
568
+ */
569
+ declare function setUserAbstraction(client: ExchangeClient, abstraction: SettableAbstractionMode, user: string): Promise<SuccessResponse>;
570
+ /**
571
+ * Set account abstraction mode using an agent wallet.
572
+ *
573
+ * Uses shorthand codes: "i" (disabled), "u" (unifiedAccount), "p" (portfolioMargin).
574
+ */
575
+ declare function agentSetAbstraction(client: ExchangeClient, abstraction: SettableAbstractionMode): Promise<SuccessResponse>;
576
+
577
+ /**
578
+ * Compute the unified account ratio for monitoring liquidation risk.
579
+ *
580
+ * The ratio represents cross maintenance margin used / available balance
581
+ * for the most leveraged collateral token. A higher ratio means closer
582
+ * to liquidation.
583
+ *
584
+ * @param multiverse - Map of DEX name to its metadata (index and collateral token)
585
+ * @param perpDexStates - Array of per-DEX clearinghouse states
586
+ * @param spotBalances - Array of spot balances per token
587
+ * @returns The maximum ratio across all collateral tokens (0 if no margin used)
588
+ */
589
+ declare function computeUnifiedAccountRatio(multiverse: Record<string, MultiverseMeta>, perpDexStates: PerpDexClearinghouseState[], spotBalances: SpotBalance[]): number;
590
+
591
+ interface PerpDexState {
592
+ totalVaultEquity: number;
593
+ perpsAtOpenInterestCap?: Array<string>;
594
+ leadingVaults?: Array<LeadingVault>;
595
+ }
596
+ interface WsWebData3 {
597
+ userState: {
598
+ abstraction: UserAbstractionMode;
599
+ agentAddress: string | null;
600
+ agentValidUntil: number | null;
601
+ serverTime: number;
602
+ cumLedger: number;
603
+ isVault: boolean;
604
+ user: string;
605
+ optOutOfSpotDusting?: boolean;
606
+ dexAbstractionEnabled?: boolean;
607
+ };
608
+ perpDexStates: Array<PerpDexState>;
609
+ }
610
+ interface LeadingVault {
611
+ address: string;
612
+ name: string;
613
+ }
614
+
615
+ export { ABSTRACTION_MODE_TO_AGENT_CODE, ADMINS, ADMIN_WALLETS, AGENT_CODE_TO_ABSTRACTION_MODE, ALL_ADMINS, 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, SUPER_ADMINS, 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.js CHANGED
@@ -550,6 +550,48 @@ var TESTNET_USDC_SPOT_TOKEN = {
550
550
  deployerTradingFeeShare: "0.0"
551
551
  };
552
552
 
553
+ // lib/constants/admin.ts
554
+ var SUPER_ADMINS = [
555
+ "did:privy:cmc3hycnb00pljs0m1z010geq",
556
+ "did:privy:cmc8w2ddl01rdju0nylb6rp1v",
557
+ "did:privy:cmc3oftiz005fjx0msox3xgey",
558
+ "did:privy:cmcbx7i4400q8l90mawdymaag",
559
+ "did:privy:cmctbwphs00vzjz0m3la3zm4c",
560
+ "did:privy:cmcblrplb009ol70mia13winn",
561
+ "did:privy:cmcd2bvft00w3l90ljeyb4wn6",
562
+ "did:privy:cmc4y13ka0119kv0nckvgla1u",
563
+ "did:privy:cmc8qc36g00c1l70nnutuscue",
564
+ "did:privy:cmc8f1tf9019zlh0myjpi420p",
565
+ "did:privy:cmc6bturg002ql80mhzqr1d76",
566
+ "did:privy:cmc8uyr4t01kljo0mk3unzjl3",
567
+ "did:privy:cmcke9v7h00yijy0o2a41nhms"
568
+ ];
569
+ var ADMINS = [
570
+ "did:privy:cmgfcjt2y0024kz0cpymoqbmp",
571
+ // aayush
572
+ "did:privy:cmeqj8tsi01k6la0c3s7gsl6w",
573
+ // elroy
574
+ "did:privy:cmiwrno1i00cdl70c5ro13eyp",
575
+ // adele
576
+ "did:privy:cmkc0jyy200abji0d42a0syil",
577
+ // matthew
578
+ "did:privy:cmlgc2zjk005vjo0cct10trdl",
579
+ // marketing
580
+ "did:privy:cme2d56i90091i90bdhuyaj7e",
581
+ // jun
582
+ "did:privy:cmm4av80f00140cldz3uv7io2",
583
+ // shubit
584
+ "did:privy:cmcbndjjm02fvjr0mrs42yahs"
585
+ // zlace
586
+ ];
587
+ var ALL_ADMINS = [...SUPER_ADMINS, ...ADMINS];
588
+ var ADMIN_WALLETS = [
589
+ "0x0c7582A67B8B6AD04Ea404A6C2A06aAc9E0d4e7c",
590
+ "0xDec587aDD20A6447fF0b29D70E95b10b197b1283",
591
+ "0x3e83987019c4CE29680401b72F8b18A2dE3f8fe6",
592
+ "0x5446A5Bc711170d5197DE33D8C193487794f30C0"
593
+ ];
594
+
553
595
  // lib/meta/metadata.ts
554
596
  var ROOT_DEX = "hyperliquid";
555
597
  var formatPriceAndSize = ({
@@ -786,11 +828,140 @@ function getDexFromCollateralTokenSymbol(collateralTokenSymbol) {
786
828
  }
787
829
 
788
830
  // lib/hip3/market-info.ts
789
- async function getAllPerpsMeta(infoClient) {
831
+ async function getPerpConciseAnnotations(infoClient) {
790
832
  return infoClient.transport.request("info", {
791
- type: "allPerpMetas"
833
+ type: "perpConciseAnnotations"
792
834
  });
793
835
  }
836
+ function enrichAllPerpsMetaWithAnnotations(metas, annotations) {
837
+ const map = new Map(annotations);
838
+ return metas.map((meta) => ({
839
+ ...meta,
840
+ universe: meta.universe.map((u) => {
841
+ const ann = map.get(u.name);
842
+ if (!ann) return u;
843
+ return {
844
+ ...u,
845
+ ...ann.category != null && ann.category !== "" ? { category: ann.category } : {},
846
+ ...ann.displayName != null && ann.displayName !== "" ? { displayName: ann.displayName } : {},
847
+ ...ann.keywords != null && ann.keywords.length > 0 ? { keywords: ann.keywords } : {}
848
+ };
849
+ })
850
+ }));
851
+ }
852
+ async function getAllPerpsMeta(infoClient) {
853
+ const [metas, annotations] = await Promise.all([
854
+ infoClient.transport.request("info", {
855
+ type: "allPerpMetas"
856
+ }),
857
+ getPerpConciseAnnotations(infoClient).catch(() => {
858
+ return [];
859
+ })
860
+ ]);
861
+ if (!annotations.length) {
862
+ return metas;
863
+ }
864
+ return enrichAllPerpsMetaWithAnnotations(metas, annotations);
865
+ }
866
+
867
+ // lib/abstraction/types.ts
868
+ var ABSTRACTION_MODE_TO_AGENT_CODE = {
869
+ disabled: "i",
870
+ unifiedAccount: "u",
871
+ portfolioMargin: "p"
872
+ };
873
+ var AGENT_CODE_TO_ABSTRACTION_MODE = {
874
+ i: "disabled",
875
+ u: "unifiedAccount",
876
+ p: "portfolioMargin"
877
+ };
878
+ var UserSetAbstractionTypes = {
879
+ "HyperliquidTransaction:UserSetAbstraction": [
880
+ { name: "hyperliquidChain", type: "string" },
881
+ { name: "user", type: "address" },
882
+ { name: "abstraction", type: "string" },
883
+ { name: "nonce", type: "uint64" }
884
+ ]
885
+ };
886
+ async function getUserAbstraction(client, user) {
887
+ return await client.transport.request("info", {
888
+ type: "userAbstraction",
889
+ user
890
+ });
891
+ }
892
+ async function setUserAbstraction(client, abstraction, user) {
893
+ const nonce = Date.now();
894
+ const isTestnet = client.isTestnet;
895
+ const action = {
896
+ type: "userSetAbstraction",
897
+ hyperliquidChain: isTestnet ? "Testnet" : "Mainnet",
898
+ signatureChainId: isTestnet ? "0x66eee" : "0xa4b1",
899
+ user,
900
+ abstraction,
901
+ nonce
902
+ };
903
+ const signature = await signing.signUserSignedAction({
904
+ wallet: client.wallet,
905
+ action,
906
+ types: UserSetAbstractionTypes
907
+ });
908
+ return await client.transport.request("exchange", {
909
+ action,
910
+ signature,
911
+ nonce: action.nonce
912
+ });
913
+ }
914
+ async function agentSetAbstraction(client, abstraction) {
915
+ const nonce = Date.now();
916
+ const code = ABSTRACTION_MODE_TO_AGENT_CODE[abstraction];
917
+ const action = {
918
+ type: "agentSetAbstraction",
919
+ abstraction: code
920
+ };
921
+ const signature = await signing.signL1Action({
922
+ wallet: client.wallet,
923
+ action,
924
+ isTestnet: client.isTestnet,
925
+ nonce
926
+ });
927
+ return await client.transport.request("exchange", {
928
+ action,
929
+ signature,
930
+ nonce
931
+ });
932
+ }
933
+
934
+ // lib/abstraction/ratio.ts
935
+ function computeUnifiedAccountRatio(multiverse, perpDexStates, spotBalances) {
936
+ const indexToCollateralToken = {};
937
+ for (const meta of Object.values(multiverse)) {
938
+ indexToCollateralToken[meta.index] = meta.collateralToken;
939
+ }
940
+ const crossMarginByToken = {};
941
+ const isolatedMarginByToken = {};
942
+ for (let index = 0; index < perpDexStates.length; index++) {
943
+ const dex = perpDexStates[index];
944
+ const token = indexToCollateralToken[index];
945
+ if (dex === void 0 || token === void 0) continue;
946
+ crossMarginByToken[token] = (crossMarginByToken[token] ?? 0) + dex.clearinghouseState.crossMaintenanceMarginUsed;
947
+ for (const ap of dex.clearinghouseState.assetPositions) {
948
+ if (ap.position.leverage.type === "isolated") {
949
+ isolatedMarginByToken[token] = (isolatedMarginByToken[token] ?? 0) + ap.position.marginUsed;
950
+ }
951
+ }
952
+ }
953
+ let maxRatio = 0;
954
+ for (const [tokenStr, crossMargin] of Object.entries(crossMarginByToken)) {
955
+ const token = Number(tokenStr);
956
+ const spotTotal = spotBalances.find((b) => b.token === token)?.total ?? 0;
957
+ const isolatedMargin = isolatedMarginByToken[token] ?? 0;
958
+ const available = spotTotal - isolatedMargin;
959
+ if (available > 0) {
960
+ maxRatio = Math.max(maxRatio, crossMargin / available);
961
+ }
962
+ }
963
+ return maxRatio;
964
+ }
794
965
 
795
966
  // lib/instrument/client.ts
796
967
  var AssetIdUtils = {
@@ -975,7 +1146,10 @@ var InstrumentClient = class {
975
1146
  type: "futures",
976
1147
  isDelisted: info.isDelisted,
977
1148
  dex: AssetIdUtils.extractDexName(info.name),
978
- collateralTokenIndex: perpMeta.collateralToken
1149
+ collateralTokenIndex: perpMeta.collateralToken,
1150
+ category: info.category,
1151
+ displayName: info.displayName,
1152
+ keywords: info.keywords
979
1153
  };
980
1154
  this.addInstrument(instrument);
981
1155
  }
@@ -2248,6 +2422,38 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
2248
2422
  async getDeliveryAddress() {
2249
2423
  return this.get("/api/basedpay/delivery-address");
2250
2424
  }
2425
+ /**
2426
+ * Get user's Hyperliquid USDC balance (perp withdrawable)
2427
+ *
2428
+ * Returns the USDC balance available for escrow deposits via usdSend.
2429
+ *
2430
+ * @returns Balance response with amount and currency
2431
+ */
2432
+ async getUsdcBalance() {
2433
+ return this.get("/api/marketplace/usdc-balance");
2434
+ }
2435
+ // ============================================================================
2436
+ // Notifications API
2437
+ // ============================================================================
2438
+ /**
2439
+ * List notifications for the authenticated customer
2440
+ *
2441
+ * @param params - Query parameters for filtering and pagination
2442
+ * @returns Paginated list of notifications with unread count
2443
+ */
2444
+ async listNotifications(params) {
2445
+ const queryString = params ? buildQueryString(params) : "";
2446
+ return this.get(`/api/marketplace/notifications${queryString}`);
2447
+ }
2448
+ /**
2449
+ * Mark notifications as read
2450
+ *
2451
+ * @param ids - Specific notification IDs to mark as read. If omitted, marks all as read.
2452
+ * @returns Count of updated notifications
2453
+ */
2454
+ async markNotificationsAsRead(ids) {
2455
+ return this.patch("/api/marketplace/notifications/read", { ids });
2456
+ }
2251
2457
  };
2252
2458
 
2253
2459
  // lib/ecommerce/client/merchant.ts
@@ -3793,6 +3999,7 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
3793
3999
  OrderStatus2["SHIPPED"] = "SHIPPED";
3794
4000
  OrderStatus2["DELIVERED"] = "DELIVERED";
3795
4001
  OrderStatus2["CANCELLED"] = "CANCELLED";
4002
+ OrderStatus2["SETTLED"] = "SETTLED";
3796
4003
  OrderStatus2["CONFIRMED"] = "CONFIRMED";
3797
4004
  OrderStatus2["COMPLETED"] = "COMPLETED";
3798
4005
  return OrderStatus2;
@@ -3926,6 +4133,7 @@ var ProductSortBy = /* @__PURE__ */ ((ProductSortBy2) => {
3926
4133
  ProductSortBy2["PRICE_ASC"] = "price_asc";
3927
4134
  ProductSortBy2["PRICE_DESC"] = "price_desc";
3928
4135
  ProductSortBy2["POPULAR"] = "popular";
4136
+ ProductSortBy2["BEST_SELLING"] = "best_selling";
3929
4137
  ProductSortBy2["FEATURED"] = "featured";
3930
4138
  ProductSortBy2["NEARBY"] = "nearby";
3931
4139
  return ProductSortBy2;
@@ -3937,6 +4145,125 @@ var ReviewSortBy = /* @__PURE__ */ ((ReviewSortBy2) => {
3937
4145
  return ReviewSortBy2;
3938
4146
  })(ReviewSortBy || {});
3939
4147
 
4148
+ // lib/ecommerce/utils/orderStateMachine.ts
4149
+ function isPickupOrder(shippingMethod, shippingRateId) {
4150
+ if (shippingRateId && shippingRateId.trim().toUpperCase() === "PICKUP") {
4151
+ return true;
4152
+ }
4153
+ if (!shippingMethod) return false;
4154
+ const normalized = shippingMethod.trim().toLowerCase().replace(/[\s-]+/g, " ");
4155
+ return normalized === "pickup" || normalized === "on site collection" || normalized === "onsite collection";
4156
+ }
4157
+ var ORDER_STATUS_TRANSITIONS = {
4158
+ ["CREATED" /* CREATED */]: [
4159
+ "PAYMENT_RESERVED" /* PAYMENT_RESERVED */,
4160
+ "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */,
4161
+ "CANCELLED" /* CANCELLED */
4162
+ ],
4163
+ ["PAYMENT_RESERVED" /* PAYMENT_RESERVED */]: [
4164
+ "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */,
4165
+ "CANCELLED" /* CANCELLED */
4166
+ ],
4167
+ ["MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */]: [
4168
+ "SHIPPED" /* SHIPPED */,
4169
+ "CANCELLED" /* CANCELLED */
4170
+ ],
4171
+ // Backward compat for existing SETTLED orders created before escrow change
4172
+ // Note: CANCELLED removed — settled orders have funds paid out, no clawback mechanism
4173
+ ["SETTLED" /* SETTLED */]: ["SHIPPED" /* SHIPPED */],
4174
+ ["SHIPPED" /* SHIPPED */]: ["DELIVERED" /* DELIVERED */, "CANCELLED" /* CANCELLED */],
4175
+ // Settlement triggered on delivery (buyer-protected escrow)
4176
+ ["DELIVERED" /* DELIVERED */]: ["SETTLED" /* SETTLED */],
4177
+ // Terminal states
4178
+ ["CANCELLED" /* CANCELLED */]: []
4179
+ };
4180
+ function validateStatusTransition(currentStatus, newStatus, options) {
4181
+ if (isPickupOrder(options?.shippingMethod, options?.shippingRateId) && (currentStatus === "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */ || currentStatus === "SETTLED" /* SETTLED */) && newStatus === "DELIVERED" /* DELIVERED */) {
4182
+ return { valid: true };
4183
+ }
4184
+ const allowed = ORDER_STATUS_TRANSITIONS[currentStatus] ?? [];
4185
+ if (!allowed.includes(newStatus)) {
4186
+ if (allowed.length === 0) {
4187
+ return {
4188
+ valid: false,
4189
+ error: `Cannot change status from ${currentStatus} \u2014 this is a final state`
4190
+ };
4191
+ }
4192
+ return {
4193
+ valid: false,
4194
+ error: `Cannot transition from ${currentStatus} to ${newStatus}. Allowed: ${allowed.join(", ")}`
4195
+ };
4196
+ }
4197
+ return { valid: true };
4198
+ }
4199
+ function getNextStatuses(currentStatus, options) {
4200
+ const base = [
4201
+ ...ORDER_STATUS_TRANSITIONS[currentStatus] ?? []
4202
+ ];
4203
+ if (isPickupOrder(options?.shippingMethod, options?.shippingRateId) && (currentStatus === "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */ || currentStatus === "SETTLED" /* SETTLED */) && !base.includes("DELIVERED" /* DELIVERED */)) {
4204
+ base.push("DELIVERED" /* DELIVERED */);
4205
+ }
4206
+ return base;
4207
+ }
4208
+ function getStatusLabel(status) {
4209
+ const labels = {
4210
+ CREATED: "Created",
4211
+ PAYMENT_RESERVED: "Payment Reserved",
4212
+ MERCHANT_ACCEPTED: "Accepted",
4213
+ SETTLED: "Completed (Paid)",
4214
+ SHIPPED: "Shipped",
4215
+ DELIVERED: "Delivered",
4216
+ CANCELLED: "Cancelled"
4217
+ };
4218
+ return labels[status] || status;
4219
+ }
4220
+ function getStatusColor(status) {
4221
+ const colors = {
4222
+ CREATED: "gray",
4223
+ PAYMENT_RESERVED: "blue",
4224
+ MERCHANT_ACCEPTED: "purple",
4225
+ SETTLED: "indigo",
4226
+ SHIPPED: "yellow",
4227
+ DELIVERED: "green",
4228
+ CANCELLED: "red"
4229
+ };
4230
+ return colors[status] || "gray";
4231
+ }
4232
+ function canCancelOrder(currentStatus) {
4233
+ return ORDER_STATUS_TRANSITIONS[currentStatus]?.includes(
4234
+ "CANCELLED" /* CANCELLED */
4235
+ ) ?? false;
4236
+ }
4237
+ function requiresTrackingInfo(newStatus, options) {
4238
+ if (newStatus !== "SHIPPED" /* SHIPPED */) return false;
4239
+ return !isPickupOrder(options?.shippingMethod, options?.shippingRateId);
4240
+ }
4241
+ function shouldNotifyCustomer(newStatus) {
4242
+ return [
4243
+ "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */,
4244
+ "SHIPPED" /* SHIPPED */,
4245
+ "DELIVERED" /* DELIVERED */,
4246
+ "CANCELLED" /* CANCELLED */
4247
+ ].includes(newStatus);
4248
+ }
4249
+ function getStatusProgress(status) {
4250
+ const progressMap = {
4251
+ CREATED: 10,
4252
+ PAYMENT_RESERVED: 25,
4253
+ MERCHANT_ACCEPTED: 40,
4254
+ SETTLED: 50,
4255
+ SHIPPED: 75,
4256
+ DELIVERED: 100,
4257
+ CANCELLED: 0
4258
+ };
4259
+ return progressMap[status] || 0;
4260
+ }
4261
+
4262
+ exports.ABSTRACTION_MODE_TO_AGENT_CODE = ABSTRACTION_MODE_TO_AGENT_CODE;
4263
+ exports.ADMINS = ADMINS;
4264
+ exports.ADMIN_WALLETS = ADMIN_WALLETS;
4265
+ exports.AGENT_CODE_TO_ABSTRACTION_MODE = AGENT_CODE_TO_ABSTRACTION_MODE;
4266
+ exports.ALL_ADMINS = ALL_ADMINS;
3940
4267
  exports.AssetIdUtils = AssetIdUtils;
3941
4268
  exports.BannerType = BannerType;
3942
4269
  exports.BaseEcommerceClient = BaseEcommerceClient;
@@ -3954,6 +4281,7 @@ exports.MerchantBusinessType = MerchantBusinessType;
3954
4281
  exports.MerchantEcommerceClient = MerchantEcommerceClient;
3955
4282
  exports.MerchantReturnPolicyType = MerchantReturnPolicyType;
3956
4283
  exports.MerchantStatus = MerchantStatus;
4284
+ exports.ORDER_STATUS_TRANSITIONS = ORDER_STATUS_TRANSITIONS;
3957
4285
  exports.OrderStatus = OrderStatus;
3958
4286
  exports.PUP_TOKEN_ADDRESS = PUP_TOKEN_ADDRESS;
3959
4287
  exports.PUP_TOKEN_THRESHOLDS = PUP_TOKEN_THRESHOLDS;
@@ -3964,6 +4292,7 @@ exports.ROOT_DEX = ROOT_DEX;
3964
4292
  exports.ReturnStatus = ReturnStatus;
3965
4293
  exports.ReviewSortBy = ReviewSortBy;
3966
4294
  exports.ReviewStatus = ReviewStatus;
4295
+ exports.SUPER_ADMINS = SUPER_ADMINS;
3967
4296
  exports.ShipmentStatus = ShipmentStatus;
3968
4297
  exports.SortOrder = SortOrder;
3969
4298
  exports.TARGET_APPROVED_MAX_BUILDER_FEE = TARGET_APPROVED_MAX_BUILDER_FEE;
@@ -3975,18 +4304,23 @@ exports.TaxReportStatus = TaxReportStatus;
3975
4304
  exports.TaxType = TaxType;
3976
4305
  exports.USDC_SPOT_TOKEN = USDC_SPOT_TOKEN;
3977
4306
  exports.UserDexAbstractionTypes = UserDexAbstractionTypes;
4307
+ exports.UserSetAbstractionTypes = UserSetAbstractionTypes;
3978
4308
  exports.WidgetType = WidgetType;
3979
4309
  exports.WidgetTypeById = WidgetTypeById;
3980
4310
  exports.XP_BOOST_PERCENTAGES = XP_BOOST_PERCENTAGES;
4311
+ exports.agentSetAbstraction = agentSetAbstraction;
3981
4312
  exports.buildCloid = buildCloid;
3982
4313
  exports.buildQueryString = buildQueryString;
3983
4314
  exports.calculateBoostPercentage = calculateBoostPercentage;
3984
4315
  exports.calculateDiscountAmount = calculateDiscountAmount;
3985
4316
  exports.calculateFinalPrice = calculateFinalPrice;
3986
4317
  exports.calculateTotalPupAmount = calculateTotalPupAmount;
4318
+ exports.canCancelOrder = canCancelOrder;
4319
+ exports.computeUnifiedAccountRatio = computeUnifiedAccountRatio;
3987
4320
  exports.decodeSlug = decodeSlug;
3988
4321
  exports.enableHip3DexAbstractionWithAgent = enableHip3DexAbstractionWithAgent;
3989
4322
  exports.encodeSlug = encodeSlug;
4323
+ exports.enrichAllPerpsMetaWithAnnotations = enrichAllPerpsMetaWithAnnotations;
3990
4324
  exports.floorUtcDay = floorUtcDay;
3991
4325
  exports.floorUtcHour = floorUtcHour;
3992
4326
  exports.floorUtcMinutes = floorUtcMinutes;
@@ -4007,10 +4341,16 @@ exports.getDisplayMarketSymbol = getDisplayMarketSymbol;
4007
4341
  exports.getHip3Dex = getHip3Dex;
4008
4342
  exports.getHip3DexAbstraction = getHip3DexAbstraction;
4009
4343
  exports.getLatestCompletedWeek = getLatestCompletedWeek;
4344
+ exports.getNextStatuses = getNextStatuses;
4010
4345
  exports.getNextTierInfo = getNextTierInfo;
4346
+ exports.getPerpConciseAnnotations = getPerpConciseAnnotations;
4011
4347
  exports.getPriceDecimals = getPriceDecimals;
4012
4348
  exports.getStaticCollateralTokenByDex = getStaticCollateralTokenByDex;
4013
4349
  exports.getStaticCollateralTokenSymbol = getStaticCollateralTokenSymbol;
4350
+ exports.getStatusColor = getStatusColor;
4351
+ exports.getStatusLabel = getStatusLabel;
4352
+ exports.getStatusProgress = getStatusProgress;
4353
+ exports.getUserAbstraction = getUserAbstraction;
4014
4354
  exports.getWeekInfoFromNumber = getWeekInfoFromNumber;
4015
4355
  exports.getWidgetTypeById = getWidgetTypeById;
4016
4356
  exports.isBasedCloid = isBasedCloid;
@@ -4018,6 +4358,7 @@ exports.isClientCode = isClientCode;
4018
4358
  exports.isHip3Symbol = isHip3Symbol;
4019
4359
  exports.isMiniAppCloid = isMiniAppCloid;
4020
4360
  exports.isMiniAppTriggeredCloid = isMiniAppTriggeredCloid;
4361
+ exports.isPickupOrder = isPickupOrder;
4021
4362
  exports.isRetryableError = isRetryableError;
4022
4363
  exports.isSpotSymbol = isSpotSymbol;
4023
4364
  exports.isStableQuoteToken = isStableQuoteToken;
@@ -4032,8 +4373,12 @@ exports.normaliseTrackingId = normaliseTrackingId;
4032
4373
  exports.normalizeAirdropAmount = normalizeAirdropAmount;
4033
4374
  exports.parseCloid = parseCloid;
4034
4375
  exports.parseError = parseError;
4376
+ exports.requiresTrackingInfo = requiresTrackingInfo;
4035
4377
  exports.retryWithBackoff = retryWithBackoff;
4036
4378
  exports.setHip3DexAbstraction = setHip3DexAbstraction;
4379
+ exports.setUserAbstraction = setUserAbstraction;
4380
+ exports.shouldNotifyCustomer = shouldNotifyCustomer;
4037
4381
  exports.sleep = sleep;
4038
4382
  exports.stableQuoteTokens = stableQuoteTokens;
4039
4383
  exports.truncateAddress = truncateAddress;
4384
+ exports.validateStatusTransition = validateStatusTransition;