@nexusmutual/sdk 0.3.0 → 0.3.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/data/products.json +6 -6
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/data/products.json
CHANGED
|
@@ -1360,7 +1360,7 @@
|
|
|
1360
1360
|
"DAI"
|
|
1361
1361
|
],
|
|
1362
1362
|
"isPrivate": true,
|
|
1363
|
-
"timestamp":
|
|
1363
|
+
"timestamp": 1684312727
|
|
1364
1364
|
},
|
|
1365
1365
|
{
|
|
1366
1366
|
"id": 84,
|
|
@@ -1422,7 +1422,7 @@
|
|
|
1422
1422
|
"DAI"
|
|
1423
1423
|
],
|
|
1424
1424
|
"isPrivate": true,
|
|
1425
|
-
"timestamp":
|
|
1425
|
+
"timestamp": 1704980411
|
|
1426
1426
|
},
|
|
1427
1427
|
{
|
|
1428
1428
|
"id": 88,
|
|
@@ -1439,7 +1439,7 @@
|
|
|
1439
1439
|
"DAI"
|
|
1440
1440
|
],
|
|
1441
1441
|
"isPrivate": true,
|
|
1442
|
-
"timestamp":
|
|
1442
|
+
"timestamp": 1704981731
|
|
1443
1443
|
},
|
|
1444
1444
|
{
|
|
1445
1445
|
"id": 89,
|
|
@@ -1683,7 +1683,7 @@
|
|
|
1683
1683
|
"DAI"
|
|
1684
1684
|
],
|
|
1685
1685
|
"isPrivate": true,
|
|
1686
|
-
"timestamp":
|
|
1686
|
+
"timestamp": 1704980411
|
|
1687
1687
|
},
|
|
1688
1688
|
{
|
|
1689
1689
|
"id": 105,
|
|
@@ -1700,7 +1700,7 @@
|
|
|
1700
1700
|
"DAI"
|
|
1701
1701
|
],
|
|
1702
1702
|
"isPrivate": true,
|
|
1703
|
-
"timestamp":
|
|
1703
|
+
"timestamp": 1689782903
|
|
1704
1704
|
},
|
|
1705
1705
|
{
|
|
1706
1706
|
"id": 106,
|
|
@@ -2165,7 +2165,7 @@
|
|
|
2165
2165
|
"ETH"
|
|
2166
2166
|
],
|
|
2167
2167
|
"isPrivate": false,
|
|
2168
|
-
"timestamp":
|
|
2168
|
+
"timestamp": 1709311739
|
|
2169
2169
|
},
|
|
2170
2170
|
{
|
|
2171
2171
|
"id": 137,
|
package/dist/index.d.mts
CHANGED
|
@@ -137,7 +137,7 @@ type GetQuoteApiResponse = ApiResponse<GetQuoteResponse, undefined>;
|
|
|
137
137
|
* @param {Integer} coverPeriod - The duration of the cover in days (28-365).
|
|
138
138
|
* @param {CoverAsset} coverAsset - The asset for which cover is being purchased (the cover must be purchased using the same asset)
|
|
139
139
|
* @param {Address} coverBuyerAddress - The Ethereum address of the buyer.
|
|
140
|
-
* @param {number} slippage - The acceptable slippage percentage. Must be between 0
|
|
140
|
+
* @param {number} slippage - The acceptable slippage percentage. Must be between 0-1 (Defaults to 0.001 ~ 0.1%)
|
|
141
141
|
* @param {string} ipfsCid - The IPFS CID for additional data (optional).
|
|
142
142
|
* @return {Promise<GetQuoteApiResponse | ErrorApiResponse>} Returns a successful quote response or an error response.
|
|
143
143
|
*/
|
|
@@ -1573,7 +1573,7 @@ var products = [
|
|
|
1573
1573
|
"DAI"
|
|
1574
1574
|
],
|
|
1575
1575
|
isPrivate: true,
|
|
1576
|
-
timestamp:
|
|
1576
|
+
timestamp: 1684312727
|
|
1577
1577
|
},
|
|
1578
1578
|
{
|
|
1579
1579
|
id: 84,
|
|
@@ -1638,7 +1638,7 @@ var products = [
|
|
|
1638
1638
|
"DAI"
|
|
1639
1639
|
],
|
|
1640
1640
|
isPrivate: true,
|
|
1641
|
-
timestamp:
|
|
1641
|
+
timestamp: 1704980411
|
|
1642
1642
|
},
|
|
1643
1643
|
{
|
|
1644
1644
|
id: 88,
|
|
@@ -1655,7 +1655,7 @@ var products = [
|
|
|
1655
1655
|
"DAI"
|
|
1656
1656
|
],
|
|
1657
1657
|
isPrivate: true,
|
|
1658
|
-
timestamp:
|
|
1658
|
+
timestamp: 1704981731
|
|
1659
1659
|
},
|
|
1660
1660
|
{
|
|
1661
1661
|
id: 89,
|
|
@@ -1911,7 +1911,7 @@ var products = [
|
|
|
1911
1911
|
"DAI"
|
|
1912
1912
|
],
|
|
1913
1913
|
isPrivate: true,
|
|
1914
|
-
timestamp:
|
|
1914
|
+
timestamp: 1704980411
|
|
1915
1915
|
},
|
|
1916
1916
|
{
|
|
1917
1917
|
id: 105,
|
|
@@ -1928,7 +1928,7 @@ var products = [
|
|
|
1928
1928
|
"DAI"
|
|
1929
1929
|
],
|
|
1930
1930
|
isPrivate: true,
|
|
1931
|
-
timestamp:
|
|
1931
|
+
timestamp: 1689782903
|
|
1932
1932
|
},
|
|
1933
1933
|
{
|
|
1934
1934
|
id: 106,
|
|
@@ -2422,7 +2422,7 @@ var products = [
|
|
|
2422
2422
|
"ETH"
|
|
2423
2423
|
],
|
|
2424
2424
|
isPrivate: false,
|
|
2425
|
-
timestamp:
|
|
2425
|
+
timestamp: 1709311739
|
|
2426
2426
|
},
|
|
2427
2427
|
{
|
|
2428
2428
|
id: 137,
|
package/dist/index.d.ts
CHANGED
|
@@ -137,7 +137,7 @@ type GetQuoteApiResponse = ApiResponse<GetQuoteResponse, undefined>;
|
|
|
137
137
|
* @param {Integer} coverPeriod - The duration of the cover in days (28-365).
|
|
138
138
|
* @param {CoverAsset} coverAsset - The asset for which cover is being purchased (the cover must be purchased using the same asset)
|
|
139
139
|
* @param {Address} coverBuyerAddress - The Ethereum address of the buyer.
|
|
140
|
-
* @param {number} slippage - The acceptable slippage percentage. Must be between 0
|
|
140
|
+
* @param {number} slippage - The acceptable slippage percentage. Must be between 0-1 (Defaults to 0.001 ~ 0.1%)
|
|
141
141
|
* @param {string} ipfsCid - The IPFS CID for additional data (optional).
|
|
142
142
|
* @return {Promise<GetQuoteApiResponse | ErrorApiResponse>} Returns a successful quote response or an error response.
|
|
143
143
|
*/
|
|
@@ -1573,7 +1573,7 @@ var products = [
|
|
|
1573
1573
|
"DAI"
|
|
1574
1574
|
],
|
|
1575
1575
|
isPrivate: true,
|
|
1576
|
-
timestamp:
|
|
1576
|
+
timestamp: 1684312727
|
|
1577
1577
|
},
|
|
1578
1578
|
{
|
|
1579
1579
|
id: 84,
|
|
@@ -1638,7 +1638,7 @@ var products = [
|
|
|
1638
1638
|
"DAI"
|
|
1639
1639
|
],
|
|
1640
1640
|
isPrivate: true,
|
|
1641
|
-
timestamp:
|
|
1641
|
+
timestamp: 1704980411
|
|
1642
1642
|
},
|
|
1643
1643
|
{
|
|
1644
1644
|
id: 88,
|
|
@@ -1655,7 +1655,7 @@ var products = [
|
|
|
1655
1655
|
"DAI"
|
|
1656
1656
|
],
|
|
1657
1657
|
isPrivate: true,
|
|
1658
|
-
timestamp:
|
|
1658
|
+
timestamp: 1704981731
|
|
1659
1659
|
},
|
|
1660
1660
|
{
|
|
1661
1661
|
id: 89,
|
|
@@ -1911,7 +1911,7 @@ var products = [
|
|
|
1911
1911
|
"DAI"
|
|
1912
1912
|
],
|
|
1913
1913
|
isPrivate: true,
|
|
1914
|
-
timestamp:
|
|
1914
|
+
timestamp: 1704980411
|
|
1915
1915
|
},
|
|
1916
1916
|
{
|
|
1917
1917
|
id: 105,
|
|
@@ -1928,7 +1928,7 @@ var products = [
|
|
|
1928
1928
|
"DAI"
|
|
1929
1929
|
],
|
|
1930
1930
|
isPrivate: true,
|
|
1931
|
-
timestamp:
|
|
1931
|
+
timestamp: 1689782903
|
|
1932
1932
|
},
|
|
1933
1933
|
{
|
|
1934
1934
|
id: 106,
|
|
@@ -2422,7 +2422,7 @@ var products = [
|
|
|
2422
2422
|
"ETH"
|
|
2423
2423
|
],
|
|
2424
2424
|
isPrivate: false,
|
|
2425
|
-
timestamp:
|
|
2425
|
+
timestamp: 1709311739
|
|
2426
2426
|
},
|
|
2427
2427
|
{
|
|
2428
2428
|
id: 137,
|
package/dist/index.js
CHANGED
|
@@ -1576,7 +1576,7 @@ var products_default = [
|
|
|
1576
1576
|
"DAI"
|
|
1577
1577
|
],
|
|
1578
1578
|
isPrivate: true,
|
|
1579
|
-
timestamp:
|
|
1579
|
+
timestamp: 1684312727
|
|
1580
1580
|
},
|
|
1581
1581
|
{
|
|
1582
1582
|
id: 84,
|
|
@@ -1638,7 +1638,7 @@ var products_default = [
|
|
|
1638
1638
|
"DAI"
|
|
1639
1639
|
],
|
|
1640
1640
|
isPrivate: true,
|
|
1641
|
-
timestamp:
|
|
1641
|
+
timestamp: 1704980411
|
|
1642
1642
|
},
|
|
1643
1643
|
{
|
|
1644
1644
|
id: 88,
|
|
@@ -1655,7 +1655,7 @@ var products_default = [
|
|
|
1655
1655
|
"DAI"
|
|
1656
1656
|
],
|
|
1657
1657
|
isPrivate: true,
|
|
1658
|
-
timestamp:
|
|
1658
|
+
timestamp: 1704981731
|
|
1659
1659
|
},
|
|
1660
1660
|
{
|
|
1661
1661
|
id: 89,
|
|
@@ -1899,7 +1899,7 @@ var products_default = [
|
|
|
1899
1899
|
"DAI"
|
|
1900
1900
|
],
|
|
1901
1901
|
isPrivate: true,
|
|
1902
|
-
timestamp:
|
|
1902
|
+
timestamp: 1704980411
|
|
1903
1903
|
},
|
|
1904
1904
|
{
|
|
1905
1905
|
id: 105,
|
|
@@ -1916,7 +1916,7 @@ var products_default = [
|
|
|
1916
1916
|
"DAI"
|
|
1917
1917
|
],
|
|
1918
1918
|
isPrivate: true,
|
|
1919
|
-
timestamp:
|
|
1919
|
+
timestamp: 1689782903
|
|
1920
1920
|
},
|
|
1921
1921
|
{
|
|
1922
1922
|
id: 106,
|
|
@@ -2381,7 +2381,7 @@ var products_default = [
|
|
|
2381
2381
|
"ETH"
|
|
2382
2382
|
],
|
|
2383
2383
|
isPrivate: false,
|
|
2384
|
-
timestamp:
|
|
2384
|
+
timestamp: 1709311739
|
|
2385
2385
|
},
|
|
2386
2386
|
{
|
|
2387
2387
|
id: 137,
|
|
@@ -3416,7 +3416,7 @@ __export(quote_exports, {
|
|
|
3416
3416
|
var import_axios = __toESM(require("axios"));
|
|
3417
3417
|
var import_dotenv = __toESM(require_main());
|
|
3418
3418
|
import_dotenv.default.config();
|
|
3419
|
-
async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, coverAsset, coverBuyerAddress, slippage = DEFAULT_SLIPPAGE, ipfsCid = "") {
|
|
3419
|
+
async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, coverAsset, coverBuyerAddress, slippage = DEFAULT_SLIPPAGE / SLIPPAGE_DENOMINATOR, ipfsCid = "") {
|
|
3420
3420
|
if (!process.env.COVER_ROUTER_URL) {
|
|
3421
3421
|
return { result: void 0, error: { message: "Missing COVER_ROUTER_URL env var" } };
|
|
3422
3422
|
}
|
|
@@ -3446,15 +3446,16 @@ async function getQuoteAndBuyCoverInputs(productId, coverAmount, coverPeriod, co
|
|
|
3446
3446
|
if (!/^0x[a-fA-F0-9]{40}$/.test(coverBuyerAddress)) {
|
|
3447
3447
|
return { result: void 0, error: { message: "Invalid coverBuyerAddress: must be a valid Ethereum address" } };
|
|
3448
3448
|
}
|
|
3449
|
-
if (typeof slippage !== "number" || slippage < 0 || slippage >
|
|
3449
|
+
if (typeof slippage !== "number" || slippage < 0 || slippage > 1) {
|
|
3450
3450
|
return {
|
|
3451
3451
|
result: void 0,
|
|
3452
|
-
error: { message:
|
|
3452
|
+
error: { message: "Invalid slippage: must be a number between 0 and 1" }
|
|
3453
3453
|
};
|
|
3454
3454
|
}
|
|
3455
3455
|
if (typeof ipfsCid !== "string") {
|
|
3456
3456
|
return { result: void 0, error: { message: "Invalid ipfsCid: must be a valid IPFS CID" } };
|
|
3457
3457
|
}
|
|
3458
|
+
slippage = slippage * SLIPPAGE_DENOMINATOR;
|
|
3458
3459
|
try {
|
|
3459
3460
|
const { quote, capacities } = await getQuote(productId, coverAmount, coverPeriod, coverAsset);
|
|
3460
3461
|
const maxPremiumInAsset = calculatePremiumWithCommissionAndSlippage(
|