@nexusmutual/sdk 0.3.3 → 0.3.5

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.
@@ -1360,7 +1360,7 @@
1360
1360
  "DAI"
1361
1361
  ],
1362
1362
  "isPrivate": true,
1363
- "timestamp": 1704980411
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": 1684312727
1425
+ "timestamp": 1704981731
1426
1426
  },
1427
1427
  {
1428
1428
  "id": 88,
@@ -1439,7 +1439,7 @@
1439
1439
  "DAI"
1440
1440
  ],
1441
1441
  "isPrivate": true,
1442
- "timestamp": 1704980411
1442
+ "timestamp": 1684312727
1443
1443
  },
1444
1444
  {
1445
1445
  "id": 89,
@@ -1700,7 +1700,7 @@
1700
1700
  "DAI"
1701
1701
  ],
1702
1702
  "isPrivate": true,
1703
- "timestamp": 1704981731
1703
+ "timestamp": 1689782903
1704
1704
  },
1705
1705
  {
1706
1706
  "id": 106,
@@ -1822,7 +1822,7 @@
1822
1822
  "DAI"
1823
1823
  ],
1824
1824
  "isPrivate": true,
1825
- "timestamp": 1691495087
1825
+ "timestamp": 1691493035
1826
1826
  },
1827
1827
  {
1828
1828
  "id": 114,
package/dist/index.d.mts CHANGED
@@ -1,41 +1,5 @@
1
1
  export * from '@nexusmutual/deployments';
2
2
 
3
- type Reserves = {
4
- ethReserve: bigint;
5
- nxmA: bigint;
6
- nxmB: bigint;
7
- budget: bigint;
8
- };
9
-
10
- /**
11
- * Calculates the amount of nxm flowing out of the pool for the given amount of eth flowing in
12
- */
13
- declare const calculateExactNxmForEth: (ethIn: bigint, reserves: Reserves) => bigint;
14
-
15
- /**
16
- * Calculates the amount of eth flowing out of the pool for the given amount of nxm flowing in
17
- */
18
- declare const calculateExactEthForNxm: (nxmIn: bigint, reserves: Reserves) => bigint;
19
-
20
- /**
21
- * Calculates the amount of nxm needed to flow into the pool to get the exact amount of eth out
22
- */
23
- declare const calculateNxmForExactEth: (ethOut: bigint, reserves: Reserves) => bigint;
24
-
25
- /**
26
- * Calculates the amount of eth needed to flow into the pool to get the exact amount of nxm out
27
- */
28
- declare const calculateEthForExactNxm: (nxmOut: bigint, reserves: Reserves) => bigint;
29
-
30
- declare const calculatePriceImpactA: (ethIn: bigint, reserves: Reserves) => bigint;
31
-
32
- declare const calculatePriceImpactB: (nxmIn: bigint, reserves: Reserves) => bigint;
33
-
34
- declare const calculateSpotPrice: (reserves: Reserves) => {
35
- spotPriceA: bigint;
36
- spotPriceB: bigint;
37
- };
38
-
39
3
  declare enum CoverAsset {
40
4
  ETH = 0,
41
5
  DAI = 1
@@ -149,17 +113,50 @@ type GetQuoteApiResponse = ApiResponse<GetQuoteResponse, undefined>;
149
113
  * @param {Integer} productId - The ID of the product for which cover is being purchased.
150
114
  * @param {IntString} coverAmount - The amount of cover in smallest unit of currency (i.e. wei)
151
115
  * @param {Integer} coverPeriod - The duration of the cover in days (28-365).
152
- * @param {CoverAsset} coverAsset - The asset for which cover is being purchased (the cover must be purchased using the same asset)
116
+ * @param {CoverAsset} coverAsset - The asset for which cover is being purchased; the purchase must use the same asset.
153
117
  * @param {Address} coverBuyerAddress - The Ethereum address of the buyer.
154
118
  * @param {number} slippage - The acceptable slippage percentage. Must be between 0-1 (Defaults to 0.001 ~ 0.1%)
155
119
  * @param {string} ipfsCid - The IPFS CID for additional data (optional).
120
+ * @param {string} coverRouterUrl - Used to override the default CoverRouter URL which is bundled this library.
156
121
  * @return {Promise<GetQuoteApiResponse | ErrorApiResponse>} Returns a successful quote response or an error response.
157
122
  */
158
- declare function getQuoteAndBuyCoverInputs(productId: Integer, coverAmount: IntString, coverPeriod: Integer, coverAsset: CoverAsset, coverBuyerAddress: Address, slippage?: number, ipfsCid?: string): Promise<GetQuoteApiResponse | ErrorApiResponse>;
123
+ declare function getQuoteAndBuyCoverInputs(productId: Integer, coverAmount: IntString, coverPeriod: Integer, coverAsset: CoverAsset, coverBuyerAddress: Address, slippage?: number, ipfsCid?: string, coverRouterUrl?: string): Promise<GetQuoteApiResponse | ErrorApiResponse>;
124
+
125
+ type Reserves = {
126
+ ethReserve: bigint;
127
+ nxmA: bigint;
128
+ nxmB: bigint;
129
+ budget: bigint;
130
+ };
131
+
132
+ /**
133
+ * Calculates the amount of nxm flowing out of the pool for the given amount of eth flowing in
134
+ */
135
+ declare const calculateExactNxmForEth: (ethIn: bigint, reserves: Reserves) => bigint;
136
+
137
+ /**
138
+ * Calculates the amount of eth flowing out of the pool for the given amount of nxm flowing in
139
+ */
140
+ declare const calculateExactEthForNxm: (nxmIn: bigint, reserves: Reserves) => bigint;
141
+
142
+ /**
143
+ * Calculates the amount of nxm needed to flow into the pool to get the exact amount of eth out
144
+ */
145
+ declare const calculateNxmForExactEth: (ethOut: bigint, reserves: Reserves) => bigint;
146
+
159
147
  /**
160
- * Calculates the max capacity by summing up all the amounts in the given array of pool capacities.
148
+ * Calculates the amount of eth needed to flow into the pool to get the exact amount of nxm out
161
149
  */
162
- declare function sumPoolCapacities(capacities: PoolCapacity[]): IntString;
150
+ declare const calculateEthForExactNxm: (nxmOut: bigint, reserves: Reserves) => bigint;
151
+
152
+ declare const calculatePriceImpactA: (ethIn: bigint, reserves: Reserves) => bigint;
153
+
154
+ declare const calculatePriceImpactB: (nxmIn: bigint, reserves: Reserves) => bigint;
155
+
156
+ declare const calculateSpotPrice: (reserves: Reserves) => {
157
+ spotPriceA: bigint;
158
+ spotPriceB: bigint;
159
+ };
163
160
 
164
161
  var products = [
165
162
  {
@@ -1587,7 +1584,7 @@ var products = [
1587
1584
  "DAI"
1588
1585
  ],
1589
1586
  isPrivate: true,
1590
- timestamp: 1704980411
1587
+ timestamp: 1684312727
1591
1588
  },
1592
1589
  {
1593
1590
  id: 84,
@@ -1652,7 +1649,7 @@ var products = [
1652
1649
  "DAI"
1653
1650
  ],
1654
1651
  isPrivate: true,
1655
- timestamp: 1684312727
1652
+ timestamp: 1704981731
1656
1653
  },
1657
1654
  {
1658
1655
  id: 88,
@@ -1669,7 +1666,7 @@ var products = [
1669
1666
  "DAI"
1670
1667
  ],
1671
1668
  isPrivate: true,
1672
- timestamp: 1704980411
1669
+ timestamp: 1684312727
1673
1670
  },
1674
1671
  {
1675
1672
  id: 89,
@@ -1942,7 +1939,7 @@ var products = [
1942
1939
  "DAI"
1943
1940
  ],
1944
1941
  isPrivate: true,
1945
- timestamp: 1704981731
1942
+ timestamp: 1689782903
1946
1943
  },
1947
1944
  {
1948
1945
  id: 106,
@@ -2071,7 +2068,7 @@ var products = [
2071
2068
  "DAI"
2072
2069
  ],
2073
2070
  isPrivate: true,
2074
- timestamp: 1691495087
2071
+ timestamp: 1691493035
2075
2072
  },
2076
2073
  {
2077
2074
  id: 114,
@@ -2975,7 +2972,6 @@ declare const nexusSdk: {
2975
2972
  DEFAULT_SLIPPAGE: 10;
2976
2973
  DEFAULT_COMMISSION_RATIO: 1500;
2977
2974
  NEXUS_MUTUAL_DAO_TREASURY_ADDRESS: "0x586b9b2F8010b284A0197f392156f1A7Eb5e86e9";
2978
- sumPoolCapacities: typeof sumPoolCapacities;
2979
2975
  getQuoteAndBuyCoverInputs: typeof getQuoteAndBuyCoverInputs;
2980
2976
  calculatePremiumWithCommissionAndSlippage: (premium: bigint, commission?: number, slippage?: number) => bigint;
2981
2977
  calculateExactNxmForEth: (ethIn: bigint, reserves: Reserves) => bigint;
@@ -38995,4 +38991,4 @@ declare const nexusSdk: {
38995
38991
  }];
38996
38992
  };
38997
38993
 
38998
- export { Address, ApiResponse, BuyCoverInput, BuyCoverParams, COMMISSION_DENOMINATOR, Capacity, CoverAsset, CoverId, CoverRouterProductCapacityResponse, CoverRouterQuoteResponse, DEFAULT_COMMISSION_RATIO, DEFAULT_SLIPPAGE, ErrorApiResponse, ErrorResponse, FloatString, GetQuoteApiResponse, GetQuoteResponse, IntString, Integer, LogoFileName, LogoName, MAXIMUM_COVER_PERIOD, MINIMUM_COVER_PERIOD, NEXUS_MUTUAL_DAO_TREASURY_ADDRESS, PoolAllocationRequest, PoolCapacity, Quote, QuoteDisplayInfo, Reserves, SLIPPAGE_DENOMINATOR, TARGET_PRICE_DENOMINATOR, allLogoFileNames, allLogoNames, calculateEthForExactNxm, calculateExactEthForNxm, calculateExactNxmForEth, calculateNxmForExactEth, calculatePremiumWithCommissionAndSlippage, calculatePriceImpactA, calculatePriceImpactB, calculateSpotPrice, nexusSdk as default, getQuoteAndBuyCoverInputs, productTypes, products, sumPoolCapacities };
38994
+ export { Address, ApiResponse, BuyCoverInput, BuyCoverParams, COMMISSION_DENOMINATOR, Capacity, CoverAsset, CoverId, CoverRouterProductCapacityResponse, CoverRouterQuoteResponse, DEFAULT_COMMISSION_RATIO, DEFAULT_SLIPPAGE, ErrorApiResponse, ErrorResponse, FloatString, GetQuoteApiResponse, GetQuoteResponse, IntString, Integer, LogoFileName, LogoName, MAXIMUM_COVER_PERIOD, MINIMUM_COVER_PERIOD, NEXUS_MUTUAL_DAO_TREASURY_ADDRESS, PoolAllocationRequest, PoolCapacity, Quote, QuoteDisplayInfo, Reserves, SLIPPAGE_DENOMINATOR, TARGET_PRICE_DENOMINATOR, allLogoFileNames, allLogoNames, calculateEthForExactNxm, calculateExactEthForNxm, calculateExactNxmForEth, calculateNxmForExactEth, calculatePremiumWithCommissionAndSlippage, calculatePriceImpactA, calculatePriceImpactB, calculateSpotPrice, nexusSdk as default, getQuoteAndBuyCoverInputs, productTypes, products };
package/dist/index.d.ts CHANGED
@@ -1,41 +1,5 @@
1
1
  export * from '@nexusmutual/deployments';
2
2
 
3
- type Reserves = {
4
- ethReserve: bigint;
5
- nxmA: bigint;
6
- nxmB: bigint;
7
- budget: bigint;
8
- };
9
-
10
- /**
11
- * Calculates the amount of nxm flowing out of the pool for the given amount of eth flowing in
12
- */
13
- declare const calculateExactNxmForEth: (ethIn: bigint, reserves: Reserves) => bigint;
14
-
15
- /**
16
- * Calculates the amount of eth flowing out of the pool for the given amount of nxm flowing in
17
- */
18
- declare const calculateExactEthForNxm: (nxmIn: bigint, reserves: Reserves) => bigint;
19
-
20
- /**
21
- * Calculates the amount of nxm needed to flow into the pool to get the exact amount of eth out
22
- */
23
- declare const calculateNxmForExactEth: (ethOut: bigint, reserves: Reserves) => bigint;
24
-
25
- /**
26
- * Calculates the amount of eth needed to flow into the pool to get the exact amount of nxm out
27
- */
28
- declare const calculateEthForExactNxm: (nxmOut: bigint, reserves: Reserves) => bigint;
29
-
30
- declare const calculatePriceImpactA: (ethIn: bigint, reserves: Reserves) => bigint;
31
-
32
- declare const calculatePriceImpactB: (nxmIn: bigint, reserves: Reserves) => bigint;
33
-
34
- declare const calculateSpotPrice: (reserves: Reserves) => {
35
- spotPriceA: bigint;
36
- spotPriceB: bigint;
37
- };
38
-
39
3
  declare enum CoverAsset {
40
4
  ETH = 0,
41
5
  DAI = 1
@@ -149,17 +113,50 @@ type GetQuoteApiResponse = ApiResponse<GetQuoteResponse, undefined>;
149
113
  * @param {Integer} productId - The ID of the product for which cover is being purchased.
150
114
  * @param {IntString} coverAmount - The amount of cover in smallest unit of currency (i.e. wei)
151
115
  * @param {Integer} coverPeriod - The duration of the cover in days (28-365).
152
- * @param {CoverAsset} coverAsset - The asset for which cover is being purchased (the cover must be purchased using the same asset)
116
+ * @param {CoverAsset} coverAsset - The asset for which cover is being purchased; the purchase must use the same asset.
153
117
  * @param {Address} coverBuyerAddress - The Ethereum address of the buyer.
154
118
  * @param {number} slippage - The acceptable slippage percentage. Must be between 0-1 (Defaults to 0.001 ~ 0.1%)
155
119
  * @param {string} ipfsCid - The IPFS CID for additional data (optional).
120
+ * @param {string} coverRouterUrl - Used to override the default CoverRouter URL which is bundled this library.
156
121
  * @return {Promise<GetQuoteApiResponse | ErrorApiResponse>} Returns a successful quote response or an error response.
157
122
  */
158
- declare function getQuoteAndBuyCoverInputs(productId: Integer, coverAmount: IntString, coverPeriod: Integer, coverAsset: CoverAsset, coverBuyerAddress: Address, slippage?: number, ipfsCid?: string): Promise<GetQuoteApiResponse | ErrorApiResponse>;
123
+ declare function getQuoteAndBuyCoverInputs(productId: Integer, coverAmount: IntString, coverPeriod: Integer, coverAsset: CoverAsset, coverBuyerAddress: Address, slippage?: number, ipfsCid?: string, coverRouterUrl?: string): Promise<GetQuoteApiResponse | ErrorApiResponse>;
124
+
125
+ type Reserves = {
126
+ ethReserve: bigint;
127
+ nxmA: bigint;
128
+ nxmB: bigint;
129
+ budget: bigint;
130
+ };
131
+
132
+ /**
133
+ * Calculates the amount of nxm flowing out of the pool for the given amount of eth flowing in
134
+ */
135
+ declare const calculateExactNxmForEth: (ethIn: bigint, reserves: Reserves) => bigint;
136
+
137
+ /**
138
+ * Calculates the amount of eth flowing out of the pool for the given amount of nxm flowing in
139
+ */
140
+ declare const calculateExactEthForNxm: (nxmIn: bigint, reserves: Reserves) => bigint;
141
+
142
+ /**
143
+ * Calculates the amount of nxm needed to flow into the pool to get the exact amount of eth out
144
+ */
145
+ declare const calculateNxmForExactEth: (ethOut: bigint, reserves: Reserves) => bigint;
146
+
159
147
  /**
160
- * Calculates the max capacity by summing up all the amounts in the given array of pool capacities.
148
+ * Calculates the amount of eth needed to flow into the pool to get the exact amount of nxm out
161
149
  */
162
- declare function sumPoolCapacities(capacities: PoolCapacity[]): IntString;
150
+ declare const calculateEthForExactNxm: (nxmOut: bigint, reserves: Reserves) => bigint;
151
+
152
+ declare const calculatePriceImpactA: (ethIn: bigint, reserves: Reserves) => bigint;
153
+
154
+ declare const calculatePriceImpactB: (nxmIn: bigint, reserves: Reserves) => bigint;
155
+
156
+ declare const calculateSpotPrice: (reserves: Reserves) => {
157
+ spotPriceA: bigint;
158
+ spotPriceB: bigint;
159
+ };
163
160
 
164
161
  var products = [
165
162
  {
@@ -1587,7 +1584,7 @@ var products = [
1587
1584
  "DAI"
1588
1585
  ],
1589
1586
  isPrivate: true,
1590
- timestamp: 1704980411
1587
+ timestamp: 1684312727
1591
1588
  },
1592
1589
  {
1593
1590
  id: 84,
@@ -1652,7 +1649,7 @@ var products = [
1652
1649
  "DAI"
1653
1650
  ],
1654
1651
  isPrivate: true,
1655
- timestamp: 1684312727
1652
+ timestamp: 1704981731
1656
1653
  },
1657
1654
  {
1658
1655
  id: 88,
@@ -1669,7 +1666,7 @@ var products = [
1669
1666
  "DAI"
1670
1667
  ],
1671
1668
  isPrivate: true,
1672
- timestamp: 1704980411
1669
+ timestamp: 1684312727
1673
1670
  },
1674
1671
  {
1675
1672
  id: 89,
@@ -1942,7 +1939,7 @@ var products = [
1942
1939
  "DAI"
1943
1940
  ],
1944
1941
  isPrivate: true,
1945
- timestamp: 1704981731
1942
+ timestamp: 1689782903
1946
1943
  },
1947
1944
  {
1948
1945
  id: 106,
@@ -2071,7 +2068,7 @@ var products = [
2071
2068
  "DAI"
2072
2069
  ],
2073
2070
  isPrivate: true,
2074
- timestamp: 1691495087
2071
+ timestamp: 1691493035
2075
2072
  },
2076
2073
  {
2077
2074
  id: 114,
@@ -2975,7 +2972,6 @@ declare const nexusSdk: {
2975
2972
  DEFAULT_SLIPPAGE: 10;
2976
2973
  DEFAULT_COMMISSION_RATIO: 1500;
2977
2974
  NEXUS_MUTUAL_DAO_TREASURY_ADDRESS: "0x586b9b2F8010b284A0197f392156f1A7Eb5e86e9";
2978
- sumPoolCapacities: typeof sumPoolCapacities;
2979
2975
  getQuoteAndBuyCoverInputs: typeof getQuoteAndBuyCoverInputs;
2980
2976
  calculatePremiumWithCommissionAndSlippage: (premium: bigint, commission?: number, slippage?: number) => bigint;
2981
2977
  calculateExactNxmForEth: (ethIn: bigint, reserves: Reserves) => bigint;
@@ -38995,4 +38991,4 @@ declare const nexusSdk: {
38995
38991
  }];
38996
38992
  };
38997
38993
 
38998
- export { Address, ApiResponse, BuyCoverInput, BuyCoverParams, COMMISSION_DENOMINATOR, Capacity, CoverAsset, CoverId, CoverRouterProductCapacityResponse, CoverRouterQuoteResponse, DEFAULT_COMMISSION_RATIO, DEFAULT_SLIPPAGE, ErrorApiResponse, ErrorResponse, FloatString, GetQuoteApiResponse, GetQuoteResponse, IntString, Integer, LogoFileName, LogoName, MAXIMUM_COVER_PERIOD, MINIMUM_COVER_PERIOD, NEXUS_MUTUAL_DAO_TREASURY_ADDRESS, PoolAllocationRequest, PoolCapacity, Quote, QuoteDisplayInfo, Reserves, SLIPPAGE_DENOMINATOR, TARGET_PRICE_DENOMINATOR, allLogoFileNames, allLogoNames, calculateEthForExactNxm, calculateExactEthForNxm, calculateExactNxmForEth, calculateNxmForExactEth, calculatePremiumWithCommissionAndSlippage, calculatePriceImpactA, calculatePriceImpactB, calculateSpotPrice, nexusSdk as default, getQuoteAndBuyCoverInputs, productTypes, products, sumPoolCapacities };
38994
+ export { Address, ApiResponse, BuyCoverInput, BuyCoverParams, COMMISSION_DENOMINATOR, Capacity, CoverAsset, CoverId, CoverRouterProductCapacityResponse, CoverRouterQuoteResponse, DEFAULT_COMMISSION_RATIO, DEFAULT_SLIPPAGE, ErrorApiResponse, ErrorResponse, FloatString, GetQuoteApiResponse, GetQuoteResponse, IntString, Integer, LogoFileName, LogoName, MAXIMUM_COVER_PERIOD, MINIMUM_COVER_PERIOD, NEXUS_MUTUAL_DAO_TREASURY_ADDRESS, PoolAllocationRequest, PoolCapacity, Quote, QuoteDisplayInfo, Reserves, SLIPPAGE_DENOMINATOR, TARGET_PRICE_DENOMINATOR, allLogoFileNames, allLogoNames, calculateEthForExactNxm, calculateExactEthForNxm, calculateExactNxmForEth, calculateNxmForExactEth, calculatePremiumWithCommissionAndSlippage, calculatePriceImpactA, calculatePriceImpactB, calculateSpotPrice, nexusSdk as default, getQuoteAndBuyCoverInputs, productTypes, products };