@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.
@@ -192,6 +192,8 @@ declare enum OrderStatus {
192
192
  DELIVERED = "DELIVERED",
193
193
  /** Order has been cancelled */
194
194
  CANCELLED = "CANCELLED",
195
+ /** Payment settled / escrow released to merchant */
196
+ SETTLED = "SETTLED",
195
197
  /** Order is confirmed (legacy status) */
196
198
  CONFIRMED = "CONFIRMED",
197
199
  /** Order is completed (legacy status) */
@@ -437,8 +439,10 @@ declare enum ProductSortBy {
437
439
  PRICE_ASC = "price_asc",
438
440
  /** Sort by price (high to low) */
439
441
  PRICE_DESC = "price_desc",
440
- /** Sort by popularity */
442
+ /** Sort by popularity (views) */
441
443
  POPULAR = "popular",
444
+ /** Sort by best selling (sold quantity) */
445
+ BEST_SELLING = "best_selling",
442
446
  /** Sort by featured status */
443
447
  FEATURED = "featured",
444
448
  /** Sort by proximity to user location (requires lat/lng) */
@@ -770,6 +774,20 @@ interface Order extends BaseEntity {
770
774
  };
771
775
  /** Order events */
772
776
  events?: OrderEvent[];
777
+ /** Expected ship date */
778
+ expectedShipDate?: string | null;
779
+ /** Estimated delivery date */
780
+ estimatedDeliveryDate?: string | null;
781
+ /** Estimated delivery days */
782
+ estimatedDeliveryDays?: number | null;
783
+ /** Auto-complete deadline */
784
+ autoCompleteDeadline?: string | null;
785
+ /** Customer confirmed receipt timestamp */
786
+ customerConfirmedAt?: string | null;
787
+ /** Auto-completed timestamp */
788
+ autoCompletedAt?: string | null;
789
+ /** Status transition timestamps */
790
+ statusTransitions?: Record<string, string> | null;
773
791
  }
774
792
  /**
775
793
  * Order event entity
@@ -2288,6 +2306,10 @@ interface ValidateDiscountResponse {
2288
2306
  /** Discount amount */
2289
2307
  discountAmount: number;
2290
2308
  };
2309
+ /** Merchant ID the discount belongs to */
2310
+ merchantId?: string;
2311
+ /** Merchant name the discount belongs to */
2312
+ merchantName?: string | null;
2291
2313
  /** Subtotal */
2292
2314
  subtotal?: number;
2293
2315
  /** Total */
@@ -3207,6 +3229,30 @@ interface CashAccountBalanceResponse {
3207
3229
  /** Currency code (e.g., "USD") */
3208
3230
  currency: string;
3209
3231
  }
3232
+ interface CustomerNotification {
3233
+ id: string;
3234
+ type: string;
3235
+ title: string;
3236
+ message: string;
3237
+ metadata: Record<string, any> | null;
3238
+ isRead: boolean;
3239
+ createdAt: string;
3240
+ }
3241
+ interface CustomerNotificationsResponse {
3242
+ notifications: CustomerNotification[];
3243
+ stats: {
3244
+ unread: number;
3245
+ };
3246
+ pagination: {
3247
+ total: number;
3248
+ limit: number;
3249
+ offset: number;
3250
+ hasMore: boolean;
3251
+ };
3252
+ }
3253
+ interface MarkNotificationsReadResponse {
3254
+ updated: number;
3255
+ }
3210
3256
  interface DeliveryAddressResponse {
3211
3257
  name: string;
3212
3258
  phoneNumber: string;
@@ -4013,6 +4059,32 @@ declare class CustomerEcommerceClient extends BaseEcommerceClient {
4013
4059
  * ```
4014
4060
  */
4015
4061
  getDeliveryAddress(): Promise<DeliveryAddressResponse>;
4062
+ /**
4063
+ * Get user's Hyperliquid USDC balance (perp withdrawable)
4064
+ *
4065
+ * Returns the USDC balance available for escrow deposits via usdSend.
4066
+ *
4067
+ * @returns Balance response with amount and currency
4068
+ */
4069
+ getUsdcBalance(): Promise<CashAccountBalanceResponse>;
4070
+ /**
4071
+ * List notifications for the authenticated customer
4072
+ *
4073
+ * @param params - Query parameters for filtering and pagination
4074
+ * @returns Paginated list of notifications with unread count
4075
+ */
4076
+ listNotifications(params?: {
4077
+ limit?: number;
4078
+ offset?: number;
4079
+ unreadOnly?: boolean;
4080
+ }): Promise<CustomerNotificationsResponse>;
4081
+ /**
4082
+ * Mark notifications as read
4083
+ *
4084
+ * @param ids - Specific notification IDs to mark as read. If omitted, marks all as read.
4085
+ * @returns Count of updated notifications
4086
+ */
4087
+ markNotificationsAsRead(ids?: string[]): Promise<MarkNotificationsReadResponse>;
4016
4088
  }
4017
4089
 
4018
4090
  /**
@@ -5727,4 +5799,52 @@ declare function calculateDiscountAmount(price: number, discountType: "PERCENTAG
5727
5799
  */
5728
5800
  declare function calculateFinalPrice(price: number, discountType: "PERCENTAGE" | "FIXED_AMOUNT", discountValue: number): number;
5729
5801
 
5730
- export { type ActiveFlashSalesResponse, type AnalyticsOverview, type ApiResponse, type AppliedDiscount, type Banner, type BannerResponse, BannerType, BaseEcommerceClient, type BaseEntity, type BrowsingLocation, type CalculateCartDiscountsRequest, type CalculateCartDiscountsResponse, type CalculateShippingRequest, type CalculateShippingResponse, type CalculateTaxRequest, type CalculateTaxResponse, type CartItem, type CashAccountBalanceResponse, type ConfirmEscrowDepositResponse, type Coupon, type CouponResponse, type CouponUsage, type CreateBannerRequest, type CreateCouponRequest, type CreateFlashSaleRequest, type CreateOrderEventRequest, type CreateOrderEventResponse, type CreateOrderRequest, type CreateOrderResponse, type CreateProductRequest, type CreateProductVariantRequest, type CreateReviewRequest, type CreateShippingMethodRequest, type CreateShippingRateRequest, type CreateShippingZoneRequest, type CreateTaxNexusRequest, type CreateTaxRuleRequest, CustomerEcommerceClient, type CustomerMessagesResponse, type CustomerSummary, type DeleteBrowsingLocationResponse, type DeliveryAddressResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, type EcommerceClientConfig, type ExpiringGemBatch, type FlashSale, type FlashSaleAllowanceInfo, type FlashSaleItem, type FlashSaleItemInput, type FollowActionResponse, type FollowStatusResponse, type FollowedMerchantSummary, type GemHistoryItem, type GemHistoryType, type GemHistoryTypeFilter, type GemSource, type GenerateTaxReportRequest, type GetAnalyticsParams, type GetAnalyticsResponse, type GetBrowsingLocationResponse, type GetCouponResponse, type GetExpiringGemsParams, type GetExpiringGemsResponse, type GetFlashSaleAllowanceParams, type GetFlashSaleAllowanceResponse, type GetGemBalanceResponse, type GetGemHistoryParams, type GetGemHistoryResponse, type GetOrderResponse, type GetPaymentMethodsResponse, type GetProductMetricsResponse, type GetProductResponse, type GetTaxReportResponse, InventoryAuditAction, type InventoryAuditEntry, type ListActiveBannersParams, type ListActiveFlashSalesParams, type ListBannersResponse, type ListCouponsResponse, type ListCustomersParams, type ListCustomersResponse, type ListFollowingParams, type ListFollowingResponse, type ListInventoryAuditResponse, type ListMediaAssetsResponse, type ListMerchantProductsParams, type ListMessagesResponse, type ListOrdersParams, type ListOrdersResponse, type ListProductVariantsResponse, type ListProductsParams, type ListProductsResponse, type ListReturnsResponse, type ListReviewsParams, type ListReviewsResponse, type ListShipmentsResponse, type ListShippingAddressesResponse, type ListShippingMethodsResponse, type ListShippingRatesResponse, type ListShippingZonesResponse, type ListTaxNexusResponse, type ListTaxReportsParams, type ListTaxReportsResponse, type ListTaxRulesResponse, type MediaAsset, type MediaAssetResponse, type Merchant, MerchantBusinessType, MerchantEcommerceClient, type MerchantProductsResponse, type MerchantProfileRequest, type MerchantProfileResponse, MerchantReturnPolicyType, type MerchantShippingSettings, type MerchantSocialLinks, MerchantStatus, type Message, type MessageResponse, type MessageStatsResponse, type Order, type OrderEvent, type OrderItem, type OrderReceiptResponse, OrderStatus, type OrdersByStatus, type PaginatedResponse, type PaginationParams, type Payment, PaymentMethod, type PaymentMethodInfo, PaymentStatus, type ProcessPaymentRequest, type ProcessPaymentResponse, type Product, type ProductDimensions, type ProductDiscountsResponse, type ProductMetrics, type ProductResponse, type ProductReview, ProductSortBy, type ProductVariant, type ProductVariantResponse, type PublicMerchantProfile, type PublicMerchantProfileResponse, type RecentOrderSummary, type RespondToReviewRequest, type Return, type ReturnItem, type ReturnResponse, ReturnStatus, type RevenueByDay, type ReviewResponse, ReviewSortBy, ReviewStatus, type SaveBrowsingLocationRequest, type SaveBrowsingLocationResponse, type SendMessageRequest, type Settlement, type Shipment, type ShipmentResponse, ShipmentStatus, type ShippingAddress$1 as ShippingAddress, type ShippingAddressRequest, type ShippingAddressResponse, type ShippingMethod, type ShippingMethodResponse, type ShippingOption, type ShippingRate, type ShippingRateResponse, type ShippingSettingsResponse, type ShippingZone, type ShippingZoneResponse, SortOrder, type SuccessResponse, TaxBehavior, type TaxBreakdownItem, type TaxNexus, type TaxNexusResponse, type TaxReport, type TaxReportDetails, TaxReportPeriodType, type TaxReportResponse, TaxReportStatus, type TaxRule, type TaxRuleResponse, type TaxSettings, type TaxSettingsResponse, TaxType, type TopProduct, type TrackBannerRequest, type UpdateBannerRequest, type UpdateCouponRequest, type UpdateFlashSaleRequest, type UpdateOrderResponse, type UpdateOrderStatusRequest, type UpdateProductRequest, type UpdateProductVariantRequest, type UpdateShipmentRequest, type UpdateShippingMethodRequest, type UpdateShippingRateRequest, type UpdateShippingSettingsRequest, type UpdateShippingZoneRequest, type UpdateTaxNexusRequest, type UpdateTaxReportStatusRequest, type UpdateTaxRuleRequest, type UpdateTaxSettingsRequest, type UserShippingAddress, type ValidateDiscountRequest, type ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress };
5802
+ /** Detect pickup / on-site-collection shipping methods (normalised matching) */
5803
+ declare function isPickupOrder(shippingMethod?: string | null, shippingRateId?: string | null): boolean;
5804
+ /**
5805
+ * Canonical order status transitions.
5806
+ *
5807
+ * Buyer-protected escrow flow:
5808
+ * CREATED → PAYMENT_RESERVED → MERCHANT_ACCEPTED → SHIPPED → DELIVERED → SETTLED
5809
+ *
5810
+ * Cancellation is allowed from any non-terminal state except DELIVERED (already in settlement).
5811
+ */
5812
+ declare const ORDER_STATUS_TRANSITIONS: Partial<Record<OrderStatus, OrderStatus[]>>;
5813
+ /**
5814
+ * Validate whether transitioning from `currentStatus` to `newStatus` is allowed.
5815
+ *
5816
+ * For pickup / on-site-collection orders, MERCHANT_ACCEPTED → DELIVERED and
5817
+ * SETTLED → DELIVERED are permitted (skipping SHIPPED).
5818
+ */
5819
+ declare function validateStatusTransition(currentStatus: string, newStatus: string, options?: {
5820
+ shippingMethod?: string | null;
5821
+ shippingRateId?: string | null;
5822
+ }): {
5823
+ valid: boolean;
5824
+ error?: string;
5825
+ };
5826
+ /**
5827
+ * Return the list of statuses reachable from `currentStatus`.
5828
+ * For pickup orders, DELIVERED is added when on MERCHANT_ACCEPTED or SETTLED.
5829
+ */
5830
+ declare function getNextStatuses(currentStatus: string, options?: {
5831
+ shippingMethod?: string | null;
5832
+ shippingRateId?: string | null;
5833
+ }): string[];
5834
+ /** Human-readable label for a status. */
5835
+ declare function getStatusLabel(status: string): string;
5836
+ /** UI colour key for a status. */
5837
+ declare function getStatusColor(status: string): string;
5838
+ /** Whether the order can be cancelled from its current status. */
5839
+ declare function canCancelOrder(currentStatus: string): boolean;
5840
+ /** Whether tracking info is required for a status change. */
5841
+ declare function requiresTrackingInfo(newStatus: string, options?: {
5842
+ shippingMethod?: string | null;
5843
+ shippingRateId?: string | null;
5844
+ }): boolean;
5845
+ /** Whether a status change should trigger customer notification. */
5846
+ declare function shouldNotifyCustomer(newStatus: string): boolean;
5847
+ /** Status progression percentage (for progress bars). */
5848
+ declare function getStatusProgress(status: string): number;
5849
+
5850
+ export { type ActiveFlashSalesResponse, type AnalyticsOverview, type ApiResponse, type AppliedDiscount, type Banner, type BannerResponse, BannerType, BaseEcommerceClient, type BaseEntity, type BrowsingLocation, type CalculateCartDiscountsRequest, type CalculateCartDiscountsResponse, type CalculateShippingRequest, type CalculateShippingResponse, type CalculateTaxRequest, type CalculateTaxResponse, type CartItem, type CashAccountBalanceResponse, type ConfirmEscrowDepositResponse, type Coupon, type CouponResponse, type CouponUsage, type CreateBannerRequest, type CreateCouponRequest, type CreateFlashSaleRequest, type CreateOrderEventRequest, type CreateOrderEventResponse, type CreateOrderRequest, type CreateOrderResponse, type CreateProductRequest, type CreateProductVariantRequest, type CreateReviewRequest, type CreateShippingMethodRequest, type CreateShippingRateRequest, type CreateShippingZoneRequest, type CreateTaxNexusRequest, type CreateTaxRuleRequest, CustomerEcommerceClient, type CustomerMessagesResponse, type CustomerNotification, type CustomerNotificationsResponse, type CustomerSummary, type DeleteBrowsingLocationResponse, type DeliveryAddressResponse, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, type EcommerceClientConfig, type ExpiringGemBatch, type FlashSale, type FlashSaleAllowanceInfo, type FlashSaleItem, type FlashSaleItemInput, type FollowActionResponse, type FollowStatusResponse, type FollowedMerchantSummary, type GemHistoryItem, type GemHistoryType, type GemHistoryTypeFilter, type GemSource, type GenerateTaxReportRequest, type GetAnalyticsParams, type GetAnalyticsResponse, type GetBrowsingLocationResponse, type GetCouponResponse, type GetExpiringGemsParams, type GetExpiringGemsResponse, type GetFlashSaleAllowanceParams, type GetFlashSaleAllowanceResponse, type GetGemBalanceResponse, type GetGemHistoryParams, type GetGemHistoryResponse, type GetOrderResponse, type GetPaymentMethodsResponse, type GetProductMetricsResponse, type GetProductResponse, type GetTaxReportResponse, InventoryAuditAction, type InventoryAuditEntry, type ListActiveBannersParams, type ListActiveFlashSalesParams, type ListBannersResponse, type ListCouponsResponse, type ListCustomersParams, type ListCustomersResponse, type ListFollowingParams, type ListFollowingResponse, type ListInventoryAuditResponse, type ListMediaAssetsResponse, type ListMerchantProductsParams, type ListMessagesResponse, type ListOrdersParams, type ListOrdersResponse, type ListProductVariantsResponse, type ListProductsParams, type ListProductsResponse, type ListReturnsResponse, type ListReviewsParams, type ListReviewsResponse, type ListShipmentsResponse, type ListShippingAddressesResponse, type ListShippingMethodsResponse, type ListShippingRatesResponse, type ListShippingZonesResponse, type ListTaxNexusResponse, type ListTaxReportsParams, type ListTaxReportsResponse, type ListTaxRulesResponse, type MarkNotificationsReadResponse, type MediaAsset, type MediaAssetResponse, type Merchant, MerchantBusinessType, MerchantEcommerceClient, type MerchantProductsResponse, type MerchantProfileRequest, type MerchantProfileResponse, MerchantReturnPolicyType, type MerchantShippingSettings, type MerchantSocialLinks, MerchantStatus, type Message, type MessageResponse, type MessageStatsResponse, ORDER_STATUS_TRANSITIONS, type Order, type OrderEvent, type OrderItem, type OrderReceiptResponse, OrderStatus, type OrdersByStatus, type PaginatedResponse, type PaginationParams, type Payment, PaymentMethod, type PaymentMethodInfo, PaymentStatus, type ProcessPaymentRequest, type ProcessPaymentResponse, type Product, type ProductDimensions, type ProductDiscountsResponse, type ProductMetrics, type ProductResponse, type ProductReview, ProductSortBy, type ProductVariant, type ProductVariantResponse, type PublicMerchantProfile, type PublicMerchantProfileResponse, type RecentOrderSummary, type RespondToReviewRequest, type Return, type ReturnItem, type ReturnResponse, ReturnStatus, type RevenueByDay, type ReviewResponse, ReviewSortBy, ReviewStatus, type SaveBrowsingLocationRequest, type SaveBrowsingLocationResponse, type SendMessageRequest, type Settlement, type Shipment, type ShipmentResponse, ShipmentStatus, type ShippingAddress$1 as ShippingAddress, type ShippingAddressRequest, type ShippingAddressResponse, type ShippingMethod, type ShippingMethodResponse, type ShippingOption, type ShippingRate, type ShippingRateResponse, type ShippingSettingsResponse, type ShippingZone, type ShippingZoneResponse, SortOrder, type SuccessResponse, TaxBehavior, type TaxBreakdownItem, type TaxNexus, type TaxNexusResponse, type TaxReport, type TaxReportDetails, TaxReportPeriodType, type TaxReportResponse, TaxReportStatus, type TaxRule, type TaxRuleResponse, type TaxSettings, type TaxSettingsResponse, TaxType, type TopProduct, type TrackBannerRequest, type UpdateBannerRequest, type UpdateCouponRequest, type UpdateFlashSaleRequest, type UpdateOrderResponse, type UpdateOrderStatusRequest, type UpdateProductRequest, type UpdateProductVariantRequest, type UpdateShipmentRequest, type UpdateShippingMethodRequest, type UpdateShippingRateRequest, type UpdateShippingSettingsRequest, type UpdateShippingZoneRequest, type UpdateTaxNexusRequest, type UpdateTaxReportStatusRequest, type UpdateTaxRuleRequest, type UpdateTaxSettingsRequest, type UserShippingAddress, type ValidateDiscountRequest, type ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, canCancelOrder, formatPrice, getBackoffDelay, getNextStatuses, getStatusColor, getStatusLabel, getStatusProgress, isPickupOrder, isRetryableError, isValidAddress, isValidEmail, parseError, requiresTrackingInfo, retryWithBackoff, shouldNotifyCustomer, sleep, truncateAddress, validateStatusTransition };
package/dist/ecommerce.js CHANGED
@@ -1230,6 +1230,38 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
1230
1230
  async getDeliveryAddress() {
1231
1231
  return this.get("/api/basedpay/delivery-address");
1232
1232
  }
1233
+ /**
1234
+ * Get user's Hyperliquid USDC balance (perp withdrawable)
1235
+ *
1236
+ * Returns the USDC balance available for escrow deposits via usdSend.
1237
+ *
1238
+ * @returns Balance response with amount and currency
1239
+ */
1240
+ async getUsdcBalance() {
1241
+ return this.get("/api/marketplace/usdc-balance");
1242
+ }
1243
+ // ============================================================================
1244
+ // Notifications API
1245
+ // ============================================================================
1246
+ /**
1247
+ * List notifications for the authenticated customer
1248
+ *
1249
+ * @param params - Query parameters for filtering and pagination
1250
+ * @returns Paginated list of notifications with unread count
1251
+ */
1252
+ async listNotifications(params) {
1253
+ const queryString = params ? buildQueryString(params) : "";
1254
+ return this.get(`/api/marketplace/notifications${queryString}`);
1255
+ }
1256
+ /**
1257
+ * Mark notifications as read
1258
+ *
1259
+ * @param ids - Specific notification IDs to mark as read. If omitted, marks all as read.
1260
+ * @returns Count of updated notifications
1261
+ */
1262
+ async markNotificationsAsRead(ids) {
1263
+ return this.patch("/api/marketplace/notifications/read", { ids });
1264
+ }
1233
1265
  };
1234
1266
 
1235
1267
  // lib/ecommerce/client/merchant.ts
@@ -2775,6 +2807,7 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
2775
2807
  OrderStatus2["SHIPPED"] = "SHIPPED";
2776
2808
  OrderStatus2["DELIVERED"] = "DELIVERED";
2777
2809
  OrderStatus2["CANCELLED"] = "CANCELLED";
2810
+ OrderStatus2["SETTLED"] = "SETTLED";
2778
2811
  OrderStatus2["CONFIRMED"] = "CONFIRMED";
2779
2812
  OrderStatus2["COMPLETED"] = "COMPLETED";
2780
2813
  return OrderStatus2;
@@ -2908,6 +2941,7 @@ var ProductSortBy = /* @__PURE__ */ ((ProductSortBy2) => {
2908
2941
  ProductSortBy2["PRICE_ASC"] = "price_asc";
2909
2942
  ProductSortBy2["PRICE_DESC"] = "price_desc";
2910
2943
  ProductSortBy2["POPULAR"] = "popular";
2944
+ ProductSortBy2["BEST_SELLING"] = "best_selling";
2911
2945
  ProductSortBy2["FEATURED"] = "featured";
2912
2946
  ProductSortBy2["NEARBY"] = "nearby";
2913
2947
  return ProductSortBy2;
@@ -2919,6 +2953,120 @@ var ReviewSortBy = /* @__PURE__ */ ((ReviewSortBy2) => {
2919
2953
  return ReviewSortBy2;
2920
2954
  })(ReviewSortBy || {});
2921
2955
 
2956
+ // lib/ecommerce/utils/orderStateMachine.ts
2957
+ function isPickupOrder(shippingMethod, shippingRateId) {
2958
+ if (shippingRateId && shippingRateId.trim().toUpperCase() === "PICKUP") {
2959
+ return true;
2960
+ }
2961
+ if (!shippingMethod) return false;
2962
+ const normalized = shippingMethod.trim().toLowerCase().replace(/[\s-]+/g, " ");
2963
+ return normalized === "pickup" || normalized === "on site collection" || normalized === "onsite collection";
2964
+ }
2965
+ var ORDER_STATUS_TRANSITIONS = {
2966
+ ["CREATED" /* CREATED */]: [
2967
+ "PAYMENT_RESERVED" /* PAYMENT_RESERVED */,
2968
+ "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */,
2969
+ "CANCELLED" /* CANCELLED */
2970
+ ],
2971
+ ["PAYMENT_RESERVED" /* PAYMENT_RESERVED */]: [
2972
+ "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */,
2973
+ "CANCELLED" /* CANCELLED */
2974
+ ],
2975
+ ["MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */]: [
2976
+ "SHIPPED" /* SHIPPED */,
2977
+ "CANCELLED" /* CANCELLED */
2978
+ ],
2979
+ // Backward compat for existing SETTLED orders created before escrow change
2980
+ // Note: CANCELLED removed — settled orders have funds paid out, no clawback mechanism
2981
+ ["SETTLED" /* SETTLED */]: ["SHIPPED" /* SHIPPED */],
2982
+ ["SHIPPED" /* SHIPPED */]: ["DELIVERED" /* DELIVERED */, "CANCELLED" /* CANCELLED */],
2983
+ // Settlement triggered on delivery (buyer-protected escrow)
2984
+ ["DELIVERED" /* DELIVERED */]: ["SETTLED" /* SETTLED */],
2985
+ // Terminal states
2986
+ ["CANCELLED" /* CANCELLED */]: []
2987
+ };
2988
+ function validateStatusTransition(currentStatus, newStatus, options) {
2989
+ if (isPickupOrder(options?.shippingMethod, options?.shippingRateId) && (currentStatus === "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */ || currentStatus === "SETTLED" /* SETTLED */) && newStatus === "DELIVERED" /* DELIVERED */) {
2990
+ return { valid: true };
2991
+ }
2992
+ const allowed = ORDER_STATUS_TRANSITIONS[currentStatus] ?? [];
2993
+ if (!allowed.includes(newStatus)) {
2994
+ if (allowed.length === 0) {
2995
+ return {
2996
+ valid: false,
2997
+ error: `Cannot change status from ${currentStatus} \u2014 this is a final state`
2998
+ };
2999
+ }
3000
+ return {
3001
+ valid: false,
3002
+ error: `Cannot transition from ${currentStatus} to ${newStatus}. Allowed: ${allowed.join(", ")}`
3003
+ };
3004
+ }
3005
+ return { valid: true };
3006
+ }
3007
+ function getNextStatuses(currentStatus, options) {
3008
+ const base = [
3009
+ ...ORDER_STATUS_TRANSITIONS[currentStatus] ?? []
3010
+ ];
3011
+ if (isPickupOrder(options?.shippingMethod, options?.shippingRateId) && (currentStatus === "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */ || currentStatus === "SETTLED" /* SETTLED */) && !base.includes("DELIVERED" /* DELIVERED */)) {
3012
+ base.push("DELIVERED" /* DELIVERED */);
3013
+ }
3014
+ return base;
3015
+ }
3016
+ function getStatusLabel(status) {
3017
+ const labels = {
3018
+ CREATED: "Created",
3019
+ PAYMENT_RESERVED: "Payment Reserved",
3020
+ MERCHANT_ACCEPTED: "Accepted",
3021
+ SETTLED: "Completed (Paid)",
3022
+ SHIPPED: "Shipped",
3023
+ DELIVERED: "Delivered",
3024
+ CANCELLED: "Cancelled"
3025
+ };
3026
+ return labels[status] || status;
3027
+ }
3028
+ function getStatusColor(status) {
3029
+ const colors = {
3030
+ CREATED: "gray",
3031
+ PAYMENT_RESERVED: "blue",
3032
+ MERCHANT_ACCEPTED: "purple",
3033
+ SETTLED: "indigo",
3034
+ SHIPPED: "yellow",
3035
+ DELIVERED: "green",
3036
+ CANCELLED: "red"
3037
+ };
3038
+ return colors[status] || "gray";
3039
+ }
3040
+ function canCancelOrder(currentStatus) {
3041
+ return ORDER_STATUS_TRANSITIONS[currentStatus]?.includes(
3042
+ "CANCELLED" /* CANCELLED */
3043
+ ) ?? false;
3044
+ }
3045
+ function requiresTrackingInfo(newStatus, options) {
3046
+ if (newStatus !== "SHIPPED" /* SHIPPED */) return false;
3047
+ return !isPickupOrder(options?.shippingMethod, options?.shippingRateId);
3048
+ }
3049
+ function shouldNotifyCustomer(newStatus) {
3050
+ return [
3051
+ "MERCHANT_ACCEPTED" /* MERCHANT_ACCEPTED */,
3052
+ "SHIPPED" /* SHIPPED */,
3053
+ "DELIVERED" /* DELIVERED */,
3054
+ "CANCELLED" /* CANCELLED */
3055
+ ].includes(newStatus);
3056
+ }
3057
+ function getStatusProgress(status) {
3058
+ const progressMap = {
3059
+ CREATED: 10,
3060
+ PAYMENT_RESERVED: 25,
3061
+ MERCHANT_ACCEPTED: 40,
3062
+ SETTLED: 50,
3063
+ SHIPPED: 75,
3064
+ DELIVERED: 100,
3065
+ CANCELLED: 0
3066
+ };
3067
+ return progressMap[status] || 0;
3068
+ }
3069
+
2922
3070
  exports.BannerType = BannerType;
2923
3071
  exports.BaseEcommerceClient = BaseEcommerceClient;
2924
3072
  exports.CustomerEcommerceClient = CustomerEcommerceClient;
@@ -2931,6 +3079,7 @@ exports.MerchantBusinessType = MerchantBusinessType;
2931
3079
  exports.MerchantEcommerceClient = MerchantEcommerceClient;
2932
3080
  exports.MerchantReturnPolicyType = MerchantReturnPolicyType;
2933
3081
  exports.MerchantStatus = MerchantStatus;
3082
+ exports.ORDER_STATUS_TRANSITIONS = ORDER_STATUS_TRANSITIONS;
2934
3083
  exports.OrderStatus = OrderStatus;
2935
3084
  exports.PaymentMethod = PaymentMethod;
2936
3085
  exports.PaymentStatus = PaymentStatus;
@@ -2947,12 +3096,21 @@ exports.TaxType = TaxType;
2947
3096
  exports.buildQueryString = buildQueryString;
2948
3097
  exports.calculateDiscountAmount = calculateDiscountAmount;
2949
3098
  exports.calculateFinalPrice = calculateFinalPrice;
3099
+ exports.canCancelOrder = canCancelOrder;
2950
3100
  exports.formatPrice = formatPrice;
2951
3101
  exports.getBackoffDelay = getBackoffDelay;
3102
+ exports.getNextStatuses = getNextStatuses;
3103
+ exports.getStatusColor = getStatusColor;
3104
+ exports.getStatusLabel = getStatusLabel;
3105
+ exports.getStatusProgress = getStatusProgress;
3106
+ exports.isPickupOrder = isPickupOrder;
2952
3107
  exports.isRetryableError = isRetryableError;
2953
3108
  exports.isValidAddress = isValidAddress;
2954
3109
  exports.isValidEmail = isValidEmail;
2955
3110
  exports.parseError = parseError;
3111
+ exports.requiresTrackingInfo = requiresTrackingInfo;
2956
3112
  exports.retryWithBackoff = retryWithBackoff;
3113
+ exports.shouldNotifyCustomer = shouldNotifyCustomer;
2957
3114
  exports.sleep = sleep;
2958
3115
  exports.truncateAddress = truncateAddress;
3116
+ exports.validateStatusTransition = validateStatusTransition;
@@ -1 +1 @@
1
- export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantBusinessType, MerchantEcommerceClient, MerchantReturnPolicyType, MerchantStatus, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './chunk-NKSQEISP.mjs';
1
+ export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantBusinessType, MerchantEcommerceClient, MerchantReturnPolicyType, MerchantStatus, ORDER_STATUS_TRANSITIONS, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, canCancelOrder, formatPrice, getBackoffDelay, getNextStatuses, getStatusColor, getStatusLabel, getStatusProgress, isPickupOrder, isRetryableError, isValidAddress, isValidEmail, parseError, requiresTrackingInfo, retryWithBackoff, shouldNotifyCustomer, sleep, truncateAddress, validateStatusTransition } from './chunk-35WGIB5F.mjs';
package/dist/index.d.mts 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.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, 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.mjs';
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.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';
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 };