@cowprotocol/cow-sdk 5.7.0 → 5.7.1-next

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 (136) hide show
  1. package/package.json +3 -4
  2. package/LICENSE-APACHE +0 -201
  3. package/LICENSE-MIT +0 -21
  4. package/dist/README.md +0 -245
  5. package/dist/common/chains.d.ts +0 -11
  6. package/dist/common/configs.d.ts +0 -78
  7. package/dist/common/consts.d.ts +0 -29
  8. package/dist/common/cow-error.d.ts +0 -5
  9. package/dist/common/generated/CoWShed.d.ts +0 -219
  10. package/dist/common/generated/CoWShedFactory.d.ts +0 -191
  11. package/dist/common/generated/ComposableCoW.d.ts +0 -340
  12. package/dist/common/generated/ExtensibleFallbackHandler.d.ts +0 -282
  13. package/dist/common/generated/TWAP.d.ts +0 -141
  14. package/dist/common/generated/common.d.ts +0 -21
  15. package/dist/common/generated/factories/CoWShedFactory__factory.d.ts +0 -250
  16. package/dist/common/generated/factories/CoWShed__factory.d.ts +0 -254
  17. package/dist/common/generated/factories/ComposableCoW__factory.d.ts +0 -475
  18. package/dist/common/generated/factories/ExtensibleFallbackHandler__factory.d.ts +0 -389
  19. package/dist/common/generated/factories/TWAP__factory.d.ts +0 -260
  20. package/dist/common/generated/factories/index.d.ts +0 -5
  21. package/dist/common/generated/index.d.ts +0 -11
  22. package/dist/common/index.d.ts +0 -5
  23. package/dist/common/ipfs.d.ts +0 -2
  24. package/dist/composable/ConditionalOrder.d.ts +0 -206
  25. package/dist/composable/ConditionalOrderFactory.d.ts +0 -9
  26. package/dist/composable/Multiplexer.d.ts +0 -174
  27. package/dist/composable/contracts.d.ts +0 -6
  28. package/dist/composable/generated/ComposableCoW.d.ts +0 -340
  29. package/dist/composable/generated/ExtensibleFallbackHandler.d.ts +0 -282
  30. package/dist/composable/generated/TWAP.d.ts +0 -141
  31. package/dist/composable/generated/common.d.ts +0 -21
  32. package/dist/composable/generated/factories/ComposableCoW__factory.d.ts +0 -475
  33. package/dist/composable/generated/factories/ExtensibleFallbackHandler__factory.d.ts +0 -389
  34. package/dist/composable/generated/factories/TWAP__factory.d.ts +0 -260
  35. package/dist/composable/generated/factories/index.d.ts +0 -3
  36. package/dist/composable/generated/index.d.ts +0 -7
  37. package/dist/composable/index.d.ts +0 -6
  38. package/dist/composable/orderTypes/Twap.d.ts +0 -242
  39. package/dist/composable/orderTypes/index.d.ts +0 -3
  40. package/dist/composable/orderTypes/test/TestConditionalOrder.d.ts +0 -25
  41. package/dist/composable/types.d.ts +0 -133
  42. package/dist/composable/utils.d.ts +0 -36
  43. package/dist/cow-shed/CoWShedHooks.d.ts +0 -35
  44. package/dist/cow-shed/contracts.d.ts +0 -4
  45. package/dist/cow-shed/index.d.ts +0 -4
  46. package/dist/cow-shed/proxyInitCode.d.ts +0 -1
  47. package/dist/cow-shed/types.d.ts +0 -33
  48. package/dist/index-5ea4bd62.js +0 -29
  49. package/dist/index-5ea4bd62.js.map +0 -1
  50. package/dist/index.d.ts +0 -6
  51. package/dist/index.js +0 -29
  52. package/dist/index.js.map +0 -1
  53. package/dist/index.modern.mjs +0 -2
  54. package/dist/index.modern.mjs.map +0 -1
  55. package/dist/index.module.js +0 -29
  56. package/dist/index.module.js.map +0 -1
  57. package/dist/order-book/api.d.ts +0 -235
  58. package/dist/order-book/generated/index.d.ts +0 -56
  59. package/dist/order-book/generated/models/Address.d.ts +0 -4
  60. package/dist/order-book/generated/models/AppData.d.ts +0 -7
  61. package/dist/order-book/generated/models/AppDataHash.d.ts +0 -6
  62. package/dist/order-book/generated/models/AppDataObject.d.ts +0 -7
  63. package/dist/order-book/generated/models/Auction.d.ts +0 -39
  64. package/dist/order-book/generated/models/AuctionOrder.d.ts +0 -92
  65. package/dist/order-book/generated/models/AuctionPrices.d.ts +0 -9
  66. package/dist/order-book/generated/models/BigUint.d.ts +0 -4
  67. package/dist/order-book/generated/models/BuyTokenDestination.d.ts +0 -7
  68. package/dist/order-book/generated/models/CallData.d.ts +0 -4
  69. package/dist/order-book/generated/models/CompetitionAuction.d.ts +0 -14
  70. package/dist/order-book/generated/models/CompetitionOrderStatus.d.ts +0 -27
  71. package/dist/order-book/generated/models/EcdsaSignature.d.ts +0 -4
  72. package/dist/order-book/generated/models/EcdsaSigningScheme.d.ts +0 -7
  73. package/dist/order-book/generated/models/EthflowData.d.ts +0 -20
  74. package/dist/order-book/generated/models/ExecutedAmounts.d.ts +0 -5
  75. package/dist/order-book/generated/models/ExecutedProtocolFee.d.ts +0 -14
  76. package/dist/order-book/generated/models/FeePolicy.d.ts +0 -7
  77. package/dist/order-book/generated/models/InteractionData.d.ts +0 -11
  78. package/dist/order-book/generated/models/NativePriceResponse.d.ts +0 -10
  79. package/dist/order-book/generated/models/OnchainOrderData.d.ts +0 -30
  80. package/dist/order-book/generated/models/Order.d.ts +0 -3
  81. package/dist/order-book/generated/models/OrderCancellation.d.ts +0 -14
  82. package/dist/order-book/generated/models/OrderCancellationError.d.ts +0 -15
  83. package/dist/order-book/generated/models/OrderCancellations.d.ts +0 -18
  84. package/dist/order-book/generated/models/OrderClass.d.ts +0 -8
  85. package/dist/order-book/generated/models/OrderCreation.d.ts +0 -88
  86. package/dist/order-book/generated/models/OrderKind.d.ts +0 -7
  87. package/dist/order-book/generated/models/OrderMetaData.d.ts +0 -97
  88. package/dist/order-book/generated/models/OrderParameters.d.ts +0 -54
  89. package/dist/order-book/generated/models/OrderPostError.d.ts +0 -35
  90. package/dist/order-book/generated/models/OrderQuoteRequest.d.ts +0 -54
  91. package/dist/order-book/generated/models/OrderQuoteResponse.d.ts +0 -28
  92. package/dist/order-book/generated/models/OrderQuoteSide.d.ts +0 -27
  93. package/dist/order-book/generated/models/OrderQuoteSideKindBuy.d.ts +0 -3
  94. package/dist/order-book/generated/models/OrderQuoteSideKindSell.d.ts +0 -3
  95. package/dist/order-book/generated/models/OrderQuoteValidity.d.ts +0 -14
  96. package/dist/order-book/generated/models/OrderStatus.d.ts +0 -10
  97. package/dist/order-book/generated/models/PreSignature.d.ts +0 -4
  98. package/dist/order-book/generated/models/PriceEstimationError.d.ts +0 -12
  99. package/dist/order-book/generated/models/PriceImprovement.d.ts +0 -12
  100. package/dist/order-book/generated/models/PriceQuality.d.ts +0 -15
  101. package/dist/order-book/generated/models/ProtocolAppData.d.ts +0 -1
  102. package/dist/order-book/generated/models/Quote.d.ts +0 -19
  103. package/dist/order-book/generated/models/SellTokenSource.d.ts +0 -8
  104. package/dist/order-book/generated/models/Signature.d.ts +0 -6
  105. package/dist/order-book/generated/models/SigningScheme.d.ts +0 -9
  106. package/dist/order-book/generated/models/SolverCompetitionResponse.d.ts +0 -30
  107. package/dist/order-book/generated/models/SolverSettlement.d.ts +0 -42
  108. package/dist/order-book/generated/models/Surplus.d.ts +0 -7
  109. package/dist/order-book/generated/models/TokenAmount.d.ts +0 -4
  110. package/dist/order-book/generated/models/TotalSurplus.d.ts +0 -10
  111. package/dist/order-book/generated/models/Trade.d.ts +0 -57
  112. package/dist/order-book/generated/models/TransactionHash.d.ts +0 -4
  113. package/dist/order-book/generated/models/UID.d.ts +0 -7
  114. package/dist/order-book/generated/models/Volume.d.ts +0 -6
  115. package/dist/order-book/index.d.ts +0 -5
  116. package/dist/order-book/mock.d.ts +0 -63
  117. package/dist/order-book/quoteAmountsAndCostsUtils.d.ts +0 -11
  118. package/dist/order-book/request.d.ts +0 -49
  119. package/dist/order-book/transformOrder.d.ts +0 -10
  120. package/dist/order-book/types.d.ts +0 -38
  121. package/dist/order-signing/index.d.ts +0 -2
  122. package/dist/order-signing/orderSigningUtils.d.ts +0 -87
  123. package/dist/order-signing/types.d.ts +0 -55
  124. package/dist/order-signing/utils.d.ts +0 -39
  125. package/dist/package.json +0 -103
  126. package/dist/subgraph/api.d.ts +0 -77
  127. package/dist/subgraph/graphql.d.ts +0 -3203
  128. package/dist/subgraph/index.d.ts +0 -1
  129. package/dist/subgraph/queries.d.ts +0 -14
  130. package/dist/utils-28261b03.js +0 -2
  131. package/dist/utils-28261b03.js.map +0 -1
  132. package/dist/utils-67d54330.js +0 -2
  133. package/dist/utils-67d54330.js.map +0 -1
  134. package/dist/utils-81055c83.js +0 -2
  135. package/dist/utils-81055c83.js.map +0 -1
  136. package/dist/utils.d.ts +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/cow-sdk",
3
- "version": "5.7.0",
3
+ "version": "5.7.1-next",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "files": [
6
6
  "/dist"
@@ -24,13 +24,12 @@
24
24
  "test:coverage": "jest --coverage --json --outputFile=jest.results.json && cat ./coverage/lcov.info | coveralls",
25
25
  "test:coverage:html": "jest --silent=false --coverage --coverageReporters html",
26
26
  "codegen": "npm run swagger:codegen && npm run typechain:codegen",
27
- "prepare": "npm run build",
28
- "prepublishOnly": "npm test && npm run lint",
29
27
  "graphql:codegen": "graphql-codegen --config graphql-codegen.yml",
30
- "swagger:codegen": " openapi --input https://raw.githubusercontent.com/cowprotocol/services/v2.281.0/crates/orderbook/openapi.yml --output src/order-book/generated --exportServices false --exportCore false",
28
+ "swagger:codegen": " openapi --input https://raw.githubusercontent.com/cowprotocol/services/main/crates/orderbook/openapi.yml --output src/order-book/generated --exportServices false --exportCore false",
31
29
  "typechain:codegen": "typechain --target ethers-v5 --out-dir ./src/common/generated './abi/*.json'"
32
30
  },
33
31
  "dependencies": {
32
+ "@cowprotocol/app-data": "^2.1.0",
34
33
  "@cowprotocol/contracts": "^1.6.0",
35
34
  "@ethersproject/abstract-signer": "^5.7.0",
36
35
  "@openzeppelin/merkle-tree": "^1.0.5",
package/LICENSE-APACHE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
package/LICENSE-MIT DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Gnosis Ltd
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/dist/README.md DELETED
@@ -1,245 +0,0 @@
1
- <p align="center">
2
- <img width="400" src="https://github.com/cowprotocol/cow-sdk/raw/main/docs/images/CoW.png" />
3
- </p>
4
-
5
- # CoW SDK
6
-
7
- ## 📚 [Docs website](https://docs.cow.fi/)
8
-
9
- ## Test coverage
10
-
11
- | Statements | Branches | Functions | Lines |
12
- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
13
- | ![Statements](https://img.shields.io/badge/statements-94.77%25-brightgreen.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-76.78%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-97.43%25-brightgreen.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-97.67%25-brightgreen.svg?style=flat) |
14
-
15
- ## Getting started
16
-
17
- **Usage examples: [VanillaJS](https://github.com/cowprotocol/cow-sdk/blob/main/examples/vanilla/src/index.ts), [Create React App](https://github.com/cowprotocol/cow-sdk/blob/main/examples/cra/src/pages/getOrders/index.tsx), [NodeJS](https://github.com/cowprotocol/cow-sdk/blob/main/examples/nodejs/src/index.ts)**
18
-
19
- ### Installation
20
-
21
- ```bash
22
- yarn add @cowprotocol/cow-sdk
23
- ```
24
-
25
- ### Content
26
-
27
- - `OrderBookApi` - provides the ability to retrieve orders and trades from the CoW Protocol order-book, as well as add and cancel them
28
- - `OrderSigningUtils` - serves to sign orders and cancel them using [EIP-712](https://eips.ethereum.org/EIPS/eip-712)
29
- - `SubgraphApi` - provides statistics data about CoW protocol from [Subgraph](https://github.com/cowprotocol/subgraph), such as trading volume, trade count and others
30
-
31
- ```typescript
32
- import { OrderBookApi, OrderSigningUtils, SubgraphApi } from '@cowprotocol/cow-sdk'
33
-
34
- const chainId = 100 // Gnosis chain
35
-
36
- const orderBookApi = new OrderBookApi({ chainId })
37
- const subgraphApi = new SubgraphApi({ chainId })
38
- const orderSigningUtils = new OrderSigningUtils()
39
- ```
40
-
41
- ## Quick start
42
-
43
- ### Sign, fetch, post and cancel order
44
-
45
- For clarity, let's look at the use of the API with a practical example:
46
- Exchanging `0.4 GNO` to `WETH` on `Gnosis chain` network.
47
-
48
- We will do the following operations:
49
-
50
- 1. Get a quote
51
- 2. Sign the order
52
- 3. Send the order to the order-book
53
- 4. Get the data of the created order
54
- 5. Get trades of the order
55
- 6. Cancel the order (signing + sending)
56
-
57
- [You also can check this code in the CRA example](https://github.com/cowprotocol/cow-sdk/blob/main/examples/cra/src/pages/quickStart/index.tsx)
58
-
59
- ```typescript
60
- import { OrderBookApi, OrderSigningUtils, SupportedChainId } from '@cowprotocol/cow-sdk'
61
- import { Web3Provider } from '@ethersproject/providers'
62
-
63
- const account = 'YOUR_WALLET_ADDRESS'
64
- const chainId = 100 // Gnosis chain
65
- const provider = new Web3Provider(window.ethereum)
66
- const signer = provider.getSigner()
67
-
68
- const quoteRequest = {
69
- sellToken: '0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1', // WETH gnosis chain
70
- buyToken: '0x9c58bacc331c9aa871afd802db6379a98e80cedb', // GNO gnosis chain
71
- from: account,
72
- receiver: account,
73
- sellAmountBeforeFee: (0.4 * 10 ** 18).toString(), // 0.4 WETH
74
- kind: OrderQuoteSide.kind.SELL,
75
- }
76
-
77
- const orderBookApi = new OrderBookApi({ chainId: SupportedChainId.GNOSIS_CHAIN })
78
-
79
- async function main() {
80
- const { quote } = await orderBookApi.getQuote(quoteRequest)
81
-
82
- const orderSigningResult = await OrderSigningUtils.signOrder(quote, chainId, signer)
83
-
84
- const orderId = await orderBookApi.sendOrder({ ...quote, ...orderSigningResult })
85
-
86
- const order = await orderBookApi.getOrder(orderId)
87
-
88
- const trades = await orderBookApi.getTrades({ orderId })
89
-
90
- const orderCancellationSigningResult = await OrderSigningUtils.signOrderCancellations([orderId], chainId, signer)
91
-
92
- const cancellationResult = await orderBookApi.sendSignedOrderCancellations({
93
- ...orderCancellationSigningResult,
94
- orderUids: [orderId],
95
- })
96
-
97
- console.log('Results: ', { orderId, order, trades, orderCancellationSigningResult, cancellationResult })
98
- }
99
- ```
100
-
101
- ### OrderBookApi
102
-
103
- `OrderBookApi` - is a main tool for working with [CoW Protocol API](https://api.cow.fi/docs/#/).
104
- Since the API supports different networks and environments, there are some options to configure it.
105
-
106
- #### Environment configuration
107
-
108
- `chainId` - can be one of `SupportedChainId.MAINNET`, `SupportedChainId.GNOSIS_CHAIN`, `SupportedChainId.ARBITRUM_ONE`, `SupportedChainId.BASE` or `SupportedChainId.SEPOLIA`
109
-
110
- `env` - this parameter affects which environment will be used:
111
-
112
- - `https://api.cow.fi` for `prod` (default)
113
- - `https://barn.api.cow.fi` for `staging`
114
-
115
- ```typescript
116
- import { OrderBookApi } from '@cowprotocol/cow-sdk'
117
-
118
- const orderBookApi = new OrderBookApi({
119
- chainId: SupportedChainId.GNOSIS_CHAIN,
120
- env: 'staging', // <-----
121
- })
122
- ```
123
-
124
- #### API urls configuration
125
-
126
- In case you need to use custom endpoints (e.g. you use a proxy), you can do it this way:
127
-
128
- ```typescript
129
- import { OrderBookApi } from '@cowprotocol/cow-sdk'
130
-
131
- const orderBookApi = new OrderBookApi({
132
- chainId: SupportedChainId.GNOSIS_CHAIN,
133
- baseUrls: {
134
- // <-----
135
- [SupportedChainId.MAINNET]: 'https://YOUR_ENDPOINT/mainnet',
136
- [SupportedChainId.GNOSIS_CHAIN]: 'https://YOUR_ENDPOINT/gnosis_chain',
137
- [SupportedChainId.ARBITRUM]: 'https://YOUR_ENDPOINT/arbitrum_one',
138
- [SupportedChainId.BASE]: 'https://YOUR_ENDPOINT/base',
139
- [SupportedChainId.SEPOLIA]: 'https://YOUR_ENDPOINT/sepolia',
140
- },
141
- })
142
- ```
143
-
144
- The [CoW Protocol API](https://api.cow.fi/docs/#/) has restrictions on the backend side to protect against DDOS and other issues.
145
-
146
- > The main restriction is request rate limit of: **5 requests per second for each IP address**
147
-
148
- The _client's_ limiter settings can be configured as well:
149
-
150
- ```typescript
151
- import { OrderBookApi } from '@cowprotocol/cow-sdk'
152
- import { BackoffOptions } from 'exponential-backoff'
153
- import { RateLimiterOpts } from 'limiter'
154
-
155
- const limiterOpts: RateLimiterOpts = {
156
- tokensPerInterval: 5,
157
- interval: 'second',
158
- }
159
-
160
- const backOffOpts: BackoffOptions = {
161
- numOfAttempts: 5,
162
- maxDelay: Infinity,
163
- jitter: 'none',
164
- }
165
-
166
- const orderBookApi = new OrderBookApi({ chainId: SupportedChainId.GNOSIS_CHAIN, limiterOpts, backOffOpts })
167
- ```
168
-
169
- ### Querying the CoW Subgraph
170
-
171
- The [Subgraph](https://github.com/cowprotocol/subgraph) is constantly indexing the protocol, making all the information more accessible. It provides information about trades, users, tokens and settlements. Additionally, it has some data aggregations which provides insights on the hourly/daily/totals USD volumes, trades, users, etc.
172
-
173
- The SDK provides an easy way to access all this information.
174
-
175
- You can query the CoW Subgraph either by running some common queries exposed by the `CowSubgraphApi` or by building your own:
176
-
177
- ```typescript
178
- import { SubgraphApi, SupportedChainId } from '@cowprotocol/cow-sdk'
179
-
180
- const cowSubgraphApi = new SubgraphApi({ chainId: SupportedChainId.MAINNET })
181
-
182
- // Get CoW Protocol totals
183
- const { tokens, orders, traders, settlements, volumeUsd, volumeEth, feesUsd, feesEth } =
184
- await cowSubgraphApi.getTotals()
185
- console.log({ tokens, orders, traders, settlements, volumeUsd, volumeEth, feesUsd, feesEth })
186
-
187
- // Get last 24 hours volume in usd
188
- const { hourlyTotals } = await cowSubgraphApi.getLastHoursVolume(24)
189
- console.log(hourlyTotals)
190
-
191
- // Get last week volume in usd
192
- const { dailyTotals } = await cowSubgraphApi.getLastDaysVolume(7)
193
- console.log(dailyTotals)
194
-
195
- // Get the last 5 batches
196
- const query = `
197
- query LastBatches($n: Int!) {
198
- settlements(orderBy: firstTradeTimestamp, orderDirection: desc, first: $n) {
199
- txHash
200
- firstTradeTimestamp
201
- }
202
- }
203
- `
204
- const variables = { n: 5 }
205
- const response = await cowSubgraphApi.runQuery(query, variables)
206
- console.log(response)
207
- ```
208
-
209
- ## Architecture
210
-
211
- One way to make the most out of the SDK is to get familiar with its architecture.
212
-
213
- > See [SDK Architecture](https://github.com/cowprotocol/cow-sdk/blob/main/docs/architecture.md)
214
-
215
- ## Development
216
-
217
- ### Install Dependencies
218
-
219
- ```bash
220
- yarn
221
- ```
222
-
223
- ### Build
224
-
225
- ```bash
226
- yarn build
227
-
228
- # Build in watch mode
229
- yarn start
230
- ```
231
-
232
- ### Unit testing
233
-
234
- ```bash
235
- yarn test
236
- ```
237
-
238
- ### Code generation
239
-
240
- Some parts of the SDK are automatically generated. This is the case for the Order Book API and the Subgraph API
241
-
242
- ```bash
243
- # Re-create automatically generated code
244
- yarn codegen
245
- ```
@@ -1,11 +0,0 @@
1
- /**
2
- * Supported chains and their `chainId` for the SDK.
3
- * @enum
4
- */
5
- export declare enum SupportedChainId {
6
- MAINNET = 1,
7
- GNOSIS_CHAIN = 100,
8
- ARBITRUM_ONE = 42161,
9
- BASE = 8453,
10
- SEPOLIA = 11155111
11
- }
@@ -1,78 +0,0 @@
1
- import { BackoffOptions } from 'exponential-backoff';
2
- import { RateLimiterOpts } from 'limiter/dist/esm';
3
- import { SupportedChainId } from './chains';
4
- /**
5
- * IPFS configuration.
6
- *
7
- * For production use, consider using {@link Pinata: https://www.pinata.cloud/}
8
- * @property {string} [uri] The URI of the IPFS node to use.
9
- * @property {string} [writeUri] The URI of the IPFS node to use for writing.
10
- * @property {string} [readUri] The URI of the IPFS node to use for reading.
11
- * @property {string} [pinataApiKey] The API key to use for Pinata.
12
- * @property {string} [pinataApiSecret] The API secret to use for Pinata.
13
- */
14
- export interface IpfsConfig {
15
- uri?: string;
16
- writeUri?: string;
17
- readUri?: string;
18
- pinataApiKey?: string;
19
- pinataApiSecret?: string;
20
- }
21
- /**
22
- * @property {RateLimiterOpts} [limiterOpts] The options to use for the rate limiter.
23
- * @property {BackoffOptions} [backoffOpts] The options to use for the backoff.
24
- */
25
- export interface RequestOptions {
26
- limiterOpts?: RateLimiterOpts;
27
- backoffOpts?: BackoffOptions;
28
- }
29
- /**
30
- * The environment to use for the Cow API.
31
- */
32
- export type CowEnv = 'prod' | 'staging';
33
- /**
34
- * Override some properties of the {@link ApiContext}.
35
- */
36
- export type PartialApiContext = Partial<ApiContext>;
37
- /**
38
- * @property {string} [1] The base URL for the mainnet API.
39
- * @property {string} [100] The base URL for the Gnosis Chain API.
40
- * @property {string} [42161] The base URL for the Arbitrum One API.
41
- * @property {string} [8453] The base URL for the Base API.
42
- * @property {string} [11155111] The base URL for the Sepolia testnet API.
43
- */
44
- export type ApiBaseUrls = Record<SupportedChainId, string>;
45
- /**
46
- * Define the context to use for the CoW Protocol API.
47
- *
48
- * CoW Protocol is a set of smart contracts and off-chain services, deployed on **multiple chains**.
49
- * {@link SupportedChainId Supported chains} are:
50
- * - Mainnet
51
- * - Gnosis Chain
52
- * - Arbitrum One
53
- * - Base
54
- * - Sepolia
55
- *
56
- * Each chain has it's own API, and each API has it's own base URL.
57
- *
58
- * Options may be selectively overridden by passing a {@link PartialApiContext} to the constructor.
59
- * @see {@link https://api.cow.fi/docs/#/}
60
- * @property {SupportedChainId} chainId The `chainId`` corresponding to this CoW Protocol API instance.
61
- * @property {CowEnv} env The environment that this context corresponds to.
62
- * @property {ApiBaseUrls} [baseUrls] URls that may be used to connect to this context.
63
- */
64
- export interface ApiContext {
65
- chainId: SupportedChainId;
66
- env: CowEnv;
67
- baseUrls?: ApiBaseUrls;
68
- limiterOpts?: RateLimiterOpts;
69
- backoffOpts?: BackoffOptions;
70
- }
71
- /**
72
- * The list of available environments.
73
- */
74
- export declare const ENVS_LIST: CowEnv[];
75
- /**
76
- * The default CoW Protocol API context.
77
- */
78
- export declare const DEFAULT_COW_API_CONTEXT: ApiContext;
@@ -1,29 +0,0 @@
1
- import { SupportedChainId } from './chains';
2
- export declare const BUY_ETH_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
3
- export declare const EXTENSIBLE_FALLBACK_HANDLER = "0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5";
4
- export declare const COMPOSABLE_COW = "0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74";
5
- export declare const COW_SHED_FACTORY = "0x00E989b87700514118Fa55326CD1cCE82faebEF6";
6
- export declare const COW_SHED_IMPLEMENTATION = "0x2CFFA8cf11B90C9F437567b86352169dF4009F73";
7
- /**
8
- * The list of supported chains.
9
- */
10
- export declare const ALL_SUPPORTED_CHAIN_IDS: SupportedChainId[];
11
- export declare function mapSupportedNetworks<T>(value: (chainId: SupportedChainId) => T): Record<SupportedChainId, T>;
12
- export declare function mapSupportedNetworks<T>(value: T): Record<SupportedChainId, T>;
13
- export declare function mapAddressToSupportedNetworks(address: string): Record<SupportedChainId, string>;
14
- /**
15
- * An object containing the addresses of the CoW Protocol settlement contracts for each supported chain.
16
- */
17
- export declare const COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS: Record<SupportedChainId, string>;
18
- /**
19
- * An object containing the addresses of the CoW Protocol Vault realyer contracts for each supported chain.
20
- */
21
- export declare const COW_PROTOCOL_VAULT_RELAYER_ADDRESS: Record<SupportedChainId, string>;
22
- /**
23
- * An object containing the addresses of the `ExtensibleFallbackHandler` contracts for each supported chain.
24
- */
25
- export declare const EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS: Record<SupportedChainId, string>;
26
- /**
27
- * An object containing the addresses of the `ComposableCow` contracts for each supported chain.
28
- */
29
- export declare const COMPOSABLE_COW_CONTRACT_ADDRESS: Record<SupportedChainId, string>;
@@ -1,5 +0,0 @@
1
- export declare class CowError extends Error {
2
- error_code?: string;
3
- constructor(message: string, error_code?: string);
4
- }
5
- export declare const logPrefix = "cow-sdk:";