ccxt 4.5.51 → 4.5.52
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 +10 -9
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/aster.js +1532 -1072
- package/dist/cjs/src/base/Exchange.js +29 -24
- package/dist/cjs/src/bequant.js +3 -0
- package/dist/cjs/src/binance.js +36 -37
- package/dist/cjs/src/binanceusdm.js +1 -0
- package/dist/cjs/src/grvt.js +15 -8
- package/dist/cjs/src/kraken.js +6 -1
- package/dist/cjs/src/pro/aster.js +130 -138
- package/dist/cjs/src/pro/bequant.js +4 -3
- package/dist/cjs/src/pro/binance.js +3 -0
- package/dist/cjs/src/pro/binanceusdm.js +6 -1
- package/dist/cjs/src/pro/grvt.js +3 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/aster.d.ts +43 -9
- package/js/src/aster.d.ts +136 -71
- package/js/src/aster.js +1532 -1072
- package/js/src/base/Exchange.d.ts +3 -4
- package/js/src/base/Exchange.js +29 -24
- package/js/src/bequant.js +3 -0
- package/js/src/binance.js +35 -32
- package/js/src/binanceusdm.js +1 -0
- package/js/src/grvt.js +15 -8
- package/js/src/kraken.js +6 -1
- package/js/src/pro/aster.d.ts +81 -45
- package/js/src/pro/aster.js +130 -138
- package/js/src/pro/bequant.js +4 -3
- package/js/src/pro/binance.js +3 -0
- package/js/src/pro/binanceusdm.js +6 -1
- package/js/src/pro/grvt.js +3 -3
- package/package.json +2 -1
package/dist/cjs/src/aster.js
CHANGED
|
@@ -6,7 +6,6 @@ var aster$1 = require('./abstract/aster.js');
|
|
|
6
6
|
var errors = require('./base/errors.js');
|
|
7
7
|
var number = require('./base/functions/number.js');
|
|
8
8
|
var Precise = require('./base/Precise.js');
|
|
9
|
-
var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
|
|
10
9
|
var crypto = require('./base/functions/crypto.js');
|
|
11
10
|
var sha3 = require('./static_dependencies/noble-hashes/sha3.js');
|
|
12
11
|
var secp256k1 = require('./static_dependencies/noble-curves/secp256k1.js');
|
|
@@ -188,169 +187,217 @@ class aster extends aster$1["default"] {
|
|
|
188
187
|
'setMargin': false,
|
|
189
188
|
'setMarginMode': true,
|
|
190
189
|
'setPositionMode': true,
|
|
191
|
-
'signIn':
|
|
190
|
+
'signIn': true,
|
|
192
191
|
'transfer': true,
|
|
193
192
|
'withdraw': true,
|
|
194
193
|
},
|
|
195
194
|
'api': {
|
|
196
195
|
'fapiPublic': {
|
|
197
|
-
'get':
|
|
198
|
-
'v1/ping',
|
|
199
|
-
'v3/ping',
|
|
200
|
-
'v1/time',
|
|
201
|
-
'v3/time',
|
|
202
|
-
'v1/exchangeInfo',
|
|
203
|
-
'v3/exchangeInfo',
|
|
204
|
-
'v1/depth',
|
|
205
|
-
'v3/depth',
|
|
206
|
-
'v1/trades',
|
|
207
|
-
'v3/trades',
|
|
208
|
-
'v1/historicalTrades',
|
|
209
|
-
'v3/historicalTrades',
|
|
210
|
-
'v1/aggTrades',
|
|
211
|
-
'v3/aggTrades',
|
|
212
|
-
'v1/klines',
|
|
213
|
-
'v3/klines',
|
|
214
|
-
'v1/indexPriceKlines',
|
|
215
|
-
'v3/indexPriceKlines',
|
|
216
|
-
'v1/markPriceKlines',
|
|
217
|
-
'v3/markPriceKlines',
|
|
218
|
-
'v1/premiumIndex',
|
|
219
|
-
'v3/premiumIndex',
|
|
220
|
-
'v1/fundingRate',
|
|
221
|
-
'v3/fundingRate',
|
|
222
|
-
'v1/fundingInfo',
|
|
223
|
-
'v3/fundingInfo',
|
|
224
|
-
'v1/ticker/24hr',
|
|
225
|
-
'v3/ticker/24hr',
|
|
226
|
-
'v1/ticker/price',
|
|
227
|
-
'v3/ticker/price',
|
|
228
|
-
'v1/ticker/bookTicker',
|
|
229
|
-
'v3/ticker/bookTicker',
|
|
230
|
-
|
|
231
|
-
'v1/adlQuantile',
|
|
232
|
-
'v1/forceOrders',
|
|
233
|
-
|
|
196
|
+
'get': {
|
|
197
|
+
'v1/ping': 1,
|
|
198
|
+
'v3/ping': 1,
|
|
199
|
+
'v1/time': 1,
|
|
200
|
+
'v3/time': 1,
|
|
201
|
+
'v1/exchangeInfo': 1,
|
|
202
|
+
'v3/exchangeInfo': 1,
|
|
203
|
+
'v1/depth': 1,
|
|
204
|
+
'v3/depth': 2,
|
|
205
|
+
'v1/trades': 1,
|
|
206
|
+
'v3/trades': 1,
|
|
207
|
+
'v1/historicalTrades': 1,
|
|
208
|
+
'v3/historicalTrades': 20,
|
|
209
|
+
'v1/aggTrades': 1,
|
|
210
|
+
'v3/aggTrades': 20,
|
|
211
|
+
'v1/klines': 1,
|
|
212
|
+
'v3/klines': 1,
|
|
213
|
+
'v1/indexPriceKlines': 1,
|
|
214
|
+
'v3/indexPriceKlines': 1,
|
|
215
|
+
'v1/markPriceKlines': 1,
|
|
216
|
+
'v3/markPriceKlines': 1,
|
|
217
|
+
'v1/premiumIndex': 1,
|
|
218
|
+
'v3/premiumIndex': 1,
|
|
219
|
+
'v1/fundingRate': 1,
|
|
220
|
+
'v3/fundingRate': 1,
|
|
221
|
+
'v1/fundingInfo': 1,
|
|
222
|
+
'v3/fundingInfo': 1,
|
|
223
|
+
'v1/ticker/24hr': 1,
|
|
224
|
+
'v3/ticker/24hr': 1,
|
|
225
|
+
'v1/ticker/price': 1,
|
|
226
|
+
'v3/ticker/price': 1,
|
|
227
|
+
'v1/ticker/bookTicker': 1,
|
|
228
|
+
'v3/ticker/bookTicker': 1,
|
|
229
|
+
// different endpoints
|
|
230
|
+
'v1/adlQuantile': 1,
|
|
231
|
+
'v1/forceOrders': 1,
|
|
232
|
+
'v3/indexreferences': 1,
|
|
233
|
+
},
|
|
234
234
|
},
|
|
235
235
|
'fapiPrivate': {
|
|
236
|
-
'get':
|
|
237
|
-
'v1/positionSide/dual',
|
|
238
|
-
'v3/positionSide/dual',
|
|
239
|
-
'v1/multiAssetsMargin',
|
|
240
|
-
'v3/multiAssetsMargin',
|
|
241
|
-
'v1/order',
|
|
242
|
-
'v3/order',
|
|
243
|
-
'v1/openOrder',
|
|
244
|
-
'v3/openOrder',
|
|
245
|
-
'v1/openOrders',
|
|
246
|
-
'v3/openOrders',
|
|
247
|
-
'v1/allOrders',
|
|
248
|
-
'v3/allOrders',
|
|
249
|
-
'v2/balance',
|
|
250
|
-
'v3/balance',
|
|
251
|
-
'v3/account',
|
|
252
|
-
'
|
|
253
|
-
'
|
|
254
|
-
'
|
|
255
|
-
'v3/
|
|
256
|
-
'
|
|
257
|
-
'v3/
|
|
258
|
-
'v1/
|
|
259
|
-
'v3/
|
|
260
|
-
'v1/
|
|
261
|
-
'v3/
|
|
262
|
-
'v1/
|
|
263
|
-
'v3/
|
|
264
|
-
|
|
265
|
-
'v3/
|
|
266
|
-
'
|
|
267
|
-
'v3/
|
|
268
|
-
'v3/
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
'v3/
|
|
272
|
-
'
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
'
|
|
276
|
-
'
|
|
277
|
-
'
|
|
278
|
-
'
|
|
279
|
-
'
|
|
280
|
-
'
|
|
281
|
-
'
|
|
282
|
-
'
|
|
283
|
-
'
|
|
284
|
-
'
|
|
285
|
-
'
|
|
286
|
-
'
|
|
287
|
-
'
|
|
288
|
-
'
|
|
289
|
-
'
|
|
290
|
-
'
|
|
291
|
-
'
|
|
292
|
-
'v3/
|
|
293
|
-
'
|
|
294
|
-
'
|
|
295
|
-
'
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
'
|
|
299
|
-
'v3/
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
'
|
|
303
|
-
'v3/
|
|
304
|
-
'
|
|
305
|
-
'v3/
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
'
|
|
309
|
-
'
|
|
310
|
-
|
|
311
|
-
|
|
236
|
+
'get': {
|
|
237
|
+
'v1/positionSide/dual': 1,
|
|
238
|
+
'v3/positionSide/dual': 30,
|
|
239
|
+
'v1/multiAssetsMargin': 1,
|
|
240
|
+
'v3/multiAssetsMargin': 1,
|
|
241
|
+
'v1/order': 1,
|
|
242
|
+
'v3/order': 1,
|
|
243
|
+
'v1/openOrder': 1,
|
|
244
|
+
'v3/openOrder': 1,
|
|
245
|
+
'v1/openOrders': 1,
|
|
246
|
+
'v3/openOrders': 1,
|
|
247
|
+
'v1/allOrders': 1,
|
|
248
|
+
'v3/allOrders': 1,
|
|
249
|
+
'v2/balance': 1,
|
|
250
|
+
'v3/balance': 1,
|
|
251
|
+
'v3/account': 1,
|
|
252
|
+
'v1/positionMargin/history': 1,
|
|
253
|
+
'v3/positionMargin/history': 1,
|
|
254
|
+
'v2/positionRisk': 1,
|
|
255
|
+
'v3/positionRisk': 1,
|
|
256
|
+
'v1/userTrades': 1,
|
|
257
|
+
'v3/userTrades': 5,
|
|
258
|
+
'v1/income': 1,
|
|
259
|
+
'v3/income': 1,
|
|
260
|
+
'v1/leverageBracket': 1,
|
|
261
|
+
'v3/leverageBracket': 1,
|
|
262
|
+
'v1/commissionRate': 1,
|
|
263
|
+
'v3/commissionRate': 1,
|
|
264
|
+
// others
|
|
265
|
+
'v3/adlQuantile': 1,
|
|
266
|
+
'v3/forceOrders': 1,
|
|
267
|
+
'v3/mmp': 1,
|
|
268
|
+
'v3/accountWithJoinMargin': 1,
|
|
269
|
+
'v4/account': 1,
|
|
270
|
+
// builder
|
|
271
|
+
'v3/agent': 1,
|
|
272
|
+
'v3/builder': 1,
|
|
273
|
+
},
|
|
274
|
+
'post': {
|
|
275
|
+
'v1/positionSide/dual': 1,
|
|
276
|
+
'v3/positionSide/dual': 1,
|
|
277
|
+
'v1/multiAssetsMargin': 1,
|
|
278
|
+
'v3/multiAssetsMargin': 1,
|
|
279
|
+
'v1/order': 1,
|
|
280
|
+
'v3/order': 1,
|
|
281
|
+
'v1/order/test': 1,
|
|
282
|
+
'v3/order/test': 1,
|
|
283
|
+
'v1/batchOrders': 1,
|
|
284
|
+
'v3/batchOrders': 1,
|
|
285
|
+
'v1/asset/wallet/transfer': 1,
|
|
286
|
+
'v3/asset/wallet/transfer': 1,
|
|
287
|
+
'v1/countdownCancelAll': 1,
|
|
288
|
+
'v3/countdownCancelAll': 1,
|
|
289
|
+
'v1/leverage': 1,
|
|
290
|
+
'v3/leverage': 1,
|
|
291
|
+
'v1/marginType': 1,
|
|
292
|
+
'v3/marginType': 1,
|
|
293
|
+
'v1/positionMargin': 1,
|
|
294
|
+
'v3/positionMargin': 1,
|
|
295
|
+
'v1/listenKey': 1,
|
|
296
|
+
'v3/listenKey': 1,
|
|
297
|
+
// others
|
|
298
|
+
'v3/mmp': 1,
|
|
299
|
+
'v3/mmpReset': 1,
|
|
300
|
+
'v3/noop': 1,
|
|
301
|
+
// builder
|
|
302
|
+
'v3/approveAgent': 1,
|
|
303
|
+
'v3/updateAgent': 1,
|
|
304
|
+
'v3/approveBuilder': 1,
|
|
305
|
+
'v3/updateBuilder': 1,
|
|
306
|
+
},
|
|
307
|
+
'put': {
|
|
308
|
+
'v1/listenKey': 1,
|
|
309
|
+
'v3/listenKey': 1,
|
|
310
|
+
},
|
|
311
|
+
'delete': {
|
|
312
|
+
'v1/order': 1,
|
|
313
|
+
'v3/order': 1,
|
|
314
|
+
'v1/allOpenOrders': 1,
|
|
315
|
+
'v3/allOpenOrders': 1,
|
|
316
|
+
'v1/batchOrders': 1,
|
|
317
|
+
'v3/batchOrders': 1,
|
|
318
|
+
'v3/mmp': 1,
|
|
319
|
+
'v1/listenKey': 1,
|
|
320
|
+
'v3/listenKey': 1,
|
|
321
|
+
// builder
|
|
322
|
+
'v3/agent': 1,
|
|
323
|
+
'v3/builder': 1,
|
|
324
|
+
},
|
|
312
325
|
},
|
|
313
326
|
'sapiPublic': {
|
|
314
|
-
'get':
|
|
315
|
-
|
|
316
|
-
'v1/
|
|
317
|
-
'v1/
|
|
318
|
-
'v1/
|
|
319
|
-
'v1/
|
|
320
|
-
'v1/
|
|
321
|
-
'v1/
|
|
322
|
-
'v1/
|
|
323
|
-
'v1/
|
|
324
|
-
'v1/ticker/
|
|
325
|
-
'v1/ticker/
|
|
326
|
-
'v1/
|
|
327
|
-
|
|
327
|
+
'get': {
|
|
328
|
+
// v1
|
|
329
|
+
'v1/ping': 1,
|
|
330
|
+
'v1/time': 1,
|
|
331
|
+
'v1/exchangeInfo': 1,
|
|
332
|
+
'v1/depth': 1,
|
|
333
|
+
'v1/trades': 1,
|
|
334
|
+
'v1/historicalTrades': 1,
|
|
335
|
+
'v1/aggTrades': 1,
|
|
336
|
+
'v1/klines': 1,
|
|
337
|
+
'v1/ticker/24hr': 1,
|
|
338
|
+
'v1/ticker/price': 1,
|
|
339
|
+
'v1/ticker/bookTicker': 1,
|
|
340
|
+
'v1/aster/withdraw/estimateFee': 1,
|
|
341
|
+
// v3
|
|
342
|
+
'v3/ping': 1,
|
|
343
|
+
'v3/time': 1,
|
|
344
|
+
'v3/exchangeInfo': 1,
|
|
345
|
+
'v3/depth': { 'cost': 2, 'byLimit': [[50, 2], [100, 5], [500, 10], [1000, 20]] },
|
|
346
|
+
'v3/trades': 1,
|
|
347
|
+
'v3/historicalTrades': 20,
|
|
348
|
+
'v3/aggTrades': 20,
|
|
349
|
+
'v3/klines': { 'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]] },
|
|
350
|
+
'v3/ticker/24hr': { 'cost': 1, 'noSymbol': 40 },
|
|
351
|
+
'v3/ticker/price': { 'cost': 1, 'noSymbol': 2 },
|
|
352
|
+
'v3/ticker/bookTicker': { 'cost': 1, 'noSymbol': 2 },
|
|
353
|
+
'v3/aster/withdraw/estimateFee': 1,
|
|
354
|
+
},
|
|
328
355
|
},
|
|
329
356
|
'sapiPrivate': {
|
|
330
|
-
'get':
|
|
331
|
-
|
|
332
|
-
'v1/
|
|
333
|
-
'v1/
|
|
334
|
-
'v1/
|
|
335
|
-
'v1/
|
|
336
|
-
'v1/
|
|
337
|
-
'v1/
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
'
|
|
341
|
-
'
|
|
342
|
-
'
|
|
343
|
-
'
|
|
344
|
-
'
|
|
345
|
-
|
|
357
|
+
'get': {
|
|
358
|
+
// v1
|
|
359
|
+
'v1/commissionRate': 1,
|
|
360
|
+
'v1/order': 1,
|
|
361
|
+
'v1/openOrders': 1,
|
|
362
|
+
'v1/allOrders': 1,
|
|
363
|
+
'v1/transactionHistory': 1,
|
|
364
|
+
'v1/account': 1,
|
|
365
|
+
'v1/userTrades': 1,
|
|
366
|
+
// v3
|
|
367
|
+
'v3/commissionRate': { 'cost': 1, 'noSymbol': 2 },
|
|
368
|
+
'v3/order': 1,
|
|
369
|
+
'v3/openOrders': 1,
|
|
370
|
+
'v3/allOrders': 5,
|
|
371
|
+
'v3/account': 5,
|
|
372
|
+
'v3/userTrades': 5,
|
|
373
|
+
'v3/openOrder': 1,
|
|
374
|
+
},
|
|
375
|
+
'post': {
|
|
376
|
+
// v1
|
|
377
|
+
'v1/order': 1,
|
|
378
|
+
'v1/asset/wallet/transfer': 5,
|
|
379
|
+
'v1/asset/sendToAddress': 1,
|
|
380
|
+
'v1/listenKey': 1,
|
|
381
|
+
// v3
|
|
382
|
+
'v3/order': 1,
|
|
383
|
+
'v3/asset/wallet/transfer': 5,
|
|
384
|
+
'v3/aster/user-withdraw': 1,
|
|
385
|
+
'v3/listenKey': 1,
|
|
386
|
+
},
|
|
346
387
|
'put': [
|
|
347
388
|
'v1/listenKey',
|
|
389
|
+
'v3/listenKey',
|
|
348
390
|
],
|
|
349
|
-
'delete':
|
|
350
|
-
|
|
351
|
-
'v1/
|
|
352
|
-
'v1/
|
|
353
|
-
|
|
391
|
+
'delete': {
|
|
392
|
+
// v1
|
|
393
|
+
'v1/order': 1,
|
|
394
|
+
'v1/allOpenOrders': 1,
|
|
395
|
+
'v1/listenKey': 1,
|
|
396
|
+
// v3
|
|
397
|
+
'v3/allOpenOrders': 1,
|
|
398
|
+
'v3/order': 1,
|
|
399
|
+
'v3/listenKey': 1,
|
|
400
|
+
},
|
|
354
401
|
},
|
|
355
402
|
},
|
|
356
403
|
'timeframes': {
|
|
@@ -372,8 +419,9 @@ class aster extends aster$1["default"] {
|
|
|
372
419
|
},
|
|
373
420
|
'precisionMode': number.TICK_SIZE,
|
|
374
421
|
'requiredCredentials': {
|
|
375
|
-
'apiKey':
|
|
376
|
-
'secret':
|
|
422
|
+
'apiKey': false,
|
|
423
|
+
'secret': false,
|
|
424
|
+
'privateKey': true,
|
|
377
425
|
},
|
|
378
426
|
'fees': {
|
|
379
427
|
'trading': {
|
|
@@ -388,28 +436,35 @@ class aster extends aster$1["default"] {
|
|
|
388
436
|
'recvWindow': 10 * 1000,
|
|
389
437
|
'defaultTimeInForce': 'GTC',
|
|
390
438
|
'zeroAddress': '0x0000000000000000000000000000000000000000',
|
|
439
|
+
'v3ChainId': 1666,
|
|
391
440
|
'quoteOrderQty': true,
|
|
392
441
|
'accountsByType': {
|
|
393
442
|
'spot': 'SPOT',
|
|
443
|
+
'swap': 'FUTURE',
|
|
394
444
|
'future': 'FUTURE',
|
|
395
445
|
'linear': 'FUTURE',
|
|
396
|
-
'swap': 'FUTURE',
|
|
397
446
|
},
|
|
398
447
|
'networks': {
|
|
399
448
|
'ERC20': 'ETH',
|
|
400
449
|
'BEP20': 'BSC',
|
|
401
|
-
'
|
|
450
|
+
'ARBONE': 'Arbitrum',
|
|
402
451
|
},
|
|
403
452
|
'networksToChainId': {
|
|
404
453
|
'ETH': 1,
|
|
405
454
|
'BSC': 56,
|
|
406
455
|
'Arbitrum': 42161,
|
|
407
456
|
},
|
|
457
|
+
'fetchOpenOrders': {
|
|
458
|
+
'warnIfNoSymbol': true, // set to false to suppress warning when calling fetchOpenOrders without symbol
|
|
459
|
+
},
|
|
460
|
+
'builderFee': true,
|
|
461
|
+
'builder': '0x1F5877C19e3777Cfd15F9d57253eA4aA5254Ec39',
|
|
462
|
+
'builderRate': '0.001',
|
|
408
463
|
},
|
|
409
464
|
'exceptions': {
|
|
410
465
|
'exact': {
|
|
411
466
|
// 10xx - General Server or Network issues
|
|
412
|
-
'-1000': errors.
|
|
467
|
+
'-1000': errors.OperationRejected,
|
|
413
468
|
'-1001': errors.NetworkError,
|
|
414
469
|
'-1002': errors.AuthenticationError,
|
|
415
470
|
'-1003': errors.RateLimitExceeded,
|
|
@@ -417,7 +472,7 @@ class aster extends aster$1["default"] {
|
|
|
417
472
|
'-1005': errors.BadRequest,
|
|
418
473
|
'-1006': errors.BadResponse,
|
|
419
474
|
'-1007': errors.RequestTimeout,
|
|
420
|
-
'-1010': errors.
|
|
475
|
+
'-1010': errors.OperationRejected,
|
|
421
476
|
'-1011': errors.PermissionDenied,
|
|
422
477
|
'-1013': errors.BadRequest,
|
|
423
478
|
'-1014': errors.OrderNotFillable,
|
|
@@ -571,7 +626,9 @@ class aster extends aster$1["default"] {
|
|
|
571
626
|
'-4183': errors.InvalidOrder,
|
|
572
627
|
'-4184': errors.InvalidOrder,
|
|
573
628
|
'-5060': errors.OperationRejected,
|
|
574
|
-
'-5076': errors.OperationRejected,
|
|
629
|
+
'-5076': errors.OperationRejected,
|
|
630
|
+
// occured errors:
|
|
631
|
+
'-4168': errors.OperationRejected, // Unable to adjust to isolated-margin mode under the Multi-Assets mode.
|
|
575
632
|
},
|
|
576
633
|
'broad': {},
|
|
577
634
|
},
|
|
@@ -597,15 +654,15 @@ class aster extends aster$1["default"] {
|
|
|
597
654
|
* @method
|
|
598
655
|
* @name aster#fetchCurrencies
|
|
599
656
|
* @description fetches all available currencies on an exchange
|
|
600
|
-
* @see https://github.
|
|
601
|
-
* @see https://github.
|
|
657
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#trading-specification-information
|
|
658
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#exchange-information
|
|
602
659
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
603
660
|
* @returns {object} an associative dictionary of currencies
|
|
604
661
|
*/
|
|
605
662
|
async fetchCurrencies(params = {}) {
|
|
606
663
|
const promises = [
|
|
607
|
-
this.
|
|
608
|
-
this.
|
|
664
|
+
this.sapiPublicGetV3ExchangeInfo(params),
|
|
665
|
+
this.fapiPublicGetV3ExchangeInfo(params),
|
|
609
666
|
];
|
|
610
667
|
const results = await Promise.all(promises);
|
|
611
668
|
const sapiResult = this.safeDict(results, 0, {});
|
|
@@ -617,8 +674,8 @@ class aster extends aster$1["default"] {
|
|
|
617
674
|
// [
|
|
618
675
|
// {
|
|
619
676
|
// "asset": "USDT",
|
|
620
|
-
// "marginAvailable": true,
|
|
621
|
-
// "autoAssetExchange": "-10000"
|
|
677
|
+
// "marginAvailable": true, // only in PERP
|
|
678
|
+
// "autoAssetExchange": "-10000" // only in PERP
|
|
622
679
|
// }
|
|
623
680
|
// ]
|
|
624
681
|
//
|
|
@@ -661,263 +718,267 @@ class aster extends aster$1["default"] {
|
|
|
661
718
|
* @method
|
|
662
719
|
* @name aster#fetchMarkets
|
|
663
720
|
* @description retrieves data on all markets for bigone
|
|
664
|
-
* @see https://github.
|
|
665
|
-
* @see https://github.
|
|
721
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#trading-specification-information
|
|
722
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#exchange-information
|
|
666
723
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
667
724
|
* @returns {object[]} an array of objects representing market data
|
|
668
725
|
*/
|
|
669
726
|
async fetchMarkets(params = {}) {
|
|
670
727
|
const promises = [
|
|
671
|
-
this.
|
|
672
|
-
this.
|
|
728
|
+
this.sapiPublicGetV3ExchangeInfo(params),
|
|
729
|
+
this.fapiPublicGetV3ExchangeInfo(params),
|
|
673
730
|
];
|
|
731
|
+
promises.push(this.signIn());
|
|
674
732
|
const results = await Promise.all(promises);
|
|
675
733
|
const sapiResult = this.safeDict(results, 0, {});
|
|
676
734
|
const sapiRows = this.safeList(sapiResult, 'symbols', []);
|
|
677
735
|
const fapiResult = this.safeDict(results, 1, {});
|
|
678
736
|
const fapiRows = this.safeList(fapiResult, 'symbols', []);
|
|
679
|
-
|
|
737
|
+
//
|
|
738
|
+
// example:
|
|
680
739
|
//
|
|
681
740
|
// [
|
|
682
|
-
//
|
|
683
|
-
//
|
|
684
|
-
//
|
|
685
|
-
//
|
|
686
|
-
//
|
|
687
|
-
//
|
|
688
|
-
//
|
|
689
|
-
//
|
|
690
|
-
//
|
|
691
|
-
//
|
|
692
|
-
//
|
|
693
|
-
//
|
|
694
|
-
//
|
|
695
|
-
//
|
|
696
|
-
//
|
|
697
|
-
//
|
|
698
|
-
//
|
|
699
|
-
//
|
|
700
|
-
//
|
|
701
|
-
//
|
|
702
|
-
//
|
|
703
|
-
//
|
|
704
|
-
//
|
|
705
|
-
//
|
|
706
|
-
//
|
|
707
|
-
//
|
|
708
|
-
//
|
|
709
|
-
//
|
|
710
|
-
//
|
|
711
|
-
//
|
|
712
|
-
//
|
|
713
|
-
//
|
|
714
|
-
//
|
|
715
|
-
//
|
|
716
|
-
//
|
|
717
|
-
//
|
|
718
|
-
//
|
|
719
|
-
//
|
|
720
|
-
//
|
|
721
|
-
//
|
|
722
|
-
//
|
|
723
|
-
//
|
|
724
|
-
//
|
|
725
|
-
//
|
|
726
|
-
//
|
|
727
|
-
//
|
|
728
|
-
//
|
|
729
|
-
//
|
|
730
|
-
//
|
|
731
|
-
//
|
|
732
|
-
//
|
|
733
|
-
//
|
|
734
|
-
//
|
|
735
|
-
//
|
|
736
|
-
//
|
|
737
|
-
//
|
|
738
|
-
//
|
|
739
|
-
//
|
|
740
|
-
//
|
|
741
|
-
//
|
|
742
|
-
//
|
|
743
|
-
//
|
|
744
|
-
//
|
|
745
|
-
//
|
|
746
|
-
//
|
|
747
|
-
//
|
|
748
|
-
//
|
|
749
|
-
//
|
|
750
|
-
//
|
|
751
|
-
// "
|
|
752
|
-
//
|
|
753
|
-
//
|
|
754
|
-
//
|
|
755
|
-
//
|
|
756
|
-
//
|
|
757
|
-
//
|
|
758
|
-
//
|
|
741
|
+
// {
|
|
742
|
+
// symbol: "TESTUSDT",
|
|
743
|
+
// status: "TRADING",
|
|
744
|
+
// baseAsset: "TEST",
|
|
745
|
+
// quoteAsset: "USDT",
|
|
746
|
+
// pricePrecision: "2",
|
|
747
|
+
// quantityPrecision: "5",
|
|
748
|
+
// baseAssetPrecision: "8",
|
|
749
|
+
// quotePrecision: "8",
|
|
750
|
+
// listingTime: "1756289680210", // only in SPOT
|
|
751
|
+
// baseAssetAddress: null, // only in SPOT
|
|
752
|
+
// ocoAllowed: false, // only in SPOT
|
|
753
|
+
// pair: "ASTERUSDT", // only in PERP
|
|
754
|
+
// contractType: "PERPETUAL", // only in PERP
|
|
755
|
+
// deliveryDate: "4133404800000", // only in PERP
|
|
756
|
+
// onboardDate: "1758178800000", // only in PERP
|
|
757
|
+
// maintMarginPercent: "12.5000", // only in PERP
|
|
758
|
+
// requiredMarginPercent: "25.0000", // only in PERP
|
|
759
|
+
// marginAsset: "USDT", // only in PERP
|
|
760
|
+
// underlyingType: "COIN", // only in PERP
|
|
761
|
+
// underlyingSubType: [ "Top", ], // only in PERP
|
|
762
|
+
// symbolType: "0", // only in PERP
|
|
763
|
+
// tradingMode: "0", // only in PERP
|
|
764
|
+
// name: "", // only in PERP
|
|
765
|
+
// channel: "{}", // only in PERP
|
|
766
|
+
// sequenceNo: "100", // only in PERP
|
|
767
|
+
// twapMinNotional: "1000", // only in PERP
|
|
768
|
+
// imn: "4000.00", // only in PERP
|
|
769
|
+
// tags: [], // only in PERP
|
|
770
|
+
// settlePlan: "0", // only in PERP
|
|
771
|
+
// triggerProtect: "0.1500", // only in PERP
|
|
772
|
+
// liquidationFee: "0.025000", // only in PERP
|
|
773
|
+
// marketTakeBound: "0.05", // only in PERP
|
|
774
|
+
// createTime: "1758215451058", // only in PERP
|
|
775
|
+
// filters: [
|
|
776
|
+
// {
|
|
777
|
+
// minPrice: "0.01",
|
|
778
|
+
// maxPrice: "1000000",
|
|
779
|
+
// filterType: "PRICE_FILTER",
|
|
780
|
+
// tickSize: "0.01",
|
|
781
|
+
// },
|
|
782
|
+
// {
|
|
783
|
+
// stepSize: "0.00001",
|
|
784
|
+
// filterType: "LOT_SIZE",
|
|
785
|
+
// maxQty: "9000",
|
|
786
|
+
// minQty: "0.00001",
|
|
787
|
+
// },
|
|
788
|
+
// {
|
|
789
|
+
// stepSize: "0.00001",
|
|
790
|
+
// filterType: "MARKET_LOT_SIZE",
|
|
791
|
+
// maxQty: "9000",
|
|
792
|
+
// minQty: "0.00001",
|
|
793
|
+
// },
|
|
794
|
+
// {
|
|
795
|
+
// limit: "200",
|
|
796
|
+
// filterType: "MAX_NUM_ORDERS",
|
|
797
|
+
// },
|
|
798
|
+
// {
|
|
799
|
+
// minNotional: "5",
|
|
800
|
+
// filterType: "MIN_NOTIONAL",
|
|
801
|
+
// },
|
|
802
|
+
// {
|
|
803
|
+
// minNotional: "5",
|
|
804
|
+
// avgPriceMins: "5",
|
|
805
|
+
// applyMinToMarket: true,
|
|
806
|
+
// filterType: "NOTIONAL", // only in SPOT
|
|
807
|
+
// applyMaxToMarket: true,
|
|
808
|
+
// },
|
|
809
|
+
// {
|
|
810
|
+
// multiplierDown: "0.2",
|
|
811
|
+
// multiplierUp: "5",
|
|
812
|
+
// multiplierDecimal: "1",
|
|
813
|
+
// filterType: "PERCENT_PRICE",
|
|
814
|
+
// },
|
|
815
|
+
// {
|
|
816
|
+
// bidMultiplierUp: "5",
|
|
817
|
+
// askMultiplierUp: "5",
|
|
818
|
+
// bidMultiplierDown: "0.2",
|
|
819
|
+
// avgPriceMins: "5",
|
|
820
|
+
// multiplierDecimal: "1",
|
|
821
|
+
// filterType: "PERCENT_PRICE_BY_SIDE", // only in SPOT
|
|
822
|
+
// askMultiplierDown: "0.2",
|
|
823
|
+
// },
|
|
824
|
+
// ],
|
|
825
|
+
// orderTypes: [ "LIMIT", "MARKET", "STOP", "STOP_MARKET", "TAKE_PROFIT", "TAKE_PROFIT_MARKET", "TRAILING_STOP_MARKET", ],
|
|
826
|
+
// timeInForce: [ "GTC", "IOC", "FOK", "GTX", "HIDDEN", ],
|
|
827
|
+
// }
|
|
759
828
|
// ]
|
|
760
829
|
//
|
|
761
|
-
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
830
|
+
//
|
|
831
|
+
const rows = this.arrayConcat(sapiRows, fapiRows);
|
|
832
|
+
return this.parseMarkets(rows);
|
|
833
|
+
}
|
|
834
|
+
parseMarket(market) {
|
|
835
|
+
const id = this.safeString(market, 'symbol');
|
|
836
|
+
const baseId = this.safeString(market, 'baseAsset');
|
|
837
|
+
const quoteId = this.safeString(market, 'quoteAsset');
|
|
838
|
+
const base = this.safeCurrencyCode(baseId);
|
|
839
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
840
|
+
const active = this.safeString(market, 'status') === 'TRADING';
|
|
841
|
+
let spot = undefined;
|
|
842
|
+
let symbol = undefined;
|
|
843
|
+
let settle = undefined;
|
|
844
|
+
let settleId = undefined;
|
|
845
|
+
let swap = undefined;
|
|
846
|
+
let linear = undefined;
|
|
847
|
+
let inverse = undefined;
|
|
848
|
+
let contractSize = undefined;
|
|
849
|
+
const contractType = this.safeString(market, 'contractType');
|
|
850
|
+
const isContract = contractType !== undefined;
|
|
851
|
+
if (isContract) {
|
|
852
|
+
// currently, there is only perpetuals, not futures
|
|
853
|
+
spot = false;
|
|
854
|
+
swap = true;
|
|
855
|
+
settleId = this.safeString(market, 'marginAsset');
|
|
856
|
+
settle = this.safeCurrencyCode(settleId);
|
|
857
|
+
symbol = base + '/' + quote + ':' + settle;
|
|
858
|
+
linear = settle === quote;
|
|
859
|
+
inverse = settle === base;
|
|
860
|
+
contractSize = this.safeNumber2(market, 'contractSize', 'unit', this.parseNumber('1'));
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
spot = true;
|
|
864
|
+
swap = false;
|
|
865
|
+
symbol = base + '/' + quote;
|
|
866
|
+
}
|
|
867
|
+
// filters
|
|
868
|
+
const filters = this.safeList(market, 'filters', []);
|
|
869
|
+
const filtersByType = this.indexBy(filters, 'filterType');
|
|
870
|
+
const filterNotional = this.safeDict2(filtersByType, 'MIN_NOTIONAL', 'NOTIONAL');
|
|
871
|
+
const filterPrice = this.safeDict(filtersByType, 'PRICE_FILTER');
|
|
872
|
+
const filterLotSize = this.safeDict(filtersByType, 'LOT_SIZE');
|
|
873
|
+
const filterMarketLotSize = this.safeDict(filtersByType, 'MARKET_LOT_SIZE', {});
|
|
874
|
+
let pricePrecision = this.safeNumber(filterPrice, 'tickSize');
|
|
875
|
+
if (pricePrecision === undefined) {
|
|
876
|
+
pricePrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision')));
|
|
877
|
+
}
|
|
878
|
+
const amountPrecision = (filterLotSize !== undefined) ? this.safeNumber(filterLotSize, 'stepSize') : this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityPrecision')));
|
|
879
|
+
return this.safeMarketStructure({
|
|
880
|
+
'id': id,
|
|
881
|
+
'symbol': symbol,
|
|
882
|
+
'base': base,
|
|
883
|
+
'quote': quote,
|
|
884
|
+
'settle': settle,
|
|
885
|
+
'baseId': baseId,
|
|
886
|
+
'quoteId': quoteId,
|
|
887
|
+
'settleId': settleId,
|
|
888
|
+
'type': isContract ? 'swap' : 'spot',
|
|
889
|
+
'spot': spot,
|
|
890
|
+
'margin': false,
|
|
891
|
+
'swap': swap,
|
|
892
|
+
'future': false,
|
|
893
|
+
'option': false,
|
|
894
|
+
'active': active,
|
|
895
|
+
'contract': isContract,
|
|
896
|
+
'linear': linear,
|
|
897
|
+
'inverse': inverse,
|
|
898
|
+
'taker': this.fees['trading']['taker'],
|
|
899
|
+
'maker': this.fees['trading']['maker'],
|
|
900
|
+
'contractSize': contractSize,
|
|
901
|
+
'expiry': undefined,
|
|
902
|
+
'expiryDatetime': undefined,
|
|
903
|
+
'strike': undefined,
|
|
904
|
+
'optionType': undefined,
|
|
905
|
+
'precision': {
|
|
906
|
+
'amount': amountPrecision,
|
|
907
|
+
'price': pricePrecision,
|
|
908
|
+
'base': this.parseNumber(this.parsePrecision(this.safeString(market, 'baseAssetPrecision'))),
|
|
909
|
+
'quote': this.parseNumber(this.parsePrecision(this.safeString(market, 'quotePrecision'))),
|
|
910
|
+
},
|
|
911
|
+
'limits': {
|
|
912
|
+
'leverage': {
|
|
913
|
+
'min': undefined,
|
|
914
|
+
'max': undefined,
|
|
836
915
|
},
|
|
837
|
-
'
|
|
838
|
-
'
|
|
839
|
-
|
|
840
|
-
'max': undefined,
|
|
841
|
-
},
|
|
842
|
-
'amount': {
|
|
843
|
-
'min': undefined,
|
|
844
|
-
'max': undefined,
|
|
845
|
-
},
|
|
846
|
-
'price': {
|
|
847
|
-
'min': undefined,
|
|
848
|
-
'max': undefined,
|
|
849
|
-
},
|
|
850
|
-
'cost': {
|
|
851
|
-
'min': undefined,
|
|
852
|
-
'max': undefined,
|
|
853
|
-
},
|
|
916
|
+
'amount': {
|
|
917
|
+
'min': this.safeNumber(filterLotSize, 'minQty'),
|
|
918
|
+
'max': this.safeNumber(filterLotSize, 'maxQty'),
|
|
854
919
|
},
|
|
855
|
-
'
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
'
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
'max': this.safeNumber(filter, 'maxQty'),
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
|
-
if ('MARKET_LOT_SIZE' in filtersByType) {
|
|
875
|
-
const filter = this.safeDict(filtersByType, 'MARKET_LOT_SIZE', {});
|
|
876
|
-
entry['limits']['market'] = {
|
|
877
|
-
'min': this.safeNumber(filter, 'minQty'),
|
|
878
|
-
'max': this.safeNumber(filter, 'maxQty'),
|
|
879
|
-
};
|
|
880
|
-
}
|
|
881
|
-
if (('MIN_NOTIONAL' in filtersByType) || ('NOTIONAL' in filtersByType)) {
|
|
882
|
-
const filter = this.safeDict2(filtersByType, 'MIN_NOTIONAL', 'NOTIONAL', {});
|
|
883
|
-
entry['limits']['cost']['min'] = this.safeNumber(filter, 'notional');
|
|
884
|
-
}
|
|
885
|
-
result.push(entry);
|
|
886
|
-
}
|
|
887
|
-
return result;
|
|
920
|
+
'price': {
|
|
921
|
+
'min': this.safeNumber(filterPrice, 'minPrice'),
|
|
922
|
+
'max': this.safeNumber(filterPrice, 'maxPrice'),
|
|
923
|
+
},
|
|
924
|
+
'cost': {
|
|
925
|
+
'min': this.safeNumber2(filterNotional, 'notional', 'minNotional'),
|
|
926
|
+
'max': undefined,
|
|
927
|
+
},
|
|
928
|
+
'market': {
|
|
929
|
+
'min': this.safeNumber(filterMarketLotSize, 'minQty'),
|
|
930
|
+
'max': this.safeNumber(filterMarketLotSize, 'maxQty'),
|
|
931
|
+
},
|
|
932
|
+
},
|
|
933
|
+
'created': this.safeInteger2(market, 'listingTime', 'createTime'),
|
|
934
|
+
'info': market,
|
|
935
|
+
});
|
|
888
936
|
}
|
|
889
937
|
/**
|
|
890
938
|
* @method
|
|
891
939
|
* @name aster#fetchTime
|
|
892
940
|
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
|
893
|
-
* @see https://github.
|
|
941
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#get-server-time
|
|
942
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#check-server-time
|
|
894
943
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
895
944
|
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
|
896
945
|
*/
|
|
897
946
|
async fetchTime(params = {}) {
|
|
898
|
-
|
|
947
|
+
let marketType = undefined;
|
|
948
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchTime', undefined, params);
|
|
949
|
+
let response = undefined;
|
|
950
|
+
if (marketType === 'swap') {
|
|
951
|
+
response = await this.fapiPublicGetV3Time(params);
|
|
952
|
+
}
|
|
953
|
+
else {
|
|
954
|
+
response = await this.sapiPublicGetV3Time(params);
|
|
955
|
+
}
|
|
899
956
|
//
|
|
900
|
-
//
|
|
901
|
-
//
|
|
902
|
-
//
|
|
957
|
+
// both SPOT & PERP has same format
|
|
958
|
+
//
|
|
959
|
+
// {
|
|
960
|
+
// "serverTime": 1499827319559
|
|
961
|
+
// }
|
|
903
962
|
//
|
|
904
963
|
return this.safeInteger(response, 'serverTime');
|
|
905
964
|
}
|
|
906
965
|
parseOHLCV(ohlcv, market = undefined) {
|
|
966
|
+
//
|
|
967
|
+
// spot:
|
|
907
968
|
//
|
|
908
969
|
// [
|
|
909
|
-
//
|
|
910
|
-
// "
|
|
911
|
-
// "
|
|
912
|
-
// "
|
|
913
|
-
// "
|
|
914
|
-
// "
|
|
915
|
-
//
|
|
916
|
-
// "
|
|
917
|
-
//
|
|
918
|
-
// "
|
|
919
|
-
// "
|
|
920
|
-
// "0"
|
|
970
|
+
// 1499040000000, // Open time
|
|
971
|
+
// "0.01634790", // Open
|
|
972
|
+
// "0.80000000", // High
|
|
973
|
+
// "0.01575800", // Low
|
|
974
|
+
// "0.01577100", // Close
|
|
975
|
+
// "148976.11427815", // Volume
|
|
976
|
+
// 1499644799999, // Close time
|
|
977
|
+
// "2434.19055334", // Quote asset volume
|
|
978
|
+
// 308, // Number of trades
|
|
979
|
+
// "1756.87402397", // Taker buy base asset volume
|
|
980
|
+
// "28.46694368", // Taker buy quote asset volume
|
|
981
|
+
// "0" // ??
|
|
921
982
|
// ]
|
|
922
983
|
//
|
|
923
984
|
return [
|
|
@@ -933,8 +994,10 @@ class aster extends aster$1["default"] {
|
|
|
933
994
|
* @method
|
|
934
995
|
* @name aster#fetchOHLCV
|
|
935
996
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
936
|
-
* @see https://github.
|
|
937
|
-
* @see https://github.
|
|
997
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#k-line-data
|
|
998
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#klinecandlestick-data
|
|
999
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#index-price-klinecandlestick-data
|
|
1000
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#mark-price-klinecandlestick-data
|
|
938
1001
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
939
1002
|
* @param {string} timeframe the length of time each candle represents
|
|
940
1003
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -945,9 +1008,6 @@ class aster extends aster$1["default"] {
|
|
|
945
1008
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
946
1009
|
*/
|
|
947
1010
|
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
948
|
-
if (symbol === undefined) {
|
|
949
|
-
throw new errors.ArgumentsRequired(this.id + ' fetchOHLCV() requires a symbol argument');
|
|
950
|
-
}
|
|
951
1011
|
await this.loadMarkets();
|
|
952
1012
|
const market = this.market(symbol);
|
|
953
1013
|
let request = {};
|
|
@@ -955,10 +1015,7 @@ class aster extends aster$1["default"] {
|
|
|
955
1015
|
request['startTime'] = since;
|
|
956
1016
|
}
|
|
957
1017
|
if (limit !== undefined) {
|
|
958
|
-
|
|
959
|
-
limit = 1500; // Default 500; max 1500.
|
|
960
|
-
}
|
|
961
|
-
request['limit'] = limit;
|
|
1018
|
+
request['limit'] = Math.min(limit, 1500);
|
|
962
1019
|
}
|
|
963
1020
|
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
964
1021
|
request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
@@ -969,97 +1026,116 @@ class aster extends aster$1["default"] {
|
|
|
969
1026
|
let response = undefined;
|
|
970
1027
|
if (isMark) {
|
|
971
1028
|
request['symbol'] = market['id'];
|
|
972
|
-
response = await this.
|
|
1029
|
+
response = await this.fapiPublicGetV3MarkPriceKlines(this.extend(request, params));
|
|
973
1030
|
}
|
|
974
1031
|
else if (isIndex) {
|
|
975
1032
|
request['pair'] = market['id'];
|
|
976
|
-
response = await this.
|
|
1033
|
+
response = await this.fapiPublicGetV3IndexPriceKlines(this.extend(request, params));
|
|
977
1034
|
}
|
|
978
1035
|
else {
|
|
979
1036
|
request['symbol'] = market['id'];
|
|
980
1037
|
if (market['linear']) {
|
|
981
|
-
response = await this.
|
|
1038
|
+
response = await this.fapiPublicGetV3Klines(this.extend(request, params));
|
|
982
1039
|
}
|
|
983
1040
|
else {
|
|
984
|
-
response = await this.
|
|
1041
|
+
response = await this.sapiPublicGetV3Klines(this.extend(request, params));
|
|
985
1042
|
}
|
|
1043
|
+
//
|
|
1044
|
+
// both SPOT & PERP has same format
|
|
1045
|
+
//
|
|
1046
|
+
// [
|
|
1047
|
+
// [
|
|
1048
|
+
// 1499040000000, // Open time
|
|
1049
|
+
// "0.01634790", // Open
|
|
1050
|
+
// "0.80000000", // High
|
|
1051
|
+
// "0.01575800", // Low
|
|
1052
|
+
// "0.01577100", // Close
|
|
1053
|
+
// "148976.11427815", // Volume
|
|
1054
|
+
// 1499644799999, // Close time
|
|
1055
|
+
// "2434.19055334", // Quote asset volume
|
|
1056
|
+
// 308, // Number of trades
|
|
1057
|
+
// "1756.87402397", // Taker buy base asset volume
|
|
1058
|
+
// "28.46694368", // Taker buy quote asset volume,
|
|
1059
|
+
// "0"
|
|
1060
|
+
// ]
|
|
1061
|
+
// ]
|
|
1062
|
+
//
|
|
986
1063
|
}
|
|
987
|
-
//
|
|
988
|
-
// [
|
|
989
|
-
// [
|
|
990
|
-
// 1631158560000,
|
|
991
|
-
// "208.1850",
|
|
992
|
-
// "208.1850",
|
|
993
|
-
// "208.1850",
|
|
994
|
-
// "208.1850",
|
|
995
|
-
// "11.84",
|
|
996
|
-
// 1631158619999,
|
|
997
|
-
// "2464.910400",
|
|
998
|
-
// 1,
|
|
999
|
-
// "11.84",
|
|
1000
|
-
// "2464.910400",
|
|
1001
|
-
// "0"
|
|
1002
|
-
// ]
|
|
1003
|
-
// ]
|
|
1004
|
-
//
|
|
1005
1064
|
return this.parseOHLCVs(response, market, timeframe, since, limit);
|
|
1006
1065
|
}
|
|
1007
1066
|
parseTrade(trade, market = undefined) {
|
|
1008
1067
|
//
|
|
1009
1068
|
// fetchTrades
|
|
1010
1069
|
//
|
|
1070
|
+
// recent trades:
|
|
1071
|
+
//
|
|
1011
1072
|
// {
|
|
1012
1073
|
// "id": 3913206,
|
|
1013
1074
|
// "price": "644.100",
|
|
1014
1075
|
// "qty": "0.08",
|
|
1015
|
-
// "quoteQty": "51.528",
|
|
1076
|
+
// "quoteQty": "51.528", // present in PERP
|
|
1077
|
+
// "baseQty": "4.95049505", // present in SPOT
|
|
1016
1078
|
// "time": 1749784506633,
|
|
1017
1079
|
// "isBuyerMaker": true
|
|
1018
1080
|
// }
|
|
1019
1081
|
//
|
|
1082
|
+
// aggrTrades
|
|
1083
|
+
//
|
|
1020
1084
|
// {
|
|
1021
|
-
// "
|
|
1022
|
-
// "
|
|
1023
|
-
// "
|
|
1024
|
-
// "
|
|
1025
|
-
// "
|
|
1026
|
-
// "
|
|
1085
|
+
// "a": 26129, // Aggregate tradeId
|
|
1086
|
+
// "p": "0.01633102", // Price
|
|
1087
|
+
// "q": "4.70443515", // Quantity
|
|
1088
|
+
// "f": 27781, // First tradeId
|
|
1089
|
+
// "l": 27781, // Last tradeId
|
|
1090
|
+
// "T": 1498793709153, // Timestamp
|
|
1091
|
+
// "m": true, // Was the buyer the maker?
|
|
1027
1092
|
// }
|
|
1028
1093
|
//
|
|
1029
|
-
// fetchMyTrades
|
|
1094
|
+
// fetchMyTrades (SPOT & PERP have similar format)
|
|
1030
1095
|
//
|
|
1031
|
-
//
|
|
1032
|
-
//
|
|
1033
|
-
//
|
|
1034
|
-
//
|
|
1035
|
-
//
|
|
1036
|
-
//
|
|
1037
|
-
//
|
|
1038
|
-
//
|
|
1039
|
-
//
|
|
1040
|
-
//
|
|
1041
|
-
//
|
|
1042
|
-
//
|
|
1043
|
-
//
|
|
1044
|
-
//
|
|
1045
|
-
//
|
|
1046
|
-
//
|
|
1096
|
+
// {
|
|
1097
|
+
// "symbol": "ETHUSDT",
|
|
1098
|
+
// "id": 2583152,
|
|
1099
|
+
// "orderId": 418588675,
|
|
1100
|
+
// "side": "SELL",
|
|
1101
|
+
// "price": "2330.04",
|
|
1102
|
+
// "qty": "0.0030",
|
|
1103
|
+
// "quoteQty": "6.99000000",
|
|
1104
|
+
// "commission": "0.00279605",
|
|
1105
|
+
// "commissionAsset": "USDT",
|
|
1106
|
+
// "time": 1776409179230,
|
|
1107
|
+
// "counterpartyId": 5143150, // only in SPOT
|
|
1108
|
+
// "createUpdateId": null, // only in SPOT
|
|
1109
|
+
// "maker": false, // only in SPOT
|
|
1110
|
+
// "buyer": false, // only in SPOT
|
|
1111
|
+
// "realizedPnl": "0.00029999", // only in PERP
|
|
1112
|
+
// "marginAsset": "USDT", // only in PERP
|
|
1113
|
+
// "positionSide": "BOTH", // only in PERP
|
|
1114
|
+
// }
|
|
1047
1115
|
//
|
|
1048
|
-
const id = this.
|
|
1049
|
-
const
|
|
1050
|
-
const
|
|
1116
|
+
const id = this.safeString2(trade, 'id', 'a');
|
|
1117
|
+
const marketId = this.safeString(trade, 'symbol');
|
|
1118
|
+
const marketType = ('positionSide' in trade) ? 'swap' : 'spot';
|
|
1119
|
+
market = this.safeMarket(marketId, market, undefined, marketType);
|
|
1120
|
+
const currencyId = this.safeString2(trade, 'commissionAsset', 'marginAsset');
|
|
1051
1121
|
const currencyCode = this.safeCurrencyCode(currencyId);
|
|
1052
|
-
const amountString = this.
|
|
1053
|
-
const priceString = this.
|
|
1122
|
+
const amountString = this.safeString2(trade, 'qty', 'q');
|
|
1123
|
+
const priceString = this.safeString2(trade, 'price', 'p');
|
|
1054
1124
|
const costString = this.safeString2(trade, 'quoteQty', 'baseQty');
|
|
1055
|
-
const timestamp = this.
|
|
1125
|
+
const timestamp = this.safeInteger2(trade, 'time', 'T');
|
|
1056
1126
|
let side = this.safeStringLower(trade, 'side');
|
|
1057
1127
|
const isMaker = this.safeBool(trade, 'maker');
|
|
1058
1128
|
let takerOrMaker = undefined;
|
|
1059
1129
|
if (isMaker !== undefined) {
|
|
1060
1130
|
takerOrMaker = isMaker ? 'maker' : 'taker';
|
|
1131
|
+
if (side === undefined) {
|
|
1132
|
+
const isBuyer = this.safeBool(trade, 'buyer');
|
|
1133
|
+
if (isBuyer !== undefined) {
|
|
1134
|
+
side = isBuyer ? 'buy' : 'sell';
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1061
1137
|
}
|
|
1062
|
-
const isBuyerMaker = this.
|
|
1138
|
+
const isBuyerMaker = this.safeBool2(trade, 'isBuyerMaker', 'm');
|
|
1063
1139
|
if (isBuyerMaker !== undefined) {
|
|
1064
1140
|
side = isBuyerMaker ? 'sell' : 'buy';
|
|
1065
1141
|
}
|
|
@@ -1068,7 +1144,7 @@ class aster extends aster$1["default"] {
|
|
|
1068
1144
|
'info': trade,
|
|
1069
1145
|
'timestamp': timestamp,
|
|
1070
1146
|
'datetime': this.iso8601(timestamp),
|
|
1071
|
-
'symbol': symbol,
|
|
1147
|
+
'symbol': market['symbol'],
|
|
1072
1148
|
'order': this.safeString(trade, 'orderId'),
|
|
1073
1149
|
'type': undefined,
|
|
1074
1150
|
'side': side,
|
|
@@ -1086,8 +1162,10 @@ class aster extends aster$1["default"] {
|
|
|
1086
1162
|
* @method
|
|
1087
1163
|
* @name aster#fetchTrades
|
|
1088
1164
|
* @description get the list of most recent trades for a particular symbol
|
|
1089
|
-
* @see https://github.
|
|
1090
|
-
* @see https://github.
|
|
1165
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#recent-trades-list
|
|
1166
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#recent-trades-aggregated
|
|
1167
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#recent-trades-list
|
|
1168
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#compressedaggregate-trades-list
|
|
1091
1169
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
1092
1170
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
1093
1171
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -1095,48 +1173,68 @@ class aster extends aster$1["default"] {
|
|
|
1095
1173
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
1096
1174
|
*/
|
|
1097
1175
|
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
1098
|
-
if (symbol === undefined) {
|
|
1099
|
-
throw new errors.ArgumentsRequired(this.id + ' fetchTrades() requires a symbol argument');
|
|
1100
|
-
}
|
|
1101
1176
|
await this.loadMarkets();
|
|
1102
1177
|
const market = this.market(symbol);
|
|
1103
|
-
|
|
1178
|
+
let request = {
|
|
1104
1179
|
'symbol': market['id'],
|
|
1105
1180
|
};
|
|
1106
1181
|
if (limit !== undefined) {
|
|
1107
|
-
|
|
1108
|
-
limit = 1000; // Default 500; max 1000.
|
|
1109
|
-
}
|
|
1110
|
-
request['limit'] = limit;
|
|
1182
|
+
request['limit'] = Math.min(limit, 1000);
|
|
1111
1183
|
}
|
|
1112
1184
|
let response = undefined;
|
|
1113
|
-
|
|
1114
|
-
|
|
1185
|
+
const sinceDefined = since !== undefined;
|
|
1186
|
+
const untilDefined = ('until' in params);
|
|
1187
|
+
if (sinceDefined) {
|
|
1188
|
+
request['startTime'] = since;
|
|
1189
|
+
}
|
|
1190
|
+
if (untilDefined) {
|
|
1191
|
+
request = this.handleUntilOption('endTime', request, params);
|
|
1192
|
+
}
|
|
1193
|
+
// use historical endpoint for targeted requests
|
|
1194
|
+
if ('startTime' in request) {
|
|
1195
|
+
if (market['swap']) {
|
|
1196
|
+
response = await this.fapiPublicGetV3AggTrades(this.extend(request, params));
|
|
1197
|
+
}
|
|
1198
|
+
else {
|
|
1199
|
+
response = await this.sapiPublicGetV3AggTrades(this.extend(request, params));
|
|
1200
|
+
}
|
|
1115
1201
|
//
|
|
1116
|
-
//
|
|
1117
|
-
//
|
|
1118
|
-
//
|
|
1119
|
-
//
|
|
1120
|
-
//
|
|
1121
|
-
//
|
|
1122
|
-
//
|
|
1123
|
-
//
|
|
1124
|
-
//
|
|
1125
|
-
//
|
|
1202
|
+
// both FAPI and SAPI have same response format
|
|
1203
|
+
//
|
|
1204
|
+
// [
|
|
1205
|
+
// {
|
|
1206
|
+
// "a": 26129, // Aggregate tradeId
|
|
1207
|
+
// "p": "0.01633102", // Price
|
|
1208
|
+
// "q": "4.70443515", // Quantity
|
|
1209
|
+
// "f": 27781, // First tradeId
|
|
1210
|
+
// "l": 27781, // Last tradeId
|
|
1211
|
+
// "T": 1498793709153, // Timestamp
|
|
1212
|
+
// "m": true, // Was the buyer the maker?
|
|
1213
|
+
// }
|
|
1214
|
+
// ]
|
|
1126
1215
|
//
|
|
1127
1216
|
}
|
|
1128
1217
|
else {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
//
|
|
1136
|
-
//
|
|
1137
|
-
//
|
|
1138
|
-
//
|
|
1139
|
-
//
|
|
1218
|
+
if (market['swap']) {
|
|
1219
|
+
response = await this.fapiPublicGetV3Trades(this.extend(request, params));
|
|
1220
|
+
}
|
|
1221
|
+
else {
|
|
1222
|
+
response = await this.sapiPublicGetV3Trades(this.extend(request, params));
|
|
1223
|
+
}
|
|
1224
|
+
//
|
|
1225
|
+
// SAPI & FAPI have only one field difference
|
|
1226
|
+
//
|
|
1227
|
+
// [
|
|
1228
|
+
// {
|
|
1229
|
+
// "id": "73620768",
|
|
1230
|
+
// "price": "2324.07",
|
|
1231
|
+
// "qty": "0.430",
|
|
1232
|
+
// "quoteQty": "999.35", // only in PERP
|
|
1233
|
+
// "baseQty": "4.95049505", // only in SPOT
|
|
1234
|
+
// "time": "1776407252900",
|
|
1235
|
+
// "isBuyerMaker": false
|
|
1236
|
+
// }, ...
|
|
1237
|
+
//
|
|
1140
1238
|
}
|
|
1141
1239
|
return this.parseTrades(response, market, since, limit);
|
|
1142
1240
|
}
|
|
@@ -1144,8 +1242,8 @@ class aster extends aster$1["default"] {
|
|
|
1144
1242
|
* @method
|
|
1145
1243
|
* @name aster#fetchMyTrades
|
|
1146
1244
|
* @description fetch all trades made by the user
|
|
1147
|
-
* @see https://github.
|
|
1148
|
-
* @see https://github.
|
|
1245
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#account-trade-history-user_data
|
|
1246
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#account-trade-list-user_data
|
|
1149
1247
|
* @param {string} [symbol] unified market symbol
|
|
1150
1248
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1151
1249
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
@@ -1154,50 +1252,51 @@ class aster extends aster$1["default"] {
|
|
|
1154
1252
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1155
1253
|
*/
|
|
1156
1254
|
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1157
|
-
|
|
1158
|
-
|
|
1255
|
+
await this.loadMarketsAndSignIn();
|
|
1256
|
+
let request = {};
|
|
1257
|
+
let market = undefined;
|
|
1258
|
+
if (symbol !== undefined) {
|
|
1259
|
+
market = this.market(symbol);
|
|
1260
|
+
request['symbol'] = market['id'];
|
|
1159
1261
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
let request = {
|
|
1163
|
-
'symbol': market['id'],
|
|
1164
|
-
};
|
|
1262
|
+
let marketType = undefined;
|
|
1263
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
1165
1264
|
if (since !== undefined) {
|
|
1166
1265
|
request['startTime'] = since;
|
|
1167
1266
|
}
|
|
1168
1267
|
if (limit !== undefined) {
|
|
1169
|
-
|
|
1170
|
-
limit = 1000; // Default 500; max 1000.
|
|
1171
|
-
}
|
|
1172
|
-
request['limit'] = limit;
|
|
1268
|
+
request['limit'] = Math.min(limit, 1000);
|
|
1173
1269
|
}
|
|
1174
1270
|
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
1175
1271
|
let response = undefined;
|
|
1176
|
-
if (
|
|
1177
|
-
response = await this.
|
|
1272
|
+
if (marketType === 'swap') {
|
|
1273
|
+
response = await this.fapiPrivateGetV3UserTrades(this.extend(request, params));
|
|
1178
1274
|
}
|
|
1179
1275
|
else {
|
|
1180
|
-
response = await this.
|
|
1276
|
+
response = await this.sapiPrivateGetV3UserTrades(this.extend(request, params));
|
|
1181
1277
|
}
|
|
1182
1278
|
//
|
|
1183
|
-
//
|
|
1184
|
-
//
|
|
1185
|
-
//
|
|
1186
|
-
//
|
|
1187
|
-
//
|
|
1188
|
-
//
|
|
1189
|
-
//
|
|
1190
|
-
//
|
|
1191
|
-
//
|
|
1192
|
-
//
|
|
1193
|
-
//
|
|
1194
|
-
//
|
|
1195
|
-
//
|
|
1196
|
-
//
|
|
1197
|
-
//
|
|
1198
|
-
//
|
|
1199
|
-
//
|
|
1200
|
-
//
|
|
1279
|
+
// SPOT & PERP have similar format
|
|
1280
|
+
//
|
|
1281
|
+
// {
|
|
1282
|
+
// "symbol": "ETHUSDT",
|
|
1283
|
+
// "id": 2583152,
|
|
1284
|
+
// "orderId": 418588675,
|
|
1285
|
+
// "side": "SELL",
|
|
1286
|
+
// "price": "2330.04",
|
|
1287
|
+
// "qty": "0.0030",
|
|
1288
|
+
// "quoteQty": "6.99000000",
|
|
1289
|
+
// "commission": "0.00279605",
|
|
1290
|
+
// "commissionAsset": "USDT",
|
|
1291
|
+
// "time": 1776409179230,
|
|
1292
|
+
// "counterpartyId": 5143150, // only in PERP
|
|
1293
|
+
// "createUpdateId": null, // only in PERP
|
|
1294
|
+
// "maker": false, // only in PERP
|
|
1295
|
+
// "buyer": false, // only in PERP
|
|
1296
|
+
// "realizedPnl": "0.00029999", // only in SPOT
|
|
1297
|
+
// "marginAsset": "USDT", // only in SPOT
|
|
1298
|
+
// "positionSide": "BOTH", // only in SPOT
|
|
1299
|
+
// }
|
|
1201
1300
|
//
|
|
1202
1301
|
return this.parseTrades(response, market, since, limit, params);
|
|
1203
1302
|
}
|
|
@@ -1205,37 +1304,32 @@ class aster extends aster$1["default"] {
|
|
|
1205
1304
|
* @method
|
|
1206
1305
|
* @name aster#fetchOrderBook
|
|
1207
1306
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
1208
|
-
* @see https://github.
|
|
1209
|
-
* @see https://github.
|
|
1307
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#depth-information
|
|
1308
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#order-book
|
|
1210
1309
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
1211
1310
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
1212
1311
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1213
1312
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
1214
1313
|
*/
|
|
1215
1314
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
1216
|
-
if (symbol === undefined) {
|
|
1217
|
-
throw new errors.ArgumentsRequired(this.id + ' fetchOrderBook() requires a symbol argument');
|
|
1218
|
-
}
|
|
1219
1315
|
await this.loadMarkets();
|
|
1220
1316
|
const market = this.market(symbol);
|
|
1221
1317
|
const request = {
|
|
1222
1318
|
'symbol': market['id'],
|
|
1223
1319
|
};
|
|
1320
|
+
let response = undefined;
|
|
1224
1321
|
if (limit !== undefined) {
|
|
1225
|
-
|
|
1226
|
-
if (limit > 1000) {
|
|
1227
|
-
limit = 1000; // Default 500; max 1000.
|
|
1228
|
-
}
|
|
1229
|
-
request['limit'] = limit;
|
|
1322
|
+
request['limit'] = this.findNearestCeiling([5, 10, 20, 50, 100, 500, 1000], limit);
|
|
1230
1323
|
}
|
|
1231
|
-
let response = undefined;
|
|
1232
1324
|
if (market['swap']) {
|
|
1233
|
-
response = await this.
|
|
1325
|
+
response = await this.fapiPublicGetV3Depth(this.extend(request, params));
|
|
1234
1326
|
}
|
|
1235
1327
|
else {
|
|
1236
|
-
response = await this.
|
|
1328
|
+
response = await this.sapiPublicGetV3Depth(this.extend(request, params));
|
|
1237
1329
|
}
|
|
1238
1330
|
//
|
|
1331
|
+
// both SPOT & PERP has same format
|
|
1332
|
+
//
|
|
1239
1333
|
// {
|
|
1240
1334
|
// "lastUpdateId": 1027024,
|
|
1241
1335
|
// "E": 1589436922972, // Message output time
|
|
@@ -1257,118 +1351,50 @@ class aster extends aster$1["default"] {
|
|
|
1257
1351
|
const timestamp = this.safeInteger(response, 'T');
|
|
1258
1352
|
return this.parseOrderBook(response, symbol, timestamp, 'bids', 'asks');
|
|
1259
1353
|
}
|
|
1260
|
-
|
|
1261
|
-
* @method
|
|
1262
|
-
* @name aster#fetchFundingRateHistory
|
|
1263
|
-
* @description fetches historical funding rate prices
|
|
1264
|
-
* @see https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#get-funding-rate-history
|
|
1265
|
-
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
|
|
1266
|
-
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
|
1267
|
-
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
|
|
1268
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1269
|
-
* @param {int} [params.until] timestamp in ms of the latest funding rate
|
|
1270
|
-
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
|
1271
|
-
*/
|
|
1272
|
-
async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1273
|
-
await this.loadMarkets();
|
|
1274
|
-
let request = {};
|
|
1275
|
-
if (symbol !== undefined) {
|
|
1276
|
-
const market = this.market(symbol);
|
|
1277
|
-
request['symbol'] = market['id'];
|
|
1278
|
-
}
|
|
1279
|
-
if (since !== undefined) {
|
|
1280
|
-
request['startTime'] = since;
|
|
1281
|
-
}
|
|
1282
|
-
if (limit !== undefined) {
|
|
1283
|
-
if (limit > 1000) {
|
|
1284
|
-
limit = 1000; // Default 100; max 1000
|
|
1285
|
-
}
|
|
1286
|
-
request['limit'] = limit;
|
|
1287
|
-
}
|
|
1288
|
-
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
1289
|
-
const response = await this.fapiPublicGetV1FundingRate(this.extend(request, params));
|
|
1354
|
+
parseTicker(ticker, market = undefined) {
|
|
1290
1355
|
//
|
|
1291
|
-
//
|
|
1292
|
-
// {
|
|
1293
|
-
// "symbol": "BTCUSDT",
|
|
1294
|
-
// "fundingTime": 1747209600000,
|
|
1295
|
-
// "fundingRate": "0.00010000"
|
|
1296
|
-
// }
|
|
1297
|
-
// ]
|
|
1356
|
+
// fetchTicker & fetchTickers: both SPOT & PERP has similar format
|
|
1298
1357
|
//
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1358
|
+
// {
|
|
1359
|
+
// "symbol": "ETHUSDT",
|
|
1360
|
+
// "priceChange": "6.54",
|
|
1361
|
+
// "priceChangePercent": "0.279",
|
|
1362
|
+
// "weightedAvgPrice": "2330.70",
|
|
1363
|
+
// "lastPrice": "2350.00",
|
|
1364
|
+
// "lastQty": "4.437",
|
|
1365
|
+
// "openPrice": "2343.46",
|
|
1366
|
+
// "highPrice": "2363.20",
|
|
1367
|
+
// "lowPrice": "2283.86",
|
|
1368
|
+
// "volume": "267154.248",
|
|
1369
|
+
// "quoteVolume": "622657018.70",
|
|
1370
|
+
// "openTime": "1776329400000",
|
|
1371
|
+
// "closeTime": "1776415832593",
|
|
1372
|
+
// "firstId": "73520536",
|
|
1373
|
+
// "lastId": "73630176",
|
|
1374
|
+
// "count": "109640",
|
|
1375
|
+
// "baseAsset": "BTC", // only in SPOT
|
|
1376
|
+
// "quoteAsset": "USDT", // only in SPOT
|
|
1377
|
+
// "bidPrice": "71125.98", // only in SPOT
|
|
1378
|
+
// "bidQty": "0.00737", // only in SPOT
|
|
1379
|
+
// "askPrice": "71152.10", // only in SPOT
|
|
1380
|
+
// "askQty": "0.32399" // only in SPOT
|
|
1381
|
+
// }
|
|
1315
1382
|
//
|
|
1316
|
-
//
|
|
1317
|
-
//
|
|
1318
|
-
//
|
|
1319
|
-
//
|
|
1320
|
-
//
|
|
1321
|
-
//
|
|
1322
|
-
//
|
|
1323
|
-
//
|
|
1324
|
-
//
|
|
1325
|
-
//
|
|
1326
|
-
//
|
|
1327
|
-
//
|
|
1328
|
-
//
|
|
1329
|
-
// "openTime": "1760578800000",
|
|
1330
|
-
// "closeTime": "1760665024749",
|
|
1331
|
-
// "firstId": "37447",
|
|
1332
|
-
// "lastId": "39698",
|
|
1333
|
-
// "count": "2252",
|
|
1334
|
-
// "baseAsset": "BTC",
|
|
1335
|
-
// "quoteAsset": "USDT",
|
|
1336
|
-
// "bidPrice": "108705.11",
|
|
1337
|
-
// "bidQty": "0.03351",
|
|
1338
|
-
// "askPrice": "108725.99",
|
|
1339
|
-
// "askQty": "0.08724"
|
|
1340
|
-
// }
|
|
1341
|
-
// swap
|
|
1342
|
-
// {
|
|
1343
|
-
// "symbol": "BTCUSDT",
|
|
1344
|
-
// "priceChange": "1845.7",
|
|
1345
|
-
// "priceChangePercent": "1.755",
|
|
1346
|
-
// "weightedAvgPrice": "105515.5",
|
|
1347
|
-
// "lastPrice": "107037.7",
|
|
1348
|
-
// "lastQty": "0.004",
|
|
1349
|
-
// "openPrice": "105192.0",
|
|
1350
|
-
// "highPrice": "107223.5",
|
|
1351
|
-
// "lowPrice": "104431.6",
|
|
1352
|
-
// "volume": "8753.286",
|
|
1353
|
-
// "quoteVolume": "923607368.61",
|
|
1354
|
-
// "openTime": 1749976620000,
|
|
1355
|
-
// "closeTime": 1750063053754,
|
|
1356
|
-
// "firstId": 24195078,
|
|
1357
|
-
// "lastId": 24375783,
|
|
1358
|
-
// "count": 180706
|
|
1359
|
-
// }
|
|
1383
|
+
//
|
|
1384
|
+
// fetchBidsAsks: SPOT & PERP have only one field difference
|
|
1385
|
+
//
|
|
1386
|
+
// [
|
|
1387
|
+
// {
|
|
1388
|
+
// "symbol": "BMTUSDT",
|
|
1389
|
+
// "bidPrice": "0.004000",
|
|
1390
|
+
// "bidQty": "1250.0",
|
|
1391
|
+
// "askPrice": "0.000000",
|
|
1392
|
+
// "askQty": "0.0",
|
|
1393
|
+
// "time": "1776411276072",
|
|
1394
|
+
// "lastUpdateId": "453174307613" // only in PERP
|
|
1395
|
+
// }, ...
|
|
1360
1396
|
//
|
|
1361
1397
|
const timestamp = this.safeInteger(ticker, 'closeTime');
|
|
1362
|
-
let marketType = undefined;
|
|
1363
|
-
if ('bidQty' in ticker) {
|
|
1364
|
-
marketType = 'spot';
|
|
1365
|
-
}
|
|
1366
|
-
else {
|
|
1367
|
-
marketType = 'contract';
|
|
1368
|
-
}
|
|
1369
|
-
const marketId = this.safeString(ticker, 'symbol');
|
|
1370
|
-
market = this.safeMarket(marketId, market, undefined, marketType);
|
|
1371
|
-
const symbol = market['symbol'];
|
|
1372
1398
|
const last = this.safeString(ticker, 'lastPrice');
|
|
1373
1399
|
const open = this.safeString(ticker, 'openPrice');
|
|
1374
1400
|
let percentage = this.safeString(ticker, 'priceChangePercent');
|
|
@@ -1377,8 +1403,18 @@ class aster extends aster$1["default"] {
|
|
|
1377
1403
|
const baseVolume = this.safeString(ticker, 'volume');
|
|
1378
1404
|
const high = this.safeString(ticker, 'highPrice');
|
|
1379
1405
|
const low = this.safeString(ticker, 'lowPrice');
|
|
1406
|
+
const isTickerResponse = ('priceChange' in ticker);
|
|
1407
|
+
let marketType = undefined;
|
|
1408
|
+
if (isTickerResponse) {
|
|
1409
|
+
marketType = ('baseAsset' in ticker) ? 'spot' : 'swap';
|
|
1410
|
+
}
|
|
1411
|
+
else {
|
|
1412
|
+
marketType = ('lastUpdateId' in ticker) ? 'swap' : 'spot';
|
|
1413
|
+
}
|
|
1414
|
+
const marketId = this.safeString(ticker, 'symbol');
|
|
1415
|
+
market = this.safeMarket(marketId, market, undefined, marketType);
|
|
1380
1416
|
return this.safeTicker({
|
|
1381
|
-
'symbol': symbol,
|
|
1417
|
+
'symbol': market['symbol'],
|
|
1382
1418
|
'timestamp': timestamp,
|
|
1383
1419
|
'datetime': this.iso8601(timestamp),
|
|
1384
1420
|
'high': high,
|
|
@@ -1406,16 +1442,13 @@ class aster extends aster$1["default"] {
|
|
|
1406
1442
|
* @method
|
|
1407
1443
|
* @name aster#fetchTicker
|
|
1408
1444
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
1409
|
-
* @see https://github.
|
|
1410
|
-
* @see https://github.
|
|
1445
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#24h-price-change
|
|
1446
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#24hr-ticker-price-change-statistics
|
|
1411
1447
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
1412
1448
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1413
1449
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1414
1450
|
*/
|
|
1415
1451
|
async fetchTicker(symbol, params = {}) {
|
|
1416
|
-
if (symbol === undefined) {
|
|
1417
|
-
throw new errors.ArgumentsRequired(this.id + ' fetchTicker() requires a symbol argument');
|
|
1418
|
-
}
|
|
1419
1452
|
await this.loadMarkets();
|
|
1420
1453
|
const market = this.market(symbol);
|
|
1421
1454
|
const request = {
|
|
@@ -1423,63 +1456,47 @@ class aster extends aster$1["default"] {
|
|
|
1423
1456
|
};
|
|
1424
1457
|
let response = undefined;
|
|
1425
1458
|
if (market['swap']) {
|
|
1426
|
-
response = await this.
|
|
1427
|
-
//
|
|
1428
|
-
// {
|
|
1429
|
-
// "symbol": "BTCUSDT",
|
|
1430
|
-
// "priceChange": "1845.7",
|
|
1431
|
-
// "priceChangePercent": "1.755",
|
|
1432
|
-
// "weightedAvgPrice": "105515.5",
|
|
1433
|
-
// "lastPrice": "107037.7",
|
|
1434
|
-
// "lastQty": "0.004",
|
|
1435
|
-
// "openPrice": "105192.0",
|
|
1436
|
-
// "highPrice": "107223.5",
|
|
1437
|
-
// "lowPrice": "104431.6",
|
|
1438
|
-
// "volume": "8753.286",
|
|
1439
|
-
// "quoteVolume": "923607368.61",
|
|
1440
|
-
// "openTime": 1749976620000,
|
|
1441
|
-
// "closeTime": 1750063053754,
|
|
1442
|
-
// "firstId": 24195078,
|
|
1443
|
-
// "lastId": 24375783,
|
|
1444
|
-
// "count": 180706
|
|
1445
|
-
// }
|
|
1446
|
-
//
|
|
1459
|
+
response = await this.fapiPublicGetV3Ticker24hr(this.extend(request, params));
|
|
1447
1460
|
}
|
|
1448
1461
|
else {
|
|
1449
|
-
response = await this.
|
|
1450
|
-
// {
|
|
1451
|
-
// "symbol": "BTCUSDT",
|
|
1452
|
-
// "priceChange": "-2274.38",
|
|
1453
|
-
// "priceChangePercent": "-2.049",
|
|
1454
|
-
// "weightedAvgPrice": "109524.37084136",
|
|
1455
|
-
// "lastPrice": "108738.78",
|
|
1456
|
-
// "lastQty": "0.00034",
|
|
1457
|
-
// "openPrice": "111013.16",
|
|
1458
|
-
// "highPrice": "111975.81",
|
|
1459
|
-
// "lowPrice": "107459.25",
|
|
1460
|
-
// "volume": "28.67876",
|
|
1461
|
-
// "quoteVolume": "3141023.14551030",
|
|
1462
|
-
// "openTime": "1760578800000",
|
|
1463
|
-
// "closeTime": "1760665024749",
|
|
1464
|
-
// "firstId": "37447",
|
|
1465
|
-
// "lastId": "39698",
|
|
1466
|
-
// "count": "2252",
|
|
1467
|
-
// "baseAsset": "BTC",
|
|
1468
|
-
// "quoteAsset": "USDT",
|
|
1469
|
-
// "bidPrice": "108705.11",
|
|
1470
|
-
// "bidQty": "0.03351",
|
|
1471
|
-
// "askPrice": "108725.99",
|
|
1472
|
-
// "askQty": "0.08724"
|
|
1473
|
-
// }
|
|
1462
|
+
response = await this.sapiPublicGetV3Ticker24hr(this.extend(request, params));
|
|
1474
1463
|
}
|
|
1464
|
+
//
|
|
1465
|
+
// both SPOT & PERP has same format
|
|
1466
|
+
//
|
|
1467
|
+
// {
|
|
1468
|
+
// "symbol": "ETHUSDT",
|
|
1469
|
+
// "priceChange": "6.54",
|
|
1470
|
+
// "priceChangePercent": "0.279",
|
|
1471
|
+
// "weightedAvgPrice": "2330.70",
|
|
1472
|
+
// "lastPrice": "2350.00",
|
|
1473
|
+
// "lastQty": "4.437",
|
|
1474
|
+
// "openPrice": "2343.46",
|
|
1475
|
+
// "highPrice": "2363.20",
|
|
1476
|
+
// "lowPrice": "2283.86",
|
|
1477
|
+
// "volume": "267154.248",
|
|
1478
|
+
// "quoteVolume": "622657018.70",
|
|
1479
|
+
// "openTime": "1776329400000",
|
|
1480
|
+
// "closeTime": "1776415832593",
|
|
1481
|
+
// "firstId": "73520536",
|
|
1482
|
+
// "lastId": "73630176",
|
|
1483
|
+
// "count": "109640",
|
|
1484
|
+
// "baseAsset": "BTC", // only in SPOT
|
|
1485
|
+
// "quoteAsset": "USDT", // only in SPOT
|
|
1486
|
+
// "bidPrice": "71125.98", // only in SPOT
|
|
1487
|
+
// "bidQty": "0.00737", // only in SPOT
|
|
1488
|
+
// "askPrice": "71152.10", // only in SPOT
|
|
1489
|
+
// "askQty": "0.32399" // only in SPOT
|
|
1490
|
+
// }
|
|
1491
|
+
//
|
|
1475
1492
|
return this.parseTicker(response, market);
|
|
1476
1493
|
}
|
|
1477
1494
|
/**
|
|
1478
1495
|
* @method
|
|
1479
1496
|
* @name aster#fetchTickers
|
|
1480
1497
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1481
|
-
* @see https://github.
|
|
1482
|
-
* @see https://github.
|
|
1498
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#24h-price-change
|
|
1499
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#24hr-ticker-price-change-statistics
|
|
1483
1500
|
* @param {string[]} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1484
1501
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1485
1502
|
* @param {string} [params.subType] "linear" or "inverse"
|
|
@@ -1490,19 +1507,14 @@ class aster extends aster$1["default"] {
|
|
|
1490
1507
|
await this.loadMarkets();
|
|
1491
1508
|
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
1492
1509
|
const market = this.getMarketFromSymbols(symbols);
|
|
1493
|
-
let
|
|
1494
|
-
[
|
|
1495
|
-
let subType = undefined;
|
|
1496
|
-
[subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
|
|
1510
|
+
let marketType = undefined;
|
|
1511
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
1497
1512
|
let response = undefined;
|
|
1498
|
-
if (
|
|
1499
|
-
response = await this.
|
|
1500
|
-
}
|
|
1501
|
-
else if (type === 'spot') {
|
|
1502
|
-
response = await this.sapiPublicGetV1Ticker24hr(params);
|
|
1513
|
+
if (marketType === 'swap') {
|
|
1514
|
+
response = await this.fapiPublicGetV3Ticker24hr(params);
|
|
1503
1515
|
}
|
|
1504
|
-
else {
|
|
1505
|
-
|
|
1516
|
+
else if (marketType === 'spot') {
|
|
1517
|
+
response = await this.sapiPublicGetV3Ticker24hr(params);
|
|
1506
1518
|
}
|
|
1507
1519
|
//
|
|
1508
1520
|
// [
|
|
@@ -1522,13 +1534,127 @@ class aster extends aster$1["default"] {
|
|
|
1522
1534
|
// "closeTime": 1750063053754,
|
|
1523
1535
|
// "firstId": 24195078,
|
|
1524
1536
|
// "lastId": 24375783,
|
|
1525
|
-
// "count": 180706
|
|
1537
|
+
// "count": 180706,
|
|
1538
|
+
// "baseAsset": "BTC", // only in SPOT
|
|
1539
|
+
// "quoteAsset": "USDT", // only in SPOT
|
|
1540
|
+
// "bidPrice": "71125.98", // only in SPOT
|
|
1541
|
+
// "bidQty": "0.00737", // only in SPOT
|
|
1542
|
+
// "askPrice": "71152.10", // only in SPOT
|
|
1543
|
+
// "askQty": "0.32399" // only in SPOT
|
|
1526
1544
|
// }
|
|
1527
1545
|
// ]
|
|
1528
1546
|
//
|
|
1529
1547
|
return this.parseTickers(response, symbols);
|
|
1530
1548
|
}
|
|
1549
|
+
/**
|
|
1550
|
+
* @method
|
|
1551
|
+
* @name aster#fetchLastPrices
|
|
1552
|
+
* @description fetches the last price for multiple markets
|
|
1553
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#latest-price
|
|
1554
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#symbol-price-ticker
|
|
1555
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
|
|
1556
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1557
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
1558
|
+
* @returns {object} a dictionary of lastprices structures
|
|
1559
|
+
*/
|
|
1560
|
+
async fetchLastPrices(symbols = undefined, params = {}) {
|
|
1561
|
+
await this.loadMarkets();
|
|
1562
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
1563
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
1564
|
+
let marketType = undefined;
|
|
1565
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
|
|
1566
|
+
let response = undefined;
|
|
1567
|
+
if (marketType === 'swap') {
|
|
1568
|
+
response = await this.fapiPublicGetV3TickerPrice(params);
|
|
1569
|
+
}
|
|
1570
|
+
else if (marketType === 'spot') {
|
|
1571
|
+
response = await this.sapiPublicGetV3TickerPrice(params);
|
|
1572
|
+
}
|
|
1573
|
+
//
|
|
1574
|
+
// both SPOT & SWAP has same format
|
|
1575
|
+
//
|
|
1576
|
+
// [
|
|
1577
|
+
// {
|
|
1578
|
+
// "symbol": "LTCBTC",
|
|
1579
|
+
// "price": "4.00000200"
|
|
1580
|
+
// "time": "1649666690902"
|
|
1581
|
+
// },
|
|
1582
|
+
// ...
|
|
1583
|
+
// ]
|
|
1584
|
+
//
|
|
1585
|
+
const results = [];
|
|
1586
|
+
for (let i = 0; i < response.length; i++) {
|
|
1587
|
+
const marketId = this.safeString(response[i], 'symbol');
|
|
1588
|
+
const safeMarket = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
1589
|
+
const priceData = this.extend(this.parseLastPrice(response[i], safeMarket), params);
|
|
1590
|
+
results.push(priceData);
|
|
1591
|
+
}
|
|
1592
|
+
symbols = this.marketSymbols(symbols);
|
|
1593
|
+
return this.filterByArray(results, 'symbol', symbols);
|
|
1594
|
+
}
|
|
1595
|
+
parseLastPrice(entry, market = undefined) {
|
|
1596
|
+
//
|
|
1597
|
+
// spot & swap
|
|
1598
|
+
//
|
|
1599
|
+
// {
|
|
1600
|
+
// "symbol": "LTCBTC",
|
|
1601
|
+
// "price": "4.00000200"
|
|
1602
|
+
// "time": "1649666690902"
|
|
1603
|
+
// }
|
|
1604
|
+
//
|
|
1605
|
+
const timestamp = this.safeInteger(entry, 'time');
|
|
1606
|
+
return {
|
|
1607
|
+
'symbol': market['symbol'],
|
|
1608
|
+
'timestamp': timestamp,
|
|
1609
|
+
'datetime': this.iso8601(timestamp),
|
|
1610
|
+
'price': this.safeNumberOmitZero(entry, 'price'),
|
|
1611
|
+
'side': undefined,
|
|
1612
|
+
'info': entry,
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
/**
|
|
1616
|
+
* @method
|
|
1617
|
+
* @name aster#fetchBidsAsks
|
|
1618
|
+
* @description fetches the bid and ask price and volume for multiple markets
|
|
1619
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#current-best-order
|
|
1620
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#symbol-order-book-ticker
|
|
1621
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
|
|
1622
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1623
|
+
* @param {string} [params.subType] "linear" or "inverse"
|
|
1624
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
|
|
1625
|
+
*/
|
|
1626
|
+
async fetchBidsAsks(symbols = undefined, params = {}) {
|
|
1627
|
+
await this.loadMarkets();
|
|
1628
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
1629
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
1630
|
+
let marketType = undefined;
|
|
1631
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchBidsAsks', market, params);
|
|
1632
|
+
let response = undefined;
|
|
1633
|
+
if (marketType === 'swap') {
|
|
1634
|
+
response = await this.fapiPublicGetV3TickerBookTicker(params);
|
|
1635
|
+
}
|
|
1636
|
+
else if (marketType === 'spot') {
|
|
1637
|
+
response = await this.sapiPublicGetV3TickerBookTicker(params);
|
|
1638
|
+
}
|
|
1639
|
+
//
|
|
1640
|
+
// SPOT & PERP have only one field difference
|
|
1641
|
+
//
|
|
1642
|
+
// [
|
|
1643
|
+
// {
|
|
1644
|
+
// "symbol": "BMTUSDT",
|
|
1645
|
+
// "bidPrice": "0.004000",
|
|
1646
|
+
// "bidQty": "1250.0",
|
|
1647
|
+
// "askPrice": "0.000000",
|
|
1648
|
+
// "askQty": "0.0",
|
|
1649
|
+
// "time": "1776411276072",
|
|
1650
|
+
// "lastUpdateId": "453174307613" // only in PERP
|
|
1651
|
+
// }, ...
|
|
1652
|
+
//
|
|
1653
|
+
return this.parseTickers(response, symbols);
|
|
1654
|
+
}
|
|
1531
1655
|
parseFundingRate(contract, market = undefined) {
|
|
1656
|
+
//
|
|
1657
|
+
// fundingRate
|
|
1532
1658
|
//
|
|
1533
1659
|
// {
|
|
1534
1660
|
// "symbol": "BTCUSDT",
|
|
@@ -1540,6 +1666,9 @@ class aster extends aster$1["default"] {
|
|
|
1540
1666
|
// "nextFundingTime": 1750147200000,
|
|
1541
1667
|
// "time": 1750146970000
|
|
1542
1668
|
// }
|
|
1669
|
+
//
|
|
1670
|
+
// funding interval
|
|
1671
|
+
//
|
|
1543
1672
|
// {
|
|
1544
1673
|
// "symbol": "INJUSDT",
|
|
1545
1674
|
// "interestRate": "0.00010000",
|
|
@@ -1582,7 +1711,7 @@ class aster extends aster$1["default"] {
|
|
|
1582
1711
|
* @method
|
|
1583
1712
|
* @name aster#fetchFundingRate
|
|
1584
1713
|
* @description fetch the current funding rate
|
|
1585
|
-
* @see https://github.
|
|
1714
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#symbol-price-ticker
|
|
1586
1715
|
* @param {string} symbol unified market symbol
|
|
1587
1716
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1588
1717
|
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
@@ -1596,7 +1725,7 @@ class aster extends aster$1["default"] {
|
|
|
1596
1725
|
const request = {
|
|
1597
1726
|
'symbol': market['id'],
|
|
1598
1727
|
};
|
|
1599
|
-
const response = await this.
|
|
1728
|
+
const response = await this.fapiPublicGetV3PremiumIndex(this.extend(request, params));
|
|
1600
1729
|
//
|
|
1601
1730
|
// {
|
|
1602
1731
|
// "symbol": "BTCUSDT",
|
|
@@ -1615,7 +1744,7 @@ class aster extends aster$1["default"] {
|
|
|
1615
1744
|
* @method
|
|
1616
1745
|
* @name aster#fetchFundingRates
|
|
1617
1746
|
* @description fetch the current funding rate for multiple symbols
|
|
1618
|
-
* @see https://github.
|
|
1747
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#symbol-price-ticker
|
|
1619
1748
|
* @param {string[]} [symbols] list of unified market symbols
|
|
1620
1749
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1621
1750
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
@@ -1623,7 +1752,7 @@ class aster extends aster$1["default"] {
|
|
|
1623
1752
|
async fetchFundingRates(symbols = undefined, params = {}) {
|
|
1624
1753
|
await this.loadMarkets();
|
|
1625
1754
|
symbols = this.marketSymbols(symbols);
|
|
1626
|
-
const response = await this.
|
|
1755
|
+
const response = await this.fapiPublicGetV3PremiumIndex(this.extend(params));
|
|
1627
1756
|
//
|
|
1628
1757
|
// [
|
|
1629
1758
|
// {
|
|
@@ -1644,7 +1773,7 @@ class aster extends aster$1["default"] {
|
|
|
1644
1773
|
* @method
|
|
1645
1774
|
* @name aster#fetchFundingIntervals
|
|
1646
1775
|
* @description fetch the funding rate interval for multiple markets
|
|
1647
|
-
* @see https://github.
|
|
1776
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#get-funding-rate-config
|
|
1648
1777
|
* @param {string[]} [symbols] list of unified market symbols
|
|
1649
1778
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1650
1779
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
@@ -1654,7 +1783,7 @@ class aster extends aster$1["default"] {
|
|
|
1654
1783
|
if (symbols !== undefined) {
|
|
1655
1784
|
symbols = this.marketSymbols(symbols);
|
|
1656
1785
|
}
|
|
1657
|
-
const response = await this.
|
|
1786
|
+
const response = await this.fapiPublicGetV3FundingInfo(params);
|
|
1658
1787
|
//
|
|
1659
1788
|
// [
|
|
1660
1789
|
// {
|
|
@@ -1669,64 +1798,98 @@ class aster extends aster$1["default"] {
|
|
|
1669
1798
|
//
|
|
1670
1799
|
return this.parseFundingRates(response, symbols);
|
|
1671
1800
|
}
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1801
|
+
/**
|
|
1802
|
+
* @method
|
|
1803
|
+
* @name aster#fetchFundingRateHistory
|
|
1804
|
+
* @description fetches historical funding rate prices
|
|
1805
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/market-data/#get-funding-rate-history
|
|
1806
|
+
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
|
|
1807
|
+
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
|
1808
|
+
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
|
|
1809
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1810
|
+
* @param {int} [params.until] timestamp in ms of the latest funding rate
|
|
1811
|
+
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
|
1812
|
+
*/
|
|
1813
|
+
async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1814
|
+
await this.loadMarkets();
|
|
1815
|
+
let request = {};
|
|
1816
|
+
let market = undefined;
|
|
1817
|
+
if (symbol !== undefined) {
|
|
1818
|
+
market = this.market(symbol);
|
|
1819
|
+
request['symbol'] = market['id'];
|
|
1683
1820
|
}
|
|
1684
|
-
|
|
1821
|
+
if (since !== undefined) {
|
|
1822
|
+
request['startTime'] = since;
|
|
1823
|
+
}
|
|
1824
|
+
if (limit !== undefined) {
|
|
1825
|
+
request['limit'] = Math.min(limit, 1000);
|
|
1826
|
+
}
|
|
1827
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
1828
|
+
const response = await this.fapiPublicGetV3FundingRate(this.extend(request, params));
|
|
1829
|
+
//
|
|
1830
|
+
// [
|
|
1831
|
+
// {
|
|
1832
|
+
// "symbol": "BTCUSDT",
|
|
1833
|
+
// "fundingTime": 1747209600000,
|
|
1834
|
+
// "fundingRate": "0.00010000"
|
|
1835
|
+
// }
|
|
1836
|
+
// ]
|
|
1837
|
+
//
|
|
1838
|
+
return this.parseFundingRateHistories(response, market);
|
|
1839
|
+
}
|
|
1840
|
+
parseFundingRateHistory(contract, market = undefined) {
|
|
1841
|
+
//
|
|
1842
|
+
// {
|
|
1843
|
+
// "symbol": "BTCUSDT",
|
|
1844
|
+
// "fundingRate": "0.00063521",
|
|
1845
|
+
// "fundingTime": "1621267200000",
|
|
1846
|
+
// }
|
|
1847
|
+
//
|
|
1848
|
+
const timestamp = this.safeInteger(contract, 'fundingTime');
|
|
1849
|
+
return {
|
|
1850
|
+
'info': contract,
|
|
1851
|
+
'symbol': this.safeSymbol(this.safeString(contract, 'symbol'), undefined, undefined, 'swap'),
|
|
1852
|
+
'fundingRate': this.safeNumber(contract, 'fundingRate'),
|
|
1853
|
+
'timestamp': timestamp,
|
|
1854
|
+
'datetime': this.iso8601(timestamp),
|
|
1855
|
+
};
|
|
1685
1856
|
}
|
|
1686
1857
|
/**
|
|
1687
1858
|
* @method
|
|
1688
1859
|
* @name aster#fetchBalance
|
|
1689
1860
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1690
|
-
* @see https://github.
|
|
1691
|
-
* @see https://github.
|
|
1861
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#account-information-user_data
|
|
1862
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#futures-account-balance-v3-user_data
|
|
1692
1863
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1693
1864
|
* @param {string} [params.subType] "linear" or "inverse"
|
|
1694
1865
|
* @param {string} [params.type] 'spot', 'option', use params["subType"] for swap and future markets
|
|
1695
1866
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1696
1867
|
*/
|
|
1697
1868
|
async fetchBalance(params = {}) {
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
[subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
|
|
1869
|
+
await this.loadMarketsAndSignIn();
|
|
1870
|
+
let marketType = undefined;
|
|
1871
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
1702
1872
|
let response = undefined;
|
|
1703
1873
|
let data = undefined;
|
|
1704
|
-
if (
|
|
1705
|
-
|
|
1706
|
-
data = this.safeList(response, 'assets', []);
|
|
1874
|
+
if (marketType === 'swap') {
|
|
1875
|
+
data = await this.fapiPrivateGetV3Balance(params);
|
|
1707
1876
|
//
|
|
1708
|
-
//
|
|
1709
|
-
//
|
|
1710
|
-
//
|
|
1711
|
-
//
|
|
1712
|
-
//
|
|
1713
|
-
//
|
|
1714
|
-
//
|
|
1715
|
-
//
|
|
1716
|
-
//
|
|
1717
|
-
//
|
|
1718
|
-
//
|
|
1719
|
-
//
|
|
1720
|
-
// "availableBalance": "23.72469206", // available balance
|
|
1721
|
-
// "maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
|
|
1722
|
-
// "marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
|
|
1723
|
-
// "updateTime": 1625474304765 // last update time
|
|
1724
|
-
// }
|
|
1725
|
-
// ]
|
|
1877
|
+
// [
|
|
1878
|
+
// {
|
|
1879
|
+
// "accountAlias": "FzXquXsRFzXqAufW",
|
|
1880
|
+
// "asset": "CDL",
|
|
1881
|
+
// "balance": "0.00000000",
|
|
1882
|
+
// "crossWalletBalance": "0.00000000",
|
|
1883
|
+
// "crossUnPnl": "0.00000000",
|
|
1884
|
+
// "availableBalance": "878.90500233",
|
|
1885
|
+
// "maxWithdrawAmount": "0.00000000",
|
|
1886
|
+
// "marginAvailable": true,
|
|
1887
|
+
// "updateTime": "0"
|
|
1888
|
+
// }, ...
|
|
1726
1889
|
//
|
|
1727
1890
|
}
|
|
1728
|
-
else if (
|
|
1729
|
-
response = await this.
|
|
1891
|
+
else if (marketType === 'spot') {
|
|
1892
|
+
response = await this.sapiPrivateGetV3Account(params);
|
|
1730
1893
|
data = this.safeList(response, 'balances', []);
|
|
1731
1894
|
//
|
|
1732
1895
|
// [
|
|
@@ -1738,16 +1901,27 @@ class aster extends aster$1["default"] {
|
|
|
1738
1901
|
// ]
|
|
1739
1902
|
//
|
|
1740
1903
|
}
|
|
1741
|
-
else {
|
|
1742
|
-
throw new errors.NotSupported(this.id + ' fetchBalance() does not support ' + type + ' markets yet');
|
|
1743
|
-
}
|
|
1744
1904
|
return this.parseBalance(data);
|
|
1745
1905
|
}
|
|
1906
|
+
parseBalance(response) {
|
|
1907
|
+
const result = { 'info': response };
|
|
1908
|
+
for (let i = 0; i < response.length; i++) {
|
|
1909
|
+
const balance = response[i];
|
|
1910
|
+
const currencyId = this.safeString(balance, 'asset');
|
|
1911
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1912
|
+
const account = this.account();
|
|
1913
|
+
account['free'] = this.safeString2(balance, 'free', 'availableBalance');
|
|
1914
|
+
account['used'] = this.safeString(balance, 'locked');
|
|
1915
|
+
account['total'] = this.safeString(balance, 'balance');
|
|
1916
|
+
result[code] = account;
|
|
1917
|
+
}
|
|
1918
|
+
return this.safeBalance(result);
|
|
1919
|
+
}
|
|
1746
1920
|
/**
|
|
1747
1921
|
* @method
|
|
1748
1922
|
* @name aster#setMarginMode
|
|
1749
1923
|
* @description set margin mode to 'cross' or 'isolated'
|
|
1750
|
-
* @see https://github.
|
|
1924
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#change-margin-type-trade
|
|
1751
1925
|
* @param {string} marginMode 'cross' or 'isolated'
|
|
1752
1926
|
* @param {string} symbol unified market symbol
|
|
1753
1927
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -1764,20 +1938,15 @@ class aster extends aster$1["default"] {
|
|
|
1764
1938
|
if ((marginMode !== 'ISOLATED') && (marginMode !== 'CROSSED')) {
|
|
1765
1939
|
throw new errors.BadRequest(this.id + ' marginMode must be either isolated or cross');
|
|
1766
1940
|
}
|
|
1767
|
-
await this.
|
|
1941
|
+
await this.loadMarketsAndSignIn();
|
|
1768
1942
|
const market = this.market(symbol);
|
|
1769
1943
|
const request = {
|
|
1770
1944
|
'symbol': market['id'],
|
|
1771
1945
|
'marginType': marginMode,
|
|
1772
1946
|
};
|
|
1773
|
-
const response = await this.
|
|
1947
|
+
const response = await this.fapiPrivatePostV3MarginType(this.extend(request, params));
|
|
1774
1948
|
//
|
|
1775
|
-
// {
|
|
1776
|
-
// "amount": 100.0,
|
|
1777
|
-
// "code": 200,
|
|
1778
|
-
// "msg": "Successfully modify position margin.",
|
|
1779
|
-
// "type": 1
|
|
1780
|
-
// }
|
|
1949
|
+
// { "code": 200,"msg": "success" }
|
|
1781
1950
|
//
|
|
1782
1951
|
return response;
|
|
1783
1952
|
}
|
|
@@ -1785,37 +1954,37 @@ class aster extends aster$1["default"] {
|
|
|
1785
1954
|
* @method
|
|
1786
1955
|
* @name aster#fetchPositionMode
|
|
1787
1956
|
* @description fetchs the position mode, hedged or one way, hedged for aster is set identically for all linear markets or all inverse markets
|
|
1788
|
-
* @see https://github.
|
|
1957
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#get-current-position-modeuser_data
|
|
1789
1958
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
1790
1959
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1791
1960
|
* @returns {object} an object detailing whether the market is in hedged or one-way mode
|
|
1792
1961
|
*/
|
|
1793
1962
|
async fetchPositionMode(symbol = undefined, params = {}) {
|
|
1794
|
-
const response = await this.
|
|
1963
|
+
const response = await this.fapiPrivateGetV3PositionSideDual(params);
|
|
1795
1964
|
//
|
|
1796
1965
|
// {
|
|
1797
1966
|
// "dualSidePosition": true // "true": Hedge Mode; "false": One-way Mode
|
|
1798
1967
|
// }
|
|
1799
1968
|
//
|
|
1800
|
-
const dualSidePosition = this.safeBool(response, 'dualSidePosition');
|
|
1801
1969
|
return {
|
|
1802
1970
|
'info': response,
|
|
1803
|
-
'hedged': (dualSidePosition
|
|
1971
|
+
'hedged': this.safeBool(response, 'dualSidePosition'),
|
|
1804
1972
|
};
|
|
1805
1973
|
}
|
|
1806
1974
|
/**
|
|
1807
1975
|
* @method
|
|
1808
1976
|
* @name aster#setPositionMode
|
|
1809
1977
|
* @description set hedged to true or false for a market
|
|
1810
|
-
* @see https://github.
|
|
1978
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#change-position-modetrade
|
|
1811
1979
|
* @param {bool} hedged set to true to use dualSidePosition
|
|
1812
1980
|
* @param {string} symbol not used by bingx setPositionMode ()
|
|
1813
1981
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1814
1982
|
* @returns {object} response from the exchange
|
|
1815
1983
|
*/
|
|
1816
1984
|
async setPositionMode(hedged, symbol = undefined, params = {}) {
|
|
1985
|
+
const strValue = hedged ? 'true' : 'false';
|
|
1817
1986
|
const request = {
|
|
1818
|
-
'dualSidePosition':
|
|
1987
|
+
'dualSidePosition': strValue,
|
|
1819
1988
|
};
|
|
1820
1989
|
//
|
|
1821
1990
|
// {
|
|
@@ -1823,7 +1992,7 @@ class aster extends aster$1["default"] {
|
|
|
1823
1992
|
// "msg": "success"
|
|
1824
1993
|
// }
|
|
1825
1994
|
//
|
|
1826
|
-
return await this.
|
|
1995
|
+
return await this.fapiPrivatePostV3PositionSideDual(this.extend(request, params));
|
|
1827
1996
|
}
|
|
1828
1997
|
parseTradingFee(fee, market = undefined) {
|
|
1829
1998
|
const marketId = this.safeString(fee, 'symbol');
|
|
@@ -1842,26 +2011,28 @@ class aster extends aster$1["default"] {
|
|
|
1842
2011
|
* @method
|
|
1843
2012
|
* @name aster#fetchTradingFee
|
|
1844
2013
|
* @description fetch the trading fees for a market
|
|
1845
|
-
* @see https://github.
|
|
1846
|
-
* @see https://github.
|
|
2014
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/market-data/#get-symbol-fees
|
|
2015
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#user-commission-rate-user_data
|
|
1847
2016
|
* @param {string} symbol unified market symbol
|
|
1848
2017
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1849
2018
|
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
1850
2019
|
*/
|
|
1851
2020
|
async fetchTradingFee(symbol, params = {}) {
|
|
1852
|
-
await this.
|
|
2021
|
+
await this.loadMarketsAndSignIn();
|
|
1853
2022
|
const market = this.market(symbol);
|
|
1854
2023
|
const request = {
|
|
1855
2024
|
'symbol': market['id'],
|
|
1856
2025
|
};
|
|
1857
2026
|
let response = undefined;
|
|
1858
2027
|
if (market['swap']) {
|
|
1859
|
-
response = await this.
|
|
2028
|
+
response = await this.fapiPrivateGetV3CommissionRate(this.extend(request, params));
|
|
1860
2029
|
}
|
|
1861
2030
|
else {
|
|
1862
|
-
response = await this.
|
|
2031
|
+
response = await this.sapiPrivateGetV3CommissionRate(this.extend(request, params));
|
|
1863
2032
|
}
|
|
1864
2033
|
//
|
|
2034
|
+
// both SPOT & SWAP has same format
|
|
2035
|
+
//
|
|
1865
2036
|
// {
|
|
1866
2037
|
// "symbol": "BTCUSDT",
|
|
1867
2038
|
// "makerCommissionRate": "0.0002",
|
|
@@ -1921,32 +2092,36 @@ class aster extends aster$1["default"] {
|
|
|
1921
2092
|
// "workingType": "CONTRACT_PRICE",
|
|
1922
2093
|
// "priceProtect": false
|
|
1923
2094
|
// }
|
|
2095
|
+
//
|
|
1924
2096
|
// spot
|
|
1925
|
-
//
|
|
1926
|
-
//
|
|
1927
|
-
//
|
|
1928
|
-
//
|
|
1929
|
-
//
|
|
1930
|
-
//
|
|
1931
|
-
//
|
|
1932
|
-
//
|
|
1933
|
-
//
|
|
1934
|
-
//
|
|
1935
|
-
//
|
|
1936
|
-
//
|
|
1937
|
-
//
|
|
1938
|
-
//
|
|
1939
|
-
//
|
|
1940
|
-
//
|
|
1941
|
-
//
|
|
1942
|
-
//
|
|
2097
|
+
//
|
|
2098
|
+
// fetchOrders, fetchOpenOrders, fetchOpenOrder, fetchOrder, cancelOrder, createOrder
|
|
2099
|
+
//
|
|
2100
|
+
// {
|
|
2101
|
+
// "orderId": "417594542",
|
|
2102
|
+
// "symbol": "ETHUSDT",
|
|
2103
|
+
// "status": "FILLED",
|
|
2104
|
+
// "clientOrderId": "web_qnvMAhOJsiVbSyu0BdKG",
|
|
2105
|
+
// "price": "0", // value set for unfilled
|
|
2106
|
+
// "avgPrice": "2351.580000", // value zero for unfilled
|
|
2107
|
+
// "origQty": "0.0054",
|
|
2108
|
+
// "executedQty": "0.0054", // value zero for unfilled
|
|
2109
|
+
// "cumQuote": "12.69853200", // value zero for unfilled
|
|
2110
|
+
// "timeInForce": "GTC",
|
|
2111
|
+
// "type": "MARKET",
|
|
2112
|
+
// "side": "SELL",
|
|
2113
|
+
// "stopPrice": "0",
|
|
2114
|
+
// "origType": "MARKET",
|
|
2115
|
+
// "time": "1776274219582",
|
|
2116
|
+
// "updateTime": "1776274219609",
|
|
2117
|
+
// "orderListId": "-1"
|
|
2118
|
+
// }
|
|
1943
2119
|
//
|
|
1944
2120
|
const info = order;
|
|
1945
2121
|
const marketId = this.safeString(order, 'symbol');
|
|
1946
2122
|
market = this.safeMarket(marketId, market);
|
|
1947
2123
|
const side = this.safeStringLower(order, 'side');
|
|
1948
2124
|
const timestamp = this.safeInteger(order, 'time');
|
|
1949
|
-
const lastTradeTimestamp = this.safeInteger(order, 'updateTime');
|
|
1950
2125
|
const statusId = this.safeStringUpper(order, 'status');
|
|
1951
2126
|
const rawType = this.safeStringUpper(order, 'type');
|
|
1952
2127
|
const stopPriceString = this.safeString(order, 'stopPrice');
|
|
@@ -1958,7 +2133,7 @@ class aster extends aster$1["default"] {
|
|
|
1958
2133
|
'symbol': this.safeSymbol(marketId, market),
|
|
1959
2134
|
'timestamp': timestamp,
|
|
1960
2135
|
'datetime': this.iso8601(timestamp),
|
|
1961
|
-
'lastTradeTimestamp':
|
|
2136
|
+
'lastTradeTimestamp': undefined,
|
|
1962
2137
|
'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
|
|
1963
2138
|
'type': this.parseOrderType(rawType),
|
|
1964
2139
|
'timeInForce': this.safeString(order, 'timeInForce'),
|
|
@@ -1981,8 +2156,8 @@ class aster extends aster$1["default"] {
|
|
|
1981
2156
|
* @method
|
|
1982
2157
|
* @name aster#fetchOrder
|
|
1983
2158
|
* @description fetches information on an order made by the user
|
|
1984
|
-
* @see https://github.
|
|
1985
|
-
* @see https://github.
|
|
2159
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#query-order-user_data
|
|
2160
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#query-order-user_data
|
|
1986
2161
|
* @param {string} id the order id
|
|
1987
2162
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
1988
2163
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -1993,7 +2168,7 @@ class aster extends aster$1["default"] {
|
|
|
1993
2168
|
if (symbol === undefined) {
|
|
1994
2169
|
throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
1995
2170
|
}
|
|
1996
|
-
await this.
|
|
2171
|
+
await this.loadMarketsAndSignIn();
|
|
1997
2172
|
const market = this.market(symbol);
|
|
1998
2173
|
const request = {
|
|
1999
2174
|
'symbol': market['id'],
|
|
@@ -2008,18 +2183,48 @@ class aster extends aster$1["default"] {
|
|
|
2008
2183
|
}
|
|
2009
2184
|
let response = undefined;
|
|
2010
2185
|
if (market['swap']) {
|
|
2011
|
-
response = await this.
|
|
2186
|
+
response = await this.fapiPrivateGetV3Order(this.extend(request, params));
|
|
2012
2187
|
}
|
|
2013
2188
|
else {
|
|
2014
|
-
response = await this.
|
|
2189
|
+
response = await this.sapiPrivateGetV3Order(this.extend(request, params));
|
|
2015
2190
|
}
|
|
2191
|
+
//
|
|
2192
|
+
// SPOT & SWAP has similar formats
|
|
2193
|
+
//
|
|
2194
|
+
// {
|
|
2195
|
+
// "orderId": "17338441758",
|
|
2196
|
+
// "symbol": "ETHUSDT",
|
|
2197
|
+
// "status": "FILLED",
|
|
2198
|
+
// "clientOrderId": "727Wt3TIUgkUCxXp20E543",
|
|
2199
|
+
// "price": "0",
|
|
2200
|
+
// "avgPrice": "2304.56000",
|
|
2201
|
+
// "origQty": "0.010",
|
|
2202
|
+
// "executedQty": "0.010",
|
|
2203
|
+
// "cumQuote": "23.04560",
|
|
2204
|
+
// "timeInForce": "GTC",
|
|
2205
|
+
// "type": "MARKET",
|
|
2206
|
+
// "side": "BUY",
|
|
2207
|
+
// "stopPrice": "0",
|
|
2208
|
+
// "origType": "MARKET",
|
|
2209
|
+
// "time": "1776800300736",
|
|
2210
|
+
// "updateTime": "1776800300700",
|
|
2211
|
+
// "orderListId": "-1" // only in SPOT
|
|
2212
|
+
// "positionSide": "BOTH", // only in SWAP
|
|
2213
|
+
// "reduceOnly": false, // only in SWAP
|
|
2214
|
+
// "closePosition": false, // only in SWAP
|
|
2215
|
+
// "workingType": "CONTRACT_PRICE", // only in SWAP
|
|
2216
|
+
// "priceProtect": false, // only in SWAP
|
|
2217
|
+
// "newChainData": { "hash": "0x46aed5...67bdbec8ba" } // only in SWAP
|
|
2218
|
+
// }
|
|
2219
|
+
//
|
|
2016
2220
|
return this.parseOrder(response, market);
|
|
2017
2221
|
}
|
|
2018
2222
|
/**
|
|
2019
2223
|
* @method
|
|
2020
2224
|
* @name aster#fetchOpenOrder
|
|
2021
2225
|
* @description fetch an open order by the id
|
|
2022
|
-
* @see https://github.
|
|
2226
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#query-current-open-order-user_data
|
|
2227
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#query-current-open-order-user_data
|
|
2023
2228
|
* @param {string} id order id
|
|
2024
2229
|
* @param {string} symbol unified market symbol
|
|
2025
2230
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -2029,7 +2234,7 @@ class aster extends aster$1["default"] {
|
|
|
2029
2234
|
if (symbol === undefined) {
|
|
2030
2235
|
throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrder() requires a symbol argument');
|
|
2031
2236
|
}
|
|
2032
|
-
await this.
|
|
2237
|
+
await this.loadMarketsAndSignIn();
|
|
2033
2238
|
const market = this.market(symbol);
|
|
2034
2239
|
const request = {
|
|
2035
2240
|
'symbol': market['id'],
|
|
@@ -2042,15 +2247,50 @@ class aster extends aster$1["default"] {
|
|
|
2042
2247
|
else {
|
|
2043
2248
|
request['orderId'] = id;
|
|
2044
2249
|
}
|
|
2045
|
-
|
|
2250
|
+
let response = undefined;
|
|
2251
|
+
if (market['spot']) {
|
|
2252
|
+
response = await this.sapiPrivateGetV3OpenOrder(this.extend(request, params));
|
|
2253
|
+
}
|
|
2254
|
+
else {
|
|
2255
|
+
response = await this.fapiPrivateGetV3OpenOrder(this.extend(request, params));
|
|
2256
|
+
}
|
|
2257
|
+
//
|
|
2258
|
+
// SPOT & SWAP has similar formats
|
|
2259
|
+
//
|
|
2260
|
+
// {
|
|
2261
|
+
// "orderId": "17338441758",
|
|
2262
|
+
// "symbol": "ETHUSDT",
|
|
2263
|
+
// "status": "FILLED",
|
|
2264
|
+
// "clientOrderId": "727Wt3TIUgkUCxXp20E543",
|
|
2265
|
+
// "price": "0",
|
|
2266
|
+
// "avgPrice": "2304.56000",
|
|
2267
|
+
// "origQty": "0.010",
|
|
2268
|
+
// "executedQty": "0.010",
|
|
2269
|
+
// "cumQuote": "23.04560",
|
|
2270
|
+
// "timeInForce": "GTC",
|
|
2271
|
+
// "type": "MARKET",
|
|
2272
|
+
// "side": "BUY",
|
|
2273
|
+
// "stopPrice": "0",
|
|
2274
|
+
// "origType": "MARKET",
|
|
2275
|
+
// "time": "1776800300736",
|
|
2276
|
+
// "updateTime": "1776800300700",
|
|
2277
|
+
// "orderListId": "-1" // only in SPOT
|
|
2278
|
+
// "positionSide": "BOTH", // only in SWAP
|
|
2279
|
+
// "reduceOnly": false, // only in SWAP
|
|
2280
|
+
// "closePosition": false, // only in SWAP
|
|
2281
|
+
// "workingType": "CONTRACT_PRICE", // only in SWAP
|
|
2282
|
+
// "priceProtect": false, // only in SWAP
|
|
2283
|
+
// "newChainData": { "hash": "0x46aed5...67bdbec8ba" } // only in SWAP
|
|
2284
|
+
// }
|
|
2285
|
+
//
|
|
2046
2286
|
return this.parseOrder(response, market);
|
|
2047
2287
|
}
|
|
2048
2288
|
/**
|
|
2049
2289
|
* @method
|
|
2050
2290
|
* @name aster#fetchOrders
|
|
2051
2291
|
* @description fetches information on multiple orders made by the user
|
|
2052
|
-
* @see https://github.
|
|
2053
|
-
* @see https://github.
|
|
2292
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#query-all-orders-user_data
|
|
2293
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#all-orders-user_data
|
|
2054
2294
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
2055
2295
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
2056
2296
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -2059,39 +2299,66 @@ class aster extends aster$1["default"] {
|
|
|
2059
2299
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2060
2300
|
*/
|
|
2061
2301
|
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2062
|
-
await this.loadMarkets();
|
|
2063
2302
|
if (symbol === undefined) {
|
|
2064
2303
|
throw new errors.ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
|
|
2065
2304
|
}
|
|
2305
|
+
await this.loadMarketsAndSignIn();
|
|
2066
2306
|
const market = this.market(symbol);
|
|
2067
2307
|
let request = {
|
|
2068
2308
|
'symbol': market['id'],
|
|
2069
2309
|
};
|
|
2310
|
+
if (limit !== undefined) {
|
|
2311
|
+
request['limit'] = Math.min(limit, 1000);
|
|
2312
|
+
}
|
|
2070
2313
|
if (since !== undefined) {
|
|
2071
2314
|
request['startTime'] = since;
|
|
2072
2315
|
}
|
|
2073
|
-
if (limit !== undefined) {
|
|
2074
|
-
if (limit > 1000) {
|
|
2075
|
-
limit = 1000; // Default 500; max 1000
|
|
2076
|
-
}
|
|
2077
|
-
request['limit'] = limit;
|
|
2078
|
-
}
|
|
2079
2316
|
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
2080
2317
|
let response = undefined;
|
|
2081
2318
|
if (market['swap']) {
|
|
2082
|
-
response = await this.
|
|
2319
|
+
response = await this.fapiPrivateGetV3AllOrders(this.extend(request, params));
|
|
2083
2320
|
}
|
|
2084
2321
|
else {
|
|
2085
|
-
response = await this.
|
|
2322
|
+
response = await this.sapiPrivateGetV3AllOrders(this.extend(request, params));
|
|
2086
2323
|
}
|
|
2324
|
+
//
|
|
2325
|
+
// SPOT & SWAP has similar responses
|
|
2326
|
+
//
|
|
2327
|
+
// [
|
|
2328
|
+
// {
|
|
2329
|
+
// "orderId": "417594542",
|
|
2330
|
+
// "symbol": "ETHUSDT",
|
|
2331
|
+
// "status": "FILLED",
|
|
2332
|
+
// "clientOrderId": "web_qnvMAhOJsiVbSyu0BdKG",
|
|
2333
|
+
// "price": "0", // value set for unfilled
|
|
2334
|
+
// "avgPrice": "2351.580000", // value zero for unfilled
|
|
2335
|
+
// "origQty": "0.0054",
|
|
2336
|
+
// "executedQty": "0.0054", // value zero for unfilled
|
|
2337
|
+
// "cumQuote": "12.69853200", // value zero for unfilled
|
|
2338
|
+
// "timeInForce": "GTC",
|
|
2339
|
+
// "type": "MARKET",
|
|
2340
|
+
// "side": "SELL",
|
|
2341
|
+
// "stopPrice": "0",
|
|
2342
|
+
// "origType": "MARKET",
|
|
2343
|
+
// "time": "1776274219582",
|
|
2344
|
+
// "updateTime": "1776274219609",
|
|
2345
|
+
// "orderListId": "-1", // only in SPOT
|
|
2346
|
+
// "reduceOnly": false, // only in PERP
|
|
2347
|
+
// "closePosition": false, // only in PERP
|
|
2348
|
+
// "positionSide": "BOTH", // only in PERP
|
|
2349
|
+
// "workingType": "CONTRACT_PRICE", // only in PERP
|
|
2350
|
+
// "priceProtect": false, // only in PERP
|
|
2351
|
+
// "newChainData": { "hash": "0xe17d3d5b...dbca8b01" } // only in PERP
|
|
2352
|
+
// }, ...
|
|
2353
|
+
//
|
|
2087
2354
|
return this.parseOrders(response, market, since, limit);
|
|
2088
2355
|
}
|
|
2089
2356
|
/**
|
|
2090
2357
|
* @method
|
|
2091
2358
|
* @name aster#fetchOpenOrders
|
|
2092
2359
|
* @description fetch all unfilled currently open orders
|
|
2093
|
-
* @see https://github.
|
|
2094
|
-
* @see https://github.
|
|
2360
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#current-open-orders-user_data
|
|
2361
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#current-all-open-orders-user_data
|
|
2095
2362
|
* @param {string} symbol unified market symbol
|
|
2096
2363
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
2097
2364
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
@@ -2101,55 +2368,63 @@ class aster extends aster$1["default"] {
|
|
|
2101
2368
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2102
2369
|
*/
|
|
2103
2370
|
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2104
|
-
await this.
|
|
2371
|
+
await this.loadMarketsAndSignIn();
|
|
2105
2372
|
const request = {};
|
|
2106
2373
|
let market = undefined;
|
|
2107
|
-
let
|
|
2108
|
-
let subType = undefined;
|
|
2109
|
-
[subType, params] = this.handleSubTypeAndParams('fetchOpenOrders', market, params);
|
|
2374
|
+
let marketType = undefined;
|
|
2110
2375
|
if (symbol !== undefined) {
|
|
2111
2376
|
market = this.market(symbol);
|
|
2112
2377
|
request['symbol'] = market['id'];
|
|
2113
2378
|
}
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
}
|
|
2119
|
-
else if (type === 'spot') {
|
|
2120
|
-
response = await this.sapiPrivateGetV1OpenOrders(this.extend(request, params));
|
|
2379
|
+
if (symbol === undefined) {
|
|
2380
|
+
if (this.options['fetchOpenOrders']['warnIfNoSymbol']) {
|
|
2381
|
+
throw new errors.ExchangeError(this.id + ' fetchOpenOrders(): WARNING - this method without providing "symbol" argument uses 40 times more rate-limit quota. If you acknowledge this warning, set ' + this.id + '.options["fetchOpenOrders"]["warnIfNoSymbol"] = false to suppress this warning message.');
|
|
2382
|
+
}
|
|
2121
2383
|
}
|
|
2122
2384
|
else {
|
|
2123
|
-
|
|
2385
|
+
market = this.market(symbol);
|
|
2386
|
+
request['symbol'] = market['id'];
|
|
2387
|
+
}
|
|
2388
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
|
|
2389
|
+
let subType = undefined;
|
|
2390
|
+
[subType, params] = this.handleSubTypeAndParams('fetchOpenOrders', market, params);
|
|
2391
|
+
let response = undefined;
|
|
2392
|
+
if (this.isLinear(marketType, subType)) {
|
|
2393
|
+
response = await this.fapiPrivateGetV3OpenOrders(this.extend(request, params));
|
|
2394
|
+
}
|
|
2395
|
+
else if (marketType === 'spot') {
|
|
2396
|
+
response = await this.sapiPrivateGetV3OpenOrders(this.extend(request, params));
|
|
2124
2397
|
}
|
|
2125
2398
|
//
|
|
2126
|
-
//
|
|
2127
|
-
//
|
|
2128
|
-
//
|
|
2129
|
-
//
|
|
2130
|
-
//
|
|
2131
|
-
//
|
|
2132
|
-
//
|
|
2133
|
-
//
|
|
2134
|
-
//
|
|
2135
|
-
//
|
|
2136
|
-
//
|
|
2137
|
-
//
|
|
2138
|
-
//
|
|
2139
|
-
//
|
|
2140
|
-
//
|
|
2141
|
-
//
|
|
2142
|
-
//
|
|
2143
|
-
//
|
|
2144
|
-
//
|
|
2145
|
-
//
|
|
2146
|
-
//
|
|
2147
|
-
//
|
|
2148
|
-
//
|
|
2149
|
-
//
|
|
2150
|
-
//
|
|
2151
|
-
//
|
|
2152
|
-
//
|
|
2399
|
+
// SPOT & SWAP has similar responses
|
|
2400
|
+
//
|
|
2401
|
+
// [
|
|
2402
|
+
// {
|
|
2403
|
+
// "orderId": "17338239315",
|
|
2404
|
+
// "symbol": "ETHUSDT",
|
|
2405
|
+
// "status": "NEW",
|
|
2406
|
+
// "clientOrderId": "web_AD_mbhgla7k15gptmwyr_x",
|
|
2407
|
+
// "price": "2216.62",
|
|
2408
|
+
// "avgPrice": "0",
|
|
2409
|
+
// "origQty": "0.012",
|
|
2410
|
+
// "executedQty": "0",
|
|
2411
|
+
// "cumQuote": "0",
|
|
2412
|
+
// "timeInForce": "GTC",
|
|
2413
|
+
// "type": "LIMIT",
|
|
2414
|
+
// "side": "BUY",
|
|
2415
|
+
// "stopPrice": "0",
|
|
2416
|
+
// "origType": "LIMIT",
|
|
2417
|
+
// "time": "1776798208476",
|
|
2418
|
+
// "updateTime": "1776798208450",
|
|
2419
|
+
// "orderListId": "-1" // only in SPOT
|
|
2420
|
+
// "reduceOnly": false, // only in PERP
|
|
2421
|
+
// "closePosition": false, // only in PERP
|
|
2422
|
+
// "positionSide": "BOTH", // only in PERP
|
|
2423
|
+
// "workingType": "CONTRACT_PRICE", // only in PERP
|
|
2424
|
+
// "priceProtect": false, // only in PERP
|
|
2425
|
+
// "newChainData": { "hash": "0xf8a496....a7fd5" } // only in PERP
|
|
2426
|
+
// }
|
|
2427
|
+
// ]
|
|
2153
2428
|
//
|
|
2154
2429
|
return this.parseOrders(response, market, since, limit);
|
|
2155
2430
|
}
|
|
@@ -2157,8 +2432,8 @@ class aster extends aster$1["default"] {
|
|
|
2157
2432
|
* @method
|
|
2158
2433
|
* @name aster#createOrder
|
|
2159
2434
|
* @description create a trade order
|
|
2160
|
-
* @see https://github.
|
|
2161
|
-
* @see https://github.
|
|
2435
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#place-order-trade
|
|
2436
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#new-order-trade
|
|
2162
2437
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2163
2438
|
* @param {string} type 'market' or 'limit' or 'STOP' or 'STOP_MARKET' or 'TAKE_PROFIT' or 'TAKE_PROFIT_MARKET' or 'TRAILING_STOP_MARKET'
|
|
2164
2439
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -2176,36 +2451,59 @@ class aster extends aster$1["default"] {
|
|
|
2176
2451
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2177
2452
|
*/
|
|
2178
2453
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
2179
|
-
await this.
|
|
2454
|
+
await this.loadMarketsAndSignIn();
|
|
2180
2455
|
const market = this.market(symbol);
|
|
2181
|
-
const test = this.safeBool(params, 'test', false);
|
|
2182
|
-
params = this.omit(params, 'test');
|
|
2183
2456
|
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
2184
2457
|
let response = undefined;
|
|
2185
2458
|
if (market['swap']) {
|
|
2186
|
-
|
|
2187
|
-
response = await this.fapiPrivatePostV1OrderTest(request);
|
|
2188
|
-
}
|
|
2189
|
-
else {
|
|
2190
|
-
response = await this.fapiPrivatePostV1Order(request);
|
|
2191
|
-
}
|
|
2459
|
+
response = await this.fapiPrivatePostV3Order(request);
|
|
2192
2460
|
}
|
|
2193
2461
|
else {
|
|
2194
|
-
response = await this.
|
|
2462
|
+
response = await this.sapiPrivatePostV3Order(request);
|
|
2195
2463
|
}
|
|
2464
|
+
//
|
|
2465
|
+
// SPOT & SWAP has similar responses
|
|
2466
|
+
//
|
|
2467
|
+
// {
|
|
2468
|
+
// "orderId": "17338441758",
|
|
2469
|
+
// "symbol": "ETHUSDT",
|
|
2470
|
+
// "status": "NEW",
|
|
2471
|
+
// "clientOrderId": "727Wt3TIUgkUCxXp20E543",
|
|
2472
|
+
// "price": "0",
|
|
2473
|
+
// "avgPrice": "0.00000",
|
|
2474
|
+
// "origQty": "0.010",
|
|
2475
|
+
// "executedQty": "0",
|
|
2476
|
+
// "cumQty": "0",
|
|
2477
|
+
// "cumQuote": "0",
|
|
2478
|
+
// "timeInForce": "GTC",
|
|
2479
|
+
// "type": "MARKET",
|
|
2480
|
+
// "side": "BUY",
|
|
2481
|
+
// "stopPrice": "0",
|
|
2482
|
+
// "origType": "MARKET",
|
|
2483
|
+
// "time": "1776800300700",
|
|
2484
|
+
// "updateTime": "1776800300700",
|
|
2485
|
+
// "orderListId": "-1", // only in SPOT
|
|
2486
|
+
// "workingType": "CONTRACT_PRICE", // only in PERP
|
|
2487
|
+
// "positionSide": "BOTH", // only in PERP
|
|
2488
|
+
// "reduceOnly": false, // only in PERP
|
|
2489
|
+
// "closePosition": false, // only in PERP
|
|
2490
|
+
// "priceProtect": false, // only in PERP
|
|
2491
|
+
// "newChainData": { "hash": "0x46ae....c8ba" } // only in PERP
|
|
2492
|
+
// }
|
|
2493
|
+
//
|
|
2196
2494
|
return this.parseOrder(response, market);
|
|
2197
2495
|
}
|
|
2198
2496
|
/**
|
|
2199
2497
|
* @method
|
|
2200
2498
|
* @name aster#createOrders
|
|
2201
2499
|
* @description create a list of trade orders
|
|
2202
|
-
* @see https://github.
|
|
2500
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#new-order-trade
|
|
2203
2501
|
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
2204
2502
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2205
2503
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2206
2504
|
*/
|
|
2207
2505
|
async createOrders(orders, params = {}) {
|
|
2208
|
-
await this.
|
|
2506
|
+
await this.loadMarketsAndSignIn();
|
|
2209
2507
|
const ordersRequests = [];
|
|
2210
2508
|
let orderSymbols = [];
|
|
2211
2509
|
if (orders.length > 5) {
|
|
@@ -2214,6 +2512,8 @@ class aster extends aster$1["default"] {
|
|
|
2214
2512
|
for (let i = 0; i < orders.length; i++) {
|
|
2215
2513
|
const rawOrder = orders[i];
|
|
2216
2514
|
const marketId = this.safeString(rawOrder, 'symbol');
|
|
2515
|
+
const currentMarket = this.market(marketId);
|
|
2516
|
+
orderSymbols.push(currentMarket['symbol']);
|
|
2217
2517
|
const type = this.safeString(rawOrder, 'type');
|
|
2218
2518
|
const side = this.safeString(rawOrder, 'side');
|
|
2219
2519
|
const amount = this.safeValue(rawOrder, 'amount');
|
|
@@ -2230,7 +2530,37 @@ class aster extends aster$1["default"] {
|
|
|
2230
2530
|
const request = {
|
|
2231
2531
|
'batchOrders': ordersRequests,
|
|
2232
2532
|
};
|
|
2233
|
-
const response = await this.
|
|
2533
|
+
const response = await this.fapiPrivatePostV3BatchOrders(this.extend(request, params));
|
|
2534
|
+
//
|
|
2535
|
+
// [
|
|
2536
|
+
// {
|
|
2537
|
+
// "orderId": 17338699853,
|
|
2538
|
+
// "symbol": "ETHUSDT",
|
|
2539
|
+
// "status": "NEW",
|
|
2540
|
+
// "clientOrderId": "NxMWPvOEyiF6TWh5UB8BQf0",
|
|
2541
|
+
// "price": "0",
|
|
2542
|
+
// "avgPrice": "0.00000",
|
|
2543
|
+
// "origQty": "0.010",
|
|
2544
|
+
// "executedQty": "0",
|
|
2545
|
+
// "cumQty": "0",
|
|
2546
|
+
// "cumQuote": "0",
|
|
2547
|
+
// "timeInForce": "GTC",
|
|
2548
|
+
// "type": "MARKET",
|
|
2549
|
+
// "reduceOnly": false,
|
|
2550
|
+
// "closePosition": false,
|
|
2551
|
+
// "side": "BUY",
|
|
2552
|
+
// "positionSide": "BOTH",
|
|
2553
|
+
// "stopPrice": "0",
|
|
2554
|
+
// "workingType": "CONTRACT_PRICE",
|
|
2555
|
+
// "priceProtect": false,
|
|
2556
|
+
// "origType": "MARKET",
|
|
2557
|
+
// "updateTime": 1776802276050,
|
|
2558
|
+
// "newChainData": {
|
|
2559
|
+
// "hash": "0x5e569d9794cf726f72c2d000d401d20315e78e4df7b58023a489864624527dfe"
|
|
2560
|
+
// }
|
|
2561
|
+
// }
|
|
2562
|
+
// ]
|
|
2563
|
+
//
|
|
2234
2564
|
return this.parseOrders(response);
|
|
2235
2565
|
}
|
|
2236
2566
|
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -2405,14 +2735,18 @@ class aster extends aster$1["default"] {
|
|
|
2405
2735
|
request['timeInForce'] = this.safeString(this.options, 'defaultTimeInForce'); // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
|
|
2406
2736
|
}
|
|
2407
2737
|
const requestParams = this.omit(params, ['newClientOrderId', 'clientOrderId', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent', 'trailingDelta', 'stopPrice', 'stopLossPrice', 'takeProfitPrice']);
|
|
2738
|
+
if (this.safeBool(this.options, 'builderFee') && market['swap']) {
|
|
2739
|
+
request['builder'] = this.safeString(this.options, 'builder');
|
|
2740
|
+
request['feeRate'] = this.safeString(this.options, 'builderRate');
|
|
2741
|
+
}
|
|
2408
2742
|
return this.extend(request, requestParams);
|
|
2409
2743
|
}
|
|
2410
2744
|
/**
|
|
2411
2745
|
* @method
|
|
2412
2746
|
* @name aster#cancelAllOrders
|
|
2413
2747
|
* @description cancel all open orders in a market
|
|
2414
|
-
* @see https://github.
|
|
2415
|
-
* @see https://github.
|
|
2748
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#cancel-all-open-orders-trade
|
|
2749
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#current-all-open-orders-user_data
|
|
2416
2750
|
* @param {string} symbol unified market symbol of the market to cancel orders in
|
|
2417
2751
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2418
2752
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -2421,19 +2755,21 @@ class aster extends aster$1["default"] {
|
|
|
2421
2755
|
if (symbol === undefined) {
|
|
2422
2756
|
throw new errors.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
|
|
2423
2757
|
}
|
|
2424
|
-
await this.
|
|
2758
|
+
await this.loadMarketsAndSignIn();
|
|
2425
2759
|
const market = this.market(symbol);
|
|
2426
2760
|
const request = {
|
|
2427
2761
|
'symbol': market['id'],
|
|
2428
2762
|
};
|
|
2429
2763
|
let response = undefined;
|
|
2430
2764
|
if (market['swap']) {
|
|
2431
|
-
response = await this.
|
|
2765
|
+
response = await this.fapiPrivateDeleteV3AllOpenOrders(this.extend(request, params));
|
|
2432
2766
|
}
|
|
2433
2767
|
else {
|
|
2434
|
-
response = await this.
|
|
2768
|
+
response = await this.sapiPrivateDeleteV3AllOpenOrders(this.extend(request, params));
|
|
2435
2769
|
}
|
|
2436
2770
|
//
|
|
2771
|
+
// SPOT & SWAP has same response
|
|
2772
|
+
//
|
|
2437
2773
|
// {
|
|
2438
2774
|
// "code": "200",
|
|
2439
2775
|
// "msg": "The operation of cancel all open order is done."
|
|
@@ -2449,8 +2785,8 @@ class aster extends aster$1["default"] {
|
|
|
2449
2785
|
* @method
|
|
2450
2786
|
* @name aster#cancelOrder
|
|
2451
2787
|
* @description cancels an open order
|
|
2452
|
-
* @see https://github.
|
|
2453
|
-
* @see https://github.
|
|
2788
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#cancel-order-trade
|
|
2789
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#cancel-order-trade
|
|
2454
2790
|
* @param {string} id order id
|
|
2455
2791
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
2456
2792
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -2460,25 +2796,25 @@ class aster extends aster$1["default"] {
|
|
|
2460
2796
|
if (symbol === undefined) {
|
|
2461
2797
|
throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
2462
2798
|
}
|
|
2463
|
-
await this.
|
|
2799
|
+
await this.loadMarketsAndSignIn();
|
|
2464
2800
|
const market = this.market(symbol);
|
|
2465
2801
|
const request = {
|
|
2466
2802
|
'symbol': market['id'],
|
|
2467
2803
|
};
|
|
2468
|
-
const clientOrderId = this.safeStringN(params, ['origClientOrderId', 'clientOrderId'
|
|
2804
|
+
const clientOrderId = this.safeStringN(params, ['origClientOrderId', 'clientOrderId']);
|
|
2469
2805
|
if (clientOrderId !== undefined) {
|
|
2470
2806
|
request['origClientOrderId'] = clientOrderId;
|
|
2471
2807
|
}
|
|
2472
2808
|
else {
|
|
2473
2809
|
request['orderId'] = id;
|
|
2474
2810
|
}
|
|
2475
|
-
params = this.omit(params, ['origClientOrderId', 'clientOrderId'
|
|
2811
|
+
params = this.omit(params, ['origClientOrderId', 'clientOrderId']);
|
|
2476
2812
|
let response = undefined;
|
|
2477
2813
|
if (market['swap']) {
|
|
2478
|
-
response = await this.
|
|
2814
|
+
response = await this.fapiPrivateDeleteV3Order(this.extend(request, params));
|
|
2479
2815
|
}
|
|
2480
2816
|
else {
|
|
2481
|
-
response = await this.
|
|
2817
|
+
response = await this.sapiPrivateDeleteV3Order(this.extend(request, params));
|
|
2482
2818
|
}
|
|
2483
2819
|
return this.parseOrder(response, market);
|
|
2484
2820
|
}
|
|
@@ -2486,7 +2822,8 @@ class aster extends aster$1["default"] {
|
|
|
2486
2822
|
* @method
|
|
2487
2823
|
* @name aster#cancelOrders
|
|
2488
2824
|
* @description cancel multiple orders
|
|
2489
|
-
* @see https://github.
|
|
2825
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#cancel-all-open-orders-trade
|
|
2826
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#cancel-multiple-orders-trade
|
|
2490
2827
|
* @param {string[]} ids order ids
|
|
2491
2828
|
* @param {string} [symbol] unified market symbol
|
|
2492
2829
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -2500,11 +2837,8 @@ class aster extends aster$1["default"] {
|
|
|
2500
2837
|
if (symbol === undefined) {
|
|
2501
2838
|
throw new errors.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
|
|
2502
2839
|
}
|
|
2503
|
-
await this.
|
|
2840
|
+
await this.loadMarketsAndSignIn();
|
|
2504
2841
|
const market = this.market(symbol);
|
|
2505
|
-
if (market['spot']) {
|
|
2506
|
-
throw new errors.NotSupported(this.id + ' cancelOrders() does not support ' + market['type'] + ' orders');
|
|
2507
|
-
}
|
|
2508
2842
|
const request = {
|
|
2509
2843
|
'symbol': market['id'],
|
|
2510
2844
|
};
|
|
@@ -2515,46 +2849,55 @@ class aster extends aster$1["default"] {
|
|
|
2515
2849
|
else {
|
|
2516
2850
|
request['orderIdList'] = ids;
|
|
2517
2851
|
}
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2852
|
+
let response = undefined;
|
|
2853
|
+
if (market['swap']) {
|
|
2854
|
+
response = await this.fapiPrivateDeleteV3BatchOrders(this.extend(request, params));
|
|
2855
|
+
//
|
|
2856
|
+
// [
|
|
2857
|
+
// {
|
|
2858
|
+
// "clientOrderId": "myOrder1",
|
|
2859
|
+
// "cumQty": "0",
|
|
2860
|
+
// "cumQuote": "0",
|
|
2861
|
+
// "executedQty": "0",
|
|
2862
|
+
// "orderId": 283194212,
|
|
2863
|
+
// "origQty": "11",
|
|
2864
|
+
// "origType": "TRAILING_STOP_MARKET",
|
|
2865
|
+
// "price": "0",
|
|
2866
|
+
// "reduceOnly": false,
|
|
2867
|
+
// "side": "BUY",
|
|
2868
|
+
// "positionSide": "SHORT",
|
|
2869
|
+
// "status": "CANCELED",
|
|
2870
|
+
// "stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
|
|
2871
|
+
// "closePosition": false, // if Close-All
|
|
2872
|
+
// "symbol": "BTCUSDT",
|
|
2873
|
+
// "timeInForce": "GTC",
|
|
2874
|
+
// "type": "TRAILING_STOP_MARKET",
|
|
2875
|
+
// "activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
|
|
2876
|
+
// "priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
|
|
2877
|
+
// "updateTime": 1571110484038,
|
|
2878
|
+
// "workingType": "CONTRACT_PRICE",
|
|
2879
|
+
// "priceProtect": false, // if conditional order trigger is protected
|
|
2880
|
+
// },
|
|
2881
|
+
// {
|
|
2882
|
+
// "code": -2011,
|
|
2883
|
+
// "msg": "Unknown order sent."
|
|
2884
|
+
// }
|
|
2885
|
+
// ]
|
|
2886
|
+
//
|
|
2887
|
+
}
|
|
2888
|
+
else {
|
|
2889
|
+
response = await this.sapiPrivateDeleteV3AllOpenOrders(this.extend(request, params));
|
|
2890
|
+
//
|
|
2891
|
+
// {"code": 200,"msg": "The operation of cancel all open order is done."}
|
|
2892
|
+
//
|
|
2893
|
+
}
|
|
2551
2894
|
return this.parseOrders(response, market);
|
|
2552
2895
|
}
|
|
2553
2896
|
/**
|
|
2554
2897
|
* @method
|
|
2555
2898
|
* @name aster#setLeverage
|
|
2556
2899
|
* @description set the level of leverage for a market
|
|
2557
|
-
* @see https://github.
|
|
2900
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#change-initial-leverage-trade
|
|
2558
2901
|
* @param {float} leverage the rate of leverage
|
|
2559
2902
|
* @param {string} symbol unified market symbol
|
|
2560
2903
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -2567,13 +2910,13 @@ class aster extends aster$1["default"] {
|
|
|
2567
2910
|
if ((leverage < 1) || (leverage > 125)) {
|
|
2568
2911
|
throw new errors.BadRequest(this.id + ' leverage should be between 1 and 125');
|
|
2569
2912
|
}
|
|
2570
|
-
await this.
|
|
2913
|
+
await this.loadMarketsAndSignIn();
|
|
2571
2914
|
const market = this.market(symbol);
|
|
2572
2915
|
const request = {
|
|
2573
2916
|
'symbol': market['id'],
|
|
2574
2917
|
'leverage': leverage,
|
|
2575
2918
|
};
|
|
2576
|
-
const response = await this.
|
|
2919
|
+
const response = await this.fapiPrivatePostV3Leverage(this.extend(request, params));
|
|
2577
2920
|
//
|
|
2578
2921
|
// {
|
|
2579
2922
|
// "leverage": 21,
|
|
@@ -2587,14 +2930,14 @@ class aster extends aster$1["default"] {
|
|
|
2587
2930
|
* @method
|
|
2588
2931
|
* @name aster#fetchLeverages
|
|
2589
2932
|
* @description fetch the set leverage for all markets
|
|
2590
|
-
* @see https://github.
|
|
2933
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#position-information-v3-user_data
|
|
2591
2934
|
* @param {string[]} [symbols] a list of unified market symbols
|
|
2592
2935
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2593
2936
|
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
2594
2937
|
*/
|
|
2595
2938
|
async fetchLeverages(symbols = undefined, params = {}) {
|
|
2596
|
-
await this.
|
|
2597
|
-
const response = await this.
|
|
2939
|
+
await this.loadMarketsAndSignIn();
|
|
2940
|
+
const response = await this.fapiPrivateGetV3PositionRisk(params);
|
|
2598
2941
|
//
|
|
2599
2942
|
// [
|
|
2600
2943
|
// {
|
|
@@ -2666,14 +3009,14 @@ class aster extends aster$1["default"] {
|
|
|
2666
3009
|
* @method
|
|
2667
3010
|
* @name aster#fetchMarginModes
|
|
2668
3011
|
* @description fetches margin mode of the user
|
|
2669
|
-
* @see https://github.
|
|
3012
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#position-information-v3-user_data
|
|
2670
3013
|
* @param {string[]} symbols unified market symbols
|
|
2671
3014
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2672
3015
|
* @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
2673
3016
|
*/
|
|
2674
3017
|
async fetchMarginModes(symbols = undefined, params = {}) {
|
|
2675
|
-
await this.
|
|
2676
|
-
const response = await this.
|
|
3018
|
+
await this.loadMarketsAndSignIn();
|
|
3019
|
+
const response = await this.fapiPrivateGetV3PositionRisk(params);
|
|
2677
3020
|
//
|
|
2678
3021
|
//
|
|
2679
3022
|
// [
|
|
@@ -2731,7 +3074,7 @@ class aster extends aster$1["default"] {
|
|
|
2731
3074
|
* @method
|
|
2732
3075
|
* @name aster#fetchMarginAdjustmentHistory
|
|
2733
3076
|
* @description fetches the history of margin added or reduced from contract isolated positions
|
|
2734
|
-
* @see https://github.
|
|
3077
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#get-position-margin-change-history-trade
|
|
2735
3078
|
* @param {string} symbol unified market symbol
|
|
2736
3079
|
* @param {string} [type] "add" or "reduce"
|
|
2737
3080
|
* @param {int} [since] timestamp in ms of the earliest change to fetch
|
|
@@ -2741,10 +3084,10 @@ class aster extends aster$1["default"] {
|
|
|
2741
3084
|
* @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
2742
3085
|
*/
|
|
2743
3086
|
async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2744
|
-
await this.loadMarkets();
|
|
2745
3087
|
if (symbol === undefined) {
|
|
2746
3088
|
throw new errors.ArgumentsRequired(this.id + ' fetchMarginAdjustmentHistory () requires a symbol argument');
|
|
2747
3089
|
}
|
|
3090
|
+
await this.loadMarketsAndSignIn();
|
|
2748
3091
|
const market = this.market(symbol);
|
|
2749
3092
|
const until = this.safeInteger(params, 'until');
|
|
2750
3093
|
params = this.omit(params, 'until');
|
|
@@ -2754,16 +3097,16 @@ class aster extends aster$1["default"] {
|
|
|
2754
3097
|
if (type !== undefined) {
|
|
2755
3098
|
request['type'] = (type === 'add') ? 1 : 2;
|
|
2756
3099
|
}
|
|
3100
|
+
if (limit !== undefined) {
|
|
3101
|
+
request['limit'] = Math.min(limit, 1000);
|
|
3102
|
+
}
|
|
2757
3103
|
if (since !== undefined) {
|
|
2758
3104
|
request['startTime'] = since;
|
|
2759
3105
|
}
|
|
2760
|
-
if (limit !== undefined) {
|
|
2761
|
-
request['limit'] = limit;
|
|
2762
|
-
}
|
|
2763
3106
|
if (until !== undefined) {
|
|
2764
3107
|
request['endTime'] = until;
|
|
2765
3108
|
}
|
|
2766
|
-
const response = await this.
|
|
3109
|
+
const response = await this.fapiPrivateGetV3PositionMarginHistory(this.extend(request, params));
|
|
2767
3110
|
//
|
|
2768
3111
|
// [
|
|
2769
3112
|
// {
|
|
@@ -2818,7 +3161,7 @@ class aster extends aster$1["default"] {
|
|
|
2818
3161
|
};
|
|
2819
3162
|
}
|
|
2820
3163
|
async modifyMarginHelper(symbol, amount, addOrReduce, params = {}) {
|
|
2821
|
-
await this.
|
|
3164
|
+
await this.loadMarketsAndSignIn();
|
|
2822
3165
|
const market = this.market(symbol);
|
|
2823
3166
|
amount = this.amountToPrecision(symbol, amount);
|
|
2824
3167
|
const request = {
|
|
@@ -2827,7 +3170,7 @@ class aster extends aster$1["default"] {
|
|
|
2827
3170
|
'amount': amount,
|
|
2828
3171
|
};
|
|
2829
3172
|
const code = market['quote'];
|
|
2830
|
-
const response = await this.
|
|
3173
|
+
const response = await this.fapiPrivatePostV3PositionMargin(this.extend(request, params));
|
|
2831
3174
|
//
|
|
2832
3175
|
// {
|
|
2833
3176
|
// "amount": 100.0,
|
|
@@ -2836,15 +3179,13 @@ class aster extends aster$1["default"] {
|
|
|
2836
3179
|
// "type": 1
|
|
2837
3180
|
// }
|
|
2838
3181
|
//
|
|
2839
|
-
return this.extend(this.parseMarginModification(response, market), {
|
|
2840
|
-
'code': code,
|
|
2841
|
-
});
|
|
3182
|
+
return this.extend(this.parseMarginModification(response, market), { 'code': code });
|
|
2842
3183
|
}
|
|
2843
3184
|
/**
|
|
2844
3185
|
* @method
|
|
2845
3186
|
* @name aster#reduceMargin
|
|
2846
3187
|
* @description remove margin from a position
|
|
2847
|
-
* @see https://github.
|
|
3188
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#modify-isolated-position-margin-trade
|
|
2848
3189
|
* @param {string} symbol unified market symbol
|
|
2849
3190
|
* @param {float} amount the amount of margin to remove
|
|
2850
3191
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -2857,7 +3198,7 @@ class aster extends aster$1["default"] {
|
|
|
2857
3198
|
* @method
|
|
2858
3199
|
* @name aster#addMargin
|
|
2859
3200
|
* @description add margin
|
|
2860
|
-
* @see https://github.
|
|
3201
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#modify-isolated-position-margin-trade
|
|
2861
3202
|
* @param {string} symbol unified market symbol
|
|
2862
3203
|
* @param {float} amount amount of margin to add
|
|
2863
3204
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -2896,7 +3237,7 @@ class aster extends aster$1["default"] {
|
|
|
2896
3237
|
* @method
|
|
2897
3238
|
* @name aster#fetchFundingHistory
|
|
2898
3239
|
* @description fetch the history of funding payments paid and received on this account
|
|
2899
|
-
* @see https://github.
|
|
3240
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#get-income-historyuser_data
|
|
2900
3241
|
* @param {string} symbol unified market symbol
|
|
2901
3242
|
* @param {int} [since] the earliest time in ms to fetch funding history for
|
|
2902
3243
|
* @param {int} [limit] the maximum number of funding history structures to retrieve
|
|
@@ -2907,7 +3248,7 @@ class aster extends aster$1["default"] {
|
|
|
2907
3248
|
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
|
|
2908
3249
|
*/
|
|
2909
3250
|
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2910
|
-
await this.
|
|
3251
|
+
await this.loadMarketsAndSignIn();
|
|
2911
3252
|
let market = undefined;
|
|
2912
3253
|
let request = {
|
|
2913
3254
|
'incomeType': 'FUNDING_FEE', // "TRANSFER","WELCOME_BONUS", "REALIZED_PNL","FUNDING_FEE", "COMMISSION", "INSURANCE_CLEAR", and "MARKET_MERCHANT_RETURN_REWARD"
|
|
@@ -2923,7 +3264,7 @@ class aster extends aster$1["default"] {
|
|
|
2923
3264
|
if (limit !== undefined) {
|
|
2924
3265
|
request['limit'] = Math.min(limit, 1000); // max 1000
|
|
2925
3266
|
}
|
|
2926
|
-
const response = await this.
|
|
3267
|
+
const response = await this.fapiPrivateGetV3Income(this.extend(request, params));
|
|
2927
3268
|
return this.parseIncomes(response, market, since, limit);
|
|
2928
3269
|
}
|
|
2929
3270
|
parseLedgerEntry(item, currency = undefined) {
|
|
@@ -2987,7 +3328,7 @@ class aster extends aster$1["default"] {
|
|
|
2987
3328
|
* @method
|
|
2988
3329
|
* @name aster#fetchLedger
|
|
2989
3330
|
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
|
2990
|
-
* @see https://github.
|
|
3331
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#get-income-historyuser_data
|
|
2991
3332
|
* @param {string} [code] unified currency code
|
|
2992
3333
|
* @param {int} [since] timestamp in ms of the earliest ledger entry
|
|
2993
3334
|
* @param {int} [limit] max number of ledger entries to return
|
|
@@ -2996,7 +3337,7 @@ class aster extends aster$1["default"] {
|
|
|
2996
3337
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
|
|
2997
3338
|
*/
|
|
2998
3339
|
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2999
|
-
await this.
|
|
3340
|
+
await this.loadMarketsAndSignIn();
|
|
3000
3341
|
let currency = undefined;
|
|
3001
3342
|
if (code !== undefined) {
|
|
3002
3343
|
currency = this.currency(code);
|
|
@@ -3013,7 +3354,7 @@ class aster extends aster$1["default"] {
|
|
|
3013
3354
|
params = this.omit(params, 'until');
|
|
3014
3355
|
request['endTime'] = until;
|
|
3015
3356
|
}
|
|
3016
|
-
const response = await this.
|
|
3357
|
+
const response = await this.fapiPrivateGetV3Income(this.extend(request, params));
|
|
3017
3358
|
//
|
|
3018
3359
|
// [
|
|
3019
3360
|
// {
|
|
@@ -3209,7 +3550,7 @@ class aster extends aster$1["default"] {
|
|
|
3209
3550
|
* @method
|
|
3210
3551
|
* @name aster#fetchPositionsRisk
|
|
3211
3552
|
* @description fetch positions risk
|
|
3212
|
-
* @see https://github.
|
|
3553
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#position-information-v3-user_data
|
|
3213
3554
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
3214
3555
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3215
3556
|
* @returns {object} data on the positions risk
|
|
@@ -3220,10 +3561,10 @@ class aster extends aster$1["default"] {
|
|
|
3220
3561
|
throw new errors.ArgumentsRequired(this.id + ' fetchPositionsRisk() requires an array argument for symbols');
|
|
3221
3562
|
}
|
|
3222
3563
|
}
|
|
3223
|
-
await this.
|
|
3564
|
+
await this.loadMarketsAndSignIn();
|
|
3224
3565
|
await this.loadLeverageBrackets(false, params);
|
|
3225
3566
|
const request = {};
|
|
3226
|
-
const response = await this.
|
|
3567
|
+
const response = await this.fapiPrivateGetV3PositionRisk(this.extend(request, params));
|
|
3227
3568
|
//
|
|
3228
3569
|
// [
|
|
3229
3570
|
// {
|
|
@@ -3258,7 +3599,7 @@ class aster extends aster$1["default"] {
|
|
|
3258
3599
|
* @method
|
|
3259
3600
|
* @name aster#fetchPositions
|
|
3260
3601
|
* @description fetch all open positions
|
|
3261
|
-
* @see https://github.
|
|
3602
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#position-information-v3-user_data
|
|
3262
3603
|
* @param {string[]} [symbols] list of unified market symbols
|
|
3263
3604
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3264
3605
|
* @param {string} [params.method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
|
|
@@ -3495,7 +3836,7 @@ class aster extends aster$1["default"] {
|
|
|
3495
3836
|
* @name aster#fetchAccountPositions
|
|
3496
3837
|
* @ignore
|
|
3497
3838
|
* @description fetch account positions
|
|
3498
|
-
|
|
3839
|
+
https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#position-information-v3-user_data
|
|
3499
3840
|
* @param {string[]} [symbols] list of unified market symbols
|
|
3500
3841
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3501
3842
|
* @returns {object} data on account positions
|
|
@@ -3506,7 +3847,7 @@ class aster extends aster$1["default"] {
|
|
|
3506
3847
|
throw new errors.ArgumentsRequired(this.id + ' fetchPositions() requires an array argument for symbols');
|
|
3507
3848
|
}
|
|
3508
3849
|
}
|
|
3509
|
-
await this.
|
|
3850
|
+
await this.loadMarketsAndSignIn();
|
|
3510
3851
|
await this.loadLeverageBrackets(false, params);
|
|
3511
3852
|
const response = await this.fapiPrivateGetV4Account(params);
|
|
3512
3853
|
let filterClosed = undefined;
|
|
@@ -3516,12 +3857,35 @@ class aster extends aster$1["default"] {
|
|
|
3516
3857
|
return this.filterByArrayPositions(result, 'symbol', symbols, false);
|
|
3517
3858
|
}
|
|
3518
3859
|
async loadLeverageBrackets(reload = false, params = {}) {
|
|
3519
|
-
await this.
|
|
3860
|
+
await this.loadMarketsAndSignIn();
|
|
3520
3861
|
// by default cache the leverage bracket
|
|
3521
3862
|
// it contains useful stuff like the maintenance margin and initial margin for positions
|
|
3522
3863
|
const leverageBrackets = this.safeDict(this.options, 'leverageBrackets');
|
|
3523
3864
|
if ((leverageBrackets === undefined) || (reload)) {
|
|
3524
|
-
const response = await this.
|
|
3865
|
+
const response = await this.fapiPrivateGetV3LeverageBracket(params);
|
|
3866
|
+
//
|
|
3867
|
+
// [
|
|
3868
|
+
// {
|
|
3869
|
+
// "symbol": "TRUTHUSDT",
|
|
3870
|
+
// "brackets": [
|
|
3871
|
+
// {
|
|
3872
|
+
// "bracket": "1",
|
|
3873
|
+
// "initialLeverage": "50",
|
|
3874
|
+
// "notionalCap": "5000",
|
|
3875
|
+
// "notionalFloor": "0",
|
|
3876
|
+
// "maintMarginRatio": "0.01",
|
|
3877
|
+
// "cum": "0.0"
|
|
3878
|
+
// },
|
|
3879
|
+
// {
|
|
3880
|
+
// "bracket": "2",
|
|
3881
|
+
// "initialLeverage": "20",
|
|
3882
|
+
// "notionalCap": "10000",
|
|
3883
|
+
// "notionalFloor": "5000",
|
|
3884
|
+
// "maintMarginRatio": "0.025",
|
|
3885
|
+
// "cum": "75.0"
|
|
3886
|
+
// },
|
|
3887
|
+
// ...
|
|
3888
|
+
//
|
|
3525
3889
|
this.options['leverageBrackets'] = this.createSafeDictionary();
|
|
3526
3890
|
for (let i = 0; i < response.length; i++) {
|
|
3527
3891
|
const entry = response[i];
|
|
@@ -3547,12 +3911,11 @@ class aster extends aster$1["default"] {
|
|
|
3547
3911
|
return this.signHash(this.keccakMessage(message), privateKey.slice(-64));
|
|
3548
3912
|
}
|
|
3549
3913
|
signWithdrawPayload(withdrawPayload, network) {
|
|
3550
|
-
const zeroAddress = this.safeString(this.options, 'zeroAddress');
|
|
3551
3914
|
const chainId = this.safeInteger(withdrawPayload, 'chainId');
|
|
3552
3915
|
const domain = {
|
|
3553
3916
|
'chainId': chainId,
|
|
3554
3917
|
'name': 'Aster',
|
|
3555
|
-
'verifyingContract': zeroAddress,
|
|
3918
|
+
'verifyingContract': this.safeString(this.options, 'zeroAddress'),
|
|
3556
3919
|
'version': '1',
|
|
3557
3920
|
};
|
|
3558
3921
|
const messageTypes = {
|
|
@@ -3567,17 +3930,17 @@ class aster extends aster$1["default"] {
|
|
|
3567
3930
|
{ 'name': 'aster chain', 'type': 'string' },
|
|
3568
3931
|
],
|
|
3569
3932
|
};
|
|
3570
|
-
const
|
|
3933
|
+
const request = {
|
|
3571
3934
|
'type': 'Withdraw',
|
|
3572
3935
|
'destination': this.safeString(withdrawPayload, 'receiver'),
|
|
3573
3936
|
'destination Chain': network,
|
|
3574
3937
|
'token': this.safeString(withdrawPayload, 'asset'),
|
|
3575
3938
|
'amount': this.safeString(withdrawPayload, 'amount'),
|
|
3576
3939
|
'fee': this.safeString(withdrawPayload, 'fee'),
|
|
3577
|
-
'nonce': this.safeInteger(withdrawPayload, '
|
|
3940
|
+
'nonce': this.safeInteger(withdrawPayload, 'userNonce'),
|
|
3578
3941
|
'aster chain': 'Mainnet',
|
|
3579
3942
|
};
|
|
3580
|
-
const msg = this.ethEncodeStructuredData(domain, messageTypes,
|
|
3943
|
+
const msg = this.ethEncodeStructuredData(domain, messageTypes, request);
|
|
3581
3944
|
const signature = this.signMessage(msg, this.privateKey);
|
|
3582
3945
|
return signature;
|
|
3583
3946
|
}
|
|
@@ -3585,7 +3948,9 @@ class aster extends aster$1["default"] {
|
|
|
3585
3948
|
* @method
|
|
3586
3949
|
* @name aster#withdraw
|
|
3587
3950
|
* @description make a withdrawal
|
|
3588
|
-
* @see https://github.
|
|
3951
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#withdraw-user_data
|
|
3952
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/deposit%26withdrawal/#withdraw-by-fapiv3-evm-futures
|
|
3953
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/deposit%26withdrawal/#withdraw-by-fapiv3-evm-spot
|
|
3589
3954
|
* @param {string} code unified currency code
|
|
3590
3955
|
* @param {float} amount the amount to withdraw
|
|
3591
3956
|
* @param {string} address the address to withdraw to
|
|
@@ -3596,12 +3961,13 @@ class aster extends aster$1["default"] {
|
|
|
3596
3961
|
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
3597
3962
|
[tag, params] = this.handleWithdrawTagAndParams(tag, params);
|
|
3598
3963
|
this.checkAddress(address);
|
|
3599
|
-
await this.
|
|
3964
|
+
await this.loadMarketsAndSignIn();
|
|
3600
3965
|
const currency = this.currency(code);
|
|
3966
|
+
const nonce = this.milliseconds() * 1000;
|
|
3601
3967
|
const request = {
|
|
3602
3968
|
'asset': currency['id'],
|
|
3603
3969
|
'receiver': address,
|
|
3604
|
-
'
|
|
3970
|
+
'userNonce': nonce.toString(),
|
|
3605
3971
|
};
|
|
3606
3972
|
let chainId = this.safeInteger(params, 'chainId');
|
|
3607
3973
|
// TODO: check how ARBI signature would work
|
|
@@ -3624,23 +3990,32 @@ class aster extends aster$1["default"] {
|
|
|
3624
3990
|
params = this.omit(params, ['chainId', 'network', 'fee']);
|
|
3625
3991
|
request['amount'] = this.currencyToPrecision(code, amount, network);
|
|
3626
3992
|
request['userSignature'] = this.signWithdrawPayload(request, network);
|
|
3627
|
-
const response = await this.
|
|
3993
|
+
const response = await this.sapiPrivatePostV3AsterUserWithdraw(this.extend(request, params));
|
|
3994
|
+
//
|
|
3995
|
+
// {
|
|
3996
|
+
// "withdrawId": "1097219372504338432",
|
|
3997
|
+
// "hash": "0x9e6baa3eb75d92a1164eef51a0cc97b9591930518ba3e8e5ab40ce524ba4e463"
|
|
3998
|
+
// }
|
|
3999
|
+
//
|
|
4000
|
+
return this.parseTransaction(response, currency);
|
|
4001
|
+
}
|
|
4002
|
+
parseTransaction(transaction, currency = undefined) {
|
|
3628
4003
|
return {
|
|
3629
|
-
'info':
|
|
3630
|
-
'id': this.safeString(
|
|
3631
|
-
'txid': this.safeString(
|
|
4004
|
+
'info': transaction,
|
|
4005
|
+
'id': this.safeString(transaction, 'withdrawId'),
|
|
4006
|
+
'txid': this.safeString(transaction, 'hash'),
|
|
3632
4007
|
'timestamp': undefined,
|
|
3633
4008
|
'datetime': undefined,
|
|
3634
|
-
'network':
|
|
3635
|
-
'address':
|
|
3636
|
-
'addressTo':
|
|
4009
|
+
'network': undefined,
|
|
4010
|
+
'address': undefined,
|
|
4011
|
+
'addressTo': undefined,
|
|
3637
4012
|
'addressFrom': undefined,
|
|
3638
|
-
'tag':
|
|
3639
|
-
'tagTo':
|
|
4013
|
+
'tag': undefined,
|
|
4014
|
+
'tagTo': undefined,
|
|
3640
4015
|
'tagFrom': undefined,
|
|
3641
4016
|
'type': 'withdrawal',
|
|
3642
|
-
'amount':
|
|
3643
|
-
'currency':
|
|
4017
|
+
'amount': undefined,
|
|
4018
|
+
'currency': undefined,
|
|
3644
4019
|
'status': undefined,
|
|
3645
4020
|
'updated': undefined,
|
|
3646
4021
|
'internal': undefined,
|
|
@@ -3652,8 +4027,8 @@ class aster extends aster$1["default"] {
|
|
|
3652
4027
|
* @method
|
|
3653
4028
|
* @name aster#transfer
|
|
3654
4029
|
* @description transfer currency internally between wallets on the same account
|
|
3655
|
-
* @see https://github.
|
|
3656
|
-
* @see https://github.
|
|
4030
|
+
* @see https://asterdex.github.io/aster-api-website/spot-v3/account%26trades/#perp-spot-transfer-trade
|
|
4031
|
+
* @see https://asterdex.github.io/aster-api-website/futures-v3/account%26trades/#transfer-between-futures-and-spot-transfer
|
|
3657
4032
|
* @param {string} code unified currency code
|
|
3658
4033
|
* @param {float} amount amount to transfer
|
|
3659
4034
|
* @param {string} fromAccount account to transfer from
|
|
@@ -3662,7 +4037,7 @@ class aster extends aster$1["default"] {
|
|
|
3662
4037
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
3663
4038
|
*/
|
|
3664
4039
|
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
3665
|
-
await this.
|
|
4040
|
+
await this.loadMarketsAndSignIn();
|
|
3666
4041
|
const currency = this.currency(code);
|
|
3667
4042
|
const request = {
|
|
3668
4043
|
'asset': currency['id'],
|
|
@@ -3683,47 +4058,36 @@ class aster extends aster$1["default"] {
|
|
|
3683
4058
|
else if (fromId === 'FUTURE' && toId === 'SPOT') {
|
|
3684
4059
|
type = 'FUTURE_SPOT';
|
|
3685
4060
|
}
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
const defaultClientTranId = this.numberToString(this.milliseconds());
|
|
3689
|
-
const clientTranId = this.safeString(params, 'clientTranId', defaultClientTranId);
|
|
3690
|
-
request['kindType'] = type;
|
|
3691
|
-
request['clientTranId'] = clientTranId;
|
|
3692
|
-
response = await this.fapiPrivatePostV1AssetWalletTransfer(this.extend(request, params));
|
|
3693
|
-
}
|
|
3694
|
-
else {
|
|
3695
|
-
// transfer asset to other address
|
|
3696
|
-
request['toAddress'] = toAccount;
|
|
3697
|
-
response = await this.sapiPrivatePostV1AssetSendToAddress(this.extend(request, params));
|
|
4061
|
+
if (type === undefined) {
|
|
4062
|
+
throw new errors.ArgumentsRequired(this.id + ' transfer() requires fromAccount and toAccount parameters to be either SPOT or FUTURE');
|
|
3698
4063
|
}
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
4064
|
+
let response = undefined;
|
|
4065
|
+
const defaultClientTranId = this.numberToString(this.milliseconds());
|
|
4066
|
+
const clientTranId = this.safeString(params, 'clientTranId', defaultClientTranId);
|
|
4067
|
+
request['kindType'] = type;
|
|
4068
|
+
request['clientTranId'] = clientTranId;
|
|
4069
|
+
response = await this.sapiPrivatePostV3AssetWalletTransfer(this.extend(request, params));
|
|
4070
|
+
return this.parseTransfer(response, currency);
|
|
4071
|
+
}
|
|
4072
|
+
parseTransfer(transfer, currency = undefined) {
|
|
4073
|
+
const currencyId = this.safeString(transfer, 'code');
|
|
3705
4074
|
return {
|
|
3706
|
-
'info':
|
|
3707
|
-
'id': this.safeString(
|
|
3708
|
-
'txid': undefined,
|
|
4075
|
+
'info': transfer,
|
|
4076
|
+
'id': this.safeString(transfer, 'tranId'),
|
|
3709
4077
|
'timestamp': undefined,
|
|
3710
4078
|
'datetime': undefined,
|
|
3711
|
-
'
|
|
3712
|
-
'
|
|
3713
|
-
'
|
|
3714
|
-
'
|
|
3715
|
-
'
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
'
|
|
3721
|
-
'status': undefined,
|
|
3722
|
-
'updated': undefined,
|
|
3723
|
-
'internal': undefined,
|
|
3724
|
-
'comment': undefined,
|
|
3725
|
-
'fee': undefined,
|
|
4079
|
+
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
4080
|
+
'amount': undefined,
|
|
4081
|
+
'fromAccount': undefined,
|
|
4082
|
+
'toAccount': undefined,
|
|
4083
|
+
'status': this.parseTransferStatus(this.safeString(transfer, 'status')),
|
|
4084
|
+
};
|
|
4085
|
+
}
|
|
4086
|
+
parseTransferStatus(status) {
|
|
4087
|
+
const statuses = {
|
|
4088
|
+
'SUCCESS': 'ok',
|
|
3726
4089
|
};
|
|
4090
|
+
return this.safeString(statuses, status, status);
|
|
3727
4091
|
}
|
|
3728
4092
|
hashMessage(binaryMessage) {
|
|
3729
4093
|
// const binaryMessage = this.encode (message);
|
|
@@ -3750,78 +4114,174 @@ class aster extends aster$1["default"] {
|
|
|
3750
4114
|
}
|
|
3751
4115
|
else if (api === 'fapiPrivate' || api === 'sapiPrivate') {
|
|
3752
4116
|
this.checkRequiredCredentials();
|
|
3753
|
-
|
|
3754
|
-
|
|
4117
|
+
const nonce = this.milliseconds() * 1000;
|
|
4118
|
+
// Sign using EIP-712 typed data per the AsterSignTransaction spec
|
|
4119
|
+
const zeroAddress = this.safeString(this.options, 'zeroAddress', '0x0000000000000000000000000000000000000000');
|
|
4120
|
+
const v3ChainId = this.safeInteger(this.options, 'v3ChainId', 1666);
|
|
4121
|
+
const signerAddress = this.safeString(this.options, 'signerAddress');
|
|
4122
|
+
if (signerAddress === undefined) {
|
|
4123
|
+
throw new errors.ArgumentsRequired(this.id + ' requires signerAddress in options when use v3 api');
|
|
4124
|
+
}
|
|
4125
|
+
const domain = {
|
|
4126
|
+
'name': 'AsterSignTransaction',
|
|
4127
|
+
'version': '1',
|
|
4128
|
+
'chainId': v3ChainId,
|
|
4129
|
+
'verifyingContract': zeroAddress,
|
|
3755
4130
|
};
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
4131
|
+
let messageTypes = {
|
|
4132
|
+
'Message': [
|
|
4133
|
+
{ 'name': 'msg', 'type': 'string' },
|
|
4134
|
+
],
|
|
4135
|
+
};
|
|
4136
|
+
// Build v3 params: original endpoint params + nonce (macroseconds) + user + signer
|
|
4137
|
+
// Note: timestamp and recvWindow are not used for v3; nonce replaces timestamp
|
|
4138
|
+
const finalParams = this.extend({
|
|
4139
|
+
'nonce': nonce.toString(),
|
|
4140
|
+
'user': this.walletAddress,
|
|
4141
|
+
'signer': signerAddress,
|
|
3762
4142
|
}, params);
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
if (origclientorderidlistLength > 0) {
|
|
3782
|
-
query = query + '&' + 'origclientorderidlist=%5B' + origclientorderidlist.join('%2C') + '%5D';
|
|
3783
|
-
}
|
|
3784
|
-
}
|
|
3785
|
-
else {
|
|
3786
|
-
query = this.rawencode(extendedParams);
|
|
3787
|
-
}
|
|
3788
|
-
let signature = '';
|
|
3789
|
-
if (path.indexOf('v3') >= 0) {
|
|
3790
|
-
const signerAddress = this.options['signerAddress'];
|
|
3791
|
-
if (signerAddress === undefined) {
|
|
3792
|
-
throw new errors.ArgumentsRequired(this.id + ' requires signerAddress in options when use v3 api');
|
|
3793
|
-
}
|
|
3794
|
-
// the keys order matter
|
|
3795
|
-
const keys = Object.keys(extendedParams);
|
|
3796
|
-
const sortedKeys = this.sort(keys);
|
|
3797
|
-
const signingPayload = {};
|
|
3798
|
-
for (let i = 0; i < sortedKeys.length; i++) {
|
|
3799
|
-
const key = sortedKeys[i];
|
|
3800
|
-
signingPayload[key] = extendedParams[key].toString();
|
|
3801
|
-
}
|
|
3802
|
-
const signingHash = this.hashMessage(this.hash(this.ethAbiEncode([
|
|
3803
|
-
'string', 'address', 'address', 'uint256',
|
|
3804
|
-
], [this.json(signingPayload), this.walletAddress, signerAddress, nonce]), sha3.keccak_256, 'binary'));
|
|
3805
|
-
signature = this.signHash(signingHash, this.privateKey);
|
|
3806
|
-
extendedParams['user'] = this.walletAddress;
|
|
3807
|
-
extendedParams['signer'] = signerAddress;
|
|
3808
|
-
extendedParams['nonce'] = nonce;
|
|
3809
|
-
query = this.rawencode(extendedParams);
|
|
4143
|
+
let paramString = undefined;
|
|
4144
|
+
let paramsToEncode = undefined;
|
|
4145
|
+
const isApproveBuilder = (path.indexOf('/approveBuilder') >= 0);
|
|
4146
|
+
if (isApproveBuilder) {
|
|
4147
|
+
// domain['name'] = 'Aster';
|
|
4148
|
+
messageTypes = {
|
|
4149
|
+
'ApproveBuilder': [
|
|
4150
|
+
{ 'name': 'Builder', 'type': 'string' },
|
|
4151
|
+
{ 'name': 'MaxFeeRate', 'type': 'string' },
|
|
4152
|
+
{ 'name': 'BuilderName', 'type': 'string' },
|
|
4153
|
+
{ 'name': 'AsterChain', 'type': 'string' },
|
|
4154
|
+
{ 'name': 'User', 'type': 'string' },
|
|
4155
|
+
{ 'name': 'Nonce', 'type': 'uint256' },
|
|
4156
|
+
],
|
|
4157
|
+
};
|
|
4158
|
+
delete finalParams['signer']; // signer is not needed for approveBuilder endpoint
|
|
4159
|
+
paramString = this.encodeValuesWithJson(finalParams);
|
|
4160
|
+
paramsToEncode = this.capitalizeKeys(finalParams);
|
|
3810
4161
|
}
|
|
3811
4162
|
else {
|
|
3812
|
-
|
|
4163
|
+
paramString = this.encodeValuesWithJson(finalParams);
|
|
4164
|
+
paramsToEncode = { 'msg': paramString };
|
|
3813
4165
|
}
|
|
3814
|
-
|
|
4166
|
+
const encodedMessage = this.ethEncodeStructuredData(domain, messageTypes, paramsToEncode);
|
|
4167
|
+
const signature = this.signMessage(encodedMessage, this.privateKey);
|
|
4168
|
+
const queryString = paramString + '&' + 'signature=' + signature;
|
|
3815
4169
|
if (method === 'GET') {
|
|
3816
|
-
url += '?' +
|
|
4170
|
+
url += '?' + queryString;
|
|
3817
4171
|
}
|
|
3818
4172
|
else {
|
|
3819
|
-
|
|
4173
|
+
headers = {};
|
|
3820
4174
|
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
4175
|
+
body = queryString;
|
|
3821
4176
|
}
|
|
3822
4177
|
}
|
|
3823
4178
|
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
3824
4179
|
}
|
|
4180
|
+
encodeValuesWithJson(values) {
|
|
4181
|
+
let encodedString = '';
|
|
4182
|
+
const keys = Object.keys(values);
|
|
4183
|
+
for (let i = 0; i < keys.length; i++) {
|
|
4184
|
+
const key = keys[i];
|
|
4185
|
+
const value = values[key];
|
|
4186
|
+
const isObj = Array.isArray(value) || this.isDictionary(value);
|
|
4187
|
+
const valueJsonified = isObj ? this.json(value) : value.toString();
|
|
4188
|
+
const encoded = this.encodeURIComponent(valueJsonified);
|
|
4189
|
+
encodedString += key + '=' + encoded + '&';
|
|
4190
|
+
}
|
|
4191
|
+
return encodedString.slice(0, -1);
|
|
4192
|
+
}
|
|
4193
|
+
capitalizeKeys(dict) {
|
|
4194
|
+
const capitalized = {};
|
|
4195
|
+
const keys = Object.keys(dict);
|
|
4196
|
+
for (let i = 0; i < keys.length; i++) {
|
|
4197
|
+
const key = keys[i];
|
|
4198
|
+
const value = dict[key];
|
|
4199
|
+
const capitalizedKey = this.capitalize(key);
|
|
4200
|
+
capitalized[capitalizedKey] = value;
|
|
4201
|
+
}
|
|
4202
|
+
return capitalized;
|
|
4203
|
+
}
|
|
4204
|
+
async loadMarketsAndSignIn() {
|
|
4205
|
+
await Promise.all([this.loadMarkets(), this.signIn()]);
|
|
4206
|
+
}
|
|
4207
|
+
/**
|
|
4208
|
+
* @method
|
|
4209
|
+
* @name aster#signIn
|
|
4210
|
+
* @description sign in, must be called prior to using other authenticated methods
|
|
4211
|
+
* @see https://asterdex.github.io/aster-api-website/asterCode/integration-flow/
|
|
4212
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4213
|
+
* @returns response from exchange
|
|
4214
|
+
*/
|
|
4215
|
+
async signIn(params = {}) {
|
|
4216
|
+
if (this.isEmptyString(this.privateKey)) {
|
|
4217
|
+
if (!this.isEmptyString(this.apiKey) || !this.isEmptyString(this.secret)) {
|
|
4218
|
+
throw new errors.NotSupported(this.id + 'after the latest upgrade (v4.5.52), CCXT now expects the l1 private key to be provided in the credentials.');
|
|
4219
|
+
}
|
|
4220
|
+
return false;
|
|
4221
|
+
}
|
|
4222
|
+
if (this.privateKey.length > 66) {
|
|
4223
|
+
throw new errors.NotSupported(this.id + ' after the latest update (v4.5.52), CCXT now expects the l1 private key to be provided in the credentials.');
|
|
4224
|
+
}
|
|
4225
|
+
await this.initializeClient(params);
|
|
4226
|
+
return true;
|
|
4227
|
+
}
|
|
4228
|
+
async initializeClient(params = {}) {
|
|
4229
|
+
const builderFee = this.safeBool(params, 'builderFee', this.safeBool(this.options, 'builderFee', true)); // we shouldn't omit here
|
|
4230
|
+
if (!builderFee) {
|
|
4231
|
+
return false; // skip if builder fee is not enabled
|
|
4232
|
+
}
|
|
4233
|
+
const approvedBuilderFee = this.safeBool(this.options, 'approvedBuilderFee', false);
|
|
4234
|
+
if (approvedBuilderFee) {
|
|
4235
|
+
return true; // skip if builder fee is already approved
|
|
4236
|
+
}
|
|
4237
|
+
const result = await this.fapiPrivateGetV3Builder();
|
|
4238
|
+
//
|
|
4239
|
+
// [
|
|
4240
|
+
// {
|
|
4241
|
+
// "userAddress": "0x35a5B33Be664B09F78b5089eb6185f71c8a7f11f",
|
|
4242
|
+
// "builderAddress": "0x1F5877C19e3777Cfd15F9d57253eA4aA5254Ec39",
|
|
4243
|
+
// "maxFeeRate": "0.001",
|
|
4244
|
+
// "builderName": "ccxt"
|
|
4245
|
+
// }
|
|
4246
|
+
// ]
|
|
4247
|
+
//
|
|
4248
|
+
const approvedBuilders = result;
|
|
4249
|
+
const length = approvedBuilders.length;
|
|
4250
|
+
let found = false;
|
|
4251
|
+
for (let i = 0; i < length; i++) {
|
|
4252
|
+
const builderInfo = this.safeDict(approvedBuilders, i, {});
|
|
4253
|
+
const builderAccountId = this.safeString(builderInfo, 'builderAddress');
|
|
4254
|
+
if (builderAccountId === this.safeString(this.options, 'builder')) {
|
|
4255
|
+
found = true;
|
|
4256
|
+
break;
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4259
|
+
if (!found) {
|
|
4260
|
+
this.options['approvedBuilderFee'] = true;
|
|
4261
|
+
try {
|
|
4262
|
+
const request = {
|
|
4263
|
+
'builder': this.safeString(this.options, 'builder'),
|
|
4264
|
+
'builderName': this.safeString(this.options, 'builderName', 'ccxt'),
|
|
4265
|
+
'maxFeeRate': this.safeString(this.options, 'builderRate'),
|
|
4266
|
+
'signatureChainId': this.safeInteger(this.options, 'v3ChainId', 1666),
|
|
4267
|
+
'asterChain': 'Mainnet',
|
|
4268
|
+
};
|
|
4269
|
+
const authResponse = await this.fapiPrivatePostV3ApproveBuilder(this.extend(request, params));
|
|
4270
|
+
//
|
|
4271
|
+
// {"code": 200,"msg": "success"}
|
|
4272
|
+
//
|
|
4273
|
+
const codeRes = this.safeInteger(authResponse, 'code');
|
|
4274
|
+
if (codeRes !== 200) {
|
|
4275
|
+
throw new errors.ExchangeError('Builder authorization failed, ' + this.json(authResponse));
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4278
|
+
catch (e) {
|
|
4279
|
+
this.options['approvedBuilderFee'] = false;
|
|
4280
|
+
this.options['builderFee'] = false; // disable if err
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4283
|
+
return undefined; // just c#
|
|
4284
|
+
}
|
|
3825
4285
|
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
3826
4286
|
if (response === undefined) {
|
|
3827
4287
|
return undefined; // fallback to default error handler
|