@nexusmutual/sdk 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data/products.json +16 -16
- package/dist/data/version.json +1 -1
- package/dist/index.d.mts +29 -20
- package/dist/index.d.ts +29 -20
- package/dist/index.js +52 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -166,6 +166,7 @@ __export(src_exports, {
|
|
|
166
166
|
NEXUS_MUTUAL_DAO_TREASURY_ADDRESS: () => NEXUS_MUTUAL_DAO_TREASURY_ADDRESS,
|
|
167
167
|
NO_COMMISSION: () => NO_COMMISSION,
|
|
168
168
|
NO_COMMISSION_DESTINATION: () => NO_COMMISSION_DESTINATION,
|
|
169
|
+
PaymentAsset: () => PaymentAsset,
|
|
169
170
|
ProductCategoryEnum: () => ProductCategoryEnum,
|
|
170
171
|
ProductTypes: () => ProductTypes,
|
|
171
172
|
SHERLOCK_BUG_BOUNTY_COMMISSION_RATIO: () => SHERLOCK_BUG_BOUNTY_COMMISSION_RATIO,
|
|
@@ -968,8 +969,17 @@ var CoverAsset = /* @__PURE__ */ ((CoverAsset2) => {
|
|
|
968
969
|
CoverAsset2[CoverAsset2["ETH"] = 0] = "ETH";
|
|
969
970
|
CoverAsset2[CoverAsset2["DAI"] = 1] = "DAI";
|
|
970
971
|
CoverAsset2[CoverAsset2["USDC"] = 6] = "USDC";
|
|
972
|
+
CoverAsset2[CoverAsset2["cbBTC"] = 7] = "cbBTC";
|
|
971
973
|
return CoverAsset2;
|
|
972
974
|
})(CoverAsset || {});
|
|
975
|
+
var PaymentAsset = /* @__PURE__ */ ((PaymentAsset2) => {
|
|
976
|
+
PaymentAsset2[PaymentAsset2["ETH"] = 0] = "ETH";
|
|
977
|
+
PaymentAsset2[PaymentAsset2["DAI"] = 1] = "DAI";
|
|
978
|
+
PaymentAsset2[PaymentAsset2["USDC"] = 6] = "USDC";
|
|
979
|
+
PaymentAsset2[PaymentAsset2["cbBTC"] = 7] = "cbBTC";
|
|
980
|
+
PaymentAsset2[PaymentAsset2["NXM"] = 255] = "NXM";
|
|
981
|
+
return PaymentAsset2;
|
|
982
|
+
})(PaymentAsset || {});
|
|
973
983
|
var CoverId = /* @__PURE__ */ ((CoverId2) => {
|
|
974
984
|
CoverId2[CoverId2["BUY"] = 0] = "BUY";
|
|
975
985
|
return CoverId2;
|
|
@@ -1075,6 +1085,7 @@ __export(constants_exports, {
|
|
|
1075
1085
|
NEXUS_MUTUAL_DAO_TREASURY_ADDRESS: () => NEXUS_MUTUAL_DAO_TREASURY_ADDRESS,
|
|
1076
1086
|
NO_COMMISSION: () => NO_COMMISSION,
|
|
1077
1087
|
NO_COMMISSION_DESTINATION: () => NO_COMMISSION_DESTINATION,
|
|
1088
|
+
PaymentAsset: () => PaymentAsset,
|
|
1078
1089
|
ProductCategoryEnum: () => ProductCategoryEnum,
|
|
1079
1090
|
SHERLOCK_BUG_BOUNTY_COMMISSION_RATIO: () => SHERLOCK_BUG_BOUNTY_COMMISSION_RATIO,
|
|
1080
1091
|
SLIPPAGE_DENOMINATOR: () => SLIPPAGE_DENOMINATOR,
|
|
@@ -1892,7 +1903,7 @@ var validateIPFSContent = (type, content) => {
|
|
|
1892
1903
|
};
|
|
1893
1904
|
|
|
1894
1905
|
// generated/version.json
|
|
1895
|
-
var version = "0.
|
|
1906
|
+
var version = "0.17.0";
|
|
1896
1907
|
|
|
1897
1908
|
// src/ipfs/uploadIPFSContent.ts
|
|
1898
1909
|
var uploadToIPFS = async (nexusApiUrl, [type, content]) => {
|
|
@@ -4898,7 +4909,7 @@ var products_default = [
|
|
|
4898
4909
|
"ETH"
|
|
4899
4910
|
],
|
|
4900
4911
|
isPrivate: false,
|
|
4901
|
-
timestamp:
|
|
4912
|
+
timestamp: 1734557999,
|
|
4902
4913
|
minPrice: 100
|
|
4903
4914
|
},
|
|
4904
4915
|
{
|
|
@@ -5022,7 +5033,7 @@ var products_default = [
|
|
|
5022
5033
|
"cbBTC"
|
|
5023
5034
|
],
|
|
5024
5035
|
isPrivate: false,
|
|
5025
|
-
timestamp:
|
|
5036
|
+
timestamp: 1733326763,
|
|
5026
5037
|
minPrice: 100
|
|
5027
5038
|
},
|
|
5028
5039
|
{
|
|
@@ -5166,7 +5177,7 @@ var products_default = [
|
|
|
5166
5177
|
"USDC"
|
|
5167
5178
|
],
|
|
5168
5179
|
isPrivate: false,
|
|
5169
|
-
timestamp:
|
|
5180
|
+
timestamp: 1731583079,
|
|
5170
5181
|
minPrice: 100
|
|
5171
5182
|
},
|
|
5172
5183
|
{
|
|
@@ -5608,7 +5619,7 @@ var products_default = [
|
|
|
5608
5619
|
"cbBTC"
|
|
5609
5620
|
],
|
|
5610
5621
|
isPrivate: false,
|
|
5611
|
-
timestamp:
|
|
5622
|
+
timestamp: 1725264851,
|
|
5612
5623
|
minPrice: 100
|
|
5613
5624
|
},
|
|
5614
5625
|
{
|
|
@@ -6001,7 +6012,7 @@ var products_default = [
|
|
|
6001
6012
|
"cbBTC"
|
|
6002
6013
|
],
|
|
6003
6014
|
isPrivate: false,
|
|
6004
|
-
timestamp:
|
|
6015
|
+
timestamp: 1741267523,
|
|
6005
6016
|
minPrice: 100
|
|
6006
6017
|
},
|
|
6007
6018
|
{
|
|
@@ -6149,7 +6160,7 @@ var products_default = [
|
|
|
6149
6160
|
"USDC"
|
|
6150
6161
|
],
|
|
6151
6162
|
isPrivate: false,
|
|
6152
|
-
timestamp:
|
|
6163
|
+
timestamp: 1722950807,
|
|
6153
6164
|
minPrice: 100
|
|
6154
6165
|
},
|
|
6155
6166
|
{
|
|
@@ -6338,7 +6349,7 @@ var products_default = [
|
|
|
6338
6349
|
"cbBTC"
|
|
6339
6350
|
],
|
|
6340
6351
|
isPrivate: false,
|
|
6341
|
-
timestamp:
|
|
6352
|
+
timestamp: 1747055891,
|
|
6342
6353
|
minPrice: 100
|
|
6343
6354
|
},
|
|
6344
6355
|
{
|
|
@@ -6618,7 +6629,7 @@ var products_default = [
|
|
|
6618
6629
|
"cbBTC"
|
|
6619
6630
|
],
|
|
6620
6631
|
isPrivate: false,
|
|
6621
|
-
timestamp:
|
|
6632
|
+
timestamp: 1740672395,
|
|
6622
6633
|
minPrice: 49
|
|
6623
6634
|
},
|
|
6624
6635
|
{
|
|
@@ -6711,7 +6722,7 @@ var products_default = [
|
|
|
6711
6722
|
"cbBTC"
|
|
6712
6723
|
],
|
|
6713
6724
|
isPrivate: true,
|
|
6714
|
-
timestamp:
|
|
6725
|
+
timestamp: 1745409575,
|
|
6715
6726
|
minPrice: 100
|
|
6716
6727
|
},
|
|
6717
6728
|
{
|
|
@@ -6766,7 +6777,7 @@ var products_default = [
|
|
|
6766
6777
|
"USDC"
|
|
6767
6778
|
],
|
|
6768
6779
|
isPrivate: false,
|
|
6769
|
-
timestamp:
|
|
6780
|
+
timestamp: 1739447471,
|
|
6770
6781
|
minPrice: 300
|
|
6771
6782
|
},
|
|
6772
6783
|
{
|
|
@@ -7044,7 +7055,7 @@ var products_default = [
|
|
|
7044
7055
|
"cbBTC"
|
|
7045
7056
|
],
|
|
7046
7057
|
isPrivate: false,
|
|
7047
|
-
timestamp:
|
|
7058
|
+
timestamp: 1741267523,
|
|
7048
7059
|
minPrice: 100
|
|
7049
7060
|
},
|
|
7050
7061
|
{
|
|
@@ -7063,7 +7074,7 @@ var products_default = [
|
|
|
7063
7074
|
"cbBTC"
|
|
7064
7075
|
],
|
|
7065
7076
|
isPrivate: false,
|
|
7066
|
-
timestamp:
|
|
7077
|
+
timestamp: 1739447471,
|
|
7067
7078
|
minPrice: 50
|
|
7068
7079
|
},
|
|
7069
7080
|
{
|
|
@@ -7101,7 +7112,7 @@ var products_default = [
|
|
|
7101
7112
|
"cbBTC"
|
|
7102
7113
|
],
|
|
7103
7114
|
isPrivate: false,
|
|
7104
|
-
timestamp:
|
|
7115
|
+
timestamp: 1739447471,
|
|
7105
7116
|
minPrice: 380
|
|
7106
7117
|
},
|
|
7107
7118
|
{
|
|
@@ -7120,7 +7131,7 @@ var products_default = [
|
|
|
7120
7131
|
"cbBTC"
|
|
7121
7132
|
],
|
|
7122
7133
|
isPrivate: true,
|
|
7123
|
-
timestamp:
|
|
7134
|
+
timestamp: 1745946671,
|
|
7124
7135
|
minPrice: 225
|
|
7125
7136
|
},
|
|
7126
7137
|
{
|
|
@@ -7357,7 +7368,7 @@ var products_default = [
|
|
|
7357
7368
|
"USDC"
|
|
7358
7369
|
],
|
|
7359
7370
|
isPrivate: false,
|
|
7360
|
-
timestamp:
|
|
7371
|
+
timestamp: 1742481059,
|
|
7361
7372
|
minPrice: 100
|
|
7362
7373
|
},
|
|
7363
7374
|
{
|
|
@@ -7410,7 +7421,7 @@ var products_default = [
|
|
|
7410
7421
|
"cbBTC"
|
|
7411
7422
|
],
|
|
7412
7423
|
isPrivate: false,
|
|
7413
|
-
timestamp:
|
|
7424
|
+
timestamp: 1744902863,
|
|
7414
7425
|
minPrice: 100
|
|
7415
7426
|
},
|
|
7416
7427
|
{
|
|
@@ -7684,7 +7695,7 @@ var productsMap = products_default.reduce(
|
|
|
7684
7695
|
(acc, product) => ({ ...acc, [product.id]: product }),
|
|
7685
7696
|
{}
|
|
7686
7697
|
);
|
|
7687
|
-
async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, coverAsset, coverBuyerAddress, slippage = DEFAULT_SLIPPAGE / SLIPPAGE_DENOMINATOR, ipfsCidOrContent = "", nexusApiUrl = "https://api.nexusmutual.io/v2", commissionRatio, commissionDestination) {
|
|
7698
|
+
async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, coverAsset, coverBuyerAddress, slippage = DEFAULT_SLIPPAGE / SLIPPAGE_DENOMINATOR, ipfsCidOrContent = "", nexusApiUrl = "https://api.nexusmutual.io/v2", commissionRatio, commissionDestination, paymentAsset = coverAsset) {
|
|
7688
7699
|
if (!Number.isInteger(productId) || productId <= 0) {
|
|
7689
7700
|
return { result: void 0, error: { message: "Invalid productId: must be a positive integer" } };
|
|
7690
7701
|
}
|
|
@@ -7706,6 +7717,12 @@ async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, co
|
|
|
7706
7717
|
error: { message: `Invalid coverAsset: must be one of ${coverAssetsString}` }
|
|
7707
7718
|
};
|
|
7708
7719
|
}
|
|
7720
|
+
if (paymentAsset !== 255 /* NXM */ && paymentAsset !== coverAsset) {
|
|
7721
|
+
return {
|
|
7722
|
+
result: void 0,
|
|
7723
|
+
error: { message: `Invalid payment asset: must be one of ${coverAsset} or NXM` }
|
|
7724
|
+
};
|
|
7725
|
+
}
|
|
7709
7726
|
if (!/^0x[a-fA-F0-9]{40}$/.test(coverBuyerAddress)) {
|
|
7710
7727
|
return { result: void 0, error: { message: "Invalid coverBuyerAddress: must be a valid Ethereum address" } };
|
|
7711
7728
|
}
|
|
@@ -7758,7 +7775,14 @@ async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, co
|
|
|
7758
7775
|
}
|
|
7759
7776
|
slippage = slippage * SLIPPAGE_DENOMINATOR;
|
|
7760
7777
|
try {
|
|
7761
|
-
const { quote } = await getQuote(
|
|
7778
|
+
const { quote } = await getQuote(
|
|
7779
|
+
productId,
|
|
7780
|
+
coverAmount,
|
|
7781
|
+
coverPeriod,
|
|
7782
|
+
coverAsset,
|
|
7783
|
+
nexusApiUrl,
|
|
7784
|
+
paymentAsset
|
|
7785
|
+
);
|
|
7762
7786
|
const maxPremiumInAsset = calculatePremiumWithCommissionAndSlippage(
|
|
7763
7787
|
BigInt(quote.premiumInAsset),
|
|
7764
7788
|
commissionRatio || BUY_COVER_COMMISSION_RATIO_BY_PRODUCT_TYPE[productType],
|
|
@@ -7800,8 +7824,14 @@ async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, co
|
|
|
7800
7824
|
return errorResponse;
|
|
7801
7825
|
}
|
|
7802
7826
|
}
|
|
7803
|
-
async function getQuote(productId, coverAmount, coverPeriod, coverAsset, nexusApiUrl) {
|
|
7804
|
-
const params = {
|
|
7827
|
+
async function getQuote(productId, coverAmount, coverPeriod, coverAsset, nexusApiUrl, paymentAsset) {
|
|
7828
|
+
const params = {
|
|
7829
|
+
productId,
|
|
7830
|
+
amount: coverAmount,
|
|
7831
|
+
period: coverPeriod,
|
|
7832
|
+
coverAsset,
|
|
7833
|
+
paymentAsset
|
|
7834
|
+
};
|
|
7805
7835
|
const response = await import_axios2.default.get(nexusApiUrl + "/quote", { params });
|
|
7806
7836
|
if (!response.data) {
|
|
7807
7837
|
throw new Error("Failed to fetch cover quote");
|
|
@@ -7972,6 +8002,7 @@ var src_default = nexusSdk;
|
|
|
7972
8002
|
NEXUS_MUTUAL_DAO_TREASURY_ADDRESS,
|
|
7973
8003
|
NO_COMMISSION,
|
|
7974
8004
|
NO_COMMISSION_DESTINATION,
|
|
8005
|
+
PaymentAsset,
|
|
7975
8006
|
ProductCategoryEnum,
|
|
7976
8007
|
ProductTypes,
|
|
7977
8008
|
SHERLOCK_BUG_BOUNTY_COMMISSION_RATIO,
|