@basedone/core 0.1.10 → 0.2.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.
Files changed (53) hide show
  1. package/dist/chunk-4GAKANLT.mjs +1987 -0
  2. package/dist/chunk-4UEJOM6W.mjs +1 -3
  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 +3732 -0
  7. package/dist/ecommerce.d.ts +3732 -0
  8. package/dist/ecommerce.js +2031 -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 +2691 -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/QUICK_REFERENCE.md +211 -0
  29. package/lib/ecommerce/README.md +385 -0
  30. package/lib/ecommerce/USAGE_EXAMPLES.md +704 -0
  31. package/lib/ecommerce/client/base.ts +272 -0
  32. package/lib/ecommerce/client/customer.ts +522 -0
  33. package/lib/ecommerce/client/merchant.ts +1341 -0
  34. package/lib/ecommerce/index.ts +51 -0
  35. package/lib/ecommerce/types/entities.ts +722 -0
  36. package/lib/ecommerce/types/enums.ts +270 -0
  37. package/lib/ecommerce/types/index.ts +18 -0
  38. package/lib/ecommerce/types/requests.ts +525 -0
  39. package/lib/ecommerce/types/responses.ts +805 -0
  40. package/lib/ecommerce/utils/errors.ts +113 -0
  41. package/lib/ecommerce/utils/helpers.ts +131 -0
  42. package/lib/hip3/market-info.ts +1 -1
  43. package/lib/instrument/client.ts +351 -0
  44. package/lib/meta/data/mainnet/perpDexs.json +34 -4
  45. package/lib/meta/data/mainnet/spotMeta.json +21 -3
  46. package/lib/meta/data/testnet/meta.json +1 -3
  47. package/lib/meta/data/testnet/perpDexs.json +174 -28
  48. package/lib/meta/data/testnet/spotMeta.json +51 -0
  49. package/lib/react/InstrumentProvider.tsx +69 -0
  50. package/lib/utils/flooredDateTime.ts +55 -0
  51. package/lib/utils/time.ts +51 -0
  52. package/package.json +37 -11
  53. package/react.ts +1 -0
package/dist/index.js CHANGED
@@ -1,4 +1,15 @@
1
- "use strict";
1
+ 'use strict';
2
+
3
+ var Decimal = require('decimal.js');
4
+ var hyperliquid = require('@nktkas/hyperliquid');
5
+ var signing = require('@nktkas/hyperliquid/signing');
6
+ var axios = require('axios');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var Decimal__default = /*#__PURE__*/_interopDefault(Decimal);
11
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
12
+
2
13
  var __create = Object.create;
3
14
  var __defProp = Object.defineProperty;
4
15
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -13,10 +24,6 @@ var __glob = (map) => (path) => {
13
24
  var __commonJS = (cb, mod) => function __require() {
14
25
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
26
  };
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
27
  var __copyProps = (to, from, except, desc) => {
21
28
  if (from && typeof from === "object" || typeof from === "function") {
22
29
  for (let key of __getOwnPropNames(from))
@@ -30,15 +37,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
37
  // file that has been converted to a CommonJS file using a Babel-
31
38
  // compatible transform (i.e. "__esModule" has not been set), then set
32
39
  // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
41
  mod
35
42
  ));
36
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
43
 
38
44
  // lib/meta/data/mainnet/staticMeta.json
39
45
  var require_staticMeta = __commonJS({
40
- "lib/meta/data/mainnet/staticMeta.json"(exports2, module2) {
41
- module2.exports = {
46
+ "lib/meta/data/mainnet/staticMeta.json"(exports$1, module) {
47
+ module.exports = {
42
48
  coins: {
43
49
  "xyz:XYZ100": {
44
50
  imageUrl: "https://app.based.one/hip3/xyz/xyz100.webp",
@@ -58,8 +64,8 @@ var require_staticMeta = __commonJS({
58
64
 
59
65
  // lib/meta/data/testnet/staticMeta.json
60
66
  var require_staticMeta2 = __commonJS({
61
- "lib/meta/data/testnet/staticMeta.json"(exports2, module2) {
62
- module2.exports = {
67
+ "lib/meta/data/testnet/staticMeta.json"(exports$1, module) {
68
+ module.exports = {
63
69
  coins: {
64
70
  "rrrrr:BTC": {
65
71
  displayName: "BTCe"
@@ -77,8 +83,8 @@ var require_staticMeta2 = __commonJS({
77
83
 
78
84
  // lib/meta/data/mainnet/spotMeta.json
79
85
  var require_spotMeta = __commonJS({
80
- "lib/meta/data/mainnet/spotMeta.json"(exports2, module2) {
81
- module2.exports = {
86
+ "lib/meta/data/mainnet/spotMeta.json"(exports$1, module) {
87
+ module.exports = {
82
88
  universe: [
83
89
  {
84
90
  tokens: [
@@ -2257,6 +2263,15 @@ var require_spotMeta = __commonJS({
2257
2263
  name: "@257",
2258
2264
  index: 257,
2259
2265
  isCanonical: false
2266
+ },
2267
+ {
2268
+ tokens: [
2269
+ 398,
2270
+ 0
2271
+ ],
2272
+ name: "@258",
2273
+ index: 258,
2274
+ isCanonical: false
2260
2275
  }
2261
2276
  ],
2262
2277
  tokens: [
@@ -2267,7 +2282,10 @@ var require_spotMeta = __commonJS({
2267
2282
  index: 0,
2268
2283
  tokenId: "0x6d1e7cde53ba9467b783cb7c530ce054",
2269
2284
  isCanonical: true,
2270
- evmContract: null,
2285
+ evmContract: {
2286
+ address: "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24",
2287
+ evm_extra_wei_decimals: -2
2288
+ },
2271
2289
  fullName: null,
2272
2290
  deployerTradingFeeShare: "0.0"
2273
2291
  },
@@ -6761,7 +6779,10 @@ var require_spotMeta = __commonJS({
6761
6779
  index: 381,
6762
6780
  tokenId: "0xbd6af8c18f3e56d2da95a3c81d18e814",
6763
6781
  isCanonical: false,
6764
- evmContract: null,
6782
+ evmContract: {
6783
+ address: "0x99603f5cb890faca5cc5495ccc74391cdffa28bc",
6784
+ evm_extra_wei_decimals: 10
6785
+ },
6765
6786
  fullName: "Funnel BNB",
6766
6787
  deployerTradingFeeShare: "1.0"
6767
6788
  },
@@ -6960,7 +6981,10 @@ var require_spotMeta = __commonJS({
6960
6981
  index: 398,
6961
6982
  tokenId: "0xec43194f64d555bdaef5afb5b6c6c686",
6962
6983
  isCanonical: false,
6963
- evmContract: null,
6984
+ evmContract: {
6985
+ address: "0xa51dc81944a15623874981181a99d6c56b20ed56",
6986
+ evm_extra_wei_decimals: 11
6987
+ },
6964
6988
  fullName: "Stable",
6965
6989
  deployerTradingFeeShare: "1.0"
6966
6990
  },
@@ -7026,8 +7050,8 @@ var require_spotMeta = __commonJS({
7026
7050
 
7027
7051
  // lib/meta/data/testnet/spotMeta.json
7028
7052
  var require_spotMeta2 = __commonJS({
7029
- "lib/meta/data/testnet/spotMeta.json"(exports2, module2) {
7030
- module2.exports = {
7053
+ "lib/meta/data/testnet/spotMeta.json"(exports$1, module) {
7054
+ module.exports = {
7031
7055
  universe: [
7032
7056
  {
7033
7057
  tokens: [
@@ -17675,6 +17699,24 @@ var require_spotMeta2 = __commonJS({
17675
17699
  name: "@1378",
17676
17700
  index: 1378,
17677
17701
  isCanonical: false
17702
+ },
17703
+ {
17704
+ tokens: [
17705
+ 1498,
17706
+ 0
17707
+ ],
17708
+ name: "@1379",
17709
+ index: 1379,
17710
+ isCanonical: false
17711
+ },
17712
+ {
17713
+ tokens: [
17714
+ 1498,
17715
+ 1452
17716
+ ],
17717
+ name: "@1380",
17718
+ index: 1380,
17719
+ isCanonical: false
17678
17720
  }
17679
17721
  ],
17680
17722
  tokens: [
@@ -34558,6 +34600,39 @@ aa aaa\\aaaaaa"aaaa'aaaaa{}`,
34558
34600
  evmContract: null,
34559
34601
  fullName: "$WASH launchpad 2025-12-02T20:17:18.214Z",
34560
34602
  deployerTradingFeeShare: "1.0"
34603
+ },
34604
+ {
34605
+ name: "RNSZPK",
34606
+ szDecimals: 0,
34607
+ weiDecimals: 10,
34608
+ index: 1496,
34609
+ tokenId: "0x699de51e4fc0e6d7a6e450d2c3d92a1a",
34610
+ isCanonical: false,
34611
+ evmContract: null,
34612
+ fullName: "$WASH launchpad 2025-12-04T03:17:21.132Z",
34613
+ deployerTradingFeeShare: "1.0"
34614
+ },
34615
+ {
34616
+ name: "VENAHX",
34617
+ szDecimals: 1,
34618
+ weiDecimals: 9,
34619
+ index: 1497,
34620
+ tokenId: "0x43513901b952fcb6d8d5697ce17fa58f",
34621
+ isCanonical: false,
34622
+ evmContract: null,
34623
+ fullName: "$WASH launchpad 2025-12-05T10:17:24.096Z",
34624
+ deployerTradingFeeShare: "1.0"
34625
+ },
34626
+ {
34627
+ name: "LMB",
34628
+ szDecimals: 2,
34629
+ weiDecimals: 8,
34630
+ index: 1498,
34631
+ tokenId: "0x9f416264220c915ec41b6c4c0b11fab1",
34632
+ isCanonical: false,
34633
+ evmContract: null,
34634
+ fullName: "LMB",
34635
+ deployerTradingFeeShare: "1.0"
34561
34636
  }
34562
34637
  ]
34563
34638
  };
@@ -34566,8 +34641,8 @@ aa aaa\\aaaaaa"aaaa'aaaaa{}`,
34566
34641
 
34567
34642
  // lib/meta/data/mainnet/meta.json
34568
34643
  var require_meta = __commonJS({
34569
- "lib/meta/data/mainnet/meta.json"(exports2, module2) {
34570
- module2.exports = {
34644
+ "lib/meta/data/mainnet/meta.json"(exports$1, module) {
34645
+ module.exports = {
34571
34646
  universe: [
34572
34647
  {
34573
34648
  szDecimals: 5,
@@ -36068,8 +36143,8 @@ var require_meta = __commonJS({
36068
36143
 
36069
36144
  // lib/meta/data/testnet/meta.json
36070
36145
  var require_meta2 = __commonJS({
36071
- "lib/meta/data/testnet/meta.json"(exports2, module2) {
36072
- module2.exports = {
36146
+ "lib/meta/data/testnet/meta.json"(exports$1, module) {
36147
+ module.exports = {
36073
36148
  universe: [
36074
36149
  {
36075
36150
  szDecimals: 2,
@@ -36576,9 +36651,7 @@ var require_meta2 = __commonJS({
36576
36651
  szDecimals: 0,
36577
36652
  name: "WIF",
36578
36653
  maxLeverage: 5,
36579
- marginTableId: 5,
36580
- onlyIsolated: true,
36581
- marginMode: "strictIsolated"
36654
+ marginTableId: 5
36582
36655
  },
36583
36656
  {
36584
36657
  szDecimals: 1,
@@ -37458,8 +37531,8 @@ var require_meta2 = __commonJS({
37458
37531
 
37459
37532
  // lib/meta/data/mainnet/perpDexs.json
37460
37533
  var require_perpDexs = __commonJS({
37461
- "lib/meta/data/mainnet/perpDexs.json"(exports2, module2) {
37462
- module2.exports = [
37534
+ "lib/meta/data/mainnet/perpDexs.json"(exports$1, module) {
37535
+ module.exports = [
37463
37536
  null,
37464
37537
  {
37465
37538
  name: "xyz",
@@ -37534,7 +37607,8 @@ var require_perpDexs = __commonJS({
37534
37607
  ]
37535
37608
  ],
37536
37609
  deployerFeeScale: "1.0",
37537
- lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00"
37610
+ lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00",
37611
+ assetToFundingMultiplier: []
37538
37612
  },
37539
37613
  {
37540
37614
  name: "flx",
@@ -37628,7 +37702,21 @@ var require_perpDexs = __commonJS({
37628
37702
  ]
37629
37703
  ],
37630
37704
  deployerFeeScale: "1.0",
37631
- lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00"
37705
+ lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00",
37706
+ assetToFundingMultiplier: [
37707
+ [
37708
+ "flx:COIN",
37709
+ "0.0396816138"
37710
+ ],
37711
+ [
37712
+ "flx:CRCL",
37713
+ "0.6849327969"
37714
+ ],
37715
+ [
37716
+ "flx:TSLA",
37717
+ "0.055534957"
37718
+ ]
37719
+ ]
37632
37720
  },
37633
37721
  {
37634
37722
  name: "vntl",
@@ -37678,7 +37766,21 @@ var require_perpDexs = __commonJS({
37678
37766
  ]
37679
37767
  ],
37680
37768
  deployerFeeScale: "1.0",
37681
- lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00"
37769
+ lastDeployerFeeScaleChangeTime: "1970-01-01T00:00:00",
37770
+ assetToFundingMultiplier: [
37771
+ [
37772
+ "vntl:ANTHROPIC",
37773
+ "0.0053054031"
37774
+ ],
37775
+ [
37776
+ "vntl:OPENAI",
37777
+ "0.0050794237"
37778
+ ],
37779
+ [
37780
+ "vntl:SPACEX",
37781
+ "0.010663783"
37782
+ ]
37783
+ ]
37682
37784
  },
37683
37785
  {
37684
37786
  name: "hyna",
@@ -37709,7 +37811,8 @@ var require_perpDexs = __commonJS({
37709
37811
  ]
37710
37812
  ],
37711
37813
  deployerFeeScale: "1.0",
37712
- lastDeployerFeeScaleChangeTime: "2025-12-03T10:32:09.252520621"
37814
+ lastDeployerFeeScaleChangeTime: "2025-12-03T10:32:09.252520621",
37815
+ assetToFundingMultiplier: []
37713
37816
  }
37714
37817
  ];
37715
37818
  }
@@ -37717,8 +37820,8 @@ var require_perpDexs = __commonJS({
37717
37820
 
37718
37821
  // lib/meta/data/testnet/perpDexs.json
37719
37822
  var require_perpDexs2 = __commonJS({
37720
- "lib/meta/data/testnet/perpDexs.json"(exports2, module2) {
37721
- module2.exports = [
37823
+ "lib/meta/data/testnet/perpDexs.json"(exports$1, module) {
37824
+ module.exports = [
37722
37825
  null,
37723
37826
  {
37724
37827
  name: "test",
@@ -38011,6 +38114,12 @@ var require_perpDexs2 = __commonJS({
38011
38114
  feeRecipient: "0x40008f23a17a1ba9a6f25723a4d06bcd81c33426",
38012
38115
  assetToStreamingOiCap: [],
38013
38116
  subDeployers: [
38117
+ [
38118
+ "registerAsset",
38119
+ [
38120
+ "0xb26126e39214f9594802b59515f409479e202f3a"
38121
+ ]
38122
+ ],
38014
38123
  [
38015
38124
  "setOracle",
38016
38125
  [
@@ -38166,79 +38275,79 @@ var require_perpDexs2 = __commonJS({
38166
38275
  assetToFundingMultiplier: [
38167
38276
  [
38168
38277
  "vntls:vANDRL",
38169
- "0.0020000002"
38278
+ "0.005000002"
38170
38279
  ],
38171
38280
  [
38172
38281
  "vntls:vANTHRPC",
38173
- "0.0025507473"
38282
+ "0.0171374751"
38174
38283
  ],
38175
38284
  [
38176
38285
  "vntls:vBYTED",
38177
- "0.0024785789"
38286
+ "0.0148191144"
38178
38287
  ],
38179
38288
  [
38180
38289
  "vntls:vCHAIN",
38181
- "0.002"
38290
+ "0.005"
38182
38291
  ],
38183
38292
  [
38184
38293
  "vntls:vCLUELY",
38185
- "0.01"
38294
+ "2.0"
38186
38295
  ],
38187
38296
  [
38188
38297
  "vntls:vCOLOSSAL",
38189
- "0.01"
38298
+ "2.0"
38190
38299
  ],
38191
38300
  [
38192
38301
  "vntls:vCURSOR",
38193
- "0.01"
38302
+ "2.0"
38194
38303
  ],
38195
38304
  [
38196
38305
  "vntls:vDBRICKS",
38197
- "0.002004205"
38306
+ "0.0050534663"
38198
38307
  ],
38199
38308
  [
38200
38309
  "vntls:vFIG",
38201
- "0.01"
38310
+ "2.0"
38202
38311
  ],
38203
38312
  [
38204
38313
  "vntls:vFIGAI",
38205
- "0.0020037172"
38314
+ "0.0050472398"
38206
38315
  ],
38207
38316
  [
38208
38317
  "vntls:vKRAKEN",
38209
- "0.01"
38318
+ "0.005"
38210
38319
  ],
38211
38320
  [
38212
38321
  "vntls:vNLINK",
38213
- "0.01"
38322
+ "2.0"
38214
38323
  ],
38215
38324
  [
38216
38325
  "vntls:vOAI",
38217
- "0.01"
38326
+ "2.0"
38218
38327
  ],
38219
38328
  [
38220
38329
  "vntls:vPERPLXT",
38221
- "0.002539593"
38330
+ "0.0167613111"
38222
38331
  ],
38223
38332
  [
38224
38333
  "vntls:vPOLY",
38225
- "0.01"
38334
+ "2.0"
38226
38335
  ],
38227
38336
  [
38228
38337
  "vntls:vRAMP",
38229
- "0.0020037948"
38338
+ "0.0050482304"
38230
38339
  ],
38231
38340
  [
38232
38341
  "vntls:vSPACEX",
38233
- "0.0020003078"
38342
+ "0.0050030981"
38234
38343
  ],
38235
38344
  [
38236
38345
  "vntls:vSTRIPE",
38237
- "0.01"
38346
+ "2.0"
38238
38347
  ],
38239
38348
  [
38240
38349
  "vntls:vXAI",
38241
- "0.01"
38350
+ "2.0"
38242
38351
  ]
38243
38352
  ]
38244
38353
  },
@@ -39261,6 +39370,7 @@ var require_perpDexs2 = __commonJS({
39261
39370
  [
39262
39371
  "setOracle",
39263
39372
  [
39373
+ "0x897ee1987787a2cd302ea9d729e5c46ccd302afe",
39264
39374
  "0xa67b36947149a7f2312bffc9d1c859bf12029986"
39265
39375
  ]
39266
39376
  ]
@@ -39845,7 +39955,24 @@ var require_perpDexs2 = __commonJS({
39845
39955
  deployer: "0x2e3ee3705913258c9a0ecb643571045343d77e1b",
39846
39956
  oracleUpdater: "0xec6c68168d9fd51bb078acc74722aeff14db220b",
39847
39957
  feeRecipient: null,
39848
- assetToStreamingOiCap: [],
39958
+ assetToStreamingOiCap: [
39959
+ [
39960
+ "trve:CRZD",
39961
+ "3000000.0"
39962
+ ],
39963
+ [
39964
+ "trve:CS2",
39965
+ "3000000.0"
39966
+ ],
39967
+ [
39968
+ "trve:F1LN",
39969
+ "3000000.0"
39970
+ ],
39971
+ [
39972
+ "trve:PMRT",
39973
+ "3000000.0"
39974
+ ]
39975
+ ],
39849
39976
  subDeployers: [
39850
39977
  [
39851
39978
  "setOracle",
@@ -39888,7 +40015,16 @@ var require_perpDexs2 = __commonJS({
39888
40015
  deployer: "0xb38a498cc3f358899a5a7ad67608271b679a4167",
39889
40016
  oracleUpdater: "0xec6c68168d9fd51bb078acc74722aeff14db220b",
39890
40017
  feeRecipient: null,
39891
- assetToStreamingOiCap: [],
40018
+ assetToStreamingOiCap: [
40019
+ [
40020
+ "trv:POKE",
40021
+ "3000000.0"
40022
+ ],
40023
+ [
40024
+ "trv:ZARD",
40025
+ "3000000.0"
40026
+ ]
40027
+ ],
39892
40028
  subDeployers: [
39893
40029
  [
39894
40030
  "setOracle",
@@ -40199,7 +40335,16 @@ var require_perpDexs2 = __commonJS({
40199
40335
  deployer: "0x9b4989cb2735a1ac906cd99648fe3d84ef4b4d2d",
40200
40336
  oracleUpdater: "0xec6c68168d9fd51bb078acc74722aeff14db220b",
40201
40337
  feeRecipient: null,
40202
- assetToStreamingOiCap: [],
40338
+ assetToStreamingOiCap: [
40339
+ [
40340
+ "trov:NDTO",
40341
+ "3000000.0"
40342
+ ],
40343
+ [
40344
+ "trov:NTDO",
40345
+ "3000000.0"
40346
+ ]
40347
+ ],
40203
40348
  subDeployers: [
40204
40349
  [
40205
40350
  "setOracle",
@@ -40321,7 +40466,16 @@ var require_perpDexs2 = __commonJS({
40321
40466
  deployer: "0xfe770a17e47717b2e43504cf8f00ced96cf00979",
40322
40467
  oracleUpdater: "0xec6c68168d9fd51bb078acc74722aeff14db220b",
40323
40468
  feeRecipient: null,
40324
- assetToStreamingOiCap: [],
40469
+ assetToStreamingOiCap: [
40470
+ [
40471
+ "trvv:BIRKN",
40472
+ "3000000.0"
40473
+ ],
40474
+ [
40475
+ "trvv:WATCH",
40476
+ "3000000.0"
40477
+ ]
40478
+ ],
40325
40479
  subDeployers: [
40326
40480
  [
40327
40481
  "setOracle",
@@ -40340,7 +40494,16 @@ var require_perpDexs2 = __commonJS({
40340
40494
  deployer: "0xaaf21c1d7e7da1604c85d3ea93268e91902ba41e",
40341
40495
  oracleUpdater: "0xec6c68168d9fd51bb078acc74722aeff14db220b",
40342
40496
  feeRecipient: null,
40343
- assetToStreamingOiCap: [],
40497
+ assetToStreamingOiCap: [
40498
+ [
40499
+ "trvo:BIRKN",
40500
+ "3000000.0"
40501
+ ],
40502
+ [
40503
+ "trvo:WATCH",
40504
+ "3000000.0"
40505
+ ]
40506
+ ],
40344
40507
  subDeployers: [
40345
40508
  [
40346
40509
  "setOracle",
@@ -40359,7 +40522,20 @@ var require_perpDexs2 = __commonJS({
40359
40522
  deployer: "0x27f9d24b907b86bce4d2cf1299248421391aa444",
40360
40523
  oracleUpdater: "0xec6c68168d9fd51bb078acc74722aeff14db220b",
40361
40524
  feeRecipient: null,
40362
- assetToStreamingOiCap: [],
40525
+ assetToStreamingOiCap: [
40526
+ [
40527
+ "tvr:HRMES",
40528
+ "3000000.0"
40529
+ ],
40530
+ [
40531
+ "tvr:LVMH",
40532
+ "3000000.0"
40533
+ ],
40534
+ [
40535
+ "tvr:RCHMT",
40536
+ "3000000.0"
40537
+ ]
40538
+ ],
40363
40539
  subDeployers: [
40364
40540
  [
40365
40541
  "setOracle",
@@ -40378,7 +40554,20 @@ var require_perpDexs2 = __commonJS({
40378
40554
  deployer: "0x2be16138a3ea12e09b38dae749f49accc735fded",
40379
40555
  oracleUpdater: "0xec6c68168d9fd51bb078acc74722aeff14db220b",
40380
40556
  feeRecipient: null,
40381
- assetToStreamingOiCap: [],
40557
+ assetToStreamingOiCap: [
40558
+ [
40559
+ "torv:BRBY",
40560
+ "3000000.0"
40561
+ ],
40562
+ [
40563
+ "torv:KRING",
40564
+ "3000000.0"
40565
+ ],
40566
+ [
40567
+ "torv:PRADA",
40568
+ "3000000.0"
40569
+ ]
40570
+ ],
40382
40571
  subDeployers: [
40383
40572
  [
40384
40573
  "setOracle",
@@ -40397,7 +40586,20 @@ var require_perpDexs2 = __commonJS({
40397
40586
  deployer: "0x5f120e2aed50caf06e89ece2de71c9f5d30bb866",
40398
40587
  oracleUpdater: "0xec6c68168d9fd51bb078acc74722aeff14db220b",
40399
40588
  feeRecipient: null,
40400
- assetToStreamingOiCap: [],
40589
+ assetToStreamingOiCap: [
40590
+ [
40591
+ "tvro:CRPI",
40592
+ "3000000.0"
40593
+ ],
40594
+ [
40595
+ "tvro:GOOS",
40596
+ "3000000.0"
40597
+ ],
40598
+ [
40599
+ "tvro:MONC",
40600
+ "3000000.0"
40601
+ ]
40602
+ ],
40401
40603
  subDeployers: [
40402
40604
  [
40403
40605
  "setOracle",
@@ -40416,7 +40618,16 @@ var require_perpDexs2 = __commonJS({
40416
40618
  deployer: "0xab8b0324d63cb39728f8c7502ff3b1a905ae8b0d",
40417
40619
  oracleUpdater: "0xec6c68168d9fd51bb078acc74722aeff14db220b",
40418
40620
  feeRecipient: null,
40419
- assetToStreamingOiCap: [],
40621
+ assetToStreamingOiCap: [
40622
+ [
40623
+ "tvor:CPRI",
40624
+ "3000000.0"
40625
+ ],
40626
+ [
40627
+ "tvor:TPR",
40628
+ "3000000.0"
40629
+ ]
40630
+ ],
40420
40631
  subDeployers: [
40421
40632
  [
40422
40633
  "setOracle",
@@ -40540,71 +40751,49 @@ var require_perpDexs2 = __commonJS({
40540
40751
  deployerFeeScale: "1.0",
40541
40752
  lastDeployerFeeScaleChangeTime: "2025-12-02T11:35:58.687904841",
40542
40753
  assetToFundingMultiplier: []
40754
+ },
40755
+ {
40756
+ name: "wa",
40757
+ fullName: "wa:GDR Test DEX",
40758
+ deployer: "0x47515db2eab01758c740ab220352a34b8d5a3826",
40759
+ oracleUpdater: "0x47515db2eab01758c740ab220352a34b8d5a3826",
40760
+ feeRecipient: null,
40761
+ assetToStreamingOiCap: [],
40762
+ subDeployers: [
40763
+ [
40764
+ "setOracle",
40765
+ [
40766
+ "0x47515db2eab01758c740ab220352a34b8d5a3826"
40767
+ ]
40768
+ ]
40769
+ ],
40770
+ deployerFeeScale: "1.0",
40771
+ lastDeployerFeeScaleChangeTime: "2025-12-03T11:35:21.991486494",
40772
+ assetToFundingMultiplier: []
40773
+ },
40774
+ {
40775
+ name: "org",
40776
+ fullName: "org dex",
40777
+ deployer: "0xf5e2c3905c402ea494e71248c6c75338b9098cf6",
40778
+ oracleUpdater: "0xf5e2c3905c402ea494e71248c6c75338b9098cf6",
40779
+ feeRecipient: null,
40780
+ assetToStreamingOiCap: [],
40781
+ subDeployers: [
40782
+ [
40783
+ "setOracle",
40784
+ [
40785
+ "0xf5e2c3905c402ea494e71248c6c75338b9098cf6"
40786
+ ]
40787
+ ]
40788
+ ],
40789
+ deployerFeeScale: "1.0",
40790
+ lastDeployerFeeScaleChangeTime: "2025-12-05T11:15:20.928371793",
40791
+ assetToFundingMultiplier: []
40543
40792
  }
40544
40793
  ];
40545
40794
  }
40546
40795
  });
40547
40796
 
40548
- // index.ts
40549
- var index_exports = {};
40550
- __export(index_exports, {
40551
- CloidClientCode: () => CloidClientCode,
40552
- CloidClientCodeNameById: () => CloidClientCodeNameById,
40553
- MetadataClient: () => MetadataClient,
40554
- PUP_TOKEN_ADDRESS: () => PUP_TOKEN_ADDRESS,
40555
- PUP_TOKEN_THRESHOLDS: () => PUP_TOKEN_THRESHOLDS,
40556
- ROOT_DEX: () => ROOT_DEX,
40557
- TARGET_APPROVED_MAX_BUILDER_FEE: () => TARGET_APPROVED_MAX_BUILDER_FEE,
40558
- TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT: () => TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT,
40559
- TESTNET_USDC_SPOT_TOKEN: () => TESTNET_USDC_SPOT_TOKEN,
40560
- USDC_SPOT_TOKEN: () => USDC_SPOT_TOKEN,
40561
- UserDexAbstractionTypes: () => UserDexAbstractionTypes,
40562
- WidgetType: () => WidgetType,
40563
- WidgetTypeById: () => WidgetTypeById,
40564
- XP_BOOST_PERCENTAGES: () => XP_BOOST_PERCENTAGES,
40565
- buildCloid: () => buildCloid,
40566
- calculateBoostPercentage: () => calculateBoostPercentage,
40567
- calculateTotalPupAmount: () => calculateTotalPupAmount,
40568
- decodeSlug: () => decodeSlug,
40569
- enableHip3DexAbstractionWithAgent: () => enableHip3DexAbstractionWithAgent,
40570
- encodeSlug: () => encodeSlug,
40571
- formatPriceAndSize: () => formatPriceAndSize,
40572
- formatPriceForDisplay: () => formatPriceForDisplay,
40573
- formatPriceForOrder: () => formatPriceForOrder,
40574
- formatSizeForDisplay: () => formatSizeForDisplay,
40575
- formatSizeForOrder: () => formatSizeForOrder,
40576
- getAllPerpsMeta: () => getAllPerpsMeta,
40577
- getApprovalAmount: () => getApprovalAmount,
40578
- getClientCodeNameById: () => getClientCodeNameById,
40579
- getCloid: () => getCloid,
40580
- getDexFromCollateralTokenSymbol: () => getDexFromCollateralTokenSymbol,
40581
- getDisplayMarketSymbol: () => getDisplayMarketSymbol,
40582
- getHip3Dex: () => getHip3Dex,
40583
- getHip3DexAbstraction: () => getHip3DexAbstraction,
40584
- getNextTierInfo: () => getNextTierInfo,
40585
- getPriceDecimals: () => getPriceDecimals,
40586
- getStaticCollateralTokenByDex: () => getStaticCollateralTokenByDex,
40587
- getStaticCollateralTokenSymbol: () => getStaticCollateralTokenSymbol,
40588
- getWidgetTypeById: () => getWidgetTypeById,
40589
- isBasedCloid: () => isBasedCloid,
40590
- isClientCode: () => isClientCode,
40591
- isHip3Symbol: () => isHip3Symbol,
40592
- isMiniAppCloid: () => isMiniAppCloid,
40593
- isMiniAppTriggeredCloid: () => isMiniAppTriggeredCloid,
40594
- isSpotSymbol: () => isSpotSymbol,
40595
- isStableQuoteToken: () => isStableQuoteToken,
40596
- isTenantCloid: () => isTenantCloid,
40597
- isTrackingIdCloid: () => isTrackingIdCloid,
40598
- isWidgetType: () => isWidgetType,
40599
- normaliseSlug: () => normaliseSlug,
40600
- normaliseTrackingId: () => normaliseTrackingId,
40601
- normalizeAirdropAmount: () => normalizeAirdropAmount,
40602
- parseCloid: () => parseCloid,
40603
- setHip3DexAbstraction: () => setHip3DexAbstraction,
40604
- stableQuoteTokens: () => stableQuoteTokens
40605
- });
40606
- module.exports = __toCommonJS(index_exports);
40607
-
40608
40797
  // lib/cloid/encoder.ts
40609
40798
  var mask = (bits) => (1n << bits) - 1n;
40610
40799
  function getEncodingLength(nbits, alphabet) {
@@ -40889,9 +41078,6 @@ function isMiniAppTriggeredCloid(cloidHex) {
40889
41078
  return cloidData.miniAppTriggered;
40890
41079
  }
40891
41080
 
40892
- // lib/fee.ts
40893
- var import_decimal = __toESM(require("decimal.js"));
40894
-
40895
41081
  // lib/constants/fee.ts
40896
41082
  var BASED_FEE_WALLET = "0x1924b8561eeF20e70Ede628A296175D358BE80e5";
40897
41083
  var BASED_REFERRAL_CODE = "SHIFU";
@@ -40914,12 +41100,12 @@ var getApprovalAmount = ({
40914
41100
  console.warn("Fee discount is not between 0 and 1, setting to 0");
40915
41101
  feeDiscount = 0;
40916
41102
  }
40917
- const discountMultiplier = feeDiscount ? new import_decimal.default(1).sub(feeDiscount) : 1;
41103
+ const discountMultiplier = feeDiscount ? new Decimal__default.default(1).sub(feeDiscount) : 1;
40918
41104
  if (!customFeeEnabled) {
40919
41105
  return {
40920
- approvalAmount: new import_decimal.default(TARGET_APPROVED_MAX_BUILDER_FEE).mul(discountMultiplier).floor().toNumber(),
40921
- perpFee: new import_decimal.default(TARGET_FUTURES_BUILDER_FEE).mul(discountMultiplier).floor().toNumber(),
40922
- spotFee: new import_decimal.default(TARGET_SPOT_BUILDER_FEE).mul(discountMultiplier).floor().toNumber(),
41106
+ approvalAmount: new Decimal__default.default(TARGET_APPROVED_MAX_BUILDER_FEE).mul(discountMultiplier).floor().toNumber(),
41107
+ perpFee: new Decimal__default.default(TARGET_FUTURES_BUILDER_FEE).mul(discountMultiplier).floor().toNumber(),
41108
+ spotFee: new Decimal__default.default(TARGET_SPOT_BUILDER_FEE).mul(discountMultiplier).floor().toNumber(),
40923
41109
  approvalPercent: TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT,
40924
41110
  builder: BASED_FEE_WALLET,
40925
41111
  referralCode: BASED_REFERRAL_CODE
@@ -40929,7 +41115,7 @@ var getApprovalAmount = ({
40929
41115
  if (validatedPerpFeePct === void 0) {
40930
41116
  validatedPerpFeePct = TARGET_FUTURES_BUILDER_FEE / 1e3;
40931
41117
  }
40932
- validatedPerpFeePct = new import_decimal.default(validatedPerpFeePct).mul(discountMultiplier).toNumber();
41118
+ validatedPerpFeePct = new Decimal__default.default(validatedPerpFeePct).mul(discountMultiplier).toNumber();
40933
41119
  if (validatedPerpFeePct > 0 && validatedPerpFeePct < 1e-3) {
40934
41120
  console.warn("Perp fee is less than 0.001%, setting to 0.001%");
40935
41121
  validatedPerpFeePct = 1e-3;
@@ -40946,7 +41132,7 @@ var getApprovalAmount = ({
40946
41132
  if (validatedSpotFeePct === void 0) {
40947
41133
  validatedSpotFeePct = TARGET_SPOT_BUILDER_FEE / 1e3;
40948
41134
  }
40949
- validatedSpotFeePct = new import_decimal.default(validatedSpotFeePct).mul(discountMultiplier).toNumber();
41135
+ validatedSpotFeePct = new Decimal__default.default(validatedSpotFeePct).mul(discountMultiplier).toNumber();
40950
41136
  if (validatedSpotFeePct > 0 && validatedSpotFeePct < 0.025) {
40951
41137
  console.warn("Spot fee is less than 0.025%, setting to 0.025%");
40952
41138
  validatedSpotFeePct = 0.025;
@@ -41052,7 +41238,6 @@ function getNextTierInfo(pupTokenAmount, normalizedAirDropAmount, isAirdropRecip
41052
41238
  else if (currentBoost === XP_BOOST_PERCENTAGES.TIER_2) currentTier = 2;
41053
41239
  else if (currentBoost === XP_BOOST_PERCENTAGES.TIER_1) currentTier = 1;
41054
41240
  if (isAirdropRecipient && normalizedAirDropAmount > 0) {
41055
- const retentionRatio = pupTokenAmount / normalizedAirDropAmount;
41056
41241
  if (currentTier === 0) {
41057
41242
  const threshold = normalizedAirDropAmount * PUP_TOKEN_THRESHOLDS.AIRDROP_35_PERCENT;
41058
41243
  return {
@@ -41149,12 +41334,6 @@ var TESTNET_USDC_SPOT_TOKEN = {
41149
41334
  fullName: null,
41150
41335
  deployerTradingFeeShare: "0.0"
41151
41336
  };
41152
-
41153
- // lib/meta/metadata.ts
41154
- var import_hyperliquid = require("@nktkas/hyperliquid");
41155
-
41156
- // lib/hip3/utils.ts
41157
- var import_signing = require("@nktkas/hyperliquid/signing");
41158
41337
  function isHip3Symbol(symbol) {
41159
41338
  if (!symbol) return false;
41160
41339
  return symbol.includes(":");
@@ -41168,7 +41347,7 @@ async function enableHip3DexAbstractionWithAgent(client) {
41168
41347
  const action = {
41169
41348
  type: "agentEnableDexAbstraction"
41170
41349
  };
41171
- const signature = await (0, import_signing.signL1Action)({
41350
+ const signature = await signing.signL1Action({
41172
41351
  wallet: client.wallet,
41173
41352
  action,
41174
41353
  isTestnet: client.isTestnet,
@@ -41199,7 +41378,7 @@ async function setHip3DexAbstraction(client, enabled, user) {
41199
41378
  enabled,
41200
41379
  nonce
41201
41380
  };
41202
- const signature = await (0, import_signing.signUserSignedAction)({
41381
+ const signature = await signing.signUserSignedAction({
41203
41382
  wallet: client.wallet,
41204
41383
  action,
41205
41384
  types: UserDexAbstractionTypes
@@ -41319,10 +41498,10 @@ var MetadataClient = class {
41319
41498
  // Lazy init flag
41320
41499
  this.initialized = false;
41321
41500
  this.initializing = null;
41322
- const transport = new import_hyperliquid.HttpTransport({
41501
+ const transport = new hyperliquid.HttpTransport({
41323
41502
  isTestnet: config.isTestnet ?? false
41324
41503
  });
41325
- this.infoClient = new import_hyperliquid.InfoClient({ transport });
41504
+ this.infoClient = new hyperliquid.InfoClient({ transport });
41326
41505
  this.config = {
41327
41506
  ...config,
41328
41507
  hip3Dexs: config.hip3Dexs?.filter((dex) => dex !== ROOT_DEX),
@@ -41794,9 +41973,6 @@ var MetadataClient = class {
41794
41973
  };
41795
41974
  }
41796
41975
  };
41797
-
41798
- // lib/utils/formatter.ts
41799
- var import_decimal2 = require("decimal.js");
41800
41976
  var formatPriceAndSize = ({
41801
41977
  px,
41802
41978
  sz,
@@ -41804,8 +41980,8 @@ var formatPriceAndSize = ({
41804
41980
  isSpot
41805
41981
  }) => {
41806
41982
  const priceDecimals = getPriceDecimals(px, szDecimals, isSpot);
41807
- const price = new import_decimal2.Decimal(px).toDP(priceDecimals).toNumber();
41808
- const size = new import_decimal2.Decimal(sz).toDP(szDecimals, import_decimal2.Decimal.ROUND_DOWN).toNumber();
41983
+ const price = new Decimal.Decimal(px).toDP(priceDecimals).toNumber();
41984
+ const size = new Decimal.Decimal(sz).toDP(szDecimals, Decimal.Decimal.ROUND_DOWN).toNumber();
41809
41985
  return {
41810
41986
  price,
41811
41987
  size
@@ -41817,7 +41993,7 @@ var formatPriceForOrder = ({
41817
41993
  isSpot
41818
41994
  }) => {
41819
41995
  const priceDecimals = getPriceDecimals(px, szDecimals, isSpot);
41820
- const price = new import_decimal2.Decimal(px).toDP(priceDecimals).toNumber();
41996
+ const price = new Decimal.Decimal(px).toDP(priceDecimals).toNumber();
41821
41997
  return price;
41822
41998
  };
41823
41999
  var formatPriceForDisplay = ({
@@ -41836,7 +42012,7 @@ var formatSizeForOrder = ({
41836
42012
  sz,
41837
42013
  szDecimals
41838
42014
  }) => {
41839
- return new import_decimal2.Decimal(sz).toDP(szDecimals, import_decimal2.Decimal.ROUND_DOWN).toNumber();
42015
+ return new Decimal.Decimal(sz).toDP(szDecimals, Decimal.Decimal.ROUND_DOWN).toNumber();
41840
42016
  };
41841
42017
  var formatSizeForDisplay = ({
41842
42018
  sz,
@@ -41863,66 +42039,2376 @@ function getPriceDecimals(price, szDecimals, isSpot) {
41863
42039
  return minDecimals;
41864
42040
  }
41865
42041
 
42042
+ // lib/utils/flooredDateTime.ts
42043
+ var MIN = 6e4;
42044
+ var HOUR = 60 * MIN;
42045
+ var DAY = 24 * HOUR;
42046
+ var WEEK = 7 * DAY;
42047
+ var opOf = (m) => m === "ceil" ? Math.ceil : m === "round" ? Math.round : Math.floor;
42048
+ function makeUtcRounder(stepMs, opts = {}) {
42049
+ const mode = opts.mode ?? "floor";
42050
+ const op = opOf(mode);
42051
+ let anchorUtc = opts.anchorUtc ?? 0;
42052
+ if (stepMs % WEEK === 0 && opts.weekStartsOn !== void 0) {
42053
+ const sundayUTC = Date.UTC(1970, 0, 4);
42054
+ anchorUtc = sundayUTC + opts.weekStartsOn * DAY;
42055
+ }
42056
+ return (t) => {
42057
+ const ts = t.getTime();
42058
+ const snapped = op((ts - anchorUtc) / stepMs) * stepMs + anchorUtc;
42059
+ return new Date(snapped);
42060
+ };
42061
+ }
42062
+ var floorUtcMinutes = (stepMinutes) => makeUtcRounder(stepMinutes * MIN, { mode: "floor" });
42063
+ var floorUtcHour = () => makeUtcRounder(HOUR, { mode: "floor" });
42064
+ var floorUtcDay = () => makeUtcRounder(DAY, { mode: "floor" });
42065
+ var floorUtcWeek = (weekStartsOn = 1) => makeUtcRounder(WEEK, { mode: "floor", weekStartsOn });
42066
+
42067
+ // lib/utils/time.ts
42068
+ var DayOfWeek = /* @__PURE__ */ ((DayOfWeek2) => {
42069
+ DayOfWeek2[DayOfWeek2["Sunday"] = 0] = "Sunday";
42070
+ DayOfWeek2[DayOfWeek2["Monday"] = 1] = "Monday";
42071
+ DayOfWeek2[DayOfWeek2["Tuesday"] = 2] = "Tuesday";
42072
+ DayOfWeek2[DayOfWeek2["Wednesday"] = 3] = "Wednesday";
42073
+ DayOfWeek2[DayOfWeek2["Thursday"] = 4] = "Thursday";
42074
+ DayOfWeek2[DayOfWeek2["Friday"] = 5] = "Friday";
42075
+ DayOfWeek2[DayOfWeek2["Saturday"] = 6] = "Saturday";
42076
+ return DayOfWeek2;
42077
+ })(DayOfWeek || {});
42078
+ var WEEK_IN_MS = 7 * 24 * 60 * 60 * 1e3;
42079
+ function getLatestCompletedWeek(currentTimestamp, offset = 0, weekStartsOn = 4 /* Thursday */) {
42080
+ const now = new Date(currentTimestamp ?? Date.now());
42081
+ const floorToWeekStart = floorUtcWeek(weekStartsOn);
42082
+ const endDate = new Date(floorToWeekStart(now).getTime() - offset * WEEK_IN_MS);
42083
+ const startDate = new Date(endDate.getTime() - WEEK_IN_MS);
42084
+ const week1StartDate = new Date(process.env.WEEK1_START_DATE || "2025-12-04T00:00:00Z");
42085
+ const msSinceWeek1 = startDate.getTime() - week1StartDate.getTime();
42086
+ const weekNumber = Math.round(msSinceWeek1 / WEEK_IN_MS) + 1;
42087
+ return { weekNumber, startDate, endDate };
42088
+ }
42089
+
41866
42090
  // lib/hip3/market-info.ts
41867
42091
  async function getAllPerpsMeta(infoClient) {
41868
42092
  return infoClient.transport.request("info", {
41869
42093
  type: "allPerpMetas"
41870
42094
  });
41871
42095
  }
41872
- // Annotate the CommonJS export names for ESM import in node:
41873
- 0 && (module.exports = {
41874
- CloidClientCode,
41875
- CloidClientCodeNameById,
41876
- MetadataClient,
41877
- PUP_TOKEN_ADDRESS,
41878
- PUP_TOKEN_THRESHOLDS,
41879
- ROOT_DEX,
41880
- TARGET_APPROVED_MAX_BUILDER_FEE,
41881
- TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT,
41882
- TESTNET_USDC_SPOT_TOKEN,
41883
- USDC_SPOT_TOKEN,
41884
- UserDexAbstractionTypes,
41885
- WidgetType,
41886
- WidgetTypeById,
41887
- XP_BOOST_PERCENTAGES,
41888
- buildCloid,
41889
- calculateBoostPercentage,
41890
- calculateTotalPupAmount,
41891
- decodeSlug,
41892
- enableHip3DexAbstractionWithAgent,
41893
- encodeSlug,
41894
- formatPriceAndSize,
41895
- formatPriceForDisplay,
41896
- formatPriceForOrder,
41897
- formatSizeForDisplay,
41898
- formatSizeForOrder,
41899
- getAllPerpsMeta,
41900
- getApprovalAmount,
41901
- getClientCodeNameById,
41902
- getCloid,
41903
- getDexFromCollateralTokenSymbol,
41904
- getDisplayMarketSymbol,
41905
- getHip3Dex,
41906
- getHip3DexAbstraction,
41907
- getNextTierInfo,
41908
- getPriceDecimals,
41909
- getStaticCollateralTokenByDex,
41910
- getStaticCollateralTokenSymbol,
41911
- getWidgetTypeById,
41912
- isBasedCloid,
41913
- isClientCode,
41914
- isHip3Symbol,
41915
- isMiniAppCloid,
41916
- isMiniAppTriggeredCloid,
41917
- isSpotSymbol,
41918
- isStableQuoteToken,
41919
- isTenantCloid,
41920
- isTrackingIdCloid,
41921
- isWidgetType,
41922
- normaliseSlug,
41923
- normaliseTrackingId,
41924
- normalizeAirdropAmount,
41925
- parseCloid,
41926
- setHip3DexAbstraction,
41927
- stableQuoteTokens
41928
- });
42096
+
42097
+ // lib/instrument/client.ts
42098
+ var AssetIdUtils = {
42099
+ /**
42100
+ * Calculate perp asset ID
42101
+ * - Root dex: assetIndex (0, 1, 2, ...)
42102
+ * - HIP3 dex: 100000 + dexIndex * 10000 + assetIndex
42103
+ */
42104
+ calcPerpAssetId(dexIndex, assetIndex) {
42105
+ if (dexIndex === 0) return assetIndex;
42106
+ return 1e5 + dexIndex * 1e4 + assetIndex;
42107
+ },
42108
+ /**
42109
+ * Calculate spot asset ID: 10000 + pairIndex
42110
+ */
42111
+ calcSpotAssetId(pairIndex) {
42112
+ return 1e4 + pairIndex;
42113
+ },
42114
+ /**
42115
+ * Check if symbol is HIP3 format (contains ":")
42116
+ */
42117
+ isHip3Symbol(symbol) {
42118
+ return symbol?.includes(":") ?? false;
42119
+ },
42120
+ /**
42121
+ * Extract dex name from HIP3 symbol (e.g., "xyz:MSTR" -> "xyz")
42122
+ */
42123
+ extractDexName(symbol) {
42124
+ if (!this.isHip3Symbol(symbol)) return void 0;
42125
+ return symbol.split(":")[0];
42126
+ }
42127
+ };
42128
+ var InstrumentClient = class {
42129
+ constructor(spotMeta, allPerpsMeta) {
42130
+ this.spotMeta = spotMeta;
42131
+ this.allPerpsMeta = allPerpsMeta;
42132
+ this.instruments = [];
42133
+ // O(1) lookup maps for efficient retrieval
42134
+ this.instrumentsBySymbol = /* @__PURE__ */ new Map();
42135
+ this.instrumentsByCoin = /* @__PURE__ */ new Map();
42136
+ this.instrumentsByAssetId = /* @__PURE__ */ new Map();
42137
+ // Additional spot lookups (base token -> instrument)
42138
+ this.spotByBaseToken = /* @__PURE__ */ new Map();
42139
+ // Dex metadata map (dex name -> PerpsMeta)
42140
+ // Key: "" for root dex, dex name for HIP3 (e.g., "xyz")
42141
+ this.dexMetaMap = /* @__PURE__ */ new Map();
42142
+ // Token index lookup for spot
42143
+ this.spotTokensByIndex = /* @__PURE__ */ new Map();
42144
+ }
42145
+ /**
42146
+ * Initialize the client by processing meta into instruments.
42147
+ * Call this after construction to populate the instrument registry.
42148
+ * @returns this for chaining
42149
+ */
42150
+ init() {
42151
+ if (!this.spotMeta || !this.allPerpsMeta) {
42152
+ throw new Error("SpotMeta and allPerpsMeta are required");
42153
+ }
42154
+ this.indexSpotTokens();
42155
+ this.processPerpsInstruments();
42156
+ this.processSpotInstruments();
42157
+ return this;
42158
+ }
42159
+ // ===== Perps Meta Accessors =====
42160
+ getAllPerpsMeta() {
42161
+ return this.allPerpsMeta;
42162
+ }
42163
+ /**
42164
+ * Get PerpsMeta for a specific dex
42165
+ * @param dex - Dex name ("" for root dex, or HIP3 dex name)
42166
+ */
42167
+ getPerpDex(dex) {
42168
+ return this.dexMetaMap.get(dex);
42169
+ }
42170
+ /**
42171
+ * Get PerpsMeta by dex index in allPerpsMeta array
42172
+ */
42173
+ getPerpDexByIndex(index) {
42174
+ return this.allPerpsMeta[index];
42175
+ }
42176
+ // ===== Instrument Accessors =====
42177
+ /**
42178
+ * Get all instruments
42179
+ */
42180
+ getAllInstruments() {
42181
+ return this.instruments;
42182
+ }
42183
+ /**
42184
+ * Get all perps instruments
42185
+ */
42186
+ getPerpsInstruments() {
42187
+ return this.instruments.filter(
42188
+ (i) => i.type === "futures"
42189
+ );
42190
+ }
42191
+ getHip3Instruments() {
42192
+ return this.instruments.filter(
42193
+ (i) => i.type === "futures" && !!i.dex
42194
+ );
42195
+ }
42196
+ /**
42197
+ * Get all spot instruments
42198
+ */
42199
+ getSpotInstruments() {
42200
+ return this.instruments.filter(
42201
+ (i) => i.type === "spot"
42202
+ );
42203
+ }
42204
+ /**
42205
+ * Get instrument by symbol or coin (tries both)
42206
+ * @param coinOrSymbol - Symbol (e.g., "BTC", "BTC/USDC") or coin (e.g., "@107")
42207
+ */
42208
+ getInstrument(coinOrSymbol) {
42209
+ return this.instrumentsByCoin.get(coinOrSymbol) ?? this.instrumentsBySymbol.get(coinOrSymbol);
42210
+ }
42211
+ /**
42212
+ * Get instrument by display symbol
42213
+ * @param symbol - Display symbol (e.g., "BTC", "BTC/USDC", "xyz:MSTR")
42214
+ */
42215
+ getInstrumentBySymbol(symbol) {
42216
+ return this.instrumentsBySymbol.get(symbol);
42217
+ }
42218
+ /**
42219
+ * Get instrument by Hyperliquid API coin format
42220
+ * @param coin - API coin name (e.g., "BTC", "@107", "xyz:MSTR")
42221
+ */
42222
+ getInstrumentByCoin(coin) {
42223
+ return this.instrumentsByCoin.get(coin);
42224
+ }
42225
+ /**
42226
+ * Get instrument by asset ID
42227
+ * @param assetId - Numeric asset ID (e.g., 1 for perps, 10001 for spot)
42228
+ */
42229
+ getInstrumentByAssetId(assetId) {
42230
+ return this.instrumentsByAssetId.get(assetId);
42231
+ }
42232
+ /**
42233
+ * Get spot instrument by base token symbol
42234
+ * @param baseSymbol - Base token symbol (e.g., "HYPE" to find "HYPE/USDC")
42235
+ */
42236
+ getSpotInstrumentByBaseToken(baseSymbol) {
42237
+ return this.spotByBaseToken.get(baseSymbol);
42238
+ }
42239
+ /** Search instruments by symbol, coin, or assetId */
42240
+ searchInstruments(query, type) {
42241
+ return this.instruments.filter((i) => {
42242
+ if (type && i.type !== type) return false;
42243
+ return i.symbol.toLowerCase().includes(query.toLowerCase()) || i.coin.toLowerCase().includes(query.toLowerCase());
42244
+ });
42245
+ }
42246
+ /**
42247
+ * Get spot token by index
42248
+ */
42249
+ getSpotToken(index) {
42250
+ return this.spotTokensByIndex.get(index);
42251
+ }
42252
+ // ===== Internal Processing =====
42253
+ indexSpotTokens() {
42254
+ for (const token of this.spotMeta.tokens) {
42255
+ this.spotTokensByIndex.set(token.index, token);
42256
+ }
42257
+ }
42258
+ processPerpsInstruments() {
42259
+ for (let dexIndex = 0; dexIndex < this.allPerpsMeta.length; dexIndex++) {
42260
+ const perpMeta = this.allPerpsMeta[dexIndex];
42261
+ const dexName = this.extractDexNameFromMeta(perpMeta, dexIndex);
42262
+ this.dexMetaMap.set(dexName, perpMeta);
42263
+ const collateralToken = this.spotTokensByIndex.get(
42264
+ perpMeta.collateralToken
42265
+ );
42266
+ const collateralTokenSymbol = collateralToken?.name ?? "USDC";
42267
+ for (let assetIndex = 0; assetIndex < perpMeta.universe.length; assetIndex++) {
42268
+ const info = perpMeta.universe[assetIndex];
42269
+ const assetId = AssetIdUtils.calcPerpAssetId(dexIndex, assetIndex);
42270
+ const instrument = {
42271
+ assetId,
42272
+ symbol: info.name,
42273
+ coin: info.name,
42274
+ szDecimals: info.szDecimals,
42275
+ leverage: info.maxLeverage,
42276
+ collateralTokenSymbol,
42277
+ type: "futures",
42278
+ isDelisted: info.isDelisted,
42279
+ dex: AssetIdUtils.extractDexName(info.name),
42280
+ collateralTokenIndex: perpMeta.collateralToken
42281
+ };
42282
+ this.addInstrument(instrument);
42283
+ }
42284
+ }
42285
+ }
42286
+ processSpotInstruments() {
42287
+ const seenSymbols = /* @__PURE__ */ new Set();
42288
+ for (const pair of this.spotMeta.universe) {
42289
+ const [baseTokenIndex, quoteTokenIndex] = pair.tokens;
42290
+ const baseToken = this.spotTokensByIndex.get(baseTokenIndex);
42291
+ const quoteToken = this.spotTokensByIndex.get(quoteTokenIndex);
42292
+ if (!baseToken || !quoteToken) continue;
42293
+ const symbol = `${baseToken.name}/${quoteToken.name}`;
42294
+ if (seenSymbols.has(symbol)) continue;
42295
+ seenSymbols.add(symbol);
42296
+ const assetId = AssetIdUtils.calcSpotAssetId(pair.index);
42297
+ const instrument = {
42298
+ assetId,
42299
+ symbol,
42300
+ coin: pair.name,
42301
+ // e.g., "@107"
42302
+ szDecimals: baseToken.szDecimals,
42303
+ type: "spot",
42304
+ baseToken,
42305
+ quoteToken
42306
+ };
42307
+ this.addInstrument(instrument);
42308
+ if (!this.spotByBaseToken.has(baseToken.name)) {
42309
+ this.spotByBaseToken.set(baseToken.name, instrument);
42310
+ }
42311
+ }
42312
+ }
42313
+ addInstrument(instrument) {
42314
+ this.instruments.push(instrument);
42315
+ this.instrumentsBySymbol.set(instrument.symbol, instrument);
42316
+ this.instrumentsByCoin.set(instrument.coin, instrument);
42317
+ this.instrumentsByAssetId.set(instrument.assetId, instrument);
42318
+ }
42319
+ /**
42320
+ * Extract dex name from PerpsMeta
42321
+ * Root dex (index 0) returns "", HIP3 dexes return the dex name (e.g., "xyz")
42322
+ */
42323
+ extractDexNameFromMeta(perpMeta, dexIndex) {
42324
+ if (dexIndex === 0) return "";
42325
+ const firstAsset = perpMeta.universe[0];
42326
+ if (!firstAsset) return "";
42327
+ return AssetIdUtils.extractDexName(firstAsset.name) ?? "";
42328
+ }
42329
+ };
42330
+
42331
+ // lib/ecommerce/utils/errors.ts
42332
+ var EcommerceApiError = class _EcommerceApiError extends Error {
42333
+ constructor(message, statusCode, data, isNetworkError = false, isTimeoutError = false) {
42334
+ super(message);
42335
+ this.name = "EcommerceApiError";
42336
+ this.statusCode = statusCode;
42337
+ this.data = data;
42338
+ this.isNetworkError = isNetworkError;
42339
+ this.isTimeoutError = isTimeoutError;
42340
+ this.isAuthError = statusCode === 401 || statusCode === 403;
42341
+ if (Error.captureStackTrace) {
42342
+ Error.captureStackTrace(this, _EcommerceApiError);
42343
+ }
42344
+ }
42345
+ };
42346
+ function parseError(error) {
42347
+ if (error.code === "ECONNABORTED" || error.code === "ETIMEDOUT") {
42348
+ return new EcommerceApiError(
42349
+ "Request timeout",
42350
+ void 0,
42351
+ void 0,
42352
+ false,
42353
+ true
42354
+ );
42355
+ }
42356
+ if (error.code === "ERR_NETWORK" || !error.response) {
42357
+ return new EcommerceApiError(
42358
+ error.message || "Network error",
42359
+ void 0,
42360
+ void 0,
42361
+ true,
42362
+ false
42363
+ );
42364
+ }
42365
+ const response = error.response;
42366
+ const statusCode = response?.status;
42367
+ const data = response?.data;
42368
+ const message = data?.error || data?.message || error.message || `API error (${statusCode})`;
42369
+ return new EcommerceApiError(message, statusCode, data);
42370
+ }
42371
+ function isRetryableError(error) {
42372
+ if (error.isNetworkError) {
42373
+ return true;
42374
+ }
42375
+ if (error.isTimeoutError) {
42376
+ return true;
42377
+ }
42378
+ if (error.statusCode && error.statusCode >= 500) {
42379
+ return true;
42380
+ }
42381
+ if (error.statusCode === 429) {
42382
+ return true;
42383
+ }
42384
+ return false;
42385
+ }
42386
+
42387
+ // lib/ecommerce/utils/helpers.ts
42388
+ function buildQueryString(params) {
42389
+ const searchParams = new URLSearchParams();
42390
+ Object.entries(params).forEach(([key, value]) => {
42391
+ if (value !== void 0 && value !== null) {
42392
+ if (Array.isArray(value)) {
42393
+ searchParams.append(key, value.join(","));
42394
+ } else {
42395
+ searchParams.append(key, String(value));
42396
+ }
42397
+ }
42398
+ });
42399
+ const queryString = searchParams.toString();
42400
+ return queryString ? `?${queryString}` : "";
42401
+ }
42402
+ function sleep(ms) {
42403
+ return new Promise((resolve) => setTimeout(resolve, ms));
42404
+ }
42405
+ function getBackoffDelay(attempt, baseDelay = 1e3) {
42406
+ return Math.min(baseDelay * Math.pow(2, attempt), 3e4);
42407
+ }
42408
+ async function retryWithBackoff(fn, maxRetries = 3, baseDelay = 1e3, shouldRetry) {
42409
+ let lastError;
42410
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
42411
+ try {
42412
+ return await fn();
42413
+ } catch (error) {
42414
+ lastError = error;
42415
+ if (attempt < maxRetries && (!shouldRetry || shouldRetry(error))) {
42416
+ const delay = getBackoffDelay(attempt, baseDelay);
42417
+ await sleep(delay);
42418
+ continue;
42419
+ }
42420
+ throw error;
42421
+ }
42422
+ }
42423
+ throw lastError;
42424
+ }
42425
+ function formatPrice(price, decimals = 2) {
42426
+ const num = typeof price === "string" ? parseFloat(price) : price;
42427
+ return num.toFixed(decimals);
42428
+ }
42429
+ function isValidEmail(email) {
42430
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
42431
+ return emailRegex.test(email);
42432
+ }
42433
+ function isValidAddress(address) {
42434
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
42435
+ }
42436
+ function truncateAddress(address, start = 6, end = 4) {
42437
+ if (!address || address.length < start + end) {
42438
+ return address;
42439
+ }
42440
+ return `${address.slice(0, start)}...${address.slice(-end)}`;
42441
+ }
42442
+ function calculateDiscountAmount(price, discountType, discountValue) {
42443
+ if (discountType === "PERCENTAGE") {
42444
+ return price * discountValue / 100;
42445
+ }
42446
+ return Math.min(discountValue, price);
42447
+ }
42448
+ function calculateFinalPrice(price, discountType, discountValue) {
42449
+ const discountAmount = calculateDiscountAmount(price, discountType, discountValue);
42450
+ return Math.max(0, price - discountAmount);
42451
+ }
42452
+
42453
+ // lib/ecommerce/client/base.ts
42454
+ var BaseEcommerceClient = class {
42455
+ constructor(config) {
42456
+ this.config = {
42457
+ baseURL: config.baseURL,
42458
+ authToken: config.authToken,
42459
+ timeout: config.timeout || 3e4,
42460
+ maxRetries: config.maxRetries || 3,
42461
+ retryBaseDelay: config.retryBaseDelay || 1e3,
42462
+ headers: config.headers,
42463
+ enableRetry: config.enableRetry !== false
42464
+ };
42465
+ this.axiosInstance = axios__default.default.create({
42466
+ baseURL: this.config.baseURL,
42467
+ timeout: this.config.timeout,
42468
+ headers: {
42469
+ "Content-Type": "application/json",
42470
+ ...this.config.headers
42471
+ }
42472
+ });
42473
+ this.axiosInstance.interceptors.request.use(
42474
+ (config2) => {
42475
+ if (this.config.authToken) {
42476
+ config2.headers.Authorization = `Bearer ${this.config.authToken}`;
42477
+ }
42478
+ return config2;
42479
+ },
42480
+ (error) => Promise.reject(error)
42481
+ );
42482
+ this.axiosInstance.interceptors.response.use(
42483
+ (response) => response,
42484
+ (error) => Promise.reject(parseError(error))
42485
+ );
42486
+ }
42487
+ /**
42488
+ * Update authentication token
42489
+ *
42490
+ * @param token - New authentication token
42491
+ *
42492
+ * @example
42493
+ * ```typescript
42494
+ * client.setAuthToken("new-auth-token");
42495
+ * ```
42496
+ */
42497
+ setAuthToken(token) {
42498
+ this.config.authToken = token;
42499
+ }
42500
+ /**
42501
+ * Clear authentication token
42502
+ *
42503
+ * @example
42504
+ * ```typescript
42505
+ * client.clearAuthToken();
42506
+ * ```
42507
+ */
42508
+ clearAuthToken() {
42509
+ this.config.authToken = void 0;
42510
+ }
42511
+ /**
42512
+ * Make a GET request
42513
+ *
42514
+ * @param url - Request URL
42515
+ * @param config - Axios request config
42516
+ * @returns Response data
42517
+ *
42518
+ * @example
42519
+ * ```typescript
42520
+ * const products = await client.get("/api/marketplace/products", {
42521
+ * params: { limit: 20, offset: 0 }
42522
+ * });
42523
+ * ```
42524
+ */
42525
+ async get(url, config) {
42526
+ return this.request({ ...config, method: "GET", url });
42527
+ }
42528
+ /**
42529
+ * Make a POST request
42530
+ *
42531
+ * @param url - Request URL
42532
+ * @param data - Request body data
42533
+ * @param config - Axios request config
42534
+ * @returns Response data
42535
+ *
42536
+ * @example
42537
+ * ```typescript
42538
+ * const order = await client.post("/api/marketplace/orders", {
42539
+ * items: [{ productId: "123", quantity: 1 }],
42540
+ * paymentMethod: "USDC_ESCROW"
42541
+ * });
42542
+ * ```
42543
+ */
42544
+ async post(url, data, config) {
42545
+ return this.request({ ...config, method: "POST", url, data });
42546
+ }
42547
+ /**
42548
+ * Make a PUT request
42549
+ *
42550
+ * @param url - Request URL
42551
+ * @param data - Request body data
42552
+ * @param config - Axios request config
42553
+ * @returns Response data
42554
+ *
42555
+ * @example
42556
+ * ```typescript
42557
+ * const product = await client.put("/api/marketplace/products/123", {
42558
+ * title: "Updated Product"
42559
+ * });
42560
+ * ```
42561
+ */
42562
+ async put(url, data, config) {
42563
+ return this.request({ ...config, method: "PUT", url, data });
42564
+ }
42565
+ /**
42566
+ * Make a PATCH request
42567
+ *
42568
+ * @param url - Request URL
42569
+ * @param data - Request body data
42570
+ * @param config - Axios request config
42571
+ * @returns Response data
42572
+ *
42573
+ * @example
42574
+ * ```typescript
42575
+ * const order = await client.patch("/api/marketplace/merchant/orders/123", {
42576
+ * status: "SHIPPED",
42577
+ * tracking: { trackingNumber: "123456", carrier: "UPS" }
42578
+ * });
42579
+ * ```
42580
+ */
42581
+ async patch(url, data, config) {
42582
+ return this.request({ ...config, method: "PATCH", url, data });
42583
+ }
42584
+ /**
42585
+ * Make a DELETE request
42586
+ *
42587
+ * @param url - Request URL
42588
+ * @param config - Axios request config
42589
+ * @returns Response data
42590
+ *
42591
+ * @example
42592
+ * ```typescript
42593
+ * await client.delete("/api/marketplace/products/123");
42594
+ * ```
42595
+ */
42596
+ async delete(url, config) {
42597
+ return this.request({ ...config, method: "DELETE", url });
42598
+ }
42599
+ /**
42600
+ * Make a request with retry logic
42601
+ *
42602
+ * @param config - Axios request config
42603
+ * @returns Response data
42604
+ */
42605
+ async request(config) {
42606
+ const makeRequest = async () => {
42607
+ return this.axiosInstance.request(config);
42608
+ };
42609
+ if (this.config.enableRetry) {
42610
+ const response = await retryWithBackoff(
42611
+ makeRequest,
42612
+ this.config.maxRetries,
42613
+ this.config.retryBaseDelay,
42614
+ (error) => isRetryableError(error)
42615
+ );
42616
+ return response.data;
42617
+ } else {
42618
+ const response = await makeRequest();
42619
+ return response.data;
42620
+ }
42621
+ }
42622
+ /**
42623
+ * Get the underlying axios instance
42624
+ *
42625
+ * @returns Axios instance
42626
+ *
42627
+ * @example
42628
+ * ```typescript
42629
+ * const axios = client.getAxiosInstance();
42630
+ * // Use axios directly for advanced use cases
42631
+ * ```
42632
+ */
42633
+ getAxiosInstance() {
42634
+ return this.axiosInstance;
42635
+ }
42636
+ };
42637
+
42638
+ // lib/ecommerce/client/customer.ts
42639
+ var CustomerEcommerceClient = class extends BaseEcommerceClient {
42640
+ // ============================================================================
42641
+ // Products API
42642
+ // ============================================================================
42643
+ /**
42644
+ * List products with filtering and pagination
42645
+ *
42646
+ * @param params - Query parameters for filtering
42647
+ * @returns Paginated list of products
42648
+ *
42649
+ * @example
42650
+ * ```typescript
42651
+ * const products = await client.listProducts({
42652
+ * limit: 20,
42653
+ * offset: 0,
42654
+ * category: "electronics",
42655
+ * search: "laptop",
42656
+ * minPrice: 500,
42657
+ * maxPrice: 2000,
42658
+ * sortBy: "price_asc"
42659
+ * });
42660
+ * ```
42661
+ */
42662
+ async listProducts(params) {
42663
+ const queryString = params ? buildQueryString(params) : "";
42664
+ return this.get(`/api/marketplace/products${queryString}`);
42665
+ }
42666
+ /**
42667
+ * Get product details by ID
42668
+ *
42669
+ * @param productId - Product ID
42670
+ * @returns Product details with merchant info, variants, and reviews
42671
+ *
42672
+ * @example
42673
+ * ```typescript
42674
+ * const product = await client.getProduct("prod_123");
42675
+ * console.log(product.title, product.priceUSDC);
42676
+ * ```
42677
+ */
42678
+ async getProduct(productId) {
42679
+ return this.get(`/api/marketplace/products/${productId}`);
42680
+ }
42681
+ /**
42682
+ * Track product view (increment view count)
42683
+ *
42684
+ * @param productId - Product ID
42685
+ * @returns Success response
42686
+ *
42687
+ * @example
42688
+ * ```typescript
42689
+ * await client.trackProductView("prod_123");
42690
+ * ```
42691
+ */
42692
+ async trackProductView(productId) {
42693
+ return this.post(`/api/marketplace/products/${productId}/view`);
42694
+ }
42695
+ /**
42696
+ * Get active automatic discounts for a product
42697
+ *
42698
+ * @param productId - Product ID
42699
+ * @returns List of applicable discounts
42700
+ *
42701
+ * @example
42702
+ * ```typescript
42703
+ * const discounts = await client.getProductDiscounts("prod_123");
42704
+ * discounts.discounts.forEach(d => console.log(d.description));
42705
+ * ```
42706
+ */
42707
+ async getProductDiscounts(productId) {
42708
+ return this.get(`/api/marketplace/products/${productId}/discounts`);
42709
+ }
42710
+ // ============================================================================
42711
+ // Orders API
42712
+ // ============================================================================
42713
+ /**
42714
+ * Create order from cart checkout
42715
+ *
42716
+ * Supports multi-merchant checkout - automatically splits orders by merchant.
42717
+ *
42718
+ * @param request - Order creation request
42719
+ * @returns Created order(s) with payment instructions
42720
+ *
42721
+ * @example
42722
+ * ```typescript
42723
+ * const result = await client.createOrder({
42724
+ * items: [
42725
+ * { productId: "prod_123", quantity: 2 },
42726
+ * { productId: "prod_456", quantity: 1, variantId: "var_789" }
42727
+ * ],
42728
+ * paymentMethod: "USDC_ESCROW",
42729
+ * shippingAddress: {
42730
+ * fullName: "John Doe",
42731
+ * phone: "+1234567890",
42732
+ * addressLine1: "123 Main St",
42733
+ * city: "New York",
42734
+ * stateProvince: "NY",
42735
+ * postalCode: "10001",
42736
+ * country: "US"
42737
+ * },
42738
+ * couponCode: "SAVE10"
42739
+ * });
42740
+ *
42741
+ * // For USDC escrow, deposit to the escrow address
42742
+ * if (result.escrow) {
42743
+ * console.log("Deposit", result.escrow.amountUSDC, "USDC to", result.escrow.address);
42744
+ * }
42745
+ * ```
42746
+ */
42747
+ async createOrder(request) {
42748
+ return this.post("/api/marketplace/orders", request);
42749
+ }
42750
+ /**
42751
+ * List user's orders
42752
+ *
42753
+ * @param params - Query parameters for filtering
42754
+ * @returns Paginated list of orders
42755
+ *
42756
+ * @example
42757
+ * ```typescript
42758
+ * const orders = await client.listOrders({
42759
+ * limit: 10,
42760
+ * offset: 0,
42761
+ * status: "SHIPPED"
42762
+ * });
42763
+ * ```
42764
+ */
42765
+ async listOrders(params) {
42766
+ const queryString = params ? buildQueryString(params) : "";
42767
+ return this.get(`/api/marketplace/orders${queryString}`);
42768
+ }
42769
+ /**
42770
+ * Get order details by ID
42771
+ *
42772
+ * @param orderId - Order ID
42773
+ * @returns Order details with items, payment, and shipment info
42774
+ *
42775
+ * @example
42776
+ * ```typescript
42777
+ * const order = await client.getOrder("ord_123");
42778
+ * console.log(order.order.status, order.order.totalUSDC);
42779
+ * ```
42780
+ */
42781
+ async getOrder(orderId) {
42782
+ return this.get(`/api/marketplace/orders/${orderId}`);
42783
+ }
42784
+ /**
42785
+ * Confirm USDC escrow deposit for order payment
42786
+ *
42787
+ * Verifies the Hyperliquid transaction and updates order status.
42788
+ *
42789
+ * @param orderId - Order ID
42790
+ * @returns Confirmation response with transaction hash
42791
+ *
42792
+ * @example
42793
+ * ```typescript
42794
+ * // After depositing USDC to escrow address
42795
+ * const result = await client.confirmEscrowDeposit("ord_123");
42796
+ * console.log("Payment confirmed:", result.depositTxHash);
42797
+ * ```
42798
+ */
42799
+ async confirmEscrowDeposit(orderId) {
42800
+ return this.post(`/api/marketplace/orders/${orderId}/confirm-escrow-deposit`);
42801
+ }
42802
+ /**
42803
+ * Get order receipt
42804
+ *
42805
+ * @param orderId - Order ID
42806
+ * @returns Order receipt for download/display
42807
+ *
42808
+ * @example
42809
+ * ```typescript
42810
+ * const receipt = await client.getOrderReceipt("ord_123");
42811
+ * console.log("Order #", receipt.receipt.orderNumber);
42812
+ * ```
42813
+ */
42814
+ async getOrderReceipt(orderId) {
42815
+ return this.get(`/api/marketplace/orders/${orderId}/receipt`);
42816
+ }
42817
+ // ============================================================================
42818
+ // Reviews API
42819
+ // ============================================================================
42820
+ /**
42821
+ * List reviews for a product
42822
+ *
42823
+ * @param productId - Product ID
42824
+ * @param params - Query parameters
42825
+ * @returns Paginated list of reviews
42826
+ *
42827
+ * @example
42828
+ * ```typescript
42829
+ * const reviews = await client.listProductReviews("prod_123", {
42830
+ * limit: 10,
42831
+ * sortBy: "highest"
42832
+ * });
42833
+ * ```
42834
+ */
42835
+ async listProductReviews(productId, params) {
42836
+ const queryString = params ? buildQueryString(params) : "";
42837
+ return this.get(`/api/marketplace/products/${productId}/reviews${queryString}`);
42838
+ }
42839
+ /**
42840
+ * Create a product review
42841
+ *
42842
+ * Requires authenticated user who has purchased the product.
42843
+ *
42844
+ * @param productId - Product ID
42845
+ * @param request - Review creation request
42846
+ * @returns Created review
42847
+ *
42848
+ * @example
42849
+ * ```typescript
42850
+ * const review = await client.createReview("prod_123", {
42851
+ * rating: 5,
42852
+ * title: "Great product!",
42853
+ * comment: "Exactly what I needed. Fast shipping too!"
42854
+ * });
42855
+ * ```
42856
+ */
42857
+ async createReview(productId, request) {
42858
+ return this.post(`/api/marketplace/products/${productId}/reviews`, request);
42859
+ }
42860
+ // ============================================================================
42861
+ // Shipping Addresses API
42862
+ // ============================================================================
42863
+ /**
42864
+ * List saved shipping addresses
42865
+ *
42866
+ * @returns List of user's saved shipping addresses
42867
+ *
42868
+ * @example
42869
+ * ```typescript
42870
+ * const addresses = await client.listShippingAddresses();
42871
+ * const defaultAddress = addresses.addresses.find(a => a.isDefault);
42872
+ * ```
42873
+ */
42874
+ async listShippingAddresses() {
42875
+ return this.get("/api/user/shipping-addresses");
42876
+ }
42877
+ /**
42878
+ * Create a new shipping address
42879
+ *
42880
+ * @param request - Shipping address data
42881
+ * @returns Created address
42882
+ *
42883
+ * @example
42884
+ * ```typescript
42885
+ * const address = await client.createShippingAddress({
42886
+ * fullName: "John Doe",
42887
+ * phone: "+1234567890",
42888
+ * addressLine1: "123 Main St",
42889
+ * city: "New York",
42890
+ * stateProvince: "NY",
42891
+ * postalCode: "10001",
42892
+ * country: "US",
42893
+ * isDefault: true,
42894
+ * label: "Home"
42895
+ * });
42896
+ * ```
42897
+ */
42898
+ async createShippingAddress(request) {
42899
+ return this.post("/api/user/shipping-addresses", request);
42900
+ }
42901
+ /**
42902
+ * Update a shipping address
42903
+ *
42904
+ * @param addressId - Address ID
42905
+ * @param request - Updated address data
42906
+ * @returns Updated address
42907
+ *
42908
+ * @example
42909
+ * ```typescript
42910
+ * const address = await client.updateShippingAddress("addr_123", {
42911
+ * phone: "+0987654321"
42912
+ * });
42913
+ * ```
42914
+ */
42915
+ async updateShippingAddress(addressId, request) {
42916
+ return this.patch(`/api/user/shipping-addresses/${addressId}`, request);
42917
+ }
42918
+ /**
42919
+ * Delete a shipping address
42920
+ *
42921
+ * @param addressId - Address ID
42922
+ * @returns Success response
42923
+ *
42924
+ * @example
42925
+ * ```typescript
42926
+ * await client.deleteShippingAddress("addr_123");
42927
+ * ```
42928
+ */
42929
+ async deleteShippingAddress(addressId) {
42930
+ return this.delete(`/api/user/shipping-addresses/${addressId}`);
42931
+ }
42932
+ // ============================================================================
42933
+ // Cart & Discounts API
42934
+ // ============================================================================
42935
+ /**
42936
+ * Calculate automatic discounts for cart items
42937
+ *
42938
+ * @param request - Cart items
42939
+ * @returns Calculated discounts and totals
42940
+ *
42941
+ * @example
42942
+ * ```typescript
42943
+ * const result = await client.calculateCartDiscounts({
42944
+ * items: [
42945
+ * { productId: "prod_123", quantity: 2 },
42946
+ * { productId: "prod_456", quantity: 1 }
42947
+ * ]
42948
+ * });
42949
+ * console.log("Subtotal:", result.subtotal);
42950
+ * console.log("Discount:", result.discountAmount);
42951
+ * console.log("Total:", result.total);
42952
+ * ```
42953
+ */
42954
+ async calculateCartDiscounts(request) {
42955
+ return this.post("/api/marketplace/cart/discounts", request);
42956
+ }
42957
+ /**
42958
+ * Validate a discount code for cart items
42959
+ *
42960
+ * @param request - Discount code and cart items
42961
+ * @returns Validation result with discount details
42962
+ *
42963
+ * @example
42964
+ * ```typescript
42965
+ * const result = await client.validateDiscountCode({
42966
+ * code: "SAVE10",
42967
+ * items: [
42968
+ * { productId: "prod_123", quantity: 2 }
42969
+ * ]
42970
+ * });
42971
+ *
42972
+ * if (result.valid) {
42973
+ * console.log("Discount:", result.discount?.discountAmount);
42974
+ * } else {
42975
+ * console.log("Error:", result.error);
42976
+ * }
42977
+ * ```
42978
+ */
42979
+ async validateDiscountCode(request) {
42980
+ return this.post("/api/marketplace/discounts/validate", request);
42981
+ }
42982
+ // ============================================================================
42983
+ // Tax Calculation API
42984
+ // ============================================================================
42985
+ /**
42986
+ * Calculate tax for cart items based on shipping address
42987
+ *
42988
+ * @param request - Cart items and shipping address
42989
+ * @returns Tax calculation with breakdown
42990
+ *
42991
+ * @example
42992
+ * ```typescript
42993
+ * const result = await client.calculateTax({
42994
+ * items: [
42995
+ * { productId: "prod_123", quantity: 2 }
42996
+ * ],
42997
+ * shippingAddress: {
42998
+ * country: "US",
42999
+ * region: "NY",
43000
+ * postalCode: "10001"
43001
+ * }
43002
+ * });
43003
+ * console.log("Tax:", result.taxAmount);
43004
+ * console.log("Total:", result.total);
43005
+ * ```
43006
+ */
43007
+ async calculateTax(request) {
43008
+ return this.post("/api/marketplace/tax/calculate", request);
43009
+ }
43010
+ // ============================================================================
43011
+ // Banners API
43012
+ // ============================================================================
43013
+ /**
43014
+ * Get active promotional banners
43015
+ *
43016
+ * @param params - Query parameters
43017
+ * @returns List of active banners
43018
+ *
43019
+ * @example
43020
+ * ```typescript
43021
+ * const banners = await client.getActiveBanners({
43022
+ * type: "HERO",
43023
+ * merchantId: "merchant_123"
43024
+ * });
43025
+ * ```
43026
+ */
43027
+ async getActiveBanners(params) {
43028
+ const queryString = params ? buildQueryString(params) : "";
43029
+ return this.get(`/api/marketplace/banners/active${queryString}`);
43030
+ }
43031
+ /**
43032
+ * Track banner impression or click
43033
+ *
43034
+ * @param bannerId - Banner ID
43035
+ * @param request - Track action (impression or click)
43036
+ * @returns Success response
43037
+ *
43038
+ * @example
43039
+ * ```typescript
43040
+ * // Track impression
43041
+ * await client.trackBanner("banner_123", { action: "impression" });
43042
+ *
43043
+ * // Track click
43044
+ * await client.trackBanner("banner_123", { action: "click" });
43045
+ * ```
43046
+ */
43047
+ async trackBanner(bannerId, request) {
43048
+ return this.post(`/api/marketplace/banners/${bannerId}/track`, request);
43049
+ }
43050
+ };
43051
+
43052
+ // lib/ecommerce/client/merchant.ts
43053
+ var MerchantEcommerceClient = class extends BaseEcommerceClient {
43054
+ // ============================================================================
43055
+ // Profile Management
43056
+ // ============================================================================
43057
+ /**
43058
+ * Get merchant profile
43059
+ *
43060
+ * @returns Merchant profile
43061
+ *
43062
+ * @example
43063
+ * ```typescript
43064
+ * const profile = await client.getMerchantProfile();
43065
+ * console.log(profile.merchant.name);
43066
+ * ```
43067
+ */
43068
+ async getMerchantProfile() {
43069
+ return this.get("/api/marketplace/merchant/profile");
43070
+ }
43071
+ /**
43072
+ * Get merchant profile (alias for getMerchantProfile)
43073
+ *
43074
+ * @returns Merchant profile
43075
+ *
43076
+ * @example
43077
+ * ```typescript
43078
+ * const profile = await client.getProfile();
43079
+ * console.log(profile.merchant.name);
43080
+ * ```
43081
+ */
43082
+ async getProfile() {
43083
+ return this.getMerchantProfile();
43084
+ }
43085
+ /**
43086
+ * Create or update merchant profile
43087
+ *
43088
+ * @param request - Profile data
43089
+ * @returns Updated merchant profile
43090
+ *
43091
+ * @example
43092
+ * ```typescript
43093
+ * const profile = await client.upsertMerchantProfile({
43094
+ * name: "My Store",
43095
+ * description: "We sell great products",
43096
+ * payoutAddress: "0x1234..."
43097
+ * });
43098
+ * ```
43099
+ */
43100
+ async upsertMerchantProfile(request) {
43101
+ return this.post("/api/marketplace/merchant/profile", request);
43102
+ }
43103
+ // ============================================================================
43104
+ // Products Management
43105
+ // ============================================================================
43106
+ /**
43107
+ * List merchant's products
43108
+ *
43109
+ * @param params - Query parameters
43110
+ * @returns Paginated list of products
43111
+ *
43112
+ * @example
43113
+ * ```typescript
43114
+ * const products = await client.listMerchantProducts({ limit: 20, offset: 0 });
43115
+ * ```
43116
+ */
43117
+ async listMerchantProducts(params) {
43118
+ const queryString = params ? buildQueryString(params) : "";
43119
+ return this.get(`/api/marketplace/merchant/products${queryString}`);
43120
+ }
43121
+ /**
43122
+ * Get a single product by ID
43123
+ *
43124
+ * @param productId - Product ID
43125
+ * @returns Product details
43126
+ *
43127
+ * @example
43128
+ * ```typescript
43129
+ * const product = await client.getProduct("prod_123");
43130
+ * console.log(product.product?.title, product.product?.priceUSDC);
43131
+ * ```
43132
+ */
43133
+ async getProduct(productId) {
43134
+ return this.get(`/api/marketplace/products/${productId}`);
43135
+ }
43136
+ /**
43137
+ * Create a new product
43138
+ *
43139
+ * @param request - Product data
43140
+ * @returns Created product
43141
+ *
43142
+ * @example
43143
+ * ```typescript
43144
+ * const product = await client.createProduct({
43145
+ * title: "Awesome Product",
43146
+ * images: ["https://..."],
43147
+ * priceUSDC: 49.99,
43148
+ * inventory: 50,
43149
+ * category: "electronics",
43150
+ * moq: 1
43151
+ * });
43152
+ * ```
43153
+ */
43154
+ async createProduct(request) {
43155
+ return this.post("/api/marketplace/merchant/products", request);
43156
+ }
43157
+ /**
43158
+ * Update a product
43159
+ *
43160
+ * @param productId - Product ID
43161
+ * @param request - Updated product data
43162
+ * @returns Updated product
43163
+ *
43164
+ * @example
43165
+ * ```typescript
43166
+ * const product = await client.updateProduct("prod_123", {
43167
+ * priceUSDC: 39.99,
43168
+ * inventory: 75
43169
+ * });
43170
+ * ```
43171
+ */
43172
+ async updateProduct(productId, request) {
43173
+ return this.put(`/api/marketplace/products/${productId}`, request);
43174
+ }
43175
+ /**
43176
+ * Delete a product
43177
+ *
43178
+ * @param productId - Product ID
43179
+ * @returns Success response
43180
+ *
43181
+ * @example
43182
+ * ```typescript
43183
+ * await client.deleteProduct("prod_123");
43184
+ * ```
43185
+ */
43186
+ async deleteProduct(productId) {
43187
+ return this.delete(`/api/marketplace/products/${productId}`);
43188
+ }
43189
+ /**
43190
+ * Toggle product featured status
43191
+ *
43192
+ * @param productId - Product ID
43193
+ * @param featured - Featured status
43194
+ * @returns Updated product
43195
+ *
43196
+ * @example
43197
+ * ```typescript
43198
+ * await client.setProductFeatured("prod_123", true);
43199
+ * ```
43200
+ */
43201
+ async setProductFeatured(productId, featured) {
43202
+ return this.patch(`/api/marketplace/merchant/products/${productId}/featured`, { featured });
43203
+ }
43204
+ /**
43205
+ * List product variants
43206
+ *
43207
+ * @param productId - Product ID
43208
+ * @returns List of variants
43209
+ *
43210
+ * @example
43211
+ * ```typescript
43212
+ * const variants = await client.listProductVariants("prod_123");
43213
+ * ```
43214
+ */
43215
+ async listProductVariants(productId) {
43216
+ return this.get(`/api/marketplace/merchant/products/${productId}/variants`);
43217
+ }
43218
+ /**
43219
+ * Create a product variant
43220
+ *
43221
+ * @param productId - Product ID
43222
+ * @param request - Variant data
43223
+ * @returns Created variant
43224
+ *
43225
+ * @example
43226
+ * ```typescript
43227
+ * const variant = await client.createProductVariant("prod_123", {
43228
+ * name: "Large / Red",
43229
+ * attributes: { size: "L", color: "Red" },
43230
+ * priceUSDC: 54.99,
43231
+ * inventory: 20
43232
+ * });
43233
+ * ```
43234
+ */
43235
+ async createProductVariant(productId, request) {
43236
+ return this.post(`/api/marketplace/merchant/products/${productId}/variants`, request);
43237
+ }
43238
+ /**
43239
+ * Get a product variant
43240
+ *
43241
+ * @param productId - Product ID
43242
+ * @param variantId - Variant ID
43243
+ * @returns Variant details
43244
+ *
43245
+ * @example
43246
+ * ```typescript
43247
+ * const variant = await client.getProductVariant("prod_123", "var_456");
43248
+ * ```
43249
+ */
43250
+ async getProductVariant(productId, variantId) {
43251
+ return this.get(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`);
43252
+ }
43253
+ /**
43254
+ * Update a product variant
43255
+ *
43256
+ * @param productId - Product ID
43257
+ * @param variantId - Variant ID
43258
+ * @param request - Updated variant data
43259
+ * @returns Updated variant
43260
+ *
43261
+ * @example
43262
+ * ```typescript
43263
+ * const variant = await client.updateProductVariant("prod_123", "var_456", {
43264
+ * inventory: 30
43265
+ * });
43266
+ * ```
43267
+ */
43268
+ async updateProductVariant(productId, variantId, request) {
43269
+ return this.put(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`, request);
43270
+ }
43271
+ /**
43272
+ * Delete a product variant
43273
+ *
43274
+ * @param productId - Product ID
43275
+ * @param variantId - Variant ID
43276
+ * @returns Success response
43277
+ *
43278
+ * @example
43279
+ * ```typescript
43280
+ * await client.deleteProductVariant("prod_123", "var_456");
43281
+ * ```
43282
+ */
43283
+ async deleteProductVariant(productId, variantId) {
43284
+ return this.delete(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`);
43285
+ }
43286
+ /**
43287
+ * Get product metrics
43288
+ *
43289
+ * @returns Product performance metrics
43290
+ *
43291
+ * @example
43292
+ * ```typescript
43293
+ * const metrics = await client.getProductMetrics();
43294
+ * console.log("Total revenue:", metrics.summary.totalRevenue);
43295
+ * ```
43296
+ */
43297
+ async getProductMetrics() {
43298
+ return this.get("/api/marketplace/merchant/products/metrics");
43299
+ }
43300
+ // ============================================================================
43301
+ // Orders Management
43302
+ // ============================================================================
43303
+ /**
43304
+ * List merchant's orders
43305
+ *
43306
+ * @param params - Query parameters
43307
+ * @returns Paginated list of orders
43308
+ *
43309
+ * @example
43310
+ * ```typescript
43311
+ * const orders = await client.listMerchantOrders({ limit: 20, offset: 0 });
43312
+ * ```
43313
+ */
43314
+ async listMerchantOrders(params) {
43315
+ const queryString = params ? buildQueryString(params) : "";
43316
+ return this.get(`/api/marketplace/merchant/orders${queryString}`);
43317
+ }
43318
+ /**
43319
+ * Get order details
43320
+ *
43321
+ * @param orderId - Order ID
43322
+ * @returns Order details with full information
43323
+ *
43324
+ * @example
43325
+ * ```typescript
43326
+ * const order = await client.getMerchantOrder("ord_123");
43327
+ * console.log(order.order.status, order.order.items);
43328
+ * ```
43329
+ */
43330
+ async getMerchantOrder(orderId) {
43331
+ return this.get(`/api/marketplace/merchant/orders/${orderId}`);
43332
+ }
43333
+ /**
43334
+ * Update order status
43335
+ *
43336
+ * @param orderId - Order ID
43337
+ * @param request - Status update request
43338
+ * @returns Updated order
43339
+ *
43340
+ * @example
43341
+ * ```typescript
43342
+ * // Accept order
43343
+ * await client.updateOrderStatus("ord_123", {
43344
+ * status: "MERCHANT_ACCEPTED"
43345
+ * });
43346
+ *
43347
+ * // Mark as shipped
43348
+ * await client.updateOrderStatus("ord_123", {
43349
+ * status: "SHIPPED",
43350
+ * tracking: {
43351
+ * trackingNumber: "1Z999AA10123456784",
43352
+ * carrier: "UPS"
43353
+ * }
43354
+ * });
43355
+ * ```
43356
+ */
43357
+ async updateOrderStatus(orderId, request) {
43358
+ return this.patch(`/api/marketplace/merchant/orders/${orderId}`, request);
43359
+ }
43360
+ /**
43361
+ * Create a custom order event
43362
+ *
43363
+ * @param orderId - Order ID
43364
+ * @param request - Event data
43365
+ * @returns Created event
43366
+ *
43367
+ * @example
43368
+ * ```typescript
43369
+ * await client.createOrderEvent("ord_123", {
43370
+ * eventType: "CUSTOM",
43371
+ * title: "Package delayed",
43372
+ * description: "Shipment delayed due to weather"
43373
+ * });
43374
+ * ```
43375
+ */
43376
+ async createOrderEvent(orderId, request) {
43377
+ return this.post(`/api/marketplace/merchant/orders/${orderId}/events`, request);
43378
+ }
43379
+ // ============================================================================
43380
+ // Customers Management
43381
+ // ============================================================================
43382
+ /**
43383
+ * List customers with order history and stats
43384
+ *
43385
+ * @param params - Query parameters
43386
+ * @returns Paginated list of customers
43387
+ *
43388
+ * @example
43389
+ * ```typescript
43390
+ * const customers = await client.listCustomers({ limit: 50, offset: 0 });
43391
+ * customers.items.forEach(c => {
43392
+ * console.log(c.username, "Total spent:", c.totalSpent);
43393
+ * });
43394
+ * ```
43395
+ */
43396
+ async listCustomers(params) {
43397
+ const queryString = params ? buildQueryString(params) : "";
43398
+ return this.get(`/api/marketplace/merchant/customers${queryString}`);
43399
+ }
43400
+ // ============================================================================
43401
+ // Coupons & Discounts Management
43402
+ // ============================================================================
43403
+ /**
43404
+ * List merchant's coupons
43405
+ *
43406
+ * @returns List of coupons with stats
43407
+ *
43408
+ * @example
43409
+ * ```typescript
43410
+ * const result = await client.listCoupons();
43411
+ * console.log("Total coupons:", result.stats.total);
43412
+ * console.log("Active:", result.stats.active);
43413
+ * ```
43414
+ */
43415
+ async listCoupons() {
43416
+ return this.get("/api/marketplace/merchant/coupons");
43417
+ }
43418
+ /**
43419
+ * Create a coupon
43420
+ *
43421
+ * @param request - Coupon data
43422
+ * @returns Created coupon
43423
+ *
43424
+ * @example
43425
+ * ```typescript
43426
+ * const coupon = await client.createCoupon({
43427
+ * code: "SAVE20",
43428
+ * discountType: "PERCENTAGE",
43429
+ * discountValue: 20,
43430
+ * startsAt: "2025-01-01T00:00:00Z",
43431
+ * expiresAt: "2025-12-31T23:59:59Z",
43432
+ * maxUses: 100
43433
+ * });
43434
+ * ```
43435
+ */
43436
+ async createCoupon(request) {
43437
+ return this.post("/api/marketplace/merchant/coupons", request);
43438
+ }
43439
+ /**
43440
+ * Get coupon details with usage history
43441
+ *
43442
+ * @param couponId - Coupon ID
43443
+ * @returns Coupon with usages
43444
+ *
43445
+ * @example
43446
+ * ```typescript
43447
+ * const coupon = await client.getCoupon("coupon_123");
43448
+ * console.log("Used", coupon.coupon.usedCount, "times");
43449
+ * ```
43450
+ */
43451
+ async getCoupon(couponId) {
43452
+ return this.get(`/api/marketplace/merchant/coupons/${couponId}`);
43453
+ }
43454
+ /**
43455
+ * Update a coupon
43456
+ *
43457
+ * @param couponId - Coupon ID
43458
+ * @param request - Updated coupon data
43459
+ * @returns Updated coupon
43460
+ *
43461
+ * @example
43462
+ * ```typescript
43463
+ * await client.updateCoupon("coupon_123", {
43464
+ * isActive: false
43465
+ * });
43466
+ * ```
43467
+ */
43468
+ async updateCoupon(couponId, request) {
43469
+ return this.put(`/api/marketplace/merchant/coupons/${couponId}`, request);
43470
+ }
43471
+ /**
43472
+ * Delete a coupon
43473
+ *
43474
+ * @param couponId - Coupon ID
43475
+ * @returns Success response
43476
+ *
43477
+ * @example
43478
+ * ```typescript
43479
+ * await client.deleteCoupon("coupon_123");
43480
+ * ```
43481
+ */
43482
+ async deleteCoupon(couponId) {
43483
+ return this.delete(`/api/marketplace/merchant/coupons/${couponId}`);
43484
+ }
43485
+ // ============================================================================
43486
+ // Shipping & Fulfillment
43487
+ // ============================================================================
43488
+ /**
43489
+ * List shipping methods
43490
+ *
43491
+ * @returns List of shipping methods
43492
+ *
43493
+ * @example
43494
+ * ```typescript
43495
+ * const methods = await client.listShippingMethods();
43496
+ * ```
43497
+ */
43498
+ async listShippingMethods() {
43499
+ return this.get("/api/marketplace/merchant/shipping/methods");
43500
+ }
43501
+ /**
43502
+ * Create a shipping method
43503
+ *
43504
+ * @param request - Shipping method data
43505
+ * @returns Created method
43506
+ *
43507
+ * @example
43508
+ * ```typescript
43509
+ * const method = await client.createShippingMethod({
43510
+ * name: "Standard Shipping",
43511
+ * carrier: "USPS",
43512
+ * estimatedDays: "3-5 business days",
43513
+ * flatRate: 5.99
43514
+ * });
43515
+ * ```
43516
+ */
43517
+ async createShippingMethod(request) {
43518
+ return this.post("/api/marketplace/merchant/shipping/methods", request);
43519
+ }
43520
+ /**
43521
+ * Update a shipping method
43522
+ *
43523
+ * @param methodId - Method ID
43524
+ * @param request - Updated method data
43525
+ * @returns Updated method
43526
+ *
43527
+ * @example
43528
+ * ```typescript
43529
+ * await client.updateShippingMethod("method_123", {
43530
+ * flatRate: 6.99
43531
+ * });
43532
+ * ```
43533
+ */
43534
+ async updateShippingMethod(methodId, request) {
43535
+ return this.put(`/api/marketplace/merchant/shipping/methods/${methodId}`, request);
43536
+ }
43537
+ /**
43538
+ * Delete a shipping method
43539
+ *
43540
+ * @param methodId - Method ID
43541
+ * @returns Success response
43542
+ *
43543
+ * @example
43544
+ * ```typescript
43545
+ * await client.deleteShippingMethod("method_123");
43546
+ * ```
43547
+ */
43548
+ async deleteShippingMethod(methodId) {
43549
+ return this.delete(`/api/marketplace/merchant/shipping/methods/${methodId}`);
43550
+ }
43551
+ /**
43552
+ * List shipments
43553
+ *
43554
+ * @returns List of shipments for merchant's orders
43555
+ *
43556
+ * @example
43557
+ * ```typescript
43558
+ * const shipments = await client.listShipments();
43559
+ * ```
43560
+ */
43561
+ async listShipments() {
43562
+ return this.get("/api/marketplace/merchant/shipping/shipments");
43563
+ }
43564
+ /**
43565
+ * Update shipment status and tracking
43566
+ *
43567
+ * @param shipmentId - Shipment ID
43568
+ * @param request - Updated shipment data
43569
+ * @returns Updated shipment
43570
+ *
43571
+ * @example
43572
+ * ```typescript
43573
+ * await client.updateShipment("ship_123", {
43574
+ * status: "SHIPPED",
43575
+ * trackingNumber: "1Z999AA10123456784",
43576
+ * carrier: "UPS"
43577
+ * });
43578
+ * ```
43579
+ */
43580
+ async updateShipment(shipmentId, request) {
43581
+ return this.patch(`/api/marketplace/merchant/shipping/shipments/${shipmentId}`, request);
43582
+ }
43583
+ // ============================================================================
43584
+ // Returns & Refunds
43585
+ // ============================================================================
43586
+ /**
43587
+ * List returns
43588
+ *
43589
+ * @returns List of returns for merchant's orders
43590
+ *
43591
+ * @example
43592
+ * ```typescript
43593
+ * const returns = await client.listReturns();
43594
+ * ```
43595
+ */
43596
+ async listReturns() {
43597
+ return this.get("/api/marketplace/merchant/returns");
43598
+ }
43599
+ /**
43600
+ * Approve a return request
43601
+ *
43602
+ * @param returnId - Return ID
43603
+ * @returns Updated return
43604
+ *
43605
+ * @example
43606
+ * ```typescript
43607
+ * await client.approveReturn("return_123");
43608
+ * ```
43609
+ */
43610
+ async approveReturn(returnId) {
43611
+ return this.post(`/api/marketplace/merchant/returns/${returnId}/approve`);
43612
+ }
43613
+ /**
43614
+ * Reject a return request
43615
+ *
43616
+ * @param returnId - Return ID
43617
+ * @returns Updated return
43618
+ *
43619
+ * @example
43620
+ * ```typescript
43621
+ * await client.rejectReturn("return_123");
43622
+ * ```
43623
+ */
43624
+ async rejectReturn(returnId) {
43625
+ return this.post(`/api/marketplace/merchant/returns/${returnId}/reject`);
43626
+ }
43627
+ /**
43628
+ * Mark return as received
43629
+ *
43630
+ * @param returnId - Return ID
43631
+ * @returns Updated return
43632
+ *
43633
+ * @example
43634
+ * ```typescript
43635
+ * await client.markReturnReceived("return_123");
43636
+ * ```
43637
+ */
43638
+ async markReturnReceived(returnId) {
43639
+ return this.post(`/api/marketplace/merchant/returns/${returnId}/received`);
43640
+ }
43641
+ /**
43642
+ * Process refund for return
43643
+ *
43644
+ * @param returnId - Return ID
43645
+ * @returns Updated return
43646
+ *
43647
+ * @example
43648
+ * ```typescript
43649
+ * await client.processRefund("return_123");
43650
+ * ```
43651
+ */
43652
+ async processRefund(returnId) {
43653
+ return this.post(`/api/marketplace/merchant/returns/${returnId}/refunded`);
43654
+ }
43655
+ // ============================================================================
43656
+ // Reviews Management
43657
+ // ============================================================================
43658
+ /**
43659
+ * List reviews for merchant's products
43660
+ *
43661
+ * @returns List of reviews
43662
+ *
43663
+ * @example
43664
+ * ```typescript
43665
+ * const reviews = await client.listMerchantReviews();
43666
+ * ```
43667
+ */
43668
+ async listMerchantReviews() {
43669
+ return this.get("/api/marketplace/merchant/reviews");
43670
+ }
43671
+ /**
43672
+ * Respond to a review
43673
+ *
43674
+ * @param reviewId - Review ID
43675
+ * @param request - Response data
43676
+ * @returns Updated review
43677
+ *
43678
+ * @example
43679
+ * ```typescript
43680
+ * await client.respondToReview("review_123", {
43681
+ * merchantResponse: "Thank you for your feedback!"
43682
+ * });
43683
+ * ```
43684
+ */
43685
+ async respondToReview(reviewId, request) {
43686
+ return this.post(`/api/marketplace/merchant/reviews/${reviewId}/respond`, request);
43687
+ }
43688
+ /**
43689
+ * Flag a review as inappropriate
43690
+ *
43691
+ * @param reviewId - Review ID
43692
+ * @returns Updated review
43693
+ *
43694
+ * @example
43695
+ * ```typescript
43696
+ * await client.flagReview("review_123");
43697
+ * ```
43698
+ */
43699
+ async flagReview(reviewId) {
43700
+ return this.post(`/api/marketplace/merchant/reviews/${reviewId}/flag`);
43701
+ }
43702
+ // ============================================================================
43703
+ // Messages
43704
+ // ============================================================================
43705
+ /**
43706
+ * List messages/conversations
43707
+ *
43708
+ * @returns List of conversations grouped by order
43709
+ *
43710
+ * @example
43711
+ * ```typescript
43712
+ * const messages = await client.listMessages();
43713
+ * console.log("Unread:", messages.stats.unread);
43714
+ * ```
43715
+ */
43716
+ async listMessages() {
43717
+ return this.get("/api/marketplace/merchant/messages");
43718
+ }
43719
+ /**
43720
+ * Send a message to customer
43721
+ *
43722
+ * @param request - Message data
43723
+ * @returns Sent message
43724
+ *
43725
+ * @example
43726
+ * ```typescript
43727
+ * await client.sendMessage({
43728
+ * orderId: "ord_123",
43729
+ * recipientId: "user_456",
43730
+ * message: "Your order has been shipped!"
43731
+ * });
43732
+ * ```
43733
+ */
43734
+ async sendMessage(request) {
43735
+ return this.post("/api/marketplace/merchant/messages/send", request);
43736
+ }
43737
+ /**
43738
+ * Mark message as read
43739
+ *
43740
+ * @param messageId - Message ID
43741
+ * @returns Updated message
43742
+ *
43743
+ * @example
43744
+ * ```typescript
43745
+ * await client.markMessageRead("msg_123");
43746
+ * ```
43747
+ */
43748
+ async markMessageRead(messageId) {
43749
+ return this.patch(`/api/marketplace/merchant/messages/${messageId}/read`);
43750
+ }
43751
+ // ============================================================================
43752
+ // Media Library
43753
+ // ============================================================================
43754
+ /**
43755
+ * List media assets
43756
+ *
43757
+ * @param params - Query parameters
43758
+ * @returns Paginated list of media assets
43759
+ *
43760
+ * @example
43761
+ * ```typescript
43762
+ * const media = await client.listMediaAssets({ limit: 50, offset: 0 });
43763
+ * ```
43764
+ */
43765
+ async listMediaAssets(params) {
43766
+ const queryString = params ? buildQueryString(params) : "";
43767
+ return this.get(`/api/marketplace/merchant/media${queryString}`);
43768
+ }
43769
+ /**
43770
+ * Upload a media asset
43771
+ *
43772
+ * @param file - File to upload (max 10MB, images only)
43773
+ * @returns Uploaded asset
43774
+ *
43775
+ * @example
43776
+ * ```typescript
43777
+ * const formData = new FormData();
43778
+ * formData.append("file", imageFile);
43779
+ *
43780
+ * const asset = await client.uploadMediaAsset(formData);
43781
+ * console.log("Uploaded:", asset.asset.blobUrl);
43782
+ * ```
43783
+ */
43784
+ async uploadMediaAsset(formData) {
43785
+ return this.post("/api/marketplace/merchant/media/upload", formData, {
43786
+ headers: { "Content-Type": "multipart/form-data" }
43787
+ });
43788
+ }
43789
+ /**
43790
+ * Delete a media asset
43791
+ *
43792
+ * @param assetId - Asset ID
43793
+ * @returns Success response
43794
+ *
43795
+ * @example
43796
+ * ```typescript
43797
+ * await client.deleteMediaAsset("asset_123");
43798
+ * ```
43799
+ */
43800
+ async deleteMediaAsset(assetId) {
43801
+ return this.delete(`/api/marketplace/merchant/media?id=${assetId}`);
43802
+ }
43803
+ // ============================================================================
43804
+ // Banners
43805
+ // ============================================================================
43806
+ /**
43807
+ * List merchant's banners
43808
+ *
43809
+ * @returns List of banners
43810
+ *
43811
+ * @example
43812
+ * ```typescript
43813
+ * const banners = await client.listMerchantBanners();
43814
+ * ```
43815
+ */
43816
+ async listMerchantBanners() {
43817
+ return this.get("/api/marketplace/merchant/banners");
43818
+ }
43819
+ /**
43820
+ * Create a promotional banner
43821
+ *
43822
+ * @param request - Banner data
43823
+ * @returns Created banner
43824
+ *
43825
+ * @example
43826
+ * ```typescript
43827
+ * const banner = await client.createBanner({
43828
+ * title: "Summer Sale",
43829
+ * imageUrl: "https://...",
43830
+ * linkUrl: "/products?category=summer",
43831
+ * ctaText: "Shop Now",
43832
+ * priority: 10
43833
+ * });
43834
+ * ```
43835
+ */
43836
+ async createBanner(request) {
43837
+ return this.post("/api/marketplace/merchant/banners", request);
43838
+ }
43839
+ /**
43840
+ * Get banner details
43841
+ *
43842
+ * @param bannerId - Banner ID
43843
+ * @returns Banner details
43844
+ *
43845
+ * @example
43846
+ * ```typescript
43847
+ * const banner = await client.getBanner("banner_123");
43848
+ * ```
43849
+ */
43850
+ async getBanner(bannerId) {
43851
+ return this.get(`/api/marketplace/merchant/banners/${bannerId}`);
43852
+ }
43853
+ /**
43854
+ * Update a banner
43855
+ *
43856
+ * @param bannerId - Banner ID
43857
+ * @param request - Updated banner data
43858
+ * @returns Updated banner
43859
+ *
43860
+ * @example
43861
+ * ```typescript
43862
+ * await client.updateBanner("banner_123", {
43863
+ * isActive: false
43864
+ * });
43865
+ * ```
43866
+ */
43867
+ async updateBanner(bannerId, request) {
43868
+ return this.put(`/api/marketplace/merchant/banners/${bannerId}`, request);
43869
+ }
43870
+ /**
43871
+ * Delete a banner
43872
+ *
43873
+ * @param bannerId - Banner ID
43874
+ * @returns Success response
43875
+ *
43876
+ * @example
43877
+ * ```typescript
43878
+ * await client.deleteBanner("banner_123");
43879
+ * ```
43880
+ */
43881
+ async deleteBanner(bannerId) {
43882
+ return this.delete(`/api/marketplace/merchant/banners/${bannerId}`);
43883
+ }
43884
+ // ============================================================================
43885
+ // Analytics
43886
+ // ============================================================================
43887
+ /**
43888
+ * Get merchant analytics
43889
+ *
43890
+ * @param params - Query parameters
43891
+ * @returns Analytics data with overview, charts, and insights
43892
+ *
43893
+ * @example
43894
+ * ```typescript
43895
+ * const analytics = await client.getAnalytics({ range: "30days" });
43896
+ * console.log("Revenue:", analytics.overview.totalRevenue);
43897
+ * console.log("Orders:", analytics.overview.totalOrders);
43898
+ * ```
43899
+ */
43900
+ async getAnalytics(params) {
43901
+ const queryString = params ? buildQueryString(params) : "";
43902
+ return this.get(`/api/marketplace/merchant/analytics${queryString}`);
43903
+ }
43904
+ // ============================================================================
43905
+ // Inventory
43906
+ // ============================================================================
43907
+ /**
43908
+ * Get inventory audit log
43909
+ *
43910
+ * @returns Recent inventory audit entries (last 500)
43911
+ *
43912
+ * @example
43913
+ * ```typescript
43914
+ * const audit = await client.getInventoryAudit();
43915
+ * audit.entries.forEach(e => {
43916
+ * console.log(e.action, e.product.title, e.changeAmount);
43917
+ * });
43918
+ * ```
43919
+ */
43920
+ async getInventoryAudit() {
43921
+ return this.get("/api/marketplace/merchant/inventory/audit");
43922
+ }
43923
+ // ============================================================================
43924
+ // Tax Management
43925
+ // ============================================================================
43926
+ /**
43927
+ * Get tax settings
43928
+ *
43929
+ * @returns Tax settings
43930
+ *
43931
+ * @example
43932
+ * ```typescript
43933
+ * const settings = await client.getTaxSettings();
43934
+ * console.log("Tax enabled:", settings.settings.taxEnabled);
43935
+ * ```
43936
+ */
43937
+ async getTaxSettings() {
43938
+ return this.get("/api/marketplace/merchant/tax-settings");
43939
+ }
43940
+ /**
43941
+ * Update tax settings
43942
+ *
43943
+ * @param request - Updated settings
43944
+ * @returns Updated tax settings
43945
+ *
43946
+ * @example
43947
+ * ```typescript
43948
+ * await client.updateTaxSettings({
43949
+ * taxEnabled: true,
43950
+ * pricesIncludeTax: false,
43951
+ * defaultTaxBehavior: "CHARGE"
43952
+ * });
43953
+ * ```
43954
+ */
43955
+ async updateTaxSettings(request) {
43956
+ return this.put("/api/marketplace/merchant/tax-settings", request);
43957
+ }
43958
+ /**
43959
+ * List tax rules
43960
+ *
43961
+ * @returns List of tax rules
43962
+ *
43963
+ * @example
43964
+ * ```typescript
43965
+ * const rules = await client.listTaxRules();
43966
+ * ```
43967
+ */
43968
+ async listTaxRules() {
43969
+ return this.get("/api/marketplace/merchant/tax-rules");
43970
+ }
43971
+ /**
43972
+ * Create a tax rule
43973
+ *
43974
+ * @param request - Tax rule data
43975
+ * @returns Created tax rule
43976
+ *
43977
+ * @example
43978
+ * ```typescript
43979
+ * const rule = await client.createTaxRule({
43980
+ * country: "US",
43981
+ * region: "NY",
43982
+ * taxType: "SALES_TAX",
43983
+ * taxName: "NY Sales Tax",
43984
+ * taxRate: 8.875
43985
+ * });
43986
+ * ```
43987
+ */
43988
+ async createTaxRule(request) {
43989
+ return this.post("/api/marketplace/merchant/tax-rules", request);
43990
+ }
43991
+ /**
43992
+ * Get tax rule details
43993
+ *
43994
+ * @param ruleId - Rule ID
43995
+ * @returns Tax rule details
43996
+ *
43997
+ * @example
43998
+ * ```typescript
43999
+ * const rule = await client.getTaxRule("rule_123");
44000
+ * ```
44001
+ */
44002
+ async getTaxRule(ruleId) {
44003
+ return this.get(`/api/marketplace/merchant/tax-rules/${ruleId}`);
44004
+ }
44005
+ /**
44006
+ * Update a tax rule
44007
+ *
44008
+ * @param ruleId - Rule ID
44009
+ * @param request - Updated rule data
44010
+ * @returns Updated tax rule
44011
+ *
44012
+ * @example
44013
+ * ```typescript
44014
+ * await client.updateTaxRule("rule_123", {
44015
+ * taxRate: 9.0
44016
+ * });
44017
+ * ```
44018
+ */
44019
+ async updateTaxRule(ruleId, request) {
44020
+ return this.put(`/api/marketplace/merchant/tax-rules/${ruleId}`, request);
44021
+ }
44022
+ /**
44023
+ * Delete a tax rule
44024
+ *
44025
+ * @param ruleId - Rule ID
44026
+ * @returns Success response
44027
+ *
44028
+ * @example
44029
+ * ```typescript
44030
+ * await client.deleteTaxRule("rule_123");
44031
+ * ```
44032
+ */
44033
+ async deleteTaxRule(ruleId) {
44034
+ return this.delete(`/api/marketplace/merchant/tax-rules/${ruleId}`);
44035
+ }
44036
+ /**
44037
+ * List tax nexus locations
44038
+ *
44039
+ * @returns List of nexus locations
44040
+ *
44041
+ * @example
44042
+ * ```typescript
44043
+ * const nexus = await client.listTaxNexus();
44044
+ * ```
44045
+ */
44046
+ async listTaxNexus() {
44047
+ return this.get("/api/marketplace/merchant/tax-nexus");
44048
+ }
44049
+ /**
44050
+ * Add a tax nexus location
44051
+ *
44052
+ * @param request - Nexus data
44053
+ * @returns Created nexus
44054
+ *
44055
+ * @example
44056
+ * ```typescript
44057
+ * const nexus = await client.createTaxNexus({
44058
+ * country: "US",
44059
+ * region: "CA",
44060
+ * registrationId: "123456789"
44061
+ * });
44062
+ * ```
44063
+ */
44064
+ async createTaxNexus(request) {
44065
+ return this.post("/api/marketplace/merchant/tax-nexus", request);
44066
+ }
44067
+ /**
44068
+ * Update a tax nexus location
44069
+ *
44070
+ * @param nexusId - Nexus ID
44071
+ * @param request - Updated nexus data
44072
+ * @returns Updated nexus
44073
+ *
44074
+ * @example
44075
+ * ```typescript
44076
+ * await client.updateTaxNexus("nexus_123", {
44077
+ * registrationId: "987654321"
44078
+ * });
44079
+ * ```
44080
+ */
44081
+ async updateTaxNexus(nexusId, request) {
44082
+ return this.put(`/api/marketplace/merchant/tax-nexus/${nexusId}`, request);
44083
+ }
44084
+ /**
44085
+ * Delete a tax nexus location
44086
+ *
44087
+ * @param nexusId - Nexus ID
44088
+ * @returns Success response
44089
+ *
44090
+ * @example
44091
+ * ```typescript
44092
+ * await client.deleteTaxNexus("nexus_123");
44093
+ * ```
44094
+ */
44095
+ async deleteTaxNexus(nexusId) {
44096
+ return this.delete(`/api/marketplace/merchant/tax-nexus/${nexusId}`);
44097
+ }
44098
+ /**
44099
+ * List tax reports
44100
+ *
44101
+ * @param params - Query parameters
44102
+ * @returns Paginated list of tax reports
44103
+ *
44104
+ * @example
44105
+ * ```typescript
44106
+ * const reports = await client.listTaxReports({ limit: 20, offset: 0 });
44107
+ *
44108
+ * // Get summary for a specific year
44109
+ * const summary = await client.listTaxReports({ year: 2025 });
44110
+ * ```
44111
+ */
44112
+ async listTaxReports(params) {
44113
+ const queryString = params ? buildQueryString(params) : "";
44114
+ return this.get(`/api/marketplace/merchant/tax-reports${queryString}`);
44115
+ }
44116
+ /**
44117
+ * Generate a tax report
44118
+ *
44119
+ * @param request - Report generation request
44120
+ * @returns Generated report
44121
+ *
44122
+ * @example
44123
+ * ```typescript
44124
+ * const report = await client.generateTaxReport({
44125
+ * periodType: "MONTHLY",
44126
+ * year: 2025,
44127
+ * period: 1 // January
44128
+ * });
44129
+ * ```
44130
+ */
44131
+ async generateTaxReport(request) {
44132
+ return this.post("/api/marketplace/merchant/tax-reports/generate", request);
44133
+ }
44134
+ /**
44135
+ * Get tax report details
44136
+ *
44137
+ * @param reportId - Report ID
44138
+ * @returns Report with detailed records
44139
+ *
44140
+ * @example
44141
+ * ```typescript
44142
+ * const report = await client.getTaxReport("report_123");
44143
+ * console.log("Total tax:", report.report.totalTax);
44144
+ * ```
44145
+ */
44146
+ async getTaxReport(reportId) {
44147
+ return this.get(`/api/marketplace/merchant/tax-reports/${reportId}`);
44148
+ }
44149
+ /**
44150
+ * Update tax report status
44151
+ *
44152
+ * @param reportId - Report ID
44153
+ * @param request - Status update
44154
+ * @returns Updated report
44155
+ *
44156
+ * @example
44157
+ * ```typescript
44158
+ * await client.updateTaxReportStatus("report_123", {
44159
+ * status: "FINALIZED"
44160
+ * });
44161
+ * ```
44162
+ */
44163
+ async updateTaxReportStatus(reportId, request) {
44164
+ return this.put(`/api/marketplace/merchant/tax-reports/${reportId}`, request);
44165
+ }
44166
+ /**
44167
+ * Export tax report as CSV
44168
+ *
44169
+ * @param reportId - Report ID
44170
+ * @returns CSV file data
44171
+ *
44172
+ * @example
44173
+ * ```typescript
44174
+ * const csv = await client.exportTaxReport("report_123");
44175
+ * // Save or download the CSV
44176
+ * ```
44177
+ */
44178
+ async exportTaxReport(reportId) {
44179
+ return this.get(`/api/marketplace/merchant/tax-reports/${reportId}/export`);
44180
+ }
44181
+ };
44182
+
44183
+ // lib/ecommerce/types/enums.ts
44184
+ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
44185
+ OrderStatus2["CREATED"] = "CREATED";
44186
+ OrderStatus2["AWAITING_DEPOSIT"] = "AWAITING_DEPOSIT";
44187
+ OrderStatus2["PAYMENT_RESERVED"] = "PAYMENT_RESERVED";
44188
+ OrderStatus2["MERCHANT_ACCEPTED"] = "MERCHANT_ACCEPTED";
44189
+ OrderStatus2["SHIPPED"] = "SHIPPED";
44190
+ OrderStatus2["DELIVERED"] = "DELIVERED";
44191
+ OrderStatus2["CANCELLED"] = "CANCELLED";
44192
+ OrderStatus2["CONFIRMED"] = "CONFIRMED";
44193
+ OrderStatus2["COMPLETED"] = "COMPLETED";
44194
+ return OrderStatus2;
44195
+ })(OrderStatus || {});
44196
+ var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
44197
+ PaymentMethod2["USDC_ESCROW"] = "USDC_ESCROW";
44198
+ PaymentMethod2["POINTS"] = "POINTS";
44199
+ return PaymentMethod2;
44200
+ })(PaymentMethod || {});
44201
+ var PaymentStatus = /* @__PURE__ */ ((PaymentStatus2) => {
44202
+ PaymentStatus2["PENDING"] = "PENDING";
44203
+ PaymentStatus2["RESERVED"] = "RESERVED";
44204
+ PaymentStatus2["COMPLETED"] = "COMPLETED";
44205
+ PaymentStatus2["FAILED"] = "FAILED";
44206
+ PaymentStatus2["REFUNDED"] = "REFUNDED";
44207
+ return PaymentStatus2;
44208
+ })(PaymentStatus || {});
44209
+ var MerchantStatus = /* @__PURE__ */ ((MerchantStatus2) => {
44210
+ MerchantStatus2["ACTIVE"] = "ACTIVE";
44211
+ MerchantStatus2["SUSPENDED"] = "SUSPENDED";
44212
+ MerchantStatus2["PENDING"] = "PENDING";
44213
+ return MerchantStatus2;
44214
+ })(MerchantStatus || {});
44215
+ var ShipmentStatus = /* @__PURE__ */ ((ShipmentStatus2) => {
44216
+ ShipmentStatus2["PENDING"] = "PENDING";
44217
+ ShipmentStatus2["SHIPPED"] = "SHIPPED";
44218
+ ShipmentStatus2["DELIVERED"] = "DELIVERED";
44219
+ ShipmentStatus2["FAILED"] = "FAILED";
44220
+ return ShipmentStatus2;
44221
+ })(ShipmentStatus || {});
44222
+ var ReturnStatus = /* @__PURE__ */ ((ReturnStatus2) => {
44223
+ ReturnStatus2["REQUESTED"] = "REQUESTED";
44224
+ ReturnStatus2["APPROVED"] = "APPROVED";
44225
+ ReturnStatus2["REJECTED"] = "REJECTED";
44226
+ ReturnStatus2["SHIPPED_BACK"] = "SHIPPED_BACK";
44227
+ ReturnStatus2["RECEIVED"] = "RECEIVED";
44228
+ ReturnStatus2["REFUNDED"] = "REFUNDED";
44229
+ return ReturnStatus2;
44230
+ })(ReturnStatus || {});
44231
+ var ReviewStatus = /* @__PURE__ */ ((ReviewStatus2) => {
44232
+ ReviewStatus2["PENDING"] = "PENDING";
44233
+ ReviewStatus2["RESPONDED"] = "RESPONDED";
44234
+ ReviewStatus2["FLAGGED"] = "FLAGGED";
44235
+ return ReviewStatus2;
44236
+ })(ReviewStatus || {});
44237
+ var DiscountType = /* @__PURE__ */ ((DiscountType2) => {
44238
+ DiscountType2["PERCENTAGE"] = "PERCENTAGE";
44239
+ DiscountType2["FIXED_AMOUNT"] = "FIXED_AMOUNT";
44240
+ DiscountType2["BUY_X_GET_Y"] = "BUY_X_GET_Y";
44241
+ DiscountType2["FREE_SHIPPING"] = "FREE_SHIPPING";
44242
+ return DiscountType2;
44243
+ })(DiscountType || {});
44244
+ var DiscountMethod = /* @__PURE__ */ ((DiscountMethod2) => {
44245
+ DiscountMethod2["CODE"] = "CODE";
44246
+ DiscountMethod2["AUTOMATIC"] = "AUTOMATIC";
44247
+ return DiscountMethod2;
44248
+ })(DiscountMethod || {});
44249
+ var DiscountScope = /* @__PURE__ */ ((DiscountScope2) => {
44250
+ DiscountScope2["ORDER"] = "ORDER";
44251
+ DiscountScope2["PRODUCT"] = "PRODUCT";
44252
+ DiscountScope2["CATEGORY"] = "CATEGORY";
44253
+ DiscountScope2["SHIPPING"] = "SHIPPING";
44254
+ return DiscountScope2;
44255
+ })(DiscountScope || {});
44256
+ var BannerType = /* @__PURE__ */ ((BannerType2) => {
44257
+ BannerType2["HERO"] = "HERO";
44258
+ BannerType2["PROMO"] = "PROMO";
44259
+ BannerType2["FEATURED"] = "FEATURED";
44260
+ return BannerType2;
44261
+ })(BannerType || {});
44262
+ var TaxType = /* @__PURE__ */ ((TaxType2) => {
44263
+ TaxType2["SALES_TAX"] = "SALES_TAX";
44264
+ TaxType2["VAT"] = "VAT";
44265
+ TaxType2["GST"] = "GST";
44266
+ TaxType2["PST"] = "PST";
44267
+ TaxType2["HST"] = "HST";
44268
+ return TaxType2;
44269
+ })(TaxType || {});
44270
+ var TaxBehavior = /* @__PURE__ */ ((TaxBehavior2) => {
44271
+ TaxBehavior2["CHARGE"] = "CHARGE";
44272
+ TaxBehavior2["INCLUSIVE"] = "INCLUSIVE";
44273
+ TaxBehavior2["EXEMPT"] = "EXEMPT";
44274
+ return TaxBehavior2;
44275
+ })(TaxBehavior || {});
44276
+ var TaxReportPeriodType = /* @__PURE__ */ ((TaxReportPeriodType2) => {
44277
+ TaxReportPeriodType2["MONTHLY"] = "MONTHLY";
44278
+ TaxReportPeriodType2["QUARTERLY"] = "QUARTERLY";
44279
+ TaxReportPeriodType2["YEARLY"] = "YEARLY";
44280
+ return TaxReportPeriodType2;
44281
+ })(TaxReportPeriodType || {});
44282
+ var TaxReportStatus = /* @__PURE__ */ ((TaxReportStatus2) => {
44283
+ TaxReportStatus2["DRAFT"] = "DRAFT";
44284
+ TaxReportStatus2["FINALIZED"] = "FINALIZED";
44285
+ TaxReportStatus2["FILED"] = "FILED";
44286
+ return TaxReportStatus2;
44287
+ })(TaxReportStatus || {});
44288
+ var InventoryAuditAction = /* @__PURE__ */ ((InventoryAuditAction2) => {
44289
+ InventoryAuditAction2["CREATED"] = "CREATED";
44290
+ InventoryAuditAction2["UPDATED"] = "UPDATED";
44291
+ InventoryAuditAction2["RESERVED"] = "RESERVED";
44292
+ InventoryAuditAction2["DEDUCTED"] = "DEDUCTED";
44293
+ InventoryAuditAction2["RESTORED"] = "RESTORED";
44294
+ return InventoryAuditAction2;
44295
+ })(InventoryAuditAction || {});
44296
+ var SortOrder = /* @__PURE__ */ ((SortOrder2) => {
44297
+ SortOrder2["ASC"] = "asc";
44298
+ SortOrder2["DESC"] = "desc";
44299
+ return SortOrder2;
44300
+ })(SortOrder || {});
44301
+ var ProductSortBy = /* @__PURE__ */ ((ProductSortBy2) => {
44302
+ ProductSortBy2["DATE_DESC"] = "date_desc";
44303
+ ProductSortBy2["DATE_ASC"] = "date_asc";
44304
+ ProductSortBy2["PRICE_ASC"] = "price_asc";
44305
+ ProductSortBy2["PRICE_DESC"] = "price_desc";
44306
+ ProductSortBy2["POPULAR"] = "popular";
44307
+ ProductSortBy2["FEATURED"] = "featured";
44308
+ return ProductSortBy2;
44309
+ })(ProductSortBy || {});
44310
+ var ReviewSortBy = /* @__PURE__ */ ((ReviewSortBy2) => {
44311
+ ReviewSortBy2["NEWEST"] = "newest";
44312
+ ReviewSortBy2["HIGHEST"] = "highest";
44313
+ ReviewSortBy2["LOWEST"] = "lowest";
44314
+ return ReviewSortBy2;
44315
+ })(ReviewSortBy || {});
44316
+
44317
+ exports.AssetIdUtils = AssetIdUtils;
44318
+ exports.BannerType = BannerType;
44319
+ exports.BaseEcommerceClient = BaseEcommerceClient;
44320
+ exports.CloidClientCode = CloidClientCode;
44321
+ exports.CloidClientCodeNameById = CloidClientCodeNameById;
44322
+ exports.CustomerEcommerceClient = CustomerEcommerceClient;
44323
+ exports.DayOfWeek = DayOfWeek;
44324
+ exports.DiscountMethod = DiscountMethod;
44325
+ exports.DiscountScope = DiscountScope;
44326
+ exports.DiscountType = DiscountType;
44327
+ exports.EcommerceApiError = EcommerceApiError;
44328
+ exports.InstrumentClient = InstrumentClient;
44329
+ exports.InventoryAuditAction = InventoryAuditAction;
44330
+ exports.MerchantEcommerceClient = MerchantEcommerceClient;
44331
+ exports.MerchantStatus = MerchantStatus;
44332
+ exports.MetadataClient = MetadataClient;
44333
+ exports.OrderStatus = OrderStatus;
44334
+ exports.PUP_TOKEN_ADDRESS = PUP_TOKEN_ADDRESS;
44335
+ exports.PUP_TOKEN_THRESHOLDS = PUP_TOKEN_THRESHOLDS;
44336
+ exports.PaymentMethod = PaymentMethod;
44337
+ exports.PaymentStatus = PaymentStatus;
44338
+ exports.ProductSortBy = ProductSortBy;
44339
+ exports.ROOT_DEX = ROOT_DEX;
44340
+ exports.ReturnStatus = ReturnStatus;
44341
+ exports.ReviewSortBy = ReviewSortBy;
44342
+ exports.ReviewStatus = ReviewStatus;
44343
+ exports.ShipmentStatus = ShipmentStatus;
44344
+ exports.SortOrder = SortOrder;
44345
+ exports.TARGET_APPROVED_MAX_BUILDER_FEE = TARGET_APPROVED_MAX_BUILDER_FEE;
44346
+ exports.TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT = TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT;
44347
+ exports.TESTNET_USDC_SPOT_TOKEN = TESTNET_USDC_SPOT_TOKEN;
44348
+ exports.TaxBehavior = TaxBehavior;
44349
+ exports.TaxReportPeriodType = TaxReportPeriodType;
44350
+ exports.TaxReportStatus = TaxReportStatus;
44351
+ exports.TaxType = TaxType;
44352
+ exports.USDC_SPOT_TOKEN = USDC_SPOT_TOKEN;
44353
+ exports.UserDexAbstractionTypes = UserDexAbstractionTypes;
44354
+ exports.WidgetType = WidgetType;
44355
+ exports.WidgetTypeById = WidgetTypeById;
44356
+ exports.XP_BOOST_PERCENTAGES = XP_BOOST_PERCENTAGES;
44357
+ exports.buildCloid = buildCloid;
44358
+ exports.buildQueryString = buildQueryString;
44359
+ exports.calculateBoostPercentage = calculateBoostPercentage;
44360
+ exports.calculateDiscountAmount = calculateDiscountAmount;
44361
+ exports.calculateFinalPrice = calculateFinalPrice;
44362
+ exports.calculateTotalPupAmount = calculateTotalPupAmount;
44363
+ exports.decodeSlug = decodeSlug;
44364
+ exports.enableHip3DexAbstractionWithAgent = enableHip3DexAbstractionWithAgent;
44365
+ exports.encodeSlug = encodeSlug;
44366
+ exports.floorUtcDay = floorUtcDay;
44367
+ exports.floorUtcHour = floorUtcHour;
44368
+ exports.floorUtcMinutes = floorUtcMinutes;
44369
+ exports.floorUtcWeek = floorUtcWeek;
44370
+ exports.formatPrice = formatPrice;
44371
+ exports.formatPriceAndSize = formatPriceAndSize;
44372
+ exports.formatPriceForDisplay = formatPriceForDisplay;
44373
+ exports.formatPriceForOrder = formatPriceForOrder;
44374
+ exports.formatSizeForDisplay = formatSizeForDisplay;
44375
+ exports.formatSizeForOrder = formatSizeForOrder;
44376
+ exports.getAllPerpsMeta = getAllPerpsMeta;
44377
+ exports.getApprovalAmount = getApprovalAmount;
44378
+ exports.getBackoffDelay = getBackoffDelay;
44379
+ exports.getClientCodeNameById = getClientCodeNameById;
44380
+ exports.getCloid = getCloid;
44381
+ exports.getDexFromCollateralTokenSymbol = getDexFromCollateralTokenSymbol;
44382
+ exports.getDisplayMarketSymbol = getDisplayMarketSymbol;
44383
+ exports.getHip3Dex = getHip3Dex;
44384
+ exports.getHip3DexAbstraction = getHip3DexAbstraction;
44385
+ exports.getLatestCompletedWeek = getLatestCompletedWeek;
44386
+ exports.getNextTierInfo = getNextTierInfo;
44387
+ exports.getPriceDecimals = getPriceDecimals;
44388
+ exports.getStaticCollateralTokenByDex = getStaticCollateralTokenByDex;
44389
+ exports.getStaticCollateralTokenSymbol = getStaticCollateralTokenSymbol;
44390
+ exports.getWidgetTypeById = getWidgetTypeById;
44391
+ exports.isBasedCloid = isBasedCloid;
44392
+ exports.isClientCode = isClientCode;
44393
+ exports.isHip3Symbol = isHip3Symbol;
44394
+ exports.isMiniAppCloid = isMiniAppCloid;
44395
+ exports.isMiniAppTriggeredCloid = isMiniAppTriggeredCloid;
44396
+ exports.isRetryableError = isRetryableError;
44397
+ exports.isSpotSymbol = isSpotSymbol;
44398
+ exports.isStableQuoteToken = isStableQuoteToken;
44399
+ exports.isTenantCloid = isTenantCloid;
44400
+ exports.isTrackingIdCloid = isTrackingIdCloid;
44401
+ exports.isValidAddress = isValidAddress;
44402
+ exports.isValidEmail = isValidEmail;
44403
+ exports.isWidgetType = isWidgetType;
44404
+ exports.makeUtcRounder = makeUtcRounder;
44405
+ exports.normaliseSlug = normaliseSlug;
44406
+ exports.normaliseTrackingId = normaliseTrackingId;
44407
+ exports.normalizeAirdropAmount = normalizeAirdropAmount;
44408
+ exports.parseCloid = parseCloid;
44409
+ exports.parseError = parseError;
44410
+ exports.retryWithBackoff = retryWithBackoff;
44411
+ exports.setHip3DexAbstraction = setHip3DexAbstraction;
44412
+ exports.sleep = sleep;
44413
+ exports.stableQuoteTokens = stableQuoteTokens;
44414
+ exports.truncateAddress = truncateAddress;