ccxt 4.5.42 → 4.5.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/abstract/aftermath.js +11 -0
- package/dist/cjs/src/aftermath.js +1324 -0
- package/dist/cjs/src/base/Exchange.js +2 -1
- package/dist/cjs/src/bigone.js +3 -0
- package/dist/cjs/src/bingx.js +1 -0
- package/dist/cjs/src/bitget.js +88 -37
- package/dist/cjs/src/bithumb.js +0 -8
- package/dist/cjs/src/bullish.js +109 -0
- package/dist/cjs/src/bybit.js +1 -0
- package/dist/cjs/src/coinbaseinternational.js +1 -0
- package/dist/cjs/src/coinex.js +1 -0
- package/dist/cjs/src/coinmetro.js +1 -1
- package/dist/cjs/src/gate.js +1 -0
- package/dist/cjs/src/gemini.js +1 -0
- package/dist/cjs/src/htx.js +2 -1
- package/dist/cjs/src/hyperliquid.js +40 -2
- package/dist/cjs/src/independentreserve.js +15 -4
- package/dist/cjs/src/krakenfutures.js +5 -2
- package/dist/cjs/src/kucoin.js +20 -3
- package/dist/cjs/src/lbank.js +1 -1
- package/dist/cjs/src/lighter.js +56 -6
- package/dist/cjs/src/luno.js +1 -0
- package/dist/cjs/src/okx.js +17 -2
- package/dist/cjs/src/pro/aftermath.js +375 -0
- package/dist/cjs/src/pro/bingx.js +5 -1
- package/dist/cjs/src/pro/cex.js +24 -28
- package/dist/cjs/src/pro/krakenfutures.js +9 -3
- package/dist/cjs/src/pro/lighter.js +127 -4
- package/dist/cjs/src/pro/mexc.js +7 -1
- package/dist/cjs/src/pro/paradex.js +3 -3
- package/dist/cjs/src/pro/woo.js +3 -8
- package/dist/cjs/src/toobit.js +1 -0
- package/js/ccxt.d.ts +8 -2
- package/js/ccxt.js +6 -2
- package/js/src/abstract/aftermath.d.ts +33 -0
- package/js/src/abstract/aftermath.js +11 -0
- package/js/src/aftermath.d.ts +291 -0
- package/js/src/aftermath.js +1322 -0
- package/js/src/base/Exchange.js +2 -1
- package/js/src/bigone.js +3 -0
- package/js/src/bingx.js +1 -0
- package/js/src/bitget.js +88 -37
- package/js/src/bithumb.js +0 -8
- package/js/src/bullish.d.ts +12 -1
- package/js/src/bullish.js +109 -0
- package/js/src/bybit.js +1 -0
- package/js/src/coinbaseinternational.js +2 -1
- package/js/src/coinex.js +1 -0
- package/js/src/coinmetro.js +1 -1
- package/js/src/gate.js +1 -0
- package/js/src/gemini.js +1 -0
- package/js/src/htx.js +2 -1
- package/js/src/hyperliquid.d.ts +11 -0
- package/js/src/hyperliquid.js +40 -2
- package/js/src/independentreserve.d.ts +1 -0
- package/js/src/independentreserve.js +15 -4
- package/js/src/krakenfutures.js +5 -2
- package/js/src/kucoin.d.ts +1 -0
- package/js/src/kucoin.js +20 -3
- package/js/src/lbank.js +1 -1
- package/js/src/lighter.d.ts +6 -1
- package/js/src/lighter.js +56 -6
- package/js/src/luno.js +1 -0
- package/js/src/okx.js +17 -2
- package/js/src/pro/aftermath.d.ts +55 -0
- package/js/src/pro/aftermath.js +374 -0
- package/js/src/pro/bingx.js +5 -1
- package/js/src/pro/cex.d.ts +1 -0
- package/js/src/pro/cex.js +24 -28
- package/js/src/pro/krakenfutures.js +9 -3
- package/js/src/pro/lighter.d.ts +23 -0
- package/js/src/pro/lighter.js +127 -4
- package/js/src/pro/mexc.js +7 -1
- package/js/src/pro/paradex.js +3 -3
- package/js/src/pro/woo.js +3 -8
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
- package/js/src/toobit.js +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,1324 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var aftermath$1 = require('./abstract/aftermath.js');
|
|
6
|
+
var number = require('./base/functions/number.js');
|
|
7
|
+
var crypto = require('./base/functions/crypto.js');
|
|
8
|
+
var ed25519 = require('./static_dependencies/noble-curves/ed25519.js');
|
|
9
|
+
var errors = require('./base/errors.js');
|
|
10
|
+
|
|
11
|
+
// ----------------------------------------------------------------------------
|
|
12
|
+
class aftermath extends aftermath$1["default"] {
|
|
13
|
+
describe() {
|
|
14
|
+
return this.deepExtend(super.describe(), {
|
|
15
|
+
'id': 'aftermath',
|
|
16
|
+
'name': 'AftermathFinance',
|
|
17
|
+
'countries': [],
|
|
18
|
+
'version': 'v1',
|
|
19
|
+
'rateLimit': 50,
|
|
20
|
+
'certified': false,
|
|
21
|
+
'pro': true,
|
|
22
|
+
'dex': true,
|
|
23
|
+
'has': {
|
|
24
|
+
'CORS': undefined,
|
|
25
|
+
'spot': false,
|
|
26
|
+
'margin': false,
|
|
27
|
+
'swap': true,
|
|
28
|
+
'future': false,
|
|
29
|
+
'option': false,
|
|
30
|
+
'addMargin': true,
|
|
31
|
+
'cancelOrder': true,
|
|
32
|
+
'cancelOrders': true,
|
|
33
|
+
'createOrder': true,
|
|
34
|
+
'createOrders': true,
|
|
35
|
+
'editOrder': false,
|
|
36
|
+
'fetchAccounts': true,
|
|
37
|
+
'fetchBalance': true,
|
|
38
|
+
'fetchCurrencies': true,
|
|
39
|
+
'fetchDepositAddress': false,
|
|
40
|
+
'fetchDeposits': false,
|
|
41
|
+
'fetchLedger': false,
|
|
42
|
+
'fetchMarkets': true,
|
|
43
|
+
'fetchMyTrades': false,
|
|
44
|
+
'fetchOHLCV': true,
|
|
45
|
+
'fetchOpenOrders': true,
|
|
46
|
+
'fetchOrder': false,
|
|
47
|
+
'fetchOrderBook': true,
|
|
48
|
+
'fetchOrders': false,
|
|
49
|
+
'fetchPosition': true,
|
|
50
|
+
'fetchPositions': true,
|
|
51
|
+
'fetchTicker': true,
|
|
52
|
+
'fetchTickers': true,
|
|
53
|
+
'fetchTrades': true,
|
|
54
|
+
'fetchTradingFee': true,
|
|
55
|
+
'fetchTradingFees': false,
|
|
56
|
+
'fetchTradingLimits': false,
|
|
57
|
+
'fetchTransactions': false,
|
|
58
|
+
'fetchWithdrawals': false,
|
|
59
|
+
'reduceMargin': true,
|
|
60
|
+
'setLeverage': true,
|
|
61
|
+
'transfer': true,
|
|
62
|
+
'withdraw': true,
|
|
63
|
+
},
|
|
64
|
+
'timeframes': {
|
|
65
|
+
'1m': '1m',
|
|
66
|
+
'3m': '3m',
|
|
67
|
+
'5m': '5m',
|
|
68
|
+
'15m': '15m',
|
|
69
|
+
'30m': '30m',
|
|
70
|
+
'1h': '1h',
|
|
71
|
+
'2h': '2h',
|
|
72
|
+
'4h': '4h',
|
|
73
|
+
'8h': '8h',
|
|
74
|
+
'12h': '12h',
|
|
75
|
+
'1d': '1d',
|
|
76
|
+
'3d': '3d',
|
|
77
|
+
'1w': '1w',
|
|
78
|
+
'1M': '1M',
|
|
79
|
+
},
|
|
80
|
+
'urls': {
|
|
81
|
+
'logo': 'https://github.com/user-attachments/assets/70e5ae86-2f3a-4755-976b-aedb9d3c2807',
|
|
82
|
+
'api': {
|
|
83
|
+
'rest': 'https://aftermath.finance/api/ccxt',
|
|
84
|
+
},
|
|
85
|
+
'test': {
|
|
86
|
+
'rest': 'https://testnet.aftermath.finance/api/ccxt',
|
|
87
|
+
},
|
|
88
|
+
'docs': 'https://docs.aftermath.finance',
|
|
89
|
+
},
|
|
90
|
+
'api': {
|
|
91
|
+
'public': {
|
|
92
|
+
'get': {
|
|
93
|
+
'markets': 1,
|
|
94
|
+
'currencies': 1,
|
|
95
|
+
},
|
|
96
|
+
'post': {
|
|
97
|
+
'ticker': 1,
|
|
98
|
+
'orderbook': 1,
|
|
99
|
+
'trades': 1,
|
|
100
|
+
'OHLCV': 1,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
'private': {
|
|
104
|
+
'post': {
|
|
105
|
+
'accounts': 1,
|
|
106
|
+
'balance': 1,
|
|
107
|
+
'myPendingOrders': 1,
|
|
108
|
+
'positions': 1,
|
|
109
|
+
'build/allocate': 1,
|
|
110
|
+
'build/cancelOrders': 1,
|
|
111
|
+
'build/createAccount': 1,
|
|
112
|
+
'build/createOrders': 1,
|
|
113
|
+
'build/deallocate': 1,
|
|
114
|
+
'build/deposit': 1,
|
|
115
|
+
'build/setLeverage': 1,
|
|
116
|
+
'build/withdraw': 1,
|
|
117
|
+
'submit/allocate': 1,
|
|
118
|
+
'submit/cancelOrders': 1,
|
|
119
|
+
'submit/createAccount': 1,
|
|
120
|
+
'submit/createOrders': 1,
|
|
121
|
+
'submit/deallocate': 1,
|
|
122
|
+
'submit/deposit': 1,
|
|
123
|
+
'submit/setLeverage': 1,
|
|
124
|
+
'submit/withdraw': 1,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
'requiredCredentials': {
|
|
129
|
+
'apiKey': false,
|
|
130
|
+
'secret': false,
|
|
131
|
+
'walletAddress': true,
|
|
132
|
+
'privateKey': true,
|
|
133
|
+
},
|
|
134
|
+
'precisionMode': number.TICK_SIZE,
|
|
135
|
+
'options': {
|
|
136
|
+
'defaultType': 'swap',
|
|
137
|
+
'sandboxMode': false,
|
|
138
|
+
},
|
|
139
|
+
'exceptions': {
|
|
140
|
+
'exact': {},
|
|
141
|
+
'broad': {},
|
|
142
|
+
},
|
|
143
|
+
'features': {
|
|
144
|
+
'default': {
|
|
145
|
+
'sandbox': true,
|
|
146
|
+
'createOrder': {
|
|
147
|
+
'timeInForce': {
|
|
148
|
+
'IOC': true,
|
|
149
|
+
'FOK': true,
|
|
150
|
+
'PO': true,
|
|
151
|
+
'GTD': false,
|
|
152
|
+
},
|
|
153
|
+
'leverage': false,
|
|
154
|
+
'marketBuyRequiresPrice': false,
|
|
155
|
+
'marketBuyByCost': false,
|
|
156
|
+
'selfTradePrevention': false,
|
|
157
|
+
'trailing': false,
|
|
158
|
+
'iceberg': false,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* @method
|
|
166
|
+
* @name aftermath#fetchCurrencies
|
|
167
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/currencies
|
|
168
|
+
* @description fetches all available currencies on an exchange
|
|
169
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
170
|
+
* @returns {object} an associative dictionary of currencies
|
|
171
|
+
*/
|
|
172
|
+
async fetchCurrencies(params = {}) {
|
|
173
|
+
const response = await this.publicGetCurrencies(params);
|
|
174
|
+
const currencies = this.parseCurrencies(response);
|
|
175
|
+
//
|
|
176
|
+
// {
|
|
177
|
+
// "BTC": {
|
|
178
|
+
// "id": "BTC",
|
|
179
|
+
// "code": "BTC",
|
|
180
|
+
// "precision": 1e-9,
|
|
181
|
+
// "name": "BTC",
|
|
182
|
+
// "active": true,
|
|
183
|
+
// "deposit": false,
|
|
184
|
+
// "withdraw": false,
|
|
185
|
+
// "limits": {
|
|
186
|
+
// "amount": {},
|
|
187
|
+
// "withdraw": {}
|
|
188
|
+
// },
|
|
189
|
+
// "networks": {}
|
|
190
|
+
// }
|
|
191
|
+
// }
|
|
192
|
+
//
|
|
193
|
+
return currencies;
|
|
194
|
+
}
|
|
195
|
+
parseCurrency(rawCurrency) {
|
|
196
|
+
return this.safeCurrencyStructure({
|
|
197
|
+
'id': this.safeString(rawCurrency, 'id'),
|
|
198
|
+
'code': this.safeString(rawCurrency, 'code'),
|
|
199
|
+
'name': this.safeString(rawCurrency, 'name'),
|
|
200
|
+
'active': this.safeBool(rawCurrency, 'active'),
|
|
201
|
+
'deposit': this.safeBool(rawCurrency, 'deposit'),
|
|
202
|
+
'withdraw': this.safeBool(rawCurrency, 'withdraw'),
|
|
203
|
+
'precision': this.safeNumber(rawCurrency, 'precision'),
|
|
204
|
+
'type': 'crypto',
|
|
205
|
+
'info': rawCurrency,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* @method
|
|
210
|
+
* @name aftermath#fetchMarkets
|
|
211
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/markets
|
|
212
|
+
* @description retrieves data on all markets for woo
|
|
213
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
214
|
+
* @returns {object[]} an array of objects representing market data
|
|
215
|
+
*/
|
|
216
|
+
async fetchMarkets(params = {}) {
|
|
217
|
+
const response = await this.publicGetMarkets(params);
|
|
218
|
+
//
|
|
219
|
+
// [
|
|
220
|
+
// {
|
|
221
|
+
// "id": "0x49bd40cc7880bd358465116157f0271c25d23361b94eace9a25dc2019b449bfc",
|
|
222
|
+
// "symbol": "BTC/USD:USDC",
|
|
223
|
+
// "base": "BTC",
|
|
224
|
+
// "quote": "USD",
|
|
225
|
+
// "baseId": "BTC",
|
|
226
|
+
// "quoteId": "USD",
|
|
227
|
+
// "active": true,
|
|
228
|
+
// "type": "swap",
|
|
229
|
+
// "spot": false,
|
|
230
|
+
// "margin": false,
|
|
231
|
+
// "swap": true,
|
|
232
|
+
// "future": false,
|
|
233
|
+
// "option": false,
|
|
234
|
+
// "contract": true,
|
|
235
|
+
// "settle": "USDC",
|
|
236
|
+
// "settleId": "0x457049371f5b5dc2bda857bb804ca6e93c5a3cae1636d0cd17bb6b6070d19458::usdc::USDC",
|
|
237
|
+
// "contractSize": 0.00001,
|
|
238
|
+
// "linear": true,
|
|
239
|
+
// "inverse": false,
|
|
240
|
+
// "taker": 0.001,
|
|
241
|
+
// "maker": 0.0,
|
|
242
|
+
// "percentage": true,
|
|
243
|
+
// "tierBased": false,
|
|
244
|
+
// "precision": {
|
|
245
|
+
// "amount": 0.00001,
|
|
246
|
+
// "price": 0.0001
|
|
247
|
+
// },
|
|
248
|
+
// "limits": {
|
|
249
|
+
// "cost": {
|
|
250
|
+
// "min": 1.0
|
|
251
|
+
// },
|
|
252
|
+
// "leverage": {
|
|
253
|
+
// "max": 50.0
|
|
254
|
+
// }
|
|
255
|
+
// },
|
|
256
|
+
// "marginModes": {
|
|
257
|
+
// "isolated": true,
|
|
258
|
+
// "cross": false
|
|
259
|
+
// },
|
|
260
|
+
// "subType": "linear"
|
|
261
|
+
// }
|
|
262
|
+
// ]
|
|
263
|
+
//
|
|
264
|
+
return this.parseMarkets(response);
|
|
265
|
+
}
|
|
266
|
+
parseMarket(market) {
|
|
267
|
+
//
|
|
268
|
+
// {
|
|
269
|
+
// "id": "0x49bd40cc7880bd358465116157f0271c25d23361b94eace9a25dc2019b449bfc",
|
|
270
|
+
// "symbol": "BTC/USD:USDC",
|
|
271
|
+
// "base": "BTC",
|
|
272
|
+
// "quote": "USD",
|
|
273
|
+
// "baseId": "BTC",
|
|
274
|
+
// "quoteId": "USD",
|
|
275
|
+
// "active": true,
|
|
276
|
+
// "type": "swap",
|
|
277
|
+
// "spot": false,
|
|
278
|
+
// "margin": false,
|
|
279
|
+
// "swap": true,
|
|
280
|
+
// "future": false,
|
|
281
|
+
// "option": false,
|
|
282
|
+
// "contract": true,
|
|
283
|
+
// "settle": "USDC",
|
|
284
|
+
// "settleId": "0x457049371f5b5dc2bda857bb804ca6e93c5a3cae1636d0cd17bb6b6070d19458::usdc::USDC",
|
|
285
|
+
// "contractSize": 0.00001,
|
|
286
|
+
// "linear": true,
|
|
287
|
+
// "inverse": false,
|
|
288
|
+
// "taker": 0.001,
|
|
289
|
+
// "maker": 0.0,
|
|
290
|
+
// "percentage": true,
|
|
291
|
+
// "tierBased": false,
|
|
292
|
+
// "precision": {
|
|
293
|
+
// "amount": 0.00001,
|
|
294
|
+
// "price": 0.0001
|
|
295
|
+
// },
|
|
296
|
+
// "limits": {
|
|
297
|
+
// "cost": {
|
|
298
|
+
// "min": 1.0
|
|
299
|
+
// },
|
|
300
|
+
// "leverage": {
|
|
301
|
+
// "max": 50.0
|
|
302
|
+
// }
|
|
303
|
+
// },
|
|
304
|
+
// "marginModes": {
|
|
305
|
+
// "isolated": true,
|
|
306
|
+
// "cross": false
|
|
307
|
+
// },
|
|
308
|
+
// "subType": "linear"
|
|
309
|
+
// }
|
|
310
|
+
//
|
|
311
|
+
const precision = this.safeDict(market, 'precision');
|
|
312
|
+
const limits = this.safeDict(market, 'limits');
|
|
313
|
+
return this.safeMarketStructure({
|
|
314
|
+
'id': this.safeString(market, 'id'),
|
|
315
|
+
'symbol': this.safeString(market, 'symbol'),
|
|
316
|
+
'base': this.safeString(market, 'base'),
|
|
317
|
+
'quote': this.safeString(market, 'quote'),
|
|
318
|
+
'settle': this.safeString(market, 'settle'),
|
|
319
|
+
'baseId': this.safeString(market, 'baseId'),
|
|
320
|
+
'quoteId': this.safeString(market, 'quoteId'),
|
|
321
|
+
'settleId': this.safeString(market, 'settleId'),
|
|
322
|
+
'type': this.safeString(market, 'type'),
|
|
323
|
+
'subType': this.safeString(market, 'subType'),
|
|
324
|
+
'spot': this.safeBool(market, 'spot'),
|
|
325
|
+
'margin': this.safeBool(market, 'margin'),
|
|
326
|
+
'swap': this.safeBool(market, 'swap'),
|
|
327
|
+
'future': this.safeBool(market, 'future'),
|
|
328
|
+
'option': this.safeBool(market, 'option'),
|
|
329
|
+
'active': this.safeBool(market, 'active'),
|
|
330
|
+
'contract': this.safeBool(market, 'contract'),
|
|
331
|
+
'linear': this.safeBool(market, 'linear'),
|
|
332
|
+
'inverse': this.safeBool(market, 'inverse'),
|
|
333
|
+
'tierBased': this.safeBool(market, 'tierBased'),
|
|
334
|
+
'percentage': this.safeBool(market, 'percentage'),
|
|
335
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
336
|
+
'expiry': undefined,
|
|
337
|
+
'expiryDatetime': undefined,
|
|
338
|
+
'strike': undefined,
|
|
339
|
+
'optionType': undefined,
|
|
340
|
+
'taker': this.safeNumber(market, 'taker'),
|
|
341
|
+
'maker': this.safeNumber(market, 'maker'),
|
|
342
|
+
'precision': {
|
|
343
|
+
'amount': this.safeNumber(precision, 'amount'),
|
|
344
|
+
'price': this.safeNumber(precision, 'price'),
|
|
345
|
+
},
|
|
346
|
+
'limits': {
|
|
347
|
+
'leverage': {
|
|
348
|
+
'min': undefined,
|
|
349
|
+
'max': this.safeNumber(limits['leverage'], 'max'),
|
|
350
|
+
},
|
|
351
|
+
'amount': {
|
|
352
|
+
'min': undefined,
|
|
353
|
+
'max': undefined,
|
|
354
|
+
},
|
|
355
|
+
'price': {
|
|
356
|
+
'min': undefined,
|
|
357
|
+
'max': undefined,
|
|
358
|
+
},
|
|
359
|
+
'cost': {
|
|
360
|
+
'min': this.safeNumber(limits['cost'], 'min'),
|
|
361
|
+
'max': undefined,
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
'marginModes': this.safeDict(market, 'marginModes'),
|
|
365
|
+
'created': undefined,
|
|
366
|
+
'info': market,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* @method
|
|
371
|
+
* @name aftermath#fetchTradingFee
|
|
372
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/markets
|
|
373
|
+
* @description fetch the trading fees for a market
|
|
374
|
+
* @param {string} symbol unified market symbol
|
|
375
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
376
|
+
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
377
|
+
*/
|
|
378
|
+
async fetchTradingFee(symbol, params = {}) {
|
|
379
|
+
await this.loadMarkets();
|
|
380
|
+
const market = this.market(symbol);
|
|
381
|
+
return this.parseTradingFee(market);
|
|
382
|
+
}
|
|
383
|
+
parseTradingFee(market = undefined) {
|
|
384
|
+
const symbol = this.safeString(market, 'symbol');
|
|
385
|
+
return {
|
|
386
|
+
'info': market,
|
|
387
|
+
'symbol': symbol,
|
|
388
|
+
'maker': this.safeNumber(market, 'maker'),
|
|
389
|
+
'taker': this.safeNumber(market, 'taker'),
|
|
390
|
+
'percentage': true,
|
|
391
|
+
'tierBased': undefined,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* @method
|
|
396
|
+
* @name aftermath#fetchTicker
|
|
397
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/ticker
|
|
398
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
399
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
400
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
401
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
402
|
+
*/
|
|
403
|
+
async fetchTicker(symbol, params = {}) {
|
|
404
|
+
await this.loadMarkets();
|
|
405
|
+
const market = this.market(symbol);
|
|
406
|
+
const request = {
|
|
407
|
+
'chId': market['id'],
|
|
408
|
+
};
|
|
409
|
+
const response = await this.publicPostTicker(this.extend(request, params));
|
|
410
|
+
//
|
|
411
|
+
// {
|
|
412
|
+
// "ask": 0.1,
|
|
413
|
+
// "askVolume": 0.1,
|
|
414
|
+
// "average": 0.1,
|
|
415
|
+
// "baseVolume": 0.1,
|
|
416
|
+
// "bid": 0.1,
|
|
417
|
+
// "bidVolume": 0.1,
|
|
418
|
+
// "change": 0.1,
|
|
419
|
+
// "close": 0.1,
|
|
420
|
+
// "high": 0.1,
|
|
421
|
+
// "indexPrice": 0.1,
|
|
422
|
+
// "last": 0.1,
|
|
423
|
+
// "low": 0.1,
|
|
424
|
+
// "markPrice": 0.1,
|
|
425
|
+
// "open": 0.1,
|
|
426
|
+
// "percentage": 0.1,
|
|
427
|
+
// "previousClose": 0.1,
|
|
428
|
+
// "quoteVolume": 0.1,
|
|
429
|
+
// "symbol": "string",
|
|
430
|
+
// "timestamp": null,
|
|
431
|
+
// "vwap": 0.1
|
|
432
|
+
// }
|
|
433
|
+
//
|
|
434
|
+
return this.parseTicker(response, market);
|
|
435
|
+
}
|
|
436
|
+
parseTicker(ticker, market = undefined) {
|
|
437
|
+
const timestamp = this.safeInteger(ticker, 'timestamp');
|
|
438
|
+
return this.safeTicker({
|
|
439
|
+
'symbol': this.safeString(ticker, 'symbol'),
|
|
440
|
+
'timestamp': timestamp,
|
|
441
|
+
'datetime': this.iso8601(timestamp),
|
|
442
|
+
'high': this.safeString(ticker, 'high'),
|
|
443
|
+
'low': this.safeString(ticker, 'low'),
|
|
444
|
+
'bid': this.safeString(ticker, 'bid'),
|
|
445
|
+
'bidVolume': this.safeString(ticker, 'bidVolume'),
|
|
446
|
+
'ask': this.safeString(ticker, 'ask'),
|
|
447
|
+
'askVolume': this.safeString(ticker, 'askVolume'),
|
|
448
|
+
'vwap': this.safeString(ticker, 'vwap'),
|
|
449
|
+
'open': this.safeString(ticker, 'open'),
|
|
450
|
+
'close': undefined,
|
|
451
|
+
'last': undefined,
|
|
452
|
+
'previousClose': undefined,
|
|
453
|
+
'change': this.safeString(ticker, 'change'),
|
|
454
|
+
'percentage': undefined,
|
|
455
|
+
'average': undefined,
|
|
456
|
+
'baseVolume': this.safeString(ticker, 'baseVolume'),
|
|
457
|
+
'quoteVolume': this.safeString(ticker, 'quoteVolume'),
|
|
458
|
+
'markPrice': undefined,
|
|
459
|
+
'indexPrice': this.safeString(ticker, 'indexPrice'),
|
|
460
|
+
'info': ticker,
|
|
461
|
+
}, market);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* @method
|
|
465
|
+
* @name aftermath#fetchOrderBook
|
|
466
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/orderbook
|
|
467
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
468
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
469
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
470
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
471
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
472
|
+
*/
|
|
473
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
474
|
+
await this.loadMarkets();
|
|
475
|
+
const market = this.market(symbol);
|
|
476
|
+
const chId = this.safeString(market, 'id');
|
|
477
|
+
const request = {
|
|
478
|
+
'chId': chId,
|
|
479
|
+
};
|
|
480
|
+
const response = await this.publicPostOrderbook(this.extend(request, params));
|
|
481
|
+
//
|
|
482
|
+
// {
|
|
483
|
+
// "asks":[
|
|
484
|
+
// [76228.1534,11.58777]
|
|
485
|
+
// ],
|
|
486
|
+
// "bids":[
|
|
487
|
+
// [76213.4842,11.96145],
|
|
488
|
+
// ],
|
|
489
|
+
// "datetime":"2025-04-07 09:29:28.213 UTC",
|
|
490
|
+
// "timestamp":1744018168213,
|
|
491
|
+
// "symbol":"BTC/USD:USDC"
|
|
492
|
+
// }
|
|
493
|
+
//
|
|
494
|
+
const timestamp = this.safeInteger(response, 'timestamp');
|
|
495
|
+
const orderbook = this.parseOrderBook(response, symbol, timestamp);
|
|
496
|
+
orderbook['nonce'] = this.safeInteger(response, 'nonce');
|
|
497
|
+
return orderbook;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* @method
|
|
501
|
+
* @name aftermath#fetchTrades
|
|
502
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/trades
|
|
503
|
+
* @description get the list of most recent trades for a particular symbol
|
|
504
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
505
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
506
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
507
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
508
|
+
* @param {int} [params.until] the latest time in ms to fetch trades for
|
|
509
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
510
|
+
*/
|
|
511
|
+
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
512
|
+
await this.loadMarkets();
|
|
513
|
+
const market = this.market(symbol);
|
|
514
|
+
const chId = this.safeString(market, 'id');
|
|
515
|
+
const request = {
|
|
516
|
+
'chId': chId,
|
|
517
|
+
};
|
|
518
|
+
if (limit !== undefined) {
|
|
519
|
+
request['limit'] = Math.min(limit, 50);
|
|
520
|
+
}
|
|
521
|
+
const response = await this.publicPostTrades(this.extend(request, params));
|
|
522
|
+
//
|
|
523
|
+
// {
|
|
524
|
+
// "trades": [
|
|
525
|
+
// {
|
|
526
|
+
// "amount": 0.03378,
|
|
527
|
+
// "datetime": "2025-12-29 22:43:54.639 UTC",
|
|
528
|
+
// "price": 87239.09499000001,
|
|
529
|
+
// "timestamp": 1767048234639,
|
|
530
|
+
// "side": "buy",
|
|
531
|
+
// "symbol": "BTC/USD:USDC"
|
|
532
|
+
// }
|
|
533
|
+
// ],
|
|
534
|
+
// "nextCursor": 573
|
|
535
|
+
// }
|
|
536
|
+
//
|
|
537
|
+
const data = this.safeList(response, 'trades', []);
|
|
538
|
+
return this.parseTrades(data, market, since, limit);
|
|
539
|
+
}
|
|
540
|
+
parseTrade(rawTrade, market = undefined) {
|
|
541
|
+
const trade = this.safeTrade(this.extend({ 'info': rawTrade }, rawTrade));
|
|
542
|
+
trade['id'] = '';
|
|
543
|
+
trade['order'] = undefined;
|
|
544
|
+
trade['takerOrMaker'] = undefined;
|
|
545
|
+
trade['timestamp'] = this.safeInteger(rawTrade, 'timestamp');
|
|
546
|
+
return trade;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* @method
|
|
550
|
+
* @name aftermath#fetchOHLCV
|
|
551
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/ohlcv
|
|
552
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
553
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
554
|
+
* @param {string} timeframe the length of time each candle represents
|
|
555
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
556
|
+
* @param {int} [limit] max=1000, max=100 when since is defined and is less than (now - (999 * (timeframe in ms)))
|
|
557
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
558
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
559
|
+
*/
|
|
560
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
561
|
+
await this.loadMarkets();
|
|
562
|
+
const market = this.market(symbol);
|
|
563
|
+
const chId = this.safeString(market, 'id');
|
|
564
|
+
const request = {
|
|
565
|
+
'chId': chId,
|
|
566
|
+
'timeframe': timeframe,
|
|
567
|
+
};
|
|
568
|
+
if (since !== undefined) {
|
|
569
|
+
request['since'] = since;
|
|
570
|
+
}
|
|
571
|
+
if (limit !== undefined) {
|
|
572
|
+
request['limit'] = limit;
|
|
573
|
+
}
|
|
574
|
+
const response = await this.publicPostOHLCV(this.extend(request, params));
|
|
575
|
+
//
|
|
576
|
+
// [
|
|
577
|
+
// [
|
|
578
|
+
// 1743932340000,
|
|
579
|
+
// 83093.5445,
|
|
580
|
+
// 83093.5445,
|
|
581
|
+
// 83093.5445,
|
|
582
|
+
// 83093.5445,
|
|
583
|
+
// 0.0
|
|
584
|
+
// ]
|
|
585
|
+
// ]
|
|
586
|
+
//
|
|
587
|
+
return this.parseOHLCVs(response, market, timeframe, since, limit);
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* @method
|
|
591
|
+
* @name aftermath#fetchBalance
|
|
592
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/balance
|
|
593
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in positions
|
|
594
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
595
|
+
* @param {string} [params.account] account object ID, required
|
|
596
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
597
|
+
*/
|
|
598
|
+
async fetchBalance(params = {}) {
|
|
599
|
+
let account = undefined;
|
|
600
|
+
[account, params] = this.handleOptionAndParams(params, 'fetchBalance', 'account');
|
|
601
|
+
const request = {
|
|
602
|
+
'account': account,
|
|
603
|
+
};
|
|
604
|
+
if (account === undefined) {
|
|
605
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchBalance() requires account');
|
|
606
|
+
}
|
|
607
|
+
const response = await this.privatePostBalance(this.extend(request, params));
|
|
608
|
+
//
|
|
609
|
+
// {
|
|
610
|
+
// "timestamp": 1744045700352,
|
|
611
|
+
// "balances": {
|
|
612
|
+
// "USDC": {
|
|
613
|
+
// "free": 7.726913939320065,
|
|
614
|
+
// "used": 22.273086060679937,
|
|
615
|
+
// "total": 30.0
|
|
616
|
+
// }
|
|
617
|
+
// }
|
|
618
|
+
// }
|
|
619
|
+
//
|
|
620
|
+
return this.parseBalance(response);
|
|
621
|
+
}
|
|
622
|
+
parseBalance(response) {
|
|
623
|
+
const result = {
|
|
624
|
+
'info': response,
|
|
625
|
+
};
|
|
626
|
+
const balances = this.safeDict(response, 'balances', []);
|
|
627
|
+
const currencies = Object.keys(balances);
|
|
628
|
+
for (let i = 0; i < currencies.length; i++) {
|
|
629
|
+
const code = currencies[i];
|
|
630
|
+
const balance = balances[code];
|
|
631
|
+
const account = this.account();
|
|
632
|
+
account['free'] = this.safeString(balance, 'free');
|
|
633
|
+
account['used'] = this.safeString(balance, 'used');
|
|
634
|
+
account['total'] = this.safeString(balance, 'total');
|
|
635
|
+
result[code] = account;
|
|
636
|
+
}
|
|
637
|
+
const timestamp = this.safeInteger(response, 'timestamp');
|
|
638
|
+
result['timestamp'] = timestamp;
|
|
639
|
+
result['datetime'] = this.iso8601(timestamp);
|
|
640
|
+
return this.safeBalance(result);
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* @method
|
|
644
|
+
* @name aftermath#fetchAccounts
|
|
645
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/accounts
|
|
646
|
+
* @description query for accounts owned by the walletAddress. An Account is needed for all trading methods.
|
|
647
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
648
|
+
* @returns {Array} a list of [account structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#accounts}
|
|
649
|
+
*/
|
|
650
|
+
async fetchAccounts(params = {}) {
|
|
651
|
+
await this.loadMarkets();
|
|
652
|
+
const request = {
|
|
653
|
+
'address': this.walletAddress,
|
|
654
|
+
};
|
|
655
|
+
const response = await this.privatePostAccounts(this.extend(request, params));
|
|
656
|
+
//
|
|
657
|
+
// [
|
|
658
|
+
// {
|
|
659
|
+
// "id": "0x21c5e3d2f5bcfd4351a62cd70874878b7923b56d79d04225ed96370a7ac844c4",
|
|
660
|
+
// "type": "primary",
|
|
661
|
+
// "code": "USDC",
|
|
662
|
+
// "accountNumber": 14822
|
|
663
|
+
// }
|
|
664
|
+
// ]
|
|
665
|
+
//
|
|
666
|
+
return this.parseAccounts(response);
|
|
667
|
+
}
|
|
668
|
+
parseAccount(account) {
|
|
669
|
+
return {
|
|
670
|
+
'id': this.safeString(account, 'id'),
|
|
671
|
+
'type': this.safeString(account, 'type'),
|
|
672
|
+
'code': this.safeString(account, 'code'),
|
|
673
|
+
'info': account,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* @method
|
|
678
|
+
* @name aftermath#fetchOpenOrders
|
|
679
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/my_pending_orders
|
|
680
|
+
* @description fetch all unfilled currently open orders
|
|
681
|
+
* @param {string} symbol unified market symbol
|
|
682
|
+
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
683
|
+
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
684
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
685
|
+
* @param {int} [params.accountNumber] account number to query orders for, required
|
|
686
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
687
|
+
*/
|
|
688
|
+
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
689
|
+
await this.loadMarkets();
|
|
690
|
+
const market = this.market(symbol);
|
|
691
|
+
let accountNumber = undefined;
|
|
692
|
+
[accountNumber, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'accountNumber');
|
|
693
|
+
if (accountNumber === undefined) {
|
|
694
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrders() requires an accountNumber parameter in params');
|
|
695
|
+
}
|
|
696
|
+
const request = {
|
|
697
|
+
'chId': this.safeString(market, 'id'),
|
|
698
|
+
'accountNumber': accountNumber,
|
|
699
|
+
};
|
|
700
|
+
const response = await this.privatePostMyPendingOrders(this.extend(request, params));
|
|
701
|
+
//
|
|
702
|
+
// [
|
|
703
|
+
// {
|
|
704
|
+
// "id": "340282366919093789037556908196463492660",
|
|
705
|
+
// "datetime": "2025-04-07 14:10:49.472 UTC",
|
|
706
|
+
// "timestamp": 1744035049472,
|
|
707
|
+
// "status": "open",
|
|
708
|
+
// "symbol": "BTC/USD:USDC",
|
|
709
|
+
// "type": "limit",
|
|
710
|
+
// "side": "buy",
|
|
711
|
+
// "price": 10000.0,
|
|
712
|
+
// "amount": 0.0001,
|
|
713
|
+
// "filled": 0.0,
|
|
714
|
+
// "remaining": 0.0001,
|
|
715
|
+
// "cost": 0.0,
|
|
716
|
+
// "trades": [],
|
|
717
|
+
// "fee": {}
|
|
718
|
+
// }
|
|
719
|
+
// ]
|
|
720
|
+
//
|
|
721
|
+
return this.parseOrders(response);
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* @method
|
|
725
|
+
* @name aftermath#fetchPosition
|
|
726
|
+
* @description fetch data on an open position
|
|
727
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/positions
|
|
728
|
+
* @param {string} symbol unified market symbol of the market the position is held in
|
|
729
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
730
|
+
* @param {int} [params.accountNumber] account number to query positions for, required
|
|
731
|
+
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
732
|
+
*/
|
|
733
|
+
async fetchPosition(symbol, params = {}) {
|
|
734
|
+
const positions = await this.fetchPositions([symbol], params);
|
|
735
|
+
return this.safeDict(positions, 0, {});
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* @method
|
|
739
|
+
* @name aftermath#fetchPositions
|
|
740
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/positions
|
|
741
|
+
* @description fetch all open positions
|
|
742
|
+
* @param {string[]} symbols list of unified market symbols
|
|
743
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
744
|
+
* @param {int} [params.accountNumber] account number to query positions for, required
|
|
745
|
+
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
746
|
+
*/
|
|
747
|
+
async fetchPositions(symbols = undefined, params = {}) {
|
|
748
|
+
await this.loadMarkets();
|
|
749
|
+
let accountNumber = undefined;
|
|
750
|
+
[accountNumber, params] = this.handleOptionAndParams(params, 'fetchPositions', 'accountNumber');
|
|
751
|
+
if (accountNumber === undefined) {
|
|
752
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchPositions() requires an accountNumber parameter in params');
|
|
753
|
+
}
|
|
754
|
+
const request = {
|
|
755
|
+
'accountNumber': accountNumber,
|
|
756
|
+
};
|
|
757
|
+
const response = await this.privatePostPositions(this.extend(request, params));
|
|
758
|
+
//
|
|
759
|
+
// [
|
|
760
|
+
// {
|
|
761
|
+
// "id": "0xb60c5078b060e4aede8e670089c9b1bc6eb231b4bcc0bfb3e97534770ace4d0c:101",
|
|
762
|
+
// "symbol": "BTC/USD",
|
|
763
|
+
// "timestamp": 1744360128358,
|
|
764
|
+
// "datetime": "2025-04-11 08:28:48.358 UTC",
|
|
765
|
+
// "side": "long",
|
|
766
|
+
// "contracts": 0.001,
|
|
767
|
+
// "contractSize": 81299.8225,
|
|
768
|
+
// "entryPrice": 0.000012292609480106,
|
|
769
|
+
// "notional": 81.30326975863777,
|
|
770
|
+
// "leverage": 2.091737393826,
|
|
771
|
+
// "collateral": 38.918646841955464,
|
|
772
|
+
// "initialMargin": 2.0325817439659444,
|
|
773
|
+
// "maintenanceMargin": 1.0162908719829722,
|
|
774
|
+
// "initialMarginPercentage": 0.025,
|
|
775
|
+
// "maintenanceMarginPercentage": 0.0125,
|
|
776
|
+
// "unrealizedPnl": -0.0498699,
|
|
777
|
+
// "liquidationPrice": 42969.81843916013,
|
|
778
|
+
// "marginMode": "isolated",
|
|
779
|
+
// "marginRatio": 0.4780714839977587
|
|
780
|
+
// }
|
|
781
|
+
// ]
|
|
782
|
+
//
|
|
783
|
+
return this.parsePositions(response, symbols);
|
|
784
|
+
}
|
|
785
|
+
parsePosition(position, market = undefined) {
|
|
786
|
+
return this.safePosition(position);
|
|
787
|
+
}
|
|
788
|
+
parseCreateEditOrderArgs(id, symbol, type, side, amount, price = undefined, params = {}) {
|
|
789
|
+
const market = this.market(symbol);
|
|
790
|
+
symbol = market['symbol'];
|
|
791
|
+
const order = {
|
|
792
|
+
'symbol': symbol,
|
|
793
|
+
'type': type,
|
|
794
|
+
'side': side,
|
|
795
|
+
'amount': amount,
|
|
796
|
+
'price': price,
|
|
797
|
+
'params': params,
|
|
798
|
+
};
|
|
799
|
+
if (id !== undefined) {
|
|
800
|
+
order['id'] = id;
|
|
801
|
+
}
|
|
802
|
+
return order;
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* @method
|
|
806
|
+
* @name aftermath#createOrder
|
|
807
|
+
* @description create a trade order
|
|
808
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/build_create_orders
|
|
809
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/submit_create_orders
|
|
810
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
811
|
+
* @param {string} type 'market' or 'limit'
|
|
812
|
+
* @param {string} side 'buy' or 'sell'
|
|
813
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
814
|
+
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
815
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
816
|
+
* @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
|
|
817
|
+
* @param {Account} [params.account] account id to use, required
|
|
818
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
819
|
+
*/
|
|
820
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
821
|
+
await this.loadMarkets();
|
|
822
|
+
let account = undefined;
|
|
823
|
+
[account, params] = this.handleOptionAndParams(params, 'createOrder', 'account');
|
|
824
|
+
const order = this.parseCreateEditOrderArgs(undefined, symbol, type, side, amount, price, params);
|
|
825
|
+
const orders = await this.createOrders([order], { 'account': account });
|
|
826
|
+
return orders[0];
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* @method
|
|
830
|
+
* @name aftermath#createOrders
|
|
831
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/build_create_orders
|
|
832
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/submit_create_orders
|
|
833
|
+
* @description create a list of trade orders
|
|
834
|
+
* @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
|
|
835
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
836
|
+
* @param {Account} [params.account] account id to use, required
|
|
837
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
838
|
+
*/
|
|
839
|
+
async createOrders(orders, params = {}) {
|
|
840
|
+
await this.loadMarkets();
|
|
841
|
+
const ordersRequest = [];
|
|
842
|
+
for (let i = 0; i < orders.length; i++) {
|
|
843
|
+
const order = this.clone(orders[i]);
|
|
844
|
+
const symbol = this.safeString(order, 'symbol');
|
|
845
|
+
const market = this.market(symbol);
|
|
846
|
+
const price = this.safeString(order, 'price');
|
|
847
|
+
const amount = this.safeString(order, 'amount');
|
|
848
|
+
const orderParams = this.safeDict(order, 'params', {});
|
|
849
|
+
const reduceOnly = this.safeBool(orderParams, 'reduceOnly');
|
|
850
|
+
if (reduceOnly !== undefined) {
|
|
851
|
+
order['reduceOnly'] = reduceOnly;
|
|
852
|
+
}
|
|
853
|
+
delete order['symbol'];
|
|
854
|
+
delete order['params'];
|
|
855
|
+
order['chId'] = market['id'];
|
|
856
|
+
if (price !== undefined) {
|
|
857
|
+
order['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
|
|
858
|
+
}
|
|
859
|
+
order['amount'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
|
|
860
|
+
ordersRequest.push(order);
|
|
861
|
+
}
|
|
862
|
+
let account = undefined;
|
|
863
|
+
[account, params] = this.handleOptionAndParams(params, 'createOrders', 'account');
|
|
864
|
+
const txRequest = {
|
|
865
|
+
'accountId': account,
|
|
866
|
+
'metadata': {
|
|
867
|
+
'sender': this.walletAddress,
|
|
868
|
+
},
|
|
869
|
+
'orders': ordersRequest,
|
|
870
|
+
'deallocateFreeCollateral': false,
|
|
871
|
+
};
|
|
872
|
+
const tx = await this.privatePostBuildCreateOrders(this.extend(txRequest, params));
|
|
873
|
+
const request = this.signTxEd25519(tx);
|
|
874
|
+
const response = await this.privatePostSubmitCreateOrders(request);
|
|
875
|
+
//
|
|
876
|
+
// [
|
|
877
|
+
// {
|
|
878
|
+
// "id": "340282366919093604570116171100942992979",
|
|
879
|
+
// "datetime": "2025-04-10 10:38:39.323 UTC",
|
|
880
|
+
// "timestamp": 1744281519323,
|
|
881
|
+
// "status": "open",
|
|
882
|
+
// "symbol": "BTC/USD:USDC",
|
|
883
|
+
// "type": "limit",
|
|
884
|
+
// "side": "buy",
|
|
885
|
+
// "price": 10001.0,
|
|
886
|
+
// "average": 0.0,
|
|
887
|
+
// "amount": 0.01,
|
|
888
|
+
// "filled": 0.0,
|
|
889
|
+
// "remaining": 0.01,
|
|
890
|
+
// "cost": 0.0,
|
|
891
|
+
// "trades": [],
|
|
892
|
+
// "fee": {}
|
|
893
|
+
// }
|
|
894
|
+
// ]
|
|
895
|
+
//
|
|
896
|
+
return this.parseOrders(response);
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* @method
|
|
900
|
+
* @name aftermath#cancelOrder
|
|
901
|
+
* @description cancels an open order
|
|
902
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/build_cancel_orders
|
|
903
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/submit_cancel_orders
|
|
904
|
+
* @param {string} id order id
|
|
905
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
906
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
907
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
908
|
+
*/
|
|
909
|
+
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
910
|
+
const orders = await this.cancelOrders([id], symbol, params);
|
|
911
|
+
return this.safeDict(orders, 0);
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* @method
|
|
915
|
+
* @name aftermath#cancelOrders
|
|
916
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/build_cancel_orders
|
|
917
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/submit_cancel_orders
|
|
918
|
+
* @description cancel multiple orders
|
|
919
|
+
* @param {string[]} ids order ids
|
|
920
|
+
* @param {string} [symbol] unified market symbol
|
|
921
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
922
|
+
* @param {Account} [params.account] account to cancel orders for, required
|
|
923
|
+
* @returns {Order[]} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
924
|
+
*/
|
|
925
|
+
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
926
|
+
await this.loadMarkets();
|
|
927
|
+
const market = this.market(symbol);
|
|
928
|
+
let account = undefined;
|
|
929
|
+
[account, params] = this.handleOptionAndParams(params, 'cancelOrders', 'account');
|
|
930
|
+
const txRequest = {
|
|
931
|
+
'accountId': account,
|
|
932
|
+
'metadata': {
|
|
933
|
+
'sender': this.walletAddress,
|
|
934
|
+
},
|
|
935
|
+
'chId': market['id'],
|
|
936
|
+
'orderIds': ids,
|
|
937
|
+
};
|
|
938
|
+
const tx = await this.privatePostBuildCancelOrders(txRequest);
|
|
939
|
+
const request = this.signTxEd25519(tx);
|
|
940
|
+
const response = await this.privatePostSubmitCancelOrders(request);
|
|
941
|
+
//
|
|
942
|
+
// [
|
|
943
|
+
// {
|
|
944
|
+
// "id": "340282366919093604570116171100942992979",
|
|
945
|
+
// "datetime": "2025-04-10 10:45:16.765 UTC",
|
|
946
|
+
// "timestamp": 1744281916765,
|
|
947
|
+
// "status": "closed",
|
|
948
|
+
// "symbol": "BTC/USD:USDC",
|
|
949
|
+
// "type": "limit",
|
|
950
|
+
// "side": "buy",
|
|
951
|
+
// "price": 10001.0,
|
|
952
|
+
// "amount": 0.01,
|
|
953
|
+
// "filled": 0.0,
|
|
954
|
+
// "remaining": 0.0,
|
|
955
|
+
// "cost": 0.0,
|
|
956
|
+
// "trades": [],
|
|
957
|
+
// "fee": {}
|
|
958
|
+
// }
|
|
959
|
+
// ]
|
|
960
|
+
//
|
|
961
|
+
return this.parseOrders(response);
|
|
962
|
+
}
|
|
963
|
+
async createAccount(symbol, params = {}) {
|
|
964
|
+
await this.loadMarkets();
|
|
965
|
+
const market = this.market(symbol);
|
|
966
|
+
const settleId = market['settleId'];
|
|
967
|
+
const txRequest = {
|
|
968
|
+
'metadata': {
|
|
969
|
+
'sender': this.walletAddress,
|
|
970
|
+
},
|
|
971
|
+
'settleId': settleId,
|
|
972
|
+
};
|
|
973
|
+
const tx = await this.privatePostBuildCreateAccount(txRequest);
|
|
974
|
+
const request = this.signTxEd25519(tx);
|
|
975
|
+
const response = await this.privatePostSubmitCreateAccount(request);
|
|
976
|
+
//
|
|
977
|
+
// [
|
|
978
|
+
// {
|
|
979
|
+
// "id": "0x2238b380cdf548cf9922a76ad8cf41cd886a04c1a68e7d0f99100b84b0b1ee48",
|
|
980
|
+
// "type": "primary",
|
|
981
|
+
// "code": "USDC",
|
|
982
|
+
// "accountNumber": 357
|
|
983
|
+
// },
|
|
984
|
+
// {
|
|
985
|
+
// "id": "0x6048be1c533a25226e2b505f5c7b8c4d731c87e9fb775dc577052c66febf1c93",
|
|
986
|
+
// "type": "subaccount",
|
|
987
|
+
// "code": "USDC",
|
|
988
|
+
// "accountNumber": 357
|
|
989
|
+
// }
|
|
990
|
+
// ]
|
|
991
|
+
//
|
|
992
|
+
return response;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* @method
|
|
996
|
+
* @name aftermath#addMargin
|
|
997
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/build_allocate
|
|
998
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/submit_allocate
|
|
999
|
+
* @description add margin
|
|
1000
|
+
* @param {string} symbol unified market symbol
|
|
1001
|
+
* @param {float} amount amount of margin to add
|
|
1002
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1003
|
+
* @param {Account} [params.account] account id to use, required
|
|
1004
|
+
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
|
|
1005
|
+
*/
|
|
1006
|
+
async addMargin(symbol, amount, params = {}) {
|
|
1007
|
+
await this.loadMarkets();
|
|
1008
|
+
const market = this.market(symbol);
|
|
1009
|
+
let account = undefined;
|
|
1010
|
+
[account, params] = this.handleOptionAndParams2(params, 'addMargin', 'account', 'accountId');
|
|
1011
|
+
const txRequest = {
|
|
1012
|
+
'accountId': account,
|
|
1013
|
+
'chId': market['id'],
|
|
1014
|
+
'amount': this.parseToNumeric(this.amountToPrecision(symbol, amount)),
|
|
1015
|
+
'metadata': {
|
|
1016
|
+
'sender': this.walletAddress,
|
|
1017
|
+
},
|
|
1018
|
+
};
|
|
1019
|
+
const tx = await this.privatePostBuildAllocate(txRequest);
|
|
1020
|
+
const request = this.signTxEd25519(tx);
|
|
1021
|
+
const response = await this.privatePostSubmitAllocate(request);
|
|
1022
|
+
//
|
|
1023
|
+
// {
|
|
1024
|
+
// "id": "0xb60c5078b060e4aede8e670089c9b1bc6eb231b4bcc0bfb3e97534770ace4d0c:101",
|
|
1025
|
+
// "symbol": "BTC/USD",
|
|
1026
|
+
// "contracts": 0.0,
|
|
1027
|
+
// "contractSize": 81656.98359916,
|
|
1028
|
+
// "notional": 0.0,
|
|
1029
|
+
// "leverage": 0.0,
|
|
1030
|
+
// "collateral": 40.0,
|
|
1031
|
+
// "initialMargin": 0.0,
|
|
1032
|
+
// "maintenanceMargin": 0.0,
|
|
1033
|
+
// "initialMarginPercentage": 0.025,
|
|
1034
|
+
// "maintenanceMarginPercentage": 0.0125,
|
|
1035
|
+
// "unrealizedPnl": 0.0,
|
|
1036
|
+
// "marginMode": "isolated"
|
|
1037
|
+
// }
|
|
1038
|
+
//
|
|
1039
|
+
return response;
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* @method
|
|
1043
|
+
* @name aftermath#reduceMargin
|
|
1044
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/build_deallocate
|
|
1045
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/submit_deallocate
|
|
1046
|
+
* @description remove margin from a position
|
|
1047
|
+
* @param {string} symbol unified market symbol
|
|
1048
|
+
* @param {float} amount amount of margin to remove
|
|
1049
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1050
|
+
* @param {Account} [params.account] account id to use, required
|
|
1051
|
+
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
|
|
1052
|
+
*/
|
|
1053
|
+
async reduceMargin(symbol, amount, params = {}) {
|
|
1054
|
+
await this.loadMarkets();
|
|
1055
|
+
const market = this.market(symbol);
|
|
1056
|
+
let account = undefined;
|
|
1057
|
+
[account, params] = this.handleOptionAndParams2(params, 'reduceMargin', 'account', 'accountId');
|
|
1058
|
+
const txRequest = {
|
|
1059
|
+
'accountId': account,
|
|
1060
|
+
'chId': market['id'],
|
|
1061
|
+
'amount': this.parseToNumeric(this.amountToPrecision(symbol, amount)),
|
|
1062
|
+
'metadata': {
|
|
1063
|
+
'sender': this.walletAddress,
|
|
1064
|
+
},
|
|
1065
|
+
};
|
|
1066
|
+
const tx = await this.privatePostBuildDeallocate(txRequest);
|
|
1067
|
+
const request = this.signTxEd25519(tx);
|
|
1068
|
+
const response = await this.privatePostSubmitDeallocate(request);
|
|
1069
|
+
//
|
|
1070
|
+
// {
|
|
1071
|
+
// "id": "0xb60c5078b060e4aede8e670089c9b1bc6eb231b4bcc0bfb3e97534770ace4d0c:101",
|
|
1072
|
+
// "symbol": "BTC/USD",
|
|
1073
|
+
// "contracts": 0.0,
|
|
1074
|
+
// "contractSize": 81678.2625,
|
|
1075
|
+
// "notional": 0.0,
|
|
1076
|
+
// "leverage": 0.0,
|
|
1077
|
+
// "collateral": 39.0,
|
|
1078
|
+
// "initialMargin": 0.0,
|
|
1079
|
+
// "maintenanceMargin": 0.0,
|
|
1080
|
+
// "initialMarginPercentage": 0.025,
|
|
1081
|
+
// "maintenanceMarginPercentage": 0.0125,
|
|
1082
|
+
// "unrealizedPnl": 0.0,
|
|
1083
|
+
// "marginMode": "isolated"
|
|
1084
|
+
// }
|
|
1085
|
+
//
|
|
1086
|
+
return response;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* @method
|
|
1090
|
+
* @name aftermath#transfer
|
|
1091
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/build_deposit
|
|
1092
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/submit_deposit
|
|
1093
|
+
* @description transfer currency internally between wallets on the same account
|
|
1094
|
+
* @param {string} code unified currency code
|
|
1095
|
+
* @param {float} amount amount to transfer
|
|
1096
|
+
* @param {string} fromAccount account to transfer from
|
|
1097
|
+
* @param {string} toAccount account to transfer to
|
|
1098
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1099
|
+
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
1100
|
+
*/
|
|
1101
|
+
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
1102
|
+
await this.loadMarkets();
|
|
1103
|
+
const currency = this.currency(code);
|
|
1104
|
+
const txRequest = {
|
|
1105
|
+
'metadata': {
|
|
1106
|
+
'sender': this.walletAddress,
|
|
1107
|
+
},
|
|
1108
|
+
'accountId': toAccount,
|
|
1109
|
+
'amount': amount,
|
|
1110
|
+
};
|
|
1111
|
+
const tx = await this.privatePostBuildDeposit(txRequest);
|
|
1112
|
+
const request = this.signTxEd25519(tx);
|
|
1113
|
+
const response = await this.privatePostSubmitDeposit(request);
|
|
1114
|
+
//
|
|
1115
|
+
// {
|
|
1116
|
+
// "id": "0xf93f9bb8bf97eb570410caada92cfa3e66c7ed3a203a164f51d22d41eabe09c0",
|
|
1117
|
+
// "type": "subaccount",
|
|
1118
|
+
// "code": "USDC",
|
|
1119
|
+
// "accountNumber": 101,
|
|
1120
|
+
// "collateral": 1.0
|
|
1121
|
+
// }
|
|
1122
|
+
//
|
|
1123
|
+
return this.extend(this.parseTransfer(response, currency), {
|
|
1124
|
+
'fromAccount': this.walletAddress,
|
|
1125
|
+
'toAccount': toAccount,
|
|
1126
|
+
'amount': amount,
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
parseTransfer(transfer, currency = undefined) {
|
|
1130
|
+
const currencyId = this.safeString(transfer, 'code');
|
|
1131
|
+
return {
|
|
1132
|
+
'info': transfer,
|
|
1133
|
+
'id': this.safeString(transfer, 'id'),
|
|
1134
|
+
'timestamp': undefined,
|
|
1135
|
+
'datetime': undefined,
|
|
1136
|
+
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
1137
|
+
'amount': undefined,
|
|
1138
|
+
'fromAccount': undefined,
|
|
1139
|
+
'toAccount': undefined,
|
|
1140
|
+
'status': undefined,
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* @method
|
|
1145
|
+
* @name aftermath#withdraw
|
|
1146
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/build_withdraw
|
|
1147
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/submit_withdraw
|
|
1148
|
+
* @description make a withdrawal
|
|
1149
|
+
* @param {string} code unified currency code
|
|
1150
|
+
* @param {float} amount the amount to withdraw
|
|
1151
|
+
* @param {string} address the address to withdraw to
|
|
1152
|
+
* @param {string} tag
|
|
1153
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1154
|
+
* @param {Account} [params.account] account id to use, required
|
|
1155
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1156
|
+
*/
|
|
1157
|
+
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
1158
|
+
await this.loadMarkets();
|
|
1159
|
+
const currency = this.currency(code);
|
|
1160
|
+
let account = undefined;
|
|
1161
|
+
[account, params] = this.handleOptionAndParams(params, 'withdraw', 'account');
|
|
1162
|
+
if (account === undefined) {
|
|
1163
|
+
throw new errors.ArgumentsRequired(this.id + ' withdraw() requires a account parameter in params');
|
|
1164
|
+
}
|
|
1165
|
+
const txRequest = {
|
|
1166
|
+
'accountId': account,
|
|
1167
|
+
'metadata': {
|
|
1168
|
+
'sender': this.walletAddress,
|
|
1169
|
+
},
|
|
1170
|
+
'amount': amount,
|
|
1171
|
+
};
|
|
1172
|
+
const tx = await this.privatePostBuildWithdraw(txRequest);
|
|
1173
|
+
const request = this.signTxEd25519(tx);
|
|
1174
|
+
const response = await this.privatePostSubmitWithdraw(request);
|
|
1175
|
+
//
|
|
1176
|
+
// {
|
|
1177
|
+
// "id": "0xf93f9bb8bf97eb570410caada92cfa3e66c7ed3a203a164f51d22d41eabe09c0",
|
|
1178
|
+
// "type": "subaccount",
|
|
1179
|
+
// "code": "USDC",
|
|
1180
|
+
// "accountNumber": 101,
|
|
1181
|
+
// "collateral": 39.0
|
|
1182
|
+
// }
|
|
1183
|
+
//
|
|
1184
|
+
return this.extend(this.parseTransaction(response, currency), {
|
|
1185
|
+
'addressFrom': account,
|
|
1186
|
+
'amount': amount,
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
parseTransaction(transaction, currency = undefined) {
|
|
1190
|
+
return {
|
|
1191
|
+
'info': transaction,
|
|
1192
|
+
'id': this.safeString(transaction, 'id'),
|
|
1193
|
+
'txid': this.safeString(transaction, 'tx_id'),
|
|
1194
|
+
'timestamp': undefined,
|
|
1195
|
+
'datetime': undefined,
|
|
1196
|
+
'address': undefined,
|
|
1197
|
+
'addressFrom': undefined,
|
|
1198
|
+
'addressTo': undefined,
|
|
1199
|
+
'tag': undefined,
|
|
1200
|
+
'tagFrom': undefined,
|
|
1201
|
+
'tagTo': undefined,
|
|
1202
|
+
'type': undefined,
|
|
1203
|
+
'amount': undefined,
|
|
1204
|
+
'currency': this.safeString(transaction, 'code'),
|
|
1205
|
+
'status': undefined,
|
|
1206
|
+
'updated': undefined,
|
|
1207
|
+
'comment': undefined,
|
|
1208
|
+
'internal': undefined,
|
|
1209
|
+
'fee': undefined,
|
|
1210
|
+
'network': undefined,
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* @method
|
|
1215
|
+
* @name aftermath#setLeverage
|
|
1216
|
+
* @description set the level of leverage for a market
|
|
1217
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/build_set_leverage
|
|
1218
|
+
* @see https://testnet.aftermath.finance/docs/#/CCXT/submit_set_leverage
|
|
1219
|
+
* @param {float} leverage the rate of leverage
|
|
1220
|
+
* @param {string} symbol unified market symbol
|
|
1221
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1222
|
+
* @param {Account} [params.account] account id to use, required
|
|
1223
|
+
* @returns {object} response from the exchange
|
|
1224
|
+
*/
|
|
1225
|
+
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
1226
|
+
if (symbol === undefined) {
|
|
1227
|
+
throw new errors.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
|
|
1228
|
+
}
|
|
1229
|
+
await this.loadMarkets();
|
|
1230
|
+
const market = this.market(symbol);
|
|
1231
|
+
let account = undefined;
|
|
1232
|
+
[account, params] = this.handleOptionAndParams2(params, 'setLeverage', 'account', 'accountId');
|
|
1233
|
+
const txRequest = {
|
|
1234
|
+
'accountId': account,
|
|
1235
|
+
'chId': market['id'],
|
|
1236
|
+
'leverage': leverage,
|
|
1237
|
+
'metadata': {
|
|
1238
|
+
'sender': this.walletAddress,
|
|
1239
|
+
},
|
|
1240
|
+
};
|
|
1241
|
+
const tx = await this.privatePostBuildSetLeverage(txRequest);
|
|
1242
|
+
const request = this.signTxEd25519(tx);
|
|
1243
|
+
const response = await this.privatePostSubmitSetLeverage(request);
|
|
1244
|
+
//
|
|
1245
|
+
// {
|
|
1246
|
+
// "id": "0xyydsxxxxxxxxyydsxxxxxxx:141",
|
|
1247
|
+
// "symbol": "BTC/USD:USDC",
|
|
1248
|
+
// "marginMode": "isolated",
|
|
1249
|
+
// "side": "long",
|
|
1250
|
+
// "contracts": 0.001,
|
|
1251
|
+
// "contractSize": 88506.195911625,
|
|
1252
|
+
// "entryPrice": 90999.0,
|
|
1253
|
+
// "notional": 88.50907726931732,
|
|
1254
|
+
// "marginRatio": 1.0000000000041465,
|
|
1255
|
+
// "leverage": 0.9999999999958537,
|
|
1256
|
+
// "collateral": 91.00196251238035,
|
|
1257
|
+
// "initialMargin": 2.212726931732933,
|
|
1258
|
+
// "maintenanceMargin": 1.1063634658664665,
|
|
1259
|
+
// "initialMarginPercentage": 0.025,
|
|
1260
|
+
// "maintenanceMarginPercentage": 0.0125,
|
|
1261
|
+
// "unrealizedPnl": -2.492804088375008,
|
|
1262
|
+
// "liquidationPrice": -3.71625538227e-7
|
|
1263
|
+
// }
|
|
1264
|
+
//
|
|
1265
|
+
return response;
|
|
1266
|
+
}
|
|
1267
|
+
/**
|
|
1268
|
+
* @method
|
|
1269
|
+
* @name aftermath#signTxEd25519
|
|
1270
|
+
* @description Helper to sign some transaction bytes and return a generic transaction execution request.
|
|
1271
|
+
* @param {object} [tx] transaction bytes and the signing digest for them
|
|
1272
|
+
* @returns {object} the input transaction bytes and the signed digest
|
|
1273
|
+
*/
|
|
1274
|
+
signTxEd25519(tx) {
|
|
1275
|
+
if (this.privateKey.indexOf('suiprivkey') >= 0) {
|
|
1276
|
+
throw new errors.NotSupported(this.id + ' only support hex encoding private key, please transform bech32 encoding private key');
|
|
1277
|
+
}
|
|
1278
|
+
const signingDigest = this.safeString(tx, 'signingDigest');
|
|
1279
|
+
const digest = this.base64ToBinary(signingDigest);
|
|
1280
|
+
const privateKey = this.base16ToBinary(this.privateKey);
|
|
1281
|
+
const signature = crypto.eddsa(digest, privateKey, ed25519.ed25519);
|
|
1282
|
+
const hexPublicKey = this.safeString(this.options, 'publicKey');
|
|
1283
|
+
if (hexPublicKey === undefined) {
|
|
1284
|
+
throw new errors.ArgumentsRequired(this.id + ' requires hex encoding public key in options');
|
|
1285
|
+
}
|
|
1286
|
+
const publicKey = this.base16ToBinary(hexPublicKey);
|
|
1287
|
+
const suiSignature = this.binaryConcat(this.base16ToBinary('00'), this.binaryConcat(this.base64ToBinary(signature), publicKey));
|
|
1288
|
+
const base64Sig = this.binaryToBase64(suiSignature);
|
|
1289
|
+
const transactionBytes = this.safeString(tx, 'transactionBytes');
|
|
1290
|
+
const signatures = [base64Sig];
|
|
1291
|
+
return { 'transactionBytes': transactionBytes, 'signatures': signatures };
|
|
1292
|
+
}
|
|
1293
|
+
parseOrder(order, market = undefined) {
|
|
1294
|
+
return this.safeOrder(order, market);
|
|
1295
|
+
}
|
|
1296
|
+
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1297
|
+
if (!response) {
|
|
1298
|
+
return undefined; // fallback to default error handler
|
|
1299
|
+
}
|
|
1300
|
+
//
|
|
1301
|
+
// Error with ID: #68498f1e536664f31a7b1aa7
|
|
1302
|
+
//
|
|
1303
|
+
if (body.indexOf('Error') >= 0) {
|
|
1304
|
+
this.throwBroadlyMatchedException(this.exceptions['broad'], body, '');
|
|
1305
|
+
throw new errors.ExchangeError(body);
|
|
1306
|
+
}
|
|
1307
|
+
return undefined;
|
|
1308
|
+
}
|
|
1309
|
+
sign(path, api = 'public', method = 'POST', params = {}, headers = undefined, body = undefined) {
|
|
1310
|
+
const url = this.urls['api']['rest'] + '/' + path;
|
|
1311
|
+
if (api === 'private') {
|
|
1312
|
+
this.checkRequiredCredentials();
|
|
1313
|
+
}
|
|
1314
|
+
if (method === 'POST') {
|
|
1315
|
+
headers = {
|
|
1316
|
+
'Content-Type': 'application/json',
|
|
1317
|
+
};
|
|
1318
|
+
body = this.json(params);
|
|
1319
|
+
}
|
|
1320
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
exports["default"] = aftermath;
|