@cowprotocol/sdk-order-book 0.6.1 → 0.6.3

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
@@ -630,6 +630,7 @@ var SigningScheme = /* @__PURE__ */ ((SigningScheme2) => {
630
630
  })(SigningScheme || {});
631
631
 
632
632
  // src/quoteAmountsAndCostsUtils.ts
633
+ var HUNDRED_THOUSANDS = 1e5;
633
634
  var ONE_HUNDRED_BPS = BigInt(100 * 100);
634
635
  function getQuoteAmountsWithCosts(params) {
635
636
  const { sellDecimals, buyDecimals, orderParams, protocolFeeBps = 0 } = params;
@@ -719,12 +720,13 @@ function getProtocolFeeAmount(params) {
719
720
  const sellAmount = BigInt(sellAmountStr);
720
721
  const buyAmount = BigInt(buyAmountStr);
721
722
  const feeAmount = BigInt(feeAmountStr);
722
- const protocolFeeBpsBig = BigInt(protocolFeeBps);
723
+ const protocolFeeScale = BigInt(HUNDRED_THOUSANDS);
724
+ const protocolFeeBpsBig = BigInt(protocolFeeBps * HUNDRED_THOUSANDS);
723
725
  if (isSell) {
724
- const denominator = ONE_HUNDRED_BPS - protocolFeeBpsBig;
726
+ const denominator = ONE_HUNDRED_BPS * protocolFeeScale - protocolFeeBpsBig;
725
727
  return buyAmount * protocolFeeBpsBig / denominator;
726
728
  } else {
727
- const denominator = ONE_HUNDRED_BPS + protocolFeeBpsBig;
729
+ const denominator = ONE_HUNDRED_BPS * protocolFeeScale + protocolFeeBpsBig;
728
730
  return (sellAmount + feeAmount) * protocolFeeBpsBig / denominator;
729
731
  }
730
732
  }
package/dist/index.mjs CHANGED
@@ -584,6 +584,7 @@ var SigningScheme = /* @__PURE__ */ ((SigningScheme2) => {
584
584
  })(SigningScheme || {});
585
585
 
586
586
  // src/quoteAmountsAndCostsUtils.ts
587
+ var HUNDRED_THOUSANDS = 1e5;
587
588
  var ONE_HUNDRED_BPS = BigInt(100 * 100);
588
589
  function getQuoteAmountsWithCosts(params) {
589
590
  const { sellDecimals, buyDecimals, orderParams, protocolFeeBps = 0 } = params;
@@ -673,12 +674,13 @@ function getProtocolFeeAmount(params) {
673
674
  const sellAmount = BigInt(sellAmountStr);
674
675
  const buyAmount = BigInt(buyAmountStr);
675
676
  const feeAmount = BigInt(feeAmountStr);
676
- const protocolFeeBpsBig = BigInt(protocolFeeBps);
677
+ const protocolFeeScale = BigInt(HUNDRED_THOUSANDS);
678
+ const protocolFeeBpsBig = BigInt(protocolFeeBps * HUNDRED_THOUSANDS);
677
679
  if (isSell) {
678
- const denominator = ONE_HUNDRED_BPS - protocolFeeBpsBig;
680
+ const denominator = ONE_HUNDRED_BPS * protocolFeeScale - protocolFeeBpsBig;
679
681
  return buyAmount * protocolFeeBpsBig / denominator;
680
682
  } else {
681
- const denominator = ONE_HUNDRED_BPS + protocolFeeBpsBig;
683
+ const denominator = ONE_HUNDRED_BPS * protocolFeeScale + protocolFeeBpsBig;
682
684
  return (sellAmount + feeAmount) * protocolFeeBpsBig / denominator;
683
685
  }
684
686
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/sdk-order-book",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
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.7.1",
35
- "@cowprotocol/sdk-common": "0.5.2"
34
+ "@cowprotocol/sdk-config": "0.7.3",
35
+ "@cowprotocol/sdk-common": "0.5.4"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsup src/index.ts --format esm,cjs --dts",