@cowprotocol/sdk-order-book 1.1.0 → 1.1.2
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 +6 -2
- package/dist/index.mjs +6 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -674,6 +674,7 @@ var HUNDRED_THOUSANDS = 1e5;
|
|
|
674
674
|
var ONE_HUNDRED_BPS = BigInt(100 * 100);
|
|
675
675
|
|
|
676
676
|
// src/quoteAmountsAndCosts/getProtocolFeeAmount.ts
|
|
677
|
+
var PROTOCOL_FEE_BPS_SCALE = BigInt(HUNDRED_THOUSANDS);
|
|
677
678
|
function getProtocolFeeAmount(params) {
|
|
678
679
|
const { orderParams, protocolFeeBps } = params;
|
|
679
680
|
const isSell = orderParams.kind === "sell" /* SELL */;
|
|
@@ -684,8 +685,11 @@ function getProtocolFeeAmount(params) {
|
|
|
684
685
|
const sellAmount = BigInt(sellAmountStr);
|
|
685
686
|
const buyAmount = BigInt(buyAmountStr);
|
|
686
687
|
const feeAmount = BigInt(feeAmountStr);
|
|
687
|
-
const protocolFeeScale =
|
|
688
|
-
const protocolFeeBpsBig = BigInt(protocolFeeBps * HUNDRED_THOUSANDS);
|
|
688
|
+
const protocolFeeScale = PROTOCOL_FEE_BPS_SCALE;
|
|
689
|
+
const protocolFeeBpsBig = BigInt(Math.round(protocolFeeBps * HUNDRED_THOUSANDS));
|
|
690
|
+
if (protocolFeeBpsBig <= 0n) {
|
|
691
|
+
return 0n;
|
|
692
|
+
}
|
|
689
693
|
if (isSell) {
|
|
690
694
|
const denominator = ONE_HUNDRED_BPS * protocolFeeScale - protocolFeeBpsBig;
|
|
691
695
|
return buyAmount * protocolFeeBpsBig / denominator;
|
package/dist/index.mjs
CHANGED
|
@@ -625,6 +625,7 @@ var HUNDRED_THOUSANDS = 1e5;
|
|
|
625
625
|
var ONE_HUNDRED_BPS = BigInt(100 * 100);
|
|
626
626
|
|
|
627
627
|
// src/quoteAmountsAndCosts/getProtocolFeeAmount.ts
|
|
628
|
+
var PROTOCOL_FEE_BPS_SCALE = BigInt(HUNDRED_THOUSANDS);
|
|
628
629
|
function getProtocolFeeAmount(params) {
|
|
629
630
|
const { orderParams, protocolFeeBps } = params;
|
|
630
631
|
const isSell = orderParams.kind === "sell" /* SELL */;
|
|
@@ -635,8 +636,11 @@ function getProtocolFeeAmount(params) {
|
|
|
635
636
|
const sellAmount = BigInt(sellAmountStr);
|
|
636
637
|
const buyAmount = BigInt(buyAmountStr);
|
|
637
638
|
const feeAmount = BigInt(feeAmountStr);
|
|
638
|
-
const protocolFeeScale =
|
|
639
|
-
const protocolFeeBpsBig = BigInt(protocolFeeBps * HUNDRED_THOUSANDS);
|
|
639
|
+
const protocolFeeScale = PROTOCOL_FEE_BPS_SCALE;
|
|
640
|
+
const protocolFeeBpsBig = BigInt(Math.round(protocolFeeBps * HUNDRED_THOUSANDS));
|
|
641
|
+
if (protocolFeeBpsBig <= 0n) {
|
|
642
|
+
return 0n;
|
|
643
|
+
}
|
|
640
644
|
if (isSell) {
|
|
641
645
|
const denominator = ONE_HUNDRED_BPS * protocolFeeScale - protocolFeeBpsBig;
|
|
642
646
|
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.
|
|
3
|
+
"version": "1.1.2",
|
|
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.
|
|
35
|
-
"@cowprotocol/sdk-common": "0.
|
|
34
|
+
"@cowprotocol/sdk-config": "0.10.0",
|
|
35
|
+
"@cowprotocol/sdk-common": "0.7.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|