ccxt-ir 4.24.0 → 4.24.1
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 +3 -3
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +262 -262
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/abstract/balinex.js +1 -1
- package/dist/cjs/src/balinex.js +217 -217
- package/dist/cjs/src/bitbarg.js +322 -322
- package/dist/cjs/src/bitpin.js +34 -24
- package/dist/cjs/src/nobitex.js +25 -26
- package/dist/cjs/src/swapwallet.js +209 -209
- package/dist/cjs/src/wallex.js +105 -18
- package/js/ccxt.d.ts +772 -772
- package/js/ccxt.js +557 -557
- package/js/src/abstract/balinex.d.ts +8 -8
- package/js/src/abstract/balinex.js +5 -5
- package/js/src/abstract/swapwallet.js +5 -5
- package/js/src/abstract/wallex.d.ts +2 -0
- package/js/src/balinex.d.ts +20 -20
- package/js/src/balinex.js +220 -220
- package/js/src/base/Exchange.d.ts +926 -926
- package/js/src/bitbarg.js +325 -325
- package/js/src/bitpin.d.ts +2 -2
- package/js/src/bitpin.js +34 -24
- package/js/src/coinbaseexchange.d.ts +334 -334
- package/js/src/nobitex.d.ts +2 -2
- package/js/src/nobitex.js +25 -26
- package/js/src/protobuf/mexc/compiled.d.cts +2 -8
- package/js/src/static_dependencies/fflake/browser.d.ts +222 -222
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -101
- package/js/src/static_dependencies/qs/formats.d.cts +8 -14
- package/js/src/static_dependencies/qs/index.d.cts +4 -10
- package/js/src/static_dependencies/qs/parse.d.cts +2 -8
- package/js/src/static_dependencies/qs/stringify.d.cts +2 -8
- package/js/src/static_dependencies/qs/utils.d.cts +9 -15
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -5
- package/js/src/swapwallet.js +212 -212
- package/js/src/wallex.d.ts +2 -2
- package/js/src/wallex.js +105 -18
- package/js/test.js +51 -62
- package/package.json +1 -1
|
@@ -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;
|
package/dist/cjs/src/wallex.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var wallex$1 = require('./abstract/wallex.js');
|
|
6
|
+
var errors = require('./base/errors.js');
|
|
6
7
|
|
|
7
8
|
// ----------------------------------------------------------------------------
|
|
8
9
|
// ---------------------------------------------------------------------------
|
|
@@ -79,6 +80,7 @@ class wallex extends wallex$1["default"] {
|
|
|
79
80
|
'fetchTradingFee': false,
|
|
80
81
|
'fetchTradingFees': false,
|
|
81
82
|
'fetchWithdrawals': false,
|
|
83
|
+
'otc': true,
|
|
82
84
|
'setLeverage': false,
|
|
83
85
|
'setMarginMode': false,
|
|
84
86
|
'transfer': false,
|
|
@@ -107,6 +109,8 @@ class wallex extends wallex$1["default"] {
|
|
|
107
109
|
'public': {
|
|
108
110
|
'get': {
|
|
109
111
|
'v1/markets': 1,
|
|
112
|
+
'v1/currencies': 1,
|
|
113
|
+
'v1/otc/price': 1,
|
|
110
114
|
'v1/currencies/stats': 1,
|
|
111
115
|
'v1/depth': 1,
|
|
112
116
|
'v1/udf/history': 1,
|
|
@@ -133,9 +137,39 @@ class wallex extends wallex$1["default"] {
|
|
|
133
137
|
* @description retrieves data on all markets for wallex
|
|
134
138
|
* @see https://api-docs.wallex.ir/#be8d9c51a2
|
|
135
139
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
140
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'
|
|
136
141
|
* @returns {object[]} an array of objects representing market data
|
|
137
142
|
*/
|
|
138
|
-
const
|
|
143
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
144
|
+
const request = this.omit(params, ['type']);
|
|
145
|
+
if (type === 'otc') {
|
|
146
|
+
const otcResponse = await this.publicGetV1Currencies(request);
|
|
147
|
+
const currencies = this.safeDict(otcResponse, 'result', {});
|
|
148
|
+
const baseIds = Object.keys(currencies);
|
|
149
|
+
const quoteIds = ['TMN', 'USDT'];
|
|
150
|
+
const otcMarkets = [];
|
|
151
|
+
for (let i = 0; i < baseIds.length; i++) {
|
|
152
|
+
const baseId = baseIds[i];
|
|
153
|
+
// TMN is a quote currency; the OTC API does not support TMNUSDT.
|
|
154
|
+
if (baseId === 'TMN') {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
for (let j = 0; j < quoteIds.length; j++) {
|
|
158
|
+
const quoteId = quoteIds[j];
|
|
159
|
+
if (baseId === quoteId) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
otcMarkets.push(this.parseMarket({
|
|
163
|
+
'symbol': baseId + quoteId,
|
|
164
|
+
'baseAsset': baseId,
|
|
165
|
+
'quoteAsset': quoteId,
|
|
166
|
+
'info': currencies[baseId],
|
|
167
|
+
}, type));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return otcMarkets;
|
|
171
|
+
}
|
|
172
|
+
const response = await this.publicGetV1Markets(request);
|
|
139
173
|
const markets = this.safeDict(response, 'result');
|
|
140
174
|
const marketList = this.safeDict(markets, 'symbols');
|
|
141
175
|
const marketKeys = Object.keys(marketList);
|
|
@@ -147,7 +181,7 @@ class wallex extends wallex$1["default"] {
|
|
|
147
181
|
}
|
|
148
182
|
return result;
|
|
149
183
|
}
|
|
150
|
-
parseMarket(market) {
|
|
184
|
+
parseMarket(market, type = 'spot') {
|
|
151
185
|
// {
|
|
152
186
|
// symbol: "PEPETMN",
|
|
153
187
|
// baseAsset: "PEPE",
|
|
@@ -211,8 +245,8 @@ class wallex extends wallex$1["default"] {
|
|
|
211
245
|
'baseId': baseId,
|
|
212
246
|
'quoteId': quoteId,
|
|
213
247
|
'settleId': undefined,
|
|
214
|
-
'type':
|
|
215
|
-
'spot':
|
|
248
|
+
'type': type,
|
|
249
|
+
'spot': type === 'spot',
|
|
216
250
|
'margin': false,
|
|
217
251
|
'swap': false,
|
|
218
252
|
'future': false,
|
|
@@ -249,7 +283,7 @@ class wallex extends wallex$1["default"] {
|
|
|
249
283
|
},
|
|
250
284
|
},
|
|
251
285
|
'created': undefined,
|
|
252
|
-
'info': market,
|
|
286
|
+
'info': this.safeDict(market, 'info', market),
|
|
253
287
|
};
|
|
254
288
|
}
|
|
255
289
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
@@ -260,8 +294,40 @@ class wallex extends wallex$1["default"] {
|
|
|
260
294
|
* @see https://api-docs.wallex.ir/#be8d9c51a2
|
|
261
295
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
262
296
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
297
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'; OTC requests one BUY quote per symbol
|
|
263
298
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
264
299
|
*/
|
|
300
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
301
|
+
params = this.omit(params, ['type']);
|
|
302
|
+
if (type === 'otc') {
|
|
303
|
+
let otcMarkets = await this.fetchMarkets(this.extend(params, { 'type': type }));
|
|
304
|
+
if (symbols !== undefined) {
|
|
305
|
+
const marketsBySymbol = this.indexBy(otcMarkets, 'symbol');
|
|
306
|
+
const marketsById = this.indexBy(otcMarkets, 'id');
|
|
307
|
+
const selectedMarkets = [];
|
|
308
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
309
|
+
const symbol = symbols[i];
|
|
310
|
+
const market = this.safeDict(marketsBySymbol, symbol, this.safeDict(marketsById, symbol));
|
|
311
|
+
if (market === undefined) {
|
|
312
|
+
throw new errors.BadSymbol(this.id + ' does not have OTC market symbol ' + symbol);
|
|
313
|
+
}
|
|
314
|
+
selectedMarkets.push(market);
|
|
315
|
+
}
|
|
316
|
+
otcMarkets = selectedMarkets;
|
|
317
|
+
}
|
|
318
|
+
const otcTickers = {};
|
|
319
|
+
for (let i = 0; i < otcMarkets.length; i++) {
|
|
320
|
+
const market = otcMarkets[i];
|
|
321
|
+
const request = this.extend(params, { 'side': 'BUY', 'symbol': market['id'] });
|
|
322
|
+
const otcResponse = await this.publicGetV1OtcPrice(request);
|
|
323
|
+
const data = this.safeDict(otcResponse, 'result', {});
|
|
324
|
+
if (this.safeString(data, 'price') === undefined) {
|
|
325
|
+
throw new errors.ExchangeError(this.id + ' OTC quote unavailable for ' + market['symbol'] + ': ' + this.json(otcResponse));
|
|
326
|
+
}
|
|
327
|
+
otcTickers[market['symbol']] = this.parseTicker(data, market);
|
|
328
|
+
}
|
|
329
|
+
return otcTickers;
|
|
330
|
+
}
|
|
265
331
|
await this.loadMarkets();
|
|
266
332
|
if (symbols !== undefined) {
|
|
267
333
|
symbols = this.marketSymbols(symbols);
|
|
@@ -273,7 +339,8 @@ class wallex extends wallex$1["default"] {
|
|
|
273
339
|
const result = {};
|
|
274
340
|
for (let i = 0; i < marketKeys.length; i++) {
|
|
275
341
|
const index = marketKeys[i];
|
|
276
|
-
const
|
|
342
|
+
const market = this.parseMarket(marketList[index]);
|
|
343
|
+
const ticker = this.parseTicker(marketList[index], market);
|
|
277
344
|
const symbol = ticker['symbol'];
|
|
278
345
|
result[symbol] = ticker;
|
|
279
346
|
}
|
|
@@ -287,15 +354,12 @@ class wallex extends wallex$1["default"] {
|
|
|
287
354
|
* @see https://api-docs.wallex.ir/#be8d9c51a2
|
|
288
355
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
289
356
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
357
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'
|
|
290
358
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
291
359
|
*/
|
|
292
|
-
await this.
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
const markets = this.safeDict(response, 'result');
|
|
296
|
-
const marketList = this.safeDict(markets, 'symbols');
|
|
297
|
-
const ticker = this.parseTicker(marketList[market['id']]);
|
|
298
|
-
return ticker;
|
|
360
|
+
const tickers = await this.fetchTickers([symbol], params);
|
|
361
|
+
const values = Object.values(tickers);
|
|
362
|
+
return this.safeValue(values, 0);
|
|
299
363
|
}
|
|
300
364
|
parseTicker(ticker, market = undefined) {
|
|
301
365
|
// {
|
|
@@ -345,7 +409,33 @@ class wallex extends wallex$1["default"] {
|
|
|
345
409
|
// isNew: false,
|
|
346
410
|
// isZeroFee: false
|
|
347
411
|
// },
|
|
348
|
-
const marketType = 'spot';
|
|
412
|
+
const marketType = this.safeString(market, 'type', 'spot');
|
|
413
|
+
if (marketType === 'otc') {
|
|
414
|
+
const timestamp = this.parse8601(this.safeString(ticker, 'current_time'));
|
|
415
|
+
const price = this.safeNumber(ticker, 'price');
|
|
416
|
+
return this.safeTicker({
|
|
417
|
+
'symbol': market['symbol'],
|
|
418
|
+
'timestamp': timestamp,
|
|
419
|
+
'datetime': this.iso8601(timestamp),
|
|
420
|
+
'high': undefined,
|
|
421
|
+
'low': undefined,
|
|
422
|
+
'bid': undefined,
|
|
423
|
+
'bidVolume': undefined,
|
|
424
|
+
'ask': price,
|
|
425
|
+
'askVolume': undefined,
|
|
426
|
+
'vwap': undefined,
|
|
427
|
+
'open': undefined,
|
|
428
|
+
'close': price,
|
|
429
|
+
'last': price,
|
|
430
|
+
'previousClose': undefined,
|
|
431
|
+
'change': undefined,
|
|
432
|
+
'percentage': undefined,
|
|
433
|
+
'average': undefined,
|
|
434
|
+
'baseVolume': undefined,
|
|
435
|
+
'quoteVolume': undefined,
|
|
436
|
+
'info': ticker,
|
|
437
|
+
}, market);
|
|
438
|
+
}
|
|
349
439
|
const stats = this.safeValue(ticker, 'stats');
|
|
350
440
|
const marketId = this.safeString(ticker, 'symbol');
|
|
351
441
|
const symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
@@ -454,10 +544,7 @@ class wallex extends wallex$1["default"] {
|
|
|
454
544
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
455
545
|
const query = this.omit(params, this.extractParams(path));
|
|
456
546
|
let url = this.urls['api']['public'] + '/' + path;
|
|
457
|
-
if (
|
|
458
|
-
url = url + '?' + this.urlencode(query);
|
|
459
|
-
}
|
|
460
|
-
if (path === 'v1/depth') {
|
|
547
|
+
if (!this.isEmpty(query)) {
|
|
461
548
|
url = url + '?' + this.urlencode(query);
|
|
462
549
|
}
|
|
463
550
|
headers = { 'Content-Type': 'application/json' };
|