@basedone/core 0.1.10 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-4UEJOM6W.mjs +1 -3
- package/dist/chunk-MVFO4WRF.mjs +2091 -0
- package/dist/chunk-VBC6EQ7Q.mjs +235 -0
- package/dist/client-CgmiTuEX.d.mts +179 -0
- package/dist/client-CgmiTuEX.d.ts +179 -0
- package/dist/ecommerce.d.mts +3986 -0
- package/dist/ecommerce.d.ts +3986 -0
- package/dist/ecommerce.js +2135 -0
- package/dist/ecommerce.mjs +2 -0
- package/dist/index.d.mts +51 -43
- package/dist/index.d.ts +51 -43
- package/dist/index.js +2795 -205
- package/dist/index.mjs +68 -90
- package/dist/{meta-FVJIMALT.mjs → meta-JB5ITE27.mjs} +4 -10
- package/dist/meta-UOGUG3OW.mjs +3 -7
- package/dist/{perpDexs-GGL32HT4.mjs → perpDexs-3LRJ5ZHM.mjs} +37 -8
- package/dist/{perpDexs-G7V2QIM6.mjs → perpDexs-4ISLD7NX.mjs} +177 -32
- package/dist/react.d.mts +39 -0
- package/dist/react.d.ts +39 -0
- package/dist/react.js +268 -0
- package/dist/react.mjs +31 -0
- package/dist/{spotMeta-OD7S6HGW.mjs → spotMeta-GHXX7C5M.mjs} +24 -9
- package/dist/{spotMeta-PCN4Z4R3.mjs → spotMeta-IBBUP2SG.mjs} +54 -6
- package/dist/staticMeta-GM7T3OYL.mjs +3 -6
- package/dist/staticMeta-QV2KMX57.mjs +3 -6
- package/ecommerce.ts +15 -0
- package/index.ts +6 -0
- package/lib/ecommerce/FLASH_SALES.md +340 -0
- package/lib/ecommerce/QUICK_REFERENCE.md +211 -0
- package/lib/ecommerce/README.md +391 -0
- package/lib/ecommerce/USAGE_EXAMPLES.md +704 -0
- package/lib/ecommerce/client/base.ts +272 -0
- package/lib/ecommerce/client/customer.ts +639 -0
- package/lib/ecommerce/client/merchant.ts +1341 -0
- package/lib/ecommerce/index.ts +51 -0
- package/lib/ecommerce/types/entities.ts +791 -0
- package/lib/ecommerce/types/enums.ts +270 -0
- package/lib/ecommerce/types/index.ts +18 -0
- package/lib/ecommerce/types/requests.ts +580 -0
- package/lib/ecommerce/types/responses.ts +857 -0
- package/lib/ecommerce/utils/errors.ts +113 -0
- package/lib/ecommerce/utils/helpers.ts +131 -0
- package/lib/hip3/market-info.ts +1 -1
- package/lib/instrument/client.ts +351 -0
- package/lib/meta/data/mainnet/perpDexs.json +34 -4
- package/lib/meta/data/mainnet/spotMeta.json +21 -3
- package/lib/meta/data/testnet/meta.json +1 -3
- package/lib/meta/data/testnet/perpDexs.json +174 -28
- package/lib/meta/data/testnet/spotMeta.json +51 -0
- package/lib/react/InstrumentProvider.tsx +69 -0
- package/lib/utils/flooredDateTime.ts +55 -0
- package/lib/utils/time.ts +51 -0
- package/package.json +37 -11
- package/react.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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"(
|
|
41
|
-
|
|
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"(
|
|
62
|
-
|
|
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"(
|
|
81
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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"(
|
|
7030
|
-
|
|
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"(
|
|
34570
|
-
|
|
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"(
|
|
36072
|
-
|
|
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"(
|
|
37462
|
-
|
|
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"(
|
|
37721
|
-
|
|
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.
|
|
38278
|
+
"0.005000002"
|
|
38170
38279
|
],
|
|
38171
38280
|
[
|
|
38172
38281
|
"vntls:vANTHRPC",
|
|
38173
|
-
"0.
|
|
38282
|
+
"0.0171374751"
|
|
38174
38283
|
],
|
|
38175
38284
|
[
|
|
38176
38285
|
"vntls:vBYTED",
|
|
38177
|
-
"0.
|
|
38286
|
+
"0.0148191144"
|
|
38178
38287
|
],
|
|
38179
38288
|
[
|
|
38180
38289
|
"vntls:vCHAIN",
|
|
38181
|
-
"0.
|
|
38290
|
+
"0.005"
|
|
38182
38291
|
],
|
|
38183
38292
|
[
|
|
38184
38293
|
"vntls:vCLUELY",
|
|
38185
|
-
"0
|
|
38294
|
+
"2.0"
|
|
38186
38295
|
],
|
|
38187
38296
|
[
|
|
38188
38297
|
"vntls:vCOLOSSAL",
|
|
38189
|
-
"0
|
|
38298
|
+
"2.0"
|
|
38190
38299
|
],
|
|
38191
38300
|
[
|
|
38192
38301
|
"vntls:vCURSOR",
|
|
38193
|
-
"0
|
|
38302
|
+
"2.0"
|
|
38194
38303
|
],
|
|
38195
38304
|
[
|
|
38196
38305
|
"vntls:vDBRICKS",
|
|
38197
|
-
"0.
|
|
38306
|
+
"0.0050534663"
|
|
38198
38307
|
],
|
|
38199
38308
|
[
|
|
38200
38309
|
"vntls:vFIG",
|
|
38201
|
-
"0
|
|
38310
|
+
"2.0"
|
|
38202
38311
|
],
|
|
38203
38312
|
[
|
|
38204
38313
|
"vntls:vFIGAI",
|
|
38205
|
-
"0.
|
|
38314
|
+
"0.0050472398"
|
|
38206
38315
|
],
|
|
38207
38316
|
[
|
|
38208
38317
|
"vntls:vKRAKEN",
|
|
38209
|
-
"0.
|
|
38318
|
+
"0.005"
|
|
38210
38319
|
],
|
|
38211
38320
|
[
|
|
38212
38321
|
"vntls:vNLINK",
|
|
38213
|
-
"0
|
|
38322
|
+
"2.0"
|
|
38214
38323
|
],
|
|
38215
38324
|
[
|
|
38216
38325
|
"vntls:vOAI",
|
|
38217
|
-
"0
|
|
38326
|
+
"2.0"
|
|
38218
38327
|
],
|
|
38219
38328
|
[
|
|
38220
38329
|
"vntls:vPERPLXT",
|
|
38221
|
-
"0.
|
|
38330
|
+
"0.0167613111"
|
|
38222
38331
|
],
|
|
38223
38332
|
[
|
|
38224
38333
|
"vntls:vPOLY",
|
|
38225
|
-
"0
|
|
38334
|
+
"2.0"
|
|
38226
38335
|
],
|
|
38227
38336
|
[
|
|
38228
38337
|
"vntls:vRAMP",
|
|
38229
|
-
"0.
|
|
38338
|
+
"0.0050482304"
|
|
38230
38339
|
],
|
|
38231
38340
|
[
|
|
38232
38341
|
"vntls:vSPACEX",
|
|
38233
|
-
"0.
|
|
38342
|
+
"0.0050030981"
|
|
38234
38343
|
],
|
|
38235
38344
|
[
|
|
38236
38345
|
"vntls:vSTRIPE",
|
|
38237
|
-
"0
|
|
38346
|
+
"2.0"
|
|
38238
38347
|
],
|
|
38239
38348
|
[
|
|
38240
38349
|
"vntls:vXAI",
|
|
38241
|
-
"0
|
|
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
|
|
41103
|
+
const discountMultiplier = feeDiscount ? new Decimal__default.default(1).sub(feeDiscount) : 1;
|
|
40918
41104
|
if (!customFeeEnabled) {
|
|
40919
41105
|
return {
|
|
40920
|
-
approvalAmount: new
|
|
40921
|
-
perpFee: new
|
|
40922
|
-
spotFee: new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
41501
|
+
const transport = new hyperliquid.HttpTransport({
|
|
41323
41502
|
isTestnet: config.isTestnet ?? false
|
|
41324
41503
|
});
|
|
41325
|
-
this.infoClient = new
|
|
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
|
|
41808
|
-
const size = new
|
|
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
|
|
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
|
|
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,2480 @@ 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
|
-
|
|
41873
|
-
|
|
41874
|
-
|
|
41875
|
-
|
|
41876
|
-
|
|
41877
|
-
|
|
41878
|
-
|
|
41879
|
-
|
|
41880
|
-
|
|
41881
|
-
|
|
41882
|
-
|
|
41883
|
-
|
|
41884
|
-
|
|
41885
|
-
|
|
41886
|
-
|
|
41887
|
-
|
|
41888
|
-
|
|
41889
|
-
|
|
41890
|
-
|
|
41891
|
-
|
|
41892
|
-
|
|
41893
|
-
|
|
41894
|
-
|
|
41895
|
-
|
|
41896
|
-
|
|
41897
|
-
|
|
41898
|
-
|
|
41899
|
-
|
|
41900
|
-
|
|
41901
|
-
|
|
41902
|
-
|
|
41903
|
-
|
|
41904
|
-
|
|
41905
|
-
|
|
41906
|
-
|
|
41907
|
-
|
|
41908
|
-
|
|
41909
|
-
|
|
41910
|
-
|
|
41911
|
-
|
|
41912
|
-
|
|
41913
|
-
|
|
41914
|
-
|
|
41915
|
-
|
|
41916
|
-
|
|
41917
|
-
|
|
41918
|
-
|
|
41919
|
-
|
|
41920
|
-
|
|
41921
|
-
|
|
41922
|
-
|
|
41923
|
-
|
|
41924
|
-
|
|
41925
|
-
|
|
41926
|
-
|
|
41927
|
-
|
|
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
|
+
// Messages API
|
|
43052
|
+
// ============================================================================
|
|
43053
|
+
/**
|
|
43054
|
+
* List messages for customer
|
|
43055
|
+
*
|
|
43056
|
+
* Returns all conversations grouped by order, where each order represents
|
|
43057
|
+
* a conversation with a merchant.
|
|
43058
|
+
*
|
|
43059
|
+
* @returns List of conversations with messages and stats
|
|
43060
|
+
*
|
|
43061
|
+
* @example
|
|
43062
|
+
* ```typescript
|
|
43063
|
+
* const result = await client.listMessages();
|
|
43064
|
+
* console.log("Unread:", result.stats.unread);
|
|
43065
|
+
* result.conversations.forEach(conv => {
|
|
43066
|
+
* console.log(`Order ${conv.orderNumber}: ${conv.unreadCount} unread`);
|
|
43067
|
+
* });
|
|
43068
|
+
* ```
|
|
43069
|
+
*/
|
|
43070
|
+
async listMessages() {
|
|
43071
|
+
return this.get("/api/marketplace/messages");
|
|
43072
|
+
}
|
|
43073
|
+
/**
|
|
43074
|
+
* Get message stats (unread count)
|
|
43075
|
+
*
|
|
43076
|
+
* Lightweight endpoint for notification badges.
|
|
43077
|
+
*
|
|
43078
|
+
* @returns Unread message count
|
|
43079
|
+
*
|
|
43080
|
+
* @example
|
|
43081
|
+
* ```typescript
|
|
43082
|
+
* const stats = await client.getMessageStats();
|
|
43083
|
+
* console.log("Unread messages:", stats.unread);
|
|
43084
|
+
* ```
|
|
43085
|
+
*/
|
|
43086
|
+
async getMessageStats() {
|
|
43087
|
+
return this.get("/api/marketplace/messages/stats");
|
|
43088
|
+
}
|
|
43089
|
+
/**
|
|
43090
|
+
* Send a message to a merchant about an order
|
|
43091
|
+
*
|
|
43092
|
+
* @param request - Message data including orderId, recipientId (merchant user ID), and message
|
|
43093
|
+
* @returns Sent message
|
|
43094
|
+
*
|
|
43095
|
+
* @example
|
|
43096
|
+
* ```typescript
|
|
43097
|
+
* await client.sendMessage({
|
|
43098
|
+
* orderId: "ord_123",
|
|
43099
|
+
* recipientId: "user_merchant_456",
|
|
43100
|
+
* message: "When will my order ship?"
|
|
43101
|
+
* });
|
|
43102
|
+
* ```
|
|
43103
|
+
*/
|
|
43104
|
+
async sendMessage(request) {
|
|
43105
|
+
return this.post("/api/marketplace/messages/send", request);
|
|
43106
|
+
}
|
|
43107
|
+
/**
|
|
43108
|
+
* Mark a message as read
|
|
43109
|
+
*
|
|
43110
|
+
* @param messageId - Message ID
|
|
43111
|
+
* @returns Updated message
|
|
43112
|
+
*
|
|
43113
|
+
* @example
|
|
43114
|
+
* ```typescript
|
|
43115
|
+
* await client.markMessageAsRead("msg_123");
|
|
43116
|
+
* ```
|
|
43117
|
+
*/
|
|
43118
|
+
async markMessageAsRead(messageId) {
|
|
43119
|
+
return this.patch(`/api/marketplace/messages/${messageId}/read`, {});
|
|
43120
|
+
}
|
|
43121
|
+
// ============================================================================
|
|
43122
|
+
// Flash Sales API
|
|
43123
|
+
// ============================================================================
|
|
43124
|
+
/**
|
|
43125
|
+
* Get active flash sales
|
|
43126
|
+
*
|
|
43127
|
+
* Returns currently running flash sales with their discounted products.
|
|
43128
|
+
* Includes countdown timer information for UI display.
|
|
43129
|
+
*
|
|
43130
|
+
* @param params - Query parameters
|
|
43131
|
+
* @returns List of active flash sales with time remaining
|
|
43132
|
+
*
|
|
43133
|
+
* @example
|
|
43134
|
+
* ```typescript
|
|
43135
|
+
* const result = await client.getActiveFlashSales({ limit: 5 });
|
|
43136
|
+
*
|
|
43137
|
+
* result.flashSales.forEach(sale => {
|
|
43138
|
+
* console.log(`${sale.name} - ends at ${sale.endsAt}`);
|
|
43139
|
+
* sale.items.forEach(item => {
|
|
43140
|
+
* console.log(` ${item.product.title}: $${item.salePrice} (${item.discountPercent}% off)`);
|
|
43141
|
+
* });
|
|
43142
|
+
* });
|
|
43143
|
+
*
|
|
43144
|
+
* // Use timeRemaining for countdown UI
|
|
43145
|
+
* if (result.timeRemaining) {
|
|
43146
|
+
* console.log(`Featured sale ends in ${result.timeRemaining.remainingSeconds} seconds`);
|
|
43147
|
+
* }
|
|
43148
|
+
* ```
|
|
43149
|
+
*/
|
|
43150
|
+
async getActiveFlashSales(params) {
|
|
43151
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
43152
|
+
return this.get(`/api/marketplace/flash-sales/active${queryString}`);
|
|
43153
|
+
}
|
|
43154
|
+
};
|
|
43155
|
+
|
|
43156
|
+
// lib/ecommerce/client/merchant.ts
|
|
43157
|
+
var MerchantEcommerceClient = class extends BaseEcommerceClient {
|
|
43158
|
+
// ============================================================================
|
|
43159
|
+
// Profile Management
|
|
43160
|
+
// ============================================================================
|
|
43161
|
+
/**
|
|
43162
|
+
* Get merchant profile
|
|
43163
|
+
*
|
|
43164
|
+
* @returns Merchant profile
|
|
43165
|
+
*
|
|
43166
|
+
* @example
|
|
43167
|
+
* ```typescript
|
|
43168
|
+
* const profile = await client.getMerchantProfile();
|
|
43169
|
+
* console.log(profile.merchant.name);
|
|
43170
|
+
* ```
|
|
43171
|
+
*/
|
|
43172
|
+
async getMerchantProfile() {
|
|
43173
|
+
return this.get("/api/marketplace/merchant/profile");
|
|
43174
|
+
}
|
|
43175
|
+
/**
|
|
43176
|
+
* Get merchant profile (alias for getMerchantProfile)
|
|
43177
|
+
*
|
|
43178
|
+
* @returns Merchant profile
|
|
43179
|
+
*
|
|
43180
|
+
* @example
|
|
43181
|
+
* ```typescript
|
|
43182
|
+
* const profile = await client.getProfile();
|
|
43183
|
+
* console.log(profile.merchant.name);
|
|
43184
|
+
* ```
|
|
43185
|
+
*/
|
|
43186
|
+
async getProfile() {
|
|
43187
|
+
return this.getMerchantProfile();
|
|
43188
|
+
}
|
|
43189
|
+
/**
|
|
43190
|
+
* Create or update merchant profile
|
|
43191
|
+
*
|
|
43192
|
+
* @param request - Profile data
|
|
43193
|
+
* @returns Updated merchant profile
|
|
43194
|
+
*
|
|
43195
|
+
* @example
|
|
43196
|
+
* ```typescript
|
|
43197
|
+
* const profile = await client.upsertMerchantProfile({
|
|
43198
|
+
* name: "My Store",
|
|
43199
|
+
* description: "We sell great products",
|
|
43200
|
+
* payoutAddress: "0x1234..."
|
|
43201
|
+
* });
|
|
43202
|
+
* ```
|
|
43203
|
+
*/
|
|
43204
|
+
async upsertMerchantProfile(request) {
|
|
43205
|
+
return this.post("/api/marketplace/merchant/profile", request);
|
|
43206
|
+
}
|
|
43207
|
+
// ============================================================================
|
|
43208
|
+
// Products Management
|
|
43209
|
+
// ============================================================================
|
|
43210
|
+
/**
|
|
43211
|
+
* List merchant's products
|
|
43212
|
+
*
|
|
43213
|
+
* @param params - Query parameters
|
|
43214
|
+
* @returns Paginated list of products
|
|
43215
|
+
*
|
|
43216
|
+
* @example
|
|
43217
|
+
* ```typescript
|
|
43218
|
+
* const products = await client.listMerchantProducts({ limit: 20, offset: 0 });
|
|
43219
|
+
* ```
|
|
43220
|
+
*/
|
|
43221
|
+
async listMerchantProducts(params) {
|
|
43222
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
43223
|
+
return this.get(`/api/marketplace/merchant/products${queryString}`);
|
|
43224
|
+
}
|
|
43225
|
+
/**
|
|
43226
|
+
* Get a single product by ID
|
|
43227
|
+
*
|
|
43228
|
+
* @param productId - Product ID
|
|
43229
|
+
* @returns Product details
|
|
43230
|
+
*
|
|
43231
|
+
* @example
|
|
43232
|
+
* ```typescript
|
|
43233
|
+
* const product = await client.getProduct("prod_123");
|
|
43234
|
+
* console.log(product.product?.title, product.product?.priceUSDC);
|
|
43235
|
+
* ```
|
|
43236
|
+
*/
|
|
43237
|
+
async getProduct(productId) {
|
|
43238
|
+
return this.get(`/api/marketplace/products/${productId}`);
|
|
43239
|
+
}
|
|
43240
|
+
/**
|
|
43241
|
+
* Create a new product
|
|
43242
|
+
*
|
|
43243
|
+
* @param request - Product data
|
|
43244
|
+
* @returns Created product
|
|
43245
|
+
*
|
|
43246
|
+
* @example
|
|
43247
|
+
* ```typescript
|
|
43248
|
+
* const product = await client.createProduct({
|
|
43249
|
+
* title: "Awesome Product",
|
|
43250
|
+
* images: ["https://..."],
|
|
43251
|
+
* priceUSDC: 49.99,
|
|
43252
|
+
* inventory: 50,
|
|
43253
|
+
* category: "electronics",
|
|
43254
|
+
* moq: 1
|
|
43255
|
+
* });
|
|
43256
|
+
* ```
|
|
43257
|
+
*/
|
|
43258
|
+
async createProduct(request) {
|
|
43259
|
+
return this.post("/api/marketplace/merchant/products", request);
|
|
43260
|
+
}
|
|
43261
|
+
/**
|
|
43262
|
+
* Update a product
|
|
43263
|
+
*
|
|
43264
|
+
* @param productId - Product ID
|
|
43265
|
+
* @param request - Updated product data
|
|
43266
|
+
* @returns Updated product
|
|
43267
|
+
*
|
|
43268
|
+
* @example
|
|
43269
|
+
* ```typescript
|
|
43270
|
+
* const product = await client.updateProduct("prod_123", {
|
|
43271
|
+
* priceUSDC: 39.99,
|
|
43272
|
+
* inventory: 75
|
|
43273
|
+
* });
|
|
43274
|
+
* ```
|
|
43275
|
+
*/
|
|
43276
|
+
async updateProduct(productId, request) {
|
|
43277
|
+
return this.put(`/api/marketplace/products/${productId}`, request);
|
|
43278
|
+
}
|
|
43279
|
+
/**
|
|
43280
|
+
* Delete a product
|
|
43281
|
+
*
|
|
43282
|
+
* @param productId - Product ID
|
|
43283
|
+
* @returns Success response
|
|
43284
|
+
*
|
|
43285
|
+
* @example
|
|
43286
|
+
* ```typescript
|
|
43287
|
+
* await client.deleteProduct("prod_123");
|
|
43288
|
+
* ```
|
|
43289
|
+
*/
|
|
43290
|
+
async deleteProduct(productId) {
|
|
43291
|
+
return this.delete(`/api/marketplace/products/${productId}`);
|
|
43292
|
+
}
|
|
43293
|
+
/**
|
|
43294
|
+
* Toggle product featured status
|
|
43295
|
+
*
|
|
43296
|
+
* @param productId - Product ID
|
|
43297
|
+
* @param featured - Featured status
|
|
43298
|
+
* @returns Updated product
|
|
43299
|
+
*
|
|
43300
|
+
* @example
|
|
43301
|
+
* ```typescript
|
|
43302
|
+
* await client.setProductFeatured("prod_123", true);
|
|
43303
|
+
* ```
|
|
43304
|
+
*/
|
|
43305
|
+
async setProductFeatured(productId, featured) {
|
|
43306
|
+
return this.patch(`/api/marketplace/merchant/products/${productId}/featured`, { featured });
|
|
43307
|
+
}
|
|
43308
|
+
/**
|
|
43309
|
+
* List product variants
|
|
43310
|
+
*
|
|
43311
|
+
* @param productId - Product ID
|
|
43312
|
+
* @returns List of variants
|
|
43313
|
+
*
|
|
43314
|
+
* @example
|
|
43315
|
+
* ```typescript
|
|
43316
|
+
* const variants = await client.listProductVariants("prod_123");
|
|
43317
|
+
* ```
|
|
43318
|
+
*/
|
|
43319
|
+
async listProductVariants(productId) {
|
|
43320
|
+
return this.get(`/api/marketplace/merchant/products/${productId}/variants`);
|
|
43321
|
+
}
|
|
43322
|
+
/**
|
|
43323
|
+
* Create a product variant
|
|
43324
|
+
*
|
|
43325
|
+
* @param productId - Product ID
|
|
43326
|
+
* @param request - Variant data
|
|
43327
|
+
* @returns Created variant
|
|
43328
|
+
*
|
|
43329
|
+
* @example
|
|
43330
|
+
* ```typescript
|
|
43331
|
+
* const variant = await client.createProductVariant("prod_123", {
|
|
43332
|
+
* name: "Large / Red",
|
|
43333
|
+
* attributes: { size: "L", color: "Red" },
|
|
43334
|
+
* priceUSDC: 54.99,
|
|
43335
|
+
* inventory: 20
|
|
43336
|
+
* });
|
|
43337
|
+
* ```
|
|
43338
|
+
*/
|
|
43339
|
+
async createProductVariant(productId, request) {
|
|
43340
|
+
return this.post(`/api/marketplace/merchant/products/${productId}/variants`, request);
|
|
43341
|
+
}
|
|
43342
|
+
/**
|
|
43343
|
+
* Get a product variant
|
|
43344
|
+
*
|
|
43345
|
+
* @param productId - Product ID
|
|
43346
|
+
* @param variantId - Variant ID
|
|
43347
|
+
* @returns Variant details
|
|
43348
|
+
*
|
|
43349
|
+
* @example
|
|
43350
|
+
* ```typescript
|
|
43351
|
+
* const variant = await client.getProductVariant("prod_123", "var_456");
|
|
43352
|
+
* ```
|
|
43353
|
+
*/
|
|
43354
|
+
async getProductVariant(productId, variantId) {
|
|
43355
|
+
return this.get(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`);
|
|
43356
|
+
}
|
|
43357
|
+
/**
|
|
43358
|
+
* Update a product variant
|
|
43359
|
+
*
|
|
43360
|
+
* @param productId - Product ID
|
|
43361
|
+
* @param variantId - Variant ID
|
|
43362
|
+
* @param request - Updated variant data
|
|
43363
|
+
* @returns Updated variant
|
|
43364
|
+
*
|
|
43365
|
+
* @example
|
|
43366
|
+
* ```typescript
|
|
43367
|
+
* const variant = await client.updateProductVariant("prod_123", "var_456", {
|
|
43368
|
+
* inventory: 30
|
|
43369
|
+
* });
|
|
43370
|
+
* ```
|
|
43371
|
+
*/
|
|
43372
|
+
async updateProductVariant(productId, variantId, request) {
|
|
43373
|
+
return this.put(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`, request);
|
|
43374
|
+
}
|
|
43375
|
+
/**
|
|
43376
|
+
* Delete a product variant
|
|
43377
|
+
*
|
|
43378
|
+
* @param productId - Product ID
|
|
43379
|
+
* @param variantId - Variant ID
|
|
43380
|
+
* @returns Success response
|
|
43381
|
+
*
|
|
43382
|
+
* @example
|
|
43383
|
+
* ```typescript
|
|
43384
|
+
* await client.deleteProductVariant("prod_123", "var_456");
|
|
43385
|
+
* ```
|
|
43386
|
+
*/
|
|
43387
|
+
async deleteProductVariant(productId, variantId) {
|
|
43388
|
+
return this.delete(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`);
|
|
43389
|
+
}
|
|
43390
|
+
/**
|
|
43391
|
+
* Get product metrics
|
|
43392
|
+
*
|
|
43393
|
+
* @returns Product performance metrics
|
|
43394
|
+
*
|
|
43395
|
+
* @example
|
|
43396
|
+
* ```typescript
|
|
43397
|
+
* const metrics = await client.getProductMetrics();
|
|
43398
|
+
* console.log("Total revenue:", metrics.summary.totalRevenue);
|
|
43399
|
+
* ```
|
|
43400
|
+
*/
|
|
43401
|
+
async getProductMetrics() {
|
|
43402
|
+
return this.get("/api/marketplace/merchant/products/metrics");
|
|
43403
|
+
}
|
|
43404
|
+
// ============================================================================
|
|
43405
|
+
// Orders Management
|
|
43406
|
+
// ============================================================================
|
|
43407
|
+
/**
|
|
43408
|
+
* List merchant's orders
|
|
43409
|
+
*
|
|
43410
|
+
* @param params - Query parameters
|
|
43411
|
+
* @returns Paginated list of orders
|
|
43412
|
+
*
|
|
43413
|
+
* @example
|
|
43414
|
+
* ```typescript
|
|
43415
|
+
* const orders = await client.listMerchantOrders({ limit: 20, offset: 0 });
|
|
43416
|
+
* ```
|
|
43417
|
+
*/
|
|
43418
|
+
async listMerchantOrders(params) {
|
|
43419
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
43420
|
+
return this.get(`/api/marketplace/merchant/orders${queryString}`);
|
|
43421
|
+
}
|
|
43422
|
+
/**
|
|
43423
|
+
* Get order details
|
|
43424
|
+
*
|
|
43425
|
+
* @param orderId - Order ID
|
|
43426
|
+
* @returns Order details with full information
|
|
43427
|
+
*
|
|
43428
|
+
* @example
|
|
43429
|
+
* ```typescript
|
|
43430
|
+
* const order = await client.getMerchantOrder("ord_123");
|
|
43431
|
+
* console.log(order.order.status, order.order.items);
|
|
43432
|
+
* ```
|
|
43433
|
+
*/
|
|
43434
|
+
async getMerchantOrder(orderId) {
|
|
43435
|
+
return this.get(`/api/marketplace/merchant/orders/${orderId}`);
|
|
43436
|
+
}
|
|
43437
|
+
/**
|
|
43438
|
+
* Update order status
|
|
43439
|
+
*
|
|
43440
|
+
* @param orderId - Order ID
|
|
43441
|
+
* @param request - Status update request
|
|
43442
|
+
* @returns Updated order
|
|
43443
|
+
*
|
|
43444
|
+
* @example
|
|
43445
|
+
* ```typescript
|
|
43446
|
+
* // Accept order
|
|
43447
|
+
* await client.updateOrderStatus("ord_123", {
|
|
43448
|
+
* status: "MERCHANT_ACCEPTED"
|
|
43449
|
+
* });
|
|
43450
|
+
*
|
|
43451
|
+
* // Mark as shipped
|
|
43452
|
+
* await client.updateOrderStatus("ord_123", {
|
|
43453
|
+
* status: "SHIPPED",
|
|
43454
|
+
* tracking: {
|
|
43455
|
+
* trackingNumber: "1Z999AA10123456784",
|
|
43456
|
+
* carrier: "UPS"
|
|
43457
|
+
* }
|
|
43458
|
+
* });
|
|
43459
|
+
* ```
|
|
43460
|
+
*/
|
|
43461
|
+
async updateOrderStatus(orderId, request) {
|
|
43462
|
+
return this.patch(`/api/marketplace/merchant/orders/${orderId}`, request);
|
|
43463
|
+
}
|
|
43464
|
+
/**
|
|
43465
|
+
* Create a custom order event
|
|
43466
|
+
*
|
|
43467
|
+
* @param orderId - Order ID
|
|
43468
|
+
* @param request - Event data
|
|
43469
|
+
* @returns Created event
|
|
43470
|
+
*
|
|
43471
|
+
* @example
|
|
43472
|
+
* ```typescript
|
|
43473
|
+
* await client.createOrderEvent("ord_123", {
|
|
43474
|
+
* eventType: "CUSTOM",
|
|
43475
|
+
* title: "Package delayed",
|
|
43476
|
+
* description: "Shipment delayed due to weather"
|
|
43477
|
+
* });
|
|
43478
|
+
* ```
|
|
43479
|
+
*/
|
|
43480
|
+
async createOrderEvent(orderId, request) {
|
|
43481
|
+
return this.post(`/api/marketplace/merchant/orders/${orderId}/events`, request);
|
|
43482
|
+
}
|
|
43483
|
+
// ============================================================================
|
|
43484
|
+
// Customers Management
|
|
43485
|
+
// ============================================================================
|
|
43486
|
+
/**
|
|
43487
|
+
* List customers with order history and stats
|
|
43488
|
+
*
|
|
43489
|
+
* @param params - Query parameters
|
|
43490
|
+
* @returns Paginated list of customers
|
|
43491
|
+
*
|
|
43492
|
+
* @example
|
|
43493
|
+
* ```typescript
|
|
43494
|
+
* const customers = await client.listCustomers({ limit: 50, offset: 0 });
|
|
43495
|
+
* customers.items.forEach(c => {
|
|
43496
|
+
* console.log(c.username, "Total spent:", c.totalSpent);
|
|
43497
|
+
* });
|
|
43498
|
+
* ```
|
|
43499
|
+
*/
|
|
43500
|
+
async listCustomers(params) {
|
|
43501
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
43502
|
+
return this.get(`/api/marketplace/merchant/customers${queryString}`);
|
|
43503
|
+
}
|
|
43504
|
+
// ============================================================================
|
|
43505
|
+
// Coupons & Discounts Management
|
|
43506
|
+
// ============================================================================
|
|
43507
|
+
/**
|
|
43508
|
+
* List merchant's coupons
|
|
43509
|
+
*
|
|
43510
|
+
* @returns List of coupons with stats
|
|
43511
|
+
*
|
|
43512
|
+
* @example
|
|
43513
|
+
* ```typescript
|
|
43514
|
+
* const result = await client.listCoupons();
|
|
43515
|
+
* console.log("Total coupons:", result.stats.total);
|
|
43516
|
+
* console.log("Active:", result.stats.active);
|
|
43517
|
+
* ```
|
|
43518
|
+
*/
|
|
43519
|
+
async listCoupons() {
|
|
43520
|
+
return this.get("/api/marketplace/merchant/coupons");
|
|
43521
|
+
}
|
|
43522
|
+
/**
|
|
43523
|
+
* Create a coupon
|
|
43524
|
+
*
|
|
43525
|
+
* @param request - Coupon data
|
|
43526
|
+
* @returns Created coupon
|
|
43527
|
+
*
|
|
43528
|
+
* @example
|
|
43529
|
+
* ```typescript
|
|
43530
|
+
* const coupon = await client.createCoupon({
|
|
43531
|
+
* code: "SAVE20",
|
|
43532
|
+
* discountType: "PERCENTAGE",
|
|
43533
|
+
* discountValue: 20,
|
|
43534
|
+
* startsAt: "2025-01-01T00:00:00Z",
|
|
43535
|
+
* expiresAt: "2025-12-31T23:59:59Z",
|
|
43536
|
+
* maxUses: 100
|
|
43537
|
+
* });
|
|
43538
|
+
* ```
|
|
43539
|
+
*/
|
|
43540
|
+
async createCoupon(request) {
|
|
43541
|
+
return this.post("/api/marketplace/merchant/coupons", request);
|
|
43542
|
+
}
|
|
43543
|
+
/**
|
|
43544
|
+
* Get coupon details with usage history
|
|
43545
|
+
*
|
|
43546
|
+
* @param couponId - Coupon ID
|
|
43547
|
+
* @returns Coupon with usages
|
|
43548
|
+
*
|
|
43549
|
+
* @example
|
|
43550
|
+
* ```typescript
|
|
43551
|
+
* const coupon = await client.getCoupon("coupon_123");
|
|
43552
|
+
* console.log("Used", coupon.coupon.usedCount, "times");
|
|
43553
|
+
* ```
|
|
43554
|
+
*/
|
|
43555
|
+
async getCoupon(couponId) {
|
|
43556
|
+
return this.get(`/api/marketplace/merchant/coupons/${couponId}`);
|
|
43557
|
+
}
|
|
43558
|
+
/**
|
|
43559
|
+
* Update a coupon
|
|
43560
|
+
*
|
|
43561
|
+
* @param couponId - Coupon ID
|
|
43562
|
+
* @param request - Updated coupon data
|
|
43563
|
+
* @returns Updated coupon
|
|
43564
|
+
*
|
|
43565
|
+
* @example
|
|
43566
|
+
* ```typescript
|
|
43567
|
+
* await client.updateCoupon("coupon_123", {
|
|
43568
|
+
* isActive: false
|
|
43569
|
+
* });
|
|
43570
|
+
* ```
|
|
43571
|
+
*/
|
|
43572
|
+
async updateCoupon(couponId, request) {
|
|
43573
|
+
return this.put(`/api/marketplace/merchant/coupons/${couponId}`, request);
|
|
43574
|
+
}
|
|
43575
|
+
/**
|
|
43576
|
+
* Delete a coupon
|
|
43577
|
+
*
|
|
43578
|
+
* @param couponId - Coupon ID
|
|
43579
|
+
* @returns Success response
|
|
43580
|
+
*
|
|
43581
|
+
* @example
|
|
43582
|
+
* ```typescript
|
|
43583
|
+
* await client.deleteCoupon("coupon_123");
|
|
43584
|
+
* ```
|
|
43585
|
+
*/
|
|
43586
|
+
async deleteCoupon(couponId) {
|
|
43587
|
+
return this.delete(`/api/marketplace/merchant/coupons/${couponId}`);
|
|
43588
|
+
}
|
|
43589
|
+
// ============================================================================
|
|
43590
|
+
// Shipping & Fulfillment
|
|
43591
|
+
// ============================================================================
|
|
43592
|
+
/**
|
|
43593
|
+
* List shipping methods
|
|
43594
|
+
*
|
|
43595
|
+
* @returns List of shipping methods
|
|
43596
|
+
*
|
|
43597
|
+
* @example
|
|
43598
|
+
* ```typescript
|
|
43599
|
+
* const methods = await client.listShippingMethods();
|
|
43600
|
+
* ```
|
|
43601
|
+
*/
|
|
43602
|
+
async listShippingMethods() {
|
|
43603
|
+
return this.get("/api/marketplace/merchant/shipping/methods");
|
|
43604
|
+
}
|
|
43605
|
+
/**
|
|
43606
|
+
* Create a shipping method
|
|
43607
|
+
*
|
|
43608
|
+
* @param request - Shipping method data
|
|
43609
|
+
* @returns Created method
|
|
43610
|
+
*
|
|
43611
|
+
* @example
|
|
43612
|
+
* ```typescript
|
|
43613
|
+
* const method = await client.createShippingMethod({
|
|
43614
|
+
* name: "Standard Shipping",
|
|
43615
|
+
* carrier: "USPS",
|
|
43616
|
+
* estimatedDays: "3-5 business days",
|
|
43617
|
+
* flatRate: 5.99
|
|
43618
|
+
* });
|
|
43619
|
+
* ```
|
|
43620
|
+
*/
|
|
43621
|
+
async createShippingMethod(request) {
|
|
43622
|
+
return this.post("/api/marketplace/merchant/shipping/methods", request);
|
|
43623
|
+
}
|
|
43624
|
+
/**
|
|
43625
|
+
* Update a shipping method
|
|
43626
|
+
*
|
|
43627
|
+
* @param methodId - Method ID
|
|
43628
|
+
* @param request - Updated method data
|
|
43629
|
+
* @returns Updated method
|
|
43630
|
+
*
|
|
43631
|
+
* @example
|
|
43632
|
+
* ```typescript
|
|
43633
|
+
* await client.updateShippingMethod("method_123", {
|
|
43634
|
+
* flatRate: 6.99
|
|
43635
|
+
* });
|
|
43636
|
+
* ```
|
|
43637
|
+
*/
|
|
43638
|
+
async updateShippingMethod(methodId, request) {
|
|
43639
|
+
return this.put(`/api/marketplace/merchant/shipping/methods/${methodId}`, request);
|
|
43640
|
+
}
|
|
43641
|
+
/**
|
|
43642
|
+
* Delete a shipping method
|
|
43643
|
+
*
|
|
43644
|
+
* @param methodId - Method ID
|
|
43645
|
+
* @returns Success response
|
|
43646
|
+
*
|
|
43647
|
+
* @example
|
|
43648
|
+
* ```typescript
|
|
43649
|
+
* await client.deleteShippingMethod("method_123");
|
|
43650
|
+
* ```
|
|
43651
|
+
*/
|
|
43652
|
+
async deleteShippingMethod(methodId) {
|
|
43653
|
+
return this.delete(`/api/marketplace/merchant/shipping/methods/${methodId}`);
|
|
43654
|
+
}
|
|
43655
|
+
/**
|
|
43656
|
+
* List shipments
|
|
43657
|
+
*
|
|
43658
|
+
* @returns List of shipments for merchant's orders
|
|
43659
|
+
*
|
|
43660
|
+
* @example
|
|
43661
|
+
* ```typescript
|
|
43662
|
+
* const shipments = await client.listShipments();
|
|
43663
|
+
* ```
|
|
43664
|
+
*/
|
|
43665
|
+
async listShipments() {
|
|
43666
|
+
return this.get("/api/marketplace/merchant/shipping/shipments");
|
|
43667
|
+
}
|
|
43668
|
+
/**
|
|
43669
|
+
* Update shipment status and tracking
|
|
43670
|
+
*
|
|
43671
|
+
* @param shipmentId - Shipment ID
|
|
43672
|
+
* @param request - Updated shipment data
|
|
43673
|
+
* @returns Updated shipment
|
|
43674
|
+
*
|
|
43675
|
+
* @example
|
|
43676
|
+
* ```typescript
|
|
43677
|
+
* await client.updateShipment("ship_123", {
|
|
43678
|
+
* status: "SHIPPED",
|
|
43679
|
+
* trackingNumber: "1Z999AA10123456784",
|
|
43680
|
+
* carrier: "UPS"
|
|
43681
|
+
* });
|
|
43682
|
+
* ```
|
|
43683
|
+
*/
|
|
43684
|
+
async updateShipment(shipmentId, request) {
|
|
43685
|
+
return this.patch(`/api/marketplace/merchant/shipping/shipments/${shipmentId}`, request);
|
|
43686
|
+
}
|
|
43687
|
+
// ============================================================================
|
|
43688
|
+
// Returns & Refunds
|
|
43689
|
+
// ============================================================================
|
|
43690
|
+
/**
|
|
43691
|
+
* List returns
|
|
43692
|
+
*
|
|
43693
|
+
* @returns List of returns for merchant's orders
|
|
43694
|
+
*
|
|
43695
|
+
* @example
|
|
43696
|
+
* ```typescript
|
|
43697
|
+
* const returns = await client.listReturns();
|
|
43698
|
+
* ```
|
|
43699
|
+
*/
|
|
43700
|
+
async listReturns() {
|
|
43701
|
+
return this.get("/api/marketplace/merchant/returns");
|
|
43702
|
+
}
|
|
43703
|
+
/**
|
|
43704
|
+
* Approve a return request
|
|
43705
|
+
*
|
|
43706
|
+
* @param returnId - Return ID
|
|
43707
|
+
* @returns Updated return
|
|
43708
|
+
*
|
|
43709
|
+
* @example
|
|
43710
|
+
* ```typescript
|
|
43711
|
+
* await client.approveReturn("return_123");
|
|
43712
|
+
* ```
|
|
43713
|
+
*/
|
|
43714
|
+
async approveReturn(returnId) {
|
|
43715
|
+
return this.post(`/api/marketplace/merchant/returns/${returnId}/approve`);
|
|
43716
|
+
}
|
|
43717
|
+
/**
|
|
43718
|
+
* Reject a return request
|
|
43719
|
+
*
|
|
43720
|
+
* @param returnId - Return ID
|
|
43721
|
+
* @returns Updated return
|
|
43722
|
+
*
|
|
43723
|
+
* @example
|
|
43724
|
+
* ```typescript
|
|
43725
|
+
* await client.rejectReturn("return_123");
|
|
43726
|
+
* ```
|
|
43727
|
+
*/
|
|
43728
|
+
async rejectReturn(returnId) {
|
|
43729
|
+
return this.post(`/api/marketplace/merchant/returns/${returnId}/reject`);
|
|
43730
|
+
}
|
|
43731
|
+
/**
|
|
43732
|
+
* Mark return as received
|
|
43733
|
+
*
|
|
43734
|
+
* @param returnId - Return ID
|
|
43735
|
+
* @returns Updated return
|
|
43736
|
+
*
|
|
43737
|
+
* @example
|
|
43738
|
+
* ```typescript
|
|
43739
|
+
* await client.markReturnReceived("return_123");
|
|
43740
|
+
* ```
|
|
43741
|
+
*/
|
|
43742
|
+
async markReturnReceived(returnId) {
|
|
43743
|
+
return this.post(`/api/marketplace/merchant/returns/${returnId}/received`);
|
|
43744
|
+
}
|
|
43745
|
+
/**
|
|
43746
|
+
* Process refund for return
|
|
43747
|
+
*
|
|
43748
|
+
* @param returnId - Return ID
|
|
43749
|
+
* @returns Updated return
|
|
43750
|
+
*
|
|
43751
|
+
* @example
|
|
43752
|
+
* ```typescript
|
|
43753
|
+
* await client.processRefund("return_123");
|
|
43754
|
+
* ```
|
|
43755
|
+
*/
|
|
43756
|
+
async processRefund(returnId) {
|
|
43757
|
+
return this.post(`/api/marketplace/merchant/returns/${returnId}/refunded`);
|
|
43758
|
+
}
|
|
43759
|
+
// ============================================================================
|
|
43760
|
+
// Reviews Management
|
|
43761
|
+
// ============================================================================
|
|
43762
|
+
/**
|
|
43763
|
+
* List reviews for merchant's products
|
|
43764
|
+
*
|
|
43765
|
+
* @returns List of reviews
|
|
43766
|
+
*
|
|
43767
|
+
* @example
|
|
43768
|
+
* ```typescript
|
|
43769
|
+
* const reviews = await client.listMerchantReviews();
|
|
43770
|
+
* ```
|
|
43771
|
+
*/
|
|
43772
|
+
async listMerchantReviews() {
|
|
43773
|
+
return this.get("/api/marketplace/merchant/reviews");
|
|
43774
|
+
}
|
|
43775
|
+
/**
|
|
43776
|
+
* Respond to a review
|
|
43777
|
+
*
|
|
43778
|
+
* @param reviewId - Review ID
|
|
43779
|
+
* @param request - Response data
|
|
43780
|
+
* @returns Updated review
|
|
43781
|
+
*
|
|
43782
|
+
* @example
|
|
43783
|
+
* ```typescript
|
|
43784
|
+
* await client.respondToReview("review_123", {
|
|
43785
|
+
* merchantResponse: "Thank you for your feedback!"
|
|
43786
|
+
* });
|
|
43787
|
+
* ```
|
|
43788
|
+
*/
|
|
43789
|
+
async respondToReview(reviewId, request) {
|
|
43790
|
+
return this.post(`/api/marketplace/merchant/reviews/${reviewId}/respond`, request);
|
|
43791
|
+
}
|
|
43792
|
+
/**
|
|
43793
|
+
* Flag a review as inappropriate
|
|
43794
|
+
*
|
|
43795
|
+
* @param reviewId - Review ID
|
|
43796
|
+
* @returns Updated review
|
|
43797
|
+
*
|
|
43798
|
+
* @example
|
|
43799
|
+
* ```typescript
|
|
43800
|
+
* await client.flagReview("review_123");
|
|
43801
|
+
* ```
|
|
43802
|
+
*/
|
|
43803
|
+
async flagReview(reviewId) {
|
|
43804
|
+
return this.post(`/api/marketplace/merchant/reviews/${reviewId}/flag`);
|
|
43805
|
+
}
|
|
43806
|
+
// ============================================================================
|
|
43807
|
+
// Messages
|
|
43808
|
+
// ============================================================================
|
|
43809
|
+
/**
|
|
43810
|
+
* List messages/conversations
|
|
43811
|
+
*
|
|
43812
|
+
* @returns List of conversations grouped by order
|
|
43813
|
+
*
|
|
43814
|
+
* @example
|
|
43815
|
+
* ```typescript
|
|
43816
|
+
* const messages = await client.listMessages();
|
|
43817
|
+
* console.log("Unread:", messages.stats.unread);
|
|
43818
|
+
* ```
|
|
43819
|
+
*/
|
|
43820
|
+
async listMessages() {
|
|
43821
|
+
return this.get("/api/marketplace/merchant/messages");
|
|
43822
|
+
}
|
|
43823
|
+
/**
|
|
43824
|
+
* Send a message to customer
|
|
43825
|
+
*
|
|
43826
|
+
* @param request - Message data
|
|
43827
|
+
* @returns Sent message
|
|
43828
|
+
*
|
|
43829
|
+
* @example
|
|
43830
|
+
* ```typescript
|
|
43831
|
+
* await client.sendMessage({
|
|
43832
|
+
* orderId: "ord_123",
|
|
43833
|
+
* recipientId: "user_456",
|
|
43834
|
+
* message: "Your order has been shipped!"
|
|
43835
|
+
* });
|
|
43836
|
+
* ```
|
|
43837
|
+
*/
|
|
43838
|
+
async sendMessage(request) {
|
|
43839
|
+
return this.post("/api/marketplace/merchant/messages/send", request);
|
|
43840
|
+
}
|
|
43841
|
+
/**
|
|
43842
|
+
* Mark message as read
|
|
43843
|
+
*
|
|
43844
|
+
* @param messageId - Message ID
|
|
43845
|
+
* @returns Updated message
|
|
43846
|
+
*
|
|
43847
|
+
* @example
|
|
43848
|
+
* ```typescript
|
|
43849
|
+
* await client.markMessageRead("msg_123");
|
|
43850
|
+
* ```
|
|
43851
|
+
*/
|
|
43852
|
+
async markMessageRead(messageId) {
|
|
43853
|
+
return this.patch(`/api/marketplace/merchant/messages/${messageId}/read`);
|
|
43854
|
+
}
|
|
43855
|
+
// ============================================================================
|
|
43856
|
+
// Media Library
|
|
43857
|
+
// ============================================================================
|
|
43858
|
+
/**
|
|
43859
|
+
* List media assets
|
|
43860
|
+
*
|
|
43861
|
+
* @param params - Query parameters
|
|
43862
|
+
* @returns Paginated list of media assets
|
|
43863
|
+
*
|
|
43864
|
+
* @example
|
|
43865
|
+
* ```typescript
|
|
43866
|
+
* const media = await client.listMediaAssets({ limit: 50, offset: 0 });
|
|
43867
|
+
* ```
|
|
43868
|
+
*/
|
|
43869
|
+
async listMediaAssets(params) {
|
|
43870
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
43871
|
+
return this.get(`/api/marketplace/merchant/media${queryString}`);
|
|
43872
|
+
}
|
|
43873
|
+
/**
|
|
43874
|
+
* Upload a media asset
|
|
43875
|
+
*
|
|
43876
|
+
* @param file - File to upload (max 10MB, images only)
|
|
43877
|
+
* @returns Uploaded asset
|
|
43878
|
+
*
|
|
43879
|
+
* @example
|
|
43880
|
+
* ```typescript
|
|
43881
|
+
* const formData = new FormData();
|
|
43882
|
+
* formData.append("file", imageFile);
|
|
43883
|
+
*
|
|
43884
|
+
* const asset = await client.uploadMediaAsset(formData);
|
|
43885
|
+
* console.log("Uploaded:", asset.asset.blobUrl);
|
|
43886
|
+
* ```
|
|
43887
|
+
*/
|
|
43888
|
+
async uploadMediaAsset(formData) {
|
|
43889
|
+
return this.post("/api/marketplace/merchant/media/upload", formData, {
|
|
43890
|
+
headers: { "Content-Type": "multipart/form-data" }
|
|
43891
|
+
});
|
|
43892
|
+
}
|
|
43893
|
+
/**
|
|
43894
|
+
* Delete a media asset
|
|
43895
|
+
*
|
|
43896
|
+
* @param assetId - Asset ID
|
|
43897
|
+
* @returns Success response
|
|
43898
|
+
*
|
|
43899
|
+
* @example
|
|
43900
|
+
* ```typescript
|
|
43901
|
+
* await client.deleteMediaAsset("asset_123");
|
|
43902
|
+
* ```
|
|
43903
|
+
*/
|
|
43904
|
+
async deleteMediaAsset(assetId) {
|
|
43905
|
+
return this.delete(`/api/marketplace/merchant/media?id=${assetId}`);
|
|
43906
|
+
}
|
|
43907
|
+
// ============================================================================
|
|
43908
|
+
// Banners
|
|
43909
|
+
// ============================================================================
|
|
43910
|
+
/**
|
|
43911
|
+
* List merchant's banners
|
|
43912
|
+
*
|
|
43913
|
+
* @returns List of banners
|
|
43914
|
+
*
|
|
43915
|
+
* @example
|
|
43916
|
+
* ```typescript
|
|
43917
|
+
* const banners = await client.listMerchantBanners();
|
|
43918
|
+
* ```
|
|
43919
|
+
*/
|
|
43920
|
+
async listMerchantBanners() {
|
|
43921
|
+
return this.get("/api/marketplace/merchant/banners");
|
|
43922
|
+
}
|
|
43923
|
+
/**
|
|
43924
|
+
* Create a promotional banner
|
|
43925
|
+
*
|
|
43926
|
+
* @param request - Banner data
|
|
43927
|
+
* @returns Created banner
|
|
43928
|
+
*
|
|
43929
|
+
* @example
|
|
43930
|
+
* ```typescript
|
|
43931
|
+
* const banner = await client.createBanner({
|
|
43932
|
+
* title: "Summer Sale",
|
|
43933
|
+
* imageUrl: "https://...",
|
|
43934
|
+
* linkUrl: "/products?category=summer",
|
|
43935
|
+
* ctaText: "Shop Now",
|
|
43936
|
+
* priority: 10
|
|
43937
|
+
* });
|
|
43938
|
+
* ```
|
|
43939
|
+
*/
|
|
43940
|
+
async createBanner(request) {
|
|
43941
|
+
return this.post("/api/marketplace/merchant/banners", request);
|
|
43942
|
+
}
|
|
43943
|
+
/**
|
|
43944
|
+
* Get banner details
|
|
43945
|
+
*
|
|
43946
|
+
* @param bannerId - Banner ID
|
|
43947
|
+
* @returns Banner details
|
|
43948
|
+
*
|
|
43949
|
+
* @example
|
|
43950
|
+
* ```typescript
|
|
43951
|
+
* const banner = await client.getBanner("banner_123");
|
|
43952
|
+
* ```
|
|
43953
|
+
*/
|
|
43954
|
+
async getBanner(bannerId) {
|
|
43955
|
+
return this.get(`/api/marketplace/merchant/banners/${bannerId}`);
|
|
43956
|
+
}
|
|
43957
|
+
/**
|
|
43958
|
+
* Update a banner
|
|
43959
|
+
*
|
|
43960
|
+
* @param bannerId - Banner ID
|
|
43961
|
+
* @param request - Updated banner data
|
|
43962
|
+
* @returns Updated banner
|
|
43963
|
+
*
|
|
43964
|
+
* @example
|
|
43965
|
+
* ```typescript
|
|
43966
|
+
* await client.updateBanner("banner_123", {
|
|
43967
|
+
* isActive: false
|
|
43968
|
+
* });
|
|
43969
|
+
* ```
|
|
43970
|
+
*/
|
|
43971
|
+
async updateBanner(bannerId, request) {
|
|
43972
|
+
return this.put(`/api/marketplace/merchant/banners/${bannerId}`, request);
|
|
43973
|
+
}
|
|
43974
|
+
/**
|
|
43975
|
+
* Delete a banner
|
|
43976
|
+
*
|
|
43977
|
+
* @param bannerId - Banner ID
|
|
43978
|
+
* @returns Success response
|
|
43979
|
+
*
|
|
43980
|
+
* @example
|
|
43981
|
+
* ```typescript
|
|
43982
|
+
* await client.deleteBanner("banner_123");
|
|
43983
|
+
* ```
|
|
43984
|
+
*/
|
|
43985
|
+
async deleteBanner(bannerId) {
|
|
43986
|
+
return this.delete(`/api/marketplace/merchant/banners/${bannerId}`);
|
|
43987
|
+
}
|
|
43988
|
+
// ============================================================================
|
|
43989
|
+
// Analytics
|
|
43990
|
+
// ============================================================================
|
|
43991
|
+
/**
|
|
43992
|
+
* Get merchant analytics
|
|
43993
|
+
*
|
|
43994
|
+
* @param params - Query parameters
|
|
43995
|
+
* @returns Analytics data with overview, charts, and insights
|
|
43996
|
+
*
|
|
43997
|
+
* @example
|
|
43998
|
+
* ```typescript
|
|
43999
|
+
* const analytics = await client.getAnalytics({ range: "30days" });
|
|
44000
|
+
* console.log("Revenue:", analytics.overview.totalRevenue);
|
|
44001
|
+
* console.log("Orders:", analytics.overview.totalOrders);
|
|
44002
|
+
* ```
|
|
44003
|
+
*/
|
|
44004
|
+
async getAnalytics(params) {
|
|
44005
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
44006
|
+
return this.get(`/api/marketplace/merchant/analytics${queryString}`);
|
|
44007
|
+
}
|
|
44008
|
+
// ============================================================================
|
|
44009
|
+
// Inventory
|
|
44010
|
+
// ============================================================================
|
|
44011
|
+
/**
|
|
44012
|
+
* Get inventory audit log
|
|
44013
|
+
*
|
|
44014
|
+
* @returns Recent inventory audit entries (last 500)
|
|
44015
|
+
*
|
|
44016
|
+
* @example
|
|
44017
|
+
* ```typescript
|
|
44018
|
+
* const audit = await client.getInventoryAudit();
|
|
44019
|
+
* audit.entries.forEach(e => {
|
|
44020
|
+
* console.log(e.action, e.product.title, e.changeAmount);
|
|
44021
|
+
* });
|
|
44022
|
+
* ```
|
|
44023
|
+
*/
|
|
44024
|
+
async getInventoryAudit() {
|
|
44025
|
+
return this.get("/api/marketplace/merchant/inventory/audit");
|
|
44026
|
+
}
|
|
44027
|
+
// ============================================================================
|
|
44028
|
+
// Tax Management
|
|
44029
|
+
// ============================================================================
|
|
44030
|
+
/**
|
|
44031
|
+
* Get tax settings
|
|
44032
|
+
*
|
|
44033
|
+
* @returns Tax settings
|
|
44034
|
+
*
|
|
44035
|
+
* @example
|
|
44036
|
+
* ```typescript
|
|
44037
|
+
* const settings = await client.getTaxSettings();
|
|
44038
|
+
* console.log("Tax enabled:", settings.settings.taxEnabled);
|
|
44039
|
+
* ```
|
|
44040
|
+
*/
|
|
44041
|
+
async getTaxSettings() {
|
|
44042
|
+
return this.get("/api/marketplace/merchant/tax-settings");
|
|
44043
|
+
}
|
|
44044
|
+
/**
|
|
44045
|
+
* Update tax settings
|
|
44046
|
+
*
|
|
44047
|
+
* @param request - Updated settings
|
|
44048
|
+
* @returns Updated tax settings
|
|
44049
|
+
*
|
|
44050
|
+
* @example
|
|
44051
|
+
* ```typescript
|
|
44052
|
+
* await client.updateTaxSettings({
|
|
44053
|
+
* taxEnabled: true,
|
|
44054
|
+
* pricesIncludeTax: false,
|
|
44055
|
+
* defaultTaxBehavior: "CHARGE"
|
|
44056
|
+
* });
|
|
44057
|
+
* ```
|
|
44058
|
+
*/
|
|
44059
|
+
async updateTaxSettings(request) {
|
|
44060
|
+
return this.put("/api/marketplace/merchant/tax-settings", request);
|
|
44061
|
+
}
|
|
44062
|
+
/**
|
|
44063
|
+
* List tax rules
|
|
44064
|
+
*
|
|
44065
|
+
* @returns List of tax rules
|
|
44066
|
+
*
|
|
44067
|
+
* @example
|
|
44068
|
+
* ```typescript
|
|
44069
|
+
* const rules = await client.listTaxRules();
|
|
44070
|
+
* ```
|
|
44071
|
+
*/
|
|
44072
|
+
async listTaxRules() {
|
|
44073
|
+
return this.get("/api/marketplace/merchant/tax-rules");
|
|
44074
|
+
}
|
|
44075
|
+
/**
|
|
44076
|
+
* Create a tax rule
|
|
44077
|
+
*
|
|
44078
|
+
* @param request - Tax rule data
|
|
44079
|
+
* @returns Created tax rule
|
|
44080
|
+
*
|
|
44081
|
+
* @example
|
|
44082
|
+
* ```typescript
|
|
44083
|
+
* const rule = await client.createTaxRule({
|
|
44084
|
+
* country: "US",
|
|
44085
|
+
* region: "NY",
|
|
44086
|
+
* taxType: "SALES_TAX",
|
|
44087
|
+
* taxName: "NY Sales Tax",
|
|
44088
|
+
* taxRate: 8.875
|
|
44089
|
+
* });
|
|
44090
|
+
* ```
|
|
44091
|
+
*/
|
|
44092
|
+
async createTaxRule(request) {
|
|
44093
|
+
return this.post("/api/marketplace/merchant/tax-rules", request);
|
|
44094
|
+
}
|
|
44095
|
+
/**
|
|
44096
|
+
* Get tax rule details
|
|
44097
|
+
*
|
|
44098
|
+
* @param ruleId - Rule ID
|
|
44099
|
+
* @returns Tax rule details
|
|
44100
|
+
*
|
|
44101
|
+
* @example
|
|
44102
|
+
* ```typescript
|
|
44103
|
+
* const rule = await client.getTaxRule("rule_123");
|
|
44104
|
+
* ```
|
|
44105
|
+
*/
|
|
44106
|
+
async getTaxRule(ruleId) {
|
|
44107
|
+
return this.get(`/api/marketplace/merchant/tax-rules/${ruleId}`);
|
|
44108
|
+
}
|
|
44109
|
+
/**
|
|
44110
|
+
* Update a tax rule
|
|
44111
|
+
*
|
|
44112
|
+
* @param ruleId - Rule ID
|
|
44113
|
+
* @param request - Updated rule data
|
|
44114
|
+
* @returns Updated tax rule
|
|
44115
|
+
*
|
|
44116
|
+
* @example
|
|
44117
|
+
* ```typescript
|
|
44118
|
+
* await client.updateTaxRule("rule_123", {
|
|
44119
|
+
* taxRate: 9.0
|
|
44120
|
+
* });
|
|
44121
|
+
* ```
|
|
44122
|
+
*/
|
|
44123
|
+
async updateTaxRule(ruleId, request) {
|
|
44124
|
+
return this.put(`/api/marketplace/merchant/tax-rules/${ruleId}`, request);
|
|
44125
|
+
}
|
|
44126
|
+
/**
|
|
44127
|
+
* Delete a tax rule
|
|
44128
|
+
*
|
|
44129
|
+
* @param ruleId - Rule ID
|
|
44130
|
+
* @returns Success response
|
|
44131
|
+
*
|
|
44132
|
+
* @example
|
|
44133
|
+
* ```typescript
|
|
44134
|
+
* await client.deleteTaxRule("rule_123");
|
|
44135
|
+
* ```
|
|
44136
|
+
*/
|
|
44137
|
+
async deleteTaxRule(ruleId) {
|
|
44138
|
+
return this.delete(`/api/marketplace/merchant/tax-rules/${ruleId}`);
|
|
44139
|
+
}
|
|
44140
|
+
/**
|
|
44141
|
+
* List tax nexus locations
|
|
44142
|
+
*
|
|
44143
|
+
* @returns List of nexus locations
|
|
44144
|
+
*
|
|
44145
|
+
* @example
|
|
44146
|
+
* ```typescript
|
|
44147
|
+
* const nexus = await client.listTaxNexus();
|
|
44148
|
+
* ```
|
|
44149
|
+
*/
|
|
44150
|
+
async listTaxNexus() {
|
|
44151
|
+
return this.get("/api/marketplace/merchant/tax-nexus");
|
|
44152
|
+
}
|
|
44153
|
+
/**
|
|
44154
|
+
* Add a tax nexus location
|
|
44155
|
+
*
|
|
44156
|
+
* @param request - Nexus data
|
|
44157
|
+
* @returns Created nexus
|
|
44158
|
+
*
|
|
44159
|
+
* @example
|
|
44160
|
+
* ```typescript
|
|
44161
|
+
* const nexus = await client.createTaxNexus({
|
|
44162
|
+
* country: "US",
|
|
44163
|
+
* region: "CA",
|
|
44164
|
+
* registrationId: "123456789"
|
|
44165
|
+
* });
|
|
44166
|
+
* ```
|
|
44167
|
+
*/
|
|
44168
|
+
async createTaxNexus(request) {
|
|
44169
|
+
return this.post("/api/marketplace/merchant/tax-nexus", request);
|
|
44170
|
+
}
|
|
44171
|
+
/**
|
|
44172
|
+
* Update a tax nexus location
|
|
44173
|
+
*
|
|
44174
|
+
* @param nexusId - Nexus ID
|
|
44175
|
+
* @param request - Updated nexus data
|
|
44176
|
+
* @returns Updated nexus
|
|
44177
|
+
*
|
|
44178
|
+
* @example
|
|
44179
|
+
* ```typescript
|
|
44180
|
+
* await client.updateTaxNexus("nexus_123", {
|
|
44181
|
+
* registrationId: "987654321"
|
|
44182
|
+
* });
|
|
44183
|
+
* ```
|
|
44184
|
+
*/
|
|
44185
|
+
async updateTaxNexus(nexusId, request) {
|
|
44186
|
+
return this.put(`/api/marketplace/merchant/tax-nexus/${nexusId}`, request);
|
|
44187
|
+
}
|
|
44188
|
+
/**
|
|
44189
|
+
* Delete a tax nexus location
|
|
44190
|
+
*
|
|
44191
|
+
* @param nexusId - Nexus ID
|
|
44192
|
+
* @returns Success response
|
|
44193
|
+
*
|
|
44194
|
+
* @example
|
|
44195
|
+
* ```typescript
|
|
44196
|
+
* await client.deleteTaxNexus("nexus_123");
|
|
44197
|
+
* ```
|
|
44198
|
+
*/
|
|
44199
|
+
async deleteTaxNexus(nexusId) {
|
|
44200
|
+
return this.delete(`/api/marketplace/merchant/tax-nexus/${nexusId}`);
|
|
44201
|
+
}
|
|
44202
|
+
/**
|
|
44203
|
+
* List tax reports
|
|
44204
|
+
*
|
|
44205
|
+
* @param params - Query parameters
|
|
44206
|
+
* @returns Paginated list of tax reports
|
|
44207
|
+
*
|
|
44208
|
+
* @example
|
|
44209
|
+
* ```typescript
|
|
44210
|
+
* const reports = await client.listTaxReports({ limit: 20, offset: 0 });
|
|
44211
|
+
*
|
|
44212
|
+
* // Get summary for a specific year
|
|
44213
|
+
* const summary = await client.listTaxReports({ year: 2025 });
|
|
44214
|
+
* ```
|
|
44215
|
+
*/
|
|
44216
|
+
async listTaxReports(params) {
|
|
44217
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
44218
|
+
return this.get(`/api/marketplace/merchant/tax-reports${queryString}`);
|
|
44219
|
+
}
|
|
44220
|
+
/**
|
|
44221
|
+
* Generate a tax report
|
|
44222
|
+
*
|
|
44223
|
+
* @param request - Report generation request
|
|
44224
|
+
* @returns Generated report
|
|
44225
|
+
*
|
|
44226
|
+
* @example
|
|
44227
|
+
* ```typescript
|
|
44228
|
+
* const report = await client.generateTaxReport({
|
|
44229
|
+
* periodType: "MONTHLY",
|
|
44230
|
+
* year: 2025,
|
|
44231
|
+
* period: 1 // January
|
|
44232
|
+
* });
|
|
44233
|
+
* ```
|
|
44234
|
+
*/
|
|
44235
|
+
async generateTaxReport(request) {
|
|
44236
|
+
return this.post("/api/marketplace/merchant/tax-reports/generate", request);
|
|
44237
|
+
}
|
|
44238
|
+
/**
|
|
44239
|
+
* Get tax report details
|
|
44240
|
+
*
|
|
44241
|
+
* @param reportId - Report ID
|
|
44242
|
+
* @returns Report with detailed records
|
|
44243
|
+
*
|
|
44244
|
+
* @example
|
|
44245
|
+
* ```typescript
|
|
44246
|
+
* const report = await client.getTaxReport("report_123");
|
|
44247
|
+
* console.log("Total tax:", report.report.totalTax);
|
|
44248
|
+
* ```
|
|
44249
|
+
*/
|
|
44250
|
+
async getTaxReport(reportId) {
|
|
44251
|
+
return this.get(`/api/marketplace/merchant/tax-reports/${reportId}`);
|
|
44252
|
+
}
|
|
44253
|
+
/**
|
|
44254
|
+
* Update tax report status
|
|
44255
|
+
*
|
|
44256
|
+
* @param reportId - Report ID
|
|
44257
|
+
* @param request - Status update
|
|
44258
|
+
* @returns Updated report
|
|
44259
|
+
*
|
|
44260
|
+
* @example
|
|
44261
|
+
* ```typescript
|
|
44262
|
+
* await client.updateTaxReportStatus("report_123", {
|
|
44263
|
+
* status: "FINALIZED"
|
|
44264
|
+
* });
|
|
44265
|
+
* ```
|
|
44266
|
+
*/
|
|
44267
|
+
async updateTaxReportStatus(reportId, request) {
|
|
44268
|
+
return this.put(`/api/marketplace/merchant/tax-reports/${reportId}`, request);
|
|
44269
|
+
}
|
|
44270
|
+
/**
|
|
44271
|
+
* Export tax report as CSV
|
|
44272
|
+
*
|
|
44273
|
+
* @param reportId - Report ID
|
|
44274
|
+
* @returns CSV file data
|
|
44275
|
+
*
|
|
44276
|
+
* @example
|
|
44277
|
+
* ```typescript
|
|
44278
|
+
* const csv = await client.exportTaxReport("report_123");
|
|
44279
|
+
* // Save or download the CSV
|
|
44280
|
+
* ```
|
|
44281
|
+
*/
|
|
44282
|
+
async exportTaxReport(reportId) {
|
|
44283
|
+
return this.get(`/api/marketplace/merchant/tax-reports/${reportId}/export`);
|
|
44284
|
+
}
|
|
44285
|
+
};
|
|
44286
|
+
|
|
44287
|
+
// lib/ecommerce/types/enums.ts
|
|
44288
|
+
var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
44289
|
+
OrderStatus2["CREATED"] = "CREATED";
|
|
44290
|
+
OrderStatus2["AWAITING_DEPOSIT"] = "AWAITING_DEPOSIT";
|
|
44291
|
+
OrderStatus2["PAYMENT_RESERVED"] = "PAYMENT_RESERVED";
|
|
44292
|
+
OrderStatus2["MERCHANT_ACCEPTED"] = "MERCHANT_ACCEPTED";
|
|
44293
|
+
OrderStatus2["SHIPPED"] = "SHIPPED";
|
|
44294
|
+
OrderStatus2["DELIVERED"] = "DELIVERED";
|
|
44295
|
+
OrderStatus2["CANCELLED"] = "CANCELLED";
|
|
44296
|
+
OrderStatus2["CONFIRMED"] = "CONFIRMED";
|
|
44297
|
+
OrderStatus2["COMPLETED"] = "COMPLETED";
|
|
44298
|
+
return OrderStatus2;
|
|
44299
|
+
})(OrderStatus || {});
|
|
44300
|
+
var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
|
|
44301
|
+
PaymentMethod2["USDC_ESCROW"] = "USDC_ESCROW";
|
|
44302
|
+
PaymentMethod2["POINTS"] = "POINTS";
|
|
44303
|
+
return PaymentMethod2;
|
|
44304
|
+
})(PaymentMethod || {});
|
|
44305
|
+
var PaymentStatus = /* @__PURE__ */ ((PaymentStatus2) => {
|
|
44306
|
+
PaymentStatus2["PENDING"] = "PENDING";
|
|
44307
|
+
PaymentStatus2["RESERVED"] = "RESERVED";
|
|
44308
|
+
PaymentStatus2["COMPLETED"] = "COMPLETED";
|
|
44309
|
+
PaymentStatus2["FAILED"] = "FAILED";
|
|
44310
|
+
PaymentStatus2["REFUNDED"] = "REFUNDED";
|
|
44311
|
+
return PaymentStatus2;
|
|
44312
|
+
})(PaymentStatus || {});
|
|
44313
|
+
var MerchantStatus = /* @__PURE__ */ ((MerchantStatus2) => {
|
|
44314
|
+
MerchantStatus2["ACTIVE"] = "ACTIVE";
|
|
44315
|
+
MerchantStatus2["SUSPENDED"] = "SUSPENDED";
|
|
44316
|
+
MerchantStatus2["PENDING"] = "PENDING";
|
|
44317
|
+
return MerchantStatus2;
|
|
44318
|
+
})(MerchantStatus || {});
|
|
44319
|
+
var ShipmentStatus = /* @__PURE__ */ ((ShipmentStatus2) => {
|
|
44320
|
+
ShipmentStatus2["PENDING"] = "PENDING";
|
|
44321
|
+
ShipmentStatus2["SHIPPED"] = "SHIPPED";
|
|
44322
|
+
ShipmentStatus2["DELIVERED"] = "DELIVERED";
|
|
44323
|
+
ShipmentStatus2["FAILED"] = "FAILED";
|
|
44324
|
+
return ShipmentStatus2;
|
|
44325
|
+
})(ShipmentStatus || {});
|
|
44326
|
+
var ReturnStatus = /* @__PURE__ */ ((ReturnStatus2) => {
|
|
44327
|
+
ReturnStatus2["REQUESTED"] = "REQUESTED";
|
|
44328
|
+
ReturnStatus2["APPROVED"] = "APPROVED";
|
|
44329
|
+
ReturnStatus2["REJECTED"] = "REJECTED";
|
|
44330
|
+
ReturnStatus2["SHIPPED_BACK"] = "SHIPPED_BACK";
|
|
44331
|
+
ReturnStatus2["RECEIVED"] = "RECEIVED";
|
|
44332
|
+
ReturnStatus2["REFUNDED"] = "REFUNDED";
|
|
44333
|
+
return ReturnStatus2;
|
|
44334
|
+
})(ReturnStatus || {});
|
|
44335
|
+
var ReviewStatus = /* @__PURE__ */ ((ReviewStatus2) => {
|
|
44336
|
+
ReviewStatus2["PENDING"] = "PENDING";
|
|
44337
|
+
ReviewStatus2["RESPONDED"] = "RESPONDED";
|
|
44338
|
+
ReviewStatus2["FLAGGED"] = "FLAGGED";
|
|
44339
|
+
return ReviewStatus2;
|
|
44340
|
+
})(ReviewStatus || {});
|
|
44341
|
+
var DiscountType = /* @__PURE__ */ ((DiscountType2) => {
|
|
44342
|
+
DiscountType2["PERCENTAGE"] = "PERCENTAGE";
|
|
44343
|
+
DiscountType2["FIXED_AMOUNT"] = "FIXED_AMOUNT";
|
|
44344
|
+
DiscountType2["BUY_X_GET_Y"] = "BUY_X_GET_Y";
|
|
44345
|
+
DiscountType2["FREE_SHIPPING"] = "FREE_SHIPPING";
|
|
44346
|
+
return DiscountType2;
|
|
44347
|
+
})(DiscountType || {});
|
|
44348
|
+
var DiscountMethod = /* @__PURE__ */ ((DiscountMethod2) => {
|
|
44349
|
+
DiscountMethod2["CODE"] = "CODE";
|
|
44350
|
+
DiscountMethod2["AUTOMATIC"] = "AUTOMATIC";
|
|
44351
|
+
return DiscountMethod2;
|
|
44352
|
+
})(DiscountMethod || {});
|
|
44353
|
+
var DiscountScope = /* @__PURE__ */ ((DiscountScope2) => {
|
|
44354
|
+
DiscountScope2["ORDER"] = "ORDER";
|
|
44355
|
+
DiscountScope2["PRODUCT"] = "PRODUCT";
|
|
44356
|
+
DiscountScope2["CATEGORY"] = "CATEGORY";
|
|
44357
|
+
DiscountScope2["SHIPPING"] = "SHIPPING";
|
|
44358
|
+
return DiscountScope2;
|
|
44359
|
+
})(DiscountScope || {});
|
|
44360
|
+
var BannerType = /* @__PURE__ */ ((BannerType2) => {
|
|
44361
|
+
BannerType2["HERO"] = "HERO";
|
|
44362
|
+
BannerType2["PROMO"] = "PROMO";
|
|
44363
|
+
BannerType2["FEATURED"] = "FEATURED";
|
|
44364
|
+
return BannerType2;
|
|
44365
|
+
})(BannerType || {});
|
|
44366
|
+
var TaxType = /* @__PURE__ */ ((TaxType2) => {
|
|
44367
|
+
TaxType2["SALES_TAX"] = "SALES_TAX";
|
|
44368
|
+
TaxType2["VAT"] = "VAT";
|
|
44369
|
+
TaxType2["GST"] = "GST";
|
|
44370
|
+
TaxType2["PST"] = "PST";
|
|
44371
|
+
TaxType2["HST"] = "HST";
|
|
44372
|
+
return TaxType2;
|
|
44373
|
+
})(TaxType || {});
|
|
44374
|
+
var TaxBehavior = /* @__PURE__ */ ((TaxBehavior2) => {
|
|
44375
|
+
TaxBehavior2["CHARGE"] = "CHARGE";
|
|
44376
|
+
TaxBehavior2["INCLUSIVE"] = "INCLUSIVE";
|
|
44377
|
+
TaxBehavior2["EXEMPT"] = "EXEMPT";
|
|
44378
|
+
return TaxBehavior2;
|
|
44379
|
+
})(TaxBehavior || {});
|
|
44380
|
+
var TaxReportPeriodType = /* @__PURE__ */ ((TaxReportPeriodType2) => {
|
|
44381
|
+
TaxReportPeriodType2["MONTHLY"] = "MONTHLY";
|
|
44382
|
+
TaxReportPeriodType2["QUARTERLY"] = "QUARTERLY";
|
|
44383
|
+
TaxReportPeriodType2["YEARLY"] = "YEARLY";
|
|
44384
|
+
return TaxReportPeriodType2;
|
|
44385
|
+
})(TaxReportPeriodType || {});
|
|
44386
|
+
var TaxReportStatus = /* @__PURE__ */ ((TaxReportStatus2) => {
|
|
44387
|
+
TaxReportStatus2["DRAFT"] = "DRAFT";
|
|
44388
|
+
TaxReportStatus2["FINALIZED"] = "FINALIZED";
|
|
44389
|
+
TaxReportStatus2["FILED"] = "FILED";
|
|
44390
|
+
return TaxReportStatus2;
|
|
44391
|
+
})(TaxReportStatus || {});
|
|
44392
|
+
var InventoryAuditAction = /* @__PURE__ */ ((InventoryAuditAction2) => {
|
|
44393
|
+
InventoryAuditAction2["CREATED"] = "CREATED";
|
|
44394
|
+
InventoryAuditAction2["UPDATED"] = "UPDATED";
|
|
44395
|
+
InventoryAuditAction2["RESERVED"] = "RESERVED";
|
|
44396
|
+
InventoryAuditAction2["DEDUCTED"] = "DEDUCTED";
|
|
44397
|
+
InventoryAuditAction2["RESTORED"] = "RESTORED";
|
|
44398
|
+
return InventoryAuditAction2;
|
|
44399
|
+
})(InventoryAuditAction || {});
|
|
44400
|
+
var SortOrder = /* @__PURE__ */ ((SortOrder2) => {
|
|
44401
|
+
SortOrder2["ASC"] = "asc";
|
|
44402
|
+
SortOrder2["DESC"] = "desc";
|
|
44403
|
+
return SortOrder2;
|
|
44404
|
+
})(SortOrder || {});
|
|
44405
|
+
var ProductSortBy = /* @__PURE__ */ ((ProductSortBy2) => {
|
|
44406
|
+
ProductSortBy2["DATE_DESC"] = "date_desc";
|
|
44407
|
+
ProductSortBy2["DATE_ASC"] = "date_asc";
|
|
44408
|
+
ProductSortBy2["PRICE_ASC"] = "price_asc";
|
|
44409
|
+
ProductSortBy2["PRICE_DESC"] = "price_desc";
|
|
44410
|
+
ProductSortBy2["POPULAR"] = "popular";
|
|
44411
|
+
ProductSortBy2["FEATURED"] = "featured";
|
|
44412
|
+
return ProductSortBy2;
|
|
44413
|
+
})(ProductSortBy || {});
|
|
44414
|
+
var ReviewSortBy = /* @__PURE__ */ ((ReviewSortBy2) => {
|
|
44415
|
+
ReviewSortBy2["NEWEST"] = "newest";
|
|
44416
|
+
ReviewSortBy2["HIGHEST"] = "highest";
|
|
44417
|
+
ReviewSortBy2["LOWEST"] = "lowest";
|
|
44418
|
+
return ReviewSortBy2;
|
|
44419
|
+
})(ReviewSortBy || {});
|
|
44420
|
+
|
|
44421
|
+
exports.AssetIdUtils = AssetIdUtils;
|
|
44422
|
+
exports.BannerType = BannerType;
|
|
44423
|
+
exports.BaseEcommerceClient = BaseEcommerceClient;
|
|
44424
|
+
exports.CloidClientCode = CloidClientCode;
|
|
44425
|
+
exports.CloidClientCodeNameById = CloidClientCodeNameById;
|
|
44426
|
+
exports.CustomerEcommerceClient = CustomerEcommerceClient;
|
|
44427
|
+
exports.DayOfWeek = DayOfWeek;
|
|
44428
|
+
exports.DiscountMethod = DiscountMethod;
|
|
44429
|
+
exports.DiscountScope = DiscountScope;
|
|
44430
|
+
exports.DiscountType = DiscountType;
|
|
44431
|
+
exports.EcommerceApiError = EcommerceApiError;
|
|
44432
|
+
exports.InstrumentClient = InstrumentClient;
|
|
44433
|
+
exports.InventoryAuditAction = InventoryAuditAction;
|
|
44434
|
+
exports.MerchantEcommerceClient = MerchantEcommerceClient;
|
|
44435
|
+
exports.MerchantStatus = MerchantStatus;
|
|
44436
|
+
exports.MetadataClient = MetadataClient;
|
|
44437
|
+
exports.OrderStatus = OrderStatus;
|
|
44438
|
+
exports.PUP_TOKEN_ADDRESS = PUP_TOKEN_ADDRESS;
|
|
44439
|
+
exports.PUP_TOKEN_THRESHOLDS = PUP_TOKEN_THRESHOLDS;
|
|
44440
|
+
exports.PaymentMethod = PaymentMethod;
|
|
44441
|
+
exports.PaymentStatus = PaymentStatus;
|
|
44442
|
+
exports.ProductSortBy = ProductSortBy;
|
|
44443
|
+
exports.ROOT_DEX = ROOT_DEX;
|
|
44444
|
+
exports.ReturnStatus = ReturnStatus;
|
|
44445
|
+
exports.ReviewSortBy = ReviewSortBy;
|
|
44446
|
+
exports.ReviewStatus = ReviewStatus;
|
|
44447
|
+
exports.ShipmentStatus = ShipmentStatus;
|
|
44448
|
+
exports.SortOrder = SortOrder;
|
|
44449
|
+
exports.TARGET_APPROVED_MAX_BUILDER_FEE = TARGET_APPROVED_MAX_BUILDER_FEE;
|
|
44450
|
+
exports.TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT = TARGET_APPROVED_MAX_BUILDER_FEE_PERCENT;
|
|
44451
|
+
exports.TESTNET_USDC_SPOT_TOKEN = TESTNET_USDC_SPOT_TOKEN;
|
|
44452
|
+
exports.TaxBehavior = TaxBehavior;
|
|
44453
|
+
exports.TaxReportPeriodType = TaxReportPeriodType;
|
|
44454
|
+
exports.TaxReportStatus = TaxReportStatus;
|
|
44455
|
+
exports.TaxType = TaxType;
|
|
44456
|
+
exports.USDC_SPOT_TOKEN = USDC_SPOT_TOKEN;
|
|
44457
|
+
exports.UserDexAbstractionTypes = UserDexAbstractionTypes;
|
|
44458
|
+
exports.WidgetType = WidgetType;
|
|
44459
|
+
exports.WidgetTypeById = WidgetTypeById;
|
|
44460
|
+
exports.XP_BOOST_PERCENTAGES = XP_BOOST_PERCENTAGES;
|
|
44461
|
+
exports.buildCloid = buildCloid;
|
|
44462
|
+
exports.buildQueryString = buildQueryString;
|
|
44463
|
+
exports.calculateBoostPercentage = calculateBoostPercentage;
|
|
44464
|
+
exports.calculateDiscountAmount = calculateDiscountAmount;
|
|
44465
|
+
exports.calculateFinalPrice = calculateFinalPrice;
|
|
44466
|
+
exports.calculateTotalPupAmount = calculateTotalPupAmount;
|
|
44467
|
+
exports.decodeSlug = decodeSlug;
|
|
44468
|
+
exports.enableHip3DexAbstractionWithAgent = enableHip3DexAbstractionWithAgent;
|
|
44469
|
+
exports.encodeSlug = encodeSlug;
|
|
44470
|
+
exports.floorUtcDay = floorUtcDay;
|
|
44471
|
+
exports.floorUtcHour = floorUtcHour;
|
|
44472
|
+
exports.floorUtcMinutes = floorUtcMinutes;
|
|
44473
|
+
exports.floorUtcWeek = floorUtcWeek;
|
|
44474
|
+
exports.formatPrice = formatPrice;
|
|
44475
|
+
exports.formatPriceAndSize = formatPriceAndSize;
|
|
44476
|
+
exports.formatPriceForDisplay = formatPriceForDisplay;
|
|
44477
|
+
exports.formatPriceForOrder = formatPriceForOrder;
|
|
44478
|
+
exports.formatSizeForDisplay = formatSizeForDisplay;
|
|
44479
|
+
exports.formatSizeForOrder = formatSizeForOrder;
|
|
44480
|
+
exports.getAllPerpsMeta = getAllPerpsMeta;
|
|
44481
|
+
exports.getApprovalAmount = getApprovalAmount;
|
|
44482
|
+
exports.getBackoffDelay = getBackoffDelay;
|
|
44483
|
+
exports.getClientCodeNameById = getClientCodeNameById;
|
|
44484
|
+
exports.getCloid = getCloid;
|
|
44485
|
+
exports.getDexFromCollateralTokenSymbol = getDexFromCollateralTokenSymbol;
|
|
44486
|
+
exports.getDisplayMarketSymbol = getDisplayMarketSymbol;
|
|
44487
|
+
exports.getHip3Dex = getHip3Dex;
|
|
44488
|
+
exports.getHip3DexAbstraction = getHip3DexAbstraction;
|
|
44489
|
+
exports.getLatestCompletedWeek = getLatestCompletedWeek;
|
|
44490
|
+
exports.getNextTierInfo = getNextTierInfo;
|
|
44491
|
+
exports.getPriceDecimals = getPriceDecimals;
|
|
44492
|
+
exports.getStaticCollateralTokenByDex = getStaticCollateralTokenByDex;
|
|
44493
|
+
exports.getStaticCollateralTokenSymbol = getStaticCollateralTokenSymbol;
|
|
44494
|
+
exports.getWidgetTypeById = getWidgetTypeById;
|
|
44495
|
+
exports.isBasedCloid = isBasedCloid;
|
|
44496
|
+
exports.isClientCode = isClientCode;
|
|
44497
|
+
exports.isHip3Symbol = isHip3Symbol;
|
|
44498
|
+
exports.isMiniAppCloid = isMiniAppCloid;
|
|
44499
|
+
exports.isMiniAppTriggeredCloid = isMiniAppTriggeredCloid;
|
|
44500
|
+
exports.isRetryableError = isRetryableError;
|
|
44501
|
+
exports.isSpotSymbol = isSpotSymbol;
|
|
44502
|
+
exports.isStableQuoteToken = isStableQuoteToken;
|
|
44503
|
+
exports.isTenantCloid = isTenantCloid;
|
|
44504
|
+
exports.isTrackingIdCloid = isTrackingIdCloid;
|
|
44505
|
+
exports.isValidAddress = isValidAddress;
|
|
44506
|
+
exports.isValidEmail = isValidEmail;
|
|
44507
|
+
exports.isWidgetType = isWidgetType;
|
|
44508
|
+
exports.makeUtcRounder = makeUtcRounder;
|
|
44509
|
+
exports.normaliseSlug = normaliseSlug;
|
|
44510
|
+
exports.normaliseTrackingId = normaliseTrackingId;
|
|
44511
|
+
exports.normalizeAirdropAmount = normalizeAirdropAmount;
|
|
44512
|
+
exports.parseCloid = parseCloid;
|
|
44513
|
+
exports.parseError = parseError;
|
|
44514
|
+
exports.retryWithBackoff = retryWithBackoff;
|
|
44515
|
+
exports.setHip3DexAbstraction = setHip3DexAbstraction;
|
|
44516
|
+
exports.sleep = sleep;
|
|
44517
|
+
exports.stableQuoteTokens = stableQuoteTokens;
|
|
44518
|
+
exports.truncateAddress = truncateAddress;
|