@basedone/core 0.2.8 → 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.
- package/dist/{chunk-NKSQEISP.mjs → chunk-35WGIB5F.mjs} +149 -1
- package/dist/{client-DMVXX1Gw.d.mts → client-BQzYwHDY.d.mts} +2 -2
- package/dist/{client-DMVXX1Gw.d.ts → client-BQzYwHDY.d.ts} +2 -2
- package/dist/ecommerce.d.mts +122 -2
- package/dist/ecommerce.d.ts +122 -2
- package/dist/ecommerce.js +158 -0
- package/dist/ecommerce.mjs +1 -1
- package/dist/index.d.mts +113 -3
- package/dist/index.d.ts +113 -3
- package/dist/index.js +299 -0
- package/dist/index.mjs +134 -2
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/index.ts +3 -0
- package/lib/abstraction/api.ts +106 -0
- package/lib/abstraction/index.ts +3 -0
- package/lib/abstraction/ratio.ts +61 -0
- package/lib/abstraction/types.ts +73 -0
- package/lib/constants/admin.ts +30 -0
- package/lib/ecommerce/client/customer.ts +42 -0
- package/lib/ecommerce/index.ts +14 -0
- package/lib/ecommerce/types/entities.ts +14 -0
- package/lib/ecommerce/types/enums.ts +5 -1
- package/lib/ecommerce/types/responses.ts +28 -0
- package/lib/ecommerce/utils/orderStateMachine.ts +197 -0
- package/lib/types.ts +29 -0
- package/package.json +1 -1
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;
|
package/dist/ecommerce.mjs
CHANGED
|
@@ -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-
|
|
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,
|
|
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 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';
|
|
4
4
|
import 'axios';
|
|
5
5
|
|
|
6
6
|
declare function encodeSlug(slug: string): bigint;
|
|
@@ -241,6 +241,9 @@ 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 ADMINS: string[];
|
|
245
|
+
declare const ADMIN_WALLETS: string[];
|
|
246
|
+
|
|
244
247
|
interface PerpsMeta {
|
|
245
248
|
/** Trading universes available for perpetual trading. */
|
|
246
249
|
universe: PerpsUniverse[];
|
|
@@ -496,4 +499,111 @@ declare function isStableQuoteToken(coin: string): boolean;
|
|
|
496
499
|
declare function getDisplayMarketSymbol(coin: string | undefined, showCollateralTokenSymbol?: boolean, collateralTokenSymbol?: string): string | undefined;
|
|
497
500
|
declare function getDexFromCollateralTokenSymbol(collateralTokenSymbol: string): string | undefined;
|
|
498
501
|
|
|
499
|
-
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { SpotToken, MarginTables, PerpsAssetCtx, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
|
|
2
|
-
export { A as AllPerpsMeta,
|
|
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 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';
|
|
4
4
|
import 'axios';
|
|
5
5
|
|
|
6
6
|
declare function encodeSlug(slug: string): bigint;
|
|
@@ -241,6 +241,9 @@ 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 ADMINS: string[];
|
|
245
|
+
declare const ADMIN_WALLETS: string[];
|
|
246
|
+
|
|
244
247
|
interface PerpsMeta {
|
|
245
248
|
/** Trading universes available for perpetual trading. */
|
|
246
249
|
universe: PerpsUniverse[];
|
|
@@ -496,4 +499,111 @@ declare function isStableQuoteToken(coin: string): boolean;
|
|
|
496
499
|
declare function getDisplayMarketSymbol(coin: string | undefined, showCollateralTokenSymbol?: boolean, collateralTokenSymbol?: string): string | undefined;
|
|
497
500
|
declare function getDexFromCollateralTokenSymbol(collateralTokenSymbol: string): string | undefined;
|
|
498
501
|
|
|
499
|
-
|
|
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 };
|