ccxt-ir 4.22.0 → 4.23.2

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.
@@ -1,9 +1,3 @@
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
1
  export function arrayToObject(source: any, options: any): any;
8
2
  export function assign(target: any, source: any): any;
9
3
  export function combine(a: any, b: any): any[];
@@ -1,5 +1,5 @@
1
1
  import { Abi, FunctionAbi, RawArgs } from '../../../types/index.js';
2
2
  import { AbiParserInterface } from './interface.js';
3
3
  export declare function createAbiParser(abi: Abi): AbiParserInterface;
4
- export declare function getAbiVersion(abi: Abi): 0 | 1 | 2;
4
+ export declare function getAbiVersion(abi: Abi): 1 | 0 | 2;
5
5
  export declare function isNoConstructorValid(method: string, argsCalldata: RawArgs, abiMethod?: FunctionAbi): boolean;
@@ -0,0 +1,20 @@
1
+ import Exchange from './base/Exchange.js';
2
+ import { Market, Strings, Ticker, Tickers } from './base/types.js';
3
+ /**
4
+ * @class swapwallet
5
+ * @augments Exchange
6
+ */
7
+ export default class swapwallet extends Exchange {
8
+ describe(): any;
9
+ fetchMarkets(params?: {}): Promise<Market[]>;
10
+ parseMarket(market: any): Market;
11
+ fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
12
+ fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
13
+ parseTicker(ticker: any, market?: Market): Ticker;
14
+ sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
15
+ url: string;
16
+ method: string;
17
+ body: any;
18
+ headers: any;
19
+ };
20
+ }
@@ -0,0 +1,218 @@
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
+ // ---------------------------------------------------------------------------
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/test.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/js/test.js CHANGED
@@ -4,38 +4,18 @@
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
- import ariomex from './src/ariomex.js';
8
- import poulyar from './src/poulyar.js';
9
- import ourbit from './src/ourbit.js';
10
- import ubitex from './src/ubitex.js';
11
- async function testTicker(exchange, name, params = {}) {
12
- try {
13
- await exchange.loadMarkets(false, params);
14
- const symbol = exchange.markets['BTC/USDT'] ? 'BTC/USDT' : exchange.symbols[0];
15
- if (symbol === undefined) {
16
- throw new Error(`${name} returned no markets`);
17
- }
18
- const ticker = await exchange.fetchTicker(symbol);
19
- if (ticker.symbol !== symbol) {
20
- throw new Error(`${name} returned ticker for ${ticker.symbol} instead of ${symbol}`);
21
- }
22
- console.log(`${name} ${symbol} ticker:`, {
23
- symbol: ticker.symbol,
24
- timestamp: ticker.timestamp,
25
- datetime: ticker.datetime,
26
- last: ticker.last,
27
- bid: ticker.bid,
28
- ask: ticker.ask,
29
- });
30
- }
31
- finally {
32
- await exchange.close();
33
- }
34
- }
35
- async function run() {
36
- await testTicker(new ariomex({ enableRateLimit: true, timeout: 30000 }), 'Ariomex');
37
- await testTicker(new poulyar({ enableRateLimit: true, timeout: 30000 }), 'Poulyar');
38
- await testTicker(new ourbit({ enableRateLimit: true, timeout: 30000 }), 'Ourbit', { type: 'spot' });
39
- await testTicker(new ubitex({ enableRateLimit: true, timeout: 30000 }), 'Ubitex');
40
- }
41
- void run();
7
+ import ccxt from './ccxt.js';
8
+ async function main() {
9
+ const exchange = new ccxt.bitbarg();
10
+ try {
11
+ const ticker = await exchange.fetchTicker('USDT/IRT');
12
+ console.log(ticker);
13
+ }
14
+ finally {
15
+ exchange.close();
16
+ }
17
+ }
18
+ main().catch((error) => {
19
+ console.error(error);
20
+ process.exitCode = 1;
21
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt-ir",
3
- "version": "4.22.0",
3
+ "version": "4.23.2",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",