@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.mjs
CHANGED
|
@@ -892,8 +892,17 @@ var CoverAsset = /* @__PURE__ */ ((CoverAsset2) => {
|
|
|
892
892
|
CoverAsset2[CoverAsset2["ETH"] = 0] = "ETH";
|
|
893
893
|
CoverAsset2[CoverAsset2["DAI"] = 1] = "DAI";
|
|
894
894
|
CoverAsset2[CoverAsset2["USDC"] = 6] = "USDC";
|
|
895
|
+
CoverAsset2[CoverAsset2["cbBTC"] = 7] = "cbBTC";
|
|
895
896
|
return CoverAsset2;
|
|
896
897
|
})(CoverAsset || {});
|
|
898
|
+
var PaymentAsset = /* @__PURE__ */ ((PaymentAsset2) => {
|
|
899
|
+
PaymentAsset2[PaymentAsset2["ETH"] = 0] = "ETH";
|
|
900
|
+
PaymentAsset2[PaymentAsset2["DAI"] = 1] = "DAI";
|
|
901
|
+
PaymentAsset2[PaymentAsset2["USDC"] = 6] = "USDC";
|
|
902
|
+
PaymentAsset2[PaymentAsset2["cbBTC"] = 7] = "cbBTC";
|
|
903
|
+
PaymentAsset2[PaymentAsset2["NXM"] = 255] = "NXM";
|
|
904
|
+
return PaymentAsset2;
|
|
905
|
+
})(PaymentAsset || {});
|
|
897
906
|
var CoverId = /* @__PURE__ */ ((CoverId2) => {
|
|
898
907
|
CoverId2[CoverId2["BUY"] = 0] = "BUY";
|
|
899
908
|
return CoverId2;
|
|
@@ -999,6 +1008,7 @@ __export(constants_exports, {
|
|
|
999
1008
|
NEXUS_MUTUAL_DAO_TREASURY_ADDRESS: () => NEXUS_MUTUAL_DAO_TREASURY_ADDRESS,
|
|
1000
1009
|
NO_COMMISSION: () => NO_COMMISSION,
|
|
1001
1010
|
NO_COMMISSION_DESTINATION: () => NO_COMMISSION_DESTINATION,
|
|
1011
|
+
PaymentAsset: () => PaymentAsset,
|
|
1002
1012
|
ProductCategoryEnum: () => ProductCategoryEnum,
|
|
1003
1013
|
SHERLOCK_BUG_BOUNTY_COMMISSION_RATIO: () => SHERLOCK_BUG_BOUNTY_COMMISSION_RATIO,
|
|
1004
1014
|
SLIPPAGE_DENOMINATOR: () => SLIPPAGE_DENOMINATOR,
|
|
@@ -1816,7 +1826,7 @@ var validateIPFSContent = (type, content) => {
|
|
|
1816
1826
|
};
|
|
1817
1827
|
|
|
1818
1828
|
// generated/version.json
|
|
1819
|
-
var version = "0.
|
|
1829
|
+
var version = "0.17.0";
|
|
1820
1830
|
|
|
1821
1831
|
// src/ipfs/uploadIPFSContent.ts
|
|
1822
1832
|
var uploadToIPFS = async (nexusApiUrl, [type, content]) => {
|
|
@@ -4822,7 +4832,7 @@ var products_default = [
|
|
|
4822
4832
|
"ETH"
|
|
4823
4833
|
],
|
|
4824
4834
|
isPrivate: false,
|
|
4825
|
-
timestamp:
|
|
4835
|
+
timestamp: 1734557999,
|
|
4826
4836
|
minPrice: 100
|
|
4827
4837
|
},
|
|
4828
4838
|
{
|
|
@@ -4946,7 +4956,7 @@ var products_default = [
|
|
|
4946
4956
|
"cbBTC"
|
|
4947
4957
|
],
|
|
4948
4958
|
isPrivate: false,
|
|
4949
|
-
timestamp:
|
|
4959
|
+
timestamp: 1733326763,
|
|
4950
4960
|
minPrice: 100
|
|
4951
4961
|
},
|
|
4952
4962
|
{
|
|
@@ -5090,7 +5100,7 @@ var products_default = [
|
|
|
5090
5100
|
"USDC"
|
|
5091
5101
|
],
|
|
5092
5102
|
isPrivate: false,
|
|
5093
|
-
timestamp:
|
|
5103
|
+
timestamp: 1731583079,
|
|
5094
5104
|
minPrice: 100
|
|
5095
5105
|
},
|
|
5096
5106
|
{
|
|
@@ -5532,7 +5542,7 @@ var products_default = [
|
|
|
5532
5542
|
"cbBTC"
|
|
5533
5543
|
],
|
|
5534
5544
|
isPrivate: false,
|
|
5535
|
-
timestamp:
|
|
5545
|
+
timestamp: 1725264851,
|
|
5536
5546
|
minPrice: 100
|
|
5537
5547
|
},
|
|
5538
5548
|
{
|
|
@@ -5925,7 +5935,7 @@ var products_default = [
|
|
|
5925
5935
|
"cbBTC"
|
|
5926
5936
|
],
|
|
5927
5937
|
isPrivate: false,
|
|
5928
|
-
timestamp:
|
|
5938
|
+
timestamp: 1741267523,
|
|
5929
5939
|
minPrice: 100
|
|
5930
5940
|
},
|
|
5931
5941
|
{
|
|
@@ -6073,7 +6083,7 @@ var products_default = [
|
|
|
6073
6083
|
"USDC"
|
|
6074
6084
|
],
|
|
6075
6085
|
isPrivate: false,
|
|
6076
|
-
timestamp:
|
|
6086
|
+
timestamp: 1722950807,
|
|
6077
6087
|
minPrice: 100
|
|
6078
6088
|
},
|
|
6079
6089
|
{
|
|
@@ -6262,7 +6272,7 @@ var products_default = [
|
|
|
6262
6272
|
"cbBTC"
|
|
6263
6273
|
],
|
|
6264
6274
|
isPrivate: false,
|
|
6265
|
-
timestamp:
|
|
6275
|
+
timestamp: 1747055891,
|
|
6266
6276
|
minPrice: 100
|
|
6267
6277
|
},
|
|
6268
6278
|
{
|
|
@@ -6542,7 +6552,7 @@ var products_default = [
|
|
|
6542
6552
|
"cbBTC"
|
|
6543
6553
|
],
|
|
6544
6554
|
isPrivate: false,
|
|
6545
|
-
timestamp:
|
|
6555
|
+
timestamp: 1740672395,
|
|
6546
6556
|
minPrice: 49
|
|
6547
6557
|
},
|
|
6548
6558
|
{
|
|
@@ -6635,7 +6645,7 @@ var products_default = [
|
|
|
6635
6645
|
"cbBTC"
|
|
6636
6646
|
],
|
|
6637
6647
|
isPrivate: true,
|
|
6638
|
-
timestamp:
|
|
6648
|
+
timestamp: 1745409575,
|
|
6639
6649
|
minPrice: 100
|
|
6640
6650
|
},
|
|
6641
6651
|
{
|
|
@@ -6690,7 +6700,7 @@ var products_default = [
|
|
|
6690
6700
|
"USDC"
|
|
6691
6701
|
],
|
|
6692
6702
|
isPrivate: false,
|
|
6693
|
-
timestamp:
|
|
6703
|
+
timestamp: 1739447471,
|
|
6694
6704
|
minPrice: 300
|
|
6695
6705
|
},
|
|
6696
6706
|
{
|
|
@@ -6968,7 +6978,7 @@ var products_default = [
|
|
|
6968
6978
|
"cbBTC"
|
|
6969
6979
|
],
|
|
6970
6980
|
isPrivate: false,
|
|
6971
|
-
timestamp:
|
|
6981
|
+
timestamp: 1741267523,
|
|
6972
6982
|
minPrice: 100
|
|
6973
6983
|
},
|
|
6974
6984
|
{
|
|
@@ -6987,7 +6997,7 @@ var products_default = [
|
|
|
6987
6997
|
"cbBTC"
|
|
6988
6998
|
],
|
|
6989
6999
|
isPrivate: false,
|
|
6990
|
-
timestamp:
|
|
7000
|
+
timestamp: 1739447471,
|
|
6991
7001
|
minPrice: 50
|
|
6992
7002
|
},
|
|
6993
7003
|
{
|
|
@@ -7025,7 +7035,7 @@ var products_default = [
|
|
|
7025
7035
|
"cbBTC"
|
|
7026
7036
|
],
|
|
7027
7037
|
isPrivate: false,
|
|
7028
|
-
timestamp:
|
|
7038
|
+
timestamp: 1739447471,
|
|
7029
7039
|
minPrice: 380
|
|
7030
7040
|
},
|
|
7031
7041
|
{
|
|
@@ -7044,7 +7054,7 @@ var products_default = [
|
|
|
7044
7054
|
"cbBTC"
|
|
7045
7055
|
],
|
|
7046
7056
|
isPrivate: true,
|
|
7047
|
-
timestamp:
|
|
7057
|
+
timestamp: 1745946671,
|
|
7048
7058
|
minPrice: 225
|
|
7049
7059
|
},
|
|
7050
7060
|
{
|
|
@@ -7281,7 +7291,7 @@ var products_default = [
|
|
|
7281
7291
|
"USDC"
|
|
7282
7292
|
],
|
|
7283
7293
|
isPrivate: false,
|
|
7284
|
-
timestamp:
|
|
7294
|
+
timestamp: 1742481059,
|
|
7285
7295
|
minPrice: 100
|
|
7286
7296
|
},
|
|
7287
7297
|
{
|
|
@@ -7334,7 +7344,7 @@ var products_default = [
|
|
|
7334
7344
|
"cbBTC"
|
|
7335
7345
|
],
|
|
7336
7346
|
isPrivate: false,
|
|
7337
|
-
timestamp:
|
|
7347
|
+
timestamp: 1744902863,
|
|
7338
7348
|
minPrice: 100
|
|
7339
7349
|
},
|
|
7340
7350
|
{
|
|
@@ -7608,7 +7618,7 @@ var productsMap = products_default.reduce(
|
|
|
7608
7618
|
(acc, product) => ({ ...acc, [product.id]: product }),
|
|
7609
7619
|
{}
|
|
7610
7620
|
);
|
|
7611
|
-
async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, coverAsset, coverBuyerAddress, slippage = DEFAULT_SLIPPAGE / SLIPPAGE_DENOMINATOR, ipfsCidOrContent = "", nexusApiUrl = "https://api.nexusmutual.io/v2", commissionRatio, commissionDestination) {
|
|
7621
|
+
async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, coverAsset, coverBuyerAddress, slippage = DEFAULT_SLIPPAGE / SLIPPAGE_DENOMINATOR, ipfsCidOrContent = "", nexusApiUrl = "https://api.nexusmutual.io/v2", commissionRatio, commissionDestination, paymentAsset = coverAsset) {
|
|
7612
7622
|
if (!Number.isInteger(productId) || productId <= 0) {
|
|
7613
7623
|
return { result: void 0, error: { message: "Invalid productId: must be a positive integer" } };
|
|
7614
7624
|
}
|
|
@@ -7630,6 +7640,12 @@ async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, co
|
|
|
7630
7640
|
error: { message: `Invalid coverAsset: must be one of ${coverAssetsString}` }
|
|
7631
7641
|
};
|
|
7632
7642
|
}
|
|
7643
|
+
if (paymentAsset !== 255 /* NXM */ && paymentAsset !== coverAsset) {
|
|
7644
|
+
return {
|
|
7645
|
+
result: void 0,
|
|
7646
|
+
error: { message: `Invalid payment asset: must be one of ${coverAsset} or NXM` }
|
|
7647
|
+
};
|
|
7648
|
+
}
|
|
7633
7649
|
if (!/^0x[a-fA-F0-9]{40}$/.test(coverBuyerAddress)) {
|
|
7634
7650
|
return { result: void 0, error: { message: "Invalid coverBuyerAddress: must be a valid Ethereum address" } };
|
|
7635
7651
|
}
|
|
@@ -7682,7 +7698,14 @@ async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, co
|
|
|
7682
7698
|
}
|
|
7683
7699
|
slippage = slippage * SLIPPAGE_DENOMINATOR;
|
|
7684
7700
|
try {
|
|
7685
|
-
const { quote } = await getQuote(
|
|
7701
|
+
const { quote } = await getQuote(
|
|
7702
|
+
productId,
|
|
7703
|
+
coverAmount,
|
|
7704
|
+
coverPeriod,
|
|
7705
|
+
coverAsset,
|
|
7706
|
+
nexusApiUrl,
|
|
7707
|
+
paymentAsset
|
|
7708
|
+
);
|
|
7686
7709
|
const maxPremiumInAsset = calculatePremiumWithCommissionAndSlippage(
|
|
7687
7710
|
BigInt(quote.premiumInAsset),
|
|
7688
7711
|
commissionRatio || BUY_COVER_COMMISSION_RATIO_BY_PRODUCT_TYPE[productType],
|
|
@@ -7724,8 +7747,14 @@ async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, co
|
|
|
7724
7747
|
return errorResponse;
|
|
7725
7748
|
}
|
|
7726
7749
|
}
|
|
7727
|
-
async function getQuote(productId, coverAmount, coverPeriod, coverAsset, nexusApiUrl) {
|
|
7728
|
-
const params = {
|
|
7750
|
+
async function getQuote(productId, coverAmount, coverPeriod, coverAsset, nexusApiUrl, paymentAsset) {
|
|
7751
|
+
const params = {
|
|
7752
|
+
productId,
|
|
7753
|
+
amount: coverAmount,
|
|
7754
|
+
period: coverPeriod,
|
|
7755
|
+
coverAsset,
|
|
7756
|
+
paymentAsset
|
|
7757
|
+
};
|
|
7729
7758
|
const response = await axios2.get(nexusApiUrl + "/quote", { params });
|
|
7730
7759
|
if (!response.data) {
|
|
7731
7760
|
throw new Error("Failed to fetch cover quote");
|
|
@@ -7895,6 +7924,7 @@ export {
|
|
|
7895
7924
|
NEXUS_MUTUAL_DAO_TREASURY_ADDRESS,
|
|
7896
7925
|
NO_COMMISSION,
|
|
7897
7926
|
NO_COMMISSION_DESTINATION,
|
|
7927
|
+
PaymentAsset,
|
|
7898
7928
|
ProductCategoryEnum,
|
|
7899
7929
|
ProductTypes,
|
|
7900
7930
|
SHERLOCK_BUG_BOUNTY_COMMISSION_RATIO,
|