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
package/js/src/swapwallet.js
CHANGED
|
@@ -4,215 +4,215 @@
|
|
|
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 './base/Exchange.js';
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
/**
|
|
11
|
-
* @class swapwallet
|
|
12
|
-
* @augments Exchange
|
|
13
|
-
*/
|
|
14
|
-
export default class swapwallet extends Exchange {
|
|
15
|
-
describe() {
|
|
16
|
-
return this.deepExtend(super.describe(), {
|
|
17
|
-
'id': 'swapwallet',
|
|
18
|
-
'name': 'Swapwallet',
|
|
19
|
-
'countries': ['IR'],
|
|
20
|
-
'rateLimit': 1000,
|
|
21
|
-
'version': 'v2',
|
|
22
|
-
'certified': false,
|
|
23
|
-
'pro': false,
|
|
24
|
-
'has': {
|
|
25
|
-
'CORS': undefined,
|
|
26
|
-
'spot': false,
|
|
27
|
-
'margin': false,
|
|
28
|
-
'swap': false,
|
|
29
|
-
'future': false,
|
|
30
|
-
'option': false,
|
|
31
|
-
'fetchMarkets': true,
|
|
32
|
-
'fetchTicker': true,
|
|
33
|
-
'fetchTickers': true,
|
|
34
|
-
'otc': true,
|
|
35
|
-
},
|
|
36
|
-
'options': {
|
|
37
|
-
'defaultType': 'otc',
|
|
38
|
-
},
|
|
39
|
-
'urls': {
|
|
40
|
-
'api': {
|
|
41
|
-
'public': 'https://swapwallet.app/api/v2',
|
|
42
|
-
},
|
|
43
|
-
'www': 'https://swapwallet.app',
|
|
44
|
-
'doc': 'https://swapwallet.app/api/v2/market/crypto/stats',
|
|
45
|
-
},
|
|
46
|
-
'api': {
|
|
47
|
-
'public': {
|
|
48
|
-
'get': {
|
|
49
|
-
'market/crypto/stats': 1,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
async fetchMarkets(params = {}) {
|
|
56
|
-
/**
|
|
57
|
-
* @method
|
|
58
|
-
* @name swapwallet#fetchMarkets
|
|
59
|
-
* @description retrieves all OTC markets
|
|
60
|
-
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
61
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
62
|
-
* @returns {object[]} an array of market structures
|
|
63
|
-
*/
|
|
64
|
-
const response = await this.publicGetMarketCryptoStats(params);
|
|
65
|
-
const markets = this.safeDict(response, 'result', {});
|
|
66
|
-
const ids = Object.keys(markets);
|
|
67
|
-
const result = [];
|
|
68
|
-
for (let i = 0; i < ids.length; i++) {
|
|
69
|
-
const id = ids[i];
|
|
70
|
-
result.push(this.parseMarket(this.extend(markets[id], { 'id': id })));
|
|
71
|
-
}
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
parseMarket(market) {
|
|
75
|
-
// {
|
|
76
|
-
// "source": "USOON",
|
|
77
|
-
// "destination": "USDT",
|
|
78
|
-
// "marketData": {
|
|
79
|
-
// "bestSell": "165.72",
|
|
80
|
-
// "bestBuy": "162.43",
|
|
81
|
-
// "latestPrice": "164.08",
|
|
82
|
-
// "dayChange": "2.98",
|
|
83
|
-
// "volume24h": "3753.99"
|
|
84
|
-
// }
|
|
85
|
-
// }
|
|
86
|
-
const baseId = this.safeString(market, 'source');
|
|
87
|
-
const quoteId = this.safeString(market, 'destination');
|
|
88
|
-
const base = this.safeCurrencyCode(baseId);
|
|
89
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
90
|
-
const id = this.safeString(market, 'id', baseId + '-' + quoteId);
|
|
91
|
-
return {
|
|
92
|
-
'id': id,
|
|
93
|
-
'symbol': base + '/' + quote,
|
|
94
|
-
'base': base,
|
|
95
|
-
'quote': quote,
|
|
96
|
-
'settle': undefined,
|
|
97
|
-
'baseId': baseId,
|
|
98
|
-
'quoteId': quoteId,
|
|
99
|
-
'settleId': undefined,
|
|
100
|
-
'type': 'otc',
|
|
101
|
-
'spot': false,
|
|
102
|
-
'margin': false,
|
|
103
|
-
'swap': false,
|
|
104
|
-
'future': false,
|
|
105
|
-
'option': false,
|
|
106
|
-
'active': undefined,
|
|
107
|
-
'contract': false,
|
|
108
|
-
'linear': undefined,
|
|
109
|
-
'inverse': undefined,
|
|
110
|
-
'contractSize': undefined,
|
|
111
|
-
'expiry': undefined,
|
|
112
|
-
'expiryDatetime': undefined,
|
|
113
|
-
'strike': undefined,
|
|
114
|
-
'optionType': undefined,
|
|
115
|
-
'precision': {
|
|
116
|
-
'amount': undefined,
|
|
117
|
-
'price': undefined,
|
|
118
|
-
},
|
|
119
|
-
'limits': {
|
|
120
|
-
'leverage': {
|
|
121
|
-
'min': undefined,
|
|
122
|
-
'max': undefined,
|
|
123
|
-
},
|
|
124
|
-
'amount': {
|
|
125
|
-
'min': undefined,
|
|
126
|
-
'max': undefined,
|
|
127
|
-
},
|
|
128
|
-
'price': {
|
|
129
|
-
'min': undefined,
|
|
130
|
-
'max': undefined,
|
|
131
|
-
},
|
|
132
|
-
'cost': {
|
|
133
|
-
'min': undefined,
|
|
134
|
-
'max': undefined,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
'created': undefined,
|
|
138
|
-
'info': market,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
142
|
-
/**
|
|
143
|
-
* @method
|
|
144
|
-
* @name swapwallet#fetchTickers
|
|
145
|
-
* @description fetches 24 hour price statistics for multiple OTC markets
|
|
146
|
-
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
147
|
-
* @param {string[]} [symbols] unified symbols, all markets are returned if undefined
|
|
148
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
149
|
-
* @returns {object} a dictionary of ticker structures indexed by symbol
|
|
150
|
-
*/
|
|
151
|
-
await this.loadMarkets();
|
|
152
|
-
symbols = this.marketSymbols(symbols);
|
|
153
|
-
const response = await this.publicGetMarketCryptoStats(params);
|
|
154
|
-
const tickers = this.safeDict(response, 'result', {});
|
|
155
|
-
const ids = Object.keys(tickers);
|
|
156
|
-
const result = {};
|
|
157
|
-
for (let i = 0; i < ids.length; i++) {
|
|
158
|
-
const id = ids[i];
|
|
159
|
-
const ticker = this.parseTicker(tickers[id]);
|
|
160
|
-
result[ticker['symbol']] = ticker;
|
|
161
|
-
}
|
|
162
|
-
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
163
|
-
}
|
|
164
|
-
async fetchTicker(symbol, params = {}) {
|
|
165
|
-
/**
|
|
166
|
-
* @method
|
|
167
|
-
* @name swapwallet#fetchTicker
|
|
168
|
-
* @description fetches 24 hour price statistics for a single OTC market
|
|
169
|
-
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
170
|
-
* @param {string} symbol unified market symbol
|
|
171
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
172
|
-
* @returns {object} a ticker structure
|
|
173
|
-
*/
|
|
174
|
-
await this.loadMarkets();
|
|
175
|
-
const market = this.market(symbol);
|
|
176
|
-
const tickers = await this.fetchTickers([market['symbol']], params);
|
|
177
|
-
return tickers[market['symbol']];
|
|
178
|
-
}
|
|
179
|
-
parseTicker(ticker, market = undefined) {
|
|
180
|
-
const baseId = this.safeString(ticker, 'source');
|
|
181
|
-
const quoteId = this.safeString(ticker, 'destination');
|
|
182
|
-
const marketId = baseId + '-' + quoteId;
|
|
183
|
-
const symbol = this.safeSymbol(marketId, market, '-', 'otc');
|
|
184
|
-
const data = this.safeDict(ticker, 'marketData', {});
|
|
185
|
-
const last = this.safeString(data, 'latestPrice');
|
|
186
|
-
return this.safeTicker({
|
|
187
|
-
'symbol': symbol,
|
|
188
|
-
'timestamp': undefined,
|
|
189
|
-
'datetime': undefined,
|
|
190
|
-
'high': undefined,
|
|
191
|
-
'low': undefined,
|
|
192
|
-
'bid': this.safeString(data, 'bestBuy'),
|
|
193
|
-
'bidVolume': undefined,
|
|
194
|
-
'ask': this.safeString(data, 'bestSell'),
|
|
195
|
-
'askVolume': undefined,
|
|
196
|
-
'vwap': undefined,
|
|
197
|
-
'open': undefined,
|
|
198
|
-
'close': last,
|
|
199
|
-
'last': last,
|
|
200
|
-
'previousClose': undefined,
|
|
201
|
-
'change': undefined,
|
|
202
|
-
'percentage': this.safeString(data, 'dayChange'),
|
|
203
|
-
'average': undefined,
|
|
204
|
-
'baseVolume': this.safeString(data, 'volume24h'),
|
|
205
|
-
'quoteVolume': undefined,
|
|
206
|
-
'info': ticker,
|
|
207
|
-
}, market);
|
|
208
|
-
}
|
|
209
|
-
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
210
|
-
const query = this.omit(params, this.extractParams(path));
|
|
211
|
-
let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
|
|
212
|
-
if (Object.keys(query).length) {
|
|
213
|
-
url += '?' + this.urlencode(query);
|
|
214
|
-
}
|
|
215
|
-
headers = { 'Content-Type': 'application/json' };
|
|
216
|
-
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
217
|
-
}
|
|
218
|
-
}
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
import Exchange from './base/Exchange.js';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
/**
|
|
11
|
+
* @class swapwallet
|
|
12
|
+
* @augments Exchange
|
|
13
|
+
*/
|
|
14
|
+
export default class swapwallet extends Exchange {
|
|
15
|
+
describe() {
|
|
16
|
+
return this.deepExtend(super.describe(), {
|
|
17
|
+
'id': 'swapwallet',
|
|
18
|
+
'name': 'Swapwallet',
|
|
19
|
+
'countries': ['IR'],
|
|
20
|
+
'rateLimit': 1000,
|
|
21
|
+
'version': 'v2',
|
|
22
|
+
'certified': false,
|
|
23
|
+
'pro': false,
|
|
24
|
+
'has': {
|
|
25
|
+
'CORS': undefined,
|
|
26
|
+
'spot': false,
|
|
27
|
+
'margin': false,
|
|
28
|
+
'swap': false,
|
|
29
|
+
'future': false,
|
|
30
|
+
'option': false,
|
|
31
|
+
'fetchMarkets': true,
|
|
32
|
+
'fetchTicker': true,
|
|
33
|
+
'fetchTickers': true,
|
|
34
|
+
'otc': true,
|
|
35
|
+
},
|
|
36
|
+
'options': {
|
|
37
|
+
'defaultType': 'otc',
|
|
38
|
+
},
|
|
39
|
+
'urls': {
|
|
40
|
+
'api': {
|
|
41
|
+
'public': 'https://swapwallet.app/api/v2',
|
|
42
|
+
},
|
|
43
|
+
'www': 'https://swapwallet.app',
|
|
44
|
+
'doc': 'https://swapwallet.app/api/v2/market/crypto/stats',
|
|
45
|
+
},
|
|
46
|
+
'api': {
|
|
47
|
+
'public': {
|
|
48
|
+
'get': {
|
|
49
|
+
'market/crypto/stats': 1,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async fetchMarkets(params = {}) {
|
|
56
|
+
/**
|
|
57
|
+
* @method
|
|
58
|
+
* @name swapwallet#fetchMarkets
|
|
59
|
+
* @description retrieves all OTC markets
|
|
60
|
+
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
61
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
62
|
+
* @returns {object[]} an array of market structures
|
|
63
|
+
*/
|
|
64
|
+
const response = await this.publicGetMarketCryptoStats(params);
|
|
65
|
+
const markets = this.safeDict(response, 'result', {});
|
|
66
|
+
const ids = Object.keys(markets);
|
|
67
|
+
const result = [];
|
|
68
|
+
for (let i = 0; i < ids.length; i++) {
|
|
69
|
+
const id = ids[i];
|
|
70
|
+
result.push(this.parseMarket(this.extend(markets[id], { 'id': id })));
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
parseMarket(market) {
|
|
75
|
+
// {
|
|
76
|
+
// "source": "USOON",
|
|
77
|
+
// "destination": "USDT",
|
|
78
|
+
// "marketData": {
|
|
79
|
+
// "bestSell": "165.72",
|
|
80
|
+
// "bestBuy": "162.43",
|
|
81
|
+
// "latestPrice": "164.08",
|
|
82
|
+
// "dayChange": "2.98",
|
|
83
|
+
// "volume24h": "3753.99"
|
|
84
|
+
// }
|
|
85
|
+
// }
|
|
86
|
+
const baseId = this.safeString(market, 'source');
|
|
87
|
+
const quoteId = this.safeString(market, 'destination');
|
|
88
|
+
const base = this.safeCurrencyCode(baseId);
|
|
89
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
90
|
+
const id = this.safeString(market, 'id', baseId + '-' + quoteId);
|
|
91
|
+
return {
|
|
92
|
+
'id': id,
|
|
93
|
+
'symbol': base + '/' + quote,
|
|
94
|
+
'base': base,
|
|
95
|
+
'quote': quote,
|
|
96
|
+
'settle': undefined,
|
|
97
|
+
'baseId': baseId,
|
|
98
|
+
'quoteId': quoteId,
|
|
99
|
+
'settleId': undefined,
|
|
100
|
+
'type': 'otc',
|
|
101
|
+
'spot': false,
|
|
102
|
+
'margin': false,
|
|
103
|
+
'swap': false,
|
|
104
|
+
'future': false,
|
|
105
|
+
'option': false,
|
|
106
|
+
'active': undefined,
|
|
107
|
+
'contract': false,
|
|
108
|
+
'linear': undefined,
|
|
109
|
+
'inverse': undefined,
|
|
110
|
+
'contractSize': undefined,
|
|
111
|
+
'expiry': undefined,
|
|
112
|
+
'expiryDatetime': undefined,
|
|
113
|
+
'strike': undefined,
|
|
114
|
+
'optionType': undefined,
|
|
115
|
+
'precision': {
|
|
116
|
+
'amount': undefined,
|
|
117
|
+
'price': undefined,
|
|
118
|
+
},
|
|
119
|
+
'limits': {
|
|
120
|
+
'leverage': {
|
|
121
|
+
'min': undefined,
|
|
122
|
+
'max': undefined,
|
|
123
|
+
},
|
|
124
|
+
'amount': {
|
|
125
|
+
'min': undefined,
|
|
126
|
+
'max': undefined,
|
|
127
|
+
},
|
|
128
|
+
'price': {
|
|
129
|
+
'min': undefined,
|
|
130
|
+
'max': undefined,
|
|
131
|
+
},
|
|
132
|
+
'cost': {
|
|
133
|
+
'min': undefined,
|
|
134
|
+
'max': undefined,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
'created': undefined,
|
|
138
|
+
'info': market,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
142
|
+
/**
|
|
143
|
+
* @method
|
|
144
|
+
* @name swapwallet#fetchTickers
|
|
145
|
+
* @description fetches 24 hour price statistics for multiple OTC markets
|
|
146
|
+
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
147
|
+
* @param {string[]} [symbols] unified symbols, all markets are returned if undefined
|
|
148
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
149
|
+
* @returns {object} a dictionary of ticker structures indexed by symbol
|
|
150
|
+
*/
|
|
151
|
+
await this.loadMarkets();
|
|
152
|
+
symbols = this.marketSymbols(symbols);
|
|
153
|
+
const response = await this.publicGetMarketCryptoStats(params);
|
|
154
|
+
const tickers = this.safeDict(response, 'result', {});
|
|
155
|
+
const ids = Object.keys(tickers);
|
|
156
|
+
const result = {};
|
|
157
|
+
for (let i = 0; i < ids.length; i++) {
|
|
158
|
+
const id = ids[i];
|
|
159
|
+
const ticker = this.parseTicker(tickers[id]);
|
|
160
|
+
result[ticker['symbol']] = ticker;
|
|
161
|
+
}
|
|
162
|
+
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
163
|
+
}
|
|
164
|
+
async fetchTicker(symbol, params = {}) {
|
|
165
|
+
/**
|
|
166
|
+
* @method
|
|
167
|
+
* @name swapwallet#fetchTicker
|
|
168
|
+
* @description fetches 24 hour price statistics for a single OTC market
|
|
169
|
+
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
170
|
+
* @param {string} symbol unified market symbol
|
|
171
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
172
|
+
* @returns {object} a ticker structure
|
|
173
|
+
*/
|
|
174
|
+
await this.loadMarkets();
|
|
175
|
+
const market = this.market(symbol);
|
|
176
|
+
const tickers = await this.fetchTickers([market['symbol']], params);
|
|
177
|
+
return tickers[market['symbol']];
|
|
178
|
+
}
|
|
179
|
+
parseTicker(ticker, market = undefined) {
|
|
180
|
+
const baseId = this.safeString(ticker, 'source');
|
|
181
|
+
const quoteId = this.safeString(ticker, 'destination');
|
|
182
|
+
const marketId = baseId + '-' + quoteId;
|
|
183
|
+
const symbol = this.safeSymbol(marketId, market, '-', 'otc');
|
|
184
|
+
const data = this.safeDict(ticker, 'marketData', {});
|
|
185
|
+
const last = this.safeString(data, 'latestPrice');
|
|
186
|
+
return this.safeTicker({
|
|
187
|
+
'symbol': symbol,
|
|
188
|
+
'timestamp': undefined,
|
|
189
|
+
'datetime': undefined,
|
|
190
|
+
'high': undefined,
|
|
191
|
+
'low': undefined,
|
|
192
|
+
'bid': this.safeString(data, 'bestBuy'),
|
|
193
|
+
'bidVolume': undefined,
|
|
194
|
+
'ask': this.safeString(data, 'bestSell'),
|
|
195
|
+
'askVolume': undefined,
|
|
196
|
+
'vwap': undefined,
|
|
197
|
+
'open': undefined,
|
|
198
|
+
'close': last,
|
|
199
|
+
'last': last,
|
|
200
|
+
'previousClose': undefined,
|
|
201
|
+
'change': undefined,
|
|
202
|
+
'percentage': this.safeString(data, 'dayChange'),
|
|
203
|
+
'average': undefined,
|
|
204
|
+
'baseVolume': this.safeString(data, 'volume24h'),
|
|
205
|
+
'quoteVolume': undefined,
|
|
206
|
+
'info': ticker,
|
|
207
|
+
}, market);
|
|
208
|
+
}
|
|
209
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
210
|
+
const query = this.omit(params, this.extractParams(path));
|
|
211
|
+
let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
|
|
212
|
+
if (Object.keys(query).length) {
|
|
213
|
+
url += '?' + this.urlencode(query);
|
|
214
|
+
}
|
|
215
|
+
headers = { 'Content-Type': 'application/json' };
|
|
216
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
217
|
+
}
|
|
218
|
+
}
|
package/js/src/wallex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/wallex.js';
|
|
2
|
-
import { Int, Market, OHLCV, OrderBook, Strings, Ticker, Tickers } from './base/types.js';
|
|
2
|
+
import { Int, Market, MarketType, OHLCV, OrderBook, Strings, Ticker, Tickers } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class wallex
|
|
5
5
|
* @augments Exchange
|
|
@@ -8,7 +8,7 @@ import { Int, Market, OHLCV, OrderBook, Strings, Ticker, Tickers } from './base/
|
|
|
8
8
|
export default class wallex extends Exchange {
|
|
9
9
|
describe(): any;
|
|
10
10
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
11
|
-
parseMarket(market: any): Market;
|
|
11
|
+
parseMarket(market: any, type?: MarketType): Market;
|
|
12
12
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
13
13
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
14
14
|
parseTicker(ticker: any, market?: Market): Ticker;
|
package/js/src/wallex.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/wallex.js';
|
|
9
|
+
import { BadSymbol, ExchangeError } from './base/errors.js';
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
10
11
|
/**
|
|
11
12
|
* @class wallex
|
|
@@ -80,6 +81,7 @@ export default class wallex extends Exchange {
|
|
|
80
81
|
'fetchTradingFee': false,
|
|
81
82
|
'fetchTradingFees': false,
|
|
82
83
|
'fetchWithdrawals': false,
|
|
84
|
+
'otc': true,
|
|
83
85
|
'setLeverage': false,
|
|
84
86
|
'setMarginMode': false,
|
|
85
87
|
'transfer': false,
|
|
@@ -108,6 +110,8 @@ export default class wallex extends Exchange {
|
|
|
108
110
|
'public': {
|
|
109
111
|
'get': {
|
|
110
112
|
'v1/markets': 1,
|
|
113
|
+
'v1/currencies': 1,
|
|
114
|
+
'v1/otc/price': 1,
|
|
111
115
|
'v1/currencies/stats': 1,
|
|
112
116
|
'v1/depth': 1,
|
|
113
117
|
'v1/udf/history': 1,
|
|
@@ -134,9 +138,39 @@ export default class wallex extends Exchange {
|
|
|
134
138
|
* @description retrieves data on all markets for wallex
|
|
135
139
|
* @see https://api-docs.wallex.ir/#be8d9c51a2
|
|
136
140
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
141
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'
|
|
137
142
|
* @returns {object[]} an array of objects representing market data
|
|
138
143
|
*/
|
|
139
|
-
const
|
|
144
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
145
|
+
const request = this.omit(params, ['type']);
|
|
146
|
+
if (type === 'otc') {
|
|
147
|
+
const otcResponse = await this.publicGetV1Currencies(request);
|
|
148
|
+
const currencies = this.safeDict(otcResponse, 'result', {});
|
|
149
|
+
const baseIds = Object.keys(currencies);
|
|
150
|
+
const quoteIds = ['TMN', 'USDT'];
|
|
151
|
+
const otcMarkets = [];
|
|
152
|
+
for (let i = 0; i < baseIds.length; i++) {
|
|
153
|
+
const baseId = baseIds[i];
|
|
154
|
+
// TMN is a quote currency; the OTC API does not support TMNUSDT.
|
|
155
|
+
if (baseId === 'TMN') {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
for (let j = 0; j < quoteIds.length; j++) {
|
|
159
|
+
const quoteId = quoteIds[j];
|
|
160
|
+
if (baseId === quoteId) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
otcMarkets.push(this.parseMarket({
|
|
164
|
+
'symbol': baseId + quoteId,
|
|
165
|
+
'baseAsset': baseId,
|
|
166
|
+
'quoteAsset': quoteId,
|
|
167
|
+
'info': currencies[baseId],
|
|
168
|
+
}, type));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return otcMarkets;
|
|
172
|
+
}
|
|
173
|
+
const response = await this.publicGetV1Markets(request);
|
|
140
174
|
const markets = this.safeDict(response, 'result');
|
|
141
175
|
const marketList = this.safeDict(markets, 'symbols');
|
|
142
176
|
const marketKeys = Object.keys(marketList);
|
|
@@ -148,7 +182,7 @@ export default class wallex extends Exchange {
|
|
|
148
182
|
}
|
|
149
183
|
return result;
|
|
150
184
|
}
|
|
151
|
-
parseMarket(market) {
|
|
185
|
+
parseMarket(market, type = 'spot') {
|
|
152
186
|
// {
|
|
153
187
|
// symbol: "PEPETMN",
|
|
154
188
|
// baseAsset: "PEPE",
|
|
@@ -212,8 +246,8 @@ export default class wallex extends Exchange {
|
|
|
212
246
|
'baseId': baseId,
|
|
213
247
|
'quoteId': quoteId,
|
|
214
248
|
'settleId': undefined,
|
|
215
|
-
'type':
|
|
216
|
-
'spot':
|
|
249
|
+
'type': type,
|
|
250
|
+
'spot': type === 'spot',
|
|
217
251
|
'margin': false,
|
|
218
252
|
'swap': false,
|
|
219
253
|
'future': false,
|
|
@@ -250,7 +284,7 @@ export default class wallex extends Exchange {
|
|
|
250
284
|
},
|
|
251
285
|
},
|
|
252
286
|
'created': undefined,
|
|
253
|
-
'info': market,
|
|
287
|
+
'info': this.safeDict(market, 'info', market),
|
|
254
288
|
};
|
|
255
289
|
}
|
|
256
290
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
@@ -261,8 +295,40 @@ export default class wallex extends Exchange {
|
|
|
261
295
|
* @see https://api-docs.wallex.ir/#be8d9c51a2
|
|
262
296
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
263
297
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
298
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'; OTC requests one BUY quote per symbol
|
|
264
299
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
265
300
|
*/
|
|
301
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
302
|
+
params = this.omit(params, ['type']);
|
|
303
|
+
if (type === 'otc') {
|
|
304
|
+
let otcMarkets = await this.fetchMarkets(this.extend(params, { 'type': type }));
|
|
305
|
+
if (symbols !== undefined) {
|
|
306
|
+
const marketsBySymbol = this.indexBy(otcMarkets, 'symbol');
|
|
307
|
+
const marketsById = this.indexBy(otcMarkets, 'id');
|
|
308
|
+
const selectedMarkets = [];
|
|
309
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
310
|
+
const symbol = symbols[i];
|
|
311
|
+
const market = this.safeDict(marketsBySymbol, symbol, this.safeDict(marketsById, symbol));
|
|
312
|
+
if (market === undefined) {
|
|
313
|
+
throw new BadSymbol(this.id + ' does not have OTC market symbol ' + symbol);
|
|
314
|
+
}
|
|
315
|
+
selectedMarkets.push(market);
|
|
316
|
+
}
|
|
317
|
+
otcMarkets = selectedMarkets;
|
|
318
|
+
}
|
|
319
|
+
const otcTickers = {};
|
|
320
|
+
for (let i = 0; i < otcMarkets.length; i++) {
|
|
321
|
+
const market = otcMarkets[i];
|
|
322
|
+
const request = this.extend(params, { 'side': 'BUY', 'symbol': market['id'] });
|
|
323
|
+
const otcResponse = await this.publicGetV1OtcPrice(request);
|
|
324
|
+
const data = this.safeDict(otcResponse, 'result', {});
|
|
325
|
+
if (this.safeString(data, 'price') === undefined) {
|
|
326
|
+
throw new ExchangeError(this.id + ' OTC quote unavailable for ' + market['symbol'] + ': ' + this.json(otcResponse));
|
|
327
|
+
}
|
|
328
|
+
otcTickers[market['symbol']] = this.parseTicker(data, market);
|
|
329
|
+
}
|
|
330
|
+
return otcTickers;
|
|
331
|
+
}
|
|
266
332
|
await this.loadMarkets();
|
|
267
333
|
if (symbols !== undefined) {
|
|
268
334
|
symbols = this.marketSymbols(symbols);
|
|
@@ -274,7 +340,8 @@ export default class wallex extends Exchange {
|
|
|
274
340
|
const result = {};
|
|
275
341
|
for (let i = 0; i < marketKeys.length; i++) {
|
|
276
342
|
const index = marketKeys[i];
|
|
277
|
-
const
|
|
343
|
+
const market = this.parseMarket(marketList[index]);
|
|
344
|
+
const ticker = this.parseTicker(marketList[index], market);
|
|
278
345
|
const symbol = ticker['symbol'];
|
|
279
346
|
result[symbol] = ticker;
|
|
280
347
|
}
|
|
@@ -288,15 +355,12 @@ export default class wallex extends Exchange {
|
|
|
288
355
|
* @see https://api-docs.wallex.ir/#be8d9c51a2
|
|
289
356
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
290
357
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
358
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'
|
|
291
359
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
292
360
|
*/
|
|
293
|
-
await this.
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
const markets = this.safeDict(response, 'result');
|
|
297
|
-
const marketList = this.safeDict(markets, 'symbols');
|
|
298
|
-
const ticker = this.parseTicker(marketList[market['id']]);
|
|
299
|
-
return ticker;
|
|
361
|
+
const tickers = await this.fetchTickers([symbol], params);
|
|
362
|
+
const values = Object.values(tickers);
|
|
363
|
+
return this.safeValue(values, 0);
|
|
300
364
|
}
|
|
301
365
|
parseTicker(ticker, market = undefined) {
|
|
302
366
|
// {
|
|
@@ -346,7 +410,33 @@ export default class wallex extends Exchange {
|
|
|
346
410
|
// isNew: false,
|
|
347
411
|
// isZeroFee: false
|
|
348
412
|
// },
|
|
349
|
-
const marketType = 'spot';
|
|
413
|
+
const marketType = this.safeString(market, 'type', 'spot');
|
|
414
|
+
if (marketType === 'otc') {
|
|
415
|
+
const timestamp = this.parse8601(this.safeString(ticker, 'current_time'));
|
|
416
|
+
const price = this.safeNumber(ticker, 'price');
|
|
417
|
+
return this.safeTicker({
|
|
418
|
+
'symbol': market['symbol'],
|
|
419
|
+
'timestamp': timestamp,
|
|
420
|
+
'datetime': this.iso8601(timestamp),
|
|
421
|
+
'high': undefined,
|
|
422
|
+
'low': undefined,
|
|
423
|
+
'bid': undefined,
|
|
424
|
+
'bidVolume': undefined,
|
|
425
|
+
'ask': price,
|
|
426
|
+
'askVolume': undefined,
|
|
427
|
+
'vwap': undefined,
|
|
428
|
+
'open': undefined,
|
|
429
|
+
'close': price,
|
|
430
|
+
'last': price,
|
|
431
|
+
'previousClose': undefined,
|
|
432
|
+
'change': undefined,
|
|
433
|
+
'percentage': undefined,
|
|
434
|
+
'average': undefined,
|
|
435
|
+
'baseVolume': undefined,
|
|
436
|
+
'quoteVolume': undefined,
|
|
437
|
+
'info': ticker,
|
|
438
|
+
}, market);
|
|
439
|
+
}
|
|
350
440
|
const stats = this.safeValue(ticker, 'stats');
|
|
351
441
|
const marketId = this.safeString(ticker, 'symbol');
|
|
352
442
|
const symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
@@ -455,10 +545,7 @@ export default class wallex extends Exchange {
|
|
|
455
545
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
456
546
|
const query = this.omit(params, this.extractParams(path));
|
|
457
547
|
let url = this.urls['api']['public'] + '/' + path;
|
|
458
|
-
if (
|
|
459
|
-
url = url + '?' + this.urlencode(query);
|
|
460
|
-
}
|
|
461
|
-
if (path === 'v1/depth') {
|
|
548
|
+
if (!this.isEmpty(query)) {
|
|
462
549
|
url = url + '?' + this.urlencode(query);
|
|
463
550
|
}
|
|
464
551
|
headers = { 'Content-Type': 'application/json' };
|