@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
package/dist/index.mjs CHANGED
@@ -1,6 +1,9 @@
1
- import {
2
- __glob
3
- } from "./chunk-4UEJOM6W.mjs";
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
+ export { AssetIdUtils, InstrumentClient } from './chunk-VBC6EQ7Q.mjs';
3
+ import { __glob } from './chunk-4UEJOM6W.mjs';
4
+ import Decimal, { Decimal as Decimal$1 } from 'decimal.js';
5
+ import { HttpTransport, InfoClient } from '@nktkas/hyperliquid';
6
+ import { signL1Action, signUserSignedAction } from '@nktkas/hyperliquid/signing';
4
7
 
5
8
  // lib/cloid/encoder.ts
6
9
  var mask = (bits) => (1n << bits) - 1n;
@@ -286,9 +289,6 @@ function isMiniAppTriggeredCloid(cloidHex) {
286
289
  return cloidData.miniAppTriggered;
287
290
  }
288
291
 
289
- // lib/fee.ts
290
- import Decimal from "decimal.js";
291
-
292
292
  // lib/constants/fee.ts
293
293
  var BASED_FEE_WALLET = "0x1924b8561eeF20e70Ede628A296175D358BE80e5";
294
294
  var BASED_REFERRAL_CODE = "SHIFU";
@@ -449,7 +449,6 @@ function getNextTierInfo(pupTokenAmount, normalizedAirDropAmount, isAirdropRecip
449
449
  else if (currentBoost === XP_BOOST_PERCENTAGES.TIER_2) currentTier = 2;
450
450
  else if (currentBoost === XP_BOOST_PERCENTAGES.TIER_1) currentTier = 1;
451
451
  if (isAirdropRecipient && normalizedAirDropAmount > 0) {
452
- const retentionRatio = pupTokenAmount / normalizedAirDropAmount;
453
452
  if (currentTier === 0) {
454
453
  const threshold = normalizedAirDropAmount * PUP_TOKEN_THRESHOLDS.AIRDROP_35_PERCENT;
455
454
  return {
@@ -546,18 +545,6 @@ var TESTNET_USDC_SPOT_TOKEN = {
546
545
  fullName: null,
547
546
  deployerTradingFeeShare: "0.0"
548
547
  };
549
-
550
- // lib/meta/metadata.ts
551
- import {
552
- HttpTransport,
553
- InfoClient
554
- } from "@nktkas/hyperliquid";
555
-
556
- // lib/hip3/utils.ts
557
- import {
558
- signL1Action,
559
- signUserSignedAction
560
- } from "@nktkas/hyperliquid/signing";
561
548
  function isHip3Symbol(symbol) {
562
549
  if (!symbol) return false;
563
550
  return symbol.includes(":");
@@ -672,26 +659,26 @@ function getDexFromCollateralTokenSymbol(collateralTokenSymbol) {
672
659
 
673
660
  // import("./data/**/*/staticMeta.json") in lib/meta/metadata.ts
674
661
  var globImport_data_staticMeta_json = __glob({
675
- "./data/mainnet/staticMeta.json": () => import("./staticMeta-QV2KMX57.mjs"),
676
- "./data/testnet/staticMeta.json": () => import("./staticMeta-GM7T3OYL.mjs")
662
+ "./data/mainnet/staticMeta.json": () => import('./staticMeta-QV2KMX57.mjs'),
663
+ "./data/testnet/staticMeta.json": () => import('./staticMeta-GM7T3OYL.mjs')
677
664
  });
678
665
 
679
666
  // import("./data/**/*/spotMeta.json") in lib/meta/metadata.ts
680
667
  var globImport_data_spotMeta_json = __glob({
681
- "./data/mainnet/spotMeta.json": () => import("./spotMeta-OD7S6HGW.mjs"),
682
- "./data/testnet/spotMeta.json": () => import("./spotMeta-PCN4Z4R3.mjs")
668
+ "./data/mainnet/spotMeta.json": () => import('./spotMeta-GHXX7C5M.mjs'),
669
+ "./data/testnet/spotMeta.json": () => import('./spotMeta-IBBUP2SG.mjs')
683
670
  });
684
671
 
685
672
  // import("./data/**/*/meta.json") in lib/meta/metadata.ts
686
673
  var globImport_data_meta_json = __glob({
687
- "./data/mainnet/meta.json": () => import("./meta-UOGUG3OW.mjs"),
688
- "./data/testnet/meta.json": () => import("./meta-FVJIMALT.mjs")
674
+ "./data/mainnet/meta.json": () => import('./meta-UOGUG3OW.mjs'),
675
+ "./data/testnet/meta.json": () => import('./meta-JB5ITE27.mjs')
689
676
  });
690
677
 
691
678
  // import("./data/**/*/perpDexs.json") in lib/meta/metadata.ts
692
679
  var globImport_data_perpDexs_json = __glob({
693
- "./data/mainnet/perpDexs.json": () => import("./perpDexs-GGL32HT4.mjs"),
694
- "./data/testnet/perpDexs.json": () => import("./perpDexs-G7V2QIM6.mjs")
680
+ "./data/mainnet/perpDexs.json": () => import('./perpDexs-3LRJ5ZHM.mjs'),
681
+ "./data/testnet/perpDexs.json": () => import('./perpDexs-4ISLD7NX.mjs')
695
682
  });
696
683
 
697
684
  // lib/meta/metadata.ts
@@ -1197,9 +1184,6 @@ var MetadataClient = class {
1197
1184
  };
1198
1185
  }
1199
1186
  };
1200
-
1201
- // lib/utils/formatter.ts
1202
- import { Decimal as Decimal2 } from "decimal.js";
1203
1187
  var formatPriceAndSize = ({
1204
1188
  px,
1205
1189
  sz,
@@ -1207,8 +1191,8 @@ var formatPriceAndSize = ({
1207
1191
  isSpot
1208
1192
  }) => {
1209
1193
  const priceDecimals = getPriceDecimals(px, szDecimals, isSpot);
1210
- const price = new Decimal2(px).toDP(priceDecimals).toNumber();
1211
- const size = new Decimal2(sz).toDP(szDecimals, Decimal2.ROUND_DOWN).toNumber();
1194
+ const price = new Decimal$1(px).toDP(priceDecimals).toNumber();
1195
+ const size = new Decimal$1(sz).toDP(szDecimals, Decimal$1.ROUND_DOWN).toNumber();
1212
1196
  return {
1213
1197
  price,
1214
1198
  size
@@ -1220,7 +1204,7 @@ var formatPriceForOrder = ({
1220
1204
  isSpot
1221
1205
  }) => {
1222
1206
  const priceDecimals = getPriceDecimals(px, szDecimals, isSpot);
1223
- const price = new Decimal2(px).toDP(priceDecimals).toNumber();
1207
+ const price = new Decimal$1(px).toDP(priceDecimals).toNumber();
1224
1208
  return price;
1225
1209
  };
1226
1210
  var formatPriceForDisplay = ({
@@ -1239,7 +1223,7 @@ var formatSizeForOrder = ({
1239
1223
  sz,
1240
1224
  szDecimals
1241
1225
  }) => {
1242
- return new Decimal2(sz).toDP(szDecimals, Decimal2.ROUND_DOWN).toNumber();
1226
+ return new Decimal$1(sz).toDP(szDecimals, Decimal$1.ROUND_DOWN).toNumber();
1243
1227
  };
1244
1228
  var formatSizeForDisplay = ({
1245
1229
  sz,
@@ -1266,65 +1250,59 @@ function getPriceDecimals(price, szDecimals, isSpot) {
1266
1250
  return minDecimals;
1267
1251
  }
1268
1252
 
1253
+ // lib/utils/flooredDateTime.ts
1254
+ var MIN = 6e4;
1255
+ var HOUR = 60 * MIN;
1256
+ var DAY = 24 * HOUR;
1257
+ var WEEK = 7 * DAY;
1258
+ var opOf = (m) => m === "ceil" ? Math.ceil : m === "round" ? Math.round : Math.floor;
1259
+ function makeUtcRounder(stepMs, opts = {}) {
1260
+ const mode = opts.mode ?? "floor";
1261
+ const op = opOf(mode);
1262
+ let anchorUtc = opts.anchorUtc ?? 0;
1263
+ if (stepMs % WEEK === 0 && opts.weekStartsOn !== void 0) {
1264
+ const sundayUTC = Date.UTC(1970, 0, 4);
1265
+ anchorUtc = sundayUTC + opts.weekStartsOn * DAY;
1266
+ }
1267
+ return (t) => {
1268
+ const ts = t.getTime();
1269
+ const snapped = op((ts - anchorUtc) / stepMs) * stepMs + anchorUtc;
1270
+ return new Date(snapped);
1271
+ };
1272
+ }
1273
+ var floorUtcMinutes = (stepMinutes) => makeUtcRounder(stepMinutes * MIN, { mode: "floor" });
1274
+ var floorUtcHour = () => makeUtcRounder(HOUR, { mode: "floor" });
1275
+ var floorUtcDay = () => makeUtcRounder(DAY, { mode: "floor" });
1276
+ var floorUtcWeek = (weekStartsOn = 1) => makeUtcRounder(WEEK, { mode: "floor", weekStartsOn });
1277
+
1278
+ // lib/utils/time.ts
1279
+ var DayOfWeek = /* @__PURE__ */ ((DayOfWeek2) => {
1280
+ DayOfWeek2[DayOfWeek2["Sunday"] = 0] = "Sunday";
1281
+ DayOfWeek2[DayOfWeek2["Monday"] = 1] = "Monday";
1282
+ DayOfWeek2[DayOfWeek2["Tuesday"] = 2] = "Tuesday";
1283
+ DayOfWeek2[DayOfWeek2["Wednesday"] = 3] = "Wednesday";
1284
+ DayOfWeek2[DayOfWeek2["Thursday"] = 4] = "Thursday";
1285
+ DayOfWeek2[DayOfWeek2["Friday"] = 5] = "Friday";
1286
+ DayOfWeek2[DayOfWeek2["Saturday"] = 6] = "Saturday";
1287
+ return DayOfWeek2;
1288
+ })(DayOfWeek || {});
1289
+ var WEEK_IN_MS = 7 * 24 * 60 * 60 * 1e3;
1290
+ function getLatestCompletedWeek(currentTimestamp, offset = 0, weekStartsOn = 4 /* Thursday */) {
1291
+ const now = new Date(currentTimestamp ?? Date.now());
1292
+ const floorToWeekStart = floorUtcWeek(weekStartsOn);
1293
+ const endDate = new Date(floorToWeekStart(now).getTime() - offset * WEEK_IN_MS);
1294
+ const startDate = new Date(endDate.getTime() - WEEK_IN_MS);
1295
+ const week1StartDate = new Date(process.env.WEEK1_START_DATE || "2025-12-04T00:00:00Z");
1296
+ const msSinceWeek1 = startDate.getTime() - week1StartDate.getTime();
1297
+ const weekNumber = Math.round(msSinceWeek1 / WEEK_IN_MS) + 1;
1298
+ return { weekNumber, startDate, endDate };
1299
+ }
1300
+
1269
1301
  // lib/hip3/market-info.ts
1270
1302
  async function getAllPerpsMeta(infoClient) {
1271
1303
  return infoClient.transport.request("info", {
1272
1304
  type: "allPerpMetas"
1273
1305
  });
1274
1306
  }
1275
- export {
1276
- CloidClientCode,
1277
- CloidClientCodeNameById,
1278
- MetadataClient,
1279
- PUP_TOKEN_ADDRESS,
1280
- PUP_TOKEN_THRESHOLDS,
1281
- ROOT_DEX,
1282
- TARGET_APPROVED_MAX_BUILDER_FEE,
1283
- TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT,
1284
- TESTNET_USDC_SPOT_TOKEN,
1285
- USDC_SPOT_TOKEN,
1286
- UserDexAbstractionTypes,
1287
- WidgetType,
1288
- WidgetTypeById,
1289
- XP_BOOST_PERCENTAGES,
1290
- buildCloid,
1291
- calculateBoostPercentage,
1292
- calculateTotalPupAmount,
1293
- decodeSlug,
1294
- enableHip3DexAbstractionWithAgent,
1295
- encodeSlug,
1296
- formatPriceAndSize,
1297
- formatPriceForDisplay,
1298
- formatPriceForOrder,
1299
- formatSizeForDisplay,
1300
- formatSizeForOrder,
1301
- getAllPerpsMeta,
1302
- getApprovalAmount,
1303
- getClientCodeNameById,
1304
- getCloid,
1305
- getDexFromCollateralTokenSymbol,
1306
- getDisplayMarketSymbol,
1307
- getHip3Dex,
1308
- getHip3DexAbstraction,
1309
- getNextTierInfo,
1310
- getPriceDecimals,
1311
- getStaticCollateralTokenByDex,
1312
- getStaticCollateralTokenSymbol,
1313
- getWidgetTypeById,
1314
- isBasedCloid,
1315
- isClientCode,
1316
- isHip3Symbol,
1317
- isMiniAppCloid,
1318
- isMiniAppTriggeredCloid,
1319
- isSpotSymbol,
1320
- isStableQuoteToken,
1321
- isTenantCloid,
1322
- isTrackingIdCloid,
1323
- isWidgetType,
1324
- normaliseSlug,
1325
- normaliseTrackingId,
1326
- normalizeAirdropAmount,
1327
- parseCloid,
1328
- setHip3DexAbstraction,
1329
- stableQuoteTokens
1330
- };
1307
+
1308
+ export { CloidClientCode, CloidClientCodeNameById, DayOfWeek, MetadataClient, PUP_TOKEN_ADDRESS, PUP_TOKEN_THRESHOLDS, ROOT_DEX, TARGET_APPROVED_MAX_BUILDER_FEE, TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT, TESTNET_USDC_SPOT_TOKEN, USDC_SPOT_TOKEN, UserDexAbstractionTypes, WidgetType, WidgetTypeById, XP_BOOST_PERCENTAGES, buildCloid, calculateBoostPercentage, calculateTotalPupAmount, decodeSlug, enableHip3DexAbstractionWithAgent, encodeSlug, floorUtcDay, floorUtcHour, floorUtcMinutes, floorUtcWeek, formatPriceAndSize, formatPriceForDisplay, formatPriceForOrder, formatSizeForDisplay, formatSizeForOrder, getAllPerpsMeta, 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 };
@@ -1,4 +1,4 @@
1
- import "./chunk-4UEJOM6W.mjs";
1
+ import './chunk-4UEJOM6W.mjs';
2
2
 
3
3
  // lib/meta/data/testnet/meta.json
4
4
  var universe = [
@@ -507,9 +507,7 @@ var universe = [
507
507
  szDecimals: 0,
508
508
  name: "WIF",
509
509
  maxLeverage: 5,
510
- marginTableId: 5,
511
- onlyIsolated: true,
512
- marginMode: "strictIsolated"
510
+ marginTableId: 5
513
511
  },
514
512
  {
515
513
  szDecimals: 1,
@@ -1388,9 +1386,5 @@ var meta_default = {
1388
1386
  marginTables,
1389
1387
  collateralToken
1390
1388
  };
1391
- export {
1392
- collateralToken,
1393
- meta_default as default,
1394
- marginTables,
1395
- universe
1396
- };
1389
+
1390
+ export { collateralToken, meta_default as default, marginTables, universe };
@@ -1,4 +1,4 @@
1
- import "./chunk-4UEJOM6W.mjs";
1
+ import './chunk-4UEJOM6W.mjs';
2
2
 
3
3
  // lib/meta/data/mainnet/meta.json
4
4
  var universe = [
@@ -1500,9 +1500,5 @@ var meta_default = {
1500
1500
  marginTables,
1501
1501
  collateralToken
1502
1502
  };
1503
- export {
1504
- collateralToken,
1505
- meta_default as default,
1506
- marginTables,
1507
- universe
1508
- };
1503
+
1504
+ export { collateralToken, meta_default as default, marginTables, universe };
@@ -1,4 +1,4 @@
1
- import "./chunk-4UEJOM6W.mjs";
1
+ import './chunk-4UEJOM6W.mjs';
2
2
 
3
3
  // lib/meta/data/mainnet/perpDexs.json
4
4
  var perpDexs_default = [
@@ -76,7 +76,8 @@ var perpDexs_default = [
76
76
  ]
77
77
  ],
78
78
  deployerFeeScale: "1.0",
79
- lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00"
79
+ lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00",
80
+ assetToFundingMultiplier: []
80
81
  },
81
82
  {
82
83
  name: "flx",
@@ -170,7 +171,21 @@ var perpDexs_default = [
170
171
  ]
171
172
  ],
172
173
  deployerFeeScale: "1.0",
173
- lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00"
174
+ lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00",
175
+ assetToFundingMultiplier: [
176
+ [
177
+ "flx:COIN",
178
+ "0.0396816138"
179
+ ],
180
+ [
181
+ "flx:CRCL",
182
+ "0.6849327969"
183
+ ],
184
+ [
185
+ "flx:TSLA",
186
+ "0.055534957"
187
+ ]
188
+ ]
174
189
  },
175
190
  {
176
191
  name: "vntl",
@@ -220,7 +235,21 @@ var perpDexs_default = [
220
235
  ]
221
236
  ],
222
237
  deployerFeeScale: "1.0",
223
- lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00"
238
+ lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00",
239
+ assetToFundingMultiplier: [
240
+ [
241
+ "vntl:ANTHROPIC",
242
+ "0.0053054031"
243
+ ],
244
+ [
245
+ "vntl:OPENAI",
246
+ "0.0050794237"
247
+ ],
248
+ [
249
+ "vntl:SPACEX",
250
+ "0.010663783"
251
+ ]
252
+ ]
224
253
  },
225
254
  {
226
255
  name: "hyna",
@@ -251,9 +280,9 @@ var perpDexs_default = [
251
280
  ]
252
281
  ],
253
282
  deployerFeeScale: "1.0",
254
- lastDeployerFeeScaleChangeTime: "2025-12-03T10:32:09.252520621"
283
+ lastDeployerFeeScaleChangeTime: "2025-12-03T10:32:09.252520621",
284
+ assetToFundingMultiplier: []
255
285
  }
256
286
  ];
257
- export {
258
- perpDexs_default as default
259
- };
287
+
288
+ export { perpDexs_default as default };