ccxt 4.2.94 → 4.2.96
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/README.md +3 -3
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +964 -406
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/errors.js +25 -64
- package/dist/cjs/src/base/functions/crypto.js +15 -2
- package/dist/cjs/src/base/functions/rsa.js +2 -2
- package/dist/cjs/src/base/ws/OrderBookSide.js +5 -0
- package/dist/cjs/src/bitstamp.js +6 -0
- package/dist/cjs/src/coinbase.js +615 -102
- package/dist/cjs/src/coinex.js +61 -55
- package/dist/cjs/src/gemini.js +29 -10
- package/dist/cjs/src/htx.js +127 -125
- package/dist/cjs/src/okx.js +40 -40
- package/dist/cjs/src/pro/coinbase.js +37 -4
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +3 -3
- package/js/src/abstract/bitstamp.d.ts +6 -0
- package/js/src/abstract/coinbase.d.ts +1 -0
- package/js/src/base/errorHierarchy.d.ts +1 -1
- package/js/src/base/errorHierarchy.js +1 -1
- package/js/src/base/errors.d.ts +26 -26
- package/js/src/base/errors.js +26 -66
- package/js/src/base/functions/crypto.d.ts +1 -1
- package/js/src/base/functions/crypto.js +15 -2
- package/js/src/base/functions/rsa.js +2 -2
- package/js/src/base/types.d.ts +1 -0
- package/js/src/base/ws/OrderBook.d.ts +8 -0
- package/js/src/base/ws/OrderBook.js +1 -6
- package/js/src/base/ws/OrderBookSide.d.ts +9 -3
- package/js/src/base/ws/OrderBookSide.js +6 -1
- package/js/src/bitstamp.js +6 -0
- package/js/src/coinbase.d.ts +8 -1
- package/js/src/coinbase.js +616 -103
- package/js/src/coinex.js +61 -55
- package/js/src/gemini.js +29 -10
- package/js/src/htx.d.ts +1 -0
- package/js/src/htx.js +128 -126
- package/js/src/okx.js +40 -40
- package/js/src/pro/coinbase.js +37 -4
- package/package.json +1 -1
- package/skip-tests.json +2 -0
package/js/src/base/errors.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
declare class BaseError extends Error {
|
|
2
2
|
constructor(message: any);
|
|
3
3
|
}
|
|
4
|
-
declare class ExchangeError extends
|
|
5
|
-
constructor(message: any);
|
|
6
|
-
}
|
|
7
|
-
declare class ExchangeClosedByUser extends Error {
|
|
4
|
+
declare class ExchangeError extends BaseError {
|
|
8
5
|
constructor(message: any);
|
|
9
6
|
}
|
|
10
7
|
declare class AuthenticationError extends ExchangeError {
|
|
11
8
|
constructor(message: any);
|
|
12
9
|
}
|
|
13
|
-
declare class PermissionDenied extends
|
|
10
|
+
declare class PermissionDenied extends AuthenticationError {
|
|
14
11
|
constructor(message: any);
|
|
15
12
|
}
|
|
16
|
-
declare class AccountNotEnabled extends
|
|
13
|
+
declare class AccountNotEnabled extends PermissionDenied {
|
|
17
14
|
constructor(message: any);
|
|
18
15
|
}
|
|
19
|
-
declare class AccountSuspended extends
|
|
16
|
+
declare class AccountSuspended extends AuthenticationError {
|
|
20
17
|
constructor(message: any);
|
|
21
18
|
}
|
|
22
19
|
declare class ArgumentsRequired extends ExchangeError {
|
|
@@ -25,10 +22,10 @@ declare class ArgumentsRequired extends ExchangeError {
|
|
|
25
22
|
declare class BadRequest extends ExchangeError {
|
|
26
23
|
constructor(message: any);
|
|
27
24
|
}
|
|
28
|
-
declare class
|
|
25
|
+
declare class BadSymbol extends BadRequest {
|
|
29
26
|
constructor(message: any);
|
|
30
27
|
}
|
|
31
|
-
declare class
|
|
28
|
+
declare class OperationRejected extends ExchangeError {
|
|
32
29
|
constructor(message: any);
|
|
33
30
|
}
|
|
34
31
|
declare class NoChange extends OperationRejected {
|
|
@@ -40,7 +37,7 @@ declare class MarginModeAlreadySet extends NoChange {
|
|
|
40
37
|
declare class BadResponse extends ExchangeError {
|
|
41
38
|
constructor(message: any);
|
|
42
39
|
}
|
|
43
|
-
declare class NullResponse extends
|
|
40
|
+
declare class NullResponse extends BadResponse {
|
|
44
41
|
constructor(message: any);
|
|
45
42
|
}
|
|
46
43
|
declare class InsufficientFunds extends ExchangeError {
|
|
@@ -55,9 +52,6 @@ declare class AddressPending extends InvalidAddress {
|
|
|
55
52
|
declare class InvalidOrder extends ExchangeError {
|
|
56
53
|
constructor(message: any);
|
|
57
54
|
}
|
|
58
|
-
declare class ContractUnavailable extends InvalidOrder {
|
|
59
|
-
constructor(message: any);
|
|
60
|
-
}
|
|
61
55
|
declare class OrderNotFound extends InvalidOrder {
|
|
62
56
|
constructor(message: any);
|
|
63
57
|
}
|
|
@@ -76,15 +70,21 @@ declare class OrderNotFillable extends InvalidOrder {
|
|
|
76
70
|
declare class DuplicateOrderId extends InvalidOrder {
|
|
77
71
|
constructor(message: any);
|
|
78
72
|
}
|
|
79
|
-
declare class
|
|
73
|
+
declare class ContractUnavailable extends InvalidOrder {
|
|
80
74
|
constructor(message: any);
|
|
81
75
|
}
|
|
82
|
-
declare class
|
|
76
|
+
declare class NotSupported extends ExchangeError {
|
|
83
77
|
constructor(message: any);
|
|
84
78
|
}
|
|
85
79
|
declare class ProxyError extends ExchangeError {
|
|
86
80
|
constructor(message: any);
|
|
87
81
|
}
|
|
82
|
+
declare class ExchangeClosedByUser extends ExchangeError {
|
|
83
|
+
constructor(message: any);
|
|
84
|
+
}
|
|
85
|
+
declare class OperationFailed extends BaseError {
|
|
86
|
+
constructor(message: any);
|
|
87
|
+
}
|
|
88
88
|
declare class NetworkError extends OperationFailed {
|
|
89
89
|
constructor(message: any);
|
|
90
90
|
}
|
|
@@ -106,21 +106,25 @@ declare class InvalidNonce extends NetworkError {
|
|
|
106
106
|
declare class RequestTimeout extends NetworkError {
|
|
107
107
|
constructor(message: any);
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
export { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout };
|
|
110
|
+
declare const _default: {
|
|
110
111
|
BaseError: typeof BaseError;
|
|
111
|
-
ExchangeClosedByUser: typeof ExchangeClosedByUser;
|
|
112
112
|
ExchangeError: typeof ExchangeError;
|
|
113
|
+
AuthenticationError: typeof AuthenticationError;
|
|
113
114
|
PermissionDenied: typeof PermissionDenied;
|
|
114
115
|
AccountNotEnabled: typeof AccountNotEnabled;
|
|
115
116
|
AccountSuspended: typeof AccountSuspended;
|
|
116
117
|
ArgumentsRequired: typeof ArgumentsRequired;
|
|
117
118
|
BadRequest: typeof BadRequest;
|
|
118
119
|
BadSymbol: typeof BadSymbol;
|
|
120
|
+
OperationRejected: typeof OperationRejected;
|
|
121
|
+
NoChange: typeof NoChange;
|
|
119
122
|
MarginModeAlreadySet: typeof MarginModeAlreadySet;
|
|
120
123
|
BadResponse: typeof BadResponse;
|
|
121
124
|
NullResponse: typeof NullResponse;
|
|
122
125
|
InsufficientFunds: typeof InsufficientFunds;
|
|
123
126
|
InvalidAddress: typeof InvalidAddress;
|
|
127
|
+
AddressPending: typeof AddressPending;
|
|
124
128
|
InvalidOrder: typeof InvalidOrder;
|
|
125
129
|
OrderNotFound: typeof OrderNotFound;
|
|
126
130
|
OrderNotCached: typeof OrderNotCached;
|
|
@@ -128,7 +132,11 @@ declare const errors: {
|
|
|
128
132
|
OrderImmediatelyFillable: typeof OrderImmediatelyFillable;
|
|
129
133
|
OrderNotFillable: typeof OrderNotFillable;
|
|
130
134
|
DuplicateOrderId: typeof DuplicateOrderId;
|
|
135
|
+
ContractUnavailable: typeof ContractUnavailable;
|
|
131
136
|
NotSupported: typeof NotSupported;
|
|
137
|
+
ProxyError: typeof ProxyError;
|
|
138
|
+
ExchangeClosedByUser: typeof ExchangeClosedByUser;
|
|
139
|
+
OperationFailed: typeof OperationFailed;
|
|
132
140
|
NetworkError: typeof NetworkError;
|
|
133
141
|
DDoSProtection: typeof DDoSProtection;
|
|
134
142
|
RateLimitExceeded: typeof RateLimitExceeded;
|
|
@@ -136,13 +144,5 @@ declare const errors: {
|
|
|
136
144
|
OnMaintenance: typeof OnMaintenance;
|
|
137
145
|
InvalidNonce: typeof InvalidNonce;
|
|
138
146
|
RequestTimeout: typeof RequestTimeout;
|
|
139
|
-
AuthenticationError: typeof AuthenticationError;
|
|
140
|
-
AddressPending: typeof AddressPending;
|
|
141
|
-
ContractUnavailable: typeof ContractUnavailable;
|
|
142
|
-
NoChange: typeof NoChange;
|
|
143
|
-
OperationRejected: typeof OperationRejected;
|
|
144
|
-
OperationFailed: typeof OperationFailed;
|
|
145
|
-
ProxyError: typeof ProxyError;
|
|
146
147
|
};
|
|
147
|
-
export
|
|
148
|
-
export default errors;
|
|
148
|
+
export default _default;
|
package/js/src/base/errors.js
CHANGED
|
@@ -5,74 +5,37 @@
|
|
|
5
5
|
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
6
|
|
|
7
7
|
/* eslint-disable max-classes-per-file */
|
|
8
|
-
// import { errorHierarchy } from './errorHierarchy.js';
|
|
9
|
-
// Commented out since I'm not sure this is mandatory anymore
|
|
10
|
-
// and does not work out of the box with esm
|
|
11
|
-
// /* ------------------------------------------------------------------------ */
|
|
12
|
-
// function subclass (BaseClass, classes, namespace = {}) {
|
|
13
|
-
// for (const [className, subclasses] of Object.entries (classes)) {
|
|
14
|
-
// const Class = Object.assign (namespace, {
|
|
15
|
-
// /* By creating a named property, we trick compiler to assign our class constructor function a name.
|
|
16
|
-
// Otherwise, all our error constructors would be shown as [Function: Error] in the debugger! And
|
|
17
|
-
// the super-useful `e.constructor.name` magic wouldn't work — we then would have no chance to
|
|
18
|
-
// obtain a error type string from an error instance programmatically! */
|
|
19
|
-
// [className]: class extends BaseClass {
|
|
20
|
-
// constructor (message) {
|
|
21
|
-
// super (message)
|
|
22
|
-
// /* A workaround to make `instanceof` work on custom Error classes in transpiled ES5.
|
|
23
|
-
// See my blog post for the explanation of this hack:
|
|
24
|
-
// https://medium.com/@xpl/javascript-deriving-from-error-properly-8d2f8f315801 */
|
|
25
|
-
// this.constructor = Class
|
|
26
|
-
// this.__proto__ = Class.prototype
|
|
27
|
-
// this.name = className
|
|
28
|
-
// this.message = message
|
|
29
|
-
// // https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work
|
|
30
|
-
// Object.setPrototypeOf (this, Class.prototype)
|
|
31
|
-
// }
|
|
32
|
-
// }
|
|
33
|
-
// })[className]
|
|
34
|
-
// subclass (Class, subclasses, namespace)
|
|
35
|
-
// }
|
|
36
|
-
// return namespace
|
|
37
|
-
// }
|
|
38
8
|
class BaseError extends Error {
|
|
39
9
|
constructor(message) {
|
|
40
10
|
super(message);
|
|
41
11
|
this.name = 'BaseError';
|
|
42
12
|
}
|
|
43
13
|
}
|
|
44
|
-
|
|
45
|
-
class ExchangeError extends Error {
|
|
14
|
+
class ExchangeError extends BaseError {
|
|
46
15
|
constructor(message) {
|
|
47
16
|
super(message);
|
|
48
17
|
this.name = 'ExchangeError';
|
|
49
18
|
}
|
|
50
19
|
}
|
|
51
|
-
class ExchangeClosedByUser extends Error {
|
|
52
|
-
constructor(message) {
|
|
53
|
-
super(message);
|
|
54
|
-
this.name = 'ExchangeClosedByUser';
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
20
|
class AuthenticationError extends ExchangeError {
|
|
58
21
|
constructor(message) {
|
|
59
22
|
super(message);
|
|
60
23
|
this.name = 'AuthenticationError';
|
|
61
24
|
}
|
|
62
25
|
}
|
|
63
|
-
class PermissionDenied extends
|
|
26
|
+
class PermissionDenied extends AuthenticationError {
|
|
64
27
|
constructor(message) {
|
|
65
28
|
super(message);
|
|
66
29
|
this.name = 'PermissionDenied';
|
|
67
30
|
}
|
|
68
31
|
}
|
|
69
|
-
class AccountNotEnabled extends
|
|
32
|
+
class AccountNotEnabled extends PermissionDenied {
|
|
70
33
|
constructor(message) {
|
|
71
34
|
super(message);
|
|
72
35
|
this.name = 'AccountNotEnabled';
|
|
73
36
|
}
|
|
74
37
|
}
|
|
75
|
-
class AccountSuspended extends
|
|
38
|
+
class AccountSuspended extends AuthenticationError {
|
|
76
39
|
constructor(message) {
|
|
77
40
|
super(message);
|
|
78
41
|
this.name = 'AccountSuspended';
|
|
@@ -90,16 +53,16 @@ class BadRequest extends ExchangeError {
|
|
|
90
53
|
this.name = 'BadRequest';
|
|
91
54
|
}
|
|
92
55
|
}
|
|
93
|
-
class
|
|
56
|
+
class BadSymbol extends BadRequest {
|
|
94
57
|
constructor(message) {
|
|
95
58
|
super(message);
|
|
96
|
-
this.name = '
|
|
59
|
+
this.name = 'BadSymbol';
|
|
97
60
|
}
|
|
98
61
|
}
|
|
99
|
-
class
|
|
62
|
+
class OperationRejected extends ExchangeError {
|
|
100
63
|
constructor(message) {
|
|
101
64
|
super(message);
|
|
102
|
-
this.name = '
|
|
65
|
+
this.name = 'OperationRejected';
|
|
103
66
|
}
|
|
104
67
|
}
|
|
105
68
|
class NoChange extends OperationRejected {
|
|
@@ -120,7 +83,7 @@ class BadResponse extends ExchangeError {
|
|
|
120
83
|
this.name = 'BadResponse';
|
|
121
84
|
}
|
|
122
85
|
}
|
|
123
|
-
class NullResponse extends
|
|
86
|
+
class NullResponse extends BadResponse {
|
|
124
87
|
constructor(message) {
|
|
125
88
|
super(message);
|
|
126
89
|
this.name = 'NullResponse';
|
|
@@ -150,12 +113,6 @@ class InvalidOrder extends ExchangeError {
|
|
|
150
113
|
this.name = 'InvalidOrder';
|
|
151
114
|
}
|
|
152
115
|
}
|
|
153
|
-
class ContractUnavailable extends InvalidOrder {
|
|
154
|
-
constructor(message) {
|
|
155
|
-
super(message);
|
|
156
|
-
this.name = 'ContractUnavailable';
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
116
|
class OrderNotFound extends InvalidOrder {
|
|
160
117
|
constructor(message) {
|
|
161
118
|
super(message);
|
|
@@ -192,25 +149,36 @@ class DuplicateOrderId extends InvalidOrder {
|
|
|
192
149
|
this.name = 'DuplicateOrderId';
|
|
193
150
|
}
|
|
194
151
|
}
|
|
152
|
+
class ContractUnavailable extends InvalidOrder {
|
|
153
|
+
constructor(message) {
|
|
154
|
+
super(message);
|
|
155
|
+
this.name = 'ContractUnavailable';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
195
158
|
class NotSupported extends ExchangeError {
|
|
196
159
|
constructor(message) {
|
|
197
160
|
super(message);
|
|
198
161
|
this.name = 'NotSupported';
|
|
199
162
|
}
|
|
200
163
|
}
|
|
201
|
-
class
|
|
164
|
+
class ProxyError extends ExchangeError {
|
|
202
165
|
constructor(message) {
|
|
203
166
|
super(message);
|
|
204
|
-
this.name = '
|
|
167
|
+
this.name = 'ProxyError';
|
|
205
168
|
}
|
|
206
169
|
}
|
|
207
|
-
class
|
|
170
|
+
class ExchangeClosedByUser extends ExchangeError {
|
|
171
|
+
constructor(message) {
|
|
172
|
+
super(message);
|
|
173
|
+
this.name = 'ExchangeClosedByUser';
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
class OperationFailed extends BaseError {
|
|
208
177
|
constructor(message) {
|
|
209
178
|
super(message);
|
|
210
179
|
this.name = 'OperationFailed';
|
|
211
180
|
}
|
|
212
181
|
}
|
|
213
|
-
// Network error
|
|
214
182
|
class NetworkError extends OperationFailed {
|
|
215
183
|
constructor(message) {
|
|
216
184
|
super(message);
|
|
@@ -253,13 +221,5 @@ class RequestTimeout extends NetworkError {
|
|
|
253
221
|
this.name = 'RequestTimeout';
|
|
254
222
|
}
|
|
255
223
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
// // Root class
|
|
259
|
-
// Error,
|
|
260
|
-
// // Derived class hierarchy
|
|
261
|
-
// errorHierarchy
|
|
262
|
-
// )
|
|
263
|
-
const errors = { BaseError, ExchangeClosedByUser, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, ContractUnavailable, NoChange, OperationRejected, OperationFailed, ProxyError };
|
|
264
|
-
export { BaseError, ExchangeClosedByUser, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, ContractUnavailable, NoChange, OperationRejected, OperationFailed, ProxyError };
|
|
265
|
-
export default errors;
|
|
224
|
+
export { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout };
|
|
225
|
+
export default { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout };
|
|
@@ -5,7 +5,7 @@ import { Hex } from '../../static_dependencies/noble-curves/abstract/utils.js';
|
|
|
5
5
|
declare type Digest = 'binary' | 'hex' | 'base64';
|
|
6
6
|
declare const hash: (request: Input, hash: CHash, digest?: Digest) => any;
|
|
7
7
|
declare const hmac: (request: Input, secret: Input, hash: CHash, digest?: Digest) => any;
|
|
8
|
-
declare function ecdsa(request: Hex, secret: Hex, curve: CurveFn, prehash?: CHash): {
|
|
8
|
+
declare function ecdsa(request: Hex, secret: Hex, curve: CurveFn, prehash?: CHash, fixedLength?: boolean): {
|
|
9
9
|
r: string;
|
|
10
10
|
s: string;
|
|
11
11
|
v: number;
|
|
@@ -11,6 +11,7 @@ import { Base64 } from '../../static_dependencies/jsencrypt/lib/asn1js/base64.js
|
|
|
11
11
|
import { ASN1 } from "../../static_dependencies/jsencrypt/lib/asn1js/asn1.js";
|
|
12
12
|
import { secp256k1 } from '../../static_dependencies/noble-curves/secp256k1.js';
|
|
13
13
|
import { P256 } from '../../static_dependencies/noble-curves/p256.js';
|
|
14
|
+
import { numberToBytesLE } from '../../static_dependencies/noble-curves/abstract/utils.js';
|
|
14
15
|
/* ------------------------------------------------------------------------ */
|
|
15
16
|
const encoders = {
|
|
16
17
|
binary: x => x,
|
|
@@ -32,7 +33,7 @@ const hmac = (request, secret, hash, digest = 'hex') => {
|
|
|
32
33
|
return encoders[digest](binary);
|
|
33
34
|
};
|
|
34
35
|
/* ............................................. */
|
|
35
|
-
function ecdsa(request, secret, curve, prehash = null) {
|
|
36
|
+
function ecdsa(request, secret, curve, prehash = null, fixedLength = false) {
|
|
36
37
|
if (prehash) {
|
|
37
38
|
request = hash(request, prehash, 'hex');
|
|
38
39
|
}
|
|
@@ -66,7 +67,19 @@ function ecdsa(request, secret, curve, prehash = null) {
|
|
|
66
67
|
throw new Error('Unsupported key format');
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
+
let signature = curve.sign(request, secret, {
|
|
71
|
+
lowS: true,
|
|
72
|
+
});
|
|
73
|
+
const minimumSize = (BigInt(1) << (BigInt(8) * BigInt(31))) - BigInt(1);
|
|
74
|
+
const halfOrder = curve.CURVE.n / BigInt(2);
|
|
75
|
+
let counter = 0;
|
|
76
|
+
while (fixedLength && (signature.r > halfOrder || signature.r <= minimumSize || signature.s <= minimumSize)) {
|
|
77
|
+
signature = curve.sign(request, secret, {
|
|
78
|
+
lowS: true,
|
|
79
|
+
extraEntropy: numberToBytesLE(BigInt(counter), 32)
|
|
80
|
+
});
|
|
81
|
+
counter += 1;
|
|
82
|
+
}
|
|
70
83
|
return {
|
|
71
84
|
'r': signature.r.toString(16),
|
|
72
85
|
's': signature.s.toString(16),
|
|
@@ -40,8 +40,8 @@ function jwt(request, secret, hash, isRSA = false, opts = {}) {
|
|
|
40
40
|
}
|
|
41
41
|
else if (algoType === 'ES') {
|
|
42
42
|
const signedHash = ecdsa(token, utf8.encode(secret), P256, hash);
|
|
43
|
-
const r =
|
|
44
|
-
const s =
|
|
43
|
+
const r = signedHash.r.padStart(64, '0');
|
|
44
|
+
const s = signedHash.s.padStart(64, '0');
|
|
45
45
|
signature = urlencodeBase64(binaryToBase64(base16ToBinary(r + s)));
|
|
46
46
|
}
|
|
47
47
|
return [token, signature].join('.');
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { IOrderBookSide } from './OrderBookSide.js';
|
|
2
|
+
import { Int, Str } from '../types.js';
|
|
1
3
|
interface CustomOrderBookProp {
|
|
2
4
|
cache: any[];
|
|
3
5
|
}
|
|
4
6
|
declare class OrderBook implements CustomOrderBookProp {
|
|
5
7
|
cache: any[];
|
|
8
|
+
asks: IOrderBookSide<any>;
|
|
9
|
+
bids: IOrderBookSide<any>;
|
|
10
|
+
timestamp: Int;
|
|
11
|
+
datetime: Str;
|
|
12
|
+
nonce: Int;
|
|
13
|
+
symbol: Str;
|
|
6
14
|
constructor(snapshot?: {}, depth?: any);
|
|
7
15
|
limit(): this;
|
|
8
16
|
update(snapshot: any): this;
|
|
@@ -8,12 +8,7 @@
|
|
|
8
8
|
// @ts-nocheck
|
|
9
9
|
import { iso8601 } from '../../base/functions/time.js';
|
|
10
10
|
import { extend } from '../../base/functions/generic.js';
|
|
11
|
-
import { Asks, Bids, CountedAsks, CountedBids, IndexedAsks, IndexedBids
|
|
12
|
-
// IncrementalAsks,
|
|
13
|
-
// IncrementalBids,
|
|
14
|
-
// IncrementalIndexedAsks,
|
|
15
|
-
// IncrementalIndexedBids, // check this
|
|
16
|
-
} from './OrderBookSide.js';
|
|
11
|
+
import { Asks, Bids, CountedAsks, CountedBids, IndexedAsks, IndexedBids } from './OrderBookSide.js';
|
|
17
12
|
class OrderBook {
|
|
18
13
|
constructor(snapshot = {}, depth = undefined) {
|
|
19
14
|
this.cache = []; // make prop visible so we use typed OrderBooks
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
interface IOrderBookSide<T> extends Array<T> {
|
|
2
|
+
store(price: any, size: any): any;
|
|
3
|
+
store(price: any, size: any, index: any): any;
|
|
4
|
+
storeArray(array: any[]): any;
|
|
5
|
+
limit(): any;
|
|
6
|
+
}
|
|
7
|
+
declare class OrderBookSide extends Array implements IOrderBookSide {
|
|
2
8
|
constructor(deltas?: any[], depth?: any);
|
|
3
9
|
storeArray(delta: any): void;
|
|
4
10
|
store(price: any, size: any): void;
|
|
@@ -8,7 +14,7 @@ declare class CountedOrderBookSide extends OrderBookSide {
|
|
|
8
14
|
store(price: any, size: any, count: any): void;
|
|
9
15
|
storeArray(delta: any): void;
|
|
10
16
|
}
|
|
11
|
-
declare class IndexedOrderBookSide extends Array {
|
|
17
|
+
declare class IndexedOrderBookSide extends Array implements IOrderBookSide {
|
|
12
18
|
constructor(deltas?: any[], depth?: number);
|
|
13
19
|
store(price: any, size: any, id: any): void;
|
|
14
20
|
storeArray(delta: any): void;
|
|
@@ -32,4 +38,4 @@ declare class IndexedAsks extends IndexedOrderBookSide {
|
|
|
32
38
|
declare class IndexedBids extends IndexedOrderBookSide {
|
|
33
39
|
get side(): boolean;
|
|
34
40
|
}
|
|
35
|
-
export { Asks, Bids, OrderBookSide, CountedAsks, CountedBids, CountedOrderBookSide, IndexedAsks, IndexedBids, IndexedOrderBookSide, };
|
|
41
|
+
export { Asks, Bids, OrderBookSide, CountedAsks, CountedBids, CountedOrderBookSide, IndexedAsks, IndexedBids, IndexedOrderBookSide, IOrderBookSide };
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
// Author: github.com/frosty00
|
|
13
13
|
// Email: carlo.revelli@berkeley.edu
|
|
14
14
|
//
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param array
|
|
18
|
+
* @param x
|
|
19
|
+
*/
|
|
15
20
|
function bisectLeft(array, x) {
|
|
16
21
|
let low = 0;
|
|
17
22
|
let high = array.length - 1;
|
|
@@ -278,4 +283,4 @@ Asks, Bids, OrderBookSide,
|
|
|
278
283
|
// count-based
|
|
279
284
|
CountedAsks, CountedBids, CountedOrderBookSide,
|
|
280
285
|
// order-id based
|
|
281
|
-
IndexedAsks, IndexedBids, IndexedOrderBookSide
|
|
286
|
+
IndexedAsks, IndexedBids, IndexedOrderBookSide };
|
package/js/src/bitstamp.js
CHANGED
|
@@ -360,6 +360,12 @@ export default class bitstamp extends Exchange {
|
|
|
360
360
|
'blur_address/': 1,
|
|
361
361
|
'vext_withdrawal/': 1,
|
|
362
362
|
'vext_address/': 1,
|
|
363
|
+
'cspr_withdrawal/': 1,
|
|
364
|
+
'cspr_address/': 1,
|
|
365
|
+
'vchf_withdrawal/': 1,
|
|
366
|
+
'vchf_address/': 1,
|
|
367
|
+
'veur_withdrawal/': 1,
|
|
368
|
+
'veur_address/': 1,
|
|
363
369
|
},
|
|
364
370
|
},
|
|
365
371
|
},
|
package/js/src/coinbase.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/coinbase.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class coinbase
|
|
5
5
|
* @augments Exchange
|
|
@@ -10,6 +10,7 @@ export default class coinbase extends Exchange {
|
|
|
10
10
|
fetchAccounts(params?: {}): Promise<Account[]>;
|
|
11
11
|
fetchAccountsV2(params?: {}): Promise<Account[]>;
|
|
12
12
|
fetchAccountsV3(params?: {}): Promise<Account[]>;
|
|
13
|
+
fetchPortfolios(params?: {}): Promise<Account[]>;
|
|
13
14
|
parseAccount(account: any): {
|
|
14
15
|
id: string;
|
|
15
16
|
type: string;
|
|
@@ -33,6 +34,8 @@ export default class coinbase extends Exchange {
|
|
|
33
34
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
34
35
|
fetchMarketsV2(params?: {}): Promise<any[]>;
|
|
35
36
|
fetchMarketsV3(params?: {}): Promise<any[]>;
|
|
37
|
+
parseSpotMarket(market: any, feeTier: any): MarketInterface;
|
|
38
|
+
parseContractMarket(market: any, feeTier: any): MarketInterface;
|
|
36
39
|
fetchCurrenciesFromCache(params?: {}): Promise<import("./base/types.js").Dictionary<any>>;
|
|
37
40
|
fetchCurrencies(params?: {}): Promise<Currencies>;
|
|
38
41
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
@@ -101,6 +104,10 @@ export default class coinbase extends Exchange {
|
|
|
101
104
|
};
|
|
102
105
|
deposit(code: string, amount: number, id: string, params?: {}): Promise<Transaction>;
|
|
103
106
|
fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
|
|
107
|
+
closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
|
|
108
|
+
fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
|
|
109
|
+
fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
|
|
110
|
+
parsePosition(position: any, market?: Market): import("./base/types.js").Position;
|
|
104
111
|
sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
|
|
105
112
|
url: string;
|
|
106
113
|
method: string;
|