ccxt 4.5.40 → 4.5.42
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/dist/ccxt.browser.min.js +18 -18
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/abstract/lighter.js +11 -0
- package/dist/cjs/src/ascendex.js +73 -1
- package/dist/cjs/src/base/Exchange.js +149 -17
- package/dist/cjs/src/base/functions/generic.js +1 -0
- package/dist/cjs/src/base/functions/io.js +160 -0
- package/dist/cjs/src/base/functions.js +6 -0
- package/dist/cjs/src/base/ws/Client.js +1 -0
- package/dist/cjs/src/base/ws/WsClient.js +1 -0
- package/dist/cjs/src/binance.js +1 -0
- package/dist/cjs/src/bingx.js +13 -3
- package/dist/cjs/src/bitmex.js +20 -0
- package/dist/cjs/src/blofin.js +2 -2
- package/dist/cjs/src/bybit.js +1 -1
- package/dist/cjs/src/coinspot.js +7 -2
- package/dist/cjs/src/delta.js +1 -1
- package/dist/cjs/src/gate.js +11 -4
- package/dist/cjs/src/gemini.js +76 -1
- package/dist/cjs/src/htx.js +2 -2
- package/dist/cjs/src/hyperliquid.js +20 -7
- package/dist/cjs/src/independentreserve.js +7 -7
- package/dist/cjs/src/kraken.js +1 -1
- package/dist/cjs/src/krakenfutures.js +96 -5
- package/dist/cjs/src/kucoin.js +3 -3
- package/dist/cjs/src/kucoinfutures.js +1 -1
- package/dist/cjs/src/lighter.js +2931 -0
- package/dist/cjs/src/mexc.js +0 -1
- package/dist/cjs/src/phemex.js +1 -1
- package/dist/cjs/src/pro/binance.js +2 -2
- package/dist/cjs/src/pro/bingx.js +215 -2
- package/dist/cjs/src/pro/bitget.js +1 -0
- package/dist/cjs/src/pro/defx.js +1 -1
- package/dist/cjs/src/pro/kucoinfutures.js +1 -1
- package/dist/cjs/src/pro/lighter.js +787 -0
- package/dist/cjs/src/pro/mexc.js +1 -1
- package/dist/cjs/src/pro/paradex.js +1 -1
- package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/address/address.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/address.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/array.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/number.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/fragments.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/index.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/interface.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/typed.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/index.js +1 -0
- package/dist/cjs/src/whitebit.js +118 -16
- package/dist/cjs/src/woo.js +1 -1
- package/js/ccxt.d.ts +8 -2
- package/js/ccxt.js +6 -2
- package/js/src/abstract/gemini.d.ts +27 -0
- package/js/src/abstract/lighter.d.ts +53 -0
- package/js/src/abstract/lighter.js +11 -0
- package/js/src/ascendex.d.ts +12 -1
- package/js/src/ascendex.js +73 -1
- package/js/src/base/Exchange.d.ts +18 -6
- package/js/src/base/Exchange.js +154 -21
- package/js/src/base/functions/generic.js +1 -0
- package/js/src/base/functions/io.d.ts +32 -0
- package/js/src/base/functions/io.js +137 -0
- package/js/src/base/functions.d.ts +1 -0
- package/js/src/base/functions.js +1 -0
- package/js/src/binance.d.ts +1 -0
- package/js/src/binance.js +1 -0
- package/js/src/bingx.js +13 -3
- package/js/src/bitmex.js +20 -0
- package/js/src/blofin.js +2 -2
- package/js/src/bybit.js +1 -1
- package/js/src/coinspot.js +7 -2
- package/js/src/delta.js +1 -1
- package/js/src/gate.d.ts +1 -0
- package/js/src/gate.js +11 -4
- package/js/src/gemini.d.ts +11 -0
- package/js/src/gemini.js +76 -1
- package/js/src/htx.js +2 -2
- package/js/src/hyperliquid.js +20 -7
- package/js/src/independentreserve.js +7 -7
- package/js/src/kraken.js +1 -1
- package/js/src/krakenfutures.d.ts +1 -1
- package/js/src/krakenfutures.js +96 -5
- package/js/src/kucoin.d.ts +3 -3
- package/js/src/kucoin.js +3 -3
- package/js/src/kucoinfutures.js +1 -1
- package/js/src/lighter.d.ts +424 -0
- package/js/src/lighter.js +2930 -0
- package/js/src/mexc.js +0 -1
- package/js/src/phemex.js +1 -1
- package/js/src/pro/binance.js +2 -2
- package/js/src/pro/bingx.d.ts +17 -1
- package/js/src/pro/bingx.js +216 -3
- package/js/src/pro/bitget.js +1 -0
- package/js/src/pro/defx.js +1 -1
- package/js/src/pro/kucoinfutures.js +1 -1
- package/js/src/pro/lighter.d.ts +161 -0
- package/js/src/pro/lighter.js +786 -0
- package/js/src/pro/mexc.js +1 -1
- package/js/src/pro/paradex.js +1 -1
- package/js/src/whitebit.d.ts +2 -1
- package/js/src/whitebit.js +118 -16
- package/js/src/woo.js +1 -1
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -89,6 +89,7 @@ var kucoin = require('./src/kucoin.js');
|
|
|
89
89
|
var kucoinfutures = require('./src/kucoinfutures.js');
|
|
90
90
|
var latoken = require('./src/latoken.js');
|
|
91
91
|
var lbank = require('./src/lbank.js');
|
|
92
|
+
var lighter = require('./src/lighter.js');
|
|
92
93
|
var luno = require('./src/luno.js');
|
|
93
94
|
var mercado = require('./src/mercado.js');
|
|
94
95
|
var mexc = require('./src/mexc.js');
|
|
@@ -176,6 +177,7 @@ var krakenfutures$1 = require('./src/pro/krakenfutures.js');
|
|
|
176
177
|
var kucoin$1 = require('./src/pro/kucoin.js');
|
|
177
178
|
var kucoinfutures$1 = require('./src/pro/kucoinfutures.js');
|
|
178
179
|
var lbank$1 = require('./src/pro/lbank.js');
|
|
180
|
+
var lighter$1 = require('./src/pro/lighter.js');
|
|
179
181
|
var luno$1 = require('./src/pro/luno.js');
|
|
180
182
|
var mexc$1 = require('./src/pro/mexc.js');
|
|
181
183
|
var modetrade$1 = require('./src/pro/modetrade.js');
|
|
@@ -198,7 +200,7 @@ var xt$1 = require('./src/pro/xt.js');
|
|
|
198
200
|
|
|
199
201
|
//-----------------------------------------------------------------------------
|
|
200
202
|
// this is updated by vss.js when building
|
|
201
|
-
const version = '4.5.
|
|
203
|
+
const version = '4.5.42';
|
|
202
204
|
Exchange["default"].ccxtVersion = version;
|
|
203
205
|
const exchanges = {
|
|
204
206
|
'alp': alp["default"],
|
|
@@ -282,6 +284,7 @@ const exchanges = {
|
|
|
282
284
|
'kucoinfutures': kucoinfutures["default"],
|
|
283
285
|
'latoken': latoken["default"],
|
|
284
286
|
'lbank': lbank["default"],
|
|
287
|
+
'lighter': lighter["default"],
|
|
285
288
|
'luno': luno["default"],
|
|
286
289
|
'mercado': mercado["default"],
|
|
287
290
|
'mexc': mexc["default"],
|
|
@@ -371,6 +374,7 @@ const pro = {
|
|
|
371
374
|
'kucoin': kucoin$1["default"],
|
|
372
375
|
'kucoinfutures': kucoinfutures$1["default"],
|
|
373
376
|
'lbank': lbank$1["default"],
|
|
377
|
+
'lighter': lighter$1["default"],
|
|
374
378
|
'luno': luno$1["default"],
|
|
375
379
|
'mexc': mexc$1["default"],
|
|
376
380
|
'modetrade': modetrade$1["default"],
|
|
@@ -523,6 +527,7 @@ exports.kucoin = kucoin["default"];
|
|
|
523
527
|
exports.kucoinfutures = kucoinfutures["default"];
|
|
524
528
|
exports.latoken = latoken["default"];
|
|
525
529
|
exports.lbank = lbank["default"];
|
|
530
|
+
exports.lighter = lighter["default"];
|
|
526
531
|
exports.luno = luno["default"];
|
|
527
532
|
exports.mercado = mercado["default"];
|
|
528
533
|
exports.mexc = mexc["default"];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Exchange$1 = require('../base/Exchange.js');
|
|
6
|
+
|
|
7
|
+
// ----------------------------------------------------------------------------
|
|
8
|
+
class Exchange extends Exchange$1["default"] {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports["default"] = Exchange;
|
package/dist/cjs/src/ascendex.js
CHANGED
|
@@ -78,8 +78,9 @@ class ascendex extends ascendex$1["default"] {
|
|
|
78
78
|
'fetchMarkOHLCV': false,
|
|
79
79
|
'fetchMySettlementHistory': false,
|
|
80
80
|
'fetchOHLCV': true,
|
|
81
|
-
'fetchOpenInterest':
|
|
81
|
+
'fetchOpenInterest': 'emulated',
|
|
82
82
|
'fetchOpenInterestHistory': false,
|
|
83
|
+
'fetchOpenInterests': true,
|
|
83
84
|
'fetchOpenOrders': true,
|
|
84
85
|
'fetchOption': false,
|
|
85
86
|
'fetchOptionChain': false,
|
|
@@ -3601,6 +3602,77 @@ class ascendex extends ascendex$1["default"] {
|
|
|
3601
3602
|
const leverages = this.safeList(data, 'contracts', []);
|
|
3602
3603
|
return this.parseLeverages(leverages, symbols, 'symbol');
|
|
3603
3604
|
}
|
|
3605
|
+
/**
|
|
3606
|
+
* @method
|
|
3607
|
+
* @name ascendex#fetchOpenInterests
|
|
3608
|
+
* @description Retrieves the open interest for a list of symbols
|
|
3609
|
+
* @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#futures-pricing-data
|
|
3610
|
+
* @param {string[]} [symbols] a list of unified CCXT market symbols
|
|
3611
|
+
* @param {object} [params] exchange specific parameters
|
|
3612
|
+
* @returns {object[]} a list of [open interest structures]{@link https://docs.ccxt.com/?id=open-interest-structure}
|
|
3613
|
+
*/
|
|
3614
|
+
async fetchOpenInterests(symbols = undefined, params = {}) {
|
|
3615
|
+
await this.loadMarkets();
|
|
3616
|
+
const request = {};
|
|
3617
|
+
let response = undefined;
|
|
3618
|
+
response = await this.v2PublicGetFuturesPricingData(this.extend(request, params));
|
|
3619
|
+
//
|
|
3620
|
+
// {
|
|
3621
|
+
// code: '0',
|
|
3622
|
+
// data: {
|
|
3623
|
+
// contracts: [
|
|
3624
|
+
// {
|
|
3625
|
+
// time: '1772138885616',
|
|
3626
|
+
// symbol: 'ZIL-PERP',
|
|
3627
|
+
// markPrice: '0.004167783',
|
|
3628
|
+
// indexPrice: '0.004168',
|
|
3629
|
+
// lastPrice: '0.00416',
|
|
3630
|
+
// openInterest: '7685003',
|
|
3631
|
+
// fundingRate: '0.0003',
|
|
3632
|
+
// nextFundingTime: '1772139600000'
|
|
3633
|
+
// },
|
|
3634
|
+
// ]
|
|
3635
|
+
// collaterals: [
|
|
3636
|
+
// { asset: 'TAO', referencePrice: '182.15' },
|
|
3637
|
+
// ...
|
|
3638
|
+
// ]
|
|
3639
|
+
// }
|
|
3640
|
+
// }
|
|
3641
|
+
//
|
|
3642
|
+
symbols = this.marketSymbols(symbols);
|
|
3643
|
+
const data = this.safeDict(response, 'data', {});
|
|
3644
|
+
const contracts = this.safeList(data, 'contracts', []);
|
|
3645
|
+
return this.parseOpenInterests(contracts, symbols);
|
|
3646
|
+
}
|
|
3647
|
+
parseOpenInterest(interest, market = undefined) {
|
|
3648
|
+
//
|
|
3649
|
+
// fetchOpenInterests
|
|
3650
|
+
//
|
|
3651
|
+
// {
|
|
3652
|
+
// time: '1772138885616',
|
|
3653
|
+
// symbol: 'ZIL-PERP',
|
|
3654
|
+
// markPrice: '0.004167783',
|
|
3655
|
+
// indexPrice: '0.004168',
|
|
3656
|
+
// lastPrice: '0.00416',
|
|
3657
|
+
// openInterest: '7685003',
|
|
3658
|
+
// fundingRate: '0.0003',
|
|
3659
|
+
// nextFundingTime: '1772139600000'
|
|
3660
|
+
// }
|
|
3661
|
+
//
|
|
3662
|
+
const marketId = this.safeString(interest, 'symbol');
|
|
3663
|
+
const timestamp = this.safeInteger(interest, 'time');
|
|
3664
|
+
const openInterest = this.safeNumber(interest, 'openInterest');
|
|
3665
|
+
return this.safeOpenInterest({
|
|
3666
|
+
'info': interest,
|
|
3667
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
3668
|
+
'baseVolume': openInterest,
|
|
3669
|
+
'quoteVolume': undefined,
|
|
3670
|
+
'openInterestAmount': openInterest,
|
|
3671
|
+
'openInterestValue': undefined,
|
|
3672
|
+
'timestamp': timestamp,
|
|
3673
|
+
'datetime': this.iso8601(timestamp),
|
|
3674
|
+
}, market);
|
|
3675
|
+
}
|
|
3604
3676
|
parseLeverage(leverage, market = undefined) {
|
|
3605
3677
|
const marketId = this.safeString(leverage, 'symbol');
|
|
3606
3678
|
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
@@ -33,8 +33,8 @@ var typedData$1 = require('../static_dependencies/starknet/utils/typedData.js');
|
|
|
33
33
|
var sha1 = require('../static_dependencies/noble-hashes/sha1.js');
|
|
34
34
|
var onboarding = require('../static_dependencies/dydx-v4-client/onboarding.js');
|
|
35
35
|
require('../static_dependencies/dydx-v4-client/helpers.js');
|
|
36
|
-
var misc = require('./functions/misc.js');
|
|
37
36
|
var index$3 = require('../static_dependencies/dydx-v4-client/long/index.cjs.js');
|
|
37
|
+
var io = require('./functions/io.js');
|
|
38
38
|
|
|
39
39
|
function _interopNamespace(e) {
|
|
40
40
|
if (e && e.__esModule) return e;
|
|
@@ -55,9 +55,9 @@ function _interopNamespace(e) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// ----------------------------------------------------------------------------
|
|
58
|
-
const { isNode, selfIsDefined, deepExtend, extend, clone,
|
|
58
|
+
const { isNode, selfIsDefined, deepExtend, extend, clone, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, binaryConcat, hash,
|
|
59
59
|
// ecdsa,
|
|
60
|
-
arrayConcat, encode, urlencode, hmac, numberToString, roundTimeframe, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray,
|
|
60
|
+
arrayConcat, encode, urlencode, hmac, numberToString, roundTimeframe, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, sort, inArray, isEmpty, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep, readFile, writeFile, existsFile, getTempDir, } = functions;
|
|
61
61
|
// ----------------------------------------------------------------------------
|
|
62
62
|
let protobufMexc = undefined;
|
|
63
63
|
let encodeAsAny = undefined;
|
|
@@ -67,14 +67,6 @@ let TxBody = undefined;
|
|
|
67
67
|
let TxRaw = undefined;
|
|
68
68
|
let SignDoc = undefined;
|
|
69
69
|
let SignMode = undefined;
|
|
70
|
-
(async () => {
|
|
71
|
-
try {
|
|
72
|
-
protobufMexc = await Promise.resolve().then(function () { return require('../protobuf/mexc/compiled.cjs.js'); });
|
|
73
|
-
}
|
|
74
|
-
catch (e) {
|
|
75
|
-
// TODO: handle error
|
|
76
|
-
}
|
|
77
|
-
})();
|
|
78
70
|
// -----------------------------------------------------------------------------
|
|
79
71
|
/**
|
|
80
72
|
* @class Exchange
|
|
@@ -192,7 +184,6 @@ class Exchange {
|
|
|
192
184
|
this.isNode = isNode;
|
|
193
185
|
this.extend = extend;
|
|
194
186
|
this.clone = clone;
|
|
195
|
-
this.flatten = flatten;
|
|
196
187
|
this.unique = unique;
|
|
197
188
|
this.indexBy = indexBy;
|
|
198
189
|
this.indexBySafe = indexBy;
|
|
@@ -227,8 +218,6 @@ class Exchange {
|
|
|
227
218
|
this.implodeParams = implodeParams;
|
|
228
219
|
this.extractParams = extractParams;
|
|
229
220
|
this.json = json;
|
|
230
|
-
this.vwap = misc.vwap;
|
|
231
|
-
this.merge = merge;
|
|
232
221
|
this.binaryConcat = binaryConcat;
|
|
233
222
|
this.hash = hash;
|
|
234
223
|
this.arrayConcat = arrayConcat;
|
|
@@ -244,8 +233,6 @@ class Exchange {
|
|
|
244
233
|
this.safeStringUpper = safeStringUpper;
|
|
245
234
|
this.safeTimestamp = safeTimestamp;
|
|
246
235
|
this.binaryConcatArray = binaryConcatArray;
|
|
247
|
-
this.uuidv1 = uuidv1;
|
|
248
|
-
this.numberToLE = numberToLE;
|
|
249
236
|
this.ymdhms = ymdhms;
|
|
250
237
|
this.yymmdd = yymmdd;
|
|
251
238
|
this.stringToBase64 = stringToBase64;
|
|
@@ -264,7 +251,6 @@ class Exchange {
|
|
|
264
251
|
this.safeStringLower2 = safeStringLower2;
|
|
265
252
|
this.safeStringUpper2 = safeStringUpper2;
|
|
266
253
|
this.isEmpty = isEmpty;
|
|
267
|
-
this.ordered = ordered;
|
|
268
254
|
this.filterBy = filterBy;
|
|
269
255
|
this.uuid16 = uuid16;
|
|
270
256
|
this.urlencodeWithArrayRepeat = urlencodeWithArrayRepeat;
|
|
@@ -287,6 +273,11 @@ class Exchange {
|
|
|
287
273
|
this.crc32 = crc32;
|
|
288
274
|
this.packb = packb;
|
|
289
275
|
this.urlencodeBase64 = urlencodeBase64;
|
|
276
|
+
// io
|
|
277
|
+
this.readFile = readFile;
|
|
278
|
+
this.writeFile = writeFile;
|
|
279
|
+
this.existsFile = existsFile;
|
|
280
|
+
this.getTempDir = getTempDir;
|
|
290
281
|
Object.assign(this, functions);
|
|
291
282
|
//
|
|
292
283
|
// if (isNode) {
|
|
@@ -396,6 +387,18 @@ class Exchange {
|
|
|
396
387
|
if (this.safeBool(userConfig, 'sandbox') || this.safeBool(userConfig, 'testnet')) {
|
|
397
388
|
this.setSandboxMode(true);
|
|
398
389
|
}
|
|
390
|
+
// exchange specific libs
|
|
391
|
+
this.loadExchangeSpecificFiles();
|
|
392
|
+
}
|
|
393
|
+
async loadExchangeSpecificFiles() {
|
|
394
|
+
if (this.id === 'mexc') {
|
|
395
|
+
try {
|
|
396
|
+
protobufMexc = await Promise.resolve().then(function () { return require('../protobuf/mexc/compiled.cjs.js'); });
|
|
397
|
+
}
|
|
398
|
+
catch (e) {
|
|
399
|
+
// TODO: handle error
|
|
400
|
+
}
|
|
401
|
+
}
|
|
399
402
|
}
|
|
400
403
|
uuid5(namespace, name) {
|
|
401
404
|
const nsBytes = namespace
|
|
@@ -695,6 +698,29 @@ class Exchange {
|
|
|
695
698
|
}
|
|
696
699
|
// set final headers
|
|
697
700
|
headers = this.setHeaders(headers);
|
|
701
|
+
// multipart/form-data
|
|
702
|
+
const headersKeys = Object.keys(headers);
|
|
703
|
+
for (let i = 0; i < headersKeys.length; i++) {
|
|
704
|
+
const key = headersKeys[i];
|
|
705
|
+
if (key.toLowerCase() === 'content-type') {
|
|
706
|
+
let value = headers[key];
|
|
707
|
+
if (value === 'multipart/form-data') {
|
|
708
|
+
const bodyKeys = Object.keys(body);
|
|
709
|
+
const boundary = '--------------------------' + this.randomBytes(12);
|
|
710
|
+
const eol = '\r\n';
|
|
711
|
+
let newBody = '';
|
|
712
|
+
for (let j = 0; j < bodyKeys.length; j++) {
|
|
713
|
+
const bodyKey = bodyKeys[j];
|
|
714
|
+
newBody += '--' + boundary + eol + 'Content-Disposition: form-data; name="' + bodyKey + '"' + eol + eol + body[bodyKey] + eol;
|
|
715
|
+
}
|
|
716
|
+
newBody += '--' + boundary + '--' + eol;
|
|
717
|
+
value += '; boundary=' + boundary;
|
|
718
|
+
headers[key] = value;
|
|
719
|
+
body = newBody;
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
698
724
|
// log
|
|
699
725
|
if (this.verbose) {
|
|
700
726
|
this.log('fetch Request:\n', this.id, method, url, '\nRequestHeaders:\n', headers, '\nRequestBody:\n', body, '\n');
|
|
@@ -1577,6 +1603,112 @@ class Exchange {
|
|
|
1577
1603
|
unlockId() {
|
|
1578
1604
|
return undefined; // c# stub
|
|
1579
1605
|
}
|
|
1606
|
+
async loadLighterLibrary(libraryPath, chainId, privateKey, apiKeyIndex, accountIndex) {
|
|
1607
|
+
// wasmExecPathExample: '/opt/homebrew/opt/go/libexec/lib/wasm/wasm_exec.js';
|
|
1608
|
+
// libraryPath eg: '/Users/cjg/Git/lighter-go/lighter.wasm';
|
|
1609
|
+
if (libraryPath === undefined || libraryPath === '') {
|
|
1610
|
+
throw new Error('loadLighterLibrary() requires "libraryPath" that should point to "lighter.wasm".\nYou can build it from source using the official Ligher SDK or download it here https://github.com/ccxt/lighter-wasm.\nExample: exchanges.options["libraryPath"] = "/user/cjg/Git/lighter-wasm/lighter.wasm"');
|
|
1611
|
+
}
|
|
1612
|
+
if (!isNode) {
|
|
1613
|
+
throw new errors.NotSupported(this.id + ' loadLighterLibrary() is only supported in node environment.');
|
|
1614
|
+
}
|
|
1615
|
+
await io.initFileSystem();
|
|
1616
|
+
const wasmExecPath = this.safeString(this.options, 'wasmExecPath');
|
|
1617
|
+
if (wasmExecPath === undefined || wasmExecPath === '') {
|
|
1618
|
+
throw new Error('loadLighterLibrary() requires "wasmExecPath" that should point to `wasm_exec.js`. You can check the location of the file locally if you have GO installed or download it here https://github.com/ccxt/lighter-wasm.\nExample: exchanges.options["wasmExecPath"] = "/opt/homebrew/opt/go/libexec/lib/wasm/wasm_exec.js"');
|
|
1619
|
+
}
|
|
1620
|
+
await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(wasmExecPath);
|
|
1621
|
+
const go = new globalThis.Go();
|
|
1622
|
+
// read wasm from disks
|
|
1623
|
+
const bytes = new Uint8Array(readFile(libraryPath, null)); // it should point to lighter.wasm
|
|
1624
|
+
const { instance } = await WebAssembly.instantiate(bytes, go.importObject);
|
|
1625
|
+
go.run(instance);
|
|
1626
|
+
// createCLient
|
|
1627
|
+
const url = this.implodeHostname(this.urls['api']['public']);
|
|
1628
|
+
const res = globalThis.CreateClient(url, privateKey, chainId, apiKeyIndex, accountIndex);
|
|
1629
|
+
this.checkLighterSignedError(res);
|
|
1630
|
+
return {}; // empty object we will read it from globalThis
|
|
1631
|
+
}
|
|
1632
|
+
// eslint-disable-next-line no-unused-vars
|
|
1633
|
+
lighterSignCreateGroupedOrders(signer, request) {
|
|
1634
|
+
const orders = request['orders'];
|
|
1635
|
+
const ordersArr = [];
|
|
1636
|
+
for (let i = 0; i < orders.length; i++) {
|
|
1637
|
+
const order = orders[i];
|
|
1638
|
+
ordersArr.push({
|
|
1639
|
+
'MarketIndex': parseInt(order['market_index']),
|
|
1640
|
+
'ClientOrderIndex': order['client_order_index'],
|
|
1641
|
+
'BaseAmount': order['base_amount'],
|
|
1642
|
+
'Price': order['avg_execution_price'],
|
|
1643
|
+
'IsAsk': order['is_ask'],
|
|
1644
|
+
'Type': order['order_type'],
|
|
1645
|
+
'TimeInForce': order['time_in_force'],
|
|
1646
|
+
'ReduceOnly': order['reduce_only'],
|
|
1647
|
+
'TriggerPrice': order['trigger_price'],
|
|
1648
|
+
'OrderExpiry': order['order_expiry'],
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
const res = globalThis.SignCreateGroupedOrders(request['grouping_type'], ordersArr, orders.length, request['nonce'], request['api_key_index'], request['account_index']);
|
|
1652
|
+
this.checkLighterSignedError(res);
|
|
1653
|
+
return [res.txType, res.txInfo];
|
|
1654
|
+
}
|
|
1655
|
+
// eslint-disable-next-line no-unused-vars
|
|
1656
|
+
lighterSignCreateOrder(signer, request) {
|
|
1657
|
+
const res = (globalThis.SignCreateOrder(parseInt(request['market_index']), request['client_order_index'], request['base_amount'], request['avg_execution_price'], request['is_ask'], request['order_type'], request['time_in_force'], request['reduce_only'], request['trigger_price'], request['order_expiry'], request['nonce'], request['api_key_index'], request['account_index']));
|
|
1658
|
+
this.checkLighterSignedError(res);
|
|
1659
|
+
return [res.txType, res.txInfo];
|
|
1660
|
+
}
|
|
1661
|
+
checkLighterSignedError(result) {
|
|
1662
|
+
if ('error' in result) {
|
|
1663
|
+
throw new Error('Lighter signing error: ' + result.error);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
lighterSignCancelOrder(signer, request) {
|
|
1667
|
+
const res = (globalThis.SignCancelOrder(request['market_index'], request['order_index'], request['nonce'], request['api_key_index'], request['account_index']));
|
|
1668
|
+
this.checkLighterSignedError(res);
|
|
1669
|
+
return [res.txType, res.txInfo];
|
|
1670
|
+
}
|
|
1671
|
+
lighterSignWithdraw(signer, request) {
|
|
1672
|
+
const res = (globalThis.SignWithdraw(request['asset_index'], request['route_type'], request['amount'], request['nonce'], request['api_key_index'], request['account_index']));
|
|
1673
|
+
this.checkLighterSignedError(res);
|
|
1674
|
+
return [res.txType, res.txInfo];
|
|
1675
|
+
}
|
|
1676
|
+
// eslint-disable-next-line no-unused-vars
|
|
1677
|
+
lighterSignCreateSubAccount(signer, request) {
|
|
1678
|
+
const res = (globalThis.SignCreateSubAccount(request['nonce'], request['api_key_index'], request['account_index']));
|
|
1679
|
+
this.checkLighterSignedError(res);
|
|
1680
|
+
return [res.txType, res.txInfo];
|
|
1681
|
+
}
|
|
1682
|
+
lighterSignCancelAllOrders(signer, request) {
|
|
1683
|
+
const res = (globalThis.SignCancelAllOrders(request['time_in_force'], request['time'], request['nonce'], request['api_key_index'], request['account_index']));
|
|
1684
|
+
this.checkLighterSignedError(res);
|
|
1685
|
+
return [res.txType, res.txInfo];
|
|
1686
|
+
}
|
|
1687
|
+
lighterSignModifyOrder(signer, request) {
|
|
1688
|
+
const res = (globalThis.SignModifyOrder(request['market_index'], request['index'], request['base_amount'], request['price'], request['trigger_price'], request['nonce'], request['api_key_index'], request['account_index']));
|
|
1689
|
+
this.checkLighterSignedError(res);
|
|
1690
|
+
return [res.txType, res.txInfo];
|
|
1691
|
+
}
|
|
1692
|
+
lighterSignTransfer(signer, request) {
|
|
1693
|
+
const res = globalThis.SignTransfer(request['to_account_index'], request['asset_index'], request['from_route_type'], request['to_route_type'], request['amount'], request['usdc_fee'], request['memo'], request['nonce'], request['api_key_index'], request['account_index']);
|
|
1694
|
+
this.checkLighterSignedError(res);
|
|
1695
|
+
return [res.txType, res.txInfo];
|
|
1696
|
+
}
|
|
1697
|
+
lighterSignUpdateLeverage(signer, request) {
|
|
1698
|
+
const res = (globalThis.SignUpdateLeverage(request['market_index'], request['initial_margin_fraction'], request['margin_mode'], request['nonce'], request['api_key_index'], request['account_index']));
|
|
1699
|
+
this.checkLighterSignedError(res);
|
|
1700
|
+
return [res.txType, res.txInfo];
|
|
1701
|
+
}
|
|
1702
|
+
lighterCreateAuthToken(signer, request) {
|
|
1703
|
+
const res = globalThis.CreateAuthToken(request['deadline'], request['api_key_index'], request['account_index']);
|
|
1704
|
+
this.checkLighterSignedError(res);
|
|
1705
|
+
return res.authToken;
|
|
1706
|
+
}
|
|
1707
|
+
lighterSignUpdateMargin(signer, request) {
|
|
1708
|
+
const res = globalThis.SignUpdateMargin(request['market_index'], request['usdc_amount'], request['direction'], request['nonce'], request['api_key_index'], request['account_index']);
|
|
1709
|
+
this.checkLighterSignedError(res);
|
|
1710
|
+
return [res.txType, res.txInfo];
|
|
1711
|
+
}
|
|
1580
1712
|
/* eslint-enable */
|
|
1581
1713
|
// ------------------------------------------------------------------------
|
|
1582
1714
|
// ########################################################################
|
|
@@ -175,6 +175,7 @@ const deepExtend = function (...args) {
|
|
|
175
175
|
}
|
|
176
176
|
return result;
|
|
177
177
|
};
|
|
178
|
+
// better "merge" func resides in static_dependencies/qs/utils.js
|
|
178
179
|
const merge = (target, ...args) => {
|
|
179
180
|
// doesn't overwrite defined keys with undefined
|
|
180
181
|
const overwrite = {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var platform = require('./platform.js');
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ----------------------------------------------------------------------------
|
|
26
|
+
/* ------------------------------------------------------------------------ */
|
|
27
|
+
let fsSyncModule = null;
|
|
28
|
+
let osSyncModule = null;
|
|
29
|
+
let pathSyncModule = null;
|
|
30
|
+
/* ------------------------------------------------------------------------ */
|
|
31
|
+
/**
|
|
32
|
+
* Initialize synchronous file system module (Node.js only)
|
|
33
|
+
* Uses dynamic import to prevent bundling in browser builds
|
|
34
|
+
*/
|
|
35
|
+
async function initFileSystem() {
|
|
36
|
+
if (platform.isNode) {
|
|
37
|
+
if (fsSyncModule === null) {
|
|
38
|
+
try {
|
|
39
|
+
// Dynamic import with webpackIgnore to prevent bundling
|
|
40
|
+
fsSyncModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'node:fs')); });
|
|
41
|
+
}
|
|
42
|
+
catch (e) { } // Silent fail in browser or if fs is unavailable
|
|
43
|
+
}
|
|
44
|
+
if (osSyncModule === null) {
|
|
45
|
+
try {
|
|
46
|
+
osSyncModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'node:os')); });
|
|
47
|
+
}
|
|
48
|
+
catch (e) { } // Silent fail in browser or if os is unavailable
|
|
49
|
+
}
|
|
50
|
+
if (pathSyncModule === null) {
|
|
51
|
+
try {
|
|
52
|
+
pathSyncModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'node:path')); });
|
|
53
|
+
}
|
|
54
|
+
catch (e) { } // Silent fail in browser or if path is unavailable
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (platform.isNode) {
|
|
59
|
+
// Pre-initialize synchronous fs module for sync methods
|
|
60
|
+
initFileSystem();
|
|
61
|
+
}
|
|
62
|
+
/* ------------------------------------------------------------------------ */
|
|
63
|
+
/**
|
|
64
|
+
* Get system temporary directory (Node.js only)
|
|
65
|
+
* @returns Temporary directory path with trailing slash, or undefined
|
|
66
|
+
*/
|
|
67
|
+
function getTempDir() {
|
|
68
|
+
if (!platform.isNode || osSyncModule === null) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const tmpDir = pathSyncModule.resolve(osSyncModule.tmpdir());
|
|
73
|
+
const sep = pathSyncModule ? pathSyncModule.sep : '/';
|
|
74
|
+
return tmpDir.endsWith(sep) ? tmpDir : tmpDir + sep;
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Check if file path is ccxt-cache file, so users are ensured there is no access possible to other files
|
|
82
|
+
* @param path File path to check
|
|
83
|
+
*/
|
|
84
|
+
function ensureWhitelistedFile(filePath) {
|
|
85
|
+
if (pathSyncModule === null) {
|
|
86
|
+
throw new Error('path module is not available');
|
|
87
|
+
}
|
|
88
|
+
const sanitizedFilePath = pathSyncModule.resolve(filePath);
|
|
89
|
+
if ((sanitizedFilePath.startsWith(filePath) && sanitizedFilePath.endsWith('.ccxtfile')) || sanitizedFilePath.endsWith('.wasm')) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
throw new Error('invalid file path: ' + filePath);
|
|
93
|
+
}
|
|
94
|
+
/* ------------------------------------------------------------------------ */
|
|
95
|
+
/**
|
|
96
|
+
* Read file contents synchronously (Node.js only)
|
|
97
|
+
* @param path File path to read
|
|
98
|
+
* @param encoding File encoding (default: 'utf8')
|
|
99
|
+
* @returns File contents as string, or undefined in browser
|
|
100
|
+
*/
|
|
101
|
+
function readFile(path, encoding = 'utf8') {
|
|
102
|
+
if (!platform.isNode || fsSyncModule === null) {
|
|
103
|
+
// Sync module not initialized yet
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
ensureWhitelistedFile(path);
|
|
107
|
+
try {
|
|
108
|
+
return fsSyncModule.readFileSync(path, encoding);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/* ------------------------------------------------------------------------ */
|
|
115
|
+
/**
|
|
116
|
+
* Write file contents synchronously (Node.js only)
|
|
117
|
+
* @param path File path to write
|
|
118
|
+
* @param data Data to write
|
|
119
|
+
* @param encoding File encoding (default: 'utf8')
|
|
120
|
+
*/
|
|
121
|
+
function writeFile(path, data, encoding = 'utf8') {
|
|
122
|
+
if (!platform.isNode || fsSyncModule === null) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
ensureWhitelistedFile(path);
|
|
126
|
+
try {
|
|
127
|
+
fsSyncModule.writeFileSync(path, data, encoding);
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
// Silent fail
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/* ------------------------------------------------------------------------ */
|
|
136
|
+
/**
|
|
137
|
+
* Check if file exists synchronously (Node.js only)
|
|
138
|
+
* @param path File path to check
|
|
139
|
+
* @returns true if file exists, false otherwise
|
|
140
|
+
*/
|
|
141
|
+
function existsFile(path) {
|
|
142
|
+
if (!platform.isNode || fsSyncModule === null) {
|
|
143
|
+
// Sync module not initialized yet
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
ensureWhitelistedFile(path);
|
|
147
|
+
try {
|
|
148
|
+
fsSyncModule.accessSync(path);
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
exports.existsFile = existsFile;
|
|
157
|
+
exports.getTempDir = getTempDir;
|
|
158
|
+
exports.initFileSystem = initFileSystem;
|
|
159
|
+
exports.readFile = readFile;
|
|
160
|
+
exports.writeFile = writeFile;
|
|
@@ -12,6 +12,7 @@ var crypto = require('./functions/crypto.js');
|
|
|
12
12
|
var time = require('./functions/time.js');
|
|
13
13
|
var throttle = require('./functions/throttle.js');
|
|
14
14
|
var misc = require('./functions/misc.js');
|
|
15
|
+
var io = require('./functions/io.js');
|
|
15
16
|
|
|
16
17
|
// ----------------------------------------------------------------------------
|
|
17
18
|
/* ------------------------------------------------------------------------ */
|
|
@@ -159,3 +160,8 @@ exports.parseTimeframe = misc.parseTimeframe;
|
|
|
159
160
|
exports.roundTimeframe = misc.roundTimeframe;
|
|
160
161
|
exports.selfIsDefined = misc.selfIsDefined;
|
|
161
162
|
exports.vwap = misc.vwap;
|
|
163
|
+
exports.existsFile = io.existsFile;
|
|
164
|
+
exports.getTempDir = io.getTempDir;
|
|
165
|
+
exports.initFileSystem = io.initFileSystem;
|
|
166
|
+
exports.readFile = io.readFile;
|
|
167
|
+
exports.writeFile = io.writeFile;
|
|
@@ -10,6 +10,7 @@ var generic = require('../functions/generic.js');
|
|
|
10
10
|
var encode = require('../functions/encode.js');
|
|
11
11
|
require('../functions/crypto.js');
|
|
12
12
|
var time = require('../functions/time.js');
|
|
13
|
+
require('../functions/io.js');
|
|
13
14
|
var index = require('../../static_dependencies/scure-base/index.js');
|
|
14
15
|
|
|
15
16
|
// ----------------------------------------------------------------------------
|
|
@@ -9,6 +9,7 @@ require('../functions/encode.js');
|
|
|
9
9
|
require('../functions/crypto.js');
|
|
10
10
|
var time = require('../functions/time.js');
|
|
11
11
|
var misc = require('../functions/misc.js');
|
|
12
|
+
require('../functions/io.js');
|
|
12
13
|
var Future = require('./Future.js');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -6416,6 +6416,7 @@ class binance extends binance$1["default"] {
|
|
|
6416
6416
|
* @param {string} [params.stopLossOrTakeProfit] 'stopLoss' or 'takeProfit', required for spot trailing orders
|
|
6417
6417
|
* @param {string} [params.positionSide] *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
|
|
6418
6418
|
* @param {bool} [params.hedged] *swap and portfolio margin only* true for hedged mode, false for one way mode, default is false
|
|
6419
|
+
* @param {string} [params.clientOrderId] the clientOrderId of the order
|
|
6419
6420
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
|
|
6420
6421
|
*/
|
|
6421
6422
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -140,7 +140,17 @@ class bingx extends bingx$1["default"] {
|
|
|
140
140
|
'api': 'https://open-api.{hostname}/openApi',
|
|
141
141
|
},
|
|
142
142
|
'test': {
|
|
143
|
-
'
|
|
143
|
+
'fund': 'https://open-api-vst.{hostname}/openApi',
|
|
144
|
+
'spot': 'https://open-api-vst.{hostname}/openApi',
|
|
145
|
+
'swap': 'https://open-api-vst.{hostname}/openApi',
|
|
146
|
+
'contract': 'https://open-api-vst.{hostname}/openApi',
|
|
147
|
+
'wallets': 'https://open-api-vst.{hostname}/openApi',
|
|
148
|
+
'user': 'https://open-api-vst.{hostname}/openApi',
|
|
149
|
+
'subAccount': 'https://open-api-vst.{hostname}/openApi',
|
|
150
|
+
'account': 'https://open-api-vst.{hostname}/openApi',
|
|
151
|
+
'copyTrading': 'https://open-api-vst.{hostname}/openApi',
|
|
152
|
+
'cswap': 'https://open-api-vst.{hostname}/openApi',
|
|
153
|
+
'api': 'https://open-api-vst.{hostname}/openApi',
|
|
144
154
|
},
|
|
145
155
|
'www': 'https://bingx.com/',
|
|
146
156
|
'doc': 'https://bingx-api.github.io/docs/',
|
|
@@ -6840,10 +6850,10 @@ class bingx extends bingx$1["default"] {
|
|
|
6840
6850
|
let version = section[1];
|
|
6841
6851
|
let access = section[2];
|
|
6842
6852
|
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
6843
|
-
|
|
6853
|
+
let url = this.implodeHostname(this.urls['api'][type]);
|
|
6854
|
+
if (isSandbox && url === undefined) {
|
|
6844
6855
|
throw new errors.NotSupported(this.id + ' does not have a testnet/sandbox URL for ' + type + ' endpoints');
|
|
6845
6856
|
}
|
|
6846
|
-
let url = this.implodeHostname(this.urls['api'][type]);
|
|
6847
6857
|
path = this.implodeParams(path, params);
|
|
6848
6858
|
const versionIsTransfer = (version === 'transfer');
|
|
6849
6859
|
const versionIsAsset = (version === 'asset');
|