ccxt 4.5.39 → 4.5.41
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 +211 -22
- 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 +143 -0
- package/dist/cjs/src/bingx.js +150 -123
- package/dist/cjs/src/bitmart.js +20 -6
- package/dist/cjs/src/bitmex.js +436 -0
- package/dist/cjs/src/blofin.js +86 -1
- package/dist/cjs/src/bybit.js +135 -0
- package/dist/cjs/src/coinspot.js +7 -2
- package/dist/cjs/src/delta.js +367 -0
- package/dist/cjs/src/gate.js +11 -4
- package/dist/cjs/src/gemini.js +76 -1
- package/dist/cjs/src/htx.js +266 -3
- 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 +121 -0
- package/dist/cjs/src/lighter.js +2931 -0
- package/dist/cjs/src/mexc.js +9 -2
- package/dist/cjs/src/phemex.js +359 -0
- package/dist/cjs/src/poloniex.js +5 -0
- package/dist/cjs/src/pro/binance.js +2 -2
- package/dist/cjs/src/pro/bingx.js +248 -35
- package/dist/cjs/src/pro/bitget.js +49 -90
- package/dist/cjs/src/pro/bitmart.js +68 -0
- package/dist/cjs/src/pro/blofin.js +52 -1
- package/dist/cjs/src/pro/coinbaseinternational.js +5 -2
- 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 +73 -1
- package/dist/cjs/src/pro/okx.js +7 -4
- package/dist/cjs/src/pro/paradex.js +138 -1
- package/dist/cjs/src/pro/woo.js +43 -0
- 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 +103 -3
- package/js/ccxt.d.ts +9 -3
- 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 +5 -0
- package/js/src/ascendex.d.ts +12 -1
- package/js/src/ascendex.js +73 -1
- package/js/src/base/Exchange.d.ts +29 -14
- package/js/src/base/Exchange.js +216 -23
- 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 +131 -0
- package/js/src/base/functions.d.ts +1 -0
- package/js/src/base/functions.js +1 -0
- package/js/src/base/types.d.ts +9 -0
- package/js/src/binance.d.ts +27 -1
- package/js/src/binance.js +143 -0
- package/js/src/bingx.d.ts +113 -108
- package/js/src/bingx.js +150 -123
- package/js/src/bitmart.js +20 -6
- package/js/src/bitmex.d.ts +50 -1
- package/js/src/bitmex.js +436 -0
- package/js/src/blofin.d.ts +12 -1
- package/js/src/blofin.js +86 -1
- package/js/src/bybit.d.ts +12 -1
- package/js/src/bybit.js +135 -0
- package/js/src/coinspot.js +7 -2
- package/js/src/delta.d.ts +12 -1
- package/js/src/delta.js +367 -0
- 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.d.ts +15 -1
- package/js/src/htx.js +266 -3
- 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.d.ts +12 -1
- package/js/src/kucoinfutures.js +121 -0
- package/js/src/lighter.d.ts +424 -0
- package/js/src/lighter.js +2924 -0
- package/js/src/mexc.js +9 -2
- package/js/src/phemex.d.ts +16 -1
- package/js/src/phemex.js +359 -0
- package/js/src/poloniex.js +5 -0
- package/js/src/pro/binance.js +2 -2
- package/js/src/pro/bingx.d.ts +50 -34
- package/js/src/pro/bingx.js +249 -36
- package/js/src/pro/bitget.d.ts +6 -6
- package/js/src/pro/bitget.js +49 -90
- package/js/src/pro/bitmart.d.ts +22 -1
- package/js/src/pro/bitmart.js +69 -1
- package/js/src/pro/blofin.d.ts +12 -1
- package/js/src/pro/blofin.js +52 -1
- package/js/src/pro/coinbaseinternational.d.ts +2 -2
- package/js/src/pro/coinbaseinternational.js +6 -3
- 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 +780 -0
- package/js/src/pro/mexc.d.ts +22 -1
- package/js/src/pro/mexc.js +73 -1
- package/js/src/pro/okx.d.ts +4 -4
- package/js/src/pro/okx.js +7 -4
- package/js/src/pro/paradex.d.ts +23 -1
- package/js/src/pro/paradex.js +138 -1
- package/js/src/pro/woo.d.ts +12 -1
- package/js/src/pro/woo.js +43 -0
- package/js/src/whitebit.d.ts +2 -1
- package/js/src/whitebit.js +118 -16
- package/js/src/woo.d.ts +12 -1
- package/js/src/woo.js +103 -3
- 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.41';
|
|
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,9 +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 generic = require('./functions/generic.js');
|
|
37
|
-
var misc = require('./functions/misc.js');
|
|
38
36
|
var index$3 = require('../static_dependencies/dydx-v4-client/long/index.cjs.js');
|
|
37
|
+
var io = require('./functions/io.js');
|
|
39
38
|
|
|
40
39
|
function _interopNamespace(e) {
|
|
41
40
|
if (e && e.__esModule) return e;
|
|
@@ -56,9 +55,9 @@ function _interopNamespace(e) {
|
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
// ----------------------------------------------------------------------------
|
|
59
|
-
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,
|
|
60
59
|
// ecdsa,
|
|
61
|
-
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;
|
|
62
61
|
// ----------------------------------------------------------------------------
|
|
63
62
|
let protobufMexc = undefined;
|
|
64
63
|
let encodeAsAny = undefined;
|
|
@@ -68,14 +67,6 @@ let TxBody = undefined;
|
|
|
68
67
|
let TxRaw = undefined;
|
|
69
68
|
let SignDoc = undefined;
|
|
70
69
|
let SignMode = undefined;
|
|
71
|
-
(async () => {
|
|
72
|
-
try {
|
|
73
|
-
protobufMexc = await Promise.resolve().then(function () { return require('../protobuf/mexc/compiled.cjs.js'); });
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
// TODO: handle error
|
|
77
|
-
}
|
|
78
|
-
})();
|
|
79
70
|
// -----------------------------------------------------------------------------
|
|
80
71
|
/**
|
|
81
72
|
* @class Exchange
|
|
@@ -191,11 +182,8 @@ class Exchange {
|
|
|
191
182
|
this.deepExtend = deepExtend;
|
|
192
183
|
this.deepExtendSafe = deepExtend;
|
|
193
184
|
this.isNode = isNode;
|
|
194
|
-
this.keys = generic.keys;
|
|
195
|
-
this.values = generic.values;
|
|
196
185
|
this.extend = extend;
|
|
197
186
|
this.clone = clone;
|
|
198
|
-
this.flatten = flatten;
|
|
199
187
|
this.unique = unique;
|
|
200
188
|
this.indexBy = indexBy;
|
|
201
189
|
this.indexBySafe = indexBy;
|
|
@@ -230,8 +218,6 @@ class Exchange {
|
|
|
230
218
|
this.implodeParams = implodeParams;
|
|
231
219
|
this.extractParams = extractParams;
|
|
232
220
|
this.json = json;
|
|
233
|
-
this.vwap = misc.vwap;
|
|
234
|
-
this.merge = merge;
|
|
235
221
|
this.binaryConcat = binaryConcat;
|
|
236
222
|
this.hash = hash;
|
|
237
223
|
this.arrayConcat = arrayConcat;
|
|
@@ -247,8 +233,6 @@ class Exchange {
|
|
|
247
233
|
this.safeStringUpper = safeStringUpper;
|
|
248
234
|
this.safeTimestamp = safeTimestamp;
|
|
249
235
|
this.binaryConcatArray = binaryConcatArray;
|
|
250
|
-
this.uuidv1 = uuidv1;
|
|
251
|
-
this.numberToLE = numberToLE;
|
|
252
236
|
this.ymdhms = ymdhms;
|
|
253
237
|
this.yymmdd = yymmdd;
|
|
254
238
|
this.stringToBase64 = stringToBase64;
|
|
@@ -267,7 +251,6 @@ class Exchange {
|
|
|
267
251
|
this.safeStringLower2 = safeStringLower2;
|
|
268
252
|
this.safeStringUpper2 = safeStringUpper2;
|
|
269
253
|
this.isEmpty = isEmpty;
|
|
270
|
-
this.ordered = ordered;
|
|
271
254
|
this.filterBy = filterBy;
|
|
272
255
|
this.uuid16 = uuid16;
|
|
273
256
|
this.urlencodeWithArrayRepeat = urlencodeWithArrayRepeat;
|
|
@@ -290,6 +273,11 @@ class Exchange {
|
|
|
290
273
|
this.crc32 = crc32;
|
|
291
274
|
this.packb = packb;
|
|
292
275
|
this.urlencodeBase64 = urlencodeBase64;
|
|
276
|
+
// io
|
|
277
|
+
this.readFile = readFile;
|
|
278
|
+
this.writeFile = writeFile;
|
|
279
|
+
this.existsFile = existsFile;
|
|
280
|
+
this.getTempDir = getTempDir;
|
|
293
281
|
Object.assign(this, functions);
|
|
294
282
|
//
|
|
295
283
|
// if (isNode) {
|
|
@@ -399,6 +387,18 @@ class Exchange {
|
|
|
399
387
|
if (this.safeBool(userConfig, 'sandbox') || this.safeBool(userConfig, 'testnet')) {
|
|
400
388
|
this.setSandboxMode(true);
|
|
401
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
|
+
}
|
|
402
402
|
}
|
|
403
403
|
uuid5(namespace, name) {
|
|
404
404
|
const nsBytes = namespace
|
|
@@ -698,6 +698,29 @@ class Exchange {
|
|
|
698
698
|
}
|
|
699
699
|
// set final headers
|
|
700
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
|
+
}
|
|
701
724
|
// log
|
|
702
725
|
if (this.verbose) {
|
|
703
726
|
this.log('fetch Request:\n', this.id, method, url, '\nRequestHeaders:\n', headers, '\nRequestBody:\n', body, '\n');
|
|
@@ -1580,6 +1603,112 @@ class Exchange {
|
|
|
1580
1603
|
unlockId() {
|
|
1581
1604
|
return undefined; // c# stub
|
|
1582
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
|
+
}
|
|
1583
1712
|
/* eslint-enable */
|
|
1584
1713
|
// ------------------------------------------------------------------------
|
|
1585
1714
|
// ########################################################################
|
|
@@ -1706,6 +1835,7 @@ class Exchange {
|
|
|
1706
1835
|
'editOrders': undefined,
|
|
1707
1836
|
'editOrderWs': undefined,
|
|
1708
1837
|
'fetchAccounts': undefined,
|
|
1838
|
+
'fetchADLRank': undefined,
|
|
1709
1839
|
'fetchBalance': true,
|
|
1710
1840
|
'fetchBalanceWs': undefined,
|
|
1711
1841
|
'fetchBidsAsks': undefined,
|
|
@@ -1791,6 +1921,8 @@ class Exchange {
|
|
|
1791
1921
|
'fetchOrderTrades': undefined,
|
|
1792
1922
|
'fetchOrderWs': undefined,
|
|
1793
1923
|
'fetchPosition': undefined,
|
|
1924
|
+
'fetchPositionADLRank': undefined,
|
|
1925
|
+
'fetchPositionsADLRank': undefined,
|
|
1794
1926
|
'fetchPositionHistory': undefined,
|
|
1795
1927
|
'fetchPositionsHistory': undefined,
|
|
1796
1928
|
'fetchPositionWs': undefined,
|
|
@@ -2624,9 +2756,12 @@ class Exchange {
|
|
|
2624
2756
|
async watchFundingRate(symbol, params = {}) {
|
|
2625
2757
|
throw new errors.NotSupported(this.id + ' watchFundingRate() is not supported yet');
|
|
2626
2758
|
}
|
|
2627
|
-
async watchFundingRates(symbols, params = {}) {
|
|
2759
|
+
async watchFundingRates(symbols = undefined, params = {}) {
|
|
2628
2760
|
throw new errors.NotSupported(this.id + ' watchFundingRates() is not supported yet');
|
|
2629
2761
|
}
|
|
2762
|
+
async unWatchFundingRates(symbols = undefined, params = {}) {
|
|
2763
|
+
throw new errors.NotSupported(this.id + ' unWatchFundingRates() is not supported yet');
|
|
2764
|
+
}
|
|
2630
2765
|
async watchFundingRatesForSymbols(symbols, params = {}) {
|
|
2631
2766
|
return await this.watchFundingRates(symbols, params);
|
|
2632
2767
|
}
|
|
@@ -2696,7 +2831,13 @@ class Exchange {
|
|
|
2696
2831
|
throw new errors.NotSupported(this.id + ' fetchOpenInterestHistory() is not supported yet');
|
|
2697
2832
|
}
|
|
2698
2833
|
async fetchOpenInterest(symbol, params = {}) {
|
|
2699
|
-
|
|
2834
|
+
if (this.has['fetchOpenInterests']) {
|
|
2835
|
+
const openInterests = await this.fetchOpenInterests([symbol], params);
|
|
2836
|
+
return this.safeDict(openInterests, symbol);
|
|
2837
|
+
}
|
|
2838
|
+
else {
|
|
2839
|
+
throw new errors.NotSupported(this.id + ' fetchOpenInterest() is not supported yet');
|
|
2840
|
+
}
|
|
2700
2841
|
}
|
|
2701
2842
|
async fetchOpenInterests(symbols = undefined, params = {}) {
|
|
2702
2843
|
throw new errors.NotSupported(this.id + ' fetchOpenInterests() is not supported yet');
|
|
@@ -4636,6 +4777,19 @@ class Exchange {
|
|
|
4636
4777
|
}
|
|
4637
4778
|
return this.filterByArrayPositions(result, 'symbol', symbols, false);
|
|
4638
4779
|
}
|
|
4780
|
+
parseADLRank(info, market = undefined) {
|
|
4781
|
+
throw new errors.NotSupported(this.id + ' parseADLRank() is not supported yet');
|
|
4782
|
+
}
|
|
4783
|
+
parseADLRanks(ranks, symbols = undefined, params = {}) {
|
|
4784
|
+
symbols = this.marketSymbols(symbols);
|
|
4785
|
+
ranks = this.toArray(ranks);
|
|
4786
|
+
const result = [];
|
|
4787
|
+
for (let i = 0; i < ranks.length; i++) {
|
|
4788
|
+
const rank = this.extend(this.parseADLRank(ranks[i], undefined), params);
|
|
4789
|
+
result.push(rank);
|
|
4790
|
+
}
|
|
4791
|
+
return this.filterByArrayPositions(result, 'symbol', symbols, false);
|
|
4792
|
+
}
|
|
4639
4793
|
parseAccounts(accounts, params = {}) {
|
|
4640
4794
|
accounts = this.toArray(accounts);
|
|
4641
4795
|
const result = [];
|
|
@@ -5475,6 +5629,9 @@ class Exchange {
|
|
|
5475
5629
|
async unWatchTickers(symbols = undefined, params = {}) {
|
|
5476
5630
|
throw new errors.NotSupported(this.id + ' unWatchTickers() is not supported yet');
|
|
5477
5631
|
}
|
|
5632
|
+
async unWatchFundingRate(symbol, params = {}) {
|
|
5633
|
+
throw new errors.NotSupported(this.id + ' unWatchFundingRate() is not supported yet');
|
|
5634
|
+
}
|
|
5478
5635
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
5479
5636
|
throw new errors.NotSupported(this.id + ' fetchOrder() is not supported yet');
|
|
5480
5637
|
}
|
|
@@ -5521,6 +5678,30 @@ class Exchange {
|
|
|
5521
5678
|
async fetchPositionMode(symbol = undefined, params = {}) {
|
|
5522
5679
|
throw new errors.NotSupported(this.id + ' fetchPositionMode() is not supported yet');
|
|
5523
5680
|
}
|
|
5681
|
+
async fetchADLRank(symbol, params = {}) {
|
|
5682
|
+
throw new errors.NotSupported(this.id + ' fetchADLRank() is not supported yet');
|
|
5683
|
+
}
|
|
5684
|
+
async fetchPositionsADLRank(symbols = undefined, params = {}) {
|
|
5685
|
+
throw new errors.NotSupported(this.id + ' fetchPositionsADLRank() is not supported yet');
|
|
5686
|
+
}
|
|
5687
|
+
async fetchPositionADLRank(symbol, params = {}) {
|
|
5688
|
+
if (this.has['fetchPositionsADLRank']) {
|
|
5689
|
+
await this.loadMarkets();
|
|
5690
|
+
const market = this.market(symbol);
|
|
5691
|
+
symbol = market['symbol'];
|
|
5692
|
+
const ranks = await this.fetchPositionsADLRank([symbol], params);
|
|
5693
|
+
const rank = this.safeDict(ranks, 0);
|
|
5694
|
+
if (rank === undefined) {
|
|
5695
|
+
throw new errors.NullResponse(this.id + ' fetchPositionsADLRank() could not find a rank for ' + symbol);
|
|
5696
|
+
}
|
|
5697
|
+
else {
|
|
5698
|
+
return rank;
|
|
5699
|
+
}
|
|
5700
|
+
}
|
|
5701
|
+
else {
|
|
5702
|
+
throw new errors.NotSupported(this.id + ' fetchPositionsADLRank() is not supported yet');
|
|
5703
|
+
}
|
|
5704
|
+
}
|
|
5524
5705
|
async createTrailingAmountOrder(symbol, type, side, amount, price = undefined, trailingAmount = undefined, trailingTriggerPrice = undefined, params = {}) {
|
|
5525
5706
|
/**
|
|
5526
5707
|
* @method
|
|
@@ -7181,6 +7362,14 @@ class Exchange {
|
|
|
7181
7362
|
*/
|
|
7182
7363
|
return this.filterByArray(objects, key, values, indexed);
|
|
7183
7364
|
}
|
|
7365
|
+
filterByArrayADLRanks(objects, key, values = undefined, indexed = true) {
|
|
7366
|
+
/**
|
|
7367
|
+
* @ignore
|
|
7368
|
+
* @method
|
|
7369
|
+
* @description Typed wrapper for filterByArray that returns a list of ADL Ranks
|
|
7370
|
+
*/
|
|
7371
|
+
return this.filterByArray(objects, key, values, indexed);
|
|
7372
|
+
}
|
|
7184
7373
|
createOHLCVObject(symbol, timeframe, data) {
|
|
7185
7374
|
const res = {};
|
|
7186
7375
|
res[symbol] = {};
|
|
@@ -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 = {};
|