ccxt-ir 4.9.25 → 4.9.27

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.
Files changed (107) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/abantether.js +344 -344
  5. package/dist/cjs/src/abstract/bitbarg.js +1 -1
  6. package/dist/cjs/src/abstract/bydfi.js +1 -1
  7. package/dist/cjs/src/abstract/cafearz.js +1 -1
  8. package/dist/cjs/src/abstract/hamtapay.js +1 -1
  9. package/dist/cjs/src/abstract/iranexchange.js +1 -1
  10. package/dist/cjs/src/abstract/kifpoolme.js +1 -1
  11. package/dist/cjs/src/abstract/mazdax.js +1 -1
  12. package/dist/cjs/src/abstract/pingi.js +1 -1
  13. package/dist/cjs/src/abstract/pooleno.js +1 -1
  14. package/dist/cjs/src/abstract/tehran_exchange.js +1 -1
  15. package/dist/cjs/src/afratether.js +347 -347
  16. package/dist/cjs/src/arzplus.js +572 -572
  17. package/dist/cjs/src/bit24.js +380 -379
  18. package/dist/cjs/src/bitbarg.js +303 -303
  19. package/dist/cjs/src/bitpin.js +478 -469
  20. package/dist/cjs/src/bydfi.js +425 -425
  21. package/dist/cjs/src/cafearz.js +337 -337
  22. package/dist/cjs/src/hamtapay.js +294 -294
  23. package/dist/cjs/src/iranexchange.js +390 -390
  24. package/dist/cjs/src/kcex.js +326 -326
  25. package/dist/cjs/src/kifpoolme.js +401 -401
  26. package/dist/cjs/src/mazdax.js +525 -525
  27. package/dist/cjs/src/ompfinex.js +501 -501
  28. package/dist/cjs/src/pingi.js +437 -437
  29. package/dist/cjs/src/pooleno.js +338 -338
  30. package/dist/cjs/src/sarmayex.js +367 -367
  31. package/dist/cjs/src/tehran_exchange.js +324 -324
  32. package/dist/cjs/src/tetherland.js +358 -358
  33. package/dist/cjs/src/toobit.js +436 -436
  34. package/dist/cjs/src/twox.js +362 -362
  35. package/js/ccxt.d.ts +1 -1
  36. package/js/ccxt.js +1 -1
  37. package/js/src/abantether.js +347 -347
  38. package/js/src/abstract/abantether.d.ts +8 -8
  39. package/js/src/abstract/arzplus.d.ts +11 -11
  40. package/js/src/abstract/bitbarg.d.ts +8 -8
  41. package/js/src/abstract/bitbarg.js +5 -5
  42. package/js/src/abstract/bitpin.d.ts +11 -10
  43. package/js/src/abstract/bydfi.d.ts +11 -11
  44. package/js/src/abstract/bydfi.js +5 -5
  45. package/js/src/abstract/cafearz.d.ts +8 -8
  46. package/js/src/abstract/cafearz.js +5 -5
  47. package/js/src/abstract/hamtapay.d.ts +9 -9
  48. package/js/src/abstract/hamtapay.js +5 -5
  49. package/js/src/abstract/iranexchange.d.ts +9 -9
  50. package/js/src/abstract/iranexchange.js +5 -5
  51. package/js/src/abstract/kifpoolme.d.ts +9 -9
  52. package/js/src/abstract/kifpoolme.js +5 -5
  53. package/js/src/abstract/mazdax.d.ts +11 -11
  54. package/js/src/abstract/mazdax.js +5 -5
  55. package/js/src/abstract/pingi.d.ts +9 -9
  56. package/js/src/abstract/pingi.js +5 -5
  57. package/js/src/abstract/pooleno.d.ts +8 -8
  58. package/js/src/abstract/pooleno.js +5 -5
  59. package/js/src/abstract/tehran_exchange.d.ts +9 -9
  60. package/js/src/abstract/tehran_exchange.js +5 -5
  61. package/js/src/abstract/toobit.d.ts +10 -10
  62. package/js/src/afratether.js +350 -350
  63. package/js/src/arzplus.d.ts +26 -26
  64. package/js/src/arzplus.js +575 -575
  65. package/js/src/base/Exchange.d.ts +926 -926
  66. package/js/src/base/types.d.ts +586 -586
  67. package/js/src/bit24.js +383 -382
  68. package/js/src/bitbarg.d.ts +21 -21
  69. package/js/src/bitbarg.js +306 -306
  70. package/js/src/bitpin.js +481 -472
  71. package/js/src/bydfi.d.ts +23 -23
  72. package/js/src/bydfi.js +428 -428
  73. package/js/src/cafearz.d.ts +21 -21
  74. package/js/src/cafearz.js +340 -340
  75. package/js/src/coinbaseexchange.d.ts +334 -334
  76. package/js/src/hamtapay.d.ts +21 -21
  77. package/js/src/hamtapay.js +297 -297
  78. package/js/src/iranexchange.d.ts +21 -21
  79. package/js/src/iranexchange.js +393 -393
  80. package/js/src/kcex.js +329 -329
  81. package/js/src/kifpoolme.d.ts +23 -23
  82. package/js/src/kifpoolme.js +404 -404
  83. package/js/src/mazdax.d.ts +23 -23
  84. package/js/src/mazdax.js +528 -528
  85. package/js/src/ompfinex.js +504 -504
  86. package/js/src/pingi.d.ts +22 -22
  87. package/js/src/pingi.js +440 -440
  88. package/js/src/pooleno.d.ts +21 -21
  89. package/js/src/pooleno.js +341 -341
  90. package/js/src/protobuf/mexc/compiled.d.cts +2 -2
  91. package/js/src/sarmayex.js +370 -370
  92. package/js/src/static_dependencies/fflake/browser.d.ts +222 -222
  93. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -51
  94. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  95. package/js/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +204 -204
  96. package/js/src/static_dependencies/qs/formats.d.cts +8 -8
  97. package/js/src/static_dependencies/qs/index.d.cts +4 -4
  98. package/js/src/static_dependencies/qs/parse.d.cts +2 -2
  99. package/js/src/static_dependencies/qs/stringify.d.cts +2 -2
  100. package/js/src/static_dependencies/qs/utils.d.cts +9 -9
  101. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
  102. package/js/src/tehran_exchange.d.ts +21 -21
  103. package/js/src/tehran_exchange.js +327 -327
  104. package/js/src/tetherland.js +361 -361
  105. package/js/src/toobit.js +439 -439
  106. package/js/src/twox.js +365 -365
  107. package/package.json +1 -1
package/js/src/twox.js CHANGED
@@ -4,368 +4,368 @@
4
4
  // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
- // ---------------------------------------------------------------------------
8
- import Exchange from './abstract/twox.js';
9
- // ---------------------------------------------------------------------------
10
- /**
11
- * @class twox
12
- * @augments Exchange
13
- * @description Set rateLimit to 1000 if fully verified
14
- */
15
- export default class twox extends Exchange {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'twox',
19
- 'name': 'Twox',
20
- 'countries': ['IR'],
21
- 'rateLimit': 1000,
22
- 'version': '1',
23
- 'certified': false,
24
- 'pro': false,
25
- 'has': {
26
- 'CORS': undefined,
27
- 'spot': false,
28
- 'margin': false,
29
- 'swap': false,
30
- 'future': false,
31
- 'option': false,
32
- 'addMargin': false,
33
- 'cancelAllOrders': false,
34
- 'cancelOrder': false,
35
- 'cancelOrders': false,
36
- 'createDepositAddress': false,
37
- 'createOrder': false,
38
- 'createStopLimitOrder': false,
39
- 'createStopMarketOrder': false,
40
- 'createStopOrder': false,
41
- 'editOrder': false,
42
- 'fetchBalance': false,
43
- 'fetchBorrowInterest': false,
44
- 'fetchBorrowRateHistories': false,
45
- 'fetchBorrowRateHistory': false,
46
- 'fetchClosedOrders': false,
47
- 'fetchCrossBorrowRate': false,
48
- 'fetchCrossBorrowRates': false,
49
- 'fetchCurrencies': false,
50
- 'fetchDepositAddress': false,
51
- 'fetchDeposits': false,
52
- 'fetchFundingHistory': false,
53
- 'fetchFundingRate': false,
54
- 'fetchFundingRateHistory': false,
55
- 'fetchFundingRates': false,
56
- 'fetchIndexOHLCV': false,
57
- 'fetchIsolatedBorrowRate': false,
58
- 'fetchIsolatedBorrowRates': false,
59
- 'fetchL2OrderBook': false,
60
- 'fetchL3OrderBook': false,
61
- 'fetchLedger': false,
62
- 'fetchLedgerEntry': false,
63
- 'fetchLeverageTiers': false,
64
- 'fetchMarkets': true,
65
- 'fetchMarkOHLCV': false,
66
- 'fetchMyTrades': false,
67
- 'fetchOHLCV': false,
68
- 'fetchOpenInterestHistory': false,
69
- 'fetchOpenOrders': false,
70
- 'fetchOrder': false,
71
- 'fetchOrderBook': false,
72
- 'fetchOrders': false,
73
- 'fetchOrderTrades': 'emulated',
74
- 'fetchPositions': false,
75
- 'fetchPremiumIndexOHLCV': false,
76
- 'fetchTicker': true,
77
- 'fetchTickers': true,
78
- 'fetchTime': false,
79
- 'fetchTrades': false,
80
- 'fetchTradingFee': false,
81
- 'fetchTradingFees': false,
82
- 'fetchWithdrawals': false,
83
- 'otc': true,
84
- 'setLeverage': false,
85
- 'setMarginMode': false,
86
- 'transfer': false,
87
- 'withdraw': false,
88
- },
89
- 'comment': 'This comment is optional',
90
- 'urls': {
91
- 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/twox/64x64.png',
92
- 'api': {
93
- 'public': 'https://api.twox.ir',
94
- },
95
- 'www': 'https://twox.ir',
96
- 'doc': [
97
- 'https://twox.ir',
98
- ],
99
- },
100
- 'api': {
101
- 'public': {
102
- 'get': {
103
- 'api/currencies': 1,
104
- },
105
- },
106
- },
107
- 'fees': {
108
- 'trading': {
109
- 'tierBased': false,
110
- 'percentage': true,
111
- 'maker': this.parseNumber('0.001'),
112
- 'taker': this.parseNumber('0.001'),
113
- },
114
- },
115
- });
116
- }
117
- async fetchMarkets(params = {}) {
118
- /**
119
- * @method
120
- * @name twox#fetchMarkets
121
- * @description retrieves data on all markets for twox
122
- * @see https://api.twox.ir/api/currencies
123
- * @param {object} [params] extra parameters specific to the exchange API endpoint
124
- * @returns {object[]} an array of objects representing market data
125
- */
126
- const response = await this.publicGetApiCurrencies(params);
127
- const result = [];
128
- const quotes = ['IRT', 'USDT'];
129
- for (let i = 0; i < response.length; i++) {
130
- const marketData = this.extend({}, response[i]);
131
- const base = this.safeString(marketData, 'symbol');
132
- for (let index = 0; index < quotes.length; index++) {
133
- const quote = quotes[index];
134
- if (base === quote || marketData['sellPrice'] === 0 || base === 'IRT') {
135
- break;
136
- }
137
- marketData['base'] = base;
138
- marketData['quote'] = quote;
139
- const market = this.parseMarket(marketData);
140
- result.push(market);
141
- }
142
- }
143
- return result;
144
- }
145
- parseMarket(market) {
146
- // {
147
- // sellPrice: 0,
148
- // buyPrice: 0,
149
- // latestPrice: 0,
150
- // weeklyChart: "https://cdn.twox.trade/currencies/charts/7d/irt_toman.svg?v=2024061017",
151
- // priceChangePercent: 0,
152
- // minAmount: 10000,
153
- // tags: [ ],
154
- // marketCategories: [ ],
155
- // id: 1,
156
- // symbol: "IRT",
157
- // name: "Toman",
158
- // icon: "https://cdn.twox.trade/currencies/icons/128x128/irt_toman.png",
159
- // persianName: "تومان",
160
- // isStableCoin: false,
161
- // isActive: true,
162
- // colorCode: null,
163
- // type: 0,
164
- // isNeedRiskWarning: false,
165
- // assetPrecision: 0,
166
- // isLeveragedToken: false,
167
- // commissionPrecision: 0,
168
- // isDepositAllEnable: true,
169
- // isTrading: true,
170
- // isWithdrawAllEnable: true,
171
- // currencySlug: "IRT_Toman",
172
- // marketCurrencyId: 0,
173
- // order: 0
174
- // },
175
- let baseId = this.safeString(market, 'base');
176
- let quoteId = this.safeString(market, 'quote');
177
- const base = this.safeCurrencyCode(baseId);
178
- const quote = this.safeCurrencyCode(quoteId);
179
- const id = base + quote;
180
- baseId = baseId.toLowerCase();
181
- quoteId = quoteId.toLowerCase();
182
- return {
183
- 'id': id,
184
- 'symbol': base + '/' + quote,
185
- 'base': base,
186
- 'quote': quote,
187
- 'settle': undefined,
188
- 'baseId': baseId,
189
- 'quoteId': quoteId,
190
- 'settleId': undefined,
191
- 'type': 'spot',
192
- 'spot': true,
193
- 'margin': false,
194
- 'swap': false,
195
- 'future': false,
196
- 'option': false,
197
- 'active': true,
198
- 'contract': false,
199
- 'linear': undefined,
200
- 'inverse': undefined,
201
- 'contractSize': undefined,
202
- 'expiry': undefined,
203
- 'expiryDatetime': undefined,
204
- 'strike': undefined,
205
- 'optionType': undefined,
206
- 'precision': {
207
- 'amount': undefined,
208
- 'price': undefined,
209
- },
210
- 'limits': {
211
- 'leverage': {
212
- 'min': undefined,
213
- 'max': undefined,
214
- },
215
- 'amount': {
216
- 'min': undefined,
217
- 'max': undefined,
218
- },
219
- 'price': {
220
- 'min': undefined,
221
- 'max': undefined,
222
- },
223
- 'cost': {
224
- 'min': undefined,
225
- 'max': undefined,
226
- },
227
- },
228
- 'created': undefined,
229
- 'info': market,
230
- };
231
- }
232
- async fetchTickers(symbols = undefined, params = {}) {
233
- /**
234
- * @method
235
- * @name twox#fetchTickers
236
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
237
- * @see https://api.twox.ir/api/currencies
238
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
239
- * @param {object} [params] extra parameters specific to the exchange API endpoint
240
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
241
- */
242
- await this.loadMarkets();
243
- if (symbols !== undefined) {
244
- symbols = this.marketSymbols(symbols);
245
- }
246
- const response = await this.publicGetApiCurrencies(params);
247
- const result = {};
248
- const quotes = ['IRT', 'USDT'];
249
- for (let i = 0; i < response.length; i++) {
250
- const base = this.safeString(response[i], 'symbol');
251
- for (let index = 0; index < quotes.length; index++) {
252
- const quote = quotes[index];
253
- if (base === quote || response[i]['sellPrice'] === 0 || base === 'IRT') {
254
- continue;
255
- }
256
- response[i]['base'] = base;
257
- response[i]['quote'] = quote;
258
- response[i]['symbol'] = base + quote;
259
- const ticker = this.parseTicker(response[i]);
260
- const symbol = ticker['symbol'];
261
- result[symbol] = ticker;
262
- }
263
- }
264
- return this.filterByArrayTickers(result, 'symbol', symbols);
265
- }
266
- async fetchTicker(symbol, params = {}) {
267
- /**
268
- * @method
269
- * @name twox#fetchTicker
270
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
271
- * @see https://api.twox.ir/api/currencies
272
- * @param {string} symbol unified symbol of the market to fetch the ticker for
273
- * @param {object} [params] extra parameters specific to the exchange API endpoint
274
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
275
- */
276
- const ticker = await this.fetchTickers([symbol]);
277
- return ticker[symbol];
278
- }
279
- parseTicker(ticker, market = undefined) {
280
- // {
281
- // sellPrice: 113201.0,
282
- // buyPrice: 112151.0,
283
- // latestPrice: 1.0,
284
- // weeklyChart: "https://cdn.twox.info/resource/w/tether.webp?v=101313",
285
- // priceChangePercent: 0.0,
286
- // sellPriceChange: 0.00,
287
- // buyPriceChange: 0.00,
288
- // minAmount: 2.0,
289
- // tags: [ ],
290
- // marketCategories: [ ],
291
- // id: 2,
292
- // symbol: "USDT",
293
- // name: "Tether USDt",
294
- // icon: "https://cdn.twox.info/resource/c/tether.webp",
295
- // persianName: "تتر",
296
- // isStableCoin: true,
297
- // isActive: true,
298
- // type: 2,
299
- // isNeedRiskWarning: false,
300
- // assetPrecision: 2,
301
- // isDepositAllEnable: true,
302
- // tradeStatus: 1,
303
- // isWithdrawAllEnable: true,
304
- // currencySlug: "tether",
305
- // marketCurrencyId: 825,
306
- // order: 1,
307
- // isTrading: true,
308
- // commissionPrecision: 8,
309
- // isDepositNeedManualConfirm: false,
310
- // supportedBy: [ ]
311
- // },
312
- const marketType = 'otc';
313
- const marketId = this.safeString(ticker, 'symbol');
314
- const symbol = this.safeSymbol(marketId, market, undefined, marketType);
315
- const sellPrice = this.safeFloat(ticker, 'sellPrice');
316
- const buyPrice = this.safeFloat(ticker, 'buyPrice');
317
- const latestPrice = this.safeFloat(ticker, 'latestPrice');
318
- let last = undefined;
319
- let bid = undefined;
320
- let ask = undefined;
321
- if (ticker['quote'] === 'IRT') {
322
- // For IRT pairs, sellPrice is what user pays (ask), buyPrice is what user receives (bid)
323
- last = sellPrice;
324
- bid = buyPrice;
325
- ask = sellPrice;
326
- }
327
- else {
328
- // For USDT pairs, use latestPrice
329
- last = latestPrice;
330
- bid = buyPrice;
331
- ask = sellPrice;
332
- }
333
- const percentage = this.safeFloat(ticker, 'priceChangePercent');
334
- const sellPriceChange = this.safeFloat(ticker, 'sellPriceChange');
335
- const buyPriceChange = this.safeFloat(ticker, 'buyPriceChange');
336
- let change = undefined;
337
- if (ticker['quote'] === 'IRT') {
338
- change = sellPriceChange;
339
- }
340
- else {
341
- change = buyPriceChange;
342
- }
343
- return this.safeTicker({
344
- 'symbol': symbol,
345
- 'timestamp': undefined,
346
- 'datetime': undefined,
347
- 'high': undefined,
348
- 'low': undefined,
349
- 'bid': bid,
350
- 'bidVolume': undefined,
351
- 'ask': ask,
352
- 'askVolume': undefined,
353
- 'vwap': undefined,
354
- 'open': undefined,
355
- 'close': last,
356
- 'last': last,
357
- 'previousClose': undefined,
358
- 'change': change,
359
- 'percentage': percentage,
360
- 'average': undefined,
361
- 'baseVolume': undefined,
362
- 'quoteVolume': undefined,
363
- 'info': ticker,
364
- }, market);
365
- }
366
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
367
- const url = this.urls['api']['public'] + '/' + path;
368
- headers = { 'Content-Type': 'application/json' };
369
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
370
- }
371
- }
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/twox.js';
9
+ // ---------------------------------------------------------------------------
10
+ /**
11
+ * @class twox
12
+ * @augments Exchange
13
+ * @description Set rateLimit to 1000 if fully verified
14
+ */
15
+ export default class twox extends Exchange {
16
+ describe() {
17
+ return this.deepExtend(super.describe(), {
18
+ 'id': 'twox',
19
+ 'name': 'Twox',
20
+ 'countries': ['IR'],
21
+ 'rateLimit': 1000,
22
+ 'version': '1',
23
+ 'certified': false,
24
+ 'pro': false,
25
+ 'has': {
26
+ 'CORS': undefined,
27
+ 'spot': false,
28
+ 'margin': false,
29
+ 'swap': false,
30
+ 'future': false,
31
+ 'option': false,
32
+ 'addMargin': false,
33
+ 'cancelAllOrders': false,
34
+ 'cancelOrder': false,
35
+ 'cancelOrders': false,
36
+ 'createDepositAddress': false,
37
+ 'createOrder': false,
38
+ 'createStopLimitOrder': false,
39
+ 'createStopMarketOrder': false,
40
+ 'createStopOrder': false,
41
+ 'editOrder': false,
42
+ 'fetchBalance': false,
43
+ 'fetchBorrowInterest': false,
44
+ 'fetchBorrowRateHistories': false,
45
+ 'fetchBorrowRateHistory': false,
46
+ 'fetchClosedOrders': false,
47
+ 'fetchCrossBorrowRate': false,
48
+ 'fetchCrossBorrowRates': false,
49
+ 'fetchCurrencies': false,
50
+ 'fetchDepositAddress': false,
51
+ 'fetchDeposits': false,
52
+ 'fetchFundingHistory': false,
53
+ 'fetchFundingRate': false,
54
+ 'fetchFundingRateHistory': false,
55
+ 'fetchFundingRates': false,
56
+ 'fetchIndexOHLCV': false,
57
+ 'fetchIsolatedBorrowRate': false,
58
+ 'fetchIsolatedBorrowRates': false,
59
+ 'fetchL2OrderBook': false,
60
+ 'fetchL3OrderBook': false,
61
+ 'fetchLedger': false,
62
+ 'fetchLedgerEntry': false,
63
+ 'fetchLeverageTiers': false,
64
+ 'fetchMarkets': true,
65
+ 'fetchMarkOHLCV': false,
66
+ 'fetchMyTrades': false,
67
+ 'fetchOHLCV': false,
68
+ 'fetchOpenInterestHistory': false,
69
+ 'fetchOpenOrders': false,
70
+ 'fetchOrder': false,
71
+ 'fetchOrderBook': false,
72
+ 'fetchOrders': false,
73
+ 'fetchOrderTrades': 'emulated',
74
+ 'fetchPositions': false,
75
+ 'fetchPremiumIndexOHLCV': false,
76
+ 'fetchTicker': true,
77
+ 'fetchTickers': true,
78
+ 'fetchTime': false,
79
+ 'fetchTrades': false,
80
+ 'fetchTradingFee': false,
81
+ 'fetchTradingFees': false,
82
+ 'fetchWithdrawals': false,
83
+ 'otc': true,
84
+ 'setLeverage': false,
85
+ 'setMarginMode': false,
86
+ 'transfer': false,
87
+ 'withdraw': false,
88
+ },
89
+ 'comment': 'This comment is optional',
90
+ 'urls': {
91
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/twox/64x64.png',
92
+ 'api': {
93
+ 'public': 'https://api.twox.ir',
94
+ },
95
+ 'www': 'https://twox.ir',
96
+ 'doc': [
97
+ 'https://twox.ir',
98
+ ],
99
+ },
100
+ 'api': {
101
+ 'public': {
102
+ 'get': {
103
+ 'api/currencies': 1,
104
+ },
105
+ },
106
+ },
107
+ 'fees': {
108
+ 'trading': {
109
+ 'tierBased': false,
110
+ 'percentage': true,
111
+ 'maker': this.parseNumber('0.001'),
112
+ 'taker': this.parseNumber('0.001'),
113
+ },
114
+ },
115
+ });
116
+ }
117
+ async fetchMarkets(params = {}) {
118
+ /**
119
+ * @method
120
+ * @name twox#fetchMarkets
121
+ * @description retrieves data on all markets for twox
122
+ * @see https://api.twox.ir/api/currencies
123
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
124
+ * @returns {object[]} an array of objects representing market data
125
+ */
126
+ const response = await this.publicGetApiCurrencies(params);
127
+ const result = [];
128
+ const quotes = ['IRT', 'USDT'];
129
+ for (let i = 0; i < response.length; i++) {
130
+ const marketData = this.extend({}, response[i]);
131
+ const base = this.safeString(marketData, 'symbol');
132
+ for (let index = 0; index < quotes.length; index++) {
133
+ const quote = quotes[index];
134
+ if (base === quote || marketData['sellPrice'] === 0 || base === 'IRT') {
135
+ break;
136
+ }
137
+ marketData['base'] = base;
138
+ marketData['quote'] = quote;
139
+ const market = this.parseMarket(marketData);
140
+ result.push(market);
141
+ }
142
+ }
143
+ return result;
144
+ }
145
+ parseMarket(market) {
146
+ // {
147
+ // sellPrice: 0,
148
+ // buyPrice: 0,
149
+ // latestPrice: 0,
150
+ // weeklyChart: "https://cdn.twox.trade/currencies/charts/7d/irt_toman.svg?v=2024061017",
151
+ // priceChangePercent: 0,
152
+ // minAmount: 10000,
153
+ // tags: [ ],
154
+ // marketCategories: [ ],
155
+ // id: 1,
156
+ // symbol: "IRT",
157
+ // name: "Toman",
158
+ // icon: "https://cdn.twox.trade/currencies/icons/128x128/irt_toman.png",
159
+ // persianName: "تومان",
160
+ // isStableCoin: false,
161
+ // isActive: true,
162
+ // colorCode: null,
163
+ // type: 0,
164
+ // isNeedRiskWarning: false,
165
+ // assetPrecision: 0,
166
+ // isLeveragedToken: false,
167
+ // commissionPrecision: 0,
168
+ // isDepositAllEnable: true,
169
+ // isTrading: true,
170
+ // isWithdrawAllEnable: true,
171
+ // currencySlug: "IRT_Toman",
172
+ // marketCurrencyId: 0,
173
+ // order: 0
174
+ // },
175
+ let baseId = this.safeString(market, 'base');
176
+ let quoteId = this.safeString(market, 'quote');
177
+ const base = this.safeCurrencyCode(baseId);
178
+ const quote = this.safeCurrencyCode(quoteId);
179
+ const id = base + quote;
180
+ baseId = baseId.toLowerCase();
181
+ quoteId = quoteId.toLowerCase();
182
+ return {
183
+ 'id': id,
184
+ 'symbol': base + '/' + quote,
185
+ 'base': base,
186
+ 'quote': quote,
187
+ 'settle': undefined,
188
+ 'baseId': baseId,
189
+ 'quoteId': quoteId,
190
+ 'settleId': undefined,
191
+ 'type': 'spot',
192
+ 'spot': true,
193
+ 'margin': false,
194
+ 'swap': false,
195
+ 'future': false,
196
+ 'option': false,
197
+ 'active': true,
198
+ 'contract': false,
199
+ 'linear': undefined,
200
+ 'inverse': undefined,
201
+ 'contractSize': undefined,
202
+ 'expiry': undefined,
203
+ 'expiryDatetime': undefined,
204
+ 'strike': undefined,
205
+ 'optionType': undefined,
206
+ 'precision': {
207
+ 'amount': undefined,
208
+ 'price': undefined,
209
+ },
210
+ 'limits': {
211
+ 'leverage': {
212
+ 'min': undefined,
213
+ 'max': undefined,
214
+ },
215
+ 'amount': {
216
+ 'min': undefined,
217
+ 'max': undefined,
218
+ },
219
+ 'price': {
220
+ 'min': undefined,
221
+ 'max': undefined,
222
+ },
223
+ 'cost': {
224
+ 'min': undefined,
225
+ 'max': undefined,
226
+ },
227
+ },
228
+ 'created': undefined,
229
+ 'info': market,
230
+ };
231
+ }
232
+ async fetchTickers(symbols = undefined, params = {}) {
233
+ /**
234
+ * @method
235
+ * @name twox#fetchTickers
236
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
237
+ * @see https://api.twox.ir/api/currencies
238
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
239
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
240
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
241
+ */
242
+ await this.loadMarkets();
243
+ if (symbols !== undefined) {
244
+ symbols = this.marketSymbols(symbols);
245
+ }
246
+ const response = await this.publicGetApiCurrencies(params);
247
+ const result = {};
248
+ const quotes = ['IRT', 'USDT'];
249
+ for (let i = 0; i < response.length; i++) {
250
+ const base = this.safeString(response[i], 'symbol');
251
+ for (let index = 0; index < quotes.length; index++) {
252
+ const quote = quotes[index];
253
+ if (base === quote || response[i]['sellPrice'] === 0 || base === 'IRT') {
254
+ continue;
255
+ }
256
+ response[i]['base'] = base;
257
+ response[i]['quote'] = quote;
258
+ response[i]['symbol'] = base + quote;
259
+ const ticker = this.parseTicker(response[i]);
260
+ const symbol = ticker['symbol'];
261
+ result[symbol] = ticker;
262
+ }
263
+ }
264
+ return this.filterByArrayTickers(result, 'symbol', symbols);
265
+ }
266
+ async fetchTicker(symbol, params = {}) {
267
+ /**
268
+ * @method
269
+ * @name twox#fetchTicker
270
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
271
+ * @see https://api.twox.ir/api/currencies
272
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
273
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
274
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
275
+ */
276
+ const ticker = await this.fetchTickers([symbol]);
277
+ return ticker[symbol];
278
+ }
279
+ parseTicker(ticker, market = undefined) {
280
+ // {
281
+ // sellPrice: 113201.0,
282
+ // buyPrice: 112151.0,
283
+ // latestPrice: 1.0,
284
+ // weeklyChart: "https://cdn.twox.info/resource/w/tether.webp?v=101313",
285
+ // priceChangePercent: 0.0,
286
+ // sellPriceChange: 0.00,
287
+ // buyPriceChange: 0.00,
288
+ // minAmount: 2.0,
289
+ // tags: [ ],
290
+ // marketCategories: [ ],
291
+ // id: 2,
292
+ // symbol: "USDT",
293
+ // name: "Tether USDt",
294
+ // icon: "https://cdn.twox.info/resource/c/tether.webp",
295
+ // persianName: "تتر",
296
+ // isStableCoin: true,
297
+ // isActive: true,
298
+ // type: 2,
299
+ // isNeedRiskWarning: false,
300
+ // assetPrecision: 2,
301
+ // isDepositAllEnable: true,
302
+ // tradeStatus: 1,
303
+ // isWithdrawAllEnable: true,
304
+ // currencySlug: "tether",
305
+ // marketCurrencyId: 825,
306
+ // order: 1,
307
+ // isTrading: true,
308
+ // commissionPrecision: 8,
309
+ // isDepositNeedManualConfirm: false,
310
+ // supportedBy: [ ]
311
+ // },
312
+ const marketType = 'otc';
313
+ const marketId = this.safeString(ticker, 'symbol');
314
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
315
+ const sellPrice = this.safeFloat(ticker, 'sellPrice');
316
+ const buyPrice = this.safeFloat(ticker, 'buyPrice');
317
+ const latestPrice = this.safeFloat(ticker, 'latestPrice');
318
+ let last = undefined;
319
+ let bid = undefined;
320
+ let ask = undefined;
321
+ if (ticker['quote'] === 'IRT') {
322
+ // For IRT pairs, sellPrice is what user pays (ask), buyPrice is what user receives (bid)
323
+ last = sellPrice;
324
+ bid = buyPrice;
325
+ ask = sellPrice;
326
+ }
327
+ else {
328
+ // For USDT pairs, use latestPrice
329
+ last = latestPrice;
330
+ bid = buyPrice;
331
+ ask = sellPrice;
332
+ }
333
+ const percentage = this.safeFloat(ticker, 'priceChangePercent');
334
+ const sellPriceChange = this.safeFloat(ticker, 'sellPriceChange');
335
+ const buyPriceChange = this.safeFloat(ticker, 'buyPriceChange');
336
+ let change = undefined;
337
+ if (ticker['quote'] === 'IRT') {
338
+ change = sellPriceChange;
339
+ }
340
+ else {
341
+ change = buyPriceChange;
342
+ }
343
+ return this.safeTicker({
344
+ 'symbol': symbol,
345
+ 'timestamp': undefined,
346
+ 'datetime': undefined,
347
+ 'high': undefined,
348
+ 'low': undefined,
349
+ 'bid': bid,
350
+ 'bidVolume': undefined,
351
+ 'ask': ask,
352
+ 'askVolume': undefined,
353
+ 'vwap': undefined,
354
+ 'open': undefined,
355
+ 'close': last,
356
+ 'last': last,
357
+ 'previousClose': undefined,
358
+ 'change': change,
359
+ 'percentage': percentage,
360
+ 'average': undefined,
361
+ 'baseVolume': undefined,
362
+ 'quoteVolume': undefined,
363
+ 'info': ticker,
364
+ }, market);
365
+ }
366
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
367
+ const url = this.urls['api']['public'] + '/' + path;
368
+ headers = { 'Content-Type': 'application/json' };
369
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
370
+ }
371
+ }