@cowprotocol/cow-sdk 1.0.2-RC.6 → 2.0.0-alpha.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/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +11 -13
- package/package.json +28 -31
- package/dist/CowSdk.d.ts +0 -21
- package/dist/api/0x/error/index.d.ts +0 -21
- package/dist/api/0x/index.d.ts +0 -11
- package/dist/api/0x/types.d.ts +0 -87
- package/dist/api/0x/utils.d.ts +0 -17
- package/dist/api/base/index.d.ts +0 -27
- package/dist/api/cow/errors/OperatorError.d.ts +0 -63
- package/dist/api/cow/errors/QuoteError.d.ts +0 -32
- package/dist/api/cow/index.d.ts +0 -26
- package/dist/api/cow/transformOrder.d.ts +0 -2
- package/dist/api/cow/types.d.ts +0 -133
- package/dist/api/cow-subgraph/graphql.d.ts +0 -2957
- package/dist/api/cow-subgraph/index.d.ts +0 -23
- package/dist/api/cow-subgraph/queries.d.ts +0 -3
- package/dist/api/index.d.ts +0 -3
- package/dist/api/metadata/index.d.ts +0 -58
- package/dist/api/metadata/types.d.ts +0 -22
- package/dist/api/paraswap/constants.d.ts +0 -10
- package/dist/api/paraswap/error/index.d.ts +0 -10
- package/dist/api/paraswap/index.d.ts +0 -32
- package/dist/api/paraswap/types.d.ts +0 -19
- package/dist/api/paraswap/utils.d.ts +0 -19
- package/dist/appData.schema-0c8db23b.js +0 -2
- package/dist/appData.schema-0c8db23b.js.map +0 -1
- package/dist/appData.schema-412cbfbf.js +0 -2
- package/dist/appData.schema-412cbfbf.js.map +0 -1
- package/dist/appData.schema-42d10730.js +0 -2
- package/dist/appData.schema-42d10730.js.map +0 -1
- package/dist/appData.schema-4c010c50.js +0 -2
- package/dist/appData.schema-4c010c50.js.map +0 -1
- package/dist/appData.schema-adfc1c6f.js +0 -2
- package/dist/appData.schema-adfc1c6f.js.map +0 -1
- package/dist/appData.schema-b8f018d7.js +0 -2
- package/dist/appData.schema-b8f018d7.js.map +0 -1
- package/dist/constants/chains.d.ts +0 -6
- package/dist/constants/index.d.ts +0 -5
- package/dist/constants/tokens.d.ts +0 -5
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -29
- package/dist/index.js.map +0 -1
- package/dist/index.modern.js +0 -29
- package/dist/index.modern.js.map +0 -1
- package/dist/index.modern.mjs +0 -29
- package/dist/index.modern.mjs.map +0 -1
- package/dist/index.module.js +0 -29
- package/dist/index.module.js.map +0 -1
- package/dist/src/appData.schema-d44994e0.js +0 -2
- package/dist/src/appData.schema-d44994e0.js.map +0 -1
- package/dist/src/appData.schema-fb2df827.js +0 -2
- package/dist/src/appData.schema-fb2df827.js.map +0 -1
- package/dist/src/cow-sdk.esm.js +0 -2
- package/dist/src/cow-sdk.esm.js.map +0 -1
- package/dist/src/cow-sdk.js +0 -2
- package/dist/src/cow-sdk.js.map +0 -1
- package/dist/src/cow-sdk.modern.js +0 -2
- package/dist/src/cow-sdk.modern.js.map +0 -1
- package/dist/src/src/CowSdk.d.ts +0 -16
- package/dist/src/src/api/cow/errors/OperatorError.d.ts +0 -63
- package/dist/src/src/api/cow/errors/QuoteError.d.ts +0 -32
- package/dist/src/src/api/cow/index.d.ts +0 -38
- package/dist/src/src/api/cow/types.d.ts +0 -73
- package/dist/src/src/api/index.d.ts +0 -1
- package/dist/src/src/constants/chains.d.ts +0 -6
- package/dist/src/src/constants/index.d.ts +0 -3
- package/dist/src/src/constants/tokens.d.ts +0 -5
- package/dist/src/src/index.d.ts +0 -4
- package/dist/src/src/types/index.d.ts +0 -7
- package/dist/src/src/utils/appData.d.ts +0 -7
- package/dist/src/src/utils/common.d.ts +0 -5
- package/dist/src/src/utils/context.d.ts +0 -24
- package/dist/src/src/utils/sign.d.ts +0 -54
- package/dist/src/src/utils/tokens.d.ts +0 -2
- package/dist/types/index.d.ts +0 -15
- package/dist/types/sdk.d.ts +0 -39
- package/dist/types/utilities.d.ts +0 -5
- package/dist/utils/appData.d.ts +0 -3
- package/dist/utils/common.d.ts +0 -9
- package/dist/utils/context.d.ts +0 -42
- package/dist/utils/ipfs.d.ts +0 -10
- package/dist/utils/market.d.ts +0 -16
- package/dist/utils/sign.d.ts +0 -55
- package/dist/utils/tokens.d.ts +0 -2
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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/README.md
CHANGED
|
@@ -73,7 +73,6 @@ The next sections will guide you through the process of creating a valid order.
|
|
|
73
73
|
> For a quick snippet with the full process on posting an order see the [Post an Order Example](./docs/post-order-example.ts).
|
|
74
74
|
|
|
75
75
|
### Enable tokens (token approval)
|
|
76
|
-
|
|
77
76
|
Because of the use of off-chain signing (meta-transactions), users will need to **Enable the sell token** before signed
|
|
78
77
|
orders can be considered as valid ones.
|
|
79
78
|
|
|
@@ -92,9 +91,10 @@ import { CowSdk, OrderKind } from '@cowprotocol/cow-sdk'
|
|
|
92
91
|
|
|
93
92
|
const mnemonic = 'fall dirt bread cactus...'
|
|
94
93
|
const wallet = Wallet.fromMnemonic(mnemonic)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
|
|
95
|
+
const cowSdk = new CowSdk(
|
|
96
|
+
100, { // Leaving chainId empty will default to MAINNET
|
|
97
|
+
signer: wallet // Provide a signer, so you can sign order
|
|
98
98
|
})
|
|
99
99
|
```
|
|
100
100
|
|
|
@@ -102,13 +102,13 @@ const cowSdk = new CowSdk(100, {
|
|
|
102
102
|
|
|
103
103
|
To create an order, you need to get a price/fee quote first:
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
* The SDK will give you easy access to the API, which returns the `Market Price` and the `Fee` for any given trade you intent to do.
|
|
106
|
+
* The returned `Market Price` is not strictly needed, you can use your own pricing logic.
|
|
107
|
+
* You can choose a price that is below this Market price (**Market Order**), or above Market Price (**Limit Order**).
|
|
108
|
+
* The `Fee` however is very important.
|
|
109
|
+
* It is the required amount in sell token the trader agrees on paying for executing the order onchain.
|
|
110
|
+
* Normally, its value is proportional to the current Gas Price of the network.
|
|
111
|
+
* This fee is never charged if you don't trade.
|
|
112
112
|
|
|
113
113
|
To get the quote, you simply specify the trade you intent to do:
|
|
114
114
|
|
|
@@ -192,7 +192,6 @@ const orderId = await cowSdk.cowApi.sendOrder({
|
|
|
192
192
|
```
|
|
193
193
|
|
|
194
194
|
### BONUS: Show link to Explorer
|
|
195
|
-
|
|
196
195
|
Once the order is posted, its good to allow to check the state of it.
|
|
197
196
|
|
|
198
197
|
One easy is to check in the CoW Explorer. You can create a CoW Explorer link if you have the `orderId`:
|
|
@@ -321,7 +320,6 @@ const uploadedAppDataHash = await cowSdk.metadataApi.uploadMetadataDocToIpfs(app
|
|
|
321
320
|
```
|
|
322
321
|
|
|
323
322
|
## Convert IPFS CIDv0 to AppData (and back)
|
|
324
|
-
|
|
325
323
|
Given an IPFS CIDv0 you can convert it to an `AppData`
|
|
326
324
|
|
|
327
325
|
```js
|
package/package.json
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/cow-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
|
-
"source": "src/index.ts",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.module.js",
|
|
8
|
-
"exports": {
|
|
9
|
-
"require": "./dist/index.js",
|
|
10
|
-
"default": "./dist/index.modern.mjs"
|
|
11
|
-
},
|
|
12
|
-
"types": "dist/index.d.ts",
|
|
13
5
|
"files": [
|
|
14
6
|
"/dist"
|
|
15
7
|
],
|
|
16
8
|
"scripts": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
9
|
+
"prebuild": "rm -rf dist && yarn run codegen",
|
|
10
|
+
"build": "tsc --module commonjs",
|
|
11
|
+
"postbuild": "cp package.json dist && cp README.md dist",
|
|
12
|
+
"start:metadata": "tsc-watch --noClear -p ./tsconfig.json --onSuccess \"node ./dist/metadata/index.js\"",
|
|
13
|
+
"start:order-book": "tsc-watch --noClear -p ./tsconfig.json --onSuccess \"node ./dist/order-book/index.js\"",
|
|
14
|
+
"start:subgraph": "tsc-watch --noClear -p ./tsconfig.json --onSuccess \"node ./dist/subgraph/index.js\"",
|
|
19
15
|
"lint": "eslint src",
|
|
20
16
|
"format": "prettier --write \"src/**/*.+(ts|json)\"",
|
|
21
17
|
"test": "jest",
|
|
22
18
|
"test:coverage": "jest --coverage --json --outputFile=jest.results.json && cat ./coverage/lcov.info | coveralls",
|
|
23
|
-
"
|
|
19
|
+
"codegen": "npm run graphql:codegen && npm run swagger:codegen",
|
|
24
20
|
"prepublishOnly": "npm test && npm run lint",
|
|
25
|
-
"graphql:codegen": "graphql-codegen --config graphql-codegen.yml"
|
|
21
|
+
"graphql:codegen": "graphql-codegen --config graphql-codegen.yml",
|
|
22
|
+
"swagger:codegen": " openapi --input https://raw.githubusercontent.com/cowprotocol/services/fix/orderbook-openapi/crates/orderbook/openapi.yml --output src/order-book/generated --client fetch --name OrderBookClient"
|
|
26
23
|
},
|
|
27
24
|
"dependencies": {
|
|
28
25
|
"@cowprotocol/app-data": "^0.0.3-RC.0",
|
|
@@ -32,30 +29,31 @@
|
|
|
32
29
|
"graphql": "^16.3.0",
|
|
33
30
|
"graphql-request": "^4.3.0",
|
|
34
31
|
"ipfs-only-hash": "^4.0.0",
|
|
35
|
-
"
|
|
36
|
-
"multiformats": "^9.6.4",
|
|
37
|
-
"paraswap": "^5.2.0",
|
|
38
|
-
"paraswap-core": "^1.0.2"
|
|
32
|
+
"multiformats": "^9.6.4"
|
|
39
33
|
},
|
|
40
34
|
"devDependencies": {
|
|
41
35
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
|
42
36
|
"@babel/plugin-proposal-private-methods": "^7.18.6",
|
|
37
|
+
"@babel/preset-env": "^7.20.2",
|
|
43
38
|
"@babel/preset-typescript": "^7.18.6",
|
|
44
|
-
"@graphql-codegen/cli": "
|
|
45
|
-
"@graphql-codegen/typescript": "
|
|
46
|
-
"@graphql-codegen/typescript-operations": "^
|
|
47
|
-
"@types/jest": "^
|
|
48
|
-
"@
|
|
49
|
-
"@typescript-eslint/
|
|
39
|
+
"@graphql-codegen/cli": "3.0.0",
|
|
40
|
+
"@graphql-codegen/typescript": "3.0.0",
|
|
41
|
+
"@graphql-codegen/typescript-operations": "^3.0.0",
|
|
42
|
+
"@types/jest": "^29.4.0",
|
|
43
|
+
"@types/node": "^18.13.0",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
45
|
+
"@typescript-eslint/parser": "^5.51.0",
|
|
50
46
|
"babel-plugin-inline-import": "^3.0.0",
|
|
51
47
|
"coveralls": "^3.1.1",
|
|
52
|
-
"eslint": "^8.
|
|
53
|
-
"eslint-config-prettier": "^8.
|
|
54
|
-
"eslint-plugin-prettier": "^4.
|
|
55
|
-
"jest": "^
|
|
48
|
+
"eslint": "^8.33.0",
|
|
49
|
+
"eslint-config-prettier": "^8.6.0",
|
|
50
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
51
|
+
"jest": "^29.4.2",
|
|
56
52
|
"jest-fetch-mock": "^3.0.3",
|
|
57
|
-
"
|
|
58
|
-
"prettier": "^2.5.1"
|
|
53
|
+
"openapi-typescript-codegen": "^0.23.0",
|
|
54
|
+
"prettier": "^2.5.1",
|
|
55
|
+
"tsc-watch": "^6.0.0",
|
|
56
|
+
"typescript": "^4.9.5"
|
|
59
57
|
},
|
|
60
58
|
"jest": {
|
|
61
59
|
"automock": false,
|
|
@@ -64,8 +62,7 @@
|
|
|
64
62
|
"./setupTests.js"
|
|
65
63
|
],
|
|
66
64
|
"collectCoverageFrom": [
|
|
67
|
-
"src/**/*.{ts,tsx}"
|
|
68
|
-
"!src/api/cow/errors/*.{ts,tsx}"
|
|
65
|
+
"src/**/*.{ts,tsx}"
|
|
69
66
|
]
|
|
70
67
|
},
|
|
71
68
|
"keywords": [
|
package/dist/CowSdk.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Signer } from 'ethers';
|
|
2
|
-
import { CowApi, CowSubgraphApi, MetadataApi } from './api';
|
|
3
|
-
import { SupportedChainId as ChainId } from './constants/chains';
|
|
4
|
-
import { Context, CowContext } from './utils/context';
|
|
5
|
-
import { UnsignedOrder } from './utils/sign';
|
|
6
|
-
import { SdkOptions, ParaswapEnabled, ZeroXEnabled, OptionsWithApisEnabledStatus } from 'sdk';
|
|
7
|
-
export declare class CowSdk<T extends ChainId = ChainId, Opt extends SdkOptions = OptionsWithApisEnabledStatus> {
|
|
8
|
-
context: Context;
|
|
9
|
-
cowApi: CowApi;
|
|
10
|
-
metadataApi: MetadataApi;
|
|
11
|
-
cowSubgraphApi: CowSubgraphApi;
|
|
12
|
-
zeroXApi: ZeroXEnabled<Opt>;
|
|
13
|
-
paraswapApi: ParaswapEnabled<Opt>;
|
|
14
|
-
constructor(chainId?: T, cowContext?: CowContext, options?: Opt);
|
|
15
|
-
updateChainId: (chainId: ChainId) => void;
|
|
16
|
-
updateContext: (cowContext: CowContext, chainId?: ChainId) => Promise<void>;
|
|
17
|
-
signOrder(order: Omit<UnsignedOrder, 'appData'>): Promise<import("./utils/sign").SigningResult>;
|
|
18
|
-
signOrderCancellation(orderId: string): Promise<import("./utils/sign").SigningResult>;
|
|
19
|
-
_checkSigner(signer?: Signer | undefined): Signer;
|
|
20
|
-
}
|
|
21
|
-
export default CowSdk;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { CowError } from '../../../utils/common';
|
|
2
|
-
interface ValidationError {
|
|
3
|
-
field: string;
|
|
4
|
-
code: number;
|
|
5
|
-
reason: string;
|
|
6
|
-
}
|
|
7
|
-
export interface ZeroXErrorResponse {
|
|
8
|
-
code: number;
|
|
9
|
-
reason: string;
|
|
10
|
-
validationErrors?: ValidationError[];
|
|
11
|
-
}
|
|
12
|
-
export declare const logPrefix = "0x-sdk:";
|
|
13
|
-
export default class ZeroXError extends CowError {
|
|
14
|
-
name: string;
|
|
15
|
-
description: string;
|
|
16
|
-
message: string;
|
|
17
|
-
static getErrorMessage(response: Response): Promise<string>;
|
|
18
|
-
static getErrorFromStatusCode(response: Response): Promise<string>;
|
|
19
|
-
constructor(apiError: ZeroXErrorResponse);
|
|
20
|
-
}
|
|
21
|
-
export {};
|
package/dist/api/0x/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SupportedChainId } from '../../constants/chains';
|
|
2
|
-
import BaseApi from '../base';
|
|
3
|
-
import { Options, PriceQuoteLegacyParams } from '../cow/types';
|
|
4
|
-
import { ZeroXOptions, ZeroXQuote } from './types';
|
|
5
|
-
export declare class ZeroXApi extends BaseApi {
|
|
6
|
-
ZEROX_OPTIONS: ZeroXOptions;
|
|
7
|
-
ZEROX_OPTIONS_URL: string;
|
|
8
|
-
constructor(chainId: SupportedChainId, options: Partial<ZeroXOptions> | undefined);
|
|
9
|
-
getQuote(params: PriceQuoteLegacyParams, options?: Options): Promise<ZeroXQuote | null>;
|
|
10
|
-
updateOptions({ affiliateAddressMap, excludedSources }: Partial<ZeroXOptions>): Promise<void>;
|
|
11
|
-
}
|
package/dist/api/0x/types.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { SupportedChainId } from '../../constants/chains';
|
|
2
|
-
interface GetSwapQuoteResponseLiquiditySource {
|
|
3
|
-
name: string;
|
|
4
|
-
proportion: string;
|
|
5
|
-
intermediateToken?: string;
|
|
6
|
-
hops?: string[];
|
|
7
|
-
}
|
|
8
|
-
interface ZeroXBaseQuote {
|
|
9
|
-
chainId: SupportedChainId;
|
|
10
|
-
price: string;
|
|
11
|
-
buyAmount: string;
|
|
12
|
-
sellAmount: string;
|
|
13
|
-
sources: GetSwapQuoteResponseLiquiditySource[];
|
|
14
|
-
gasPrice: string;
|
|
15
|
-
estimatedGas: string;
|
|
16
|
-
sellTokenToEthRate: string;
|
|
17
|
-
buyTokenToEthRate: string;
|
|
18
|
-
protocolFee: string;
|
|
19
|
-
minimumProtocolFee: string;
|
|
20
|
-
allowanceTarget?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface ZeroXQuote extends ZeroXBaseQuote {
|
|
23
|
-
sellTokenAddress: string;
|
|
24
|
-
buyTokenAddress: string;
|
|
25
|
-
value: string;
|
|
26
|
-
gas: string;
|
|
27
|
-
}
|
|
28
|
-
export declare type ZeroXOptions = {
|
|
29
|
-
affiliateAddressMap: Partial<Record<number, string>>;
|
|
30
|
-
excludedSources: ERC20BridgeSource[];
|
|
31
|
-
};
|
|
32
|
-
export declare enum ERC20BridgeSource {
|
|
33
|
-
Native = "Native",
|
|
34
|
-
Uniswap = "Uniswap",
|
|
35
|
-
UniswapV2 = "Uniswap_V2",
|
|
36
|
-
Eth2Dai = "Eth2Dai",
|
|
37
|
-
Kyber = "Kyber",
|
|
38
|
-
Curve = "Curve",
|
|
39
|
-
LiquidityProvider = "LiquidityProvider",
|
|
40
|
-
MultiBridge = "MultiBridge",
|
|
41
|
-
Balancer = "Balancer",
|
|
42
|
-
BalancerV2 = "Balancer_V2",
|
|
43
|
-
Cream = "CREAM",
|
|
44
|
-
Bancor = "Bancor",
|
|
45
|
-
MakerPsm = "MakerPsm",
|
|
46
|
-
MStable = "mStable",
|
|
47
|
-
Mooniswap = "Mooniswap",
|
|
48
|
-
MultiHop = "MultiHop",
|
|
49
|
-
Shell = "Shell",
|
|
50
|
-
Swerve = "Swerve",
|
|
51
|
-
SnowSwap = "SnowSwap",
|
|
52
|
-
SushiSwap = "SushiSwap",
|
|
53
|
-
Dodo = "DODO",
|
|
54
|
-
DodoV2 = "DODO_V2",
|
|
55
|
-
CryptoCom = "CryptoCom",
|
|
56
|
-
Linkswap = "Linkswap",
|
|
57
|
-
KyberDmm = "KyberDMM",
|
|
58
|
-
Smoothy = "Smoothy",
|
|
59
|
-
Component = "Component",
|
|
60
|
-
Saddle = "Saddle",
|
|
61
|
-
XSigma = "xSigma",
|
|
62
|
-
UniswapV3 = "Uniswap_V3",
|
|
63
|
-
CurveV2 = "Curve_V2",
|
|
64
|
-
Lido = "Lido",
|
|
65
|
-
ShibaSwap = "ShibaSwap",
|
|
66
|
-
Clipper = "Clipper",
|
|
67
|
-
PancakeSwap = "PancakeSwap",
|
|
68
|
-
PancakeSwapV2 = "PancakeSwap_V2",
|
|
69
|
-
BakerySwap = "BakerySwap",
|
|
70
|
-
Nerve = "Nerve",
|
|
71
|
-
Belt = "Belt",
|
|
72
|
-
Ellipsis = "Ellipsis",
|
|
73
|
-
ApeSwap = "ApeSwap",
|
|
74
|
-
CafeSwap = "CafeSwap",
|
|
75
|
-
CheeseSwap = "CheeseSwap",
|
|
76
|
-
JulSwap = "JulSwap",
|
|
77
|
-
ACryptos = "ACryptoS",
|
|
78
|
-
QuickSwap = "QuickSwap",
|
|
79
|
-
ComethSwap = "ComethSwap",
|
|
80
|
-
Dfyn = "Dfyn",
|
|
81
|
-
WaultSwap = "WaultSwap",
|
|
82
|
-
Polydex = "Polydex",
|
|
83
|
-
FirebirdOneSwap = "FirebirdOneSwap",
|
|
84
|
-
JetSwap = "JetSwap",
|
|
85
|
-
IronSwap = "IronSwap"
|
|
86
|
-
}
|
|
87
|
-
export {};
|
package/dist/api/0x/utils.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { OrderKind } from '@cowprotocol/contracts';
|
|
2
|
-
import { SupportedChainId } from '../../constants/chains';
|
|
3
|
-
import { PriceInformation, PriceQuoteLegacyParams } from '../cow/types';
|
|
4
|
-
import { ZeroXOptions, ZeroXQuote } from './types';
|
|
5
|
-
export declare function get0xUrls(): Partial<Record<SupportedChainId, string>>;
|
|
6
|
-
export declare function normaliseQuoteResponse(priceRaw: ZeroXQuote | null, kind: OrderKind): PriceInformation | null;
|
|
7
|
-
export declare function getMatchaChainId(chainId: SupportedChainId): SupportedChainId | null;
|
|
8
|
-
export declare function optionsToMatchaParamsUrl({ excludedSources, affiliateAddress, }: {
|
|
9
|
-
excludedSources: ZeroXOptions['excludedSources'];
|
|
10
|
-
affiliateAddress: string;
|
|
11
|
-
}): string;
|
|
12
|
-
export declare function handleQuoteResponse<T = unknown, P extends PriceQuoteLegacyParams = PriceQuoteLegacyParams>(response: Response, params?: P): Promise<T>;
|
|
13
|
-
export declare function throwOrReturnAffiliateAddress({ affiliateAddressMap, chainId, }: {
|
|
14
|
-
affiliateAddressMap: ZeroXOptions['affiliateAddressMap'];
|
|
15
|
-
chainId: SupportedChainId;
|
|
16
|
-
}): string;
|
|
17
|
-
export declare function extractExcludedSources({ excludedSources }: Pick<ZeroXOptions, 'excludedSources'>): string;
|
package/dist/api/base/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { SupportedChainId } from '../../constants/chains';
|
|
2
|
-
import { Context } from '../../utils/context';
|
|
3
|
-
import { Options } from '../cow/types';
|
|
4
|
-
interface ConstructorParams {
|
|
5
|
-
context: Context;
|
|
6
|
-
name: string;
|
|
7
|
-
apiVersion?: string;
|
|
8
|
-
getApiUrl: (...params: any[]) => Partial<Record<SupportedChainId, string>>;
|
|
9
|
-
defaultHeaders?: HeadersInit;
|
|
10
|
-
}
|
|
11
|
-
export default class BaseApi {
|
|
12
|
-
context: Context;
|
|
13
|
-
API_NAME: string;
|
|
14
|
-
API_VERSION: string;
|
|
15
|
-
API_URL_GETTER: (...params: any[]) => Partial<Record<SupportedChainId, string>>;
|
|
16
|
-
DEFAULT_HEADERS: HeadersInit;
|
|
17
|
-
constructor({ context, name, getApiUrl, defaultHeaders, apiVersion, }: ConstructorParams);
|
|
18
|
-
protected getApiBaseUrl(...params: unknown[]): Promise<string>;
|
|
19
|
-
protected post(url: string, data: unknown, options?: Options, onlySingleEnv?: boolean): Promise<Response>;
|
|
20
|
-
protected get(url: string, options?: Options): Promise<Response>;
|
|
21
|
-
protected delete(url: string, data: unknown, options?: Options): Promise<Response>;
|
|
22
|
-
protected fetchSingleEnv(url: string, method: 'GET' | 'POST' | 'DELETE', fetchFn: BaseApi['fetch'], getApiUrl: BaseApi['API_URL_GETTER'], options?: Options, data?: unknown): Promise<Response>;
|
|
23
|
-
protected fetchMultipleEnvs(url: string, method: 'GET' | 'POST' | 'DELETE', fetchFn: BaseApi['fetch'], getApiUrl: BaseApi['API_URL_GETTER'], options?: Options, data?: unknown): Promise<Response>;
|
|
24
|
-
protected fetch(url: string, method: 'GET' | 'POST' | 'DELETE', baseUrl: string, data?: unknown, requestOptions?: RequestInit): Promise<Response>;
|
|
25
|
-
private fetchMultipleEnvsRecursive;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { CowError } from '../../../utils/common';
|
|
2
|
-
declare type ApiActionType = 'get' | 'create' | 'delete';
|
|
3
|
-
export interface ApiErrorObject {
|
|
4
|
-
errorType: ApiErrorCodes;
|
|
5
|
-
description: string;
|
|
6
|
-
data?: unknown;
|
|
7
|
-
}
|
|
8
|
-
export declare enum ApiErrorCodes {
|
|
9
|
-
DuplicateOrder = "DuplicateOrder",
|
|
10
|
-
InvalidSignature = "InvalidSignature",
|
|
11
|
-
MissingOrderData = "MissingOrderData",
|
|
12
|
-
InsufficientValidTo = "InsufficientValidTo",
|
|
13
|
-
InsufficientAllowance = "InsufficientAllowance",
|
|
14
|
-
InsufficientBalance = "InsufficientBalance",
|
|
15
|
-
InsufficientFee = "InsufficientFee",
|
|
16
|
-
WrongOwner = "WrongOwner",
|
|
17
|
-
NotFound = "NotFound",
|
|
18
|
-
OrderNotFound = "OrderNotFound",
|
|
19
|
-
AlreadyCancelled = "AlreadyCancelled",
|
|
20
|
-
OrderFullyExecuted = "OrderFullyExecuted",
|
|
21
|
-
OrderExpired = "OrderExpired",
|
|
22
|
-
NoLiquidity = "NoLiquidity",
|
|
23
|
-
UnsupportedToken = "UnsupportedToken",
|
|
24
|
-
AmountIsZero = "AmountIsZero",
|
|
25
|
-
SellAmountDoesNotCoverFee = "SellAmountDoesNotCoverFee",
|
|
26
|
-
TransferEthToContract = "TransferEthToContract",
|
|
27
|
-
UNHANDLED_GET_ERROR = "UNHANDLED_GET_ERROR",
|
|
28
|
-
UNHANDLED_CREATE_ERROR = "UNHANDLED_CREATE_ERROR",
|
|
29
|
-
UNHANDLED_DELETE_ERROR = "UNHANDLED_DELETE_ERROR"
|
|
30
|
-
}
|
|
31
|
-
export declare enum ApiErrorCodeDetails {
|
|
32
|
-
DuplicateOrder = "There was another identical order already submitted. Please try again.",
|
|
33
|
-
InsufficientFee = "The signed fee is insufficient. It's possible that is higher now due to a change in the gas price, ether price, or the sell token price. Please try again to get an updated fee quote.",
|
|
34
|
-
InvalidSignature = "The order signature is invalid. Check whether your Wallet app supports off-chain signing.",
|
|
35
|
-
MissingOrderData = "The order has missing information",
|
|
36
|
-
InsufficientValidTo = "The order you are signing is already expired. This can happen if you set a short expiration in the settings and waited too long before signing the transaction. Please try again.",
|
|
37
|
-
InsufficientAllowance = "The account doesn't have enough funds",
|
|
38
|
-
InsufficientBalance = "The account needs to approve the selling token in order to trade",
|
|
39
|
-
WrongOwner = "The signature is invalid.\n\nIt's likely that the signing method provided by your wallet doesn't comply with the standards required by CowSwap.\n\nCheck whether your Wallet app supports off-chain signing (EIP-712 or ETHSIGN).",
|
|
40
|
-
NotFound = "Not found",
|
|
41
|
-
OrderNotFound = "The order you are trying to cancel does not exist",
|
|
42
|
-
AlreadyCancelled = "Order is already cancelled",
|
|
43
|
-
OrderFullyExecuted = "Order is already filled",
|
|
44
|
-
OrderExpired = "Order is expired",
|
|
45
|
-
NoLiquidity = "Token pair selected has insufficient liquidity",
|
|
46
|
-
UnsupportedToken = "One of the tokens you are trading is unsupported. Please read the FAQ for more info.",
|
|
47
|
-
AmountIsZero = "Amount is zero",
|
|
48
|
-
SellAmountDoesNotCoverFee = "Sell amount does not sufficiently cover the current fee",
|
|
49
|
-
TransferEthToContract = "Sending the native currency to smart contract wallets is not currently supported",
|
|
50
|
-
UNHANDLED_GET_ERROR = "Order fetch failed. This may be due to a server or network connectivity issue. Please try again later.",
|
|
51
|
-
UNHANDLED_CREATE_ERROR = "The order was not accepted by the network",
|
|
52
|
-
UNHANDLED_DELETE_ERROR = "The order cancellation was not accepted by the network"
|
|
53
|
-
}
|
|
54
|
-
export default class OperatorError extends CowError {
|
|
55
|
-
name: string;
|
|
56
|
-
description: ApiErrorObject['description'];
|
|
57
|
-
static apiErrorDetails: typeof ApiErrorCodeDetails;
|
|
58
|
-
static getErrorMessage(response: Response, action: ApiActionType): Promise<string>;
|
|
59
|
-
static getErrorFromStatusCode(response: Response, action: 'create' | 'delete'): Promise<string>;
|
|
60
|
-
constructor(apiError: ApiErrorObject);
|
|
61
|
-
}
|
|
62
|
-
export declare function isValidOperatorError(error: unknown): error is OperatorError;
|
|
63
|
-
export {};
|