@cowprotocol/cow-sdk 5.9.0 → 5.10.0-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.
Files changed (35) hide show
  1. package/README.md +44 -3
  2. package/dist/README.md +44 -3
  3. package/dist/{index-d7269169.js → index-f4e68213.js} +3 -3
  4. package/dist/index-f4e68213.js.map +1 -0
  5. package/dist/index.js +2 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.modern.mjs +1 -1
  8. package/dist/index.module.js +2 -2
  9. package/dist/index.module.js.map +1 -1
  10. package/dist/order-book/generated/index.d.ts +0 -1
  11. package/dist/order-book/generated/models/Auction.d.ts +1 -10
  12. package/dist/order-book/generated/models/AuctionPrices.d.ts +1 -4
  13. package/dist/order-book/generated/models/CompetitionOrderStatus.d.ts +4 -2
  14. package/dist/order-book/generated/models/ExecutedProtocolFee.d.ts +0 -6
  15. package/dist/order-book/generated/models/OnchainOrderData.d.ts +3 -9
  16. package/dist/order-book/generated/models/OrderCreation.d.ts +4 -12
  17. package/dist/order-book/generated/models/OrderMetaData.d.ts +20 -17
  18. package/dist/order-book/generated/models/OrderParameters.d.ts +1 -2
  19. package/dist/order-book/generated/models/OrderQuoteRequest.d.ts +11 -7
  20. package/dist/order-book/generated/models/OrderQuoteResponse.d.ts +1 -2
  21. package/dist/order-book/generated/models/OrderQuoteSide.d.ts +1 -2
  22. package/dist/order-book/generated/models/PriceQuality.d.ts +4 -3
  23. package/dist/order-book/generated/models/SolverSettlement.d.ts +6 -1
  24. package/dist/order-book/generated/models/UID.d.ts +4 -3
  25. package/dist/package.json +2 -2
  26. package/dist/schemas/trading/SwapAdvancedSettings.ts +2 -2
  27. package/dist/{utils-7f502e5c.js → utils-43555783.js} +1 -1
  28. package/dist/{utils-7f502e5c.js.map → utils-43555783.js.map} +1 -1
  29. package/dist/{utils-be09ebbf.js → utils-9d1e9d0e.js} +2 -2
  30. package/dist/{utils-be09ebbf.js.map → utils-9d1e9d0e.js.map} +1 -1
  31. package/dist/{utils-83038876.js → utils-dc9c9d10.js} +1 -1
  32. package/dist/{utils-83038876.js.map → utils-dc9c9d10.js.map} +1 -1
  33. package/package.json +2 -2
  34. package/dist/index-d7269169.js.map +0 -1
  35. package/dist/order-book/generated/models/ProtocolAppData.d.ts +0 -1
package/README.md CHANGED
@@ -22,7 +22,50 @@
22
22
  yarn add @cowprotocol/cow-sdk
23
23
  ```
24
24
 
25
- ### Content
25
+ ## [Trading SDK](./src/trading/README.md)
26
+
27
+ CoW Protocol is intent based, decentralized trading protocol that allows users to trade ERC-20 tokens.
28
+
29
+ The basic swap flow:
30
+ 1. 🔎 Get a quote (price) for a trade (_or define your own price with a limit order_)
31
+ 2. ✍️ Sign the order
32
+ 3. ✅ Post the order to the order-book
33
+
34
+ The easiest way to start trading is to use the `TradingSdk`:
35
+
36
+ ```typescript
37
+ import { SupportedChainId, OrderKind, TradeParameters, TradingSdk } from '@cowprotocol/cow-sdk'
38
+
39
+ // Initialize the SDK
40
+ const sdk = new TradingSdk({
41
+ chainId: SupportedChainId.SEPOLIA,
42
+ signer: '<privateKeyOrEthersSigner>',
43
+ appCode: '<YOUR_APP_CODE>',
44
+ })
45
+
46
+ // Define trade parameters
47
+ const parameters: TradeParameters = {
48
+ kind: OrderKind.BUY,
49
+ sellToken: '0xfff9976782d46cc05630d1f6ebab18b2324d6b14',
50
+ sellTokenDecimals: 18,
51
+ buyToken: '0x0625afb445c3b6b7b929342a04a22599fd5dbb59',
52
+ buyTokenDecimals: 18,
53
+ amount: '120000000000000000'
54
+ }
55
+
56
+ // Post the order
57
+ const orderId = await sdk.postSwapOrder(parameters)
58
+
59
+ console.log('Order created, id: ', orderId)
60
+ ```
61
+
62
+ This example is the simplest way to trade on CoW Protocol.
63
+
64
+ You might want to use more advanced parameters like `receiver`, `partiallyFillable`, `validTo` and others.
65
+ Check the [Trading SDK documentation](./src/trading/README.md) for more details.
66
+
67
+
68
+ ## Other utilities
26
69
 
27
70
  - `OrderBookApi` - provides the ability to retrieve orders and trades from the CoW Protocol order-book, as well as add and cancel them
28
71
  - `OrderSigningUtils` - serves to sign orders and cancel them using [EIP-712](https://eips.ethereum.org/EIPS/eip-712)
@@ -38,8 +81,6 @@ const subgraphApi = new SubgraphApi({ chainId })
38
81
  const orderSigningUtils = new OrderSigningUtils()
39
82
  ```
40
83
 
41
- ## Quick start
42
-
43
84
  ### Sign, fetch, post and cancel order
44
85
 
45
86
  For clarity, let's look at the use of the API with a practical example:
package/dist/README.md CHANGED
@@ -22,7 +22,50 @@
22
22
  yarn add @cowprotocol/cow-sdk
23
23
  ```
24
24
 
25
- ### Content
25
+ ## [Trading SDK](./src/trading/README.md)
26
+
27
+ CoW Protocol is intent based, decentralized trading protocol that allows users to trade ERC-20 tokens.
28
+
29
+ The basic swap flow:
30
+ 1. 🔎 Get a quote (price) for a trade (_or define your own price with a limit order_)
31
+ 2. ✍️ Sign the order
32
+ 3. ✅ Post the order to the order-book
33
+
34
+ The easiest way to start trading is to use the `TradingSdk`:
35
+
36
+ ```typescript
37
+ import { SupportedChainId, OrderKind, TradeParameters, TradingSdk } from '@cowprotocol/cow-sdk'
38
+
39
+ // Initialize the SDK
40
+ const sdk = new TradingSdk({
41
+ chainId: SupportedChainId.SEPOLIA,
42
+ signer: '<privateKeyOrEthersSigner>',
43
+ appCode: '<YOUR_APP_CODE>',
44
+ })
45
+
46
+ // Define trade parameters
47
+ const parameters: TradeParameters = {
48
+ kind: OrderKind.BUY,
49
+ sellToken: '0xfff9976782d46cc05630d1f6ebab18b2324d6b14',
50
+ sellTokenDecimals: 18,
51
+ buyToken: '0x0625afb445c3b6b7b929342a04a22599fd5dbb59',
52
+ buyTokenDecimals: 18,
53
+ amount: '120000000000000000'
54
+ }
55
+
56
+ // Post the order
57
+ const orderId = await sdk.postSwapOrder(parameters)
58
+
59
+ console.log('Order created, id: ', orderId)
60
+ ```
61
+
62
+ This example is the simplest way to trade on CoW Protocol.
63
+
64
+ You might want to use more advanced parameters like `receiver`, `partiallyFillable`, `validTo` and others.
65
+ Check the [Trading SDK documentation](./src/trading/README.md) for more details.
66
+
67
+
68
+ ## Other utilities
26
69
 
27
70
  - `OrderBookApi` - provides the ability to retrieve orders and trades from the CoW Protocol order-book, as well as add and cancel them
28
71
  - `OrderSigningUtils` - serves to sign orders and cancel them using [EIP-712](https://eips.ethereum.org/EIPS/eip-712)
@@ -38,8 +81,6 @@ const subgraphApi = new SubgraphApi({ chainId })
38
81
  const orderSigningUtils = new OrderSigningUtils()
39
82
  ```
40
83
 
41
- ## Quick start
42
-
43
84
  ### Sign, fetch, post and cancel order
44
85
 
45
86
  For clarity, let's look at the use of the API with a practical example: