ccxt-look 1.81.50
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/.cache/eslintcache +1 -0
- package/.dockerignore +6 -0
- package/.eslintignore +1 -0
- package/.gitattributes +5 -0
- package/.readthedocs.yaml +16 -0
- package/CONTRIBUTING.md +1049 -0
- package/LICENSE.txt +21 -0
- package/README.md +537 -0
- package/SECURITY.md +5 -0
- package/build/cleanup-old-tags.js +94 -0
- package/build/countries.js +256 -0
- package/build/export-exchanges.js +520 -0
- package/build/fs.js +51 -0
- package/build/transpile.js +1772 -0
- package/build/vss.js +78 -0
- package/ccxt.browser.js +7 -0
- package/ccxt.d.ts +692 -0
- package/ccxt.js +171 -0
- package/cleanup.sh +2 -0
- package/composer-install.sh +20 -0
- package/dist/ccxt.browser.js +208383 -0
- package/gource.sh +3 -0
- package/index.html +7 -0
- package/js/.eslintrc +87 -0
- package/js/aax.js +2686 -0
- package/js/ascendex.js +2584 -0
- package/js/base/.eslintrc.js +43 -0
- package/js/base/Exchange.js +2371 -0
- package/js/base/Precise.js +283 -0
- package/js/base/errorHierarchy.js +47 -0
- package/js/base/errors.js +55 -0
- package/js/base/functions/crypto.js +158 -0
- package/js/base/functions/encode.js +118 -0
- package/js/base/functions/generic.js +270 -0
- package/js/base/functions/misc.js +138 -0
- package/js/base/functions/number.js +329 -0
- package/js/base/functions/platform.js +38 -0
- package/js/base/functions/string.js +21 -0
- package/js/base/functions/throttle.js +79 -0
- package/js/base/functions/time.js +210 -0
- package/js/base/functions/type.js +66 -0
- package/js/base/functions.js +28 -0
- package/js/bequant.js +32 -0
- package/js/bibox.js +1407 -0
- package/js/bigone.js +1366 -0
- package/js/binance.js +5652 -0
- package/js/binancecoinm.js +46 -0
- package/js/binanceus.js +46 -0
- package/js/binanceusdm.js +49 -0
- package/js/bit2c.js +535 -0
- package/js/bitbank.js +842 -0
- package/js/bitbay.js +16 -0
- package/js/bitbns.js +1073 -0
- package/js/bitcoincom.js +15 -0
- package/js/bitfinex.js +1433 -0
- package/js/bitfinex2.js +2025 -0
- package/js/bitflyer.js +840 -0
- package/js/bitforex.js +614 -0
- package/js/bitget.js +2397 -0
- package/js/bithumb.js +980 -0
- package/js/bitmart.js +2516 -0
- package/js/bitmex.js +1809 -0
- package/js/bitopro.js +1443 -0
- package/js/bitpanda.js +1782 -0
- package/js/bitrue.js +1747 -0
- package/js/bitso.js +1062 -0
- package/js/bitstamp.js +1757 -0
- package/js/bitstamp1.js +343 -0
- package/js/bittrex.js +1876 -0
- package/js/bitvavo.js +1579 -0
- package/js/bkex.js +1233 -0
- package/js/bl3p.js +346 -0
- package/js/blockchaincom.js +969 -0
- package/js/btcalpha.js +680 -0
- package/js/btcbox.js +477 -0
- package/js/btcmarkets.js +1022 -0
- package/js/btctradeua.js +466 -0
- package/js/btcturk.js +734 -0
- package/js/buda.js +946 -0
- package/js/bw.js +1265 -0
- package/js/bybit.js +3372 -0
- package/js/bytetrade.js +1336 -0
- package/js/cdax.js +1646 -0
- package/js/cex.js +1410 -0
- package/js/coinbase.js +1342 -0
- package/js/coinbaseprime.js +31 -0
- package/js/coinbasepro.js +1466 -0
- package/js/coincheck.js +755 -0
- package/js/coinex.js +3400 -0
- package/js/coinfalcon.js +880 -0
- package/js/coinmate.js +794 -0
- package/js/coinone.js +816 -0
- package/js/coinspot.js +345 -0
- package/js/crex24.js +1636 -0
- package/js/cryptocom.js +1832 -0
- package/js/currencycom.js +1748 -0
- package/js/delta.js +1547 -0
- package/js/deribit.js +2148 -0
- package/js/digifinex.js +1585 -0
- package/js/eqonex.js +1660 -0
- package/js/exmo.js +1670 -0
- package/js/fairdesk.js +1231 -0
- package/js/flowbtc.js +35 -0
- package/js/fmfwio.js +34 -0
- package/js/ftx.js +2751 -0
- package/js/ftxus.js +38 -0
- package/js/gateio.js +4174 -0
- package/js/gemini.js +1397 -0
- package/js/hitbtc.js +1343 -0
- package/js/hitbtc3.js +2329 -0
- package/js/hollaex.js +1486 -0
- package/js/huobi.js +5706 -0
- package/js/huobijp.js +1710 -0
- package/js/huobipro.js +18 -0
- package/js/idex.js +1439 -0
- package/js/independentreserve.js +649 -0
- package/js/indodax.js +742 -0
- package/js/itbit.js +722 -0
- package/js/kraken.js +2179 -0
- package/js/kucoin.js +2571 -0
- package/js/kucoinfutures.js +1771 -0
- package/js/kuna.js +809 -0
- package/js/latoken.js +1445 -0
- package/js/lbank.js +760 -0
- package/js/liquid.js +1432 -0
- package/js/luno.js +873 -0
- package/js/lykke.js +1147 -0
- package/js/mercado.js +771 -0
- package/js/mexc.js +3151 -0
- package/js/ndax.js +2233 -0
- package/js/novadax.js +1318 -0
- package/js/oceanex.js +816 -0
- package/js/okcoin.js +3841 -0
- package/js/okex.js +16 -0
- package/js/okex5.js +16 -0
- package/js/okx.js +4795 -0
- package/js/paymium.js +498 -0
- package/js/phemex.js +2957 -0
- package/js/poloniex.js +1674 -0
- package/js/probit.js +1346 -0
- package/js/qtrade.js +1588 -0
- package/js/ripio.js +1061 -0
- package/js/static_dependencies/BN/bn.js +3526 -0
- package/js/static_dependencies/README.md +1 -0
- package/js/static_dependencies/crypto-js/crypto-js.js +5988 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/base.js +375 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/edwards.js +433 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/index.js +8 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/mont.js +180 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/short.js +938 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curves.js +204 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/index.js +240 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/key.js +119 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/signature.js +24 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/index.js +145 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/key.js +100 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/signature.js +65 -0
- package/js/static_dependencies/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
- package/js/static_dependencies/elliptic/lib/elliptic/utils.js +214 -0
- package/js/static_dependencies/elliptic/lib/elliptic.js +22 -0
- package/js/static_dependencies/elliptic/lib/hmac-drbg/hmac-drbg.js +114 -0
- package/js/static_dependencies/fetch-ponyfill/fetch-node.js +39 -0
- package/js/static_dependencies/node-fetch/index.js +1564 -0
- package/js/static_dependencies/node-rsa/NodeRSA.js +223 -0
- package/js/static_dependencies/node-rsa/asn1/ber/errors.js +13 -0
- package/js/static_dependencies/node-rsa/asn1/ber/index.js +21 -0
- package/js/static_dependencies/node-rsa/asn1/ber/reader.js +262 -0
- package/js/static_dependencies/node-rsa/asn1/ber/types.js +36 -0
- package/js/static_dependencies/node-rsa/asn1/index.js +17 -0
- package/js/static_dependencies/node-rsa/encryptEngines/js.js +34 -0
- package/js/static_dependencies/node-rsa/formats/components.js +71 -0
- package/js/static_dependencies/node-rsa/formats/formats.js +31 -0
- package/js/static_dependencies/node-rsa/formats/pkcs1.js +148 -0
- package/js/static_dependencies/node-rsa/formats/pkcs8.js +187 -0
- package/js/static_dependencies/node-rsa/libs/jsbn.js +1252 -0
- package/js/static_dependencies/node-rsa/libs/rsa.js +147 -0
- package/js/static_dependencies/node-rsa/schemes/pkcs1.js +176 -0
- package/js/static_dependencies/node-rsa/schemes/schemes.js +21 -0
- package/js/static_dependencies/node-rsa/utils.js +98 -0
- package/js/static_dependencies/qs/formats.js +18 -0
- package/js/static_dependencies/qs/index.js +11 -0
- package/js/static_dependencies/qs/parse.js +242 -0
- package/js/static_dependencies/qs/stringify.js +269 -0
- package/js/static_dependencies/qs/utils.js +230 -0
- package/js/stex.js +1925 -0
- package/js/test/.eslintrc.js +42 -0
- package/js/test/Exchange/test.balance.js +61 -0
- package/js/test/Exchange/test.borrowRate.js +32 -0
- package/js/test/Exchange/test.currency.js +52 -0
- package/js/test/Exchange/test.fetchBalance.js +23 -0
- package/js/test/Exchange/test.fetchBorrowInterest.js +59 -0
- package/js/test/Exchange/test.fetchBorrowRate.js +32 -0
- package/js/test/Exchange/test.fetchBorrowRates.js +28 -0
- package/js/test/Exchange/test.fetchClosedOrders.js +32 -0
- package/js/test/Exchange/test.fetchCurrencies.js +35 -0
- package/js/test/Exchange/test.fetchDeposits.js +31 -0
- package/js/test/Exchange/test.fetchFundingFees.js +19 -0
- package/js/test/Exchange/test.fetchFundingRateHistory.js +40 -0
- package/js/test/Exchange/test.fetchL2OrderBook.js +23 -0
- package/js/test/Exchange/test.fetchLedger.js +42 -0
- package/js/test/Exchange/test.fetchLeverageTiers.js +33 -0
- package/js/test/Exchange/test.fetchMarketLeverageTiers.js +22 -0
- package/js/test/Exchange/test.fetchMarkets.js +33 -0
- package/js/test/Exchange/test.fetchMyTrades.js +42 -0
- package/js/test/Exchange/test.fetchOHLCV.js +46 -0
- package/js/test/Exchange/test.fetchOpenOrders.js +36 -0
- package/js/test/Exchange/test.fetchOrderBook.js +25 -0
- package/js/test/Exchange/test.fetchOrderBooks.js +35 -0
- package/js/test/Exchange/test.fetchOrders.js +41 -0
- package/js/test/Exchange/test.fetchPositions.js +47 -0
- package/js/test/Exchange/test.fetchStatus.js +35 -0
- package/js/test/Exchange/test.fetchTicker.js +38 -0
- package/js/test/Exchange/test.fetchTickers.js +49 -0
- package/js/test/Exchange/test.fetchTrades.js +39 -0
- package/js/test/Exchange/test.fetchTradingFee.js +18 -0
- package/js/test/Exchange/test.fetchTradingFees.js +22 -0
- package/js/test/Exchange/test.fetchTransactions.js +31 -0
- package/js/test/Exchange/test.fetchWithdrawals.js +31 -0
- package/js/test/Exchange/test.ledgerItem.js +46 -0
- package/js/test/Exchange/test.leverageTier.js +33 -0
- package/js/test/Exchange/test.loadMarkets.js +35 -0
- package/js/test/Exchange/test.market.js +129 -0
- package/js/test/Exchange/test.ohlcv.js +33 -0
- package/js/test/Exchange/test.order.js +62 -0
- package/js/test/Exchange/test.orderbook.js +61 -0
- package/js/test/Exchange/test.position.js +21 -0
- package/js/test/Exchange/test.throttle.js +94 -0
- package/js/test/Exchange/test.ticker.js +95 -0
- package/js/test/Exchange/test.trade.js +68 -0
- package/js/test/Exchange/test.tradingFee.js +34 -0
- package/js/test/Exchange/test.transaction.js +35 -0
- package/js/test/base/.eslintrc +38 -0
- package/js/test/base/functions/test.crypto.js +110 -0
- package/js/test/base/functions/test.datetime.js +62 -0
- package/js/test/base/functions/test.generic.js +152 -0
- package/js/test/base/functions/test.number.js +362 -0
- package/js/test/base/functions/test.time.js +56 -0
- package/js/test/base/functions/test.type.js +53 -0
- package/js/test/base/test.base.js +193 -0
- package/js/test/errors/test.InsufficientFunds.js +86 -0
- package/js/test/errors/test.InvalidNonce.js +64 -0
- package/js/test/errors/test.InvalidOrder.js +35 -0
- package/js/test/errors/test.OrderNotFound.js +39 -0
- package/js/test/test.js +426 -0
- package/js/test/test.timeout_hang.js +12 -0
- package/js/therock.js +1431 -0
- package/js/tidebit.js +632 -0
- package/js/tidex.js +939 -0
- package/js/timex.js +1283 -0
- package/js/upbit.js +1622 -0
- package/js/vcc.js +1353 -0
- package/js/wavesexchange.js +2185 -0
- package/js/wazirx.js +732 -0
- package/js/whitebit.js +1352 -0
- package/js/woo.js +1577 -0
- package/js/xena.js +1948 -0
- package/js/yobit.js +1129 -0
- package/js/zaif.js +647 -0
- package/js/zb.js +4088 -0
- package/js/zipmex.js +40 -0
- package/js/zonda.js +1497 -0
- package/multilang.sh +159 -0
- package/package.json +591 -0
- package/postinstall.js +103 -0
package/js/probit.js
ADDED
@@ -0,0 +1,1346 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ExchangeError, ExchangeNotAvailable, BadResponse, BadRequest, InvalidOrder, InsufficientFunds, AuthenticationError, ArgumentsRequired, InvalidAddress, RateLimitExceeded, DDoSProtection, BadSymbol } = require ('./base/errors');
|
7
|
+
const { TRUNCATE, TICK_SIZE } = require ('./base/functions/number');
|
8
|
+
const Precise = require ('./base/Precise');
|
9
|
+
|
10
|
+
// ---------------------------------------------------------------------------
|
11
|
+
|
12
|
+
module.exports = class probit extends Exchange {
|
13
|
+
describe () {
|
14
|
+
return this.deepExtend (super.describe (), {
|
15
|
+
'id': 'probit',
|
16
|
+
'name': 'ProBit',
|
17
|
+
'countries': [ 'SC', 'KR' ], // Seychelles, South Korea
|
18
|
+
'rateLimit': 50, // ms
|
19
|
+
'has': {
|
20
|
+
'CORS': true,
|
21
|
+
'spot': true,
|
22
|
+
'margin': false,
|
23
|
+
'swap': false,
|
24
|
+
'future': false,
|
25
|
+
'option': false,
|
26
|
+
'addMargin': false,
|
27
|
+
'cancelOrder': true,
|
28
|
+
'createMarketOrder': true,
|
29
|
+
'createOrder': true,
|
30
|
+
'createReduceOnlyOrder': false,
|
31
|
+
'fetchBalance': true,
|
32
|
+
'fetchBorrowRate': false,
|
33
|
+
'fetchBorrowRateHistories': false,
|
34
|
+
'fetchBorrowRateHistory': false,
|
35
|
+
'fetchBorrowRates': false,
|
36
|
+
'fetchBorrowRatesPerSymbol': false,
|
37
|
+
'fetchClosedOrders': true,
|
38
|
+
'fetchCurrencies': true,
|
39
|
+
'fetchDepositAddress': true,
|
40
|
+
'fetchDepositAddresses': true,
|
41
|
+
'fetchFundingHistory': false,
|
42
|
+
'fetchFundingRate': false,
|
43
|
+
'fetchFundingRateHistory': false,
|
44
|
+
'fetchFundingRates': false,
|
45
|
+
'fetchIndexOHLCV': false,
|
46
|
+
'fetchLeverage': false,
|
47
|
+
'fetchLeverageTiers': false,
|
48
|
+
'fetchMarkets': true,
|
49
|
+
'fetchMarkOHLCV': false,
|
50
|
+
'fetchMyTrades': true,
|
51
|
+
'fetchOHLCV': true,
|
52
|
+
'fetchOpenOrders': true,
|
53
|
+
'fetchOrder': true,
|
54
|
+
'fetchOrderBook': true,
|
55
|
+
'fetchPosition': false,
|
56
|
+
'fetchPositions': false,
|
57
|
+
'fetchPositionsRisk': false,
|
58
|
+
'fetchPremiumIndexOHLCV': false,
|
59
|
+
'fetchTicker': true,
|
60
|
+
'fetchTickers': true,
|
61
|
+
'fetchTime': true,
|
62
|
+
'fetchTrades': true,
|
63
|
+
'fetchTradingFee': false,
|
64
|
+
'fetchTradingFees': false,
|
65
|
+
'reduceMargin': false,
|
66
|
+
'setLeverage': false,
|
67
|
+
'setMarginMode': false,
|
68
|
+
'setPositionMode': false,
|
69
|
+
'signIn': true,
|
70
|
+
'withdraw': true,
|
71
|
+
},
|
72
|
+
'timeframes': {
|
73
|
+
'1m': '1m',
|
74
|
+
'3m': '3m',
|
75
|
+
'5m': '5m',
|
76
|
+
'10m': '10m',
|
77
|
+
'15m': '15m',
|
78
|
+
'30m': '30m',
|
79
|
+
'1h': '1h',
|
80
|
+
'4h': '4h',
|
81
|
+
'6h': '6h',
|
82
|
+
'12h': '12h',
|
83
|
+
'1d': '1D',
|
84
|
+
'1w': '1W',
|
85
|
+
'1M': '1M',
|
86
|
+
},
|
87
|
+
'version': 'v1',
|
88
|
+
'urls': {
|
89
|
+
'logo': 'https://user-images.githubusercontent.com/51840849/79268032-c4379480-7ea2-11ea-80b3-dd96bb29fd0d.jpg',
|
90
|
+
'api': {
|
91
|
+
'accounts': 'https://accounts.probit.com',
|
92
|
+
'public': 'https://api.probit.com/api/exchange',
|
93
|
+
'private': 'https://api.probit.com/api/exchange',
|
94
|
+
},
|
95
|
+
'www': 'https://www.probit.com',
|
96
|
+
'doc': [
|
97
|
+
'https://docs-en.probit.com',
|
98
|
+
'https://docs-ko.probit.com',
|
99
|
+
],
|
100
|
+
'fees': 'https://support.probit.com/hc/en-us/articles/360020968611-Trading-Fees',
|
101
|
+
'referral': 'https://www.probit.com/r/34608773',
|
102
|
+
},
|
103
|
+
'api': {
|
104
|
+
'public': {
|
105
|
+
'get': {
|
106
|
+
'market': 1,
|
107
|
+
'currency': 1,
|
108
|
+
'currency_with_platform': 1,
|
109
|
+
'time': 1,
|
110
|
+
'ticker': 1,
|
111
|
+
'order_book': 1,
|
112
|
+
'trade': 1,
|
113
|
+
'candle': 1,
|
114
|
+
},
|
115
|
+
},
|
116
|
+
'private': {
|
117
|
+
'post': {
|
118
|
+
'new_order': 2,
|
119
|
+
'cancel_order': 1,
|
120
|
+
'withdrawal': 2,
|
121
|
+
},
|
122
|
+
'get': {
|
123
|
+
'balance': 1,
|
124
|
+
'order': 1,
|
125
|
+
'open_order': 1,
|
126
|
+
'order_history': 1,
|
127
|
+
'trade_history': 1,
|
128
|
+
'deposit_address': 1,
|
129
|
+
},
|
130
|
+
},
|
131
|
+
'accounts': {
|
132
|
+
'post': {
|
133
|
+
'token': 1,
|
134
|
+
},
|
135
|
+
},
|
136
|
+
},
|
137
|
+
'fees': {
|
138
|
+
'trading': {
|
139
|
+
'tierBased': false,
|
140
|
+
'percentage': true,
|
141
|
+
'maker': this.parseNumber ('0.002'),
|
142
|
+
'taker': this.parseNumber ('0.002'),
|
143
|
+
},
|
144
|
+
},
|
145
|
+
'exceptions': {
|
146
|
+
'exact': {
|
147
|
+
'UNAUTHORIZED': AuthenticationError,
|
148
|
+
'INVALID_ARGUMENT': BadRequest, // Parameters are not a valid format, parameters are empty, or out of range, or a parameter was sent when not required.
|
149
|
+
'TRADING_UNAVAILABLE': ExchangeNotAvailable,
|
150
|
+
'NOT_ENOUGH_BALANCE': InsufficientFunds,
|
151
|
+
'NOT_ALLOWED_COMBINATION': BadRequest,
|
152
|
+
'INVALID_ORDER': InvalidOrder, // Requested order does not exist, or it is not your order
|
153
|
+
'RATE_LIMIT_EXCEEDED': RateLimitExceeded, // You are sending requests too frequently. Please try it later.
|
154
|
+
'MARKET_UNAVAILABLE': ExchangeNotAvailable, // Market is closed today
|
155
|
+
'INVALID_MARKET': BadSymbol, // Requested market is not exist
|
156
|
+
'MARKET_CLOSED': BadSymbol, // {"errorCode":"MARKET_CLOSED"}
|
157
|
+
'MARKET_NOT_FOUND': BadSymbol, // {"errorCode":"MARKET_NOT_FOUND","message":"8e2b8496-0a1e-5beb-b990-a205b902eabe","details":{}}
|
158
|
+
'INVALID_CURRENCY': BadRequest, // Requested currency is not exist on ProBit system
|
159
|
+
'TOO_MANY_OPEN_ORDERS': DDoSProtection, // Too many open orders
|
160
|
+
'DUPLICATE_ADDRESS': InvalidAddress, // Address already exists in withdrawal address list
|
161
|
+
'invalid_grant': AuthenticationError, // {"error":"invalid_grant"}
|
162
|
+
},
|
163
|
+
},
|
164
|
+
'requiredCredentials': {
|
165
|
+
'apiKey': true,
|
166
|
+
'secret': true,
|
167
|
+
},
|
168
|
+
'precisionMode': TICK_SIZE,
|
169
|
+
'options': {
|
170
|
+
'createMarketBuyOrderRequiresPrice': true,
|
171
|
+
'timeInForce': {
|
172
|
+
'limit': 'gtc',
|
173
|
+
'market': 'ioc',
|
174
|
+
},
|
175
|
+
'networks': {
|
176
|
+
'BEP20': 'BSC',
|
177
|
+
'ERC20': 'ETH',
|
178
|
+
'TRC20': 'TRON',
|
179
|
+
'TRX': 'TRON',
|
180
|
+
},
|
181
|
+
},
|
182
|
+
'commonCurrencies': {
|
183
|
+
'AUTO': 'Cube',
|
184
|
+
'AZU': 'Azultec',
|
185
|
+
'BCC': 'BCC',
|
186
|
+
'BDP': 'BidiPass',
|
187
|
+
'BIRD': 'Birdchain',
|
188
|
+
'BTCBEAR': 'BEAR',
|
189
|
+
'BTCBULL': 'BULL',
|
190
|
+
'CBC': 'CryptoBharatCoin',
|
191
|
+
'CHE': 'Chellit',
|
192
|
+
'CLR': 'Color Platform',
|
193
|
+
'CTK': 'Cryptyk',
|
194
|
+
'CTT': 'Castweet',
|
195
|
+
'DIP': 'Dipper',
|
196
|
+
'DKT': 'DAKOTA',
|
197
|
+
'EGC': 'EcoG9coin',
|
198
|
+
'EPS': 'Epanus', // conflict with EPS Ellipsis https://github.com/ccxt/ccxt/issues/8909
|
199
|
+
'FX': 'Fanzy',
|
200
|
+
'GDT': 'Gorilla Diamond',
|
201
|
+
'GM': 'GM Holding',
|
202
|
+
'GOGOL': 'GOL',
|
203
|
+
'GOL': 'Goldofir',
|
204
|
+
'GRB': 'Global Reward Bank',
|
205
|
+
'HBC': 'Hybrid Bank Cash',
|
206
|
+
'HUSL': 'The Hustle App',
|
207
|
+
'LAND': 'Landbox',
|
208
|
+
'LBK': 'Legal Block',
|
209
|
+
'ORC': 'Oracle System',
|
210
|
+
'PXP': 'PIXSHOP COIN',
|
211
|
+
'PYE': 'CreamPYE',
|
212
|
+
'ROOK': 'Reckoon',
|
213
|
+
'SOC': 'Soda Coin',
|
214
|
+
'SST': 'SocialSwap',
|
215
|
+
'TCT': 'Top Coin Token',
|
216
|
+
'TOR': 'Torex',
|
217
|
+
'TPAY': 'Tetra Pay',
|
218
|
+
'UNI': 'UNICORN Token',
|
219
|
+
'UNISWAP': 'UNI',
|
220
|
+
},
|
221
|
+
});
|
222
|
+
}
|
223
|
+
|
224
|
+
async fetchMarkets (params = {}) {
|
225
|
+
const response = await this.publicGetMarket (params);
|
226
|
+
//
|
227
|
+
// {
|
228
|
+
// "data":[
|
229
|
+
// {
|
230
|
+
// "id":"MONA-USDT",
|
231
|
+
// "base_currency_id":"MONA",
|
232
|
+
// "quote_currency_id":"USDT",
|
233
|
+
// "min_price":"0.001",
|
234
|
+
// "max_price":"9999999999999999",
|
235
|
+
// "price_increment":"0.001",
|
236
|
+
// "min_quantity":"0.0001",
|
237
|
+
// "max_quantity":"9999999999999999",
|
238
|
+
// "quantity_precision":4,
|
239
|
+
// "min_cost":"1",
|
240
|
+
// "max_cost":"9999999999999999",
|
241
|
+
// "cost_precision":8,
|
242
|
+
// "taker_fee_rate":"0.2",
|
243
|
+
// "maker_fee_rate":"0.2",
|
244
|
+
// "show_in_ui":true,
|
245
|
+
// "closed":false
|
246
|
+
// },
|
247
|
+
// ]
|
248
|
+
// }
|
249
|
+
//
|
250
|
+
const markets = this.safeValue (response, 'data', []);
|
251
|
+
const result = [];
|
252
|
+
for (let i = 0; i < markets.length; i++) {
|
253
|
+
const market = markets[i];
|
254
|
+
const id = this.safeString (market, 'id');
|
255
|
+
const baseId = this.safeString (market, 'base_currency_id');
|
256
|
+
const quoteId = this.safeString (market, 'quote_currency_id');
|
257
|
+
const base = this.safeCurrencyCode (baseId);
|
258
|
+
const quote = this.safeCurrencyCode (quoteId);
|
259
|
+
const closed = this.safeValue (market, 'closed', false);
|
260
|
+
const amountPrecision = this.safeString (market, 'quantity_precision');
|
261
|
+
const costPrecision = this.safeString (market, 'cost_precision');
|
262
|
+
const amountTickSize = this.parsePrecision (amountPrecision);
|
263
|
+
const costTickSize = this.parsePrecision (costPrecision);
|
264
|
+
const takerFeeRate = this.safeString (market, 'taker_fee_rate');
|
265
|
+
const taker = Precise.stringDiv (takerFeeRate, '100');
|
266
|
+
const makerFeeRate = this.safeString (market, 'maker_fee_rate');
|
267
|
+
const maker = Precise.stringDiv (makerFeeRate, '100');
|
268
|
+
result.push ({
|
269
|
+
'id': id,
|
270
|
+
'symbol': base + '/' + quote,
|
271
|
+
'base': base,
|
272
|
+
'quote': quote,
|
273
|
+
'settle': undefined,
|
274
|
+
'baseId': baseId,
|
275
|
+
'quoteId': quoteId,
|
276
|
+
'settleId': undefined,
|
277
|
+
'type': 'spot',
|
278
|
+
'spot': true,
|
279
|
+
'margin': false,
|
280
|
+
'swap': false,
|
281
|
+
'future': false,
|
282
|
+
'option': false,
|
283
|
+
'active': !closed,
|
284
|
+
'contract': false,
|
285
|
+
'linear': undefined,
|
286
|
+
'inverse': undefined,
|
287
|
+
'taker': this.parseNumber (taker),
|
288
|
+
'maker': this.parseNumber (maker),
|
289
|
+
'contractSize': undefined,
|
290
|
+
'expiry': undefined,
|
291
|
+
'expiryDatetime': undefined,
|
292
|
+
'strike': undefined,
|
293
|
+
'optionType': undefined,
|
294
|
+
'precision': {
|
295
|
+
'amount': this.parseNumber (amountTickSize),
|
296
|
+
'price': this.safeNumber (market, 'price_increment'),
|
297
|
+
'cost': this.parseNumber (costTickSize),
|
298
|
+
},
|
299
|
+
'limits': {
|
300
|
+
'leverage': {
|
301
|
+
'min': undefined,
|
302
|
+
'max': undefined,
|
303
|
+
},
|
304
|
+
'amount': {
|
305
|
+
'min': this.safeNumber (market, 'min_quantity'),
|
306
|
+
'max': this.safeNumber (market, 'max_quantity'),
|
307
|
+
},
|
308
|
+
'price': {
|
309
|
+
'min': this.safeNumber (market, 'min_price'),
|
310
|
+
'max': this.safeNumber (market, 'max_price'),
|
311
|
+
},
|
312
|
+
'cost': {
|
313
|
+
'min': this.safeNumber (market, 'min_cost'),
|
314
|
+
'max': this.safeNumber (market, 'max_cost'),
|
315
|
+
},
|
316
|
+
},
|
317
|
+
'info': market,
|
318
|
+
});
|
319
|
+
}
|
320
|
+
return result;
|
321
|
+
}
|
322
|
+
|
323
|
+
async fetchCurrencies (params = {}) {
|
324
|
+
const response = await this.publicGetCurrencyWithPlatform (params);
|
325
|
+
//
|
326
|
+
// {
|
327
|
+
// "data":[
|
328
|
+
// {
|
329
|
+
// "id":"USDT",
|
330
|
+
// "display_name":{"ko-kr":"테더","en-us":"Tether"},
|
331
|
+
// "show_in_ui":true,
|
332
|
+
// "platform":[
|
333
|
+
// {
|
334
|
+
// "id":"ETH",
|
335
|
+
// "priority":1,
|
336
|
+
// "deposit":true,
|
337
|
+
// "withdrawal":true,
|
338
|
+
// "currency_id":"USDT",
|
339
|
+
// "precision":6,
|
340
|
+
// "min_confirmation_count":15,
|
341
|
+
// "require_destination_tag":false,
|
342
|
+
// "display_name":{"name":{"ko-kr":"ERC-20","en-us":"ERC-20"}},
|
343
|
+
// "min_deposit_amount":"0",
|
344
|
+
// "min_withdrawal_amount":"1",
|
345
|
+
// "withdrawal_fee":[
|
346
|
+
// {"amount":"0.01","priority":2,"currency_id":"ETH"},
|
347
|
+
// {"amount":"1.5","priority":1,"currency_id":"USDT"},
|
348
|
+
// ],
|
349
|
+
// "deposit_fee":{},
|
350
|
+
// "suspended_reason":"",
|
351
|
+
// "deposit_suspended":false,
|
352
|
+
// "withdrawal_suspended":false
|
353
|
+
// },
|
354
|
+
// {
|
355
|
+
// "id":"OMNI",
|
356
|
+
// "priority":2,
|
357
|
+
// "deposit":true,
|
358
|
+
// "withdrawal":true,
|
359
|
+
// "currency_id":"USDT",
|
360
|
+
// "precision":6,
|
361
|
+
// "min_confirmation_count":3,
|
362
|
+
// "require_destination_tag":false,
|
363
|
+
// "display_name":{"name":{"ko-kr":"OMNI","en-us":"OMNI"}},
|
364
|
+
// "min_deposit_amount":"0",
|
365
|
+
// "min_withdrawal_amount":"5",
|
366
|
+
// "withdrawal_fee":[{"amount":"5","priority":1,"currency_id":"USDT"}],
|
367
|
+
// "deposit_fee":{},
|
368
|
+
// "suspended_reason":"wallet_maintenance",
|
369
|
+
// "deposit_suspended":false,
|
370
|
+
// "withdrawal_suspended":false
|
371
|
+
// }
|
372
|
+
// ],
|
373
|
+
// "stakeable":false,
|
374
|
+
// "unstakeable":false,
|
375
|
+
// "auto_stake":false,
|
376
|
+
// "auto_stake_amount":"0"
|
377
|
+
// }
|
378
|
+
// ]
|
379
|
+
// }
|
380
|
+
//
|
381
|
+
const currencies = this.safeValue (response, 'data');
|
382
|
+
const result = {};
|
383
|
+
for (let i = 0; i < currencies.length; i++) {
|
384
|
+
const currency = currencies[i];
|
385
|
+
const id = this.safeString (currency, 'id');
|
386
|
+
const code = this.safeCurrencyCode (id);
|
387
|
+
const displayName = this.safeValue (currency, 'display_name');
|
388
|
+
const name = this.safeString (displayName, 'en-us');
|
389
|
+
const platforms = this.safeValue (currency, 'platform', []);
|
390
|
+
const platformsByPriority = this.sortBy (platforms, 'priority');
|
391
|
+
const platform = this.safeValue (platformsByPriority, 0, {});
|
392
|
+
const precision = this.safeInteger (platform, 'precision');
|
393
|
+
const depositSuspended = this.safeValue (platform, 'deposit_suspended');
|
394
|
+
const withdrawalSuspended = this.safeValue (platform, 'withdrawal_suspended');
|
395
|
+
const deposit = !depositSuspended;
|
396
|
+
const withdraw = !withdrawalSuspended;
|
397
|
+
const active = deposit && withdraw;
|
398
|
+
const withdrawalFees = this.safeValue (platform, 'withdrawal_fee', {});
|
399
|
+
const fees = [];
|
400
|
+
// sometimes the withdrawal fee is an empty object
|
401
|
+
// [ { 'amount': '0.015', 'priority': 1, 'currency_id': 'ETH' }, {} ]
|
402
|
+
for (let j = 0; j < withdrawalFees.length; j++) {
|
403
|
+
const withdrawalFee = withdrawalFees[j];
|
404
|
+
const amount = this.safeNumber (withdrawalFee, 'amount');
|
405
|
+
const priority = this.safeInteger (withdrawalFee, 'priority');
|
406
|
+
if ((amount !== undefined) && (priority !== undefined)) {
|
407
|
+
fees.push (withdrawalFee);
|
408
|
+
}
|
409
|
+
}
|
410
|
+
const withdrawalFeesByPriority = this.sortBy (fees, 'priority');
|
411
|
+
const withdrawalFee = this.safeValue (withdrawalFeesByPriority, 0, {});
|
412
|
+
const fee = this.safeNumber (withdrawalFee, 'amount');
|
413
|
+
result[code] = {
|
414
|
+
'id': id,
|
415
|
+
'code': code,
|
416
|
+
'info': currency,
|
417
|
+
'name': name,
|
418
|
+
'active': active,
|
419
|
+
'deposit': deposit,
|
420
|
+
'withdraw': withdraw,
|
421
|
+
'fee': fee,
|
422
|
+
'precision': precision,
|
423
|
+
'limits': {
|
424
|
+
'amount': {
|
425
|
+
'min': undefined,
|
426
|
+
'max': undefined,
|
427
|
+
},
|
428
|
+
'deposit': {
|
429
|
+
'min': this.safeNumber (platform, 'min_deposit_amount'),
|
430
|
+
'max': undefined,
|
431
|
+
},
|
432
|
+
'withdraw': {
|
433
|
+
'min': this.safeNumber (platform, 'min_withdrawal_amount'),
|
434
|
+
'max': undefined,
|
435
|
+
},
|
436
|
+
},
|
437
|
+
};
|
438
|
+
}
|
439
|
+
return result;
|
440
|
+
}
|
441
|
+
|
442
|
+
parseBalance (response) {
|
443
|
+
const result = {
|
444
|
+
'info': response,
|
445
|
+
'timestamp': undefined,
|
446
|
+
'datetime': undefined,
|
447
|
+
};
|
448
|
+
const data = this.safeValue (response, 'data');
|
449
|
+
for (let i = 0; i < data.length; i++) {
|
450
|
+
const balance = data[i];
|
451
|
+
const currencyId = this.safeString (balance, 'currency_id');
|
452
|
+
const code = this.safeCurrencyCode (currencyId);
|
453
|
+
const account = this.account ();
|
454
|
+
account['total'] = this.safeString (balance, 'total');
|
455
|
+
account['free'] = this.safeString (balance, 'available');
|
456
|
+
result[code] = account;
|
457
|
+
}
|
458
|
+
return this.safeBalance (result);
|
459
|
+
}
|
460
|
+
|
461
|
+
async fetchBalance (params = {}) {
|
462
|
+
await this.loadMarkets ();
|
463
|
+
const response = await this.privateGetBalance (params);
|
464
|
+
//
|
465
|
+
// {
|
466
|
+
// data: [
|
467
|
+
// {
|
468
|
+
// "currency_id":"XRP",
|
469
|
+
// "total":"100",
|
470
|
+
// "available":"0",
|
471
|
+
// }
|
472
|
+
// ]
|
473
|
+
// }
|
474
|
+
//
|
475
|
+
return this.parseBalance (response);
|
476
|
+
}
|
477
|
+
|
478
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
479
|
+
await this.loadMarkets ();
|
480
|
+
const market = this.market (symbol);
|
481
|
+
const request = {
|
482
|
+
'market_id': market['id'],
|
483
|
+
};
|
484
|
+
const response = await this.publicGetOrderBook (this.extend (request, params));
|
485
|
+
//
|
486
|
+
// {
|
487
|
+
// data: [
|
488
|
+
// { side: 'buy', price: '0.000031', quantity: '10' },
|
489
|
+
// { side: 'buy', price: '0.00356007', quantity: '4.92156877' },
|
490
|
+
// { side: 'sell', price: '0.1857', quantity: '0.17' },
|
491
|
+
// ]
|
492
|
+
// }
|
493
|
+
//
|
494
|
+
const data = this.safeValue (response, 'data', []);
|
495
|
+
const dataBySide = this.groupBy (data, 'side');
|
496
|
+
return this.parseOrderBook (dataBySide, symbol, undefined, 'buy', 'sell', 'price', 'quantity');
|
497
|
+
}
|
498
|
+
|
499
|
+
async fetchTickers (symbols = undefined, params = {}) {
|
500
|
+
await this.loadMarkets ();
|
501
|
+
const request = {};
|
502
|
+
if (symbols !== undefined) {
|
503
|
+
const marketIds = this.marketIds (symbols);
|
504
|
+
request['market_ids'] = marketIds.join (',');
|
505
|
+
}
|
506
|
+
const response = await this.publicGetTicker (this.extend (request, params));
|
507
|
+
//
|
508
|
+
// {
|
509
|
+
// "data":[
|
510
|
+
// {
|
511
|
+
// "last":"0.022902",
|
512
|
+
// "low":"0.021693",
|
513
|
+
// "high":"0.024093",
|
514
|
+
// "change":"-0.000047",
|
515
|
+
// "base_volume":"15681.986",
|
516
|
+
// "quote_volume":"360.514403624",
|
517
|
+
// "market_id":"ETH-BTC",
|
518
|
+
// "time":"2020-04-12T18:43:38.000Z"
|
519
|
+
// }
|
520
|
+
// ]
|
521
|
+
// }
|
522
|
+
//
|
523
|
+
const data = this.safeValue (response, 'data', []);
|
524
|
+
return this.parseTickers (data, symbols);
|
525
|
+
}
|
526
|
+
|
527
|
+
async fetchTicker (symbol, params = {}) {
|
528
|
+
await this.loadMarkets ();
|
529
|
+
const market = this.market (symbol);
|
530
|
+
const request = {
|
531
|
+
'market_ids': market['id'],
|
532
|
+
};
|
533
|
+
const response = await this.publicGetTicker (this.extend (request, params));
|
534
|
+
//
|
535
|
+
// {
|
536
|
+
// "data":[
|
537
|
+
// {
|
538
|
+
// "last":"0.022902",
|
539
|
+
// "low":"0.021693",
|
540
|
+
// "high":"0.024093",
|
541
|
+
// "change":"-0.000047",
|
542
|
+
// "base_volume":"15681.986",
|
543
|
+
// "quote_volume":"360.514403624",
|
544
|
+
// "market_id":"ETH-BTC",
|
545
|
+
// "time":"2020-04-12T18:43:38.000Z"
|
546
|
+
// }
|
547
|
+
// ]
|
548
|
+
// }
|
549
|
+
//
|
550
|
+
const data = this.safeValue (response, 'data', []);
|
551
|
+
const ticker = this.safeValue (data, 0);
|
552
|
+
if (ticker === undefined) {
|
553
|
+
throw new BadResponse (this.id + ' fetchTicker() returned an empty response');
|
554
|
+
}
|
555
|
+
return this.parseTicker (ticker, market);
|
556
|
+
}
|
557
|
+
|
558
|
+
parseTicker (ticker, market = undefined) {
|
559
|
+
//
|
560
|
+
// {
|
561
|
+
// "last":"0.022902",
|
562
|
+
// "low":"0.021693",
|
563
|
+
// "high":"0.024093",
|
564
|
+
// "change":"-0.000047",
|
565
|
+
// "base_volume":"15681.986",
|
566
|
+
// "quote_volume":"360.514403624",
|
567
|
+
// "market_id":"ETH-BTC",
|
568
|
+
// "time":"2020-04-12T18:43:38.000Z"
|
569
|
+
// }
|
570
|
+
//
|
571
|
+
const timestamp = this.parse8601 (this.safeString (ticker, 'time'));
|
572
|
+
const marketId = this.safeString (ticker, 'market_id');
|
573
|
+
const symbol = this.safeSymbol (marketId, market, '-');
|
574
|
+
const close = this.safeString (ticker, 'last');
|
575
|
+
const change = this.safeString (ticker, 'change');
|
576
|
+
const baseVolume = this.safeString (ticker, 'base_volume');
|
577
|
+
const quoteVolume = this.safeString (ticker, 'quote_volume');
|
578
|
+
return this.safeTicker ({
|
579
|
+
'symbol': symbol,
|
580
|
+
'timestamp': timestamp,
|
581
|
+
'datetime': this.iso8601 (timestamp),
|
582
|
+
'high': this.safeString (ticker, 'high'),
|
583
|
+
'low': this.safeString (ticker, 'low'),
|
584
|
+
'bid': undefined,
|
585
|
+
'bidVolume': undefined,
|
586
|
+
'ask': undefined,
|
587
|
+
'askVolume': undefined,
|
588
|
+
'vwap': undefined,
|
589
|
+
'open': undefined,
|
590
|
+
'close': close,
|
591
|
+
'last': close,
|
592
|
+
'previousClose': undefined, // previous day close
|
593
|
+
'change': change,
|
594
|
+
'percentage': undefined,
|
595
|
+
'average': undefined,
|
596
|
+
'baseVolume': baseVolume,
|
597
|
+
'quoteVolume': quoteVolume,
|
598
|
+
'info': ticker,
|
599
|
+
}, market, false);
|
600
|
+
}
|
601
|
+
|
602
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
603
|
+
await this.loadMarkets ();
|
604
|
+
let market = undefined;
|
605
|
+
const request = {
|
606
|
+
'limit': 100,
|
607
|
+
'start_time': this.iso8601 (0),
|
608
|
+
'end_time': this.iso8601 (this.milliseconds ()),
|
609
|
+
};
|
610
|
+
if (symbol !== undefined) {
|
611
|
+
market = this.market (symbol);
|
612
|
+
request['market_id'] = market['id'];
|
613
|
+
}
|
614
|
+
if (since !== undefined) {
|
615
|
+
request['start_time'] = this.iso8601 (since);
|
616
|
+
}
|
617
|
+
if (limit !== undefined) {
|
618
|
+
request['limit'] = limit;
|
619
|
+
}
|
620
|
+
const response = await this.privateGetTradeHistory (this.extend (request, params));
|
621
|
+
//
|
622
|
+
// {
|
623
|
+
// data: [
|
624
|
+
// {
|
625
|
+
// "id":"BTC-USDT:183566",
|
626
|
+
// "order_id":"17209376",
|
627
|
+
// "side":"sell",
|
628
|
+
// "fee_amount":"0.657396569175",
|
629
|
+
// "fee_currency_id":"USDT",
|
630
|
+
// "status":"settled",
|
631
|
+
// "price":"6573.96569175",
|
632
|
+
// "quantity":"0.1",
|
633
|
+
// "cost":"657.396569175",
|
634
|
+
// "time":"2018-08-10T06:06:46.000Z",
|
635
|
+
// "market_id":"BTC-USDT"
|
636
|
+
// }
|
637
|
+
// ]
|
638
|
+
// }
|
639
|
+
//
|
640
|
+
const data = this.safeValue (response, 'data', []);
|
641
|
+
return this.parseTrades (data, market, since, limit);
|
642
|
+
}
|
643
|
+
|
644
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
645
|
+
await this.loadMarkets ();
|
646
|
+
const market = this.market (symbol);
|
647
|
+
const request = {
|
648
|
+
'market_id': market['id'],
|
649
|
+
'limit': 100,
|
650
|
+
'start_time': '1970-01-01T00:00:00.000Z',
|
651
|
+
'end_time': this.iso8601 (this.milliseconds ()),
|
652
|
+
};
|
653
|
+
if (since !== undefined) {
|
654
|
+
request['start_time'] = this.iso8601 (since);
|
655
|
+
}
|
656
|
+
if (limit !== undefined) {
|
657
|
+
request['limit'] = limit;
|
658
|
+
}
|
659
|
+
const response = await this.publicGetTrade (this.extend (request, params));
|
660
|
+
//
|
661
|
+
// {
|
662
|
+
// "data":[
|
663
|
+
// {
|
664
|
+
// "id":"ETH-BTC:3331886",
|
665
|
+
// "price":"0.022981",
|
666
|
+
// "quantity":"12.337",
|
667
|
+
// "time":"2020-04-12T20:55:42.371Z",
|
668
|
+
// "side":"sell",
|
669
|
+
// "tick_direction":"down"
|
670
|
+
// },
|
671
|
+
// {
|
672
|
+
// "id":"ETH-BTC:3331885",
|
673
|
+
// "price":"0.022982",
|
674
|
+
// "quantity":"6.472",
|
675
|
+
// "time":"2020-04-12T20:55:39.652Z",
|
676
|
+
// "side":"sell",
|
677
|
+
// "tick_direction":"down"
|
678
|
+
// }
|
679
|
+
// ]
|
680
|
+
// }
|
681
|
+
//
|
682
|
+
const data = this.safeValue (response, 'data', []);
|
683
|
+
return this.parseTrades (data, market, since, limit);
|
684
|
+
}
|
685
|
+
|
686
|
+
parseTrade (trade, market = undefined) {
|
687
|
+
//
|
688
|
+
// fetchTrades (public)
|
689
|
+
//
|
690
|
+
// {
|
691
|
+
// "id":"ETH-BTC:3331886",
|
692
|
+
// "price":"0.022981",
|
693
|
+
// "quantity":"12.337",
|
694
|
+
// "time":"2020-04-12T20:55:42.371Z",
|
695
|
+
// "side":"sell",
|
696
|
+
// "tick_direction":"down"
|
697
|
+
// }
|
698
|
+
//
|
699
|
+
// fetchMyTrades (private)
|
700
|
+
//
|
701
|
+
// {
|
702
|
+
// "id":"BTC-USDT:183566",
|
703
|
+
// "order_id":"17209376",
|
704
|
+
// "side":"sell",
|
705
|
+
// "fee_amount":"0.657396569175",
|
706
|
+
// "fee_currency_id":"USDT",
|
707
|
+
// "status":"settled",
|
708
|
+
// "price":"6573.96569175",
|
709
|
+
// "quantity":"0.1",
|
710
|
+
// "cost":"657.396569175",
|
711
|
+
// "time":"2018-08-10T06:06:46.000Z",
|
712
|
+
// "market_id":"BTC-USDT"
|
713
|
+
// }
|
714
|
+
//
|
715
|
+
const timestamp = this.parse8601 (this.safeString (trade, 'time'));
|
716
|
+
const id = this.safeString (trade, 'id');
|
717
|
+
let marketId = undefined;
|
718
|
+
if (id !== undefined) {
|
719
|
+
const parts = id.split (':');
|
720
|
+
marketId = this.safeString (parts, 0);
|
721
|
+
}
|
722
|
+
marketId = this.safeString (trade, 'market_id', marketId);
|
723
|
+
const symbol = this.safeSymbol (marketId, market, '-');
|
724
|
+
const side = this.safeString (trade, 'side');
|
725
|
+
const priceString = this.safeString (trade, 'price');
|
726
|
+
const amountString = this.safeString (trade, 'quantity');
|
727
|
+
const orderId = this.safeString (trade, 'order_id');
|
728
|
+
const feeCostString = this.safeString (trade, 'fee_amount');
|
729
|
+
let fee = undefined;
|
730
|
+
if (feeCostString !== undefined) {
|
731
|
+
const feeCurrencyId = this.safeString (trade, 'fee_currency_id');
|
732
|
+
const feeCurrencyCode = this.safeCurrencyCode (feeCurrencyId);
|
733
|
+
fee = {
|
734
|
+
'cost': feeCostString,
|
735
|
+
'currency': feeCurrencyCode,
|
736
|
+
};
|
737
|
+
}
|
738
|
+
return this.safeTrade ({
|
739
|
+
'id': id,
|
740
|
+
'info': trade,
|
741
|
+
'timestamp': timestamp,
|
742
|
+
'datetime': this.iso8601 (timestamp),
|
743
|
+
'symbol': symbol,
|
744
|
+
'order': orderId,
|
745
|
+
'type': undefined,
|
746
|
+
'side': side,
|
747
|
+
'takerOrMaker': undefined,
|
748
|
+
'price': priceString,
|
749
|
+
'amount': amountString,
|
750
|
+
'cost': undefined,
|
751
|
+
'fee': fee,
|
752
|
+
}, market);
|
753
|
+
}
|
754
|
+
|
755
|
+
async fetchTime (params = {}) {
|
756
|
+
const response = await this.publicGetTime (params);
|
757
|
+
//
|
758
|
+
// { "data":"2020-04-12T18:54:25.390Z" }
|
759
|
+
//
|
760
|
+
const timestamp = this.parse8601 (this.safeString (response, 'data'));
|
761
|
+
return timestamp;
|
762
|
+
}
|
763
|
+
|
764
|
+
normalizeOHLCVTimestamp (timestamp, timeframe, after = false) {
|
765
|
+
const duration = this.parseTimeframe (timeframe);
|
766
|
+
if (timeframe === '1M') {
|
767
|
+
const iso8601 = this.iso8601 (timestamp);
|
768
|
+
const parts = iso8601.split ('-');
|
769
|
+
const year = this.safeString (parts, 0);
|
770
|
+
let month = this.safeInteger (parts, 1);
|
771
|
+
if (after) {
|
772
|
+
month = this.sum (month, 1);
|
773
|
+
}
|
774
|
+
if (month < 10) {
|
775
|
+
month = '0' + month.toString ();
|
776
|
+
} else {
|
777
|
+
month = month.toString ();
|
778
|
+
}
|
779
|
+
return year + '-' + month + '-01T00:00:00.000Z';
|
780
|
+
} else if (timeframe === '1w') {
|
781
|
+
timestamp = parseInt (timestamp / 1000);
|
782
|
+
const firstSunday = 259200; // 1970-01-04T00:00:00.000Z
|
783
|
+
const difference = timestamp - firstSunday;
|
784
|
+
const numWeeks = Math.floor (difference / duration);
|
785
|
+
let previousSunday = this.sum (firstSunday, numWeeks * duration);
|
786
|
+
if (after) {
|
787
|
+
previousSunday = this.sum (previousSunday, duration);
|
788
|
+
}
|
789
|
+
return this.iso8601 (previousSunday * 1000);
|
790
|
+
} else {
|
791
|
+
timestamp = parseInt (timestamp / 1000);
|
792
|
+
timestamp = duration * parseInt (timestamp / duration);
|
793
|
+
if (after) {
|
794
|
+
timestamp = this.sum (timestamp, duration);
|
795
|
+
}
|
796
|
+
return this.iso8601 (timestamp * 1000);
|
797
|
+
}
|
798
|
+
}
|
799
|
+
|
800
|
+
async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
801
|
+
await this.loadMarkets ();
|
802
|
+
const market = this.market (symbol);
|
803
|
+
const interval = this.timeframes[timeframe];
|
804
|
+
limit = (limit === undefined) ? 100 : limit;
|
805
|
+
let requestLimit = this.sum (limit, 1);
|
806
|
+
requestLimit = Math.min (1000, requestLimit); // max 1000
|
807
|
+
const request = {
|
808
|
+
'market_ids': market['id'],
|
809
|
+
'interval': interval,
|
810
|
+
'sort': 'asc', // 'asc' will always include the start_time, 'desc' will always include end_time
|
811
|
+
'limit': requestLimit, // max 1000
|
812
|
+
};
|
813
|
+
const now = this.milliseconds ();
|
814
|
+
const duration = this.parseTimeframe (timeframe);
|
815
|
+
let startTime = since;
|
816
|
+
let endTime = now;
|
817
|
+
if (since === undefined) {
|
818
|
+
if (limit === undefined) {
|
819
|
+
throw new ArgumentsRequired (this.id + ' fetchOHLCV() requires either a since argument or a limit argument');
|
820
|
+
} else {
|
821
|
+
startTime = now - limit * duration * 1000;
|
822
|
+
}
|
823
|
+
} else {
|
824
|
+
if (limit === undefined) {
|
825
|
+
endTime = now;
|
826
|
+
} else {
|
827
|
+
endTime = this.sum (since, this.sum (limit, 1) * duration * 1000);
|
828
|
+
}
|
829
|
+
}
|
830
|
+
const startTimeNormalized = this.normalizeOHLCVTimestamp (startTime, timeframe);
|
831
|
+
const endTimeNormalized = this.normalizeOHLCVTimestamp (endTime, timeframe, true);
|
832
|
+
request['start_time'] = startTimeNormalized;
|
833
|
+
request['end_time'] = endTimeNormalized;
|
834
|
+
const response = await this.publicGetCandle (this.extend (request, params));
|
835
|
+
//
|
836
|
+
// {
|
837
|
+
// "data":[
|
838
|
+
// {
|
839
|
+
// "market_id":"ETH-BTC",
|
840
|
+
// "open":"0.02811",
|
841
|
+
// "close":"0.02811",
|
842
|
+
// "low":"0.02811",
|
843
|
+
// "high":"0.02811",
|
844
|
+
// "base_volume":"0.0005",
|
845
|
+
// "quote_volume":"0.000014055",
|
846
|
+
// "start_time":"2018-11-30T18:19:00.000Z",
|
847
|
+
// "end_time":"2018-11-30T18:20:00.000Z"
|
848
|
+
// },
|
849
|
+
// ]
|
850
|
+
// }
|
851
|
+
//
|
852
|
+
const data = this.safeValue (response, 'data', []);
|
853
|
+
return this.parseOHLCVs (data, market, timeframe, since, limit);
|
854
|
+
}
|
855
|
+
|
856
|
+
parseOHLCV (ohlcv, market = undefined) {
|
857
|
+
//
|
858
|
+
// {
|
859
|
+
// "market_id":"ETH-BTC",
|
860
|
+
// "open":"0.02811",
|
861
|
+
// "close":"0.02811",
|
862
|
+
// "low":"0.02811",
|
863
|
+
// "high":"0.02811",
|
864
|
+
// "base_volume":"0.0005",
|
865
|
+
// "quote_volume":"0.000014055",
|
866
|
+
// "start_time":"2018-11-30T18:19:00.000Z",
|
867
|
+
// "end_time":"2018-11-30T18:20:00.000Z"
|
868
|
+
// }
|
869
|
+
//
|
870
|
+
return [
|
871
|
+
this.parse8601 (this.safeString (ohlcv, 'start_time')),
|
872
|
+
this.safeNumber (ohlcv, 'open'),
|
873
|
+
this.safeNumber (ohlcv, 'high'),
|
874
|
+
this.safeNumber (ohlcv, 'low'),
|
875
|
+
this.safeNumber (ohlcv, 'close'),
|
876
|
+
this.safeNumber (ohlcv, 'base_volume'),
|
877
|
+
];
|
878
|
+
}
|
879
|
+
|
880
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
881
|
+
await this.loadMarkets ();
|
882
|
+
since = this.parse8601 (since);
|
883
|
+
const request = {};
|
884
|
+
let market = undefined;
|
885
|
+
if (symbol !== undefined) {
|
886
|
+
market = this.market (symbol);
|
887
|
+
request['market_id'] = market['id'];
|
888
|
+
}
|
889
|
+
const response = await this.privateGetOpenOrder (this.extend (request, params));
|
890
|
+
const data = this.safeValue (response, 'data');
|
891
|
+
return this.parseOrders (data, market, since, limit);
|
892
|
+
}
|
893
|
+
|
894
|
+
async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
895
|
+
await this.loadMarkets ();
|
896
|
+
const request = {
|
897
|
+
'start_time': this.iso8601 (0),
|
898
|
+
'end_time': this.iso8601 (this.milliseconds ()),
|
899
|
+
'limit': 100,
|
900
|
+
};
|
901
|
+
let market = undefined;
|
902
|
+
if (symbol !== undefined) {
|
903
|
+
market = this.market (symbol);
|
904
|
+
request['market_id'] = market['id'];
|
905
|
+
}
|
906
|
+
if (since) {
|
907
|
+
request['start_time'] = this.iso8601 (since);
|
908
|
+
}
|
909
|
+
if (limit) {
|
910
|
+
request['limit'] = limit;
|
911
|
+
}
|
912
|
+
const response = await this.privateGetOrderHistory (this.extend (request, params));
|
913
|
+
const data = this.safeValue (response, 'data');
|
914
|
+
return this.parseOrders (data, market, since, limit);
|
915
|
+
}
|
916
|
+
|
917
|
+
async fetchOrder (id, symbol = undefined, params = {}) {
|
918
|
+
if (symbol === undefined) {
|
919
|
+
throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument');
|
920
|
+
}
|
921
|
+
await this.loadMarkets ();
|
922
|
+
const market = this.market (symbol);
|
923
|
+
const request = {
|
924
|
+
'market_id': market['id'],
|
925
|
+
};
|
926
|
+
const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_order_id');
|
927
|
+
if (clientOrderId !== undefined) {
|
928
|
+
request['client_order_id'] = clientOrderId;
|
929
|
+
} else {
|
930
|
+
request['order_id'] = id;
|
931
|
+
}
|
932
|
+
const query = this.omit (params, [ 'clientOrderId', 'client_order_id' ]);
|
933
|
+
const response = await this.privateGetOrder (this.extend (request, query));
|
934
|
+
const data = this.safeValue (response, 'data', []);
|
935
|
+
const order = this.safeValue (data, 0);
|
936
|
+
return this.parseOrder (order, market);
|
937
|
+
}
|
938
|
+
|
939
|
+
parseOrderStatus (status) {
|
940
|
+
const statuses = {
|
941
|
+
'open': 'open',
|
942
|
+
'cancelled': 'canceled',
|
943
|
+
'filled': 'closed',
|
944
|
+
};
|
945
|
+
return this.safeString (statuses, status, status);
|
946
|
+
}
|
947
|
+
|
948
|
+
parseOrder (order, market = undefined) {
|
949
|
+
//
|
950
|
+
// {
|
951
|
+
// id: string,
|
952
|
+
// user_id: string,
|
953
|
+
// market_id: string,
|
954
|
+
// type: 'orderType',
|
955
|
+
// side: 'side',
|
956
|
+
// quantity: string,
|
957
|
+
// limit_price: string,
|
958
|
+
// time_in_force: 'timeInForce',
|
959
|
+
// filled_cost: string,
|
960
|
+
// filled_quantity: string,
|
961
|
+
// open_quantity: string,
|
962
|
+
// cancelled_quantity: string,
|
963
|
+
// status: 'orderStatus',
|
964
|
+
// time: 'date',
|
965
|
+
// client_order_id: string,
|
966
|
+
// }
|
967
|
+
//
|
968
|
+
const status = this.parseOrderStatus (this.safeString (order, 'status'));
|
969
|
+
const id = this.safeString (order, 'id');
|
970
|
+
const type = this.safeString (order, 'type');
|
971
|
+
const side = this.safeString (order, 'side');
|
972
|
+
const marketId = this.safeString (order, 'market_id');
|
973
|
+
const symbol = this.safeSymbol (marketId, market, '-');
|
974
|
+
const timestamp = this.parse8601 (this.safeString (order, 'time'));
|
975
|
+
let price = this.safeString (order, 'limit_price');
|
976
|
+
const filled = this.safeString (order, 'filled_quantity');
|
977
|
+
let remaining = this.safeString (order, 'open_quantity');
|
978
|
+
const canceledAmount = this.safeString (order, 'cancelled_quantity');
|
979
|
+
if (canceledAmount !== undefined) {
|
980
|
+
remaining = Precise.stringAdd (remaining, canceledAmount);
|
981
|
+
}
|
982
|
+
const amount = this.safeString (order, 'quantity', Precise.stringAdd (filled, remaining));
|
983
|
+
const cost = this.safeString2 (order, 'filled_cost', 'cost');
|
984
|
+
if (type === 'market') {
|
985
|
+
price = undefined;
|
986
|
+
}
|
987
|
+
let clientOrderId = this.safeString (order, 'client_order_id');
|
988
|
+
if (clientOrderId === '') {
|
989
|
+
clientOrderId = undefined;
|
990
|
+
}
|
991
|
+
const timeInForce = this.safeStringUpper (order, 'time_in_force');
|
992
|
+
return this.safeOrder ({
|
993
|
+
'id': id,
|
994
|
+
'info': order,
|
995
|
+
'clientOrderId': clientOrderId,
|
996
|
+
'timestamp': timestamp,
|
997
|
+
'datetime': this.iso8601 (timestamp),
|
998
|
+
'lastTradeTimestamp': undefined,
|
999
|
+
'symbol': symbol,
|
1000
|
+
'type': type,
|
1001
|
+
'timeInForce': timeInForce,
|
1002
|
+
'side': side,
|
1003
|
+
'status': status,
|
1004
|
+
'price': price,
|
1005
|
+
'stopPrice': undefined,
|
1006
|
+
'amount': amount,
|
1007
|
+
'filled': filled,
|
1008
|
+
'remaining': remaining,
|
1009
|
+
'average': undefined,
|
1010
|
+
'cost': cost,
|
1011
|
+
'fee': undefined,
|
1012
|
+
'trades': undefined,
|
1013
|
+
}, market);
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
costToPrecision (symbol, cost) {
|
1017
|
+
return this.decimalToPrecision (cost, TRUNCATE, this.markets[symbol]['precision']['cost'], this.precisionMode);
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
1021
|
+
await this.loadMarkets ();
|
1022
|
+
const market = this.market (symbol);
|
1023
|
+
const options = this.safeValue (this.options, 'timeInForce');
|
1024
|
+
const defaultTimeInForce = this.safeValue (options, type);
|
1025
|
+
const timeInForce = this.safeString2 (params, 'timeInForce', 'time_in_force', defaultTimeInForce);
|
1026
|
+
const request = {
|
1027
|
+
'market_id': market['id'],
|
1028
|
+
'type': type,
|
1029
|
+
'side': side,
|
1030
|
+
'time_in_force': timeInForce,
|
1031
|
+
};
|
1032
|
+
const clientOrderId = this.safeString2 (params, 'clientOrderId', 'client_order_id');
|
1033
|
+
if (clientOrderId !== undefined) {
|
1034
|
+
request['client_order_id'] = clientOrderId;
|
1035
|
+
}
|
1036
|
+
let costToPrecision = undefined;
|
1037
|
+
if (type === 'limit') {
|
1038
|
+
request['limit_price'] = this.priceToPrecision (symbol, price);
|
1039
|
+
request['quantity'] = this.amountToPrecision (symbol, amount);
|
1040
|
+
} else if (type === 'market') {
|
1041
|
+
// for market buy it requires the amount of quote currency to spend
|
1042
|
+
if (side === 'buy') {
|
1043
|
+
let cost = this.safeNumber (params, 'cost');
|
1044
|
+
const createMarketBuyOrderRequiresPrice = this.safeValue (this.options, 'createMarketBuyOrderRequiresPrice', true);
|
1045
|
+
if (createMarketBuyOrderRequiresPrice) {
|
1046
|
+
if (price !== undefined) {
|
1047
|
+
if (cost === undefined) {
|
1048
|
+
cost = amount * price;
|
1049
|
+
}
|
1050
|
+
} else if (cost === undefined) {
|
1051
|
+
throw new InvalidOrder (this.id + " createOrder() requires the price argument for market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = false and supply the total cost value in the 'amount' argument or in the 'cost' extra parameter (the exchange-specific behaviour)");
|
1052
|
+
}
|
1053
|
+
} else {
|
1054
|
+
cost = (cost === undefined) ? amount : cost;
|
1055
|
+
}
|
1056
|
+
costToPrecision = this.costToPrecision (symbol, cost);
|
1057
|
+
request['cost'] = costToPrecision;
|
1058
|
+
} else {
|
1059
|
+
request['quantity'] = this.amountToPrecision (symbol, amount);
|
1060
|
+
}
|
1061
|
+
}
|
1062
|
+
const query = this.omit (params, [ 'timeInForce', 'time_in_force', 'clientOrderId', 'client_order_id' ]);
|
1063
|
+
const response = await this.privatePostNewOrder (this.extend (request, query));
|
1064
|
+
//
|
1065
|
+
// {
|
1066
|
+
// data: {
|
1067
|
+
// id: string,
|
1068
|
+
// user_id: string,
|
1069
|
+
// market_id: string,
|
1070
|
+
// type: 'orderType',
|
1071
|
+
// side: 'side',
|
1072
|
+
// quantity: string,
|
1073
|
+
// limit_price: string,
|
1074
|
+
// time_in_force: 'timeInForce',
|
1075
|
+
// filled_cost: string,
|
1076
|
+
// filled_quantity: string,
|
1077
|
+
// open_quantity: string,
|
1078
|
+
// cancelled_quantity: string,
|
1079
|
+
// status: 'orderStatus',
|
1080
|
+
// time: 'date',
|
1081
|
+
// client_order_id: string,
|
1082
|
+
// }
|
1083
|
+
// }
|
1084
|
+
//
|
1085
|
+
const data = this.safeValue (response, 'data');
|
1086
|
+
const order = this.parseOrder (data, market);
|
1087
|
+
// a workaround for incorrect huge amounts
|
1088
|
+
// returned by the exchange on market buys
|
1089
|
+
if ((type === 'market') && (side === 'buy')) {
|
1090
|
+
order['amount'] = undefined;
|
1091
|
+
order['cost'] = this.parseNumber (costToPrecision);
|
1092
|
+
order['remaining'] = undefined;
|
1093
|
+
}
|
1094
|
+
return order;
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
1098
|
+
if (symbol === undefined) {
|
1099
|
+
throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument');
|
1100
|
+
}
|
1101
|
+
await this.loadMarkets ();
|
1102
|
+
const market = this.market (symbol);
|
1103
|
+
const request = {
|
1104
|
+
'market_id': market['id'],
|
1105
|
+
'order_id': id,
|
1106
|
+
};
|
1107
|
+
const response = await this.privatePostCancelOrder (this.extend (request, params));
|
1108
|
+
const data = this.safeValue (response, 'data');
|
1109
|
+
return this.parseOrder (data);
|
1110
|
+
}
|
1111
|
+
|
1112
|
+
parseDepositAddress (depositAddress, currency = undefined) {
|
1113
|
+
const address = this.safeString (depositAddress, 'address');
|
1114
|
+
const tag = this.safeString (depositAddress, 'destination_tag');
|
1115
|
+
const currencyId = this.safeString (depositAddress, 'currency_id');
|
1116
|
+
const code = this.safeCurrencyCode (currencyId);
|
1117
|
+
this.checkAddress (address);
|
1118
|
+
return {
|
1119
|
+
'currency': code,
|
1120
|
+
'address': address,
|
1121
|
+
'tag': tag,
|
1122
|
+
'network': undefined,
|
1123
|
+
'info': depositAddress,
|
1124
|
+
};
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
async fetchDepositAddress (code, params = {}) {
|
1128
|
+
await this.loadMarkets ();
|
1129
|
+
const currency = this.currency (code);
|
1130
|
+
const request = {
|
1131
|
+
'currency_id': currency['id'],
|
1132
|
+
};
|
1133
|
+
const response = await this.privateGetDepositAddress (this.extend (request, params));
|
1134
|
+
//
|
1135
|
+
// {
|
1136
|
+
// "data":[
|
1137
|
+
// {
|
1138
|
+
// "currency_id":"ETH",
|
1139
|
+
// "address":"0x12e2caf3c4051ba1146e612f532901a423a9898a",
|
1140
|
+
// "destination_tag":null
|
1141
|
+
// }
|
1142
|
+
// ]
|
1143
|
+
// }
|
1144
|
+
//
|
1145
|
+
const data = this.safeValue (response, 'data', []);
|
1146
|
+
const firstAddress = this.safeValue (data, 0);
|
1147
|
+
if (firstAddress === undefined) {
|
1148
|
+
throw new InvalidAddress (this.id + ' fetchDepositAddress() returned an empty response');
|
1149
|
+
}
|
1150
|
+
return this.parseDepositAddress (firstAddress, currency);
|
1151
|
+
}
|
1152
|
+
|
1153
|
+
async fetchDepositAddresses (codes = undefined, params = {}) {
|
1154
|
+
await this.loadMarkets ();
|
1155
|
+
const request = {};
|
1156
|
+
if (codes) {
|
1157
|
+
const currencyIds = [];
|
1158
|
+
for (let i = 0; i < codes.length; i++) {
|
1159
|
+
const currency = this.currency (codes[i]);
|
1160
|
+
currencyIds.push (currency['id']);
|
1161
|
+
}
|
1162
|
+
request['currency_id'] = codes.join (',');
|
1163
|
+
}
|
1164
|
+
const response = await this.privateGetDepositAddress (this.extend (request, params));
|
1165
|
+
const data = this.safeValue (response, 'data', []);
|
1166
|
+
return this.parseDepositAddresses (data);
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
async withdraw (code, amount, address, tag = undefined, params = {}) {
|
1170
|
+
[ tag, params ] = this.handleWithdrawTagAndParams (tag, params);
|
1171
|
+
// In order to use this method
|
1172
|
+
// you need to allow API withdrawal from the API Settings Page, and
|
1173
|
+
// and register the list of withdrawal addresses and destination tags on the API Settings page
|
1174
|
+
// you can only withdraw to the registered addresses using the API
|
1175
|
+
this.checkAddress (address);
|
1176
|
+
await this.loadMarkets ();
|
1177
|
+
const currency = this.currency (code);
|
1178
|
+
if (tag === undefined) {
|
1179
|
+
tag = '';
|
1180
|
+
}
|
1181
|
+
const request = {
|
1182
|
+
'currency_id': currency['id'],
|
1183
|
+
// 'platform_id': 'ETH', // if omitted it will use the default platform for the currency
|
1184
|
+
'address': address,
|
1185
|
+
'destination_tag': tag,
|
1186
|
+
'amount': this.numberToString (amount),
|
1187
|
+
// which currency to pay the withdrawal fees
|
1188
|
+
// only applicable for currencies that accepts multiple withdrawal fee options
|
1189
|
+
// 'fee_currency_id': 'ETH', // if omitted it will use the default fee policy for each currency
|
1190
|
+
// whether the amount field includes fees
|
1191
|
+
// 'include_fee': false, // makes sense only when fee_currency_id is equal to currency_id
|
1192
|
+
};
|
1193
|
+
const networks = this.safeValue (this.options, 'networks', {});
|
1194
|
+
let network = this.safeStringUpper (params, 'network'); // this line allows the user to specify either ERC20 or ETH
|
1195
|
+
network = this.safeString (networks, network, network); // handle ERC20>ETH alias
|
1196
|
+
if (network !== undefined) {
|
1197
|
+
request['platform_id'] = network;
|
1198
|
+
params = this.omit (params, 'network');
|
1199
|
+
}
|
1200
|
+
const response = await this.privatePostWithdrawal (this.extend (request, params));
|
1201
|
+
const data = this.safeValue (response, 'data');
|
1202
|
+
return this.parseTransaction (data, currency);
|
1203
|
+
}
|
1204
|
+
|
1205
|
+
parseTransaction (transaction, currency = undefined) {
|
1206
|
+
const id = this.safeString (transaction, 'id');
|
1207
|
+
const amount = this.safeNumber (transaction, 'amount');
|
1208
|
+
const address = this.safeString (transaction, 'address');
|
1209
|
+
const tag = this.safeString (transaction, 'destination_tag');
|
1210
|
+
const txid = this.safeString (transaction, 'hash');
|
1211
|
+
const timestamp = this.parse8601 (this.safeString (transaction, 'time'));
|
1212
|
+
const type = this.safeString (transaction, 'type');
|
1213
|
+
const currencyId = this.safeString (transaction, 'currency_id');
|
1214
|
+
const code = this.safeCurrencyCode (currencyId);
|
1215
|
+
const status = this.parseTransactionStatus (this.safeString (transaction, 'status'));
|
1216
|
+
const feeCost = this.safeNumber (transaction, 'fee');
|
1217
|
+
let fee = undefined;
|
1218
|
+
if (feeCost !== undefined && feeCost !== 0) {
|
1219
|
+
fee = {
|
1220
|
+
'currency': code,
|
1221
|
+
'cost': feeCost,
|
1222
|
+
};
|
1223
|
+
}
|
1224
|
+
return {
|
1225
|
+
'id': id,
|
1226
|
+
'currency': code,
|
1227
|
+
'amount': amount,
|
1228
|
+
'network': undefined,
|
1229
|
+
'addressFrom': undefined,
|
1230
|
+
'address': address,
|
1231
|
+
'addressTo': address,
|
1232
|
+
'tagFrom': undefined,
|
1233
|
+
'tag': tag,
|
1234
|
+
'tagTo': tag,
|
1235
|
+
'status': status,
|
1236
|
+
'type': type,
|
1237
|
+
'txid': txid,
|
1238
|
+
'timestamp': timestamp,
|
1239
|
+
'datetime': this.iso8601 (timestamp),
|
1240
|
+
'updated': undefined,
|
1241
|
+
'fee': fee,
|
1242
|
+
'info': transaction,
|
1243
|
+
};
|
1244
|
+
}
|
1245
|
+
|
1246
|
+
parseTransactionStatus (status) {
|
1247
|
+
const statuses = {
|
1248
|
+
'requested': 'pending',
|
1249
|
+
'pending': 'pending',
|
1250
|
+
'confirming': 'pending',
|
1251
|
+
'confirmed': 'pending',
|
1252
|
+
'applying': 'pending',
|
1253
|
+
'done': 'ok',
|
1254
|
+
'cancelled': 'canceled',
|
1255
|
+
'cancelling': 'canceled',
|
1256
|
+
};
|
1257
|
+
return this.safeString (statuses, status, status);
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
nonce () {
|
1261
|
+
return this.milliseconds ();
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
1265
|
+
let url = this.urls['api'][api] + '/';
|
1266
|
+
const query = this.omit (params, this.extractParams (path));
|
1267
|
+
if (api === 'accounts') {
|
1268
|
+
this.checkRequiredCredentials ();
|
1269
|
+
url += this.implodeParams (path, params);
|
1270
|
+
const auth = this.apiKey + ':' + this.secret;
|
1271
|
+
const auth64 = this.stringToBase64 (auth);
|
1272
|
+
headers = {
|
1273
|
+
'Authorization': 'Basic ' + this.decode (auth64),
|
1274
|
+
'Content-Type': 'application/json',
|
1275
|
+
};
|
1276
|
+
if (Object.keys (query).length) {
|
1277
|
+
body = this.json (query);
|
1278
|
+
}
|
1279
|
+
} else {
|
1280
|
+
url += this.version + '/';
|
1281
|
+
if (api === 'public') {
|
1282
|
+
url += this.implodeParams (path, params);
|
1283
|
+
if (Object.keys (query).length) {
|
1284
|
+
url += '?' + this.urlencode (query);
|
1285
|
+
}
|
1286
|
+
} else if (api === 'private') {
|
1287
|
+
const now = this.milliseconds ();
|
1288
|
+
this.checkRequiredCredentials ();
|
1289
|
+
const expires = this.safeInteger (this.options, 'expires');
|
1290
|
+
if ((expires === undefined) || (expires < now)) {
|
1291
|
+
throw new AuthenticationError (this.id + ' access token expired, call signIn() method');
|
1292
|
+
}
|
1293
|
+
const accessToken = this.safeString (this.options, 'accessToken');
|
1294
|
+
headers = {
|
1295
|
+
'Authorization': 'Bearer ' + accessToken,
|
1296
|
+
};
|
1297
|
+
url += this.implodeParams (path, params);
|
1298
|
+
if (method === 'GET') {
|
1299
|
+
if (Object.keys (query).length) {
|
1300
|
+
url += '?' + this.urlencode (query);
|
1301
|
+
}
|
1302
|
+
} else if (Object.keys (query).length) {
|
1303
|
+
body = this.json (query);
|
1304
|
+
headers['Content-Type'] = 'application/json';
|
1305
|
+
}
|
1306
|
+
}
|
1307
|
+
}
|
1308
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
1309
|
+
}
|
1310
|
+
|
1311
|
+
async signIn (params = {}) {
|
1312
|
+
this.checkRequiredCredentials ();
|
1313
|
+
const request = {
|
1314
|
+
'grant_type': 'client_credentials', // the only supported value
|
1315
|
+
};
|
1316
|
+
const response = await this.accountsPostToken (this.extend (request, params));
|
1317
|
+
//
|
1318
|
+
// {
|
1319
|
+
// access_token: '0ttDv/2hTTn3bLi8GP1gKaneiEQ6+0hOBenPrxNQt2s=',
|
1320
|
+
// token_type: 'bearer',
|
1321
|
+
// expires_in: 900
|
1322
|
+
// }
|
1323
|
+
//
|
1324
|
+
const expiresIn = this.safeInteger (response, 'expires_in');
|
1325
|
+
const accessToken = this.safeString (response, 'access_token');
|
1326
|
+
this.options['accessToken'] = accessToken;
|
1327
|
+
this.options['expires'] = this.sum (this.milliseconds (), expiresIn * 1000);
|
1328
|
+
return response;
|
1329
|
+
}
|
1330
|
+
|
1331
|
+
handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
1332
|
+
if (response === undefined) {
|
1333
|
+
return; // fallback to default error handler
|
1334
|
+
}
|
1335
|
+
if ('errorCode' in response) {
|
1336
|
+
const errorCode = this.safeString (response, 'errorCode');
|
1337
|
+
const message = this.safeString (response, 'message');
|
1338
|
+
if (errorCode !== undefined) {
|
1339
|
+
const feedback = this.id + ' ' + body;
|
1340
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback);
|
1341
|
+
this.throwBroadlyMatchedException (this.exceptions['exact'], errorCode, feedback);
|
1342
|
+
throw new ExchangeError (feedback);
|
1343
|
+
}
|
1344
|
+
}
|
1345
|
+
}
|
1346
|
+
};
|