@cowprotocol/sdk-order-book 1.1.1 → 2.0.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/index.js CHANGED
@@ -188,7 +188,6 @@ var ORDER_BOOK_PROD_CONFIG = {
188
188
  [import_sdk_config2.SupportedChainId.SEPOLIA]: `${PROD_BASE_URL}/sepolia`,
189
189
  [import_sdk_config2.SupportedChainId.POLYGON]: `${PROD_BASE_URL}/polygon`,
190
190
  [import_sdk_config2.SupportedChainId.AVALANCHE]: `${PROD_BASE_URL}/avalanche`,
191
- [import_sdk_config2.SupportedChainId.LENS]: `${PROD_BASE_URL}/lens`,
192
191
  [import_sdk_config2.SupportedChainId.BNB]: `${PROD_BASE_URL}/bnb`,
193
192
  [import_sdk_config2.SupportedChainId.LINEA]: `${PROD_BASE_URL}/linea`,
194
193
  [import_sdk_config2.SupportedChainId.PLASMA]: `${PROD_BASE_URL}/plasma`,
@@ -202,7 +201,6 @@ var ORDER_BOOK_STAGING_CONFIG = {
202
201
  [import_sdk_config2.SupportedChainId.SEPOLIA]: `${STAGING_BASE_URL}/sepolia`,
203
202
  [import_sdk_config2.SupportedChainId.POLYGON]: `${STAGING_BASE_URL}/polygon`,
204
203
  [import_sdk_config2.SupportedChainId.AVALANCHE]: `${STAGING_BASE_URL}/avalanche`,
205
- [import_sdk_config2.SupportedChainId.LENS]: `${STAGING_BASE_URL}/lens`,
206
204
  [import_sdk_config2.SupportedChainId.BNB]: `${STAGING_BASE_URL}/bnb`,
207
205
  [import_sdk_config2.SupportedChainId.LINEA]: `${STAGING_BASE_URL}/linea`,
208
206
  [import_sdk_config2.SupportedChainId.PLASMA]: `${STAGING_BASE_URL}/plasma`,
@@ -216,7 +214,6 @@ var ORDER_BOOK_PARTNER_PROD_CONFIG = {
216
214
  [import_sdk_config2.SupportedChainId.SEPOLIA]: `${PARTNER_PROD_BASE_URL}/sepolia`,
217
215
  [import_sdk_config2.SupportedChainId.POLYGON]: `${PARTNER_PROD_BASE_URL}/polygon`,
218
216
  [import_sdk_config2.SupportedChainId.AVALANCHE]: `${PARTNER_PROD_BASE_URL}/avalanche`,
219
- [import_sdk_config2.SupportedChainId.LENS]: `${PARTNER_PROD_BASE_URL}/lens`,
220
217
  [import_sdk_config2.SupportedChainId.BNB]: `${PARTNER_PROD_BASE_URL}/bnb`,
221
218
  [import_sdk_config2.SupportedChainId.LINEA]: `${PARTNER_PROD_BASE_URL}/linea`,
222
219
  [import_sdk_config2.SupportedChainId.PLASMA]: `${PARTNER_PROD_BASE_URL}/plasma`,
@@ -230,7 +227,6 @@ var ORDER_BOOK_PARTNER_STAGING_CONFIG = {
230
227
  [import_sdk_config2.SupportedChainId.SEPOLIA]: `${PARTNER_STAGING_BASE_URL}/sepolia`,
231
228
  [import_sdk_config2.SupportedChainId.POLYGON]: `${PARTNER_STAGING_BASE_URL}/polygon`,
232
229
  [import_sdk_config2.SupportedChainId.AVALANCHE]: `${PARTNER_STAGING_BASE_URL}/avalanche`,
233
- [import_sdk_config2.SupportedChainId.LENS]: `${PARTNER_STAGING_BASE_URL}/lens`,
234
230
  [import_sdk_config2.SupportedChainId.BNB]: `${PARTNER_STAGING_BASE_URL}/bnb`,
235
231
  [import_sdk_config2.SupportedChainId.LINEA]: `${PARTNER_STAGING_BASE_URL}/linea`,
236
232
  [import_sdk_config2.SupportedChainId.PLASMA]: `${PARTNER_STAGING_BASE_URL}/plasma`,
@@ -674,6 +670,7 @@ var HUNDRED_THOUSANDS = 1e5;
674
670
  var ONE_HUNDRED_BPS = BigInt(100 * 100);
675
671
 
676
672
  // src/quoteAmountsAndCosts/getProtocolFeeAmount.ts
673
+ var PROTOCOL_FEE_BPS_SCALE = BigInt(HUNDRED_THOUSANDS);
677
674
  function getProtocolFeeAmount(params) {
678
675
  const { orderParams, protocolFeeBps } = params;
679
676
  const isSell = orderParams.kind === "sell" /* SELL */;
@@ -684,8 +681,11 @@ function getProtocolFeeAmount(params) {
684
681
  const sellAmount = BigInt(sellAmountStr);
685
682
  const buyAmount = BigInt(buyAmountStr);
686
683
  const feeAmount = BigInt(feeAmountStr);
687
- const protocolFeeScale = BigInt(HUNDRED_THOUSANDS);
688
- const protocolFeeBpsBig = BigInt(protocolFeeBps * HUNDRED_THOUSANDS);
684
+ const protocolFeeScale = PROTOCOL_FEE_BPS_SCALE;
685
+ const protocolFeeBpsBig = BigInt(Math.round(protocolFeeBps * HUNDRED_THOUSANDS));
686
+ if (protocolFeeBpsBig <= 0n) {
687
+ return 0n;
688
+ }
689
689
  if (isSell) {
690
690
  const denominator = ONE_HUNDRED_BPS * protocolFeeScale - protocolFeeBpsBig;
691
691
  return buyAmount * protocolFeeBpsBig / denominator;
package/dist/index.mjs CHANGED
@@ -139,7 +139,6 @@ var ORDER_BOOK_PROD_CONFIG = {
139
139
  [SupportedChainId.SEPOLIA]: `${PROD_BASE_URL}/sepolia`,
140
140
  [SupportedChainId.POLYGON]: `${PROD_BASE_URL}/polygon`,
141
141
  [SupportedChainId.AVALANCHE]: `${PROD_BASE_URL}/avalanche`,
142
- [SupportedChainId.LENS]: `${PROD_BASE_URL}/lens`,
143
142
  [SupportedChainId.BNB]: `${PROD_BASE_URL}/bnb`,
144
143
  [SupportedChainId.LINEA]: `${PROD_BASE_URL}/linea`,
145
144
  [SupportedChainId.PLASMA]: `${PROD_BASE_URL}/plasma`,
@@ -153,7 +152,6 @@ var ORDER_BOOK_STAGING_CONFIG = {
153
152
  [SupportedChainId.SEPOLIA]: `${STAGING_BASE_URL}/sepolia`,
154
153
  [SupportedChainId.POLYGON]: `${STAGING_BASE_URL}/polygon`,
155
154
  [SupportedChainId.AVALANCHE]: `${STAGING_BASE_URL}/avalanche`,
156
- [SupportedChainId.LENS]: `${STAGING_BASE_URL}/lens`,
157
155
  [SupportedChainId.BNB]: `${STAGING_BASE_URL}/bnb`,
158
156
  [SupportedChainId.LINEA]: `${STAGING_BASE_URL}/linea`,
159
157
  [SupportedChainId.PLASMA]: `${STAGING_BASE_URL}/plasma`,
@@ -167,7 +165,6 @@ var ORDER_BOOK_PARTNER_PROD_CONFIG = {
167
165
  [SupportedChainId.SEPOLIA]: `${PARTNER_PROD_BASE_URL}/sepolia`,
168
166
  [SupportedChainId.POLYGON]: `${PARTNER_PROD_BASE_URL}/polygon`,
169
167
  [SupportedChainId.AVALANCHE]: `${PARTNER_PROD_BASE_URL}/avalanche`,
170
- [SupportedChainId.LENS]: `${PARTNER_PROD_BASE_URL}/lens`,
171
168
  [SupportedChainId.BNB]: `${PARTNER_PROD_BASE_URL}/bnb`,
172
169
  [SupportedChainId.LINEA]: `${PARTNER_PROD_BASE_URL}/linea`,
173
170
  [SupportedChainId.PLASMA]: `${PARTNER_PROD_BASE_URL}/plasma`,
@@ -181,7 +178,6 @@ var ORDER_BOOK_PARTNER_STAGING_CONFIG = {
181
178
  [SupportedChainId.SEPOLIA]: `${PARTNER_STAGING_BASE_URL}/sepolia`,
182
179
  [SupportedChainId.POLYGON]: `${PARTNER_STAGING_BASE_URL}/polygon`,
183
180
  [SupportedChainId.AVALANCHE]: `${PARTNER_STAGING_BASE_URL}/avalanche`,
184
- [SupportedChainId.LENS]: `${PARTNER_STAGING_BASE_URL}/lens`,
185
181
  [SupportedChainId.BNB]: `${PARTNER_STAGING_BASE_URL}/bnb`,
186
182
  [SupportedChainId.LINEA]: `${PARTNER_STAGING_BASE_URL}/linea`,
187
183
  [SupportedChainId.PLASMA]: `${PARTNER_STAGING_BASE_URL}/plasma`,
@@ -625,6 +621,7 @@ var HUNDRED_THOUSANDS = 1e5;
625
621
  var ONE_HUNDRED_BPS = BigInt(100 * 100);
626
622
 
627
623
  // src/quoteAmountsAndCosts/getProtocolFeeAmount.ts
624
+ var PROTOCOL_FEE_BPS_SCALE = BigInt(HUNDRED_THOUSANDS);
628
625
  function getProtocolFeeAmount(params) {
629
626
  const { orderParams, protocolFeeBps } = params;
630
627
  const isSell = orderParams.kind === "sell" /* SELL */;
@@ -635,8 +632,11 @@ function getProtocolFeeAmount(params) {
635
632
  const sellAmount = BigInt(sellAmountStr);
636
633
  const buyAmount = BigInt(buyAmountStr);
637
634
  const feeAmount = BigInt(feeAmountStr);
638
- const protocolFeeScale = BigInt(HUNDRED_THOUSANDS);
639
- const protocolFeeBpsBig = BigInt(protocolFeeBps * HUNDRED_THOUSANDS);
635
+ const protocolFeeScale = PROTOCOL_FEE_BPS_SCALE;
636
+ const protocolFeeBpsBig = BigInt(Math.round(protocolFeeBps * HUNDRED_THOUSANDS));
637
+ if (protocolFeeBpsBig <= 0n) {
638
+ return 0n;
639
+ }
640
640
  if (isSell) {
641
641
  const denominator = ONE_HUNDRED_BPS * protocolFeeScale - protocolFeeBpsBig;
642
642
  return buyAmount * protocolFeeBpsBig / denominator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/sdk-order-book",
3
- "version": "1.1.1",
3
+ "version": "2.0.0",
4
4
  "description": "CowProtocol Order Book package",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -31,8 +31,8 @@
31
31
  "cross-fetch": "^3.2.0",
32
32
  "exponential-backoff": "^3.1.2",
33
33
  "limiter": "^3.0.0",
34
- "@cowprotocol/sdk-config": "0.10.0",
35
- "@cowprotocol/sdk-common": "0.7.0"
34
+ "@cowprotocol/sdk-config": "1.0.0",
35
+ "@cowprotocol/sdk-common": "0.7.1"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsup src/index.ts --format esm,cjs --dts",