ccxt-ir 4.9.22 → 4.9.23

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 (102) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +4 -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 +11 -0
  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/bitbarg.js +303 -303
  18. package/dist/cjs/src/bydfi.js +425 -425
  19. package/dist/cjs/src/cafearz.js +337 -337
  20. package/dist/cjs/src/hamtapay.js +294 -294
  21. package/dist/cjs/src/iranexchange.js +398 -0
  22. package/dist/cjs/src/kcex.js +326 -326
  23. package/dist/cjs/src/kifpoolme.js +401 -401
  24. package/dist/cjs/src/mazdax.js +525 -525
  25. package/dist/cjs/src/ompfinex.js +501 -501
  26. package/dist/cjs/src/pingi.js +437 -437
  27. package/dist/cjs/src/pooleno.js +338 -338
  28. package/dist/cjs/src/sarmayex.js +367 -367
  29. package/dist/cjs/src/tehran_exchange.js +324 -324
  30. package/dist/cjs/src/tetherland.js +358 -358
  31. package/dist/cjs/src/toobit.js +436 -436
  32. package/dist/cjs/src/twox.js +362 -362
  33. package/js/ccxt.d.ts +5 -2
  34. package/js/ccxt.js +4 -2
  35. package/js/src/abantether.js +347 -347
  36. package/js/src/abstract/abantether.d.ts +8 -8
  37. package/js/src/abstract/arzplus.d.ts +11 -11
  38. package/js/src/abstract/bitbarg.d.ts +8 -8
  39. package/js/src/abstract/bitbarg.js +5 -5
  40. package/js/src/abstract/bydfi.d.ts +11 -11
  41. package/js/src/abstract/bydfi.js +5 -5
  42. package/js/src/abstract/cafearz.d.ts +8 -8
  43. package/js/src/abstract/cafearz.js +5 -5
  44. package/js/src/abstract/hamtapay.d.ts +9 -9
  45. package/js/src/abstract/hamtapay.js +5 -5
  46. package/js/src/abstract/iranexchange.d.ts +9 -0
  47. package/js/src/abstract/iranexchange.js +11 -0
  48. package/js/src/abstract/kifpoolme.d.ts +9 -9
  49. package/js/src/abstract/kifpoolme.js +5 -5
  50. package/js/src/abstract/mazdax.d.ts +11 -11
  51. package/js/src/abstract/mazdax.js +5 -5
  52. package/js/src/abstract/pingi.d.ts +9 -9
  53. package/js/src/abstract/pingi.js +5 -5
  54. package/js/src/abstract/pooleno.d.ts +8 -8
  55. package/js/src/abstract/pooleno.js +5 -5
  56. package/js/src/abstract/tehran_exchange.d.ts +9 -9
  57. package/js/src/abstract/tehran_exchange.js +5 -5
  58. package/js/src/abstract/toobit.d.ts +10 -10
  59. package/js/src/afratether.js +350 -350
  60. package/js/src/arzplus.d.ts +26 -26
  61. package/js/src/arzplus.js +575 -575
  62. package/js/src/base/Exchange.d.ts +2 -2
  63. package/js/src/base/types.d.ts +586 -586
  64. package/js/src/bitbarg.d.ts +21 -21
  65. package/js/src/bitbarg.js +306 -306
  66. package/js/src/bydfi.d.ts +23 -23
  67. package/js/src/bydfi.js +428 -428
  68. package/js/src/cafearz.d.ts +21 -21
  69. package/js/src/cafearz.js +340 -340
  70. package/js/src/coinbaseexchange.d.ts +1 -1
  71. package/js/src/hamtapay.d.ts +21 -21
  72. package/js/src/hamtapay.js +297 -297
  73. package/js/src/iranexchange.d.ts +21 -0
  74. package/js/src/iranexchange.js +397 -0
  75. package/js/src/kcex.js +329 -329
  76. package/js/src/kifpoolme.d.ts +23 -23
  77. package/js/src/kifpoolme.js +404 -404
  78. package/js/src/mazdax.d.ts +23 -23
  79. package/js/src/mazdax.js +528 -528
  80. package/js/src/ompfinex.js +504 -504
  81. package/js/src/pingi.d.ts +22 -22
  82. package/js/src/pingi.js +440 -440
  83. package/js/src/pooleno.d.ts +21 -21
  84. package/js/src/pooleno.js +341 -341
  85. package/js/src/protobuf/mexc/compiled.d.cts +0 -6
  86. package/js/src/sarmayex.js +370 -370
  87. package/js/src/static_dependencies/fflake/browser.d.ts +5 -5
  88. package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -51
  89. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -101
  90. package/js/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +204 -204
  91. package/js/src/static_dependencies/qs/formats.d.cts +0 -6
  92. package/js/src/static_dependencies/qs/index.d.cts +0 -6
  93. package/js/src/static_dependencies/qs/parse.d.cts +0 -6
  94. package/js/src/static_dependencies/qs/stringify.d.cts +0 -6
  95. package/js/src/static_dependencies/qs/utils.d.cts +0 -6
  96. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -5
  97. package/js/src/tehran_exchange.d.ts +21 -21
  98. package/js/src/tehran_exchange.js +327 -327
  99. package/js/src/tetherland.js +361 -361
  100. package/js/src/toobit.js +439 -439
  101. package/js/src/twox.js +365 -365
  102. package/package.json +1 -1
@@ -4,330 +4,330 @@
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/tehran_exchange.js';
9
- // ---------------------------------------------------------------------------
10
- /**
11
- * @class tehran_exchange
12
- * @augments Exchange
13
- * @description Set rateLimit to 1000 if fully verified
14
- */
15
- export default class tehran_exchange extends Exchange {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'tehran_exchange',
19
- 'name': 'Tehran Exchange',
20
- 'countries': ['IR'],
21
- 'rateLimit': 1000,
22
- 'version': '1',
23
- 'certified': false,
24
- 'pro': false,
25
- 'has': {
26
- 'CORS': undefined,
27
- 'spot': true,
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
- 'fetchLedger': false,
61
- 'fetchLedgerEntry': false,
62
- 'fetchLeverageTiers': false,
63
- 'fetchMarkets': true,
64
- 'fetchMarkOHLCV': false,
65
- 'fetchMyTrades': false,
66
- 'fetchOHLCV': false,
67
- 'fetchOpenInterestHistory': false,
68
- 'fetchOpenOrders': false,
69
- 'fetchOrder': false,
70
- 'fetchOrderBook': false,
71
- 'fetchOrders': false,
72
- 'fetchOrderTrades': 'emulated',
73
- 'fetchPositions': false,
74
- 'fetchPremiumIndexOHLCV': false,
75
- 'fetchTicker': true,
76
- 'fetchTickers': true,
77
- 'fetchTime': false,
78
- 'fetchTrades': false,
79
- 'fetchTradingFee': false,
80
- 'fetchTradingFees': false,
81
- 'fetchWithdrawals': false,
82
- 'setLeverage': false,
83
- 'setMarginMode': false,
84
- 'transfer': false,
85
- 'withdraw': false,
86
- },
87
- 'comment': 'This comment is optional',
88
- 'urls': {
89
- 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/tehran_exchange/64x64.png',
90
- 'api': {
91
- 'public': 'https://otc-api.tehran.exchange',
92
- },
93
- 'www': 'https://tehran.exchange',
94
- 'doc': [
95
- 'https://tehran.exchange',
96
- ],
97
- },
98
- 'api': {
99
- 'public': {
100
- 'get': {
101
- 'otc/v1/market/pair': 1,
102
- 'otc/v1/market/order/pair/price': 1,
103
- },
104
- },
105
- },
106
- 'fees': {
107
- 'trading': {
108
- 'tierBased': false,
109
- 'percentage': true,
110
- 'maker': this.parseNumber('0.0025'),
111
- 'taker': this.parseNumber('0.0025'),
112
- },
113
- },
114
- });
115
- }
116
- async fetchMarkets(params = {}) {
117
- /**
118
- * @method
119
- * @name tehran_exchange#fetchMarkets
120
- * @description retrieves data on all markets for tehran_exchange
121
- * @see https://otc-api.tehran.exchange/otc/v1/market/pair
122
- * @param {object} [params] extra parameters specific to the exchange API endpoint
123
- * @returns {object[]} an array of objects representing market data
124
- */
125
- const response = await this.publicGetOtcV1MarketPair(params);
126
- const data = this.safeDict(response, 'data', {});
127
- const pairs = this.safeList(data, 'pairs', []);
128
- const result = [];
129
- for (let i = 0; i < pairs.length; i++) {
130
- const market = this.parseMarket(pairs[i]);
131
- result.push(market);
132
- }
133
- return result;
134
- }
135
- parseMarket(market) {
136
- // {
137
- // "id": 6054,
138
- // "pair": "HBAR_USDT",
139
- // "status": "TRADABLE",
140
- // "tradable": true,
141
- // "fiatOrder": false,
142
- // "quoteName": "Tether",
143
- // "baseName": "Hedera",
144
- // "quoteNameFa": "تتر",
145
- // "baseNameFa": "هدرا هش گراف ",
146
- // "quoteImageUrl": "https://s3-dev.tehranex.com/asset/coin_icon/64/usdt.png",
147
- // "baseImageUrl": "https://s3-dev.tehranex.com/asset/coin_icon/64/hbar.png",
148
- // "quoteSymbol": "USDT",
149
- // "baseSymbol": "HBAR",
150
- // "amountPrecision": 2,
151
- // "feePercentage": 0.25,
152
- // "providerFeePercentage": 0.05,
153
- // "maxQuoteAmount": 600000,
154
- // "minBaseAmount": 0.01,
155
- // "minQuoteAmount": 1,
156
- // "pricePrecision": 5,
157
- // "baseVirtualCurrencyId": 989,
158
- // "quoteVirtualCurrencyId": 1
159
- // }
160
- const id = this.safeString(market, 'pair');
161
- const baseId = this.safeString(market, 'baseSymbol');
162
- const quoteId = this.safeString(market, 'quoteSymbol');
163
- const base = this.safeCurrencyCode(baseId);
164
- const quote = this.safeCurrencyCode(quoteId);
165
- const status = this.safeString(market, 'status');
166
- const tradable = this.safeBool(market, 'tradable', false);
167
- const active = (status === 'TRADABLE') && tradable;
168
- const amountPrecision = this.safeInteger(market, 'amountPrecision');
169
- const pricePrecision = this.safeInteger(market, 'pricePrecision');
170
- const minBaseAmount = this.safeString(market, 'minBaseAmount');
171
- const minQuoteAmount = this.safeString(market, 'minQuoteAmount');
172
- const maxQuoteAmount = this.safeString(market, 'maxQuoteAmount');
173
- return {
174
- 'id': id,
175
- 'symbol': base + '/' + quote,
176
- 'base': base,
177
- 'quote': quote,
178
- 'settle': undefined,
179
- 'baseId': baseId,
180
- 'quoteId': quoteId,
181
- 'settleId': undefined,
182
- 'type': 'spot',
183
- 'spot': true,
184
- 'margin': false,
185
- 'swap': false,
186
- 'future': false,
187
- 'option': false,
188
- 'active': active,
189
- 'contract': false,
190
- 'linear': undefined,
191
- 'inverse': undefined,
192
- 'contractSize': undefined,
193
- 'expiry': undefined,
194
- 'expiryDatetime': undefined,
195
- 'strike': undefined,
196
- 'optionType': undefined,
197
- 'precision': {
198
- 'amount': amountPrecision,
199
- 'price': pricePrecision,
200
- },
201
- 'limits': {
202
- 'leverage': {
203
- 'min': undefined,
204
- 'max': undefined,
205
- },
206
- 'amount': {
207
- 'min': this.parseNumber(minBaseAmount),
208
- 'max': undefined,
209
- },
210
- 'price': {
211
- 'min': undefined,
212
- 'max': undefined,
213
- },
214
- 'cost': {
215
- 'min': this.parseNumber(minQuoteAmount),
216
- 'max': this.parseNumber(maxQuoteAmount),
217
- },
218
- },
219
- 'created': undefined,
220
- 'info': market,
221
- };
222
- }
223
- async fetchTickers(symbols = undefined, params = {}) {
224
- /**
225
- * @method
226
- * @name tehran_exchange#fetchTickers
227
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
228
- * @see https://otc-api.tehran.exchange/otc/v1/market/pair
229
- * @see https://otc-api.tehran.exchange/otc/v1/market/order/pair/price
230
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
231
- * @param {object} [params] extra parameters specific to the exchange API endpoint
232
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
233
- */
234
- await this.loadMarkets();
235
- if (symbols !== undefined) {
236
- symbols = this.marketSymbols(symbols);
237
- }
238
- const response = await this.publicGetOtcV1MarketPair(params);
239
- const data = this.safeDict(response, 'data', {});
240
- const pairs = this.safeList(data, 'pairs', []);
241
- // filter symbols from pairs
242
- const filteredPairs = [];
243
- for (let i = 0; i < pairs.length; i++) {
244
- const pair = pairs[i];
245
- const pairId = this.safeString(pair, 'pair');
246
- const symbol = this.safeSymbol(pairId);
247
- if (symbols.includes(symbol)) {
248
- filteredPairs.push(pair);
249
- }
250
- }
251
- const result = {};
252
- for (let i = 0; i < filteredPairs.length; i++) {
253
- const pairData = filteredPairs[i];
254
- const pairId = this.safeString(pairData, 'pair');
255
- // Fetch BUY price
256
- const request = {
257
- 'pair': pairId,
258
- 'side': 'BUY',
259
- 'basedOn': 'BASE',
260
- 'amount': 1,
261
- };
262
- const priceResponse = await this.publicGetOtcV1MarketOrderPairPrice(request);
263
- const priceData = this.safeDict(priceResponse, 'data', {});
264
- const price = this.safeFloat(priceData, 'price', 0);
265
- pairData['price'] = price;
266
- const ticker = this.parseTicker(pairData);
267
- const symbol = ticker['symbol'];
268
- result[symbol] = ticker;
269
- }
270
- return this.filterByArrayTickers(result, 'symbol', symbols);
271
- }
272
- async fetchTicker(symbol, params = {}) {
273
- /**
274
- * @method
275
- * @name tehran_exchange#fetchTicker
276
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
277
- * @see https://otc-api.tehran.exchange/otc/v1/market/pair
278
- * @param {string} symbol unified symbol of the market to fetch the ticker for
279
- * @param {object} [params] extra parameters specific to the exchange API endpoint
280
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
281
- */
282
- const ticker = await this.fetchTickers([symbol]);
283
- return ticker[this.safeSymbol(symbol)];
284
- }
285
- parseTicker(ticker, market = undefined) {
286
- // {
287
- // "id": 6054,
288
- // "pair": "HBAR_USDT",
289
- // "status": "TRADABLE",
290
- // "tradable": true,
291
- // "baseSymbol": "HBAR",
292
- // "quoteSymbol": "USDT",
293
- // ...
294
- // "price": 12345,
295
- // }
296
- const marketType = 'spot';
297
- const baseSymbol = this.safeString(ticker, 'baseSymbol');
298
- const quoteSymbol = this.safeString(ticker, 'quoteSymbol');
299
- const marketId = baseSymbol + '/' + quoteSymbol;
300
- const symbol = this.safeSymbol(marketId, market, undefined, marketType);
301
- const price = this.safeFloat(ticker, 'price');
302
- return this.safeTicker({
303
- 'symbol': symbol,
304
- 'timestamp': undefined,
305
- 'datetime': undefined,
306
- 'high': undefined,
307
- 'low': undefined,
308
- 'bid': price,
309
- 'bidVolume': undefined,
310
- 'ask': price,
311
- 'askVolume': undefined,
312
- 'open': undefined,
313
- 'close': price,
314
- 'last': price,
315
- 'previousClose': undefined,
316
- 'change': undefined,
317
- 'percentage': undefined,
318
- 'average': undefined,
319
- 'baseVolume': undefined,
320
- 'quoteVolume': undefined,
321
- 'info': ticker,
322
- }, market);
323
- }
324
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
325
- const query = this.omit(params, this.extractParams(path));
326
- let url = this.urls['api']['public'] + '/' + path;
327
- if (Object.keys(query).length) {
328
- url += '?' + this.urlencode(query);
329
- }
330
- headers = { 'Content-Type': 'application/json' };
331
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
332
- }
333
- }
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/tehran_exchange.js';
9
+ // ---------------------------------------------------------------------------
10
+ /**
11
+ * @class tehran_exchange
12
+ * @augments Exchange
13
+ * @description Set rateLimit to 1000 if fully verified
14
+ */
15
+ export default class tehran_exchange extends Exchange {
16
+ describe() {
17
+ return this.deepExtend(super.describe(), {
18
+ 'id': 'tehran_exchange',
19
+ 'name': 'Tehran Exchange',
20
+ 'countries': ['IR'],
21
+ 'rateLimit': 1000,
22
+ 'version': '1',
23
+ 'certified': false,
24
+ 'pro': false,
25
+ 'has': {
26
+ 'CORS': undefined,
27
+ 'spot': true,
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
+ 'fetchLedger': false,
61
+ 'fetchLedgerEntry': false,
62
+ 'fetchLeverageTiers': false,
63
+ 'fetchMarkets': true,
64
+ 'fetchMarkOHLCV': false,
65
+ 'fetchMyTrades': false,
66
+ 'fetchOHLCV': false,
67
+ 'fetchOpenInterestHistory': false,
68
+ 'fetchOpenOrders': false,
69
+ 'fetchOrder': false,
70
+ 'fetchOrderBook': false,
71
+ 'fetchOrders': false,
72
+ 'fetchOrderTrades': 'emulated',
73
+ 'fetchPositions': false,
74
+ 'fetchPremiumIndexOHLCV': false,
75
+ 'fetchTicker': true,
76
+ 'fetchTickers': true,
77
+ 'fetchTime': false,
78
+ 'fetchTrades': false,
79
+ 'fetchTradingFee': false,
80
+ 'fetchTradingFees': false,
81
+ 'fetchWithdrawals': false,
82
+ 'setLeverage': false,
83
+ 'setMarginMode': false,
84
+ 'transfer': false,
85
+ 'withdraw': false,
86
+ },
87
+ 'comment': 'This comment is optional',
88
+ 'urls': {
89
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/tehran_exchange/64x64.png',
90
+ 'api': {
91
+ 'public': 'https://otc-api.tehran.exchange',
92
+ },
93
+ 'www': 'https://tehran.exchange',
94
+ 'doc': [
95
+ 'https://tehran.exchange',
96
+ ],
97
+ },
98
+ 'api': {
99
+ 'public': {
100
+ 'get': {
101
+ 'otc/v1/market/pair': 1,
102
+ 'otc/v1/market/order/pair/price': 1,
103
+ },
104
+ },
105
+ },
106
+ 'fees': {
107
+ 'trading': {
108
+ 'tierBased': false,
109
+ 'percentage': true,
110
+ 'maker': this.parseNumber('0.0025'),
111
+ 'taker': this.parseNumber('0.0025'),
112
+ },
113
+ },
114
+ });
115
+ }
116
+ async fetchMarkets(params = {}) {
117
+ /**
118
+ * @method
119
+ * @name tehran_exchange#fetchMarkets
120
+ * @description retrieves data on all markets for tehran_exchange
121
+ * @see https://otc-api.tehran.exchange/otc/v1/market/pair
122
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
123
+ * @returns {object[]} an array of objects representing market data
124
+ */
125
+ const response = await this.publicGetOtcV1MarketPair(params);
126
+ const data = this.safeDict(response, 'data', {});
127
+ const pairs = this.safeList(data, 'pairs', []);
128
+ const result = [];
129
+ for (let i = 0; i < pairs.length; i++) {
130
+ const market = this.parseMarket(pairs[i]);
131
+ result.push(market);
132
+ }
133
+ return result;
134
+ }
135
+ parseMarket(market) {
136
+ // {
137
+ // "id": 6054,
138
+ // "pair": "HBAR_USDT",
139
+ // "status": "TRADABLE",
140
+ // "tradable": true,
141
+ // "fiatOrder": false,
142
+ // "quoteName": "Tether",
143
+ // "baseName": "Hedera",
144
+ // "quoteNameFa": "تتر",
145
+ // "baseNameFa": "هدرا هش گراف ",
146
+ // "quoteImageUrl": "https://s3-dev.tehranex.com/asset/coin_icon/64/usdt.png",
147
+ // "baseImageUrl": "https://s3-dev.tehranex.com/asset/coin_icon/64/hbar.png",
148
+ // "quoteSymbol": "USDT",
149
+ // "baseSymbol": "HBAR",
150
+ // "amountPrecision": 2,
151
+ // "feePercentage": 0.25,
152
+ // "providerFeePercentage": 0.05,
153
+ // "maxQuoteAmount": 600000,
154
+ // "minBaseAmount": 0.01,
155
+ // "minQuoteAmount": 1,
156
+ // "pricePrecision": 5,
157
+ // "baseVirtualCurrencyId": 989,
158
+ // "quoteVirtualCurrencyId": 1
159
+ // }
160
+ const id = this.safeString(market, 'pair');
161
+ const baseId = this.safeString(market, 'baseSymbol');
162
+ const quoteId = this.safeString(market, 'quoteSymbol');
163
+ const base = this.safeCurrencyCode(baseId);
164
+ const quote = this.safeCurrencyCode(quoteId);
165
+ const status = this.safeString(market, 'status');
166
+ const tradable = this.safeBool(market, 'tradable', false);
167
+ const active = (status === 'TRADABLE') && tradable;
168
+ const amountPrecision = this.safeInteger(market, 'amountPrecision');
169
+ const pricePrecision = this.safeInteger(market, 'pricePrecision');
170
+ const minBaseAmount = this.safeString(market, 'minBaseAmount');
171
+ const minQuoteAmount = this.safeString(market, 'minQuoteAmount');
172
+ const maxQuoteAmount = this.safeString(market, 'maxQuoteAmount');
173
+ return {
174
+ 'id': id,
175
+ 'symbol': base + '/' + quote,
176
+ 'base': base,
177
+ 'quote': quote,
178
+ 'settle': undefined,
179
+ 'baseId': baseId,
180
+ 'quoteId': quoteId,
181
+ 'settleId': undefined,
182
+ 'type': 'spot',
183
+ 'spot': true,
184
+ 'margin': false,
185
+ 'swap': false,
186
+ 'future': false,
187
+ 'option': false,
188
+ 'active': active,
189
+ 'contract': false,
190
+ 'linear': undefined,
191
+ 'inverse': undefined,
192
+ 'contractSize': undefined,
193
+ 'expiry': undefined,
194
+ 'expiryDatetime': undefined,
195
+ 'strike': undefined,
196
+ 'optionType': undefined,
197
+ 'precision': {
198
+ 'amount': amountPrecision,
199
+ 'price': pricePrecision,
200
+ },
201
+ 'limits': {
202
+ 'leverage': {
203
+ 'min': undefined,
204
+ 'max': undefined,
205
+ },
206
+ 'amount': {
207
+ 'min': this.parseNumber(minBaseAmount),
208
+ 'max': undefined,
209
+ },
210
+ 'price': {
211
+ 'min': undefined,
212
+ 'max': undefined,
213
+ },
214
+ 'cost': {
215
+ 'min': this.parseNumber(minQuoteAmount),
216
+ 'max': this.parseNumber(maxQuoteAmount),
217
+ },
218
+ },
219
+ 'created': undefined,
220
+ 'info': market,
221
+ };
222
+ }
223
+ async fetchTickers(symbols = undefined, params = {}) {
224
+ /**
225
+ * @method
226
+ * @name tehran_exchange#fetchTickers
227
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
228
+ * @see https://otc-api.tehran.exchange/otc/v1/market/pair
229
+ * @see https://otc-api.tehran.exchange/otc/v1/market/order/pair/price
230
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
231
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
232
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
233
+ */
234
+ await this.loadMarkets();
235
+ if (symbols !== undefined) {
236
+ symbols = this.marketSymbols(symbols);
237
+ }
238
+ const response = await this.publicGetOtcV1MarketPair(params);
239
+ const data = this.safeDict(response, 'data', {});
240
+ const pairs = this.safeList(data, 'pairs', []);
241
+ // filter symbols from pairs
242
+ const filteredPairs = [];
243
+ for (let i = 0; i < pairs.length; i++) {
244
+ const pair = pairs[i];
245
+ const pairId = this.safeString(pair, 'pair');
246
+ const symbol = this.safeSymbol(pairId);
247
+ if (symbols.includes(symbol)) {
248
+ filteredPairs.push(pair);
249
+ }
250
+ }
251
+ const result = {};
252
+ for (let i = 0; i < filteredPairs.length; i++) {
253
+ const pairData = filteredPairs[i];
254
+ const pairId = this.safeString(pairData, 'pair');
255
+ // Fetch BUY price
256
+ const request = {
257
+ 'pair': pairId,
258
+ 'side': 'BUY',
259
+ 'basedOn': 'BASE',
260
+ 'amount': 1,
261
+ };
262
+ const priceResponse = await this.publicGetOtcV1MarketOrderPairPrice(request);
263
+ const priceData = this.safeDict(priceResponse, 'data', {});
264
+ const price = this.safeFloat(priceData, 'price', 0);
265
+ pairData['price'] = price;
266
+ const ticker = this.parseTicker(pairData);
267
+ const symbol = ticker['symbol'];
268
+ result[symbol] = ticker;
269
+ }
270
+ return this.filterByArrayTickers(result, 'symbol', symbols);
271
+ }
272
+ async fetchTicker(symbol, params = {}) {
273
+ /**
274
+ * @method
275
+ * @name tehran_exchange#fetchTicker
276
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
277
+ * @see https://otc-api.tehran.exchange/otc/v1/market/pair
278
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
279
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
280
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
281
+ */
282
+ const ticker = await this.fetchTickers([symbol]);
283
+ return ticker[this.safeSymbol(symbol)];
284
+ }
285
+ parseTicker(ticker, market = undefined) {
286
+ // {
287
+ // "id": 6054,
288
+ // "pair": "HBAR_USDT",
289
+ // "status": "TRADABLE",
290
+ // "tradable": true,
291
+ // "baseSymbol": "HBAR",
292
+ // "quoteSymbol": "USDT",
293
+ // ...
294
+ // "price": 12345,
295
+ // }
296
+ const marketType = 'spot';
297
+ const baseSymbol = this.safeString(ticker, 'baseSymbol');
298
+ const quoteSymbol = this.safeString(ticker, 'quoteSymbol');
299
+ const marketId = baseSymbol + '/' + quoteSymbol;
300
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
301
+ const price = this.safeFloat(ticker, 'price');
302
+ return this.safeTicker({
303
+ 'symbol': symbol,
304
+ 'timestamp': undefined,
305
+ 'datetime': undefined,
306
+ 'high': undefined,
307
+ 'low': undefined,
308
+ 'bid': price,
309
+ 'bidVolume': undefined,
310
+ 'ask': price,
311
+ 'askVolume': undefined,
312
+ 'open': undefined,
313
+ 'close': price,
314
+ 'last': price,
315
+ 'previousClose': undefined,
316
+ 'change': undefined,
317
+ 'percentage': undefined,
318
+ 'average': undefined,
319
+ 'baseVolume': undefined,
320
+ 'quoteVolume': undefined,
321
+ 'info': ticker,
322
+ }, market);
323
+ }
324
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
325
+ const query = this.omit(params, this.extractParams(path));
326
+ let url = this.urls['api']['public'] + '/' + path;
327
+ if (Object.keys(query).length) {
328
+ url += '?' + this.urlencode(query);
329
+ }
330
+ headers = { 'Content-Type': 'application/json' };
331
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
332
+ }
333
+ }