ccxt 4.2.60 → 4.2.62
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 +6 -5
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +11280 -3407
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/src/abstract/hyperliquid.js +9 -0
- package/dist/cjs/src/base/Exchange.js +22 -1
- package/dist/cjs/src/base/functions/encode.js +5 -0
- package/dist/cjs/src/base/functions.js +1 -0
- package/dist/cjs/src/bitfinex2.js +1 -1
- package/dist/cjs/src/bitget.js +74 -23
- package/dist/cjs/src/coinbase.js +108 -103
- package/dist/cjs/src/coinex.js +61 -1
- package/dist/cjs/src/hyperliquid.js +2035 -0
- package/dist/cjs/src/kraken.js +8 -2
- package/dist/cjs/src/krakenfutures.js +28 -0
- package/dist/cjs/src/kucoinfutures.js +2 -2
- package/dist/cjs/src/okx.js +1 -1
- package/dist/cjs/src/phemex.js +2 -2
- package/dist/cjs/src/pro/bingx.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +158 -0
- package/dist/cjs/src/static_dependencies/ethers/address/address.js +144 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +407 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/address.js +45 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/anonymous.js +28 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/array.js +176 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/boolean.js +27 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +52 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +45 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/null.js +30 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/number.js +60 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/string.js +27 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/tuple.js +68 -0
- package/dist/cjs/src/static_dependencies/ethers/fragments.js +614 -0
- package/dist/cjs/src/static_dependencies/ethers/hash/typed-data.js +492 -0
- package/dist/cjs/src/static_dependencies/ethers/index.js +35 -0
- package/dist/cjs/src/static_dependencies/ethers/interface.js +44 -0
- package/dist/cjs/src/static_dependencies/ethers/typed.js +618 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/base58.js +20 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/data.js +134 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/errors.js +228 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/events.js +13 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/fixednumber.js +29 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/index.js +53 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/maths.js +231 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/properties.js +47 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/utf8.js +218 -0
- package/dist/cjs/src/static_dependencies/messagepack/msgpack.js +292 -0
- package/dist/cjs/src/tokocrypto.js +22 -2
- package/dist/cjs/src/wazirx.js +308 -3
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/coinbase.d.ts +3 -3
- package/js/src/abstract/hyperliquid.d.ts +9 -0
- package/js/src/abstract/hyperliquid.js +11 -0
- package/js/src/base/Exchange.d.ts +4 -0
- package/js/src/base/Exchange.js +13 -1
- package/js/src/base/functions/encode.d.ts +2 -1
- package/js/src/base/functions/encode.js +5 -1
- package/js/src/bitfinex2.js +1 -1
- package/js/src/bitget.js +74 -23
- package/js/src/coinbase.js +108 -103
- package/js/src/coinex.d.ts +3 -1
- package/js/src/coinex.js +61 -1
- package/js/src/hyperliquid.d.ts +83 -0
- package/js/src/hyperliquid.js +2036 -0
- package/js/src/kraken.js +8 -2
- package/js/src/krakenfutures.d.ts +2 -1
- package/js/src/krakenfutures.js +28 -0
- package/js/src/kucoinfutures.js +2 -2
- package/js/src/okx.js +1 -1
- package/js/src/phemex.js +2 -2
- package/js/src/pro/bingx.js +1 -0
- package/js/src/static_dependencies/ethers/abi-coder.d.ts +50 -0
- package/js/src/static_dependencies/ethers/abi-coder.js +148 -0
- package/js/src/static_dependencies/ethers/address/address.d.ts +55 -0
- package/js/src/static_dependencies/ethers/address/address.js +162 -0
- package/js/src/static_dependencies/ethers/address/checks.d.ts +80 -0
- package/js/src/static_dependencies/ethers/address/checks.js +119 -0
- package/js/src/static_dependencies/ethers/address/contract-address.d.ts +47 -0
- package/js/src/static_dependencies/ethers/address/contract-address.js +73 -0
- package/js/src/static_dependencies/ethers/address/index.d.ts +48 -0
- package/js/src/static_dependencies/ethers/address/index.js +24 -0
- package/js/src/static_dependencies/ethers/bytes32.d.ts +14 -0
- package/js/src/static_dependencies/ethers/bytes32.js +45 -0
- package/js/src/static_dependencies/ethers/coders/abstract-coder.d.ts +120 -0
- package/js/src/static_dependencies/ethers/coders/abstract-coder.js +424 -0
- package/js/src/static_dependencies/ethers/coders/address.d.ts +12 -0
- package/js/src/static_dependencies/ethers/coders/address.js +34 -0
- package/js/src/static_dependencies/ethers/coders/anonymous.d.ts +14 -0
- package/js/src/static_dependencies/ethers/coders/anonymous.js +27 -0
- package/js/src/static_dependencies/ethers/coders/array.d.ts +24 -0
- package/js/src/static_dependencies/ethers/coders/array.js +162 -0
- package/js/src/static_dependencies/ethers/coders/boolean.d.ts +12 -0
- package/js/src/static_dependencies/ethers/coders/boolean.js +26 -0
- package/js/src/static_dependencies/ethers/coders/bytes.d.ts +18 -0
- package/js/src/static_dependencies/ethers/coders/bytes.js +39 -0
- package/js/src/static_dependencies/ethers/coders/fixed-bytes.d.ts +14 -0
- package/js/src/static_dependencies/ethers/coders/fixed-bytes.js +32 -0
- package/js/src/static_dependencies/ethers/coders/null.d.ts +11 -0
- package/js/src/static_dependencies/ethers/coders/null.js +29 -0
- package/js/src/static_dependencies/ethers/coders/number.d.ts +15 -0
- package/js/src/static_dependencies/ethers/coders/number.js +48 -0
- package/js/src/static_dependencies/ethers/coders/string.d.ts +12 -0
- package/js/src/static_dependencies/ethers/coders/string.js +26 -0
- package/js/src/static_dependencies/ethers/coders/tuple.d.ts +15 -0
- package/js/src/static_dependencies/ethers/coders/tuple.js +67 -0
- package/js/src/static_dependencies/ethers/fragments.d.ts +458 -0
- package/js/src/static_dependencies/ethers/fragments.js +1252 -0
- package/js/src/static_dependencies/ethers/hash/index.d.ts +10 -0
- package/js/src/static_dependencies/ethers/hash/index.js +15 -0
- package/js/src/static_dependencies/ethers/hash/solidity.d.ts +30 -0
- package/js/src/static_dependencies/ethers/hash/solidity.js +107 -0
- package/js/src/static_dependencies/ethers/hash/typed-data.d.ts +144 -0
- package/js/src/static_dependencies/ethers/hash/typed-data.js +490 -0
- package/js/src/static_dependencies/ethers/index.d.ts +19 -0
- package/js/src/static_dependencies/ethers/index.js +22 -0
- package/js/src/static_dependencies/ethers/interface.d.ts +380 -0
- package/js/src/static_dependencies/ethers/interface.js +990 -0
- package/js/src/static_dependencies/ethers/typed.d.ts +569 -0
- package/js/src/static_dependencies/ethers/typed.js +608 -0
- package/js/src/static_dependencies/ethers/utils/base58.d.ts +22 -0
- package/js/src/static_dependencies/ethers/utils/base58.js +68 -0
- package/js/src/static_dependencies/ethers/utils/base64-browser.d.ts +3 -0
- package/js/src/static_dependencies/ethers/utils/base64-browser.js +24 -0
- package/js/src/static_dependencies/ethers/utils/base64.d.ts +39 -0
- package/js/src/static_dependencies/ethers/utils/base64.js +58 -0
- package/js/src/static_dependencies/ethers/utils/data.d.ts +92 -0
- package/js/src/static_dependencies/ethers/utils/data.js +175 -0
- package/js/src/static_dependencies/ethers/utils/errors.d.ts +509 -0
- package/js/src/static_dependencies/ethers/utils/errors.js +227 -0
- package/js/src/static_dependencies/ethers/utils/events.d.ts +76 -0
- package/js/src/static_dependencies/ethers/utils/events.js +52 -0
- package/js/src/static_dependencies/ethers/utils/fixednumber.d.ts +251 -0
- package/js/src/static_dependencies/ethers/utils/fixednumber.js +529 -0
- package/js/src/static_dependencies/ethers/utils/index.d.ts +30 -0
- package/js/src/static_dependencies/ethers/utils/index.js +38 -0
- package/js/src/static_dependencies/ethers/utils/maths.d.ts +65 -0
- package/js/src/static_dependencies/ethers/utils/maths.js +220 -0
- package/js/src/static_dependencies/ethers/utils/properties.d.ts +22 -0
- package/js/src/static_dependencies/ethers/utils/properties.js +59 -0
- package/js/src/static_dependencies/ethers/utils/rlp-decode.d.ts +5 -0
- package/js/src/static_dependencies/ethers/utils/rlp-decode.js +84 -0
- package/js/src/static_dependencies/ethers/utils/rlp-encode.d.ts +5 -0
- package/js/src/static_dependencies/ethers/utils/rlp-encode.js +54 -0
- package/js/src/static_dependencies/ethers/utils/rlp.d.ts +16 -0
- package/js/src/static_dependencies/ethers/utils/rlp.js +14 -0
- package/js/src/static_dependencies/ethers/utils/units.d.ts +23 -0
- package/js/src/static_dependencies/ethers/utils/units.js +88 -0
- package/js/src/static_dependencies/ethers/utils/utf8.d.ts +95 -0
- package/js/src/static_dependencies/ethers/utils/utf8.js +225 -0
- package/js/src/static_dependencies/ethers/utils/uuid.d.ts +7 -0
- package/js/src/static_dependencies/ethers/utils/uuid.js +35 -0
- package/js/src/static_dependencies/messagepack/msgpack.d.ts +2 -0
- package/js/src/static_dependencies/messagepack/msgpack.js +572 -0
- package/js/src/tokocrypto.js +22 -2
- package/js/src/wazirx.d.ts +12 -1
- package/js/src/wazirx.js +308 -3
- package/package.json +1 -1
- package/skip-tests.json +18 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* All errors in ethers include properties to ensure they are both
|
|
9
|
+
* human-readable (i.e. ``.message``) and machine-readable (i.e. ``.code``).
|
|
10
|
+
*
|
|
11
|
+
* The [[isError]] function can be used to check the error ``code`` and
|
|
12
|
+
* provide a type guard for the properties present on that error interface.
|
|
13
|
+
*
|
|
14
|
+
* @_section: api/utils/errors:Errors [about-errors]
|
|
15
|
+
*/
|
|
16
|
+
import { defineProperties } from "./properties.js";
|
|
17
|
+
function stringify(value) {
|
|
18
|
+
if (value == null) {
|
|
19
|
+
return "null";
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return "[ " + (value.map(stringify)).join(", ") + " ]";
|
|
23
|
+
}
|
|
24
|
+
if (value instanceof Uint8Array) {
|
|
25
|
+
const HEX = "0123456789abcdef";
|
|
26
|
+
let result = "0x";
|
|
27
|
+
for (let i = 0; i < value.length; i++) {
|
|
28
|
+
result += HEX[value[i] >> 4];
|
|
29
|
+
result += HEX[value[i] & 0xf];
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
if (typeof (value) === "object" && typeof (value.toJSON) === "function") {
|
|
34
|
+
return stringify(value.toJSON());
|
|
35
|
+
}
|
|
36
|
+
switch (typeof (value)) {
|
|
37
|
+
case "boolean":
|
|
38
|
+
case "symbol":
|
|
39
|
+
return value.toString();
|
|
40
|
+
case "bigint":
|
|
41
|
+
return BigInt(value).toString();
|
|
42
|
+
case "number":
|
|
43
|
+
return (value).toString();
|
|
44
|
+
case "string":
|
|
45
|
+
return JSON.stringify(value);
|
|
46
|
+
case "object": {
|
|
47
|
+
const keys = Object.keys(value);
|
|
48
|
+
keys.sort();
|
|
49
|
+
return "{ " + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(", ") + " }";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return `[ COULD NOT SERIALIZE ]`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns true if the %%error%% matches an error thrown by ethers
|
|
56
|
+
* that matches the error %%code%%.
|
|
57
|
+
*
|
|
58
|
+
* In TypeScript environments, this can be used to check that %%error%%
|
|
59
|
+
* matches an EthersError type, which means the expected properties will
|
|
60
|
+
* be set.
|
|
61
|
+
*
|
|
62
|
+
* @See [ErrorCodes](api:ErrorCode)
|
|
63
|
+
* @example
|
|
64
|
+
* try {
|
|
65
|
+
* // code....
|
|
66
|
+
* } catch (e) {
|
|
67
|
+
* if (isError(e, "CALL_EXCEPTION")) {
|
|
68
|
+
* // The Type Guard has validated this object
|
|
69
|
+
* console.log(e.data);
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
*/
|
|
73
|
+
export function isError(error, code) {
|
|
74
|
+
return (error && error.code === code);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns true if %%error%% is a [[CallExceptionError].
|
|
78
|
+
*/
|
|
79
|
+
export function isCallException(error) {
|
|
80
|
+
return isError(error, "CALL_EXCEPTION");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns a new Error configured to the format ethers emits errors, with
|
|
84
|
+
* the %%message%%, [[api:ErrorCode]] %%code%% and additional properties
|
|
85
|
+
* for the corresponding EthersError.
|
|
86
|
+
*
|
|
87
|
+
* Each error in ethers includes the version of ethers, a
|
|
88
|
+
* machine-readable [[ErrorCode]], and depending on %%code%%, additional
|
|
89
|
+
* required properties. The error message will also include the %%message%%,
|
|
90
|
+
* ethers version, %%code%% and all additional properties, serialized.
|
|
91
|
+
*/
|
|
92
|
+
export function makeError(message, code, info) {
|
|
93
|
+
let shortMessage = message;
|
|
94
|
+
{
|
|
95
|
+
const details = [];
|
|
96
|
+
if (info) {
|
|
97
|
+
if ("message" in info || "code" in info || "name" in info) {
|
|
98
|
+
throw new Error(`value will overwrite populated values: ${stringify(info)}`);
|
|
99
|
+
}
|
|
100
|
+
for (const key in info) {
|
|
101
|
+
if (key === "shortMessage") {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const value = (info[key]);
|
|
105
|
+
// try {
|
|
106
|
+
details.push(key + "=" + stringify(value));
|
|
107
|
+
// } catch (error: any) {
|
|
108
|
+
// console.log("MMM", error.message);
|
|
109
|
+
// details.push(key + "=[could not serialize object]");
|
|
110
|
+
// }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
details.push(`code=${code}`);
|
|
114
|
+
if (details.length) {
|
|
115
|
+
message += " (" + details.join(", ") + ")";
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
let error;
|
|
119
|
+
switch (code) {
|
|
120
|
+
case "INVALID_ARGUMENT":
|
|
121
|
+
error = new TypeError(message);
|
|
122
|
+
break;
|
|
123
|
+
case "NUMERIC_FAULT":
|
|
124
|
+
case "BUFFER_OVERRUN":
|
|
125
|
+
error = new RangeError(message);
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
error = new Error(message);
|
|
129
|
+
}
|
|
130
|
+
defineProperties(error, { code });
|
|
131
|
+
if (info) {
|
|
132
|
+
Object.assign(error, info);
|
|
133
|
+
}
|
|
134
|
+
if (error.shortMessage == null) {
|
|
135
|
+
defineProperties(error, { shortMessage });
|
|
136
|
+
}
|
|
137
|
+
return error;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Throws an EthersError with %%message%%, %%code%% and additional error
|
|
141
|
+
* %%info%% when %%check%% is falsish..
|
|
142
|
+
*
|
|
143
|
+
* @see [[api:makeError]]
|
|
144
|
+
*/
|
|
145
|
+
export function assert(check, message, code, info) {
|
|
146
|
+
if (!check) {
|
|
147
|
+
throw makeError(message, code, info);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* A simple helper to simply ensuring provided arguments match expected
|
|
152
|
+
* constraints, throwing if not.
|
|
153
|
+
*
|
|
154
|
+
* In TypeScript environments, the %%check%% has been asserted true, so
|
|
155
|
+
* any further code does not need additional compile-time checks.
|
|
156
|
+
*/
|
|
157
|
+
export function assertArgument(check, message, name, value) {
|
|
158
|
+
assert(check, message, "INVALID_ARGUMENT", { argument: name, value: value });
|
|
159
|
+
}
|
|
160
|
+
export function assertArgumentCount(count, expectedCount, message) {
|
|
161
|
+
if (message == null) {
|
|
162
|
+
message = "";
|
|
163
|
+
}
|
|
164
|
+
if (message) {
|
|
165
|
+
message = ": " + message;
|
|
166
|
+
}
|
|
167
|
+
assert(count >= expectedCount, "missing arguemnt" + message, "MISSING_ARGUMENT", {
|
|
168
|
+
count: count,
|
|
169
|
+
expectedCount: expectedCount
|
|
170
|
+
});
|
|
171
|
+
assert(count <= expectedCount, "too many arguemnts" + message, "UNEXPECTED_ARGUMENT", {
|
|
172
|
+
count: count,
|
|
173
|
+
expectedCount: expectedCount
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
const _normalizeForms = ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
|
|
177
|
+
try {
|
|
178
|
+
// General test for normalize
|
|
179
|
+
/* c8 ignore start */
|
|
180
|
+
if ("test".normalize(form) !== "test") {
|
|
181
|
+
throw new Error("bad");
|
|
182
|
+
}
|
|
183
|
+
;
|
|
184
|
+
/* c8 ignore stop */
|
|
185
|
+
if (form === "NFD") {
|
|
186
|
+
const check = String.fromCharCode(0xe9).normalize("NFD");
|
|
187
|
+
const expected = String.fromCharCode(0x65, 0x0301);
|
|
188
|
+
/* c8 ignore start */
|
|
189
|
+
if (check !== expected) {
|
|
190
|
+
throw new Error("broken");
|
|
191
|
+
}
|
|
192
|
+
/* c8 ignore stop */
|
|
193
|
+
}
|
|
194
|
+
accum.push(form);
|
|
195
|
+
}
|
|
196
|
+
catch (error) { }
|
|
197
|
+
return accum;
|
|
198
|
+
}, []);
|
|
199
|
+
/**
|
|
200
|
+
* Throws if the normalization %%form%% is not supported.
|
|
201
|
+
*/
|
|
202
|
+
export function assertNormalize(form) {
|
|
203
|
+
assert(_normalizeForms.indexOf(form) >= 0, "platform missing String.prototype.normalize", "UNSUPPORTED_OPERATION", {
|
|
204
|
+
operation: "String.prototype.normalize", info: { form }
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Many classes use file-scoped values to guard the constructor,
|
|
209
|
+
* making it effectively private. This facilitates that pattern
|
|
210
|
+
* by ensuring the %%givenGaurd%% matches the file-scoped %%guard%%,
|
|
211
|
+
* throwing if not, indicating the %%className%% if provided.
|
|
212
|
+
*/
|
|
213
|
+
export function assertPrivate(givenGuard, guard, className) {
|
|
214
|
+
if (className == null) {
|
|
215
|
+
className = "";
|
|
216
|
+
}
|
|
217
|
+
if (givenGuard !== guard) {
|
|
218
|
+
let method = className, operation = "new";
|
|
219
|
+
if (className) {
|
|
220
|
+
method += ".";
|
|
221
|
+
operation += " " + className;
|
|
222
|
+
}
|
|
223
|
+
assert(false, `private constructor; use ${method}from* methods`, "UNSUPPORTED_OPERATION", {
|
|
224
|
+
operation
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A callback function called when a an event is triggered.
|
|
3
|
+
*/
|
|
4
|
+
export declare type Listener = (...args: Array<any>) => void;
|
|
5
|
+
/**
|
|
6
|
+
* An **EventEmitterable** behaves similar to an EventEmitter
|
|
7
|
+
* except provides async access to its methods.
|
|
8
|
+
*
|
|
9
|
+
* An EventEmitter implements the observer pattern.
|
|
10
|
+
*/
|
|
11
|
+
export interface EventEmitterable<T> {
|
|
12
|
+
/**
|
|
13
|
+
* Registers a %%listener%% that is called whenever the
|
|
14
|
+
* %%event%% occurs until unregistered.
|
|
15
|
+
*/
|
|
16
|
+
on(event: T, listener: Listener): Promise<this>;
|
|
17
|
+
/**
|
|
18
|
+
* Registers a %%listener%% that is called the next time
|
|
19
|
+
* %%event%% occurs.
|
|
20
|
+
*/
|
|
21
|
+
once(event: T, listener: Listener): Promise<this>;
|
|
22
|
+
/**
|
|
23
|
+
* Triggers each listener for %%event%% with the %%args%%.
|
|
24
|
+
*/
|
|
25
|
+
emit(event: T, ...args: Array<any>): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves to the number of listeners for %%event%%.
|
|
28
|
+
*/
|
|
29
|
+
listenerCount(event?: T): Promise<number>;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves to the listeners for %%event%%.
|
|
32
|
+
*/
|
|
33
|
+
listeners(event?: T): Promise<Array<Listener>>;
|
|
34
|
+
/**
|
|
35
|
+
* Unregister the %%listener%% for %%event%%. If %%listener%%
|
|
36
|
+
* is unspecified, all listeners are unregistered.
|
|
37
|
+
*/
|
|
38
|
+
off(event: T, listener?: Listener): Promise<this>;
|
|
39
|
+
/**
|
|
40
|
+
* Unregister all listeners for %%event%%.
|
|
41
|
+
*/
|
|
42
|
+
removeAllListeners(event?: T): Promise<this>;
|
|
43
|
+
/**
|
|
44
|
+
* Alias for [[on]].
|
|
45
|
+
*/
|
|
46
|
+
addListener(event: T, listener: Listener): Promise<this>;
|
|
47
|
+
/**
|
|
48
|
+
* Alias for [[off]].
|
|
49
|
+
*/
|
|
50
|
+
removeListener(event: T, listener: Listener): Promise<this>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* When an [[EventEmitterable]] triggers a [[Listener]], the
|
|
54
|
+
* callback always ahas one additional argument passed, which is
|
|
55
|
+
* an **EventPayload**.
|
|
56
|
+
*/
|
|
57
|
+
export declare class EventPayload<T> {
|
|
58
|
+
#private;
|
|
59
|
+
/**
|
|
60
|
+
* The event filter.
|
|
61
|
+
*/
|
|
62
|
+
readonly filter: T;
|
|
63
|
+
/**
|
|
64
|
+
* The **EventEmitterable**.
|
|
65
|
+
*/
|
|
66
|
+
readonly emitter: EventEmitterable<T>;
|
|
67
|
+
/**
|
|
68
|
+
* Create a new **EventPayload** for %%emitter%% with
|
|
69
|
+
* the %%listener%% and for %%filter%%.
|
|
70
|
+
*/
|
|
71
|
+
constructor(emitter: EventEmitterable<T>, listener: null | Listener, filter: T);
|
|
72
|
+
/**
|
|
73
|
+
* Unregister the triggered listener for future events.
|
|
74
|
+
*/
|
|
75
|
+
removeListener(): Promise<void>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
+
};
|
|
13
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
14
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
15
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
16
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
17
|
+
};
|
|
18
|
+
var _EventPayload_listener;
|
|
19
|
+
/**
|
|
20
|
+
* Events allow for applications to use the observer pattern, which
|
|
21
|
+
* allows subscribing and publishing events, outside the normal
|
|
22
|
+
* execution paths.
|
|
23
|
+
*
|
|
24
|
+
* @_section api/utils/events:Events [about-events]
|
|
25
|
+
*/
|
|
26
|
+
import { defineProperties } from "./properties.js";
|
|
27
|
+
/**
|
|
28
|
+
* When an [[EventEmitterable]] triggers a [[Listener]], the
|
|
29
|
+
* callback always ahas one additional argument passed, which is
|
|
30
|
+
* an **EventPayload**.
|
|
31
|
+
*/
|
|
32
|
+
export class EventPayload {
|
|
33
|
+
/**
|
|
34
|
+
* Create a new **EventPayload** for %%emitter%% with
|
|
35
|
+
* the %%listener%% and for %%filter%%.
|
|
36
|
+
*/
|
|
37
|
+
constructor(emitter, listener, filter) {
|
|
38
|
+
_EventPayload_listener.set(this, void 0);
|
|
39
|
+
__classPrivateFieldSet(this, _EventPayload_listener, listener, "f");
|
|
40
|
+
defineProperties(this, { emitter, filter });
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Unregister the triggered listener for future events.
|
|
44
|
+
*/
|
|
45
|
+
async removeListener() {
|
|
46
|
+
if (__classPrivateFieldGet(this, _EventPayload_listener, "f") == null) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
await this.emitter.off(this.filter, __classPrivateFieldGet(this, _EventPayload_listener, "f"));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
_EventPayload_listener = new WeakMap();
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import type { BigNumberish, BytesLike, Numeric } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A description of a fixed-point arithmetic field.
|
|
4
|
+
*
|
|
5
|
+
* When specifying the fixed format, the values override the default of
|
|
6
|
+
* a ``fixed128x18``, which implies a signed 128-bit value with 18
|
|
7
|
+
* decimals of precision.
|
|
8
|
+
*
|
|
9
|
+
* The alias ``fixed`` and ``ufixed`` can be used for ``fixed128x18`` and
|
|
10
|
+
* ``ufixed128x18`` respectively.
|
|
11
|
+
*
|
|
12
|
+
* When a fixed format string begins with a ``u``, it indicates the field
|
|
13
|
+
* is unsigned, so any negative values will overflow. The first number
|
|
14
|
+
* indicates the bit-width and the second number indicates the decimal
|
|
15
|
+
* precision.
|
|
16
|
+
*
|
|
17
|
+
* When a ``number`` is used for a fixed format, it indicates the number
|
|
18
|
+
* of decimal places, and the default width and signed-ness will be used.
|
|
19
|
+
*
|
|
20
|
+
* The bit-width must be byte aligned and the decimals can be at most 80.
|
|
21
|
+
*/
|
|
22
|
+
export declare type FixedFormat = number | string | {
|
|
23
|
+
signed?: boolean;
|
|
24
|
+
width?: number;
|
|
25
|
+
decimals?: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A FixedNumber represents a value over its [[FixedFormat]]
|
|
29
|
+
* arithmetic field.
|
|
30
|
+
*
|
|
31
|
+
* A FixedNumber can be used to perform math, losslessly, on
|
|
32
|
+
* values which have decmial places.
|
|
33
|
+
*
|
|
34
|
+
* A FixedNumber has a fixed bit-width to store values in, and stores all
|
|
35
|
+
* values internally by multiplying the value by 10 raised to the power of
|
|
36
|
+
* %%decimals%%.
|
|
37
|
+
*
|
|
38
|
+
* If operations are performed that cause a value to grow too high (close to
|
|
39
|
+
* positive infinity) or too low (close to negative infinity), the value
|
|
40
|
+
* is said to //overflow//.
|
|
41
|
+
*
|
|
42
|
+
* For example, an 8-bit signed value, with 0 decimals may only be within
|
|
43
|
+
* the range ``-128`` to ``127``; so ``-128 - 1`` will overflow and become
|
|
44
|
+
* ``127``. Likewise, ``127 + 1`` will overflow and become ``-127``.
|
|
45
|
+
*
|
|
46
|
+
* Many operation have a normal and //unsafe// variant. The normal variant
|
|
47
|
+
* will throw a [[NumericFaultError]] on any overflow, while the //unsafe//
|
|
48
|
+
* variant will silently allow overflow, corrupting its value value.
|
|
49
|
+
*
|
|
50
|
+
* If operations are performed that cause a value to become too small
|
|
51
|
+
* (close to zero), the value loses precison and is said to //underflow//.
|
|
52
|
+
*
|
|
53
|
+
* For example, an value with 1 decimal place may store a number as small
|
|
54
|
+
* as ``0.1``, but the value of ``0.1 / 2`` is ``0.05``, which cannot fit
|
|
55
|
+
* into 1 decimal place, so underflow occurs which means precision is lost
|
|
56
|
+
* and the value becomes ``0``.
|
|
57
|
+
*
|
|
58
|
+
* Some operations have a normal and //signalling// variant. The normal
|
|
59
|
+
* variant will silently ignore underflow, while the //signalling// variant
|
|
60
|
+
* will thow a [[NumericFaultError]] on underflow.
|
|
61
|
+
*/
|
|
62
|
+
export declare class FixedNumber {
|
|
63
|
+
#private;
|
|
64
|
+
/**
|
|
65
|
+
* The specific fixed-point arithmetic field for this value.
|
|
66
|
+
*/
|
|
67
|
+
readonly format: string;
|
|
68
|
+
/**
|
|
69
|
+
* This is a property so console.log shows a human-meaningful value.
|
|
70
|
+
*
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
73
|
+
readonly _value: string;
|
|
74
|
+
/**
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
constructor(guard: any, value: bigint, format: any);
|
|
78
|
+
/**
|
|
79
|
+
* If true, negative values are permitted, otherwise only
|
|
80
|
+
* positive values and zero are allowed.
|
|
81
|
+
*/
|
|
82
|
+
get signed(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* The number of bits available to store the value.
|
|
85
|
+
*/
|
|
86
|
+
get width(): number;
|
|
87
|
+
/**
|
|
88
|
+
* The number of decimal places in the fixed-point arithment field.
|
|
89
|
+
*/
|
|
90
|
+
get decimals(): number;
|
|
91
|
+
/**
|
|
92
|
+
* The value as an integer, based on the smallest unit the
|
|
93
|
+
* [[decimals]] allow.
|
|
94
|
+
*/
|
|
95
|
+
get value(): bigint;
|
|
96
|
+
/**
|
|
97
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% added
|
|
98
|
+
* to %%other%%, ignoring overflow.
|
|
99
|
+
*/
|
|
100
|
+
addUnsafe(other: FixedNumber): FixedNumber;
|
|
101
|
+
/**
|
|
102
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% added
|
|
103
|
+
* to %%other%%. A [[NumericFaultError]] is thrown if overflow
|
|
104
|
+
* occurs.
|
|
105
|
+
*/
|
|
106
|
+
add(other: FixedNumber): FixedNumber;
|
|
107
|
+
/**
|
|
108
|
+
* Returns a new [[FixedNumber]] with the result of %%other%% subtracted
|
|
109
|
+
* from %%this%%, ignoring overflow.
|
|
110
|
+
*/
|
|
111
|
+
subUnsafe(other: FixedNumber): FixedNumber;
|
|
112
|
+
/**
|
|
113
|
+
* Returns a new [[FixedNumber]] with the result of %%other%% subtracted
|
|
114
|
+
* from %%this%%. A [[NumericFaultError]] is thrown if overflow
|
|
115
|
+
* occurs.
|
|
116
|
+
*/
|
|
117
|
+
sub(other: FixedNumber): FixedNumber;
|
|
118
|
+
/**
|
|
119
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
|
120
|
+
* by %%other%%, ignoring overflow and underflow (precision loss).
|
|
121
|
+
*/
|
|
122
|
+
mulUnsafe(other: FixedNumber): FixedNumber;
|
|
123
|
+
/**
|
|
124
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
|
125
|
+
* by %%other%%. A [[NumericFaultError]] is thrown if overflow
|
|
126
|
+
* occurs.
|
|
127
|
+
*/
|
|
128
|
+
mul(other: FixedNumber): FixedNumber;
|
|
129
|
+
/**
|
|
130
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
|
131
|
+
* by %%other%%. A [[NumericFaultError]] is thrown if overflow
|
|
132
|
+
* occurs or if underflow (precision loss) occurs.
|
|
133
|
+
*/
|
|
134
|
+
mulSignal(other: FixedNumber): FixedNumber;
|
|
135
|
+
/**
|
|
136
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% divided
|
|
137
|
+
* by %%other%%, ignoring underflow (precision loss). A
|
|
138
|
+
* [[NumericFaultError]] is thrown if overflow occurs.
|
|
139
|
+
*/
|
|
140
|
+
divUnsafe(other: FixedNumber): FixedNumber;
|
|
141
|
+
/**
|
|
142
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% divided
|
|
143
|
+
* by %%other%%, ignoring underflow (precision loss). A
|
|
144
|
+
* [[NumericFaultError]] is thrown if overflow occurs.
|
|
145
|
+
*/
|
|
146
|
+
div(other: FixedNumber): FixedNumber;
|
|
147
|
+
/**
|
|
148
|
+
* Returns a new [[FixedNumber]] with the result of %%this%% divided
|
|
149
|
+
* by %%other%%. A [[NumericFaultError]] is thrown if underflow
|
|
150
|
+
* (precision loss) occurs.
|
|
151
|
+
*/
|
|
152
|
+
divSignal(other: FixedNumber): FixedNumber;
|
|
153
|
+
/**
|
|
154
|
+
* Returns a comparison result between %%this%% and %%other%%.
|
|
155
|
+
*
|
|
156
|
+
* This is suitable for use in sorting, where ``-1`` implies %%this%%
|
|
157
|
+
* is smaller, ``1`` implies %%this%% is larger and ``0`` implies
|
|
158
|
+
* both are equal.
|
|
159
|
+
*/
|
|
160
|
+
cmp(other: FixedNumber): number;
|
|
161
|
+
/**
|
|
162
|
+
* Returns true if %%other%% is equal to %%this%%.
|
|
163
|
+
*/
|
|
164
|
+
eq(other: FixedNumber): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Returns true if %%other%% is less than to %%this%%.
|
|
167
|
+
*/
|
|
168
|
+
lt(other: FixedNumber): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Returns true if %%other%% is less than or equal to %%this%%.
|
|
171
|
+
*/
|
|
172
|
+
lte(other: FixedNumber): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Returns true if %%other%% is greater than to %%this%%.
|
|
175
|
+
*/
|
|
176
|
+
gt(other: FixedNumber): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Returns true if %%other%% is greater than or equal to %%this%%.
|
|
179
|
+
*/
|
|
180
|
+
gte(other: FixedNumber): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Returns a new [[FixedNumber]] which is the largest **integer**
|
|
183
|
+
* that is less than or equal to %%this%%.
|
|
184
|
+
*
|
|
185
|
+
* The decimal component of the result will always be ``0``.
|
|
186
|
+
*/
|
|
187
|
+
floor(): FixedNumber;
|
|
188
|
+
/**
|
|
189
|
+
* Returns a new [[FixedNumber]] which is the smallest **integer**
|
|
190
|
+
* that is greater than or equal to %%this%%.
|
|
191
|
+
*
|
|
192
|
+
* The decimal component of the result will always be ``0``.
|
|
193
|
+
*/
|
|
194
|
+
ceiling(): FixedNumber;
|
|
195
|
+
/**
|
|
196
|
+
* Returns a new [[FixedNumber]] with the decimal component
|
|
197
|
+
* rounded up on ties at %%decimals%% places.
|
|
198
|
+
*/
|
|
199
|
+
round(decimals?: number): FixedNumber;
|
|
200
|
+
/**
|
|
201
|
+
* Returns true if %%this%% is equal to ``0``.
|
|
202
|
+
*/
|
|
203
|
+
isZero(): boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Returns true if %%this%% is less than ``0``.
|
|
206
|
+
*/
|
|
207
|
+
isNegative(): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Returns the string representation of %%this%%.
|
|
210
|
+
*/
|
|
211
|
+
toString(): string;
|
|
212
|
+
/**
|
|
213
|
+
* Returns a float approximation.
|
|
214
|
+
*
|
|
215
|
+
* Due to IEEE 754 precission (or lack thereof), this function
|
|
216
|
+
* can only return an approximation and most values will contain
|
|
217
|
+
* rounding errors.
|
|
218
|
+
*/
|
|
219
|
+
toUnsafeFloat(): number;
|
|
220
|
+
/**
|
|
221
|
+
* Return a new [[FixedNumber]] with the same value but has had
|
|
222
|
+
* its field set to %%format%%.
|
|
223
|
+
*
|
|
224
|
+
* This will throw if the value cannot fit into %%format%%.
|
|
225
|
+
*/
|
|
226
|
+
toFormat(format: FixedFormat): FixedNumber;
|
|
227
|
+
/**
|
|
228
|
+
* Creates a new [[FixedNumber]] for %%value%% divided by
|
|
229
|
+
* %%decimal%% places with %%format%%.
|
|
230
|
+
*
|
|
231
|
+
* This will throw a [[NumericFaultError]] if %%value%% (once adjusted
|
|
232
|
+
* for %%decimals%%) cannot fit in %%format%%, either due to overflow
|
|
233
|
+
* or underflow (precision loss).
|
|
234
|
+
*/
|
|
235
|
+
static fromValue(_value: BigNumberish, _decimals?: Numeric, _format?: FixedFormat): FixedNumber;
|
|
236
|
+
/**
|
|
237
|
+
* Creates a new [[FixedNumber]] for %%value%% with %%format%%.
|
|
238
|
+
*
|
|
239
|
+
* This will throw a [[NumericFaultError]] if %%value%% cannot fit
|
|
240
|
+
* in %%format%%, either due to overflow or underflow (precision loss).
|
|
241
|
+
*/
|
|
242
|
+
static fromString(_value: string, _format?: FixedFormat): FixedNumber;
|
|
243
|
+
/**
|
|
244
|
+
* Creates a new [[FixedNumber]] with the big-endian representation
|
|
245
|
+
* %%value%% with %%format%%.
|
|
246
|
+
*
|
|
247
|
+
* This will throw a [[NumericFaultError]] if %%value%% cannot fit
|
|
248
|
+
* in %%format%% due to overflow.
|
|
249
|
+
*/
|
|
250
|
+
static fromBytes(_value: BytesLike, _format?: FixedFormat): FixedNumber;
|
|
251
|
+
}
|