ccxt-ir 4.23.2 → 4.24.0

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.
@@ -5,215 +5,215 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var Exchange = require('./base/Exchange.js');
6
6
 
7
7
  // ----------------------------------------------------------------------------
8
- // ---------------------------------------------------------------------------
9
- /**
10
- * @class swapwallet
11
- * @augments Exchange
12
- */
13
- class swapwallet extends Exchange["default"] {
14
- describe() {
15
- return this.deepExtend(super.describe(), {
16
- 'id': 'swapwallet',
17
- 'name': 'Swapwallet',
18
- 'countries': ['IR'],
19
- 'rateLimit': 1000,
20
- 'version': 'v2',
21
- 'certified': false,
22
- 'pro': false,
23
- 'has': {
24
- 'CORS': undefined,
25
- 'spot': false,
26
- 'margin': false,
27
- 'swap': false,
28
- 'future': false,
29
- 'option': false,
30
- 'fetchMarkets': true,
31
- 'fetchTicker': true,
32
- 'fetchTickers': true,
33
- 'otc': true,
34
- },
35
- 'options': {
36
- 'defaultType': 'otc',
37
- },
38
- 'urls': {
39
- 'api': {
40
- 'public': 'https://swapwallet.app/api/v2',
41
- },
42
- 'www': 'https://swapwallet.app',
43
- 'doc': 'https://swapwallet.app/api/v2/market/crypto/stats',
44
- },
45
- 'api': {
46
- 'public': {
47
- 'get': {
48
- 'market/crypto/stats': 1,
49
- },
50
- },
51
- },
52
- });
53
- }
54
- async fetchMarkets(params = {}) {
55
- /**
56
- * @method
57
- * @name swapwallet#fetchMarkets
58
- * @description retrieves all OTC markets
59
- * @see https://swapwallet.app/api/v2/market/crypto/stats
60
- * @param {object} [params] extra parameters specific to the exchange API endpoint
61
- * @returns {object[]} an array of market structures
62
- */
63
- const response = await this.publicGetMarketCryptoStats(params);
64
- const markets = this.safeDict(response, 'result', {});
65
- const ids = Object.keys(markets);
66
- const result = [];
67
- for (let i = 0; i < ids.length; i++) {
68
- const id = ids[i];
69
- result.push(this.parseMarket(this.extend(markets[id], { 'id': id })));
70
- }
71
- return result;
72
- }
73
- parseMarket(market) {
74
- // {
75
- // "source": "USOON",
76
- // "destination": "USDT",
77
- // "marketData": {
78
- // "bestSell": "165.72",
79
- // "bestBuy": "162.43",
80
- // "latestPrice": "164.08",
81
- // "dayChange": "2.98",
82
- // "volume24h": "3753.99"
83
- // }
84
- // }
85
- const baseId = this.safeString(market, 'source');
86
- const quoteId = this.safeString(market, 'destination');
87
- const base = this.safeCurrencyCode(baseId);
88
- const quote = this.safeCurrencyCode(quoteId);
89
- const id = this.safeString(market, 'id', baseId + '-' + quoteId);
90
- return {
91
- 'id': id,
92
- 'symbol': base + '/' + quote,
93
- 'base': base,
94
- 'quote': quote,
95
- 'settle': undefined,
96
- 'baseId': baseId,
97
- 'quoteId': quoteId,
98
- 'settleId': undefined,
99
- 'type': 'otc',
100
- 'spot': false,
101
- 'margin': false,
102
- 'swap': false,
103
- 'future': false,
104
- 'option': false,
105
- 'active': undefined,
106
- 'contract': false,
107
- 'linear': undefined,
108
- 'inverse': undefined,
109
- 'contractSize': undefined,
110
- 'expiry': undefined,
111
- 'expiryDatetime': undefined,
112
- 'strike': undefined,
113
- 'optionType': undefined,
114
- 'precision': {
115
- 'amount': undefined,
116
- 'price': undefined,
117
- },
118
- 'limits': {
119
- 'leverage': {
120
- 'min': undefined,
121
- 'max': undefined,
122
- },
123
- 'amount': {
124
- 'min': undefined,
125
- 'max': undefined,
126
- },
127
- 'price': {
128
- 'min': undefined,
129
- 'max': undefined,
130
- },
131
- 'cost': {
132
- 'min': undefined,
133
- 'max': undefined,
134
- },
135
- },
136
- 'created': undefined,
137
- 'info': market,
138
- };
139
- }
140
- async fetchTickers(symbols = undefined, params = {}) {
141
- /**
142
- * @method
143
- * @name swapwallet#fetchTickers
144
- * @description fetches 24 hour price statistics for multiple OTC markets
145
- * @see https://swapwallet.app/api/v2/market/crypto/stats
146
- * @param {string[]} [symbols] unified symbols, all markets are returned if undefined
147
- * @param {object} [params] extra parameters specific to the exchange API endpoint
148
- * @returns {object} a dictionary of ticker structures indexed by symbol
149
- */
150
- await this.loadMarkets();
151
- symbols = this.marketSymbols(symbols);
152
- const response = await this.publicGetMarketCryptoStats(params);
153
- const tickers = this.safeDict(response, 'result', {});
154
- const ids = Object.keys(tickers);
155
- const result = {};
156
- for (let i = 0; i < ids.length; i++) {
157
- const id = ids[i];
158
- const ticker = this.parseTicker(tickers[id]);
159
- result[ticker['symbol']] = ticker;
160
- }
161
- return this.filterByArrayTickers(result, 'symbol', symbols);
162
- }
163
- async fetchTicker(symbol, params = {}) {
164
- /**
165
- * @method
166
- * @name swapwallet#fetchTicker
167
- * @description fetches 24 hour price statistics for a single OTC market
168
- * @see https://swapwallet.app/api/v2/market/crypto/stats
169
- * @param {string} symbol unified market symbol
170
- * @param {object} [params] extra parameters specific to the exchange API endpoint
171
- * @returns {object} a ticker structure
172
- */
173
- await this.loadMarkets();
174
- const market = this.market(symbol);
175
- const tickers = await this.fetchTickers([market['symbol']], params);
176
- return tickers[market['symbol']];
177
- }
178
- parseTicker(ticker, market = undefined) {
179
- const baseId = this.safeString(ticker, 'source');
180
- const quoteId = this.safeString(ticker, 'destination');
181
- const marketId = baseId + '-' + quoteId;
182
- const symbol = this.safeSymbol(marketId, market, '-', 'otc');
183
- const data = this.safeDict(ticker, 'marketData', {});
184
- const last = this.safeString(data, 'latestPrice');
185
- return this.safeTicker({
186
- 'symbol': symbol,
187
- 'timestamp': undefined,
188
- 'datetime': undefined,
189
- 'high': undefined,
190
- 'low': undefined,
191
- 'bid': this.safeString(data, 'bestBuy'),
192
- 'bidVolume': undefined,
193
- 'ask': this.safeString(data, 'bestSell'),
194
- 'askVolume': undefined,
195
- 'vwap': undefined,
196
- 'open': undefined,
197
- 'close': last,
198
- 'last': last,
199
- 'previousClose': undefined,
200
- 'change': undefined,
201
- 'percentage': this.safeString(data, 'dayChange'),
202
- 'average': undefined,
203
- 'baseVolume': this.safeString(data, 'volume24h'),
204
- 'quoteVolume': undefined,
205
- 'info': ticker,
206
- }, market);
207
- }
208
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
209
- const query = this.omit(params, this.extractParams(path));
210
- let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
211
- if (Object.keys(query).length) {
212
- url += '?' + this.urlencode(query);
213
- }
214
- headers = { 'Content-Type': 'application/json' };
215
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
216
- }
8
+ // ---------------------------------------------------------------------------
9
+ /**
10
+ * @class swapwallet
11
+ * @augments Exchange
12
+ */
13
+ class swapwallet extends Exchange["default"] {
14
+ describe() {
15
+ return this.deepExtend(super.describe(), {
16
+ 'id': 'swapwallet',
17
+ 'name': 'Swapwallet',
18
+ 'countries': ['IR'],
19
+ 'rateLimit': 1000,
20
+ 'version': 'v2',
21
+ 'certified': false,
22
+ 'pro': false,
23
+ 'has': {
24
+ 'CORS': undefined,
25
+ 'spot': false,
26
+ 'margin': false,
27
+ 'swap': false,
28
+ 'future': false,
29
+ 'option': false,
30
+ 'fetchMarkets': true,
31
+ 'fetchTicker': true,
32
+ 'fetchTickers': true,
33
+ 'otc': true,
34
+ },
35
+ 'options': {
36
+ 'defaultType': 'otc',
37
+ },
38
+ 'urls': {
39
+ 'api': {
40
+ 'public': 'https://swapwallet.app/api/v2',
41
+ },
42
+ 'www': 'https://swapwallet.app',
43
+ 'doc': 'https://swapwallet.app/api/v2/market/crypto/stats',
44
+ },
45
+ 'api': {
46
+ 'public': {
47
+ 'get': {
48
+ 'market/crypto/stats': 1,
49
+ },
50
+ },
51
+ },
52
+ });
53
+ }
54
+ async fetchMarkets(params = {}) {
55
+ /**
56
+ * @method
57
+ * @name swapwallet#fetchMarkets
58
+ * @description retrieves all OTC markets
59
+ * @see https://swapwallet.app/api/v2/market/crypto/stats
60
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
61
+ * @returns {object[]} an array of market structures
62
+ */
63
+ const response = await this.publicGetMarketCryptoStats(params);
64
+ const markets = this.safeDict(response, 'result', {});
65
+ const ids = Object.keys(markets);
66
+ const result = [];
67
+ for (let i = 0; i < ids.length; i++) {
68
+ const id = ids[i];
69
+ result.push(this.parseMarket(this.extend(markets[id], { 'id': id })));
70
+ }
71
+ return result;
72
+ }
73
+ parseMarket(market) {
74
+ // {
75
+ // "source": "USOON",
76
+ // "destination": "USDT",
77
+ // "marketData": {
78
+ // "bestSell": "165.72",
79
+ // "bestBuy": "162.43",
80
+ // "latestPrice": "164.08",
81
+ // "dayChange": "2.98",
82
+ // "volume24h": "3753.99"
83
+ // }
84
+ // }
85
+ const baseId = this.safeString(market, 'source');
86
+ const quoteId = this.safeString(market, 'destination');
87
+ const base = this.safeCurrencyCode(baseId);
88
+ const quote = this.safeCurrencyCode(quoteId);
89
+ const id = this.safeString(market, 'id', baseId + '-' + quoteId);
90
+ return {
91
+ 'id': id,
92
+ 'symbol': base + '/' + quote,
93
+ 'base': base,
94
+ 'quote': quote,
95
+ 'settle': undefined,
96
+ 'baseId': baseId,
97
+ 'quoteId': quoteId,
98
+ 'settleId': undefined,
99
+ 'type': 'otc',
100
+ 'spot': false,
101
+ 'margin': false,
102
+ 'swap': false,
103
+ 'future': false,
104
+ 'option': false,
105
+ 'active': undefined,
106
+ 'contract': false,
107
+ 'linear': undefined,
108
+ 'inverse': undefined,
109
+ 'contractSize': undefined,
110
+ 'expiry': undefined,
111
+ 'expiryDatetime': undefined,
112
+ 'strike': undefined,
113
+ 'optionType': undefined,
114
+ 'precision': {
115
+ 'amount': undefined,
116
+ 'price': undefined,
117
+ },
118
+ 'limits': {
119
+ 'leverage': {
120
+ 'min': undefined,
121
+ 'max': undefined,
122
+ },
123
+ 'amount': {
124
+ 'min': undefined,
125
+ 'max': undefined,
126
+ },
127
+ 'price': {
128
+ 'min': undefined,
129
+ 'max': undefined,
130
+ },
131
+ 'cost': {
132
+ 'min': undefined,
133
+ 'max': undefined,
134
+ },
135
+ },
136
+ 'created': undefined,
137
+ 'info': market,
138
+ };
139
+ }
140
+ async fetchTickers(symbols = undefined, params = {}) {
141
+ /**
142
+ * @method
143
+ * @name swapwallet#fetchTickers
144
+ * @description fetches 24 hour price statistics for multiple OTC markets
145
+ * @see https://swapwallet.app/api/v2/market/crypto/stats
146
+ * @param {string[]} [symbols] unified symbols, all markets are returned if undefined
147
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
148
+ * @returns {object} a dictionary of ticker structures indexed by symbol
149
+ */
150
+ await this.loadMarkets();
151
+ symbols = this.marketSymbols(symbols);
152
+ const response = await this.publicGetMarketCryptoStats(params);
153
+ const tickers = this.safeDict(response, 'result', {});
154
+ const ids = Object.keys(tickers);
155
+ const result = {};
156
+ for (let i = 0; i < ids.length; i++) {
157
+ const id = ids[i];
158
+ const ticker = this.parseTicker(tickers[id]);
159
+ result[ticker['symbol']] = ticker;
160
+ }
161
+ return this.filterByArrayTickers(result, 'symbol', symbols);
162
+ }
163
+ async fetchTicker(symbol, params = {}) {
164
+ /**
165
+ * @method
166
+ * @name swapwallet#fetchTicker
167
+ * @description fetches 24 hour price statistics for a single OTC market
168
+ * @see https://swapwallet.app/api/v2/market/crypto/stats
169
+ * @param {string} symbol unified market symbol
170
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
171
+ * @returns {object} a ticker structure
172
+ */
173
+ await this.loadMarkets();
174
+ const market = this.market(symbol);
175
+ const tickers = await this.fetchTickers([market['symbol']], params);
176
+ return tickers[market['symbol']];
177
+ }
178
+ parseTicker(ticker, market = undefined) {
179
+ const baseId = this.safeString(ticker, 'source');
180
+ const quoteId = this.safeString(ticker, 'destination');
181
+ const marketId = baseId + '-' + quoteId;
182
+ const symbol = this.safeSymbol(marketId, market, '-', 'otc');
183
+ const data = this.safeDict(ticker, 'marketData', {});
184
+ const last = this.safeString(data, 'latestPrice');
185
+ return this.safeTicker({
186
+ 'symbol': symbol,
187
+ 'timestamp': undefined,
188
+ 'datetime': undefined,
189
+ 'high': undefined,
190
+ 'low': undefined,
191
+ 'bid': this.safeString(data, 'bestBuy'),
192
+ 'bidVolume': undefined,
193
+ 'ask': this.safeString(data, 'bestSell'),
194
+ 'askVolume': undefined,
195
+ 'vwap': undefined,
196
+ 'open': undefined,
197
+ 'close': last,
198
+ 'last': last,
199
+ 'previousClose': undefined,
200
+ 'change': undefined,
201
+ 'percentage': this.safeString(data, 'dayChange'),
202
+ 'average': undefined,
203
+ 'baseVolume': this.safeString(data, 'volume24h'),
204
+ 'quoteVolume': undefined,
205
+ 'info': ticker,
206
+ }, market);
207
+ }
208
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
209
+ const query = this.omit(params, this.extractParams(path));
210
+ let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
211
+ if (Object.keys(query).length) {
212
+ url += '?' + this.urlencode(query);
213
+ }
214
+ headers = { 'Content-Type': 'application/json' };
215
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
216
+ }
217
217
  }
218
218
 
219
219
  exports["default"] = swapwallet;