ccxt-ir 4.23.0 → 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.
- package/README.md +4 -4
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +264 -261
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/abstract/balinex.js +11 -0
- package/dist/cjs/src/balinex.js +227 -0
- package/dist/cjs/src/bitbarg.js +322 -303
- package/dist/cjs/src/swapwallet.js +209 -209
- package/js/ccxt.d.ts +772 -769
- package/js/ccxt.js +557 -555
- package/js/src/abstract/balinex.d.ts +8 -0
- package/js/src/abstract/balinex.js +11 -0
- package/js/src/abstract/swapwallet.js +11 -0
- package/js/src/balinex.d.ts +20 -0
- package/js/src/balinex.js +226 -0
- package/js/src/base/Exchange.d.ts +926 -926
- package/js/src/bitbarg.js +325 -306
- package/js/src/coinbaseexchange.d.ts +334 -334
- package/js/src/protobuf/mexc/compiled.d.cts +8 -2
- 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 +14 -8
- package/js/src/static_dependencies/qs/index.d.cts +10 -4
- package/js/src/static_dependencies/qs/parse.d.cts +8 -2
- package/js/src/static_dependencies/qs/stringify.d.cts +8 -2
- package/js/src/static_dependencies/qs/utils.d.cts +15 -9
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -5
- package/js/src/swapwallet.js +212 -212
- package/js/test.js +62 -62
- package/package.json +1 -1
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
declare const
|
|
8
|
-
export
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
declare const _default: string;
|
|
8
|
+
export declare namespace formatters {
|
|
9
|
+
function RFC1738(value: any): string;
|
|
10
|
+
function RFC3986(value: any): any;
|
|
11
|
+
}
|
|
12
|
+
declare const RFC1738_1: string;
|
|
13
|
+
declare const RFC3986_1: string;
|
|
14
|
+
export { _default as default, RFC1738_1 as RFC1738, RFC3986_1 as RFC3986 };
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
import formats = require("./formats.cjs");
|
|
8
|
+
import parse = require("./parse.cjs");
|
|
9
|
+
import stringify = require("./stringify.cjs");
|
|
10
|
+
export { formats, parse, stringify };
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
declare function _exports(str: any, opts: any): any;
|
|
8
|
+
export = _exports;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
declare function _exports(object: any, opts: any): string;
|
|
8
|
+
export = _exports;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function
|
|
8
|
-
export function
|
|
9
|
-
export function
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
export function arrayToObject(source: any, options: any): any;
|
|
8
|
+
export function assign(target: any, source: any): any;
|
|
9
|
+
export function combine(a: any, b: any): any[];
|
|
10
|
+
export function compact(value: any): any;
|
|
11
|
+
export function decode(str: any, decoder: any, charset: any): any;
|
|
12
|
+
export function encode(str: any, defaultEncoder: any, charset: any): any;
|
|
13
|
+
export function isBuffer(obj: any): boolean;
|
|
14
|
+
export function isRegExp(obj: any): boolean;
|
|
15
|
+
export function merge(target: any, source: any, options: any): any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Abi, FunctionAbi, RawArgs } from '../../../types/index.js';
|
|
2
|
-
import { AbiParserInterface } from './interface.js';
|
|
3
|
-
export declare function createAbiParser(abi: Abi): AbiParserInterface;
|
|
4
|
-
export declare function getAbiVersion(abi: Abi):
|
|
5
|
-
export declare function isNoConstructorValid(method: string, argsCalldata: RawArgs, abiMethod?: FunctionAbi): boolean;
|
|
1
|
+
import { Abi, FunctionAbi, RawArgs } from '../../../types/index.js';
|
|
2
|
+
import { AbiParserInterface } from './interface.js';
|
|
3
|
+
export declare function createAbiParser(abi: Abi): AbiParserInterface;
|
|
4
|
+
export declare function getAbiVersion(abi: Abi): 0 | 1 | 2;
|
|
5
|
+
export declare function isNoConstructorValid(method: string, argsCalldata: RawArgs, abiMethod?: FunctionAbi): boolean;
|
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 =
|
|
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
|
+
}
|