@cowprotocol/cow-sdk 5.3.0 → 5.3.1-RC.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.
@@ -0,0 +1,11 @@
1
+ import { QuoteAmountsAndCosts } from './types';
2
+ import { type OrderParameters } from './generated';
3
+ interface Params {
4
+ orderParams: OrderParameters;
5
+ sellDecimals: number;
6
+ buyDecimals: number;
7
+ slippagePercentBps: number;
8
+ partnerFeeBps: number | undefined;
9
+ }
10
+ export declare function getQuoteAmountsAndCosts(params: Params): QuoteAmountsAndCosts;
11
+ export {};
@@ -5,3 +5,35 @@ import { Order } from './generated';
5
5
  export interface EnrichedOrder extends Order {
6
6
  totalFee: string;
7
7
  }
8
+ /**
9
+ * CoW Protocol quote has amounts (sell/buy) and costs (network fee), there is also partner fees.
10
+ * Besides that, CoW Protocol supports both sell and buy orders and the fees and costs are calculated differently.
11
+ *
12
+ * The order of adding fees and costs is as follows:
13
+ * 1. Network fee is always added to the sell amount
14
+ * 2. Partner fee is added to the surplus amount (sell amount for sell-orders, buy amount for buy-orders)
15
+ *
16
+ * For sell-orders the partner fee is subtracted from the buy amount after network costs.
17
+ * For buy-orders the partner fee is added on top of the sell amount after network costs.
18
+ */
19
+ export interface QuoteAmountsAndCosts<Amounts = {
20
+ sellAmount: bigint;
21
+ buyAmount: bigint;
22
+ }> {
23
+ isSell: boolean;
24
+ quotePrice: number;
25
+ costs: {
26
+ networkFee: {
27
+ amountInSellCurrency: bigint;
28
+ amountInBuyCurrency: bigint;
29
+ };
30
+ partnerFee: {
31
+ amount: bigint;
32
+ bps: number;
33
+ };
34
+ };
35
+ beforeNetworkCosts: Amounts;
36
+ afterNetworkCosts: Amounts;
37
+ afterPartnerFees: Amounts;
38
+ afterSlippage: Amounts;
39
+ }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/cow-sdk",
3
- "version": "5.3.0",
3
+ "version": "5.3.1-RC.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "files": [
6
6
  "/dist"
@@ -100,4 +100,4 @@
100
100
  "typescript",
101
101
  "subgraph"
102
102
  ]
103
- }
103
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/cow-sdk",
3
- "version": "5.3.0",
3
+ "version": "5.3.1-RC.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "files": [
6
6
  "/dist"
@@ -100,4 +100,4 @@
100
100
  "typescript",
101
101
  "subgraph"
102
102
  ]
103
- }
103
+ }