@basedone/core 0.1.10 → 0.2.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.
Files changed (54) hide show
  1. package/dist/chunk-4UEJOM6W.mjs +1 -3
  2. package/dist/chunk-MVFO4WRF.mjs +2091 -0
  3. package/dist/chunk-VBC6EQ7Q.mjs +235 -0
  4. package/dist/client-CgmiTuEX.d.mts +179 -0
  5. package/dist/client-CgmiTuEX.d.ts +179 -0
  6. package/dist/ecommerce.d.mts +3986 -0
  7. package/dist/ecommerce.d.ts +3986 -0
  8. package/dist/ecommerce.js +2135 -0
  9. package/dist/ecommerce.mjs +2 -0
  10. package/dist/index.d.mts +51 -43
  11. package/dist/index.d.ts +51 -43
  12. package/dist/index.js +2795 -205
  13. package/dist/index.mjs +68 -90
  14. package/dist/{meta-FVJIMALT.mjs → meta-JB5ITE27.mjs} +4 -10
  15. package/dist/meta-UOGUG3OW.mjs +3 -7
  16. package/dist/{perpDexs-GGL32HT4.mjs → perpDexs-3LRJ5ZHM.mjs} +37 -8
  17. package/dist/{perpDexs-G7V2QIM6.mjs → perpDexs-4ISLD7NX.mjs} +177 -32
  18. package/dist/react.d.mts +39 -0
  19. package/dist/react.d.ts +39 -0
  20. package/dist/react.js +268 -0
  21. package/dist/react.mjs +31 -0
  22. package/dist/{spotMeta-OD7S6HGW.mjs → spotMeta-GHXX7C5M.mjs} +24 -9
  23. package/dist/{spotMeta-PCN4Z4R3.mjs → spotMeta-IBBUP2SG.mjs} +54 -6
  24. package/dist/staticMeta-GM7T3OYL.mjs +3 -6
  25. package/dist/staticMeta-QV2KMX57.mjs +3 -6
  26. package/ecommerce.ts +15 -0
  27. package/index.ts +6 -0
  28. package/lib/ecommerce/FLASH_SALES.md +340 -0
  29. package/lib/ecommerce/QUICK_REFERENCE.md +211 -0
  30. package/lib/ecommerce/README.md +391 -0
  31. package/lib/ecommerce/USAGE_EXAMPLES.md +704 -0
  32. package/lib/ecommerce/client/base.ts +272 -0
  33. package/lib/ecommerce/client/customer.ts +639 -0
  34. package/lib/ecommerce/client/merchant.ts +1341 -0
  35. package/lib/ecommerce/index.ts +51 -0
  36. package/lib/ecommerce/types/entities.ts +791 -0
  37. package/lib/ecommerce/types/enums.ts +270 -0
  38. package/lib/ecommerce/types/index.ts +18 -0
  39. package/lib/ecommerce/types/requests.ts +580 -0
  40. package/lib/ecommerce/types/responses.ts +857 -0
  41. package/lib/ecommerce/utils/errors.ts +113 -0
  42. package/lib/ecommerce/utils/helpers.ts +131 -0
  43. package/lib/hip3/market-info.ts +1 -1
  44. package/lib/instrument/client.ts +351 -0
  45. package/lib/meta/data/mainnet/perpDexs.json +34 -4
  46. package/lib/meta/data/mainnet/spotMeta.json +21 -3
  47. package/lib/meta/data/testnet/meta.json +1 -3
  48. package/lib/meta/data/testnet/perpDexs.json +174 -28
  49. package/lib/meta/data/testnet/spotMeta.json +51 -0
  50. package/lib/react/InstrumentProvider.tsx +69 -0
  51. package/lib/utils/flooredDateTime.ts +55 -0
  52. package/lib/utils/time.ts +51 -0
  53. package/package.json +37 -11
  54. package/react.ts +1 -0
@@ -0,0 +1,2 @@
1
+ export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantEcommerceClient, 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-MVFO4WRF.mjs';
2
+ import './chunk-4UEJOM6W.mjs';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { SpotToken, MarginTables, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
2
2
  import { Hex } from '@nktkas/hyperliquid/types';
3
+ export { A as AllPerpsMeta, d as AssetIdUtils, B as BaseInstrument, I as InstrumentClient, M as MarketInstrument, c as PerpsInstrument, P as PerpsMeta, a as PerpsMetaAndAssetCtxs, b as PerpsUniverse, S as SpotInstrument, g as getAllPerpsMeta } from './client-CgmiTuEX.mjs';
4
+ export { ActiveFlashSalesResponse, AnalyticsOverview, ApiResponse, AppliedDiscount, Banner, BannerResponse, BannerType, BaseEcommerceClient, BaseEntity, CalculateCartDiscountsRequest, CalculateCartDiscountsResponse, CalculateTaxRequest, CalculateTaxResponse, CartItem, ConfirmEscrowDepositResponse, Coupon, CouponResponse, CouponUsage, CreateBannerRequest, CreateCouponRequest, CreateFlashSaleRequest, CreateOrderEventRequest, CreateOrderEventResponse, CreateOrderRequest, CreateOrderResponse, CreateProductRequest, CreateProductVariantRequest, CreateReviewRequest, CreateShippingMethodRequest, CreateTaxNexusRequest, CreateTaxRuleRequest, CustomerEcommerceClient, CustomerMessagesResponse, CustomerSummary, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, FlashSale, FlashSaleItem, FlashSaleItemInput, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetCouponResponse, GetOrderResponse, GetProductMetricsResponse, GetProductResponse, GetTaxReportResponse, InventoryAuditAction, InventoryAuditEntry, ListActiveBannersParams, ListActiveFlashSalesParams, ListBannersResponse, ListCouponsResponse, ListCustomersParams, ListCustomersResponse, ListInventoryAuditResponse, ListMediaAssetsResponse, ListMessagesResponse, ListOrdersParams, ListOrdersResponse, ListProductVariantsResponse, ListProductsParams, ListProductsResponse, ListReturnsResponse, ListReviewsParams, ListReviewsResponse, ListShipmentsResponse, ListShippingAddressesResponse, ListShippingMethodsResponse, ListTaxNexusResponse, ListTaxReportsParams, ListTaxReportsResponse, ListTaxRulesResponse, MediaAsset, MediaAssetResponse, Merchant, MerchantEcommerceClient, MerchantProfileRequest, MerchantProfileResponse, MerchantStatus, Message, MessageResponse, MessageStatsResponse, Order, OrderEvent, OrderItem, OrderReceiptResponse, OrderStatus, OrdersByStatus, PaginatedResponse, PaginationParams, Payment, PaymentMethod, PaymentStatus, Product, ProductDimensions, ProductDiscountsResponse, ProductMetrics, ProductResponse, ProductReview, ProductSortBy, ProductVariant, ProductVariantResponse, RecentOrderSummary, RespondToReviewRequest, Return, ReturnItem, ReturnResponse, ReturnStatus, RevenueByDay, ReviewResponse, ReviewSortBy, ReviewStatus, SendMessageRequest, Settlement, Shipment, ShipmentResponse, ShipmentStatus, ShippingAddress, ShippingAddressRequest, ShippingAddressResponse, ShippingMethod, ShippingMethodResponse, 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, UpdateTaxNexusRequest, UpdateTaxReportStatusRequest, UpdateTaxRuleRequest, UpdateTaxSettingsRequest, UserShippingAddress, ValidateDiscountRequest, ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './ecommerce.mjs';
5
+ import 'axios';
3
6
 
4
7
  declare function encodeSlug(slug: string): bigint;
5
8
  declare function decodeSlug(value: bigint): string;
@@ -239,16 +242,16 @@ declare function getNextTierInfo(pupTokenAmount: number, normalizedAirDropAmount
239
242
  declare const USDC_SPOT_TOKEN: SpotToken;
240
243
  declare const TESTNET_USDC_SPOT_TOKEN: SpotToken;
241
244
 
242
- interface PerpsMeta$1 {
245
+ interface PerpsMeta {
243
246
  /** Trading universes available for perpetual trading. */
244
- universe: PerpsUniverse$1[];
247
+ universe: PerpsUniverse[];
245
248
  /** Margin requirement tables for different leverage tiers. */
246
249
  marginTables: MarginTables;
247
250
  /** Collateral token index. */
248
251
  collateralToken?: number;
249
252
  }
250
253
  /** Trading universe parameters for perpetual assets. */
251
- interface PerpsUniverse$1 {
254
+ interface PerpsUniverse {
252
255
  /** Minimum decimal places for order sizes. */
253
256
  szDecimals: number;
254
257
  /** Name of the universe. */
@@ -301,7 +304,7 @@ interface MarketInfo {
301
304
  growthMode: boolean;
302
305
  }
303
306
  interface DexInfo {
304
- meta: PerpsMeta$1;
307
+ meta: PerpsMeta;
305
308
  assetContext: PerpsAssetCtx[];
306
309
  dexFullName: string;
307
310
  dexName: string;
@@ -311,7 +314,7 @@ interface DexInfo {
311
314
  imageUrl?: string;
312
315
  accountName?: string;
313
316
  }
314
- type ExtendedPerpsMeta = PerpsMeta$1 & {
317
+ type ExtendedPerpsMeta = PerpsMeta & {
315
318
  collateralToken?: number;
316
319
  };
317
320
  /**
@@ -461,7 +464,7 @@ declare class MetadataClient {
461
464
  */
462
465
  getRawMetadata(): {
463
466
  spotMeta: SpotMeta | null;
464
- perpsMeta: PerpsMeta$1 | null;
467
+ perpsMeta: PerpsMeta | null;
465
468
  perpDexs: (PerpDex | null)[];
466
469
  hip3DexsMeta: {
467
470
  [k: string]: DexInfo;
@@ -554,6 +557,47 @@ declare const formatSizeForDisplay: ({ sz, szDecimals, }: {
554
557
  */
555
558
  declare function getPriceDecimals(price: number, szDecimals: number, isSpot: boolean): number;
556
559
 
560
+ type RoundMode = 'floor' | 'round' | 'ceil';
561
+ interface UtcRoundOptions {
562
+ mode?: RoundMode;
563
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
564
+ anchorUtc?: number;
565
+ }
566
+ /**
567
+ * Higher-order UTC rounder.
568
+ * Snaps an instant t to the UTC grid defined by (anchorUtc + k*stepMs).
569
+ * Formula: anchor + step * op((t - anchor)/step)
570
+ */
571
+ declare function makeUtcRounder(stepMs: number, opts?: UtcRoundOptions): (t: Date) => Date;
572
+ declare const floorUtcMinutes: (stepMinutes: number) => (t: Date) => Date;
573
+ declare const floorUtcHour: () => (t: Date) => Date;
574
+ declare const floorUtcDay: () => (t: Date) => Date;
575
+ declare const floorUtcWeek: (weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6) => (t: Date) => Date;
576
+
577
+ declare enum DayOfWeek {
578
+ Sunday = 0,
579
+ Monday = 1,
580
+ Tuesday = 2,
581
+ Wednesday = 3,
582
+ Thursday = 4,
583
+ Friday = 5,
584
+ Saturday = 6
585
+ }
586
+ interface WeekInfo {
587
+ weekNumber: number;
588
+ startDate: Date;
589
+ endDate: Date;
590
+ }
591
+ /**
592
+ * Gets the latest completed week information.
593
+ *
594
+ * @param currentTimestamp - Optional timestamp in milliseconds. If not provided, uses current time.
595
+ * @param offset - Optional number of weeks to offset (0 = latest completed week, 1 = previous week, etc.)
596
+ * @param weekStartsOn - Day of week the week should start on. Defaults to Thursday.
597
+ * @returns WeekInfo with weekNumber, startDate, and endDate
598
+ */
599
+ declare function getLatestCompletedWeek(currentTimestamp?: number, offset?: number, weekStartsOn?: DayOfWeek): WeekInfo;
600
+
557
601
  declare function isHip3Symbol(symbol: string | undefined): boolean;
558
602
  declare function getHip3Dex(symbol: string): string | null;
559
603
  /**
@@ -599,40 +643,4 @@ declare function isStableQuoteToken(coin: string): boolean;
599
643
  declare function getDisplayMarketSymbol(coin: string | undefined, showCollateralTokenSymbol?: boolean, collateralTokenSymbol?: string): string | undefined;
600
644
  declare function getDexFromCollateralTokenSymbol(collateralTokenSymbol: string): string | undefined;
601
645
 
602
- interface PerpsMeta {
603
- collateralToken: number;
604
- /** Trading universes available for perpetual trading. */
605
- universe: PerpsUniverse[];
606
- /** Margin requirement tables for different leverage tiers. */
607
- marginTables: MarginTables;
608
- }
609
- /** Metadata and context for perpetual assets. */
610
- type PerpsMetaAndAssetCtxs = [
611
- /** Metadata for assets. */
612
- PerpsMeta,
613
- /** Context for each perpetual asset. */
614
- PerpsAssetCtx[]
615
- ];
616
- /** Trading universe parameters for perpetual assets. */
617
- interface PerpsUniverse {
618
- /** Minimum decimal places for order sizes. */
619
- szDecimals: number;
620
- /** Name of the universe. */
621
- name: string;
622
- /** Maximum allowed leverage. */
623
- maxLeverage: number;
624
- /** Unique identifier for the margin requirements table. */
625
- marginTableId: number;
626
- /** Indicates if only isolated margin trading is allowed. */
627
- onlyIsolated?: true;
628
- /** Indicates if the universe is delisted. */
629
- isDelisted?: true;
630
- /** Indicates if the universe is in growth mode, eligible for discounted fees */
631
- growthMode?: true;
632
- /** Margin mode for the universe. */
633
- marginMode?: "strictIsolated" | "noCross";
634
- }
635
- type AllPerpsMeta = PerpsMeta[];
636
- declare function getAllPerpsMeta(infoClient: InfoClient): Promise<AllPerpsMeta>;
637
-
638
- export { type AirdropAllocationData, type AllPerpsMeta, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PerpDex, type PerpsMeta, type PerpsMetaAndAssetCtxs, type PerpsUniverse, type PupEligibilityResult, ROOT_DEX, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, type TokenInfo, USDC_SPOT_TOKEN, type UpheavalApiResponse, type UpheavalPosition, type UpheavalSnapshot, UserDexAbstractionTypes, type V3LPTokenInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getAllPerpsMeta, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };
646
+ export { type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, DayOfWeek, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PerpDex, type PupEligibilityResult, ROOT_DEX, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, type TokenInfo, USDC_SPOT_TOKEN, type UpheavalApiResponse, type UpheavalPosition, type UpheavalSnapshot, UserDexAbstractionTypes, type V3LPTokenInfo, type WeekInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getLatestCompletedWeek, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, makeUtcRounder, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { SpotToken, MarginTables, PerpsAssetCtx, SpotMeta, ExchangeClient, SuccessResponse, InfoClient } from '@nktkas/hyperliquid';
2
2
  import { Hex } from '@nktkas/hyperliquid/types';
3
+ export { A as AllPerpsMeta, d as AssetIdUtils, B as BaseInstrument, I as InstrumentClient, M as MarketInstrument, c as PerpsInstrument, P as PerpsMeta, a as PerpsMetaAndAssetCtxs, b as PerpsUniverse, S as SpotInstrument, g as getAllPerpsMeta } from './client-CgmiTuEX.js';
4
+ export { ActiveFlashSalesResponse, AnalyticsOverview, ApiResponse, AppliedDiscount, Banner, BannerResponse, BannerType, BaseEcommerceClient, BaseEntity, CalculateCartDiscountsRequest, CalculateCartDiscountsResponse, CalculateTaxRequest, CalculateTaxResponse, CartItem, ConfirmEscrowDepositResponse, Coupon, CouponResponse, CouponUsage, CreateBannerRequest, CreateCouponRequest, CreateFlashSaleRequest, CreateOrderEventRequest, CreateOrderEventResponse, CreateOrderRequest, CreateOrderResponse, CreateProductRequest, CreateProductVariantRequest, CreateReviewRequest, CreateShippingMethodRequest, CreateTaxNexusRequest, CreateTaxRuleRequest, CustomerEcommerceClient, CustomerMessagesResponse, CustomerSummary, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, EcommerceClientConfig, FlashSale, FlashSaleItem, FlashSaleItemInput, GenerateTaxReportRequest, GetAnalyticsParams, GetAnalyticsResponse, GetCouponResponse, GetOrderResponse, GetProductMetricsResponse, GetProductResponse, GetTaxReportResponse, InventoryAuditAction, InventoryAuditEntry, ListActiveBannersParams, ListActiveFlashSalesParams, ListBannersResponse, ListCouponsResponse, ListCustomersParams, ListCustomersResponse, ListInventoryAuditResponse, ListMediaAssetsResponse, ListMessagesResponse, ListOrdersParams, ListOrdersResponse, ListProductVariantsResponse, ListProductsParams, ListProductsResponse, ListReturnsResponse, ListReviewsParams, ListReviewsResponse, ListShipmentsResponse, ListShippingAddressesResponse, ListShippingMethodsResponse, ListTaxNexusResponse, ListTaxReportsParams, ListTaxReportsResponse, ListTaxRulesResponse, MediaAsset, MediaAssetResponse, Merchant, MerchantEcommerceClient, MerchantProfileRequest, MerchantProfileResponse, MerchantStatus, Message, MessageResponse, MessageStatsResponse, Order, OrderEvent, OrderItem, OrderReceiptResponse, OrderStatus, OrdersByStatus, PaginatedResponse, PaginationParams, Payment, PaymentMethod, PaymentStatus, Product, ProductDimensions, ProductDiscountsResponse, ProductMetrics, ProductResponse, ProductReview, ProductSortBy, ProductVariant, ProductVariantResponse, RecentOrderSummary, RespondToReviewRequest, Return, ReturnItem, ReturnResponse, ReturnStatus, RevenueByDay, ReviewResponse, ReviewSortBy, ReviewStatus, SendMessageRequest, Settlement, Shipment, ShipmentResponse, ShipmentStatus, ShippingAddress, ShippingAddressRequest, ShippingAddressResponse, ShippingMethod, ShippingMethodResponse, 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, UpdateTaxNexusRequest, UpdateTaxReportStatusRequest, UpdateTaxRuleRequest, UpdateTaxSettingsRequest, UserShippingAddress, ValidateDiscountRequest, ValidateDiscountResponse, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress } from './ecommerce.js';
5
+ import 'axios';
3
6
 
4
7
  declare function encodeSlug(slug: string): bigint;
5
8
  declare function decodeSlug(value: bigint): string;
@@ -239,16 +242,16 @@ declare function getNextTierInfo(pupTokenAmount: number, normalizedAirDropAmount
239
242
  declare const USDC_SPOT_TOKEN: SpotToken;
240
243
  declare const TESTNET_USDC_SPOT_TOKEN: SpotToken;
241
244
 
242
- interface PerpsMeta$1 {
245
+ interface PerpsMeta {
243
246
  /** Trading universes available for perpetual trading. */
244
- universe: PerpsUniverse$1[];
247
+ universe: PerpsUniverse[];
245
248
  /** Margin requirement tables for different leverage tiers. */
246
249
  marginTables: MarginTables;
247
250
  /** Collateral token index. */
248
251
  collateralToken?: number;
249
252
  }
250
253
  /** Trading universe parameters for perpetual assets. */
251
- interface PerpsUniverse$1 {
254
+ interface PerpsUniverse {
252
255
  /** Minimum decimal places for order sizes. */
253
256
  szDecimals: number;
254
257
  /** Name of the universe. */
@@ -301,7 +304,7 @@ interface MarketInfo {
301
304
  growthMode: boolean;
302
305
  }
303
306
  interface DexInfo {
304
- meta: PerpsMeta$1;
307
+ meta: PerpsMeta;
305
308
  assetContext: PerpsAssetCtx[];
306
309
  dexFullName: string;
307
310
  dexName: string;
@@ -311,7 +314,7 @@ interface DexInfo {
311
314
  imageUrl?: string;
312
315
  accountName?: string;
313
316
  }
314
- type ExtendedPerpsMeta = PerpsMeta$1 & {
317
+ type ExtendedPerpsMeta = PerpsMeta & {
315
318
  collateralToken?: number;
316
319
  };
317
320
  /**
@@ -461,7 +464,7 @@ declare class MetadataClient {
461
464
  */
462
465
  getRawMetadata(): {
463
466
  spotMeta: SpotMeta | null;
464
- perpsMeta: PerpsMeta$1 | null;
467
+ perpsMeta: PerpsMeta | null;
465
468
  perpDexs: (PerpDex | null)[];
466
469
  hip3DexsMeta: {
467
470
  [k: string]: DexInfo;
@@ -554,6 +557,47 @@ declare const formatSizeForDisplay: ({ sz, szDecimals, }: {
554
557
  */
555
558
  declare function getPriceDecimals(price: number, szDecimals: number, isSpot: boolean): number;
556
559
 
560
+ type RoundMode = 'floor' | 'round' | 'ceil';
561
+ interface UtcRoundOptions {
562
+ mode?: RoundMode;
563
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
564
+ anchorUtc?: number;
565
+ }
566
+ /**
567
+ * Higher-order UTC rounder.
568
+ * Snaps an instant t to the UTC grid defined by (anchorUtc + k*stepMs).
569
+ * Formula: anchor + step * op((t - anchor)/step)
570
+ */
571
+ declare function makeUtcRounder(stepMs: number, opts?: UtcRoundOptions): (t: Date) => Date;
572
+ declare const floorUtcMinutes: (stepMinutes: number) => (t: Date) => Date;
573
+ declare const floorUtcHour: () => (t: Date) => Date;
574
+ declare const floorUtcDay: () => (t: Date) => Date;
575
+ declare const floorUtcWeek: (weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6) => (t: Date) => Date;
576
+
577
+ declare enum DayOfWeek {
578
+ Sunday = 0,
579
+ Monday = 1,
580
+ Tuesday = 2,
581
+ Wednesday = 3,
582
+ Thursday = 4,
583
+ Friday = 5,
584
+ Saturday = 6
585
+ }
586
+ interface WeekInfo {
587
+ weekNumber: number;
588
+ startDate: Date;
589
+ endDate: Date;
590
+ }
591
+ /**
592
+ * Gets the latest completed week information.
593
+ *
594
+ * @param currentTimestamp - Optional timestamp in milliseconds. If not provided, uses current time.
595
+ * @param offset - Optional number of weeks to offset (0 = latest completed week, 1 = previous week, etc.)
596
+ * @param weekStartsOn - Day of week the week should start on. Defaults to Thursday.
597
+ * @returns WeekInfo with weekNumber, startDate, and endDate
598
+ */
599
+ declare function getLatestCompletedWeek(currentTimestamp?: number, offset?: number, weekStartsOn?: DayOfWeek): WeekInfo;
600
+
557
601
  declare function isHip3Symbol(symbol: string | undefined): boolean;
558
602
  declare function getHip3Dex(symbol: string): string | null;
559
603
  /**
@@ -599,40 +643,4 @@ declare function isStableQuoteToken(coin: string): boolean;
599
643
  declare function getDisplayMarketSymbol(coin: string | undefined, showCollateralTokenSymbol?: boolean, collateralTokenSymbol?: string): string | undefined;
600
644
  declare function getDexFromCollateralTokenSymbol(collateralTokenSymbol: string): string | undefined;
601
645
 
602
- interface PerpsMeta {
603
- collateralToken: number;
604
- /** Trading universes available for perpetual trading. */
605
- universe: PerpsUniverse[];
606
- /** Margin requirement tables for different leverage tiers. */
607
- marginTables: MarginTables;
608
- }
609
- /** Metadata and context for perpetual assets. */
610
- type PerpsMetaAndAssetCtxs = [
611
- /** Metadata for assets. */
612
- PerpsMeta,
613
- /** Context for each perpetual asset. */
614
- PerpsAssetCtx[]
615
- ];
616
- /** Trading universe parameters for perpetual assets. */
617
- interface PerpsUniverse {
618
- /** Minimum decimal places for order sizes. */
619
- szDecimals: number;
620
- /** Name of the universe. */
621
- name: string;
622
- /** Maximum allowed leverage. */
623
- maxLeverage: number;
624
- /** Unique identifier for the margin requirements table. */
625
- marginTableId: number;
626
- /** Indicates if only isolated margin trading is allowed. */
627
- onlyIsolated?: true;
628
- /** Indicates if the universe is delisted. */
629
- isDelisted?: true;
630
- /** Indicates if the universe is in growth mode, eligible for discounted fees */
631
- growthMode?: true;
632
- /** Margin mode for the universe. */
633
- marginMode?: "strictIsolated" | "noCross";
634
- }
635
- type AllPerpsMeta = PerpsMeta[];
636
- declare function getAllPerpsMeta(infoClient: InfoClient): Promise<AllPerpsMeta>;
637
-
638
- export { type AirdropAllocationData, type AllPerpsMeta, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PerpDex, type PerpsMeta, type PerpsMetaAndAssetCtxs, type PerpsUniverse, type PupEligibilityResult, ROOT_DEX, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, type TokenInfo, USDC_SPOT_TOKEN, type UpheavalApiResponse, type UpheavalPosition, type UpheavalSnapshot, UserDexAbstractionTypes, type V3LPTokenInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getAllPerpsMeta, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };
646
+ export { type AirdropAllocationData, CloidClientCode, type CloidClientCodeId, CloidClientCodeNameById, type CloidData, DayOfWeek, type DexInfo, type ExtendedPerpsMeta, type MarketInfo, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, type PerpDex, type PupEligibilityResult, ROOT_DEX, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, type TokenInfo, USDC_SPOT_TOKEN, type UpheavalApiResponse, type UpheavalPosition, type UpheavalSnapshot, UserDexAbstractionTypes, type V3LPTokenInfo, type WeekInfo, WidgetType, WidgetTypeById, type WidgetTypeId, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getApprovalAmount, getClientCodeNameById, getCloid, getDexFromCollateralTokenSymbol, getDisplayMarketSymbol, getHip3Dex, getHip3DexAbstraction, getLatestCompletedWeek, getNextTierInfo, getPriceDecimals, getStaticCollateralTokenByDex, getStaticCollateralTokenSymbol, getWidgetTypeById, isBasedCloid, isClientCode, isHip3Symbol, isMiniAppCloid, isMiniAppTriggeredCloid, isSpotSymbol, isStableQuoteToken, isTenantCloid, isTrackingIdCloid, isWidgetType, makeUtcRounder, normaliseSlug, normaliseTrackingId, normalizeAirdropAmount, parseCloid, setHip3DexAbstraction, stableQuoteTokens };