@cowprotocol/sdk-order-book 0.6.6 → 1.1.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
@@ -25,6 +25,8 @@ __export(src_exports, {
25
25
  DEFAULT_BACKOFF_OPTIONS: () => DEFAULT_BACKOFF_OPTIONS,
26
26
  DEFAULT_LIMITER_OPTIONS: () => DEFAULT_LIMITER_OPTIONS,
27
27
  EcdsaSigningScheme: () => EcdsaSigningScheme,
28
+ ORDER_BOOK_PARTNER_PROD_CONFIG: () => ORDER_BOOK_PARTNER_PROD_CONFIG,
29
+ ORDER_BOOK_PARTNER_STAGING_CONFIG: () => ORDER_BOOK_PARTNER_STAGING_CONFIG,
28
30
  ORDER_BOOK_PROD_CONFIG: () => ORDER_BOOK_PROD_CONFIG,
29
31
  ORDER_BOOK_STAGING_CONFIG: () => ORDER_BOOK_STAGING_CONFIG,
30
32
  OnchainOrderData: () => OnchainOrderData,
@@ -41,9 +43,10 @@ __export(src_exports, {
41
43
  PriceQuality: () => PriceQuality,
42
44
  SellTokenSource: () => SellTokenSource,
43
45
  SigningScheme: () => SigningScheme,
44
- getBigNumber: () => getBigNumber,
46
+ getProtocolFeeAmount: () => getProtocolFeeAmount,
47
+ getQuoteAmountsAfterPartnerFee: () => getQuoteAmountsAfterPartnerFee,
48
+ getQuoteAmountsAfterSlippage: () => getQuoteAmountsAfterSlippage,
45
49
  getQuoteAmountsAndCosts: () => getQuoteAmountsAndCosts,
46
- getQuoteAmountsWithCosts: () => getQuoteAmountsWithCosts,
47
50
  request: () => request
48
51
  });
49
52
  module.exports = __toCommonJS(src_exports);
@@ -117,11 +120,12 @@ var getResponseBody = async (response) => {
117
120
  }
118
121
  return void 0;
119
122
  };
120
- async function request(baseUrl, { path, query, method, body }, rateLimiter, backoffOpts) {
123
+ async function request(baseUrl, { path, query, method, body }, rateLimiter, backoffOpts, additionalHeaders) {
121
124
  const queryString = query ? "?" + query : "";
122
125
  const headers = {
123
126
  Accept: "application/json",
124
- "Content-Type": "application/json"
127
+ "Content-Type": "application/json",
128
+ ...additionalHeaders
125
129
  };
126
130
  const url = `${baseUrl}${path}${queryString}`;
127
131
  const bodyContent = (() => {
@@ -174,6 +178,8 @@ function transformEthFlowOrder(order) {
174
178
  // src/api.ts
175
179
  var PROD_BASE_URL = "https://api.cow.fi";
176
180
  var STAGING_BASE_URL = "https://barn.api.cow.fi";
181
+ var PARTNER_PROD_BASE_URL = "https://partners.cow.fi";
182
+ var PARTNER_STAGING_BASE_URL = "https://partners.barn.cow.fi";
177
183
  var ORDER_BOOK_PROD_CONFIG = {
178
184
  [import_sdk_config2.SupportedChainId.MAINNET]: `${PROD_BASE_URL}/mainnet`,
179
185
  [import_sdk_config2.SupportedChainId.GNOSIS_CHAIN]: `${PROD_BASE_URL}/xdai`,
@@ -202,6 +208,34 @@ var ORDER_BOOK_STAGING_CONFIG = {
202
208
  [import_sdk_config2.SupportedChainId.PLASMA]: `${STAGING_BASE_URL}/plasma`,
203
209
  [import_sdk_config2.SupportedChainId.INK]: `${STAGING_BASE_URL}/ink`
204
210
  };
211
+ var ORDER_BOOK_PARTNER_PROD_CONFIG = {
212
+ [import_sdk_config2.SupportedChainId.MAINNET]: `${PARTNER_PROD_BASE_URL}/mainnet`,
213
+ [import_sdk_config2.SupportedChainId.GNOSIS_CHAIN]: `${PARTNER_PROD_BASE_URL}/xdai`,
214
+ [import_sdk_config2.SupportedChainId.ARBITRUM_ONE]: `${PARTNER_PROD_BASE_URL}/arbitrum_one`,
215
+ [import_sdk_config2.SupportedChainId.BASE]: `${PARTNER_PROD_BASE_URL}/base`,
216
+ [import_sdk_config2.SupportedChainId.SEPOLIA]: `${PARTNER_PROD_BASE_URL}/sepolia`,
217
+ [import_sdk_config2.SupportedChainId.POLYGON]: `${PARTNER_PROD_BASE_URL}/polygon`,
218
+ [import_sdk_config2.SupportedChainId.AVALANCHE]: `${PARTNER_PROD_BASE_URL}/avalanche`,
219
+ [import_sdk_config2.SupportedChainId.LENS]: `${PARTNER_PROD_BASE_URL}/lens`,
220
+ [import_sdk_config2.SupportedChainId.BNB]: `${PARTNER_PROD_BASE_URL}/bnb`,
221
+ [import_sdk_config2.SupportedChainId.LINEA]: `${PARTNER_PROD_BASE_URL}/linea`,
222
+ [import_sdk_config2.SupportedChainId.PLASMA]: `${PARTNER_PROD_BASE_URL}/plasma`,
223
+ [import_sdk_config2.SupportedChainId.INK]: `${PARTNER_PROD_BASE_URL}/ink`
224
+ };
225
+ var ORDER_BOOK_PARTNER_STAGING_CONFIG = {
226
+ [import_sdk_config2.SupportedChainId.MAINNET]: `${PARTNER_STAGING_BASE_URL}/mainnet`,
227
+ [import_sdk_config2.SupportedChainId.GNOSIS_CHAIN]: `${PARTNER_STAGING_BASE_URL}/xdai`,
228
+ [import_sdk_config2.SupportedChainId.ARBITRUM_ONE]: `${PARTNER_STAGING_BASE_URL}/arbitrum_one`,
229
+ [import_sdk_config2.SupportedChainId.BASE]: `${PARTNER_STAGING_BASE_URL}/base`,
230
+ [import_sdk_config2.SupportedChainId.SEPOLIA]: `${PARTNER_STAGING_BASE_URL}/sepolia`,
231
+ [import_sdk_config2.SupportedChainId.POLYGON]: `${PARTNER_STAGING_BASE_URL}/polygon`,
232
+ [import_sdk_config2.SupportedChainId.AVALANCHE]: `${PARTNER_STAGING_BASE_URL}/avalanche`,
233
+ [import_sdk_config2.SupportedChainId.LENS]: `${PARTNER_STAGING_BASE_URL}/lens`,
234
+ [import_sdk_config2.SupportedChainId.BNB]: `${PARTNER_STAGING_BASE_URL}/bnb`,
235
+ [import_sdk_config2.SupportedChainId.LINEA]: `${PARTNER_STAGING_BASE_URL}/linea`,
236
+ [import_sdk_config2.SupportedChainId.PLASMA]: `${PARTNER_STAGING_BASE_URL}/plasma`,
237
+ [import_sdk_config2.SupportedChainId.INK]: `${PARTNER_STAGING_BASE_URL}/ink`
238
+ };
205
239
  function cleanObjectFromUndefinedValues(obj) {
206
240
  return Object.keys(obj).reduce(
207
241
  (acc, key) => {
@@ -427,8 +461,8 @@ var OrderBookApi = class {
427
461
  * @returns The API endpoint to get the order.
428
462
  */
429
463
  getOrderLink(orderUid, contextOverride) {
430
- const { chainId, env } = this.getContextWithOverride(contextOverride);
431
- return this.getApiBaseUrls(env)[chainId] + `/api/v1/orders/${orderUid}`;
464
+ const context = this.getContextWithOverride(contextOverride ?? {});
465
+ return this.getApiBaseUrls(context)[context.chainId] + `/api/v1/orders/${orderUid}`;
432
466
  }
433
467
  /**
434
468
  * Apply an override to the context for a request.
@@ -439,14 +473,18 @@ var OrderBookApi = class {
439
473
  return { ...this.context, ...contextOverride };
440
474
  }
441
475
  /**
442
- * Get the base URLs for the API endpoints given the environment.
443
- * @param env The environment to get the base URLs for.
476
+ * Get the base URLs for the API endpoints given the context.
477
+ * Uses partner URLs when apiKey is set (and no custom baseUrls override).
478
+ * @param context The merged API context for the request.
444
479
  * @returns The base URLs for the API endpoints.
445
480
  */
446
- getApiBaseUrls(env) {
447
- if (this.context.baseUrls)
448
- return this.context.baseUrls;
449
- return env === "prod" ? ORDER_BOOK_PROD_CONFIG : ORDER_BOOK_STAGING_CONFIG;
481
+ getApiBaseUrls(context) {
482
+ if (context.baseUrls)
483
+ return context.baseUrls;
484
+ if (context.apiKey) {
485
+ return context.env === "prod" ? ORDER_BOOK_PARTNER_PROD_CONFIG : ORDER_BOOK_PARTNER_STAGING_CONFIG;
486
+ }
487
+ return context.env === "prod" ? ORDER_BOOK_PROD_CONFIG : ORDER_BOOK_STAGING_CONFIG;
450
488
  }
451
489
  /**
452
490
  * Make a request to the API.
@@ -455,12 +493,14 @@ var OrderBookApi = class {
455
493
  * @returns The response from the API.
456
494
  */
457
495
  fetch(params, contextOverride = {}) {
458
- const { chainId, env, backoffOpts: _backoffOpts } = this.getContextWithOverride(contextOverride);
459
- const baseUrl = this.getApiBaseUrls(env)[chainId];
496
+ const context = this.getContextWithOverride(contextOverride);
497
+ const { chainId, backoffOpts: _backoffOpts, apiKey } = context;
498
+ const baseUrl = this.getApiBaseUrls(context)[chainId];
460
499
  const backoffOpts = _backoffOpts || DEFAULT_BACKOFF_OPTIONS;
461
500
  const rateLimiter = contextOverride.limiterOpts ? new import_limiter.RateLimiter(contextOverride.limiterOpts) : this.rateLimiter;
501
+ const additionalHeaders = apiKey ? { "X-API-Key": apiKey } : void 0;
462
502
  (0, import_sdk_common.log)(`Fetching OrderBook API: ${baseUrl}${params.path}. Params: ${JSON.stringify(params, import_sdk_common.jsonWithBigintReplacer)}`);
463
- return request(baseUrl, params, rateLimiter, backoffOpts);
503
+ return request(baseUrl, params, rateLimiter, backoffOpts, additionalHeaders);
464
504
  }
465
505
  };
466
506
 
@@ -629,90 +669,14 @@ var SigningScheme = /* @__PURE__ */ ((SigningScheme2) => {
629
669
  return SigningScheme2;
630
670
  })(SigningScheme || {});
631
671
 
632
- // src/quoteAmountsAndCostsUtils.ts
672
+ // src/quoteAmountsAndCosts/quoteAmountsAndCosts.const.ts
633
673
  var HUNDRED_THOUSANDS = 1e5;
634
674
  var ONE_HUNDRED_BPS = BigInt(100 * 100);
635
- function getQuoteAmountsWithCosts(params) {
636
- const { sellDecimals, buyDecimals, orderParams, protocolFeeBps = 0 } = params;
637
- const isSell = orderParams.kind === "sell" /* SELL */;
638
- const protocolFeeAmount = getProtocolFeeAmount({ orderParams, isSell, protocolFeeBps });
639
- const protocolFeeAmountDecimals = isSell ? buyDecimals : sellDecimals;
640
- const {
641
- sellAmountAfterNetworkCosts,
642
- buyAmountAfterNetworkCosts,
643
- buyAmountBeforeNetworkCosts,
644
- networkCostAmount,
645
- quotePrice,
646
- sellAmountBeforeNetworkCosts
647
- } = _getQuoteAmountsWithCosts({
648
- sellDecimals,
649
- buyDecimals,
650
- orderParams,
651
- protocolFeeAmount: getBigNumber(protocolFeeAmount, protocolFeeAmountDecimals),
652
- isSell
653
- });
654
- return {
655
- isSell,
656
- quotePrice,
657
- sellAmountAfterNetworkCosts: sellAmountAfterNetworkCosts.big,
658
- buyAmountAfterNetworkCosts: buyAmountAfterNetworkCosts.big,
659
- buyAmountBeforeNetworkCosts: buyAmountBeforeNetworkCosts.big,
660
- networkCostAmount: networkCostAmount.big,
661
- sellAmountBeforeNetworkCosts: sellAmountBeforeNetworkCosts.big
662
- };
663
- }
664
- function _getQuoteAmountsWithCosts(params) {
665
- const { sellDecimals, buyDecimals, orderParams, isSell, protocolFeeAmount } = params;
666
- const networkCostAmount = getBigNumber(orderParams.feeAmount, sellDecimals);
667
- const sellAmountBeforeNetworkCosts = getBigNumber(orderParams.sellAmount, sellDecimals);
668
- const buyAmountAfterNetworkCosts = getBigNumber(orderParams.buyAmount, buyDecimals);
669
- const quotePrice = isSell ? (
670
- // For SELL order is already deducting protocol fees from buyAmount, so we need to add it back to get the actual price
671
- (buyAmountAfterNetworkCosts.num + protocolFeeAmount.num) / sellAmountBeforeNetworkCosts.num
672
- ) : (
673
- // For BUY order is already adding protocol fees to sellAmount, so we need to subtract it to get the actual price
674
- buyAmountAfterNetworkCosts.num / (sellAmountBeforeNetworkCosts.num - protocolFeeAmount.num)
675
- );
676
- const sellAmountAfterNetworkCosts = getBigNumber(
677
- sellAmountBeforeNetworkCosts.big + networkCostAmount.big,
678
- sellDecimals
679
- );
680
- const buyAmountBeforeNetworkCosts = getBigNumber(quotePrice * sellAmountAfterNetworkCosts.num, buyDecimals);
681
- return {
682
- isSell,
683
- quotePrice,
684
- networkCostAmount,
685
- sellAmountBeforeNetworkCosts,
686
- buyAmountAfterNetworkCosts,
687
- sellAmountAfterNetworkCosts,
688
- buyAmountBeforeNetworkCosts
689
- };
690
- }
691
- function getQuoteAmountsWithPartnerFee(params) {
692
- const {
693
- sellAmountAfterNetworkCosts,
694
- buyAmountAfterNetworkCosts,
695
- buyAmountBeforeProtocolFee,
696
- sellAmountBeforeProtocolFee,
697
- isSell,
698
- partnerFeeBps
699
- } = params;
700
- const surplusAmountForPartnerFee = isSell ? buyAmountBeforeProtocolFee : sellAmountBeforeProtocolFee;
701
- const partnerFeeAmount = partnerFeeBps > 0 ? surplusAmountForPartnerFee * BigInt(partnerFeeBps) / ONE_HUNDRED_BPS : BigInt(0);
702
- const afterPartnerFees = isSell ? {
703
- sellAmount: sellAmountAfterNetworkCosts,
704
- buyAmount: buyAmountAfterNetworkCosts - partnerFeeAmount
705
- } : {
706
- sellAmount: sellAmountAfterNetworkCosts + partnerFeeAmount,
707
- buyAmount: buyAmountAfterNetworkCosts
708
- };
709
- return {
710
- partnerFeeAmount,
711
- afterPartnerFees
712
- };
713
- }
675
+
676
+ // src/quoteAmountsAndCosts/getProtocolFeeAmount.ts
714
677
  function getProtocolFeeAmount(params) {
715
- const { orderParams, protocolFeeBps, isSell } = params;
678
+ const { orderParams, protocolFeeBps } = params;
679
+ const isSell = orderParams.kind === "sell" /* SELL */;
716
680
  if (protocolFeeBps <= 0) {
717
681
  return 0n;
718
682
  }
@@ -730,9 +694,29 @@ function getProtocolFeeAmount(params) {
730
694
  return (sellAmount + feeAmount) * protocolFeeBpsBig / denominator;
731
695
  }
732
696
  }
733
- function getQuoteAmountsWithSlippage(params) {
734
- const { afterPartnerFees, isSell, slippagePercentBps } = params;
735
- const getSlippageAmount = (amount) => amount * BigInt(slippagePercentBps) / ONE_HUNDRED_BPS;
697
+
698
+ // src/quoteAmountsAndCosts/getQuoteAmountsAfterPartnerFee.ts
699
+ function getQuoteAmountsAfterPartnerFee(params) {
700
+ const { afterNetworkCosts, beforeAllFees, isSell, partnerFeeBps } = params;
701
+ const surplusAmountForPartnerFee = isSell ? beforeAllFees.buyAmount : beforeAllFees.sellAmount;
702
+ const partnerFeeAmount = partnerFeeBps > 0 ? surplusAmountForPartnerFee * BigInt(partnerFeeBps) / ONE_HUNDRED_BPS : BigInt(0);
703
+ const afterPartnerFees = isSell ? {
704
+ sellAmount: afterNetworkCosts.sellAmount,
705
+ buyAmount: afterNetworkCosts.buyAmount - partnerFeeAmount
706
+ } : {
707
+ sellAmount: afterNetworkCosts.sellAmount + partnerFeeAmount,
708
+ buyAmount: afterNetworkCosts.buyAmount
709
+ };
710
+ return {
711
+ partnerFeeAmount,
712
+ afterPartnerFees
713
+ };
714
+ }
715
+
716
+ // src/quoteAmountsAndCosts/getQuoteAmountsAfterSlippage.ts
717
+ function getQuoteAmountsAfterSlippage(params) {
718
+ const { afterPartnerFees, isSell, slippageBps } = params;
719
+ const getSlippageAmount = (amount) => amount * BigInt(slippageBps) / ONE_HUNDRED_BPS;
736
720
  const afterSlippage = isSell ? {
737
721
  sellAmount: afterPartnerFees.sellAmount,
738
722
  buyAmount: afterPartnerFees.buyAmount - getSlippageAmount(afterPartnerFees.buyAmount)
@@ -744,66 +728,76 @@ function getQuoteAmountsWithSlippage(params) {
744
728
  afterSlippage
745
729
  };
746
730
  }
731
+
732
+ // src/quoteAmountsAndCosts/getQuoteAmountsAndCosts.ts
747
733
  function getQuoteAmountsAndCosts(params) {
748
- const { orderParams, sellDecimals, buyDecimals, slippagePercentBps } = params;
734
+ const { orderParams, slippagePercentBps } = params;
749
735
  const partnerFeeBps = params.partnerFeeBps ?? 0;
750
736
  const protocolFeeBps = params.protocolFeeBps ?? 0;
751
737
  const isSell = orderParams.kind === "sell" /* SELL */;
738
+ const sellAmount = BigInt(orderParams.sellAmount);
739
+ const buyAmount = BigInt(orderParams.buyAmount);
740
+ const networkCostAmount = BigInt(orderParams.feeAmount);
741
+ const networkCostAmountInBuyCurrency = buyAmount * networkCostAmount / sellAmount;
752
742
  const protocolFeeAmount = getProtocolFeeAmount({
753
743
  orderParams,
754
- isSell,
755
744
  protocolFeeBps
756
745
  });
757
- const protocolFeeAmountDecimals = isSell ? buyDecimals : sellDecimals;
758
- const {
759
- networkCostAmount,
760
- sellAmountBeforeNetworkCosts,
761
- buyAmountAfterNetworkCosts,
762
- sellAmountAfterNetworkCosts,
763
- buyAmountBeforeNetworkCosts,
764
- quotePrice
765
- } = _getQuoteAmountsWithCosts({
766
- sellDecimals,
767
- buyDecimals,
768
- orderParams,
769
- isSell,
770
- protocolFeeAmount: getBigNumber(protocolFeeAmount, protocolFeeAmountDecimals)
771
- });
772
- const buyAmountBeforeProtocolFee = isSell ? protocolFeeBps > 0 ? buyAmountAfterNetworkCosts.big + protocolFeeAmount : buyAmountBeforeNetworkCosts.big : buyAmountAfterNetworkCosts.big;
773
- const sellAmountBeforeProtocolFee = isSell ? sellAmountAfterNetworkCosts.big : protocolFeeBps > 0 ? sellAmountAfterNetworkCosts.big - protocolFeeAmount : sellAmountBeforeNetworkCosts.big;
774
- const { afterPartnerFees, partnerFeeAmount } = getQuoteAmountsWithPartnerFee({
775
- sellAmountAfterNetworkCosts: sellAmountAfterNetworkCosts.big,
776
- buyAmountAfterNetworkCosts: buyAmountAfterNetworkCosts.big,
777
- buyAmountBeforeProtocolFee,
778
- sellAmountBeforeProtocolFee,
746
+ const beforeAllFees = isSell ? {
747
+ // Only in case of SELL order, network costs are already added to sellAmount which comes from /quote API
748
+ sellAmount: sellAmount + networkCostAmount,
749
+ /**
750
+ * Important!
751
+ * For SELL orders, /quote API returns sellAmount AFTER network costs
752
+ * buyAmount is correlated to that sellAmount, hence, it doesn't include network costs as well
753
+ * Because of that, we add network costs here as well to have both amounts consistent
754
+ */
755
+ buyAmount: buyAmount + networkCostAmountInBuyCurrency + protocolFeeAmount
756
+ } : {
757
+ sellAmount: sellAmount - protocolFeeAmount,
758
+ buyAmount
759
+ };
760
+ const afterProtocolFees = isSell ? {
761
+ sellAmount: beforeAllFees.sellAmount,
762
+ buyAmount: beforeAllFees.buyAmount - protocolFeeAmount
763
+ } : {
764
+ sellAmount,
765
+ buyAmount: beforeAllFees.buyAmount
766
+ };
767
+ const afterNetworkCosts = isSell ? {
768
+ // For SELL order, the /quote API response sellAmount is already after network costs
769
+ // buyAmount is relative to sellAmount, hence it's also after network costs
770
+ sellAmount,
771
+ buyAmount
772
+ } : {
773
+ // For BUY order, the /quote API response sellAmount is only after protocolFee, so we need to add networks costs to the amount
774
+ sellAmount: sellAmount + networkCostAmount,
775
+ buyAmount: afterProtocolFees.buyAmount
776
+ };
777
+ const { afterPartnerFees, partnerFeeAmount } = getQuoteAmountsAfterPartnerFee({
778
+ afterNetworkCosts,
779
+ beforeAllFees,
779
780
  isSell,
780
781
  partnerFeeBps
781
782
  });
782
- const { afterSlippage } = getQuoteAmountsWithSlippage({
783
+ const { afterSlippage } = getQuoteAmountsAfterSlippage({
783
784
  afterPartnerFees,
784
785
  isSell,
785
- slippagePercentBps
786
+ slippageBps: slippagePercentBps
786
787
  });
787
- const beforeNetworkCosts = isSell ? {
788
- sellAmount: sellAmountBeforeNetworkCosts.big,
789
- buyAmount: buyAmountBeforeProtocolFee
788
+ const amountsToSign = isSell ? {
789
+ sellAmount: beforeAllFees.sellAmount,
790
+ buyAmount: afterSlippage.buyAmount
790
791
  } : {
791
- sellAmount: sellAmountBeforeProtocolFee,
792
- buyAmount: buyAmountBeforeNetworkCosts.big
793
- };
794
- const beforeAllFees = isSell ? {
795
- sellAmount: sellAmountBeforeNetworkCosts.big,
796
- buyAmount: buyAmountBeforeNetworkCosts.big
797
- } : {
798
- sellAmount: sellAmountBeforeNetworkCosts.big - protocolFeeAmount,
799
- buyAmount: buyAmountBeforeNetworkCosts.big
792
+ sellAmount: afterSlippage.sellAmount,
793
+ buyAmount: beforeAllFees.buyAmount
800
794
  };
801
795
  return {
802
796
  isSell,
803
797
  costs: {
804
798
  networkFee: {
805
- amountInSellCurrency: networkCostAmount.big,
806
- amountInBuyCurrency: getBigNumber(quotePrice * networkCostAmount.num, buyDecimals).big
799
+ amountInSellCurrency: networkCostAmount,
800
+ amountInBuyCurrency: networkCostAmountInBuyCurrency
807
801
  },
808
802
  partnerFee: {
809
803
  amount: partnerFeeAmount,
@@ -814,27 +808,15 @@ function getQuoteAmountsAndCosts(params) {
814
808
  bps: protocolFeeBps
815
809
  }
816
810
  },
817
- beforeNetworkCosts,
818
811
  beforeAllFees,
819
- afterNetworkCosts: {
820
- sellAmount: sellAmountAfterNetworkCosts.big,
821
- buyAmount: buyAmountAfterNetworkCosts.big
822
- },
812
+ beforeNetworkCosts: afterProtocolFees,
813
+ afterProtocolFees,
814
+ afterNetworkCosts,
823
815
  afterPartnerFees,
824
- afterSlippage
816
+ afterSlippage,
817
+ amountsToSign
825
818
  };
826
819
  }
827
- function getBigNumber(value, decimals) {
828
- if (typeof value === "number") {
829
- const bigAsNumber = value * 10 ** decimals;
830
- const bigAsNumberString = bigAsNumber.toFixed();
831
- const big2 = BigInt(bigAsNumberString.includes("e") ? bigAsNumber : bigAsNumberString);
832
- return { big: big2, num: value };
833
- }
834
- const big = BigInt(value);
835
- const num = Number(big) / 10 ** decimals;
836
- return { big, num };
837
- }
838
820
  // Annotate the CommonJS export names for ESM import in node:
839
821
  0 && (module.exports = {
840
822
  BuyTokenDestination,
@@ -842,6 +824,8 @@ function getBigNumber(value, decimals) {
842
824
  DEFAULT_BACKOFF_OPTIONS,
843
825
  DEFAULT_LIMITER_OPTIONS,
844
826
  EcdsaSigningScheme,
827
+ ORDER_BOOK_PARTNER_PROD_CONFIG,
828
+ ORDER_BOOK_PARTNER_STAGING_CONFIG,
845
829
  ORDER_BOOK_PROD_CONFIG,
846
830
  ORDER_BOOK_STAGING_CONFIG,
847
831
  OnchainOrderData,
@@ -858,8 +842,9 @@ function getBigNumber(value, decimals) {
858
842
  PriceQuality,
859
843
  SellTokenSource,
860
844
  SigningScheme,
861
- getBigNumber,
845
+ getProtocolFeeAmount,
846
+ getQuoteAmountsAfterPartnerFee,
847
+ getQuoteAmountsAfterSlippage,
862
848
  getQuoteAmountsAndCosts,
863
- getQuoteAmountsWithCosts,
864
849
  request
865
850
  });