@cowprotocol/sdk-order-book 0.2.4-beta.0 → 0.3.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/README.md CHANGED
@@ -18,8 +18,6 @@ yarn add @cowprotocol/sdk-order-book
18
18
 
19
19
  ## Usage
20
20
 
21
- ### Individual package usage
22
-
23
21
  ```typescript
24
22
  import { OrderBookApi, SupportedChainId, OrderQuoteRequest, OrderCreation } from '@cowprotocol/sdk-order-book'
25
23
  import { setGlobalAdapter } from '@cowprotocol/sdk-common'
@@ -76,7 +74,7 @@ const trades = await orderBookApi.getTrades({
76
74
  })
77
75
  ```
78
76
 
79
- ### Usage with Umbrella SDK
77
+ ### Usage with CoW SDK
80
78
 
81
79
  ```typescript
82
80
  import { CowSdk, SupportedChainId, OrderQuoteRequest } from '@cowprotocol/cow-sdk'
@@ -94,7 +92,6 @@ const sdk = new CowSdk({
94
92
  adapter,
95
93
  })
96
94
 
97
- // Use Order Book through the umbrella SDK
98
95
  const { quote } = await sdk.orderBook.getQuote(quoteRequest)
99
96
  const orderId = await sdk.orderBook.sendOrder(signedOrder)
100
97
  const order = await sdk.orderBook.getOrder(orderId)
package/dist/index.d.mts CHANGED
@@ -510,12 +510,12 @@ type OrderMetaData = {
510
510
  */
511
511
  availableBalance?: TokenAmount | null;
512
512
  /**
513
- * The total amount of `sellToken` that has been executed for this order including fees.
513
+ * The total amount of `sellToken` that has been transferred from the user for this order so far.
514
514
  *
515
515
  */
516
516
  executedSellAmount: BigUint;
517
517
  /**
518
- * The total amount of `sellToken` that has been executed for this order without fees.
518
+ * The total amount of `sellToken` that has been transferred from the user for this order so far minus tokens that were transferred as part of the signed `fee` of the order. This is only relevant for old orders because now all orders have a signed `fee` of 0 and solvers compute an appropriate fee dynamically at the time of the order execution.
519
519
  *
520
520
  */
521
521
  executedSellAmountBeforeFees: BigUint;
@@ -525,7 +525,8 @@ type OrderMetaData = {
525
525
  */
526
526
  executedBuyAmount: BigUint;
527
527
  /**
528
- * The total amount of fees that have been executed for this order.
528
+ * [DEPRECATED] The total amount of the user signed `fee` that have been executed for this order. This value is only non-negative for very old orders.
529
+ *
529
530
  */
530
531
  executedFeeAmount: BigUint;
531
532
  /**
@@ -536,10 +537,6 @@ type OrderMetaData = {
536
537
  * Order status.
537
538
  */
538
539
  status: OrderStatus;
539
- /**
540
- * Amount that the signed fee would be without subsidies.
541
- */
542
- fullFeeAmount?: TokenAmount;
543
540
  /**
544
541
  * Liquidity orders are functionally the same as normal smart contract
545
542
  * orders but are not placed with the intent of actively getting
@@ -566,11 +563,8 @@ type OrderMetaData = {
566
563
  */
567
564
  onchainOrderData?: OnchainOrderData;
568
565
  /**
569
- * Surplus fee that the limit order was executed with.
570
- */
571
- executedSurplusFee?: BigUint;
572
- /**
573
- * Total fee charged for execution of the order. Contains network fee and protocol fees.
566
+ * Total fee charged for execution of the order. Contains network fee and protocol fees. This takes into account the historic static fee signed by the user and the new dynamic fee computed by solvers.
567
+ *
574
568
  */
575
569
  executedFee?: BigUint;
576
570
  /**
@@ -662,7 +656,7 @@ type OrderParameters = {
662
656
  validTo: number;
663
657
  appData: AppDataHash;
664
658
  /**
665
- * feeRatio * sellAmount + minimal_fee in atoms.
659
+ * sellAmount in atoms to cover network fees. Needs to be zero (and incorporated into the limit price) when placing the order
666
660
  */
667
661
  feeAmount: TokenAmount;
668
662
  /**
@@ -710,7 +704,8 @@ declare namespace OrderPostError {
710
704
  UNSUPPORTED_TOKEN = "UnsupportedToken",
711
705
  INVALID_APP_DATA = "InvalidAppData",
712
706
  APP_DATA_HASH_MISMATCH = "AppDataHashMismatch",
713
- APPDATA_FROM_MISMATCH = "AppdataFromMismatch"
707
+ APPDATA_FROM_MISMATCH = "AppdataFromMismatch",
708
+ OLD_ORDER_ACTIVELY_BID_ON = "OldOrderActivelyBidOn"
714
709
  }
715
710
  }
716
711
 
@@ -826,6 +821,11 @@ type OrderQuoteRequest = (OrderQuoteSide & OrderQuoteValidity & {
826
821
  *
827
822
  */
828
823
  onchainOrder?: any;
824
+ /**
825
+ * User provided timeout in milliseconds. Can only be used to reduce the response time for quote requests if the default is too slow as values greater than the default will be capped to the default. Note that reducing the timeout can result in worse quotes because the reduced timeout might be too slow for some price estimators.
826
+ *
827
+ */
828
+ timeout?: number;
829
829
  });
830
830
 
831
831
  /**
@@ -852,6 +852,16 @@ type OrderQuoteResponse = {
852
852
  *
853
853
  */
854
854
  verified: boolean;
855
+ /**
856
+ * Protocol fee in basis points (e.g., "2" for 0.02%). This represents the volume-based fee policy. Only present when configured.
857
+ *
858
+ */
859
+ protocolFeeBps?: string;
860
+ /**
861
+ * Protocol fee amount in sell token. For SELL orders, this amount is already included in the returned sellAmount. For BUY orders, this amount is applied before network fees are added to sellAmount. Only present when a volume fee is configured.
862
+ *
863
+ */
864
+ protocolFeeSellAmount?: TokenAmount;
855
865
  };
856
866
 
857
867
  type PriceEstimationError = {
@@ -869,9 +879,9 @@ declare namespace PriceEstimationError {
869
879
 
870
880
  type SolverSettlement = {
871
881
  /**
872
- * Name of the solver.
882
+ * Which position the solution achieved in the total ranking of the competition.
873
883
  */
874
- solver?: string;
884
+ ranking?: number;
875
885
  /**
876
886
  * The address used by the solver to execute the settlement on-chain.
877
887
  *
@@ -879,22 +889,21 @@ type SolverSettlement = {
879
889
  * used instead.
880
890
  */
881
891
  solverAddress?: string;
882
- objective?: {
883
- /**
884
- * The total objective value used for ranking solutions.
885
- */
886
- total?: number;
887
- surplus?: number;
888
- fees?: number;
889
- cost?: number;
890
- gas?: number;
891
- };
892
892
  /**
893
893
  * The score of the current auction as defined in [CIP-20](https://snapshot.org/#/cow.eth/proposal/0x2d3f9bd1ea72dca84b03e97dda3efc1f4a42a772c54bd2037e8b62e7d09a491f).
894
- * It is `null` for old auctions.
895
894
  *
896
895
  */
897
- score?: BigUint | null;
896
+ score?: BigUint;
897
+ /**
898
+ * The reference score as defined in [CIP-67](https://forum.cow.fi/t/cip-67-moving-from-batch-auction-to-the-fair-combinatorial-auction/2967) (if available).
899
+ *
900
+ */
901
+ referenceScore?: BigUint | null;
902
+ /**
903
+ * Transaction in which the solution was executed onchain (if available).
904
+ *
905
+ */
906
+ txHash?: TransactionHash | null;
898
907
  /**
899
908
  * The prices of tokens for settled user orders as passed to the settlement contract.
900
909
  *
@@ -905,12 +914,17 @@ type SolverSettlement = {
905
914
  */
906
915
  orders?: Array<{
907
916
  id?: UID;
908
- executedAmount?: BigUint;
917
+ sellAmount?: BigUint;
918
+ buyAmount?: BigUint;
909
919
  }>;
910
920
  /**
911
921
  * whether the solution is a winner (received the right to get executed) or not
912
922
  */
913
923
  isWinner?: boolean;
924
+ /**
925
+ * whether the solution was filtered out according to the rules of [CIP-67](https://forum.cow.fi/t/cip-67-moving-from-batch-auction-to-the-fair-combinatorial-auction/2967).
926
+ */
927
+ filteredOut?: boolean;
914
928
  };
915
929
 
916
930
  /**
@@ -925,15 +939,19 @@ type SolverCompetitionResponse = {
925
939
  */
926
940
  auctionId?: number;
927
941
  /**
928
- * The hash of the transaction that the winning solution of this info was submitted in.
942
+ * Block that the auction started on.
943
+ */
944
+ auctionStartBlock?: number;
945
+ /**
946
+ * The hashes of the transactions for the winning solutions of this competition.
947
+ *
929
948
  */
930
- transactionHash?: TransactionHash | null;
949
+ transactionHashes?: Array<TransactionHash>;
931
950
  /**
932
- * Gas price used for ranking solutions.
951
+ * The reference scores for each winning solver according to [CIP-67](https://forum.cow.fi/t/cip-67-moving-from-batch-auction-to-the-fair-combinatorial-auction/2967) (if available).
952
+ *
933
953
  */
934
- gasPrice?: number;
935
- liquidityCollectedBlock?: number;
936
- competitionSimulationBlock?: number;
954
+ referenceScores?: Record<string, BigUint>;
937
955
  auction?: CompetitionAuction;
938
956
  /**
939
957
  * Maps from solver name to object describing that solver's settlement.
@@ -1023,6 +1041,10 @@ interface Costs<T> {
1023
1041
  amount: T;
1024
1042
  bps: number;
1025
1043
  };
1044
+ protocolFee: {
1045
+ amount: T;
1046
+ bps: number;
1047
+ };
1026
1048
  }
1027
1049
  /**
1028
1050
  * Details about costs and amounts, costs and fees of a quote.
@@ -1033,6 +1055,9 @@ interface Costs<T> {
1033
1055
  * The order of adding fees and costs is as follows:
1034
1056
  * 1. Network fee is always added to the sell amount
1035
1057
  * 2. Partner fee is added to the surplus amount (sell amount for sell-orders, buy amount for buy-orders)
1058
+ * 3. Protocol fee is already baked into the quoted amounts:
1059
+ * - for SELL orders it has been deducted from the buy amount
1060
+ * - for BUY orders it has been added on top of the sell amount.
1036
1061
  *
1037
1062
  * For sell-orders the partner fee is subtracted from the buy amount after network costs.
1038
1063
  * For buy-orders the partner fee is added on top of the sell amount after network costs.
@@ -1052,6 +1077,7 @@ interface QuoteAmountsAndCosts<T = bigint> {
1052
1077
  * so UIs can decide how to show it to the user.
1053
1078
  */
1054
1079
  costs: Costs<T>;
1080
+ beforeAllFees: Amounts<T>;
1055
1081
  /**
1056
1082
  * Amounts before network costs. This amount could be shown to the user to reflect how much they are expected to get
1057
1083
  * before applying any costs or fees (if costs and fees are displayed separately).
@@ -1364,11 +1390,13 @@ interface QuoteAmountsAndCostsParams {
1364
1390
  buyDecimals: number;
1365
1391
  slippagePercentBps: number;
1366
1392
  partnerFeeBps: number | undefined;
1393
+ protocolFeeBps: number | undefined;
1367
1394
  }
1368
1395
  declare function getQuoteAmountsWithCosts(params: {
1369
1396
  sellDecimals: number;
1370
1397
  buyDecimals: number;
1371
1398
  orderParams: OrderParameters;
1399
+ protocolFeeBps?: number;
1372
1400
  }): {
1373
1401
  isSell: boolean;
1374
1402
  quotePrice: number;
package/dist/index.d.ts CHANGED
@@ -510,12 +510,12 @@ type OrderMetaData = {
510
510
  */
511
511
  availableBalance?: TokenAmount | null;
512
512
  /**
513
- * The total amount of `sellToken` that has been executed for this order including fees.
513
+ * The total amount of `sellToken` that has been transferred from the user for this order so far.
514
514
  *
515
515
  */
516
516
  executedSellAmount: BigUint;
517
517
  /**
518
- * The total amount of `sellToken` that has been executed for this order without fees.
518
+ * The total amount of `sellToken` that has been transferred from the user for this order so far minus tokens that were transferred as part of the signed `fee` of the order. This is only relevant for old orders because now all orders have a signed `fee` of 0 and solvers compute an appropriate fee dynamically at the time of the order execution.
519
519
  *
520
520
  */
521
521
  executedSellAmountBeforeFees: BigUint;
@@ -525,7 +525,8 @@ type OrderMetaData = {
525
525
  */
526
526
  executedBuyAmount: BigUint;
527
527
  /**
528
- * The total amount of fees that have been executed for this order.
528
+ * [DEPRECATED] The total amount of the user signed `fee` that have been executed for this order. This value is only non-negative for very old orders.
529
+ *
529
530
  */
530
531
  executedFeeAmount: BigUint;
531
532
  /**
@@ -536,10 +537,6 @@ type OrderMetaData = {
536
537
  * Order status.
537
538
  */
538
539
  status: OrderStatus;
539
- /**
540
- * Amount that the signed fee would be without subsidies.
541
- */
542
- fullFeeAmount?: TokenAmount;
543
540
  /**
544
541
  * Liquidity orders are functionally the same as normal smart contract
545
542
  * orders but are not placed with the intent of actively getting
@@ -566,11 +563,8 @@ type OrderMetaData = {
566
563
  */
567
564
  onchainOrderData?: OnchainOrderData;
568
565
  /**
569
- * Surplus fee that the limit order was executed with.
570
- */
571
- executedSurplusFee?: BigUint;
572
- /**
573
- * Total fee charged for execution of the order. Contains network fee and protocol fees.
566
+ * Total fee charged for execution of the order. Contains network fee and protocol fees. This takes into account the historic static fee signed by the user and the new dynamic fee computed by solvers.
567
+ *
574
568
  */
575
569
  executedFee?: BigUint;
576
570
  /**
@@ -662,7 +656,7 @@ type OrderParameters = {
662
656
  validTo: number;
663
657
  appData: AppDataHash;
664
658
  /**
665
- * feeRatio * sellAmount + minimal_fee in atoms.
659
+ * sellAmount in atoms to cover network fees. Needs to be zero (and incorporated into the limit price) when placing the order
666
660
  */
667
661
  feeAmount: TokenAmount;
668
662
  /**
@@ -710,7 +704,8 @@ declare namespace OrderPostError {
710
704
  UNSUPPORTED_TOKEN = "UnsupportedToken",
711
705
  INVALID_APP_DATA = "InvalidAppData",
712
706
  APP_DATA_HASH_MISMATCH = "AppDataHashMismatch",
713
- APPDATA_FROM_MISMATCH = "AppdataFromMismatch"
707
+ APPDATA_FROM_MISMATCH = "AppdataFromMismatch",
708
+ OLD_ORDER_ACTIVELY_BID_ON = "OldOrderActivelyBidOn"
714
709
  }
715
710
  }
716
711
 
@@ -826,6 +821,11 @@ type OrderQuoteRequest = (OrderQuoteSide & OrderQuoteValidity & {
826
821
  *
827
822
  */
828
823
  onchainOrder?: any;
824
+ /**
825
+ * User provided timeout in milliseconds. Can only be used to reduce the response time for quote requests if the default is too slow as values greater than the default will be capped to the default. Note that reducing the timeout can result in worse quotes because the reduced timeout might be too slow for some price estimators.
826
+ *
827
+ */
828
+ timeout?: number;
829
829
  });
830
830
 
831
831
  /**
@@ -852,6 +852,16 @@ type OrderQuoteResponse = {
852
852
  *
853
853
  */
854
854
  verified: boolean;
855
+ /**
856
+ * Protocol fee in basis points (e.g., "2" for 0.02%). This represents the volume-based fee policy. Only present when configured.
857
+ *
858
+ */
859
+ protocolFeeBps?: string;
860
+ /**
861
+ * Protocol fee amount in sell token. For SELL orders, this amount is already included in the returned sellAmount. For BUY orders, this amount is applied before network fees are added to sellAmount. Only present when a volume fee is configured.
862
+ *
863
+ */
864
+ protocolFeeSellAmount?: TokenAmount;
855
865
  };
856
866
 
857
867
  type PriceEstimationError = {
@@ -869,9 +879,9 @@ declare namespace PriceEstimationError {
869
879
 
870
880
  type SolverSettlement = {
871
881
  /**
872
- * Name of the solver.
882
+ * Which position the solution achieved in the total ranking of the competition.
873
883
  */
874
- solver?: string;
884
+ ranking?: number;
875
885
  /**
876
886
  * The address used by the solver to execute the settlement on-chain.
877
887
  *
@@ -879,22 +889,21 @@ type SolverSettlement = {
879
889
  * used instead.
880
890
  */
881
891
  solverAddress?: string;
882
- objective?: {
883
- /**
884
- * The total objective value used for ranking solutions.
885
- */
886
- total?: number;
887
- surplus?: number;
888
- fees?: number;
889
- cost?: number;
890
- gas?: number;
891
- };
892
892
  /**
893
893
  * The score of the current auction as defined in [CIP-20](https://snapshot.org/#/cow.eth/proposal/0x2d3f9bd1ea72dca84b03e97dda3efc1f4a42a772c54bd2037e8b62e7d09a491f).
894
- * It is `null` for old auctions.
895
894
  *
896
895
  */
897
- score?: BigUint | null;
896
+ score?: BigUint;
897
+ /**
898
+ * The reference score as defined in [CIP-67](https://forum.cow.fi/t/cip-67-moving-from-batch-auction-to-the-fair-combinatorial-auction/2967) (if available).
899
+ *
900
+ */
901
+ referenceScore?: BigUint | null;
902
+ /**
903
+ * Transaction in which the solution was executed onchain (if available).
904
+ *
905
+ */
906
+ txHash?: TransactionHash | null;
898
907
  /**
899
908
  * The prices of tokens for settled user orders as passed to the settlement contract.
900
909
  *
@@ -905,12 +914,17 @@ type SolverSettlement = {
905
914
  */
906
915
  orders?: Array<{
907
916
  id?: UID;
908
- executedAmount?: BigUint;
917
+ sellAmount?: BigUint;
918
+ buyAmount?: BigUint;
909
919
  }>;
910
920
  /**
911
921
  * whether the solution is a winner (received the right to get executed) or not
912
922
  */
913
923
  isWinner?: boolean;
924
+ /**
925
+ * whether the solution was filtered out according to the rules of [CIP-67](https://forum.cow.fi/t/cip-67-moving-from-batch-auction-to-the-fair-combinatorial-auction/2967).
926
+ */
927
+ filteredOut?: boolean;
914
928
  };
915
929
 
916
930
  /**
@@ -925,15 +939,19 @@ type SolverCompetitionResponse = {
925
939
  */
926
940
  auctionId?: number;
927
941
  /**
928
- * The hash of the transaction that the winning solution of this info was submitted in.
942
+ * Block that the auction started on.
943
+ */
944
+ auctionStartBlock?: number;
945
+ /**
946
+ * The hashes of the transactions for the winning solutions of this competition.
947
+ *
929
948
  */
930
- transactionHash?: TransactionHash | null;
949
+ transactionHashes?: Array<TransactionHash>;
931
950
  /**
932
- * Gas price used for ranking solutions.
951
+ * The reference scores for each winning solver according to [CIP-67](https://forum.cow.fi/t/cip-67-moving-from-batch-auction-to-the-fair-combinatorial-auction/2967) (if available).
952
+ *
933
953
  */
934
- gasPrice?: number;
935
- liquidityCollectedBlock?: number;
936
- competitionSimulationBlock?: number;
954
+ referenceScores?: Record<string, BigUint>;
937
955
  auction?: CompetitionAuction;
938
956
  /**
939
957
  * Maps from solver name to object describing that solver's settlement.
@@ -1023,6 +1041,10 @@ interface Costs<T> {
1023
1041
  amount: T;
1024
1042
  bps: number;
1025
1043
  };
1044
+ protocolFee: {
1045
+ amount: T;
1046
+ bps: number;
1047
+ };
1026
1048
  }
1027
1049
  /**
1028
1050
  * Details about costs and amounts, costs and fees of a quote.
@@ -1033,6 +1055,9 @@ interface Costs<T> {
1033
1055
  * The order of adding fees and costs is as follows:
1034
1056
  * 1. Network fee is always added to the sell amount
1035
1057
  * 2. Partner fee is added to the surplus amount (sell amount for sell-orders, buy amount for buy-orders)
1058
+ * 3. Protocol fee is already baked into the quoted amounts:
1059
+ * - for SELL orders it has been deducted from the buy amount
1060
+ * - for BUY orders it has been added on top of the sell amount.
1036
1061
  *
1037
1062
  * For sell-orders the partner fee is subtracted from the buy amount after network costs.
1038
1063
  * For buy-orders the partner fee is added on top of the sell amount after network costs.
@@ -1052,6 +1077,7 @@ interface QuoteAmountsAndCosts<T = bigint> {
1052
1077
  * so UIs can decide how to show it to the user.
1053
1078
  */
1054
1079
  costs: Costs<T>;
1080
+ beforeAllFees: Amounts<T>;
1055
1081
  /**
1056
1082
  * Amounts before network costs. This amount could be shown to the user to reflect how much they are expected to get
1057
1083
  * before applying any costs or fees (if costs and fees are displayed separately).
@@ -1364,11 +1390,13 @@ interface QuoteAmountsAndCostsParams {
1364
1390
  buyDecimals: number;
1365
1391
  slippagePercentBps: number;
1366
1392
  partnerFeeBps: number | undefined;
1393
+ protocolFeeBps: number | undefined;
1367
1394
  }
1368
1395
  declare function getQuoteAmountsWithCosts(params: {
1369
1396
  sellDecimals: number;
1370
1397
  buyDecimals: number;
1371
1398
  orderParams: OrderParameters;
1399
+ protocolFeeBps?: number;
1372
1400
  }): {
1373
1401
  isSell: boolean;
1374
1402
  quotePrice: number;
package/dist/index.js CHANGED
@@ -183,7 +183,9 @@ var ORDER_BOOK_PROD_CONFIG = {
183
183
  [import_sdk_config2.SupportedChainId.POLYGON]: `${PROD_BASE_URL}/polygon`,
184
184
  [import_sdk_config2.SupportedChainId.AVALANCHE]: `${PROD_BASE_URL}/avalanche`,
185
185
  [import_sdk_config2.SupportedChainId.LENS]: `${PROD_BASE_URL}/lens`,
186
- [import_sdk_config2.SupportedChainId.BNB]: `${PROD_BASE_URL}/bnb`
186
+ [import_sdk_config2.SupportedChainId.BNB]: `${PROD_BASE_URL}/bnb`,
187
+ [import_sdk_config2.SupportedChainId.LINEA]: `${PROD_BASE_URL}/linea`,
188
+ [import_sdk_config2.SupportedChainId.PLASMA]: `${PROD_BASE_URL}/plasma`
187
189
  };
188
190
  var ORDER_BOOK_STAGING_CONFIG = {
189
191
  [import_sdk_config2.SupportedChainId.MAINNET]: `${STAGING_BASE_URL}/mainnet`,
@@ -194,7 +196,9 @@ var ORDER_BOOK_STAGING_CONFIG = {
194
196
  [import_sdk_config2.SupportedChainId.POLYGON]: `${STAGING_BASE_URL}/polygon`,
195
197
  [import_sdk_config2.SupportedChainId.AVALANCHE]: `${STAGING_BASE_URL}/avalanche`,
196
198
  [import_sdk_config2.SupportedChainId.LENS]: `${STAGING_BASE_URL}/lens`,
197
- [import_sdk_config2.SupportedChainId.BNB]: `${STAGING_BASE_URL}/bnb`
199
+ [import_sdk_config2.SupportedChainId.BNB]: `${STAGING_BASE_URL}/bnb`,
200
+ [import_sdk_config2.SupportedChainId.LINEA]: `${STAGING_BASE_URL}/linea`,
201
+ [import_sdk_config2.SupportedChainId.PLASMA]: `${STAGING_BASE_URL}/plasma`
198
202
  };
199
203
  function cleanObjectFromUndefinedValues(obj) {
200
204
  return Object.keys(obj).reduce(
@@ -558,6 +562,7 @@ var OrderPostError;
558
562
  errorType2["INVALID_APP_DATA"] = "InvalidAppData";
559
563
  errorType2["APP_DATA_HASH_MISMATCH"] = "AppDataHashMismatch";
560
564
  errorType2["APPDATA_FROM_MISMATCH"] = "AppdataFromMismatch";
565
+ errorType2["OLD_ORDER_ACTIVELY_BID_ON"] = "OldOrderActivelyBidOn";
561
566
  })(errorType = OrderPostError2.errorType || (OrderPostError2.errorType = {}));
562
567
  })(OrderPostError || (OrderPostError = {}));
563
568
 
@@ -623,16 +628,24 @@ var SigningScheme = /* @__PURE__ */ ((SigningScheme2) => {
623
628
  // src/quoteAmountsAndCostsUtils.ts
624
629
  var ONE_HUNDRED_BPS = BigInt(100 * 100);
625
630
  function getQuoteAmountsWithCosts(params) {
626
- const { sellDecimals, buyDecimals, orderParams } = params;
631
+ const { sellDecimals, buyDecimals, orderParams, protocolFeeBps = 0 } = params;
632
+ const isSell = orderParams.kind === "sell" /* SELL */;
633
+ const protocolFeeAmount = getProtocolFeeAmount({ orderParams, isSell, protocolFeeBps });
634
+ const protocolFeeAmountDecimals = isSell ? buyDecimals : sellDecimals;
627
635
  const {
628
636
  sellAmountAfterNetworkCosts,
629
637
  buyAmountAfterNetworkCosts,
630
638
  buyAmountBeforeNetworkCosts,
631
- isSell,
632
639
  networkCostAmount,
633
640
  quotePrice,
634
641
  sellAmountBeforeNetworkCosts
635
- } = _getQuoteAmountsWithCosts({ sellDecimals, buyDecimals, orderParams });
642
+ } = _getQuoteAmountsWithCosts({
643
+ sellDecimals,
644
+ buyDecimals,
645
+ orderParams,
646
+ protocolFeeAmount: getBigNumber(protocolFeeAmount, protocolFeeAmountDecimals),
647
+ isSell
648
+ });
636
649
  return {
637
650
  isSell,
638
651
  quotePrice,
@@ -644,12 +657,17 @@ function getQuoteAmountsWithCosts(params) {
644
657
  };
645
658
  }
646
659
  function _getQuoteAmountsWithCosts(params) {
647
- const { sellDecimals, buyDecimals, orderParams } = params;
648
- const isSell = orderParams.kind === "sell" /* SELL */;
660
+ const { sellDecimals, buyDecimals, orderParams, isSell, protocolFeeAmount } = params;
649
661
  const networkCostAmount = getBigNumber(orderParams.feeAmount, sellDecimals);
650
662
  const sellAmountBeforeNetworkCosts = getBigNumber(orderParams.sellAmount, sellDecimals);
651
663
  const buyAmountAfterNetworkCosts = getBigNumber(orderParams.buyAmount, buyDecimals);
652
- const quotePrice = buyAmountAfterNetworkCosts.num / sellAmountBeforeNetworkCosts.num;
664
+ const quotePrice = isSell ? (
665
+ // For SELL order is already deducting protocol fees from buyAmount, so we need to add it back to get the actual price
666
+ (buyAmountAfterNetworkCosts.num + protocolFeeAmount.num) / sellAmountBeforeNetworkCosts.num
667
+ ) : (
668
+ // For BUY order is already adding protocol fees to sellAmount, so we need to subtract it to get the actual price
669
+ buyAmountAfterNetworkCosts.num / (sellAmountBeforeNetworkCosts.num - protocolFeeAmount.num)
670
+ );
653
671
  const sellAmountAfterNetworkCosts = getBigNumber(
654
672
  sellAmountBeforeNetworkCosts.big + networkCostAmount.big,
655
673
  sellDecimals
@@ -669,25 +687,43 @@ function getQuoteAmountsWithPartnerFee(params) {
669
687
  const {
670
688
  sellAmountAfterNetworkCosts,
671
689
  buyAmountAfterNetworkCosts,
672
- buyAmountBeforeNetworkCosts,
673
- sellAmountBeforeNetworkCosts,
690
+ buyAmountBeforeProtocolFee,
691
+ sellAmountBeforeProtocolFee,
674
692
  isSell,
675
693
  partnerFeeBps
676
694
  } = params;
677
- const surplusAmount = isSell ? buyAmountBeforeNetworkCosts.big : sellAmountBeforeNetworkCosts.big;
678
- const partnerFeeAmount = partnerFeeBps > 0 ? surplusAmount * BigInt(partnerFeeBps) / ONE_HUNDRED_BPS : BigInt(0);
695
+ const surplusAmountForPartnerFee = isSell ? buyAmountBeforeProtocolFee : sellAmountBeforeProtocolFee;
696
+ const partnerFeeAmount = partnerFeeBps > 0 ? surplusAmountForPartnerFee * BigInt(partnerFeeBps) / ONE_HUNDRED_BPS : BigInt(0);
679
697
  const afterPartnerFees = isSell ? {
680
- sellAmount: sellAmountAfterNetworkCosts.big,
681
- buyAmount: buyAmountAfterNetworkCosts.big - partnerFeeAmount
698
+ sellAmount: sellAmountAfterNetworkCosts,
699
+ buyAmount: buyAmountAfterNetworkCosts - partnerFeeAmount
682
700
  } : {
683
- sellAmount: sellAmountAfterNetworkCosts.big + partnerFeeAmount,
684
- buyAmount: buyAmountAfterNetworkCosts.big
701
+ sellAmount: sellAmountAfterNetworkCosts + partnerFeeAmount,
702
+ buyAmount: buyAmountAfterNetworkCosts
685
703
  };
686
704
  return {
687
705
  partnerFeeAmount,
688
706
  afterPartnerFees
689
707
  };
690
708
  }
709
+ function getProtocolFeeAmount(params) {
710
+ const { orderParams, protocolFeeBps, isSell } = params;
711
+ if (protocolFeeBps <= 0) {
712
+ return 0n;
713
+ }
714
+ const { sellAmount: sellAmountStr, buyAmount: buyAmountStr, feeAmount: feeAmountStr } = orderParams;
715
+ const sellAmount = BigInt(sellAmountStr);
716
+ const buyAmount = BigInt(buyAmountStr);
717
+ const feeAmount = BigInt(feeAmountStr);
718
+ const protocolFeeBpsBig = BigInt(protocolFeeBps);
719
+ if (isSell) {
720
+ const denominator = ONE_HUNDRED_BPS - protocolFeeBpsBig;
721
+ return buyAmount * protocolFeeBpsBig / denominator;
722
+ } else {
723
+ const denominator = ONE_HUNDRED_BPS + protocolFeeBpsBig;
724
+ return (sellAmount + feeAmount) * protocolFeeBpsBig / denominator;
725
+ }
726
+ }
691
727
  function getQuoteAmountsWithSlippage(params) {
692
728
  const { afterPartnerFees, isSell, slippagePercentBps } = params;
693
729
  const getSlippageAmount = (amount) => amount * BigInt(slippagePercentBps) / ONE_HUNDRED_BPS;
@@ -705,20 +741,35 @@ function getQuoteAmountsWithSlippage(params) {
705
741
  function getQuoteAmountsAndCosts(params) {
706
742
  const { orderParams, sellDecimals, buyDecimals, slippagePercentBps } = params;
707
743
  const partnerFeeBps = params.partnerFeeBps ?? 0;
708
- const {
744
+ const protocolFeeBps = params.protocolFeeBps ?? 0;
745
+ const isSell = orderParams.kind === "sell" /* SELL */;
746
+ const protocolFeeAmount = getProtocolFeeAmount({
747
+ orderParams,
709
748
  isSell,
749
+ protocolFeeBps
750
+ });
751
+ const protocolFeeAmountDecimals = isSell ? buyDecimals : sellDecimals;
752
+ const {
710
753
  networkCostAmount,
711
754
  sellAmountBeforeNetworkCosts,
712
755
  buyAmountAfterNetworkCosts,
713
756
  sellAmountAfterNetworkCosts,
714
757
  buyAmountBeforeNetworkCosts,
715
758
  quotePrice
716
- } = _getQuoteAmountsWithCosts({ sellDecimals, buyDecimals, orderParams });
759
+ } = _getQuoteAmountsWithCosts({
760
+ sellDecimals,
761
+ buyDecimals,
762
+ orderParams,
763
+ isSell,
764
+ protocolFeeAmount: getBigNumber(protocolFeeAmount, protocolFeeAmountDecimals)
765
+ });
766
+ const buyAmountBeforeProtocolFee = isSell ? protocolFeeBps > 0 ? buyAmountAfterNetworkCosts.big + protocolFeeAmount : buyAmountBeforeNetworkCosts.big : buyAmountAfterNetworkCosts.big;
767
+ const sellAmountBeforeProtocolFee = isSell ? sellAmountAfterNetworkCosts.big : protocolFeeBps > 0 ? sellAmountAfterNetworkCosts.big - protocolFeeAmount : sellAmountBeforeNetworkCosts.big;
717
768
  const { afterPartnerFees, partnerFeeAmount } = getQuoteAmountsWithPartnerFee({
718
- sellAmountAfterNetworkCosts,
719
- buyAmountAfterNetworkCosts,
720
- buyAmountBeforeNetworkCosts,
721
- sellAmountBeforeNetworkCosts,
769
+ sellAmountAfterNetworkCosts: sellAmountAfterNetworkCosts.big,
770
+ buyAmountAfterNetworkCosts: buyAmountAfterNetworkCosts.big,
771
+ buyAmountBeforeProtocolFee,
772
+ sellAmountBeforeProtocolFee,
722
773
  isSell,
723
774
  partnerFeeBps
724
775
  });
@@ -727,6 +778,20 @@ function getQuoteAmountsAndCosts(params) {
727
778
  isSell,
728
779
  slippagePercentBps
729
780
  });
781
+ const beforeNetworkCosts = isSell ? {
782
+ sellAmount: sellAmountBeforeNetworkCosts.big,
783
+ buyAmount: buyAmountBeforeProtocolFee
784
+ } : {
785
+ sellAmount: sellAmountBeforeProtocolFee,
786
+ buyAmount: buyAmountBeforeNetworkCosts.big
787
+ };
788
+ const beforeAllFees = isSell ? {
789
+ sellAmount: sellAmountBeforeNetworkCosts.big,
790
+ buyAmount: buyAmountBeforeNetworkCosts.big + protocolFeeAmount
791
+ } : {
792
+ sellAmount: sellAmountBeforeNetworkCosts.big - protocolFeeAmount,
793
+ buyAmount: buyAmountBeforeNetworkCosts.big
794
+ };
730
795
  return {
731
796
  isSell,
732
797
  costs: {
@@ -737,12 +802,14 @@ function getQuoteAmountsAndCosts(params) {
737
802
  partnerFee: {
738
803
  amount: partnerFeeAmount,
739
804
  bps: partnerFeeBps
805
+ },
806
+ protocolFee: {
807
+ amount: protocolFeeAmount,
808
+ bps: protocolFeeBps
740
809
  }
741
810
  },
742
- beforeNetworkCosts: {
743
- sellAmount: sellAmountBeforeNetworkCosts.big,
744
- buyAmount: buyAmountBeforeNetworkCosts.big
745
- },
811
+ beforeNetworkCosts,
812
+ beforeAllFees,
746
813
  afterNetworkCosts: {
747
814
  sellAmount: sellAmountAfterNetworkCosts.big,
748
815
  buyAmount: buyAmountAfterNetworkCosts.big
package/dist/index.mjs CHANGED
@@ -2,11 +2,11 @@
2
2
  import "cross-fetch/polyfill";
3
3
  import { RateLimiter } from "limiter";
4
4
  import {
5
- SupportedChainId,
6
5
  DEFAULT_COW_API_CONTEXT,
7
- ENVS_LIST
6
+ ENVS_LIST,
7
+ SupportedChainId
8
8
  } from "@cowprotocol/sdk-config";
9
- import { CowError, log, jsonWithBigintReplacer } from "@cowprotocol/sdk-common";
9
+ import { CowError, jsonWithBigintReplacer, log } from "@cowprotocol/sdk-common";
10
10
 
11
11
  // src/request.ts
12
12
  import { backOff } from "exponential-backoff";
@@ -137,7 +137,9 @@ var ORDER_BOOK_PROD_CONFIG = {
137
137
  [SupportedChainId.POLYGON]: `${PROD_BASE_URL}/polygon`,
138
138
  [SupportedChainId.AVALANCHE]: `${PROD_BASE_URL}/avalanche`,
139
139
  [SupportedChainId.LENS]: `${PROD_BASE_URL}/lens`,
140
- [SupportedChainId.BNB]: `${PROD_BASE_URL}/bnb`
140
+ [SupportedChainId.BNB]: `${PROD_BASE_URL}/bnb`,
141
+ [SupportedChainId.LINEA]: `${PROD_BASE_URL}/linea`,
142
+ [SupportedChainId.PLASMA]: `${PROD_BASE_URL}/plasma`
141
143
  };
142
144
  var ORDER_BOOK_STAGING_CONFIG = {
143
145
  [SupportedChainId.MAINNET]: `${STAGING_BASE_URL}/mainnet`,
@@ -148,7 +150,9 @@ var ORDER_BOOK_STAGING_CONFIG = {
148
150
  [SupportedChainId.POLYGON]: `${STAGING_BASE_URL}/polygon`,
149
151
  [SupportedChainId.AVALANCHE]: `${STAGING_BASE_URL}/avalanche`,
150
152
  [SupportedChainId.LENS]: `${STAGING_BASE_URL}/lens`,
151
- [SupportedChainId.BNB]: `${STAGING_BASE_URL}/bnb`
153
+ [SupportedChainId.BNB]: `${STAGING_BASE_URL}/bnb`,
154
+ [SupportedChainId.LINEA]: `${STAGING_BASE_URL}/linea`,
155
+ [SupportedChainId.PLASMA]: `${STAGING_BASE_URL}/plasma`
152
156
  };
153
157
  function cleanObjectFromUndefinedValues(obj) {
154
158
  return Object.keys(obj).reduce(
@@ -512,6 +516,7 @@ var OrderPostError;
512
516
  errorType2["INVALID_APP_DATA"] = "InvalidAppData";
513
517
  errorType2["APP_DATA_HASH_MISMATCH"] = "AppDataHashMismatch";
514
518
  errorType2["APPDATA_FROM_MISMATCH"] = "AppdataFromMismatch";
519
+ errorType2["OLD_ORDER_ACTIVELY_BID_ON"] = "OldOrderActivelyBidOn";
515
520
  })(errorType = OrderPostError2.errorType || (OrderPostError2.errorType = {}));
516
521
  })(OrderPostError || (OrderPostError = {}));
517
522
 
@@ -577,16 +582,24 @@ var SigningScheme = /* @__PURE__ */ ((SigningScheme2) => {
577
582
  // src/quoteAmountsAndCostsUtils.ts
578
583
  var ONE_HUNDRED_BPS = BigInt(100 * 100);
579
584
  function getQuoteAmountsWithCosts(params) {
580
- const { sellDecimals, buyDecimals, orderParams } = params;
585
+ const { sellDecimals, buyDecimals, orderParams, protocolFeeBps = 0 } = params;
586
+ const isSell = orderParams.kind === "sell" /* SELL */;
587
+ const protocolFeeAmount = getProtocolFeeAmount({ orderParams, isSell, protocolFeeBps });
588
+ const protocolFeeAmountDecimals = isSell ? buyDecimals : sellDecimals;
581
589
  const {
582
590
  sellAmountAfterNetworkCosts,
583
591
  buyAmountAfterNetworkCosts,
584
592
  buyAmountBeforeNetworkCosts,
585
- isSell,
586
593
  networkCostAmount,
587
594
  quotePrice,
588
595
  sellAmountBeforeNetworkCosts
589
- } = _getQuoteAmountsWithCosts({ sellDecimals, buyDecimals, orderParams });
596
+ } = _getQuoteAmountsWithCosts({
597
+ sellDecimals,
598
+ buyDecimals,
599
+ orderParams,
600
+ protocolFeeAmount: getBigNumber(protocolFeeAmount, protocolFeeAmountDecimals),
601
+ isSell
602
+ });
590
603
  return {
591
604
  isSell,
592
605
  quotePrice,
@@ -598,12 +611,17 @@ function getQuoteAmountsWithCosts(params) {
598
611
  };
599
612
  }
600
613
  function _getQuoteAmountsWithCosts(params) {
601
- const { sellDecimals, buyDecimals, orderParams } = params;
602
- const isSell = orderParams.kind === "sell" /* SELL */;
614
+ const { sellDecimals, buyDecimals, orderParams, isSell, protocolFeeAmount } = params;
603
615
  const networkCostAmount = getBigNumber(orderParams.feeAmount, sellDecimals);
604
616
  const sellAmountBeforeNetworkCosts = getBigNumber(orderParams.sellAmount, sellDecimals);
605
617
  const buyAmountAfterNetworkCosts = getBigNumber(orderParams.buyAmount, buyDecimals);
606
- const quotePrice = buyAmountAfterNetworkCosts.num / sellAmountBeforeNetworkCosts.num;
618
+ const quotePrice = isSell ? (
619
+ // For SELL order is already deducting protocol fees from buyAmount, so we need to add it back to get the actual price
620
+ (buyAmountAfterNetworkCosts.num + protocolFeeAmount.num) / sellAmountBeforeNetworkCosts.num
621
+ ) : (
622
+ // For BUY order is already adding protocol fees to sellAmount, so we need to subtract it to get the actual price
623
+ buyAmountAfterNetworkCosts.num / (sellAmountBeforeNetworkCosts.num - protocolFeeAmount.num)
624
+ );
607
625
  const sellAmountAfterNetworkCosts = getBigNumber(
608
626
  sellAmountBeforeNetworkCosts.big + networkCostAmount.big,
609
627
  sellDecimals
@@ -623,25 +641,43 @@ function getQuoteAmountsWithPartnerFee(params) {
623
641
  const {
624
642
  sellAmountAfterNetworkCosts,
625
643
  buyAmountAfterNetworkCosts,
626
- buyAmountBeforeNetworkCosts,
627
- sellAmountBeforeNetworkCosts,
644
+ buyAmountBeforeProtocolFee,
645
+ sellAmountBeforeProtocolFee,
628
646
  isSell,
629
647
  partnerFeeBps
630
648
  } = params;
631
- const surplusAmount = isSell ? buyAmountBeforeNetworkCosts.big : sellAmountBeforeNetworkCosts.big;
632
- const partnerFeeAmount = partnerFeeBps > 0 ? surplusAmount * BigInt(partnerFeeBps) / ONE_HUNDRED_BPS : BigInt(0);
649
+ const surplusAmountForPartnerFee = isSell ? buyAmountBeforeProtocolFee : sellAmountBeforeProtocolFee;
650
+ const partnerFeeAmount = partnerFeeBps > 0 ? surplusAmountForPartnerFee * BigInt(partnerFeeBps) / ONE_HUNDRED_BPS : BigInt(0);
633
651
  const afterPartnerFees = isSell ? {
634
- sellAmount: sellAmountAfterNetworkCosts.big,
635
- buyAmount: buyAmountAfterNetworkCosts.big - partnerFeeAmount
652
+ sellAmount: sellAmountAfterNetworkCosts,
653
+ buyAmount: buyAmountAfterNetworkCosts - partnerFeeAmount
636
654
  } : {
637
- sellAmount: sellAmountAfterNetworkCosts.big + partnerFeeAmount,
638
- buyAmount: buyAmountAfterNetworkCosts.big
655
+ sellAmount: sellAmountAfterNetworkCosts + partnerFeeAmount,
656
+ buyAmount: buyAmountAfterNetworkCosts
639
657
  };
640
658
  return {
641
659
  partnerFeeAmount,
642
660
  afterPartnerFees
643
661
  };
644
662
  }
663
+ function getProtocolFeeAmount(params) {
664
+ const { orderParams, protocolFeeBps, isSell } = params;
665
+ if (protocolFeeBps <= 0) {
666
+ return 0n;
667
+ }
668
+ const { sellAmount: sellAmountStr, buyAmount: buyAmountStr, feeAmount: feeAmountStr } = orderParams;
669
+ const sellAmount = BigInt(sellAmountStr);
670
+ const buyAmount = BigInt(buyAmountStr);
671
+ const feeAmount = BigInt(feeAmountStr);
672
+ const protocolFeeBpsBig = BigInt(protocolFeeBps);
673
+ if (isSell) {
674
+ const denominator = ONE_HUNDRED_BPS - protocolFeeBpsBig;
675
+ return buyAmount * protocolFeeBpsBig / denominator;
676
+ } else {
677
+ const denominator = ONE_HUNDRED_BPS + protocolFeeBpsBig;
678
+ return (sellAmount + feeAmount) * protocolFeeBpsBig / denominator;
679
+ }
680
+ }
645
681
  function getQuoteAmountsWithSlippage(params) {
646
682
  const { afterPartnerFees, isSell, slippagePercentBps } = params;
647
683
  const getSlippageAmount = (amount) => amount * BigInt(slippagePercentBps) / ONE_HUNDRED_BPS;
@@ -659,20 +695,35 @@ function getQuoteAmountsWithSlippage(params) {
659
695
  function getQuoteAmountsAndCosts(params) {
660
696
  const { orderParams, sellDecimals, buyDecimals, slippagePercentBps } = params;
661
697
  const partnerFeeBps = params.partnerFeeBps ?? 0;
662
- const {
698
+ const protocolFeeBps = params.protocolFeeBps ?? 0;
699
+ const isSell = orderParams.kind === "sell" /* SELL */;
700
+ const protocolFeeAmount = getProtocolFeeAmount({
701
+ orderParams,
663
702
  isSell,
703
+ protocolFeeBps
704
+ });
705
+ const protocolFeeAmountDecimals = isSell ? buyDecimals : sellDecimals;
706
+ const {
664
707
  networkCostAmount,
665
708
  sellAmountBeforeNetworkCosts,
666
709
  buyAmountAfterNetworkCosts,
667
710
  sellAmountAfterNetworkCosts,
668
711
  buyAmountBeforeNetworkCosts,
669
712
  quotePrice
670
- } = _getQuoteAmountsWithCosts({ sellDecimals, buyDecimals, orderParams });
713
+ } = _getQuoteAmountsWithCosts({
714
+ sellDecimals,
715
+ buyDecimals,
716
+ orderParams,
717
+ isSell,
718
+ protocolFeeAmount: getBigNumber(protocolFeeAmount, protocolFeeAmountDecimals)
719
+ });
720
+ const buyAmountBeforeProtocolFee = isSell ? protocolFeeBps > 0 ? buyAmountAfterNetworkCosts.big + protocolFeeAmount : buyAmountBeforeNetworkCosts.big : buyAmountAfterNetworkCosts.big;
721
+ const sellAmountBeforeProtocolFee = isSell ? sellAmountAfterNetworkCosts.big : protocolFeeBps > 0 ? sellAmountAfterNetworkCosts.big - protocolFeeAmount : sellAmountBeforeNetworkCosts.big;
671
722
  const { afterPartnerFees, partnerFeeAmount } = getQuoteAmountsWithPartnerFee({
672
- sellAmountAfterNetworkCosts,
673
- buyAmountAfterNetworkCosts,
674
- buyAmountBeforeNetworkCosts,
675
- sellAmountBeforeNetworkCosts,
723
+ sellAmountAfterNetworkCosts: sellAmountAfterNetworkCosts.big,
724
+ buyAmountAfterNetworkCosts: buyAmountAfterNetworkCosts.big,
725
+ buyAmountBeforeProtocolFee,
726
+ sellAmountBeforeProtocolFee,
676
727
  isSell,
677
728
  partnerFeeBps
678
729
  });
@@ -681,6 +732,20 @@ function getQuoteAmountsAndCosts(params) {
681
732
  isSell,
682
733
  slippagePercentBps
683
734
  });
735
+ const beforeNetworkCosts = isSell ? {
736
+ sellAmount: sellAmountBeforeNetworkCosts.big,
737
+ buyAmount: buyAmountBeforeProtocolFee
738
+ } : {
739
+ sellAmount: sellAmountBeforeProtocolFee,
740
+ buyAmount: buyAmountBeforeNetworkCosts.big
741
+ };
742
+ const beforeAllFees = isSell ? {
743
+ sellAmount: sellAmountBeforeNetworkCosts.big,
744
+ buyAmount: buyAmountBeforeNetworkCosts.big + protocolFeeAmount
745
+ } : {
746
+ sellAmount: sellAmountBeforeNetworkCosts.big - protocolFeeAmount,
747
+ buyAmount: buyAmountBeforeNetworkCosts.big
748
+ };
684
749
  return {
685
750
  isSell,
686
751
  costs: {
@@ -691,12 +756,14 @@ function getQuoteAmountsAndCosts(params) {
691
756
  partnerFee: {
692
757
  amount: partnerFeeAmount,
693
758
  bps: partnerFeeBps
759
+ },
760
+ protocolFee: {
761
+ amount: protocolFeeAmount,
762
+ bps: protocolFeeBps
694
763
  }
695
764
  },
696
- beforeNetworkCosts: {
697
- sellAmount: sellAmountBeforeNetworkCosts.big,
698
- buyAmount: buyAmountBeforeNetworkCosts.big
699
- },
765
+ beforeNetworkCosts,
766
+ beforeAllFees,
700
767
  afterNetworkCosts: {
701
768
  sellAmount: sellAmountAfterNetworkCosts.big,
702
769
  buyAmount: buyAmountAfterNetworkCosts.big
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/sdk-order-book",
3
- "version": "0.2.4-beta.0",
3
+ "version": "0.3.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.3.2-beta.0",
35
- "@cowprotocol/sdk-common": "0.3.0-beta.0"
34
+ "@cowprotocol/sdk-config": "0.4.0",
35
+ "@cowprotocol/sdk-common": "0.4.0"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -41,7 +41,7 @@
41
41
  "test": "jest",
42
42
  "test:coverage": "jest --coverage --json --outputFile=jest.results.json && npx coveralls < ./coverage/lcov.info",
43
43
  "test:coverage:html": "jest --silent=false --coverage --coverageReporters html",
44
- "swagger:codegen": "openapi --input https://raw.githubusercontent.com/cowprotocol/services/v2.291.0/crates/orderbook/openapi.yml --output src/generated --exportServices false --exportCore false",
44
+ "swagger:codegen": "openapi --input https://raw.githubusercontent.com/cowprotocol/services/dfb50cb4a103e8f949f5a7145beb6be63ef41c85/crates/orderbook/openapi.yml --output src/generated --exportServices false --exportCore false",
45
45
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
46
46
  "typecheck": "tsc --noEmit"
47
47
  }